Lines Matching defs:ahd
58 static void ahd_set_tran_settings(struct ahd_softc *ahd,
61 static void ahd_get_tran_settings(struct ahd_softc *ahd,
69 static void ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
71 static void ahd_abort_ccb(struct ahd_softc *ahd, struct cam_sim *sim,
73 static int ahd_create_path(struct ahd_softc *ahd,
139 ahd_create_path(struct ahd_softc *ahd, char channel, u_int target,
144 path_id = cam_sim_path(ahd->platform_data->sim);
150 ahd_sysctl(struct ahd_softc *ahd)
155 sysctl_ctx_init(&ahd->sysctl_ctx[i]);
157 ahd->sysctl_tree[AHD_SYSCTL_ROOT] =
158 SYSCTL_ADD_NODE(&ahd->sysctl_ctx[AHD_SYSCTL_ROOT],
160 device_get_nameunit(ahd->dev_softc),
163 SYSCTL_ADD_PROC(&ahd->sysctl_ctx[AHD_SYSCTL_ROOT],
164 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_ROOT]), OID_AUTO,
165 "clear", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ahd,
169 ahd->sysctl_tree[i] =
170 SYSCTL_ADD_NODE(&ahd->sysctl_ctx[i],
171 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_ROOT]),
177 SYSCTL_ADD_UINT(&ahd->sysctl_ctx[AHD_SYSCTL_SUMMARY],
178 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_SUMMARY]),
180 CTLFLAG_RD, &ahd->summerr[i], i,
182 SYSCTL_ADD_PROC(&ahd->sysctl_ctx[AHD_SYSCTL_DEBUG],
183 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_DEBUG]),
185 CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_MPSAFE, ahd, i,
192 ahd_map_int(struct ahd_softc *ahd)
197 error = bus_setup_intr(ahd->dev_softc, ahd->platform_data->irq,
199 ahd_platform_intr, ahd, &ahd->platform_data->ih);
201 device_printf(ahd->dev_softc, "bus_setup_intr() failed: %d\n",
210 ahd_attach(struct ahd_softc *ahd)
227 if (ahd_spawn_recovery_thread(ahd) != 0)
230 ahd_controller_info(ahd, ahd_info);
232 ahd_lock(ahd);
244 sim = cam_sim_alloc(ahd_action, ahd_poll, "ahd", ahd,
245 device_get_unit(ahd->dev_softc),
246 &ahd->platform_data->mtx, 1, /*XXX*/256, devq);
252 if (xpt_bus_register(sim, ahd->dev_softc, /*bus_id*/0) != CAM_SUCCESS) {
277 ahd->platform_data->sim = sim;
278 ahd->platform_data->path = path;
279 ahd_unlock(ahd);
282 ahd->platform_data->eh =
284 ahd, SHUTDOWN_PRI_DEFAULT);
285 ahd_intr_enable(ahd, TRUE);
297 struct ahd_softc *ahd;
299 ahd = (struct ahd_softc *)arg;
300 ahd_lock(ahd);
301 ahd_intr(ahd);
302 ahd_unlock(ahd);
306 ahd_sync_ccb(struct ahd_softc *ahd, struct scb *scb, union ccb *ccb, bool post)
321 bus_dmamap_sync(ahd->buffer_dmat, scb->dmamap, op);
330 ahd_done(struct ahd_softc *ahd, struct scb *scb)
345 ahd_sync_ccb(ahd, scb, ccb, true);
346 bus_dmamap_unload(ahd->buffer_dmat, scb->dmamap);
360 if (ahd->pending_device != NULL
361 && xpt_path_comp(ahd->pending_device->path, ccb_path) == 0) {
363 ahd->pending_device = NULL;
374 ahd_free_scb(ahd, scb);
383 ahd->scb_data.recovery_scbs--;
389 if (ahd->scb_data.recovery_scbs == 0) {
396 &ahd->pending_scbs, pending_links) {
401 ahd_print_path(ahd, scb);
423 ahd_get_sense_buf(ahd, scb),
440 ahd_get_sense_buf(ahd, scb) + SIU_SENSE_OFFSET(siu),
457 ahd_free_scb(ahd, scb);
464 struct ahd_softc *ahd;
473 ahd = (struct ahd_softc *)cam_sim_softc(sim);
476 our_id = SIM_SCSI_ID(ahd, sim);
487 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate,
494 lstate = ahd->black_hole;
505 if ((ahd->flags & AHD_TQINFIFO_BLOCKED) != 0)
506 ahd_run_tqinfifo(ahd, /*paused*/FALSE);
529 if ((ahd->flags & AHD_INITIATORROLE) == 0
540 tinfo = ahd_fetch_transinfo(ahd, 'A', our_id,
550 if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {
552 ahd->flags |= AHD_RESOURCE_SHORTAGE;
572 hscb->scsiid = BUILD_SCSIID(ahd, sim, target_id, our_id);
586 if (ahd->pending_device == lstate)
606 ahd_setup_data(ahd, sim, &ccb->csio, scb);
618 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate,
629 ahd_send_lstate_events(ahd, lstate);
633 ahd_handle_en_lun(ahd, sim, ccb);
639 ahd_abort_ccb(ahd, sim, ccb);
644 ahd_set_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
645 SIM_CHANNEL(ahd, sim), &ccb->cts);
652 ahd_get_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
653 SIM_CHANNEL(ahd, sim), &ccb->cts);
659 aic_calc_geometry(&ccb->ccg, ahd->flags & AHD_EXTENDED_TRANS_A);
667 found = ahd_reset_channel(ahd, SIM_CHANNEL(ahd, sim),
670 xpt_print_path(SIM_PATH(ahd, sim));
689 if ((ahd->features & AHD_WIDE) != 0)
691 if ((ahd->features & AHD_TARGETMODE) != 0) {
700 cpi->max_target = (ahd->features & AHD_WIDE) ? 15 : 7;
702 cpi->initiator_id = ahd->our_id;
703 if ((ahd->flags & AHD_RESET_BUS_A) == 0) {
731 ahd_set_tran_settings(struct ahd_softc *ahd, int our_id, char channel,
745 ahd_compile_devinfo(&devinfo, SIM_SCSI_ID(ahd, sim),
748 SIM_CHANNEL(ahd, sim),
750 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
764 discenable = &ahd->user_discenable;
765 tagenable = &ahd->user_tagenable;
788 ahd_validate_width(ahd, /*tinfo limit*/NULL,
790 ahd_set_width(ahd, &devinfo, spi->bus_width,
827 ahd_find_syncrate(ahd, &spi->sync_period,
829 ahd_validate_offset(ahd, /*tinfo limit*/NULL,
839 ahd_set_syncrate(ahd, &devinfo, spi->sync_period,
847 ahd_get_tran_settings(struct ahd_softc *ahd, int our_id, char channel,
863 targ_info = ahd_fetch_transinfo(ahd, devinfo.channel,
875 if ((ahd->user_discenable & devinfo.target_mask) != 0)
878 if ((ahd->user_tagenable & devinfo.target_mask) != 0)
915 struct ahd_softc *ahd;
919 ahd = (struct ahd_softc *)cam_sim_softc(sim);
925 ahd_compile_devinfo(&devinfo, SIM_SCSI_ID(ahd, sim),
928 SIM_CHANNEL(ahd, sim),
935 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
937 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
953 struct ahd_softc *ahd;
960 ahd = scb->ahd_softc;
968 bus_dmamap_unload(ahd->buffer_dmat, scb->dmamap);
969 ahd_free_scb(ahd, scb);
980 sg = ahd_sg_setup(ahd, scb, sg, dm_segs->ds_addr,
986 ahd_sync_ccb(ahd, scb, ccb, false);
1006 bus_dmamap_unload(ahd->buffer_dmat,
1008 ahd_free_scb(ahd, scb);
1013 tinfo = ahd_fetch_transinfo(ahd, SCSIID_CHANNEL(ahd, scb->hscb->scsiid),
1015 SCSIID_TARGET(ahd, scb->hscb->scsiid),
1018 mask = SCB_GET_TARGET_MASK(ahd, scb);
1041 LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
1049 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
1050 ahd_pause(ahd);
1051 ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
1052 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
1053 ahd_unpause(ahd);
1055 ahd_queue_scb(ahd, scb);
1067 ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
1091 ahd_free_scb(ahd, scb);
1110 ahd_free_scb(ahd, scb);
1119 error = bus_dmamap_load_ccb(ahd->buffer_dmat,
1135 ahd_abort_ccb(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
1151 status = ahd_find_tmode_devs(ahd, sim, abort_ccb, &tstate,
1220 ahd_send_async(struct ahd_softc *ahd, char channel, u_int target,
1229 error = ahd_create_path(ahd, channel, target, lun, &path);
1244 ahd_get_tran_settings(ahd, ahd->our_id, channel, &cts);
1266 ahd_platform_set_tags(struct ahd_softc *ahd,
1272 ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg)
1274 ahd->platform_data = malloc(sizeof(struct ahd_platform_data), M_DEVBUF,
1276 if (ahd->platform_data == NULL)
1282 ahd_platform_free(struct ahd_softc *ahd)
1286 pdata = ahd->platform_data;
1289 bus_release_resource(ahd->dev_softc,
1295 bus_release_resource(ahd->dev_softc,
1301 bus_release_resource(ahd->dev_softc,
1313 free(ahd->platform_data, M_DEVBUF);
1327 struct ahd_softc *ahd;
1330 ahd = device_get_softc(dev);
1331 ahd_lock(ahd);
1332 TAILQ_REMOVE(&ahd_tailq, ahd, links);
1333 ahd_intr_enable(ahd, FALSE);
1334 bus_teardown_intr(dev, ahd->platform_data->irq, ahd->platform_data->ih);
1335 ahd_unlock(ahd);
1336 ahd_free(ahd);
1377 "ahd",
1542 DECLARE_MODULE(ahd, ahd_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
1543 MODULE_DEPEND(ahd, cam, 1, 1, 1);
1544 MODULE_VERSION(ahd, 1);