int tws_ioctl(struct dev_ioctl_args *ap) { cdev_t dev = ap->a_head.a_dev; u_long cmd = ap->a_cmd; caddr_t buf = ap->a_data; struct tws_softc *sc = (struct tws_softc *)(dev->si_drv1); int error; TWS_TRACE_DEBUG(sc, "entry", sc, cmd); sc->stats.ioctls++; switch(cmd) { case TWS_IOCTL_FIRMWARE_PASS_THROUGH : error = tws_passthru(sc, (void *)buf); break; case TWS_IOCTL_SCAN_BUS : TWS_TRACE_DEBUG(sc, "scan-bus", 0, 0); lockmgr(&sc->sim_lock, LK_EXCLUSIVE); error = tws_bus_scan(sc); lockmgr(&sc->sim_lock, LK_RELEASE); break; default : TWS_TRACE_DEBUG(sc, "ioctl-aen", cmd, buf); error = tws_ioctl_aen(sc, cmd, (void *)buf); break; } return(error); }
int tws_ioctl(struct cdev *dev, u_long cmd, caddr_t buf, int flags, d_thread_t *proc) { struct tws_softc *sc = (struct tws_softc *)(dev->si_drv1); int error; TWS_TRACE_DEBUG(sc, "entry", sc, cmd); sc->stats.ioctls++; switch(cmd) { case TWS_IOCTL_FIRMWARE_PASS_THROUGH : error = tws_passthru(sc, (void *)buf); break; case TWS_IOCTL_SCAN_BUS : TWS_TRACE_DEBUG(sc, "scan-bus", 0, 0); error = tws_bus_scan(sc); break; default : TWS_TRACE_DEBUG(sc, "ioctl-aen", cmd, buf); error = tws_ioctl_aen(sc, cmd, (void *)buf); break; } return(error); }
int tws_cam_attach(struct tws_softc *sc) { struct cam_devq *devq; int error; TWS_TRACE_DEBUG(sc, "entry", 0, sc); /* Create a device queue for sim */ /* * if the user sets cam depth to less than 1 * cam may get confused */ if ( tws_cam_depth < 1 ) tws_cam_depth = 1; if ( tws_cam_depth > (tws_queue_depth - TWS_RESERVED_REQS) ) tws_cam_depth = tws_queue_depth - TWS_RESERVED_REQS; TWS_TRACE_DEBUG(sc, "depths,ctlr,cam", tws_queue_depth, tws_cam_depth); if ((devq = cam_simq_alloc(tws_cam_depth)) == NULL) { tws_log(sc, CAM_SIMQ_ALLOC); return(ENOMEM); } /* * Create a SIM entry. Though we can support tws_cam_depth * simultaneous requests, we claim to be able to handle only * (tws_cam_depth), so that we always have reserved requests * packet available to service ioctls and internal commands. */ sc->sim = cam_sim_alloc(tws_action, tws_poll, "tws", sc, device_get_unit(sc->tws_dev), &sc->sim_lock, tws_cam_depth, 1, devq); /* 1, 1, devq); */ cam_simq_release(devq); if (sc->sim == NULL) { tws_log(sc, CAM_SIM_ALLOC); } /* Register the bus. */ lockmgr(&sc->sim_lock, LK_EXCLUSIVE); if (xpt_bus_register(sc->sim, 0) != CAM_SUCCESS) { cam_sim_free(sc->sim); sc->sim = NULL; /* so cam_detach will not try to free it */ lockmgr(&sc->sim_lock, LK_RELEASE); tws_log(sc, TWS_XPT_BUS_REGISTER); return(ENXIO); } if (xpt_create_path(&sc->path, NULL, cam_sim_path(sc->sim), CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { xpt_bus_deregister(cam_sim_path(sc->sim)); cam_sim_free(sc->sim); tws_log(sc, TWS_XPT_CREATE_PATH); lockmgr(&sc->sim_lock, LK_RELEASE); return(ENXIO); } if ((error = tws_bus_scan(sc))) { tws_log(sc, TWS_BUS_SCAN_REQ); lockmgr(&sc->sim_lock, LK_RELEASE); return(error); } lockmgr(&sc->sim_lock, LK_RELEASE); return(0); }