Deleted Added
full compact
mpt_cam.c (226118) mpt_cam.c (231228)
1/*-
2 * FreeBSD/CAM specific routines for LSI '909 FC adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 80 unchanged lines hidden (view full) ---

89 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
90 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
92 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
93 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
94 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95 */
96#include <sys/cdefs.h>
1/*-
2 * FreeBSD/CAM specific routines for LSI '909 FC adapters.
3 * FreeBSD Version.
4 *
5 * Copyright (c) 2000, 2001 by Greg Ansley
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 80 unchanged lines hidden (view full) ---

89 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
90 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
91 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
92 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
93 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
94 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95 */
96#include <sys/cdefs.h>
97__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_cam.c 226118 2011-10-07 21:23:42Z marius $");
97__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt_cam.c 231228 2012-02-08 21:40:54Z marius $");
98
99#include <dev/mpt/mpt.h>
100#include <dev/mpt/mpt_cam.h>
101#include <dev/mpt/mpt_raid.h>
102
103#include "dev/mpt/mpilib/mpi_ioc.h" /* XXX Fix Event Handling!!! */
104#include "dev/mpt/mpilib/mpi_init.h"
105#include "dev/mpt/mpilib/mpi_targ.h"

--- 1245 unchanged lines hidden (view full) ---

1351 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) {
1352 request_t *cmd_req =
1353 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id);
1354 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM;
1355 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL;
1356 MPT_TGT_STATE(mpt, cmd_req)->req = NULL;
1357 }
1358 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
98
99#include <dev/mpt/mpt.h>
100#include <dev/mpt/mpt_cam.h>
101#include <dev/mpt/mpt_raid.h>
102
103#include "dev/mpt/mpilib/mpi_ioc.h" /* XXX Fix Event Handling!!! */
104#include "dev/mpt/mpilib/mpi_init.h"
105#include "dev/mpt/mpilib/mpi_targ.h"

--- 1245 unchanged lines hidden (view full) ---

