Lines Matching refs:cr

142 static int	ciss_start(struct ciss_request *cr);
149 static int _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_status, const char *func);
150 static int ciss_synch_request(struct ciss_request *cr, int timeout);
151 static int ciss_poll_request(struct ciss_request *cr, int timeout);
152 static int ciss_wait_request(struct ciss_request *cr, int timeout);
154 static int ciss_abort_request(struct ciss_request *cr);
159 static void ciss_preen_command(struct ciss_request *cr);
160 static void ciss_release_request(struct ciss_request *cr);
168 static int ciss_map_request(struct ciss_request *cr);
171 static void ciss_unmap_request(struct ciss_request *cr);
181 static void ciss_cam_complete(struct ciss_request *cr);
187 static void ciss_nop_complete(struct ciss_request *cr);
190 static void ciss_notify_complete(struct ciss_request *cr);
198 static void ciss_print_request(struct ciss_request *cr);
1014 struct ciss_request *cr;
1020 cr = NULL;
1032 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_FLUSH_CACHE,
1039 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1047 ciss_report_request(cr, &command_status, NULL);
1061 if (cr != NULL)
1062 ciss_release_request(cr);
1069 struct ciss_request *cr = NULL;
1078 if ((error = ciss_get_request(sc, &cr)) != 0)
1081 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_SOFT_RESET,
1085 cc = cr->cr_cc;
1088 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0)
1091 ciss_release_request(cr);
1097 if (cr != NULL)
1098 ciss_release_request(cr);
1111 struct ciss_request *cr;
1155 cr = &sc->ciss_request[i];
1156 cr->cr_sc = sc;
1157 cr->cr_tag = i;
1158 cr->cr_cc = (struct ciss_command *)((uintptr_t)sc->ciss_command +
1160 cr->cr_ccphys = sc->ciss_command_phys + CISS_COMMAND_ALLOC_SIZE * i;
1161 bus_dmamap_create(sc->ciss_buffer_dmat, 0, &cr->cr_datamap);
1162 ciss_enqueue_free(cr);
1182 struct ciss_request *cr;
1187 cr = NULL;
1192 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_CTLR,
1200 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1208 ciss_report_request(cr, &command_status, NULL);
1286 if (cr != NULL)
1287 ciss_release_request(cr);
1297 struct ciss_request *cr;
1307 cr = NULL;
1313 if ((error = ciss_get_request(sc, &cr)) != 0)
1325 cc = cr->cr_cc;
1326 cr->cr_data = cll;
1327 cr->cr_length = report_size;
1328 cr->cr_flags = CISS_REQ_DATAIN;
1349 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1357 ciss_report_request(cr, &command_status, NULL);
1372 ciss_release_request(cr);
1373 cr = NULL;
1376 if (cr != NULL)
1377 ciss_release_request(cr);
1638 struct ciss_request *cr;
1644 cr = NULL;
1648 if ((error = ciss_get_request(sc, &cr)) != 0)
1651 cc = cr->cr_cc;
1652 cr->cr_data = &ld->cl_geometry;
1653 cr->cr_length = sizeof(ld->cl_geometry);
1654 cr->cr_flags = CISS_REQ_DATAIN;
1669 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1674 ciss_report_request(cr, &command_status, NULL);
1689 if (cr != NULL)
1690 ciss_release_request(cr);
1699 struct ciss_request *cr;
1706 cr = NULL;
1711 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_LDRIVE,
1715 cc = cr->cr_cc;
1723 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1731 ciss_report_request(cr, &command_status, NULL);
1744 ciss_release_request(cr);
1745 cr = NULL;
1785 if (cr != NULL)
1786 ciss_release_request(cr);
1799 struct ciss_request *cr;
1807 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_LSTATUS,
1811 cc = cr->cr_cc;
1819 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1827 ciss_report_request(cr, &command_status, NULL);
1850 if (cr != NULL)
1851 ciss_release_request(cr);
1885 struct ciss_request *cr;
1898 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ACCEPT_MEDIA,
1901 cc = cr->cr_cc;
1909 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1917 ciss_report_request(cr, &command_status, NULL);
1923 ciss_printf(cr->cr_sc, "error accepting media into failed logical drive (%s)\n",
1929 if (cr != NULL)
1930 ciss_release_request(cr);
1940 struct ciss_request *cr;
2004 while ((cr = ciss_dequeue_free(sc)) != NULL)
2005 bus_dmamap_destroy(sc->ciss_buffer_dmat, cr->cr_datamap);
2064 ciss_start(struct ciss_request *cr)
2069 cc = cr->cr_cc;
2070 debug(2, "post command %d tag %d ", cr->cr_tag, cc->header.host_tag);
2075 if ((error = ciss_map_request(cr)))
2079 ciss_print_request(cr);
2102 struct ciss_request *cr;
2124 cr = &(sc->ciss_request[index]);
2125 cc = cr->cr_cc;
2127 ciss_enqueue_complete(cr, qh);
2135 struct ciss_request *cr;
2153 cr = &(sc->ciss_request[index]);
2154 cc = cr->cr_cc;
2156 ciss_enqueue_complete(cr, qh);
2228 struct ciss_request *cr;
2237 if ((cr = ciss_dequeue_complete(sc, qh)) == NULL)
2239 ciss_unmap_request(cr);
2241 if ((cr->cr_flags & CISS_REQ_BUSY) == 0)
2243 cr->cr_flags &= ~CISS_REQ_BUSY;
2248 if (cr->cr_complete != NULL) {
2249 cr->cr_complete(cr);
2256 if (cr->cr_flags & CISS_REQ_SLEEP) {
2257 cr->cr_flags &= ~CISS_REQ_SLEEP;
2258 wakeup(cr);
2265 if (cr->cr_flags & CISS_REQ_POLL) {
2266 cr->cr_flags &= ~CISS_REQ_POLL;
2275 ciss_enqueue_free(cr);
2284 _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_status, const char *func)
2291 cc = cr->cr_cc;
2329 ciss_printf(cr->cr_sc, "command status 0x%x (%s) scsi status 0x%x\n",
2333 ciss_printf(cr->cr_sc, "invalid command, offense size %d at %d, value 0x%x, function %s\n",
2341 ciss_print_request(cr);
2353 ciss_synch_request(struct ciss_request *cr, int timeout)
2355 if (cr->cr_sc->ciss_flags & CISS_FLAG_RUNNING) {
2356 return(ciss_wait_request(cr, timeout));
2358 return(ciss_poll_request(cr, timeout));
2368 ciss_poll_request(struct ciss_request *cr, int timeout)
2377 sc = cr->cr_sc;
2378 cr->cr_flags |= CISS_REQ_POLL;
2379 if ((error = ciss_start(cr)) != 0)
2388 if (!(cr->cr_flags & CISS_REQ_POLL))
2402 ciss_wait_request(struct ciss_request *cr, int timeout)
2408 cr->cr_flags |= CISS_REQ_SLEEP;
2409 if ((error = ciss_start(cr)) != 0)
2412 while ((cr->cr_flags & CISS_REQ_SLEEP) && (error != EWOULDBLOCK)) {
2413 error = msleep(cr, &cr->cr_sc->ciss_mtx, PRIBIO, "cissREQ", (timeout * hz) / 1000);
2426 struct ciss_request *cr;
2434 if ((error = ciss_get_request(ar->cr_sc, &cr)) != 0)
2438 cc = cr->cr_cc;
2458 error = ciss_synch_request(cr, 35 * 1000);
2460 error = ciss_report_request(cr, NULL, NULL);
2461 ciss_release_request(cr);
2474 struct ciss_request *cr;
2481 if ((cr = ciss_dequeue_free(sc)) == NULL)
2484 cr->cr_data = NULL;
2485 cr->cr_flags = 0;
2486 cr->cr_complete = NULL;
2487 cr->cr_private = NULL;
2488 cr->cr_sg_tag = CISS_SG_MAX; /* Backstop to prevent accidents */
2490 ciss_preen_command(cr);
2491 *crp = cr;
2496 ciss_preen_command(struct ciss_request *cr)
2507 cc = cr->cr_cc;
2510 cc->header.host_tag = cr->cr_tag << 2;
2513 cmdphys = cr->cr_ccphys;
2522 ciss_release_request(struct ciss_request *cr)
2528 sc = cr->cr_sc;
2531 ciss_requeue_free(cr);
2542 struct ciss_request *cr;
2551 cr = NULL;
2557 if ((error = ciss_get_request(sc, &cr)) != 0)
2579 cr->cr_data = buf;
2580 cr->cr_length = bufsize;
2582 cr->cr_flags = CISS_REQ_DATAIN;
2584 cc = cr->cr_cc;
2602 if (cr != NULL)
2603 ciss_release_request(cr);
2605 *crp = cr;
2618 struct ciss_request *cr;
2625 cr = NULL;
2630 while (ciss_get_request(sc, &cr) != 0)
2632 cc = cr->cr_cc;
2638 cr->cr_length = ioc->buf_size;
2640 if ((cr->cr_data = malloc(ioc->buf_size, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
2644 if ((error = copyin(ioc->buf, cr->cr_data, ioc->buf_size))) {
2662 if ((error = ciss_synch_request(cr, 60 * 1000))) {
2680 (error = copyout(cr->cr_data, ioc->buf, ioc->buf_size))) {
2692 if ((cr != NULL) && (cr->cr_data != NULL))
2693 free(cr->cr_data, CISS_MALLOC_CLASS);
2694 if (cr != NULL)
2695 ciss_release_request(cr);
2704 ciss_map_request(struct ciss_request *cr)
2711 sc = cr->cr_sc;
2714 if (cr->cr_flags & CISS_REQ_MAPPED)
2717 cr->cr_flags |= CISS_REQ_MAPPED;
2722 if (cr->cr_data != NULL) {
2723 if (cr->cr_flags & CISS_REQ_CCB)
2725 cr->cr_datamap, cr->cr_data,
2726 ciss_request_map_helper, cr, 0);
2728 error = bus_dmamap_load(sc->ciss_buffer_dmat, cr->cr_datamap,
2729 cr->cr_data, cr->cr_length,
2730 ciss_request_map_helper, cr, 0);
2737 cr->cr_sg_tag = CISS_SG_NONE;
2738 cr->cr_flags |= CISS_REQ_BUSY;
2740 CISS_TL_PERF_POST_CMD(sc, cr);
2742 CISS_TL_SIMPLE_POST_CMD(sc, cr->cr_ccphys);
2752 struct ciss_request *cr;
2758 cr = (struct ciss_request *)arg;
2759 sc = cr->cr_sc;
2760 cc = cr->cr_cc;
2771 if (cr->cr_flags & CISS_REQ_DATAIN)
2772 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_PREREAD);
2773 if (cr->cr_flags & CISS_REQ_DATAOUT)
2774 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_PREWRITE);
2777 cr->cr_sg_tag = CISS_SG_NONE;
2779 cr->cr_sg_tag = CISS_SG_1;
2781 cr->cr_sg_tag = CISS_SG_2;
2783 cr->cr_sg_tag = CISS_SG_4;
2785 cr->cr_sg_tag = CISS_SG_8;
2787 cr->cr_sg_tag = CISS_SG_16;
2789 cr->cr_sg_tag = CISS_SG_32;
2791 cr->cr_sg_tag = CISS_SG_MAX;
2796 cr->cr_flags |= CISS_REQ_BUSY;
2798 CISS_TL_PERF_POST_CMD(sc, cr);
2800 CISS_TL_SIMPLE_POST_CMD(sc, cr->cr_ccphys);
2807 ciss_unmap_request(struct ciss_request *cr)
2813 sc = cr->cr_sc;
2816 if ((cr->cr_flags & CISS_REQ_MAPPED) == 0)
2822 if (cr->cr_data == NULL)
2825 if (cr->cr_flags & CISS_REQ_DATAIN)
2826 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_POSTREAD);
2827 if (cr->cr_flags & CISS_REQ_DATAOUT)
2828 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_POSTWRITE);
2830 bus_dmamap_unload(sc->ciss_buffer_dmat, cr->cr_datamap);
2832 cr->cr_flags &= ~CISS_REQ_MAPPED;
3096 struct ciss_request *cr;
3127 if ((error = ciss_get_request(sc, &cr)) != 0) {
3137 cc = cr->cr_cc;
3138 cr->cr_data = csio;
3139 cr->cr_length = csio->dxfer_len;
3140 cr->cr_complete = ciss_cam_complete;
3141 cr->cr_private = csio;
3156 cr->cr_flags = CISS_REQ_DATAOUT | CISS_REQ_CCB;
3159 cr->cr_flags = CISS_REQ_DATAIN | CISS_REQ_CCB;
3162 cr->cr_data = NULL;
3163 cr->cr_flags = 0;
3180 if ((error = ciss_start(cr)) != 0) {
3187 ciss_release_request(cr);
3283 ciss_cam_complete(struct ciss_request *cr)
3294 sc = cr->cr_sc;
3295 cc = cr->cr_cc;
3297 csio = (struct ccb_scsiio *)cr->cr_private;
3302 ciss_report_request(cr, &command_status, &scsi_status);
3356 ciss_release_request(cr);
3451 struct ciss_request *cr = NULL;
3480 if (ciss_nop_message_heartbeat != 0 && (error = ciss_get_request(sc, &cr)) == 0) {
3481 cc = cr->cr_cc;
3482 cr->cr_complete = ciss_nop_complete;
3490 if ((error = ciss_start(cr)) != 0) {
3511 ciss_nop_complete(struct ciss_request *cr)
3516 sc = cr->cr_sc;
3517 if (ciss_report_request(cr, NULL, NULL) != 0) {
3524 ciss_release_request(cr);
3537 struct ciss_request *cr;
3547 cr = &sc->ciss_request[i];
3548 if ((cr->cr_flags & CISS_REQ_BUSY) == 0)
3551 cc = cr->cr_cc;
3554 ciss_enqueue_complete(cr, &qh);
3558 if ((cr = ciss_dequeue_complete(sc, &qh)) == NULL)
3564 if (cr->cr_complete != NULL) {
3565 cr->cr_complete(cr);
3572 if (cr->cr_flags & CISS_REQ_SLEEP) {
3573 cr->cr_flags &= ~CISS_REQ_SLEEP;
3574 wakeup(cr);
3583 * If (cr) is NULL, this is the first request of the adapter, so
3590 struct ciss_request *cr;
3597 cr = sc->ciss_periodic_notify;
3600 if (cr == NULL) {
3601 if ((error = ciss_get_request(sc, &cr)) != 0) {
3605 sc->ciss_periodic_notify = cr;
3606 cr->cr_complete = ciss_notify_complete;
3607 debug(1, "acquired request %d", cr->cr_tag);
3615 if (cr->cr_data == NULL) {
3616 if ((cr->cr_data = malloc(CISS_NOTIFY_DATA_SIZE, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
3621 cr->cr_length = CISS_NOTIFY_DATA_SIZE;
3625 ciss_preen_command(cr);
3628 cc = cr->cr_cc;
3640 bzero(cr->cr_data, CISS_NOTIFY_DATA_SIZE);
3654 error = ciss_start(cr);
3658 if (cr != NULL) {
3659 if (cr->cr_data != NULL)
3660 free(cr->cr_data, CISS_MALLOC_CLASS);
3661 ciss_release_request(cr);
3673 ciss_notify_complete(struct ciss_request *cr)
3682 cc = cr->cr_cc;
3683 cn = (struct ciss_notify *)cr->cr_data;
3684 sc = cr->cr_sc;
3689 ciss_report_request(cr, &command_status, &scsi_status);
3701 ciss_release_request(cr);
3724 ciss_release_request(cr);
3729 ciss_enqueue_notify(cr);
3755 struct ciss_request *cr;
3762 cr = NULL;
3770 if ((error = ciss_get_request(sc, &cr)))
3774 if ((cr->cr_data = malloc(CISS_NOTIFY_DATA_SIZE, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
3779 cr->cr_length = CISS_NOTIFY_DATA_SIZE;
3782 cc = cr->cr_cc;
3798 ciss_print_request(cr);
3803 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
3811 ciss_report_request(cr, &command_status, &scsi_status);
3862 if (cr != NULL) {
3863 if (cr->cr_data != NULL)
3864 free(cr->cr_data, CISS_MALLOC_CLASS);
3865 ciss_release_request(cr);
3878 struct ciss_request *cr;
3883 cr = NULL;
3895 if ((error = ciss_get_bmic_request(sc, &cr, CISS_COMMAND_ABORT_NOTIFY,
3902 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
3910 ciss_report_request(cr, &command_status, NULL);
3922 if (cr != NULL)
3923 ciss_release_request(cr);
4151 struct ciss_request *cr;
4168 cr = ciss_dequeue_notify(sc);
4170 if (cr == NULL)
4171 panic("cr null");
4172 cn = (struct ciss_notify *)cr->cr_data;
4186 ciss_release_request(cr);
4236 ciss_print_request(struct ciss_request *cr)
4242 sc = cr->cr_sc;
4243 cc = cr->cr_cc;
4245 ciss_printf(sc, "REQUEST @ %p\n", cr);
4247 cr->cr_data, cr->cr_length, cr->cr_tag, cr->cr_flags,
4589 union ciss_statrequest *cr = (union ciss_statrequest *)addr;
4591 switch (cr->cs_item) {
4594 bcopy(&sc->ciss_qstat[cr->cs_item], &cr->cs_qstat,