Lines Matching defs:cr

146 static int	ciss_start(struct ciss_request *cr);
153 static int _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_status, const char *func);
154 static int ciss_synch_request(struct ciss_request *cr, int timeout);
155 static int ciss_poll_request(struct ciss_request *cr, int timeout);
156 static int ciss_wait_request(struct ciss_request *cr, int timeout);
158 static int ciss_abort_request(struct ciss_request *cr);
163 static void ciss_preen_command(struct ciss_request *cr);
164 static void ciss_release_request(struct ciss_request *cr);
172 static int ciss_map_request(struct ciss_request *cr);
175 static void ciss_unmap_request(struct ciss_request *cr);
185 static void ciss_cam_complete(struct ciss_request *cr);
191 static void ciss_nop_complete(struct ciss_request *cr);
194 static void ciss_notify_complete(struct ciss_request *cr);
203 static void ciss_print_request(struct ciss_request *cr);
1060 struct ciss_request *cr;
1066 cr = NULL;
1078 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_FLUSH_CACHE,
1085 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1093 ciss_report_request(cr, &command_status, NULL);
1107 if (cr != NULL)
1108 ciss_release_request(cr);
1115 struct ciss_request *cr = NULL;
1124 if ((error = ciss_get_request(sc, &cr)) != 0)
1127 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_SOFT_RESET,
1131 cc = cr->cr_cc;
1134 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0)
1137 ciss_release_request(cr);
1143 if (cr != NULL)
1144 ciss_release_request(cr);
1157 struct ciss_request *cr;
1201 cr = &sc->ciss_request[i];
1202 cr->cr_sc = sc;
1203 cr->cr_tag = i;
1204 cr->cr_cc = (struct ciss_command *)((uintptr_t)sc->ciss_command +
1206 cr->cr_ccphys = sc->ciss_command_phys + CISS_COMMAND_ALLOC_SIZE * i;
1207 bus_dmamap_create(sc->ciss_buffer_dmat, 0, &cr->cr_datamap);
1208 ciss_enqueue_free(cr);
1228 struct ciss_request *cr;
1233 cr = NULL;
1238 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_CTLR,
1246 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1254 ciss_report_request(cr, &command_status, NULL);
1345 if (cr != NULL)
1346 ciss_release_request(cr);
1356 struct ciss_request *cr;
1366 cr = NULL;
1372 if ((error = ciss_get_request(sc, &cr)) != 0)
1384 cc = cr->cr_cc;
1385 cr->cr_data = cll;
1386 cr->cr_length = report_size;
1387 cr->cr_flags = CISS_REQ_DATAIN;
1408 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1416 ciss_report_request(cr, &command_status, NULL);
1431 ciss_release_request(cr);
1432 cr = NULL;
1435 if (cr != NULL)
1436 ciss_release_request(cr);
1703 struct ciss_request *cr;
1709 cr = NULL;
1713 if ((error = ciss_get_request(sc, &cr)) != 0)
1716 cc = cr->cr_cc;
1717 cr->cr_data = &ld->cl_geometry;
1718 cr->cr_length = sizeof(ld->cl_geometry);
1719 cr->cr_flags = CISS_REQ_DATAIN;
1734 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1739 ciss_report_request(cr, &command_status, NULL);
1754 if (cr != NULL)
1755 ciss_release_request(cr);
1764 struct ciss_request *cr;
1771 cr = NULL;
1776 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_LDRIVE,
1780 cc = cr->cr_cc;
1788 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1796 ciss_report_request(cr, &command_status, NULL);
1809 ciss_release_request(cr);
1810 cr = NULL;
1850 if (cr != NULL)
1851 ciss_release_request(cr);
1864 struct ciss_request *cr;
1872 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ID_LSTATUS,
1876 cc = cr->cr_cc;
1884 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1892 ciss_report_request(cr, &command_status, NULL);
1915 if (cr != NULL)
1916 ciss_release_request(cr);
1950 struct ciss_request *cr;
1963 if ((error = ciss_get_bmic_request(sc, &cr, CISS_BMIC_ACCEPT_MEDIA,
1966 cc = cr->cr_cc;
1974 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
1982 ciss_report_request(cr, &command_status, NULL);
1988 ciss_printf(cr->cr_sc, "error accepting media into failed logical drive (%s)\n",
1994 if (cr != NULL)
1995 ciss_release_request(cr);
2005 struct ciss_request *cr;
2069 while ((cr = ciss_dequeue_free(sc)) != NULL)
2070 bus_dmamap_destroy(sc->ciss_buffer_dmat, cr->cr_datamap);
2129 ciss_start(struct ciss_request *cr)
2133 debug(2, "post command %d tag %d ", cr->cr_tag, cr->cr_cc->header.host_tag);
2138 if ((error = ciss_map_request(cr)))
2142 ciss_print_request(cr);
2165 struct ciss_request *cr;
2186 cr = &(sc->ciss_request[index]);
2187 cc = cr->cr_cc;
2189 ciss_enqueue_complete(cr, qh);
2197 struct ciss_request *cr;
2215 cr = &(sc->ciss_request[index]);
2216 cc = cr->cr_cc;
2218 ciss_enqueue_complete(cr, qh);
2289 struct ciss_request *cr;
2298 if ((cr = ciss_dequeue_complete(sc, qh)) == NULL)
2300 ciss_unmap_request(cr);
2302 if ((cr->cr_flags & CISS_REQ_BUSY) == 0)
2304 cr->cr_flags &= ~CISS_REQ_BUSY;
2309 if (cr->cr_complete != NULL) {
2310 cr->cr_complete(cr);
2317 if (cr->cr_flags & CISS_REQ_SLEEP) {
2318 cr->cr_flags &= ~CISS_REQ_SLEEP;
2319 wakeup(cr);
2326 if (cr->cr_flags & CISS_REQ_POLL) {
2327 cr->cr_flags &= ~CISS_REQ_POLL;
2336 ciss_enqueue_free(cr);
2345 _ciss_report_request(struct ciss_request *cr, int *command_status, int *scsi_status, const char *func)
2352 cc = cr->cr_cc;
2394 ciss_printf(cr->cr_sc, "command status 0x%x (%s) scsi status 0x%x (opcode 0x%02x)\n",
2400 ciss_printf(cr->cr_sc, "invalid command, offense size %d at %d, value 0x%x, function %s\n",
2408 ciss_print_request(cr);
2420 ciss_synch_request(struct ciss_request *cr, int timeout)
2422 if (cr->cr_sc->ciss_flags & CISS_FLAG_RUNNING) {
2423 return(ciss_wait_request(cr, timeout));
2425 return(ciss_poll_request(cr, timeout));
2435 ciss_poll_request(struct ciss_request *cr, int timeout)
2444 sc = cr->cr_sc;
2445 cr->cr_flags |= CISS_REQ_POLL;
2446 if ((error = ciss_start(cr)) != 0)
2455 if (!(cr->cr_flags & CISS_REQ_POLL))
2469 ciss_wait_request(struct ciss_request *cr, int timeout)
2475 cr->cr_flags |= CISS_REQ_SLEEP;
2476 if ((error = ciss_start(cr)) != 0)
2479 while ((cr->cr_flags & CISS_REQ_SLEEP) && (error != EWOULDBLOCK)) {
2480 error = msleep_sbt(cr, &cr->cr_sc->ciss_mtx, PRIBIO, "cissREQ",
2494 struct ciss_request *cr;
2502 if ((error = ciss_get_request(ar->cr_sc, &cr)) != 0)
2506 cc = cr->cr_cc;
2526 error = ciss_synch_request(cr, 35 * 1000);
2528 error = ciss_report_request(cr, NULL, NULL);
2529 ciss_release_request(cr);
2541 struct ciss_request *cr;
2548 if ((cr = ciss_dequeue_free(sc)) == NULL)
2551 cr->cr_data = NULL;
2552 cr->cr_flags = 0;
2553 cr->cr_complete = NULL;
2554 cr->cr_private = NULL;
2555 cr->cr_sg_tag = CISS_SG_MAX; /* Backstop to prevent accidents */
2557 ciss_preen_command(cr);
2558 *crp = cr;
2563 ciss_preen_command(struct ciss_request *cr)
2574 cc = cr->cr_cc;
2577 cc->header.host_tag = cr->cr_tag << 2;
2580 cmdphys = cr->cr_ccphys;
2589 ciss_release_request(struct ciss_request *cr)
2595 ciss_requeue_free(cr);
2606 struct ciss_request *cr;
2615 cr = NULL;
2621 if ((error = ciss_get_request(sc, &cr)) != 0)
2643 cr->cr_data = buf;
2644 cr->cr_length = bufsize;
2646 cr->cr_flags = CISS_REQ_DATAIN;
2648 cc = cr->cr_cc;
2666 if (cr != NULL)
2667 ciss_release_request(cr);
2669 *crp = cr;
2682 struct ciss_request *cr;
2689 cr = NULL;
2694 while (ciss_get_request(sc, &cr) != 0)
2696 cc = cr->cr_cc;
2702 cr->cr_length = ioc->buf_size;
2704 if ((cr->cr_data = malloc(ioc->buf_size, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
2708 if ((error = copyin(ioc->buf, cr->cr_data, ioc->buf_size))) {
2726 if ((error = ciss_synch_request(cr, 60 * 1000))) {
2744 (error = copyout(cr->cr_data, ioc->buf, ioc->buf_size))) {
2756 if ((cr != NULL) && (cr->cr_data != NULL))
2757 free(cr->cr_data, CISS_MALLOC_CLASS);
2758 if (cr != NULL)
2759 ciss_release_request(cr);
2768 ciss_map_request(struct ciss_request *cr)
2775 sc = cr->cr_sc;
2778 if (cr->cr_flags & CISS_REQ_MAPPED)
2781 cr->cr_flags |= CISS_REQ_MAPPED;
2786 if (cr->cr_data != NULL) {
2787 if (cr->cr_flags & CISS_REQ_CCB)
2789 cr->cr_datamap, cr->cr_data,
2790 ciss_request_map_helper, cr, 0);
2792 error = bus_dmamap_load(sc->ciss_buffer_dmat, cr->cr_datamap,
2793 cr->cr_data, cr->cr_length,
2794 ciss_request_map_helper, cr, 0);
2801 cr->cr_sg_tag = CISS_SG_NONE;
2802 cr->cr_flags |= CISS_REQ_BUSY;
2804 CISS_TL_PERF_POST_CMD(sc, cr);
2806 CISS_TL_SIMPLE_POST_CMD(sc, cr->cr_ccphys);
2816 struct ciss_request *cr;
2822 cr = (struct ciss_request *)arg;
2823 sc = cr->cr_sc;
2824 cc = cr->cr_cc;
2835 if (cr->cr_flags & CISS_REQ_DATAIN)
2836 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_PREREAD);
2837 if (cr->cr_flags & CISS_REQ_DATAOUT)
2838 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_PREWRITE);
2841 cr->cr_sg_tag = CISS_SG_NONE;
2843 cr->cr_sg_tag = CISS_SG_1;
2845 cr->cr_sg_tag = CISS_SG_2;
2847 cr->cr_sg_tag = CISS_SG_4;
2849 cr->cr_sg_tag = CISS_SG_8;
2851 cr->cr_sg_tag = CISS_SG_16;
2853 cr->cr_sg_tag = CISS_SG_32;
2855 cr->cr_sg_tag = CISS_SG_MAX;
2860 cr->cr_flags |= CISS_REQ_BUSY;
2862 CISS_TL_PERF_POST_CMD(sc, cr);
2864 CISS_TL_SIMPLE_POST_CMD(sc, cr->cr_ccphys);
2871 ciss_unmap_request(struct ciss_request *cr)
2877 sc = cr->cr_sc;
2880 if ((cr->cr_flags & CISS_REQ_MAPPED) == 0)
2886 if (cr->cr_data == NULL)
2889 if (cr->cr_flags & CISS_REQ_DATAIN)
2890 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_POSTREAD);
2891 if (cr->cr_flags & CISS_REQ_DATAOUT)
2892 bus_dmamap_sync(sc->ciss_buffer_dmat, cr->cr_datamap, BUS_DMASYNC_POSTWRITE);
2894 bus_dmamap_unload(sc->ciss_buffer_dmat, cr->cr_datamap);
2896 cr->cr_flags &= ~CISS_REQ_MAPPED;
3159 struct ciss_request *cr;
3190 if ((error = ciss_get_request(sc, &cr)) != 0) {
3200 cc = cr->cr_cc;
3201 cr->cr_data = csio;
3202 cr->cr_length = csio->dxfer_len;
3203 cr->cr_complete = ciss_cam_complete;
3204 cr->cr_private = csio;
3219 cr->cr_flags = CISS_REQ_DATAOUT | CISS_REQ_CCB;
3222 cr->cr_flags = CISS_REQ_DATAIN | CISS_REQ_CCB;
3225 cr->cr_data = NULL;
3226 cr->cr_flags = 0;
3243 if ((error = ciss_start(cr)) != 0) {
3250 ciss_release_request(cr);
3346 ciss_cam_complete(struct ciss_request *cr)
3357 sc = cr->cr_sc;
3358 cc = cr->cr_cc;
3360 csio = (struct ccb_scsiio *)cr->cr_private;
3365 ciss_report_request(cr, &command_status, &scsi_status);
3397 ciss_release_request(cr);
3495 struct ciss_request *cr = NULL;
3524 if (ciss_nop_message_heartbeat != 0 && (error = ciss_get_request(sc, &cr)) == 0) {
3525 cc = cr->cr_cc;
3526 cr->cr_complete = ciss_nop_complete;
3534 if ((error = ciss_start(cr)) != 0) {
3555 ciss_nop_complete(struct ciss_request *cr)
3560 sc = cr->cr_sc;
3561 if (ciss_report_request(cr, NULL, NULL) != 0) {
3568 ciss_release_request(cr);
3581 struct ciss_request *cr;
3592 cr = &sc->ciss_request[i];
3593 if ((cr->cr_flags & CISS_REQ_BUSY) == 0)
3596 cc = cr->cr_cc;
3599 ciss_enqueue_complete(cr, &qh);
3603 if ((cr = ciss_dequeue_complete(sc, &qh)) == NULL)
3609 if (cr->cr_complete != NULL) {
3610 cr->cr_complete(cr);
3617 if (cr->cr_flags & CISS_REQ_SLEEP) {
3618 cr->cr_flags &= ~CISS_REQ_SLEEP;
3619 wakeup(cr);
3628 * If (cr) is NULL, this is the first request of the adapter, so
3635 struct ciss_request *cr;
3642 cr = sc->ciss_periodic_notify;
3645 if (cr == NULL) {
3646 if ((error = ciss_get_request(sc, &cr)) != 0) {
3650 sc->ciss_periodic_notify = cr;
3651 cr->cr_complete = ciss_notify_complete;
3652 debug(1, "acquired request %d", cr->cr_tag);
3660 if (cr->cr_data == NULL) {
3661 if ((cr->cr_data = malloc(CISS_NOTIFY_DATA_SIZE, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
3666 cr->cr_length = CISS_NOTIFY_DATA_SIZE;
3670 ciss_preen_command(cr);
3673 cc = cr->cr_cc;
3685 bzero(cr->cr_data, CISS_NOTIFY_DATA_SIZE);
3699 error = ciss_start(cr);
3703 if (cr != NULL) {
3704 if (cr->cr_data != NULL)
3705 free(cr->cr_data, CISS_MALLOC_CLASS);
3706 ciss_release_request(cr);
3718 ciss_notify_complete(struct ciss_request *cr)
3726 cn = (struct ciss_notify *)cr->cr_data;
3727 sc = cr->cr_sc;
3732 ciss_report_request(cr, &command_status, &scsi_status);
3744 ciss_release_request(cr);
3767 ciss_release_request(cr);
3772 ciss_enqueue_notify(cr);
3798 struct ciss_request *cr;
3805 cr = NULL;
3813 if ((error = ciss_get_request(sc, &cr)))
3817 if ((cr->cr_data = malloc(CISS_NOTIFY_DATA_SIZE, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) {
3822 cr->cr_length = CISS_NOTIFY_DATA_SIZE;
3825 cc = cr->cr_cc;
3841 ciss_print_request(cr);
3847 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
3855 ciss_report_request(cr, &command_status, &scsi_status);
3906 if (cr != NULL) {
3907 if (cr->cr_data != NULL)
3908 free(cr->cr_data, CISS_MALLOC_CLASS);
3909 ciss_release_request(cr);
3922 struct ciss_request *cr;
3927 cr = NULL;
3939 if ((error = ciss_get_bmic_request(sc, &cr, CISS_COMMAND_ABORT_NOTIFY,
3946 if ((error = ciss_synch_request(cr, 60 * 1000)) != 0) {
3954 ciss_report_request(cr, &command_status, NULL);
3966 if (cr != NULL)
3967 ciss_release_request(cr);
4193 struct ciss_request *cr;
4208 cr = ciss_dequeue_notify(sc);
4210 if (cr == NULL) {
4224 cn = (struct ciss_notify *)cr->cr_data;
4238 ciss_release_request(cr);
4280 ciss_print_request(struct ciss_request *cr)
4286 sc = cr->cr_sc;
4287 cc = cr->cr_cc;
4289 ciss_printf(sc, "REQUEST @ %p\n", cr);
4291 cr->cr_data, cr->cr_length, cr->cr_tag, cr->cr_flags,
4636 union ciss_statrequest *cr = (union ciss_statrequest *)addr;
4638 switch (cr->cs_item) {
4641 bcopy(&sc->ciss_qstat[cr->cs_item], &cr->cs_qstat,