1351 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) {
1352 request_t *cmd_req =
1353 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id);
1354 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM;
1355 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL;
1356 MPT_TGT_STATE(mpt, cmd_req)->req = NULL;
1357 }
1358 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1359 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
1359 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
1360 xpt_done(ccb);
1361 CAMLOCK_2_MPTLOCK(mpt);
1362 mpt_free_request(mpt, req);
1363 MPTLOCK_2_CAMLOCK(mpt);
1364 return;
1365 }
1366
1367 /*

--- 261 unchanged lines hidden (view full) ---

1629 }
1630 mpt_prt(mpt,
1631 "mpt_execute_req_a64: I/O cancelled (status 0x%x)\n",
1632 ccb->ccb_h.status & CAM_STATUS_MASK);
1633 if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
1634 bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
1635 }
1636 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1360 xpt_done(ccb);
1361 CAMLOCK_2_MPTLOCK(mpt);
1362 mpt_free_request(mpt, req);
1363 MPTLOCK_2_CAMLOCK(mpt);
1364 return;
1365 }
1366
1367 /*

--- 261 unchanged lines hidden (view full) ---

1629 }
1630 mpt_prt(mpt,
1631 "mpt_execute_req_a64: I/O cancelled (status 0x%x)\n",
1632 ccb->ccb_h.status & CAM_STATUS_MASK);
1633 if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
1634 bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
1635 }
1636 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1637 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
1637 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
1638 xpt_done(ccb);
1639 CAMLOCK_2_MPTLOCK(mpt);
1640 mpt_free_request(mpt, req);
1641 MPTLOCK_2_CAMLOCK(mpt);
1642 return;
1643 }
1644
1645 ccb->ccb_h.status |= CAM_SIM_QUEUED;

--- 108 unchanged lines hidden (view full) ---

1754 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) {
1755 request_t *cmd_req =
1756 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id);
1757 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM;
1758 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL;
1759 MPT_TGT_STATE(mpt, cmd_req)->req = NULL;
1760 }
1761 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1638 xpt_done(ccb);
1639 CAMLOCK_2_MPTLOCK(mpt);
1640 mpt_free_request(mpt, req);
1641 MPTLOCK_2_CAMLOCK(mpt);
1642 return;
1643 }
1644
1645 ccb->ccb_h.status |= CAM_SIM_QUEUED;

--- 108 unchanged lines hidden (view full) ---

1754 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) {
1755 request_t *cmd_req =
1756 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id);
1757 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM;
1758 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL;
1759 MPT_TGT_STATE(mpt, cmd_req)->req = NULL;
1760 }
1761 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1762 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
1762 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
1763 xpt_done(ccb);
1764 CAMLOCK_2_MPTLOCK(mpt);
1765 mpt_free_request(mpt, req);
1766 MPTLOCK_2_CAMLOCK(mpt);
1767 return;
1768 }
1769
1770 /*

--- 253 unchanged lines hidden (view full) ---

2024 }
2025 mpt_prt(mpt,
2026 "mpt_execute_req: I/O cancelled (status 0x%x)\n",
2027 ccb->ccb_h.status & CAM_STATUS_MASK);
2028 if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
2029 bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
2030 }
2031 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
1763 xpt_done(ccb);
1764 CAMLOCK_2_MPTLOCK(mpt);
1765 mpt_free_request(mpt, req);
1766 MPTLOCK_2_CAMLOCK(mpt);
1767 return;
1768 }
1769
1770 /*

--- 253 unchanged lines hidden (view full) ---

2024 }
2025 mpt_prt(mpt,
2026 "mpt_execute_req: I/O cancelled (status 0x%x)\n",
2027 ccb->ccb_h.status & CAM_STATUS_MASK);
2028 if (nseg && (ccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
2029 bus_dmamap_unload(mpt->buffer_dmat, req->dmap);
2030 }
2031 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
2032 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
2032 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
2033 xpt_done(ccb);
2034 CAMLOCK_2_MPTLOCK(mpt);
2035 mpt_free_request(mpt, req);
2036 MPTLOCK_2_CAMLOCK(mpt);
2037 return;
2038 }
2039
2040 ccb->ccb_h.status |= CAM_SIM_QUEUED;

--- 691 unchanged lines hidden (view full) ---

2732 iq->device &= ~0x1F;
2733 iq->device |= T_NODEVICE;
2734 }
2735 }
2736 if (mpt->verbose == MPT_PRT_DEBUG) {
2737 mpt_prt(mpt, "mpt_scsi_reply_handler: %p:%u complete\n",
2738 req, req->serno);
2739 }
2033 xpt_done(ccb);
2034 CAMLOCK_2_MPTLOCK(mpt);
2035 mpt_free_request(mpt, req);
2036 MPTLOCK_2_CAMLOCK(mpt);
2037 return;
2038 }
2039
2040 ccb->ccb_h.status |= CAM_SIM_QUEUED;

--- 691 unchanged lines hidden (view full) ---

2732 iq->device &= ~0x1F;
2733 iq->device |= T_NODEVICE;
2734 }
2735 }
2736 if (mpt->verbose == MPT_PRT_DEBUG) {
2737 mpt_prt(mpt, "mpt_scsi_reply_handler: %p:%u complete\n",
2738 req, req->serno);
2739 }
2740 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
2740 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
2741 MPTLOCK_2_CAMLOCK(mpt);
2742 xpt_done(ccb);
2743 CAMLOCK_2_MPTLOCK(mpt);
2744 if ((req->state & REQ_STATE_TIMEDOUT) == 0) {
2745 TAILQ_REMOVE(&mpt->request_pending_list, req, links);
2746 } else {
2747 mpt_prt(mpt, "completing timedout/aborted req %p:%u\n",
2748 req, req->serno);

--- 898 unchanged lines hidden (view full) ---

3647
3648 ccg = &ccb->ccg;
3649 if (ccg->block_size == 0) {
3650 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
3651 mpt_set_ccb_status(ccb, CAM_REQ_INVALID);
3652 break;
3653 }
3654 mpt_calc_geometry(ccg, /*extended*/1);
2741 MPTLOCK_2_CAMLOCK(mpt);
2742 xpt_done(ccb);
2743 CAMLOCK_2_MPTLOCK(mpt);
2744 if ((req->state & REQ_STATE_TIMEDOUT) == 0) {
2745 TAILQ_REMOVE(&mpt->request_pending_list, req, links);
2746 } else {
2747 mpt_prt(mpt, "completing timedout/aborted req %p:%u\n",
2748 req, req->serno);

--- 898 unchanged lines hidden (view full) ---

3647
3648 ccg = &ccb->ccg;
3649 if (ccg->block_size == 0) {
3650 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
3651 mpt_set_ccb_status(ccb, CAM_REQ_INVALID);
3652 break;
3653 }
3654 mpt_calc_geometry(ccg, /*extended*/1);
3655 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d\n", __LINE__));
3655 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__));
3656 break;
3657 }
3658 case XPT_PATH_INQ: /* Path routing inquiry */
3659 {
3660 struct ccb_pathinq *cpi = &ccb->cpi;
3661
3662 cpi->version_num = 1;
3663 cpi->target_sprt = 0;

--- 882 unchanged lines hidden (view full) ---

4546 }
4547
4548 if (csio->dxfer_len) {
4549 bus_dmamap_callback_t *cb;
4550 PTR_MSG_TARGET_ASSIST_REQUEST ta;
4551 request_t *req;
4552
4553 KASSERT((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE,
3656 break;
3657 }
3658 case XPT_PATH_INQ: /* Path routing inquiry */
3659 {
3660 struct ccb_pathinq *cpi = &ccb->cpi;
3661
3662 cpi->version_num = 1;
3663 cpi->target_sprt = 0;

--- 882 unchanged lines hidden (view full) ---

4546 }
4547
4548 if (csio->dxfer_len) {
4549 bus_dmamap_callback_t *cb;
4550 PTR_MSG_TARGET_ASSIST_REQUEST ta;
4551 request_t *req;
4552
4553 KASSERT((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE,
4554 ("dxfer_len %u but direction is NONE\n", csio->dxfer_len));
4554 ("dxfer_len %u but direction is NONE", csio->dxfer_len));
4555
4556 if ((req = mpt_get_request(mpt, FALSE)) == NULL) {
4557 if (mpt->outofbeer == 0) {
4558 mpt->outofbeer = 1;
4559 xpt_freeze_simq(mpt->sim, 1);
4560 mpt_lprt(mpt, MPT_PRT_DEBUG, "FREEZEQ\n");
4561 }
4562 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;

--- 887 unchanged lines hidden (view full) ---

5450 /*
5451 * Do we need to send status now? That is, are
5452 * we done with all our data transfers?
5453 */
5454 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) == 0) {
5455 mpt_set_ccb_status(ccb, CAM_REQ_CMP);
5456 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
5457 KASSERT(ccb->ccb_h.status,
4555
4556 if ((req = mpt_get_request(mpt, FALSE)) == NULL) {
4557 if (mpt->outofbeer == 0) {
4558 mpt->outofbeer = 1;
4559 xpt_freeze_simq(mpt->sim, 1);
4560 mpt_lprt(mpt, MPT_PRT_DEBUG, "FREEZEQ\n");
4561 }
4562 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;

--- 887 unchanged lines hidden (view full) ---

5450 /*
5451 * Do we need to send status now? That is, are
5452 * we done with all our data transfers?
5453 */
5454 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) == 0) {
5455 mpt_set_ccb_status(ccb, CAM_REQ_CMP);
5456 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
5457 KASSERT(ccb->ccb_h.status,
5458 ("zero ccb sts at %d\n", __LINE__));
5458 ("zero ccb sts at %d", __LINE__));
5459 tgt->state = TGT_STATE_IN_CAM;
5460 if (mpt->outofbeer) {
5461 ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
5462 mpt->outofbeer = 0;
5463 mpt_lprt(mpt, MPT_PRT_DEBUG, "THAWQ\n");
5464 }
5465 MPTLOCK_2_CAMLOCK(mpt);
5466 xpt_done(ccb);

--- 45 unchanged lines hidden (view full) ---

5512 ("tgt->req %p:%u tgt->req->ccb %p",
5513 tgt->req, tgt->req->serno, tgt->req->ccb));
5514 /*
5515 * Notify CAM that we're done
5516 */
5517 mpt_set_ccb_status(ccb, CAM_REQ_CMP);
5518 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
5519 KASSERT(ccb->ccb_h.status,
5459 tgt->state = TGT_STATE_IN_CAM;
5460 if (mpt->outofbeer) {
5461 ccb->ccb_h.status |= CAM_RELEASE_SIMQ;
5462 mpt->outofbeer = 0;
5463 mpt_lprt(mpt, MPT_PRT_DEBUG, "THAWQ\n");
5464 }
5465 MPTLOCK_2_CAMLOCK(mpt);
5466 xpt_done(ccb);

--- 45 unchanged lines hidden (view full) ---

5512 ("tgt->req %p:%u tgt->req->ccb %p",
5513 tgt->req, tgt->req->serno, tgt->req->ccb));
5514 /*
5515 * Notify CAM that we're done
5516 */
5517 mpt_set_ccb_status(ccb, CAM_REQ_CMP);
5518 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
5519 KASSERT(ccb->ccb_h.status,
5520 ("ZERO ccb sts at %d\n", __LINE__));
5520 ("ZERO ccb sts at %d", __LINE__));
5521 tgt->ccb = NULL;
5522 } else {
5523 mpt_lprt(mpt, MPT_PRT_DEBUG,
5524 "TARGET_STATUS non-CAM for req %p:%u\n",
5525 tgt->req, tgt->req->serno);
5526 }
5527 TAILQ_REMOVE(&mpt->request_pending_list,
5528 tgt->req, links);

