Deleted Added
full compact
mpt.c (165814) mpt.c (169293)
1/*-
2 * Generic routines for LSI Fusion 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

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

91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98#include <sys/cdefs.h>
1/*-
2 * Generic routines for LSI Fusion 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

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

91 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
92 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
93 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
94 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
95 * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96 */
97
98#include <sys/cdefs.h>
99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 165814 2007-01-05 22:49:05Z mjacob $");
99__FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 169293 2007-05-05 20:18:24Z mjacob $");
100
101#include <dev/mpt/mpt.h>
102#include <dev/mpt/mpt_cam.h> /* XXX For static handler registration */
103#include <dev/mpt/mpt_raid.h> /* XXX For static handler registration */
104
105#include <dev/mpt/mpilib/mpi.h>
106#include <dev/mpt/mpilib/mpi_ioc.h>
107#include <dev/mpt/mpilib/mpi_fc.h>

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

699mpt_intr(void *arg)
700{
701 struct mpt_softc *mpt;
702 uint32_t reply_desc;
703 int ntrips = 0;
704
705 mpt = (struct mpt_softc *)arg;
706 mpt_lprt(mpt, MPT_PRT_DEBUG2, "enter mpt_intr\n");
100
101#include <dev/mpt/mpt.h>
102#include <dev/mpt/mpt_cam.h> /* XXX For static handler registration */
103#include <dev/mpt/mpt_raid.h> /* XXX For static handler registration */
104
105#include <dev/mpt/mpilib/mpi.h>
106#include <dev/mpt/mpilib/mpi_ioc.h>
107#include <dev/mpt/mpilib/mpi_fc.h>

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

699mpt_intr(void *arg)
700{
701 struct mpt_softc *mpt;
702 uint32_t reply_desc;
703 int ntrips = 0;
704
705 mpt = (struct mpt_softc *)arg;
706 mpt_lprt(mpt, MPT_PRT_DEBUG2, "enter mpt_intr\n");
707 MPT_LOCK_ASSERT(mpt);
708
707 while ((reply_desc = mpt_pop_reply_queue(mpt)) != MPT_REPLY_EMPTY) {
708 request_t *req;
709 MSG_DEFAULT_REPLY *reply_frame;
710 uint32_t reply_baddr;
711 uint32_t ctxt_idx;
712 u_int cb_index;
713 u_int req_index;
714 int free_rf;

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

1166 return;
1167 }
1168 if ((nxt = req->chain) != NULL) {
1169 req->chain = NULL;
1170 mpt_free_request(mpt, nxt); /* NB: recursion */
1171 }
1172 KASSERT(req->state != REQ_STATE_FREE, ("freeing free request"));
1173 KASSERT(!(req->state & REQ_STATE_LOCKED), ("freeing locked request"));
709 while ((reply_desc = mpt_pop_reply_queue(mpt)) != MPT_REPLY_EMPTY) {
710 request_t *req;
711 MSG_DEFAULT_REPLY *reply_frame;
712 uint32_t reply_baddr;
713 uint32_t ctxt_idx;
714 u_int cb_index;
715 u_int req_index;
716 int free_rf;

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

1168 return;
1169 }
1170 if ((nxt = req->chain) != NULL) {
1171 req->chain = NULL;
1172 mpt_free_request(mpt, nxt); /* NB: recursion */
1173 }
1174 KASSERT(req->state != REQ_STATE_FREE, ("freeing free request"));
1175 KASSERT(!(req->state & REQ_STATE_LOCKED), ("freeing locked request"));
1174 KASSERT(MPT_OWNED(mpt), ("mpt_free_request: mpt not locked\n"));
1176 MPT_LOCK_ASSERT(mpt);
1175 KASSERT(mpt_req_on_free_list(mpt, req) == 0,
1176 ("mpt_free_request: req %p:%u func %x already on freelist",
1177 req, req->serno, ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));
1178 KASSERT(mpt_req_on_pending_list(mpt, req) == 0,
1179 ("mpt_free_request: req %p:%u func %x on pending list",
1180 req, req->serno, ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));
1181#ifdef INVARIANTS
1182 mpt_req_not_spcl(mpt, req, "mpt_free_request", __LINE__);

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

1215
1216/* Get a command buffer from the free queue */
1217request_t *
1218mpt_get_request(struct mpt_softc *mpt, int sleep_ok)
1219{
1220 request_t *req;
1221
1222retry:
1177 KASSERT(mpt_req_on_free_list(mpt, req) == 0,
1178 ("mpt_free_request: req %p:%u func %x already on freelist",
1179 req, req->serno, ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));
1180 KASSERT(mpt_req_on_pending_list(mpt, req) == 0,
1181 ("mpt_free_request: req %p:%u func %x on pending list",
1182 req, req->serno, ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));
1183#ifdef INVARIANTS
1184 mpt_req_not_spcl(mpt, req, "mpt_free_request", __LINE__);

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

1217
1218/* Get a command buffer from the free queue */
1219request_t *
1220mpt_get_request(struct mpt_softc *mpt, int sleep_ok)
1221{
1222 request_t *req;
1223
1224retry:
1223 KASSERT(MPT_OWNED(mpt), ("mpt_get_request: mpt not locked\n"));
1225 MPT_LOCK_ASSERT(mpt);
1224 req = TAILQ_FIRST(&mpt->request_free_list);
1225 if (req != NULL) {
1226 KASSERT(req == &mpt->request_pool[req->index],
1227 ("mpt_get_request: corrupted request free list\n"));
1228 KASSERT(req->state == REQ_STATE_FREE,
1229 ("req %p:%u not free on free list %x index %d function %x",
1230 req, req->serno, req->state, req->index,
1231 ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));

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

2102
2103/*
2104 * Initialize per-instance driver data and perform
2105 * initial controller configuration.
2106 */
2107int
2108mpt_core_attach(struct mpt_softc *mpt)
2109{
1226 req = TAILQ_FIRST(&mpt->request_free_list);
1227 if (req != NULL) {
1228 KASSERT(req == &mpt->request_pool[req->index],
1229 ("mpt_get_request: corrupted request free list\n"));
1230 KASSERT(req->state == REQ_STATE_FREE,
1231 ("req %p:%u not free on free list %x index %d function %x",
1232 req, req->serno, req->state, req->index,
1233 ((MSG_REQUEST_HEADER *)req->req_vbuf)->Function));

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

2104
2105/*
2106 * Initialize per-instance driver data and perform
2107 * initial controller configuration.
2108 */
2109int
2110mpt_core_attach(struct mpt_softc *mpt)
2111{
2110 int val;
2112 int val, error;
2111
2112 LIST_INIT(&mpt->ack_frames);
2113 /* Put all request buffers on the free list */
2114 TAILQ_INIT(&mpt->request_pending_list);
2115 TAILQ_INIT(&mpt->request_free_list);
2116 TAILQ_INIT(&mpt->request_timeout_list);
2113
2114 LIST_INIT(&mpt->ack_frames);
2115 /* Put all request buffers on the free list */
2116 TAILQ_INIT(&mpt->request_pending_list);
2117 TAILQ_INIT(&mpt->request_free_list);
2118 TAILQ_INIT(&mpt->request_timeout_list);
2119 MPT_LOCK(mpt);
2117 for (val = 0; val < MPT_MAX_REQUESTS(mpt); val++) {
2118 request_t *req = &mpt->request_pool[val];
2119 req->state = REQ_STATE_ALLOCATED;
2120 mpt_free_request(mpt, req);
2121 }
2120 for (val = 0; val < MPT_MAX_REQUESTS(mpt); val++) {
2121 request_t *req = &mpt->request_pool[val];
2122 req->state = REQ_STATE_ALLOCATED;
2123 mpt_free_request(mpt, req);
2124 }
2125 MPT_UNLOCK(mpt);
2122 for (val = 0; val < MPT_MAX_LUNS; val++) {
2123 STAILQ_INIT(&mpt->trt[val].atios);
2124 STAILQ_INIT(&mpt->trt[val].inots);
2125 }
2126 STAILQ_INIT(&mpt->trt_wildcard.atios);
2127 STAILQ_INIT(&mpt->trt_wildcard.inots);
2128#ifdef MPT_TEST_MULTIPATH
2129 mpt->failure_id = -1;
2130#endif
2131 mpt->scsi_tgt_handler_id = MPT_HANDLER_ID_NONE;
2132 mpt_sysctl_attach(mpt);
2133 mpt_lprt(mpt, MPT_PRT_DEBUG, "doorbell req = %s\n",
2134 mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL)));
2126 for (val = 0; val < MPT_MAX_LUNS; val++) {
2127 STAILQ_INIT(&mpt->trt[val].atios);
2128 STAILQ_INIT(&mpt->trt[val].inots);
2129 }
2130 STAILQ_INIT(&mpt->trt_wildcard.atios);
2131 STAILQ_INIT(&mpt->trt_wildcard.inots);
2132#ifdef MPT_TEST_MULTIPATH
2133 mpt->failure_id = -1;
2134#endif
2135 mpt->scsi_tgt_handler_id = MPT_HANDLER_ID_NONE;
2136 mpt_sysctl_attach(mpt);
2137 mpt_lprt(mpt, MPT_PRT_DEBUG, "doorbell req = %s\n",
2138 mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL)));
2135 return (mpt_configure_ioc(mpt, 0, 0));
2139
2140 MPT_LOCK(mpt);
2141 error = mpt_configure_ioc(mpt, 0, 0);
2142 MPT_UNLOCK(mpt);
2143
2144 return (error);
2136}
2137
2138int
2139mpt_core_enable(struct mpt_softc *mpt)
2140{
2141 /*
2142 * We enter with the IOC enabled, but async events
2143 * not enabled, ports not enabled and interrupts
2144 * not enabled.
2145 */
2145}
2146
2147int
2148mpt_core_enable(struct mpt_softc *mpt)
2149{
2150 /*
2151 * We enter with the IOC enabled, but async events
2152 * not enabled, ports not enabled and interrupts
2153 * not enabled.
2154 */
2155 MPT_LOCK(mpt);
2146
2147 /*
2148 * Enable asynchronous event reporting- all personalities
2149 * have attached so that they should be able to now field
2150 * async events.
2151 */
2152 mpt_send_event_request(mpt, 1);
2153

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

2172 */
2173 mpt_intr(mpt);
2174
2175 /*
2176 * Enable the port.
2177 */
2178 if (mpt_send_port_enable(mpt, 0) != MPT_OK) {
2179 mpt_prt(mpt, "failed to enable port 0\n");
2156
2157 /*
2158 * Enable asynchronous event reporting- all personalities
2159 * have attached so that they should be able to now field
2160 * async events.
2161 */
2162 mpt_send_event_request(mpt, 1);
2163

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

2182 */
2183 mpt_intr(mpt);
2184
2185 /*
2186 * Enable the port.
2187 */
2188 if (mpt_send_port_enable(mpt, 0) != MPT_OK) {
2189 mpt_prt(mpt, "failed to enable port 0\n");
2190 MPT_UNLOCK(mpt);
2180 return (ENXIO);
2181 }
2191 return (ENXIO);
2192 }
2193 MPT_UNLOCK(mpt);
2182 return (0);
2183}
2184
2185void
2186mpt_core_shutdown(struct mpt_softc *mpt)
2187{
2188 mpt_disable_ints(mpt);
2189}

--- 515 unchanged lines hidden ---
2194 return (0);
2195}
2196
2197void
2198mpt_core_shutdown(struct mpt_softc *mpt)
2199{
2200 mpt_disable_ints(mpt);
2201}

--- 515 unchanged lines hidden ---