tws_cam.c (263125) | tws_cam.c (275977) |
---|---|
1/* 2 * Copyright (c) 2010 LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah <manjunath.ranganathaiah@lsi.com> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/* 2 * Copyright (c) 2010 LSI Corp. 3 * All rights reserved. 4 * Author : Manjunath Ranganathaiah <manjunath.ranganathaiah@lsi.com> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: stable/10/sys/dev/tws/tws_cam.c 263125 2014-03-14 00:57:32Z delphij $ | 27 * $FreeBSD: stable/10/sys/dev/tws/tws_cam.c 275977 2014-12-21 02:39:10Z smh $ |
28 */ 29 30#include <dev/tws/tws.h> 31#include <dev/tws/tws_services.h> 32#include <dev/tws/tws_hdm.h> 33#include <dev/tws/tws_user.h> 34#include <cam/cam.h> 35#include <cam/cam_ccb.h> --- 300 unchanged lines hidden (view full) --- 336tws_scsi_complete(struct tws_request *req) 337{ 338 struct tws_softc *sc = req->sc; 339 340 mtx_lock(&sc->q_lock); 341 tws_q_remove_request(sc, req, TWS_BUSY_Q); 342 mtx_unlock(&sc->q_lock); 343 | 28 */ 29 30#include <dev/tws/tws.h> 31#include <dev/tws/tws_services.h> 32#include <dev/tws/tws_hdm.h> 33#include <dev/tws/tws_user.h> 34#include <cam/cam.h> 35#include <cam/cam_ccb.h> --- 300 unchanged lines hidden (view full) --- 336tws_scsi_complete(struct tws_request *req) 337{ 338 struct tws_softc *sc = req->sc; 339 340 mtx_lock(&sc->q_lock); 341 tws_q_remove_request(sc, req, TWS_BUSY_Q); 342 mtx_unlock(&sc->q_lock); 343 |
344 untimeout(tws_timeout, req, req->thandle); | 344 callout_stop(&req->timeout); |
345 tws_unmap_request(req->sc, req); 346 347 348 req->ccb_ptr->ccb_h.status = CAM_REQ_CMP; 349 mtx_lock(&sc->sim_lock); 350 xpt_done(req->ccb_ptr); 351 mtx_unlock(&sc->sim_lock); 352 --- 4 unchanged lines hidden (view full) --- 357 358void 359tws_getset_param_complete(struct tws_request *req) 360{ 361 struct tws_softc *sc = req->sc; 362 363 TWS_TRACE_DEBUG(sc, "getset complete", req, req->request_id); 364 | 345 tws_unmap_request(req->sc, req); 346 347 348 req->ccb_ptr->ccb_h.status = CAM_REQ_CMP; 349 mtx_lock(&sc->sim_lock); 350 xpt_done(req->ccb_ptr); 351 mtx_unlock(&sc->sim_lock); 352 --- 4 unchanged lines hidden (view full) --- 357 358void 359tws_getset_param_complete(struct tws_request *req) 360{ 361 struct tws_softc *sc = req->sc; 362 363 TWS_TRACE_DEBUG(sc, "getset complete", req, req->request_id); 364 |
365 untimeout(tws_timeout, req, req->thandle); | 365 callout_stop(&req->timeout); |
366 tws_unmap_request(sc, req); 367 368 free(req->data, M_TWS); 369 370 req->state = TWS_REQ_STATE_FREE; 371} 372 373void 374tws_aen_complete(struct tws_request *req) 375{ 376 struct tws_softc *sc = req->sc; 377 struct tws_command_header *sense; 378 struct tws_event_packet event; 379 u_int16_t aen_code=0; 380 381 TWS_TRACE_DEBUG(sc, "aen complete", 0, req->request_id); 382 | 366 tws_unmap_request(sc, req); 367 368 free(req->data, M_TWS); 369 370 req->state = TWS_REQ_STATE_FREE; 371} 372 373void 374tws_aen_complete(struct tws_request *req) 375{ 376 struct tws_softc *sc = req->sc; 377 struct tws_command_header *sense; 378 struct tws_event_packet event; 379 u_int16_t aen_code=0; 380 381 TWS_TRACE_DEBUG(sc, "aen complete", 0, req->request_id); 382 |
383 untimeout(tws_timeout, req, req->thandle); | 383 callout_stop(&req->timeout); |
384 tws_unmap_request(sc, req); 385 386 sense = (struct tws_command_header *)req->data; 387 388 TWS_TRACE_DEBUG(sc,"sense code, key",sense->sense_data[0], 389 sense->sense_data[2]); 390 TWS_TRACE_DEBUG(sc,"sense rid, seve",sense->header_desc.request_id, 391 sense->status_block.res__severity); --- 57 unchanged lines hidden (view full) --- 449 } 450} 451 452void 453tws_cmd_complete(struct tws_request *req) 454{ 455 struct tws_softc *sc = req->sc; 456 | 384 tws_unmap_request(sc, req); 385 386 sense = (struct tws_command_header *)req->data; 387 388 TWS_TRACE_DEBUG(sc,"sense code, key",sense->sense_data[0], 389 sense->sense_data[2]); 390 TWS_TRACE_DEBUG(sc,"sense rid, seve",sense->header_desc.request_id, 391 sense->status_block.res__severity); --- 57 unchanged lines hidden (view full) --- 449 } 450} 451 452void 453tws_cmd_complete(struct tws_request *req) 454{ 455 struct tws_softc *sc = req->sc; 456 |
457 untimeout(tws_timeout, req, req->thandle); | 457 callout_stop(&req->timeout); |
458 tws_unmap_request(sc, req); 459} 460 461static void 462tws_err_complete(struct tws_softc *sc, u_int64_t mfa) 463{ 464 struct tws_command_header *hdr; 465 struct tws_sense *sen; --- 90 unchanged lines hidden (view full) --- 556 } 557 ccb->csio.scsi_status = req->cmd_pkt->cmd.pkt_a.status; 558 559 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; 560 mtx_lock(&sc->sim_lock); 561 xpt_done(ccb); 562 mtx_unlock(&sc->sim_lock); 563 | 458 tws_unmap_request(sc, req); 459} 460 461static void 462tws_err_complete(struct tws_softc *sc, u_int64_t mfa) 463{ 464 struct tws_command_header *hdr; 465 struct tws_sense *sen; --- 90 unchanged lines hidden (view full) --- 556 } 557 ccb->csio.scsi_status = req->cmd_pkt->cmd.pkt_a.status; 558 559 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; 560 mtx_lock(&sc->sim_lock); 561 xpt_done(ccb); 562 mtx_unlock(&sc->sim_lock); 563 |
564 untimeout(tws_timeout, req, req->thandle); | 564 callout_stop(&req->timeout); |
565 tws_unmap_request(req->sc, req); 566 mtx_lock(&sc->q_lock); 567 tws_q_remove_request(sc, req, TWS_BUSY_Q); 568 tws_q_insert_tail(sc, req, TWS_FREE_Q); 569 mtx_unlock(&sc->q_lock); 570} 571 572static void --- 13 unchanged lines hidden (view full) --- 586 union ccb *ccb; 587 TWS_TRACE_DEBUG(sc, "entry", 0, 0); 588 589 mtx_lock(&sc->q_lock); 590 req = tws_q_remove_tail(sc, TWS_BUSY_Q); 591 mtx_unlock(&sc->q_lock); 592 while ( req ) { 593 TWS_TRACE_DEBUG(sc, "moved to TWS_COMPLETE_Q", 0, req->request_id); | 565 tws_unmap_request(req->sc, req); 566 mtx_lock(&sc->q_lock); 567 tws_q_remove_request(sc, req, TWS_BUSY_Q); 568 tws_q_insert_tail(sc, req, TWS_FREE_Q); 569 mtx_unlock(&sc->q_lock); 570} 571 572static void --- 13 unchanged lines hidden (view full) --- 586 union ccb *ccb; 587 TWS_TRACE_DEBUG(sc, "entry", 0, 0); 588 589 mtx_lock(&sc->q_lock); 590 req = tws_q_remove_tail(sc, TWS_BUSY_Q); 591 mtx_unlock(&sc->q_lock); 592 while ( req ) { 593 TWS_TRACE_DEBUG(sc, "moved to TWS_COMPLETE_Q", 0, req->request_id); |
594 untimeout(tws_timeout, req, req->thandle); | 594 callout_stop(&req->timeout); |
595 596 req->error_code = TWS_REQ_RET_RESET; 597 ccb = (union ccb *)(req->ccb_ptr); 598 599 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; 600 ccb->ccb_h.status |= CAM_REQUEUE_REQ; 601 ccb->ccb_h.status |= CAM_SCSI_BUS_RESET; 602 --- 14 unchanged lines hidden (view full) --- 617static void 618tws_drain_reserved_reqs(struct tws_softc *sc) 619{ 620 struct tws_request *r; 621 622 r = &sc->reqs[TWS_REQ_TYPE_AEN_FETCH]; 623 if ( r->state != TWS_REQ_STATE_FREE ) { 624 TWS_TRACE_DEBUG(sc, "reset aen req", 0, 0); | 595 596 req->error_code = TWS_REQ_RET_RESET; 597 ccb = (union ccb *)(req->ccb_ptr); 598 599 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; 600 ccb->ccb_h.status |= CAM_REQUEUE_REQ; 601 ccb->ccb_h.status |= CAM_SCSI_BUS_RESET; 602 --- 14 unchanged lines hidden (view full) --- 617static void 618tws_drain_reserved_reqs(struct tws_softc *sc) 619{ 620 struct tws_request *r; 621 622 r = &sc->reqs[TWS_REQ_TYPE_AEN_FETCH]; 623 if ( r->state != TWS_REQ_STATE_FREE ) { 624 TWS_TRACE_DEBUG(sc, "reset aen req", 0, 0); |
625 untimeout(tws_timeout, r, r->thandle); | 625 callout_stop(&r->timeout); |
626 tws_unmap_request(sc, r); 627 free(r->data, M_TWS); 628 r->state = TWS_REQ_STATE_FREE; 629 r->error_code = TWS_REQ_RET_RESET; 630 } 631 632 r = &sc->reqs[TWS_REQ_TYPE_PASSTHRU]; 633 if ( r->state == TWS_REQ_STATE_BUSY ) { 634 TWS_TRACE_DEBUG(sc, "reset passthru req", 0, 0); 635 r->error_code = TWS_REQ_RET_RESET; 636 } 637 638 r = &sc->reqs[TWS_REQ_TYPE_GETSET_PARAM]; 639 if ( r->state != TWS_REQ_STATE_FREE ) { 640 TWS_TRACE_DEBUG(sc, "reset setparam req", 0, 0); | 626 tws_unmap_request(sc, r); 627 free(r->data, M_TWS); 628 r->state = TWS_REQ_STATE_FREE; 629 r->error_code = TWS_REQ_RET_RESET; 630 } 631 632 r = &sc->reqs[TWS_REQ_TYPE_PASSTHRU]; 633 if ( r->state == TWS_REQ_STATE_BUSY ) { 634 TWS_TRACE_DEBUG(sc, "reset passthru req", 0, 0); 635 r->error_code = TWS_REQ_RET_RESET; 636 } 637 638 r = &sc->reqs[TWS_REQ_TYPE_GETSET_PARAM]; 639 if ( r->state != TWS_REQ_STATE_FREE ) { 640 TWS_TRACE_DEBUG(sc, "reset setparam req", 0, 0); |
641 untimeout(tws_timeout, r, r->thandle); | 641 callout_stop(&r->timeout); |
642 tws_unmap_request(sc, r); 643 free(r->data, M_TWS); 644 r->state = TWS_REQ_STATE_FREE; 645 r->error_code = TWS_REQ_RET_RESET; 646 } 647} 648 649static void --- 92 unchanged lines hidden (view full) --- 742 req->flags |= TWS_DATA_CCB; 743 /* save ccb ptr */ 744 req->ccb_ptr = ccb; 745 /* 746 * tws_map_load_data_callback will fill in the SGL, 747 * and submit the I/O. 748 */ 749 sc->stats.scsi_ios++; | 642 tws_unmap_request(sc, r); 643 free(r->data, M_TWS); 644 r->state = TWS_REQ_STATE_FREE; 645 r->error_code = TWS_REQ_RET_RESET; 646 } 647} 648 649static void --- 92 unchanged lines hidden (view full) --- 742 req->flags |= TWS_DATA_CCB; 743 /* save ccb ptr */ 744 req->ccb_ptr = ccb; 745 /* 746 * tws_map_load_data_callback will fill in the SGL, 747 * and submit the I/O. 748 */ 749 sc->stats.scsi_ios++; |
750 req->thandle = timeout(tws_timeout, req, (ccb_h->timeout * hz)/1000); | 750 callout_reset(&req->timeout, (ccb_h->timeout * hz) / 1000, tws_timeout, req); |
751 error = tws_map_request(sc, req); 752 return(error); 753} 754 755 756int 757tws_send_scsi_cmd(struct tws_softc *sc, int cmd) 758{ --- 21 unchanged lines hidden (view full) --- 780 781 req->length = TWS_SECTOR_SIZE; 782 req->data = malloc(TWS_SECTOR_SIZE, M_TWS, M_NOWAIT); 783 if ( req->data == NULL ) 784 return(ENOMEM); 785 bzero(req->data, TWS_SECTOR_SIZE); 786 req->flags = TWS_DIR_IN; 787 | 751 error = tws_map_request(sc, req); 752 return(error); 753} 754 755 756int 757tws_send_scsi_cmd(struct tws_softc *sc, int cmd) 758{ --- 21 unchanged lines hidden (view full) --- 780 781 req->length = TWS_SECTOR_SIZE; 782 req->data = malloc(TWS_SECTOR_SIZE, M_TWS, M_NOWAIT); 783 if ( req->data == NULL ) 784 return(ENOMEM); 785 bzero(req->data, TWS_SECTOR_SIZE); 786 req->flags = TWS_DIR_IN; 787 |
788 req->thandle = timeout(tws_timeout, req, (TWS_IO_TIMEOUT * hz)); | 788 callout_reset(&req->timeout, (TWS_IO_TIMEOUT * hz), tws_timeout, req); |
789 error = tws_map_request(sc, req); 790 return(error); 791 792} 793 794int 795tws_set_param(struct tws_softc *sc, u_int32_t table_id, u_int32_t param_id, 796 u_int32_t param_size, void *data) --- 30 unchanged lines hidden (view full) --- 827 cmd->param.size = 2; /* map routine will add sgls */ 828 829 /* Specify which parameter we want to set. */ 830 param->table_id = (table_id | TWS_9K_PARAM_DESCRIPTOR); 831 param->parameter_id = (u_int8_t)(param_id); 832 param->parameter_size_bytes = (u_int16_t)param_size; 833 memcpy(param->data, data, param_size); 834 | 789 error = tws_map_request(sc, req); 790 return(error); 791 792} 793 794int 795tws_set_param(struct tws_softc *sc, u_int32_t table_id, u_int32_t param_id, 796 u_int32_t param_size, void *data) --- 30 unchanged lines hidden (view full) --- 827 cmd->param.size = 2; /* map routine will add sgls */ 828 829 /* Specify which parameter we want to set. */ 830 param->table_id = (table_id | TWS_9K_PARAM_DESCRIPTOR); 831 param->parameter_id = (u_int8_t)(param_id); 832 param->parameter_size_bytes = (u_int16_t)param_size; 833 memcpy(param->data, data, param_size); 834 |
835 req->thandle = timeout(tws_timeout, req, (TWS_IOCTL_TIMEOUT * hz)); | 835 callout_reset(&req->timeout, (TWS_IOCTL_TIMEOUT * hz), tws_timeout, req); |
836 error = tws_map_request(sc, req); 837 return(error); 838 839} 840 841int 842tws_get_param(struct tws_softc *sc, u_int32_t table_id, u_int32_t param_id, 843 u_int32_t param_size, void *data) --- 319 unchanged lines hidden (view full) --- 1163 return; 1164 } 1165 1166 if ( tws_get_state(sc) == TWS_RESET ) { 1167 mtx_unlock(&sc->gen_lock); 1168 return; 1169 } 1170 | 836 error = tws_map_request(sc, req); 837 return(error); 838 839} 840 841int 842tws_get_param(struct tws_softc *sc, u_int32_t table_id, u_int32_t param_id, 843 u_int32_t param_size, void *data) --- 319 unchanged lines hidden (view full) --- 1163 return; 1164 } 1165 1166 if ( tws_get_state(sc) == TWS_RESET ) { 1167 mtx_unlock(&sc->gen_lock); 1168 return; 1169 } 1170 |
1171 tws_teardown_intr(sc); | |
1172 xpt_freeze_simq(sc->sim, 1); 1173 1174 tws_send_event(sc, TWS_RESET_START); 1175 1176 if (req->type == TWS_REQ_TYPE_SCSI_IO) { 1177 device_printf(sc->tws_dev, "I/O Request timed out... Resetting controller\n"); 1178 } else if (req->type == TWS_REQ_TYPE_PASSTHRU) { 1179 device_printf(sc->tws_dev, "IOCTL Request timed out... Resetting controller\n"); --- 6 unchanged lines hidden (view full) --- 1186 tws_reset_cb( (void*) sc ); 1187 tws_reinit( (void*) sc ); 1188 1189// device_printf(sc->tws_dev, "Controller Reset complete!\n"); 1190 tws_send_event(sc, TWS_RESET_COMPLETE); 1191 mtx_unlock(&sc->gen_lock); 1192 1193 xpt_release_simq(sc->sim, 1); | 1171 xpt_freeze_simq(sc->sim, 1); 1172 1173 tws_send_event(sc, TWS_RESET_START); 1174 1175 if (req->type == TWS_REQ_TYPE_SCSI_IO) { 1176 device_printf(sc->tws_dev, "I/O Request timed out... Resetting controller\n"); 1177 } else if (req->type == TWS_REQ_TYPE_PASSTHRU) { 1178 device_printf(sc->tws_dev, "IOCTL Request timed out... Resetting controller\n"); --- 6 unchanged lines hidden (view full) --- 1185 tws_reset_cb( (void*) sc ); 1186 tws_reinit( (void*) sc ); 1187 1188// device_printf(sc->tws_dev, "Controller Reset complete!\n"); 1189 tws_send_event(sc, TWS_RESET_COMPLETE); 1190 mtx_unlock(&sc->gen_lock); 1191 1192 xpt_release_simq(sc->sim, 1); |
1194 tws_setup_intr(sc, sc->irqs); | |
1195} 1196 1197void 1198tws_reset(void *arg) 1199{ 1200 struct tws_softc *sc = (struct tws_softc *)arg; 1201 1202 mtx_lock(&sc->gen_lock); 1203 if ( tws_get_state(sc) == TWS_RESET ) { 1204 mtx_unlock(&sc->gen_lock); 1205 return; 1206 } 1207 | 1193} 1194 1195void 1196tws_reset(void *arg) 1197{ 1198 struct tws_softc *sc = (struct tws_softc *)arg; 1199 1200 mtx_lock(&sc->gen_lock); 1201 if ( tws_get_state(sc) == TWS_RESET ) { 1202 mtx_unlock(&sc->gen_lock); 1203 return; 1204 } 1205 |
1208 tws_teardown_intr(sc); | |
1209 xpt_freeze_simq(sc->sim, 1); 1210 1211 tws_send_event(sc, TWS_RESET_START); 1212 1213 device_printf(sc->tws_dev, "Resetting controller\n"); 1214 1215 tws_assert_soft_reset(sc); 1216 tws_turn_off_interrupts(sc); 1217 tws_reset_cb( (void*) sc ); 1218 tws_reinit( (void*) sc ); 1219 1220// device_printf(sc->tws_dev, "Controller Reset complete!\n"); 1221 tws_send_event(sc, TWS_RESET_COMPLETE); 1222 mtx_unlock(&sc->gen_lock); 1223 1224 xpt_release_simq(sc->sim, 1); | 1206 xpt_freeze_simq(sc->sim, 1); 1207 1208 tws_send_event(sc, TWS_RESET_START); 1209 1210 device_printf(sc->tws_dev, "Resetting controller\n"); 1211 1212 tws_assert_soft_reset(sc); 1213 tws_turn_off_interrupts(sc); 1214 tws_reset_cb( (void*) sc ); 1215 tws_reinit( (void*) sc ); 1216 1217// device_printf(sc->tws_dev, "Controller Reset complete!\n"); 1218 tws_send_event(sc, TWS_RESET_COMPLETE); 1219 mtx_unlock(&sc->gen_lock); 1220 1221 xpt_release_simq(sc->sim, 1); |
1225 tws_setup_intr(sc, sc->irqs); | |
1226} 1227 1228static void 1229tws_reset_cb(void *arg) 1230{ 1231 struct tws_softc *sc = (struct tws_softc *)arg; 1232 time_t endt; 1233 int found = 0; --- 85 unchanged lines hidden --- | 1222} 1223 1224static void 1225tws_reset_cb(void *arg) 1226{ 1227 struct tws_softc *sc = (struct tws_softc *)arg; 1228 time_t endt; 1229 int found = 0; --- 85 unchanged lines hidden --- |