--- 55 unchanged lines hidden (view full) ---

5584 if (status != MPI_IOCSTATUS_SUCCESS) {
5585 /*
5586 * XXX What to do?
5587 */
5588 break;
5589 }
5590 tgt = MPT_TGT_STATE(mpt, req);
5591 KASSERT(tgt->state == TGT_STATE_LOADING,
5521 tgt->ccb = NULL;
5522 } else {
5523 mpt_lprt(mpt, MPT_PRT_DEBUG,
5524 "TARGET_STATUS non-CAM for req %p:%u\n",
5525 tgt->req, tgt->req->serno);
5526 }
5527 TAILQ_REMOVE(&mpt->request_pending_list,
5528 tgt->req, links);

--- 55 unchanged lines hidden (view full) ---

5584 if (status != MPI_IOCSTATUS_SUCCESS) {
5585 /*
5586 * XXX What to do?
5587 */
5588 break;
5589 }
5590 tgt = MPT_TGT_STATE(mpt, req);
5591 KASSERT(tgt->state == TGT_STATE_LOADING,
5592 ("bad state 0x%x on reply to buffer post\n", tgt->state));
5592 ("bad state 0x%x on reply to buffer post", tgt->state));
5593 mpt_assign_serno(mpt, req);
5594 tgt->state = TGT_STATE_LOADED;
5595 break;
5596 }
5597 case MPI_FUNCTION_TARGET_ASSIST:
5598#ifdef INVARIANTS
5599 mpt_req_not_spcl(mpt, req, "tgt reply TARGET ASSIST", __LINE__);
5600#endif

--- 35 unchanged lines hidden ---
5593 mpt_assign_serno(mpt, req);
5594 tgt->state = TGT_STATE_LOADED;
5595 break;
5596 }
5597 case MPI_FUNCTION_TARGET_ASSIST:
5598#ifdef INVARIANTS
5599 mpt_req_not_spcl(mpt, req, "tgt reply TARGET ASSIST", __LINE__);
5600#endif

--- 35 unchanged lines hidden ---