Deleted Added
full compact
95c95
< __FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 156796 2006-03-17 04:52:27Z mjacob $");
---
> __FBSDID("$FreeBSD: head/sys/dev/mpt/mpt.c 157117 2006-03-25 07:08:27Z mjacob $");
102a103,104
> #include <dev/mpt/mpilib/mpi_fc.h>
> #include <dev/mpt/mpilib/mpi_targ.h>
126c128
< static int mpt_enable_ioc(struct mpt_softc *mpt);
---
> static int mpt_enable_ioc(struct mpt_softc *mpt, int);
153c155
< * Used infrequenstly, so no need to optimize like a forward
---
> * Used infrequently, so no need to optimize like a forward
181a184
> static mpt_enable_handler_t mpt_stdenable;
191a195
> .enable = mpt_stdenable,
200a205
> static mpt_enable_handler_t mpt_core_enable;
210a216
> .enable = mpt_core_enable,
229,230c235
< #define MPT_PERS_ATACHED(pers, mpt) \
< ((mpt)->pers_mask & (0x1 << pers->id))
---
> #define MPT_PERS_ATTACHED(pers, mpt) ((mpt)->mpt_pers_mask & (0x1 << pers->id))
276a282
> #if __FreeBSD_version >= 500000
278a285
> #endif
311a319,325
> mpt_stdenable(struct mpt_softc *mpt)
> {
> /* Enable is always successfull. */
> return (0);
> }
>
> int
388,389c402,403
< if (free_cbi == MPT_HANDLER_ID_NONE
< && (mpt_reply_handlers[cbi]
---
> if (free_cbi == MPT_HANDLER_ID_NONE &&
> (mpt_reply_handlers[cbi]
393c407
< if (free_cbi == MPT_HANDLER_ID_NONE)
---
> if (free_cbi == MPT_HANDLER_ID_NONE) {
394a409
> }
432c447
< MSG_DEFAULT_REPLY *reply_frame)
---
> uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
434,435c449,451
< mpt_prt(mpt, "XXXX Default Handler Called. Req %p, Frame %p\n",
< req, reply_frame);
---
> mpt_prt(mpt,
> "Default Handler Called: req=%p:%u reply_descriptor=%x frame=%p\n",
> req, req->serno, reply_desc, reply_frame);
440c456
< mpt_prt(mpt, "XXXX Reply Frame Ignored\n");
---
> mpt_prt(mpt, "Reply Frame Ignored\n");
447c463
< MSG_DEFAULT_REPLY *reply_frame)
---
> uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
474c490
< MSG_DEFAULT_REPLY *reply_frame)
---
> uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
482c498
< MSG_DEFAULT_REPLY *reply_frame)
---
> uint32_t reply_desc, MSG_DEFAULT_REPLY *reply_frame)
487c503,504
< mpt_prt(mpt, "Event Handler: req %p - Unexpected NULL reply\n");
---
> mpt_prt(mpt, "Event Handler: req %p:%u - Unexpected NULL reply\n",
> req, req->serno);
622c639,640
< uint32_t reply_desc;
---
> uint32_t reply_desc;
> int ntrips = 0;
628a647
> uint32_t ctxt_idx;
638d656
<
644,646c662,664
< bus_dmamap_sync_range(mpt->reply_dmat, mpt->reply_dmap,
< offset, MPT_REPLY_SIZE,
< BUS_DMASYNC_POSTREAD);
---
> bus_dmamap_sync_range(mpt->reply_dmat,
> mpt->reply_dmap, offset, MPT_REPLY_SIZE,
> BUS_DMASYNC_POSTREAD);
648c666,728
< reply_desc = le32toh(reply_frame->MsgContext);
---
> ctxt_idx = le32toh(reply_frame->MsgContext);
> } else {
> uint32_t type;
>
> type = MPI_GET_CONTEXT_REPLY_TYPE(reply_desc);
> ctxt_idx = reply_desc;
> mpt_lprt(mpt, MPT_PRT_DEBUG1, "Context Reply: 0x%08x\n",
> reply_desc);
>
> switch (type) {
> case MPI_CONTEXT_REPLY_TYPE_SCSI_INIT:
> ctxt_idx &= MPI_CONTEXT_REPLY_CONTEXT_MASK;
> break;
> case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET:
> ctxt_idx = GET_IO_INDEX(reply_desc);
> if (mpt->tgt_cmd_ptrs == NULL) {
> mpt_prt(mpt,
> "mpt_intr: no target cmd ptrs\n");
> reply_desc = MPT_REPLY_EMPTY;
> break;
> }
> if (ctxt_idx >= mpt->tgt_cmds_allocated) {
> mpt_prt(mpt,
> "mpt_intr: bad tgt cmd ctxt %u\n",
> ctxt_idx);
> reply_desc = MPT_REPLY_EMPTY;
> ntrips = 1000;
> break;
> }
> req = mpt->tgt_cmd_ptrs[ctxt_idx];
> if (req == NULL) {
> mpt_prt(mpt, "no request backpointer "
> "at index %u", ctxt_idx);
> reply_desc = MPT_REPLY_EMPTY;
> ntrips = 1000;
> break;
> }
> /*
> * Reformulate ctxt_idx to be just as if
> * it were another type of context reply
> * so the code below will find the request
> * via indexing into the pool.
> */
> ctxt_idx =
> req->index | mpt->scsi_tgt_handler_id;
> req = NULL;
> break;
> case MPI_CONTEXT_REPLY_TYPE_LAN:
> mpt_prt(mpt, "LAN CONTEXT REPLY: 0x%08x\n",
> reply_desc);
> reply_desc = MPT_REPLY_EMPTY;
> break;
> default:
> mpt_prt(mpt, "Context Reply 0x%08x?\n", type);
> reply_desc = MPT_REPLY_EMPTY;
> break;
> }
> if (reply_desc == MPT_REPLY_EMPTY) {
> if (ntrips++ > 1000) {
> break;
> }
> continue;
> }
650,652c730,733
< cb_index = MPT_CONTEXT_TO_CBI(reply_desc);
< req_index = MPT_CONTEXT_TO_REQI(reply_desc);
< if (req_index < MPT_MAX_REQUESTS(mpt))
---
>
> cb_index = MPT_CONTEXT_TO_CBI(ctxt_idx);
> req_index = MPT_CONTEXT_TO_REQI(ctxt_idx);
> if (req_index < MPT_MAX_REQUESTS(mpt)) {
653a735
> }
655c737,738
< free_rf = mpt_reply_handlers[cb_index](mpt, req, reply_frame);
---
> free_rf = mpt_reply_handlers[cb_index](mpt, req,
> reply_desc, reply_frame);
658a742,752
>
> /*
> * If we got ourselves disabled, don't get stuck in a loop
> */
> if (mpt->disabled) {
> mpt_disable_ints(mpt);
> break;
> }
> if (ntrips++ > 1000) {
> break;
> }
681c775,776
< mpt_reply_handlers[cb_index](mpt, req, &ioc_status_frame);
---
> mpt_reply_handlers[cb_index](mpt, req, msg_hdr->MsgContext,
> &ioc_status_frame);
721c816
< return MPT_OK;
---
> return (MPT_OK);
723,724c818
<
< DELAY(1000);
---
> DELAY(200);
726c820
< return MPT_FAIL;
---
> return (MPT_FAIL);
741c835
< return MPT_FAIL;
---
> return (MPT_FAIL);
785c879
< return MPT_FAIL;
---
> return (MPT_FAIL);
794c888
< return MPT_FAIL;
---
> return (MPT_FAIL);
802c896
< return MPT_FAIL;
---
> return (MPT_FAIL);
808c902
< return MPT_FAIL;
---
> return (MPT_FAIL);
982c1076
< ret = mpt_enable_ioc(mpt);
---
> ret = mpt_enable_ioc(mpt, 1);
1013c1107,1110
< TAILQ_INSERT_HEAD(&mpt->request_free_list, req, links);
---
> /*
> * Insert free ones at the tail
> */
> TAILQ_INSERT_TAIL(&mpt->request_free_list, req, links);
1046,1048c1143
< if ((req->serno = ++(mpt->cmd_serno)) == 0) {
< req->serno = ++(mpt->cmd_serno);
< }
---
> req->serno = mpt->sequence++;
1066,1067c1161,1167
< mpt_prt(mpt, "Send Request %d (0x%x):",
< req->index, req->req_pbuf);
---
> #if __FreeBSD_version >= 500000
> mpt_prt(mpt, "Send Request %d (%jx):",
> req->index, (uintmax_t) req->req_pbuf);
> #else
> mpt_prt(mpt, "Send Request %d (%llx):",
> req->index, (unsigned long long) req->req_pbuf);
> #endif
1111c1211
< if (sleep_ok != 0)
---
> if (sleep_ok != 0) {
1113c1213
< else
---
> } else {
1114a1215
> }
1118,1120c1219
< while ((req->state & mask) != state
< && mpt->reset_cnt == saved_cnt) {
<
---
> while ((req->state & mask) != state && mpt->reset_cnt == saved_cnt) {
1129d1227
< mpt_prt(mpt, "mpt_wait_req timed out\n");
1137c1235
< if (mpt->reset_cnt != saved_cnt)
---
> if (mpt->reset_cnt != saved_cnt) {
1139c1237,1240
< if (time_ms && timeout <= 0)
---
> }
> if (time_ms && timeout <= 0) {
> MSG_REQUEST_HEADER *msg_hdr = req->req_vbuf;
> mpt_prt(mpt, "mpt_wait_req(%x) timed out\n", msg_hdr->Function);
1140a1242
> }
1439,1440d1540
< #define CFG_DATA_OFF 128
<
1458c1558
< PageAddress, req->req_pbuf + CFG_DATA_OFF,
---
> PageAddress, req->req_pbuf + MPT_RQSL(mpt),
1473c1573
< memcpy(hdr, ((uint8_t *)req->req_vbuf)+CFG_DATA_OFF, len);
---
> memcpy(hdr, ((uint8_t *)req->req_vbuf)+MPT_RQSL(mpt), len);
1500c1600
< memcpy(((caddr_t)req->req_vbuf)+CFG_DATA_OFF, hdr, len);
---
> memcpy(((caddr_t)req->req_vbuf)+MPT_RQSL(mpt), hdr, len);
1507c1607
< PageAddress, req->req_pbuf + CFG_DATA_OFF,
---
> PageAddress, req->req_pbuf + MPT_RQSL(mpt),
1677,1906d1776
< * Read SCSI configuration information
< */
< static int
< mpt_read_config_info_spi(struct mpt_softc *mpt)
< {
< int rv, i;
<
< rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 0,
< 0, &mpt->mpt_port_page0.Header,
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv)
< return (-1);
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 0 Header: %x %x %x %x\n",
< mpt->mpt_port_page0.Header.PageVersion,
< mpt->mpt_port_page0.Header.PageLength,
< mpt->mpt_port_page0.Header.PageNumber,
< mpt->mpt_port_page0.Header.PageType);
<
< rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 1,
< 0, &mpt->mpt_port_page1.Header,
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv)
< return (-1);
<
< mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 1 Header: %x %x %x %x\n",
< mpt->mpt_port_page1.Header.PageVersion,
< mpt->mpt_port_page1.Header.PageLength,
< mpt->mpt_port_page1.Header.PageNumber,
< mpt->mpt_port_page1.Header.PageType);
<
< rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_PORT, 2,
< /*PageAddress*/0, &mpt->mpt_port_page2.Header,
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv)
< return (-1);
<
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 2 Header: %x %x %x %x\n",
< mpt->mpt_port_page1.Header.PageVersion,
< mpt->mpt_port_page1.Header.PageLength,
< mpt->mpt_port_page1.Header.PageNumber,
< mpt->mpt_port_page1.Header.PageType);
<
< for (i = 0; i < 16; i++) {
< rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_DEVICE,
< 0, i, &mpt->mpt_dev_page0[i].Header,
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv)
< return (-1);
<
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Target %d Device Page 0 Header: %x %x %x %x\n",
< i, mpt->mpt_dev_page0[i].Header.PageVersion,
< mpt->mpt_dev_page0[i].Header.PageLength,
< mpt->mpt_dev_page0[i].Header.PageNumber,
< mpt->mpt_dev_page0[i].Header.PageType);
<
< rv = mpt_read_cfg_header(mpt, MPI_CONFIG_PAGETYPE_SCSI_DEVICE,
< 1, i, &mpt->mpt_dev_page1[i].Header,
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv)
< return (-1);
<
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Target %d Device Page 1 Header: %x %x %x %x\n",
< i, mpt->mpt_dev_page1[i].Header.PageVersion,
< mpt->mpt_dev_page1[i].Header.PageLength,
< mpt->mpt_dev_page1[i].Header.PageNumber,
< mpt->mpt_dev_page1[i].Header.PageType);
< }
<
< /*
< * At this point, we don't *have* to fail. As long as we have
< * valid config header information, we can (barely) lurch
< * along.
< */
<
< rv = mpt_read_cur_cfg_page(mpt, /*PageAddress*/0,
< &mpt->mpt_port_page0.Header,
< sizeof(mpt->mpt_port_page0),
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv) {
< mpt_prt(mpt, "failed to read SPI Port Page 0\n");
< } else {
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 0: Capabilities %x PhysicalInterface %x\n",
< mpt->mpt_port_page0.Capabilities,
< mpt->mpt_port_page0.PhysicalInterface);
< }
<
< rv = mpt_read_cur_cfg_page(mpt, /*PageAddress*/0,
< &mpt->mpt_port_page1.Header,
< sizeof(mpt->mpt_port_page1),
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv) {
< mpt_prt(mpt, "failed to read SPI Port Page 1\n");
< } else {
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 1: Configuration %x OnBusTimerValue %x\n",
< mpt->mpt_port_page1.Configuration,
< mpt->mpt_port_page1.OnBusTimerValue);
< }
<
< rv = mpt_read_cur_cfg_page(mpt, /*PageAddress*/0,
< &mpt->mpt_port_page2.Header,
< sizeof(mpt->mpt_port_page2),
< /*sleep_ok*/FALSE, /*timeout_ms*/5000);
< if (rv) {
< mpt_prt(mpt, "failed to read SPI Port Page 2\n");
< } else {
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 2: Flags %x Settings %x\n",
< mpt->mpt_port_page2.PortFlags,
< mpt->mpt_port_page2.PortSettings);
< for (i = 0; i < 16; i++) {
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Port Page 2 Tgt %d: timo %x SF %x Flags %x\n",
< i, mpt->mpt_port_page2.DeviceSettings[i].Timeout,
< mpt->mpt_port_page2.DeviceSettings[i].SyncFactor,
< mpt->mpt_port_page2.DeviceSettings[i].DeviceFlags);
< }
< }
<
< for (i = 0; i < 16; i++) {
< rv = mpt_read_cur_cfg_page(mpt, /*PageAddress*/i,
< &mpt->mpt_dev_page0[i].Header,
< sizeof(*mpt->mpt_dev_page0),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (rv) {
< mpt_prt(mpt,
< "cannot read SPI Tgt %d Device Page 0\n", i);
< continue;
< }
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Tgt %d Page 0: NParms %x Information %x",
< i, mpt->mpt_dev_page0[i].NegotiatedParameters,
< mpt->mpt_dev_page0[i].Information);
<
< rv = mpt_read_cur_cfg_page(mpt, /*PageAddress*/i,
< &mpt->mpt_dev_page1[i].Header,
< sizeof(*mpt->mpt_dev_page1),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (rv) {
< mpt_prt(mpt,
< "cannot read SPI Tgt %d Device Page 1\n", i);
< continue;
< }
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Tgt %d Page 1: RParms %x Configuration %x\n",
< i, mpt->mpt_dev_page1[i].RequestedParameters,
< mpt->mpt_dev_page1[i].Configuration);
< }
< return (0);
< }
<
< /*
< * Validate SPI configuration information.
< *
< * In particular, validate SPI Port Page 1.
< */
< static int
< mpt_set_initial_config_spi(struct mpt_softc *mpt)
< {
< int i, pp1val = ((1 << mpt->mpt_ini_id) << 16) | mpt->mpt_ini_id;
< int error;
<
< mpt->mpt_disc_enable = 0xff;
< mpt->mpt_tag_enable = 0;
<
< if (mpt->mpt_port_page1.Configuration != pp1val) {
< CONFIG_PAGE_SCSI_PORT_1 tmp;
<
< mpt_prt(mpt,
< "SPI Port Page 1 Config value bad (%x)- should be %x\n",
< mpt->mpt_port_page1.Configuration, pp1val);
< tmp = mpt->mpt_port_page1;
< tmp.Configuration = pp1val;
< error = mpt_write_cur_cfg_page(mpt, /*PageAddress*/0,
< &tmp.Header, sizeof(tmp),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (error)
< return (-1);
< error = mpt_read_cur_cfg_page(mpt, /*PageAddress*/0,
< &tmp.Header, sizeof(tmp),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (error)
< return (-1);
< if (tmp.Configuration != pp1val) {
< mpt_prt(mpt,
< "failed to reset SPI Port Page 1 Config value\n");
< return (-1);
< }
< mpt->mpt_port_page1 = tmp;
< }
<
< for (i = 0; i < 16; i++) {
< CONFIG_PAGE_SCSI_DEVICE_1 tmp;
< tmp = mpt->mpt_dev_page1[i];
< tmp.RequestedParameters = 0;
< tmp.Configuration = 0;
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "Set Tgt %d SPI DevicePage 1 values to %x 0 %x\n",
< i, tmp.RequestedParameters, tmp.Configuration);
< error = mpt_write_cur_cfg_page(mpt, /*PageAddress*/i,
< &tmp.Header, sizeof(tmp),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (error)
< return (-1);
< error = mpt_read_cur_cfg_page(mpt, /*PageAddress*/i,
< &tmp.Header, sizeof(tmp),
< /*sleep_ok*/FALSE,
< /*timeout_ms*/5000);
< if (error)
< return (-1);
< mpt->mpt_dev_page1[i] = tmp;
< mpt_lprt(mpt, MPT_PRT_DEBUG,
< "SPI Tgt %d Page 1: RParm %x Configuration %x\n", i,
< mpt->mpt_dev_page1[i].RequestedParameters,
< mpt->mpt_dev_page1[i].Configuration);
< }
< return (0);
< }
<
< /*
1921c1791
< bzero(enable_req, sizeof *enable_req);
---
> bzero(enable_req, MPT_RQSL(mpt));
1935c1805
< mpt_prt(mpt, "port enable timed out\n");
---
> mpt_prt(mpt, "port %d enable timed out\n", port);
1938a1809
> mpt_lprt(mpt, MPT_PRT_DEBUG, "enabled port %d\n", port);
1994a1866
> #if __FreeBSD_version >= 500000
2000a1873
> #endif
2005a1879
> struct mpt_personality *pers;
2006a1881
> int error;
2009,2011d1883
< struct mpt_personality *pers;
< int error;
<
2013c1885
< if (pers == NULL)
---
> if (pers == NULL) {
2015c1887
<
---
> }
2026a1899,1916
> /*
> * Now that we've attached everything, do the enable function
> * for all of the personalities. This allows the personalities
> * to do setups that are appropriate for them prior to enabling
> * any ports.
> */
> for (i = 0; i < MPT_MAX_PERSONALITIES; i++) {
> pers = mpt_personalities[i];
> if (pers != NULL && MPT_PERS_ATTACHED(pers, mpt) != 0) {
> error = pers->enable(mpt);
> if (error != 0) {
> mpt_prt(mpt, "personality %s attached but would"
> " not enable (%d)\n", pers->name, error);
> mpt_detach(mpt);
> return (error);
> }
> }
> }
2035c1925
< MPT_PERS_FOREACH_REVERSE(mpt, pers)
---
> MPT_PERS_FOREACH_REVERSE(mpt, pers) {
2037,2038c1927
<
< mpt_reset(mpt, /*reinit*/FALSE);
---
> }
2065c1954
< for (i = 0; i < MPT_NUM_REPLY_HANDLERS; i++)
---
> for (i = 0; i < MPT_NUM_REPLY_HANDLERS; i++) {
2066a1956
> }
2074d1963
<
2087a1977
>
2093c1983
< for (val = 0; val < MPT_MAX_REQUESTS(mpt); val++)
---
> for (val = 0; val < MPT_MAX_REQUESTS(mpt); val++) {
2094a1985
> }
2095a1987,1995
> for (val = 0; val < MPT_MAX_LUNS; val++) {
> STAILQ_INIT(&mpt->trt[val].atios);
> STAILQ_INIT(&mpt->trt[val].inots);
> }
> STAILQ_INIT(&mpt->trt_wildcard.atios);
> STAILQ_INIT(&mpt->trt_wildcard.inots);
>
> mpt->scsi_tgt_handler_id = MPT_HANDLER_ID_NONE;
>
2099c1999
< mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL)));
---
> mpt_ioc_diag(mpt_read(mpt, MPT_OFFSET_DOORBELL)));
2105a2006,2052
> int
> mpt_core_enable(struct mpt_softc *mpt)
> {
> /*
> * We enter with the IOC enabled, but async events
> * not enabled, ports not enabled and interrupts
> * not enabled.
> */
>
> /*
> * Enable asynchronous event reporting- all personalities
> * have attached so that they should be able to now field
> * async events.
> */
> mpt_send_event_request(mpt, 1);
>
> /*
> * Catch any pending interrupts
> *
> * This seems to be crucial- otherwise
> * the portenable below times out.
> */
> mpt_intr(mpt);
>
> /*
> * Enable Interrupts
> */
> mpt_enable_ints(mpt);
>
> /*
> * Catch any pending interrupts
> *
> * This seems to be crucial- otherwise
> * the portenable below times out.
> */
> mpt_intr(mpt);
>
> /*
> * Enable the port- but only if we are not MPT_ROLE_NONE.
> */
> if (mpt_send_port_enable(mpt, 0) != MPT_OK) {
> mpt_prt(mpt, "failed to enable port 0\n");
> return (ENXIO);
> }
> return (0);
> }
>
2108a2056
> mpt_disable_ints(mpt);
2113a2062
> mpt_disable_ints(mpt);
2265c2214
< if (needreset || (mpt_rd_db(mpt) & MPT_DB_STATE_MASK) !=
---
> if (needreset || MPT_STATE(mpt_rd_db(mpt)) !=
2267c2216
< if (mpt_reset(mpt, /*reinit*/FALSE) != MPT_OK)
---
> if (mpt_reset(mpt, FALSE) != MPT_OK) {
2268a2218
> }
2411,2414c2361,2362
< if (!(pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR)) {
< mpt_prt(mpt, "initiator role unsupported\n");
< return (ENXIO);
< }
---
> mpt->mpt_max_tgtcmds = le16toh(pfp.MaxPostedCmdBuffers);
>
2428,2429c2376,2393
< if (mpt_enable_ioc(mpt) != 0) {
< mpt_prt(mpt, "Unable to initialize IOC\n");
---
> /*
> * Match our expected role with what this port supports.
> *
> * We only do this to meet expectations. That is, if the
> * user has specified they want initiator role, and we
> * don't support it, that's an error we return back upstream.
> */
>
> mpt->cap = MPT_ROLE_NONE;
> if (pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) {
> mpt->cap |= MPT_ROLE_INITIATOR;
> }
> if (pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) {
> mpt->cap |= MPT_ROLE_TARGET;
> }
> if (mpt->cap == MPT_ROLE_NONE) {
> mpt_prt(mpt, "port does not support either target or "
> "initiator role\n");
2432a2397,2413
> if ((mpt->role & MPT_ROLE_INITIATOR) &&
> (mpt->cap & MPT_ROLE_INITIATOR) == 0) {
> mpt_prt(mpt, "port does not support initiator role\n");
> return (ENXIO);
> }
>
> if ((mpt->role & MPT_ROLE_TARGET) &&
> (mpt->cap & MPT_ROLE_TARGET) == 0) {
> mpt_prt(mpt, "port does not support target role\n");
> return (ENXIO);
> }
>
> if (mpt_enable_ioc(mpt, 0) != MPT_OK) {
> mpt_prt(mpt, "unable to initialize IOC\n");
> return (ENXIO);
> }
>
2434,2439c2415
< * Read and set up initial configuration information
< * (IOC and SPI only for now)
< *
< * XXX Should figure out what "personalities" are
< * available and defer all initialization junk to
< * them.
---
> * Read IOC configuration information.
2443,2451d2418
< if (mpt->is_fc == 0 && mpt->is_sas == 0) {
< if (mpt_read_config_info_spi(mpt)) {
< return (EIO);
< }
< if (mpt_set_initial_config_spi(mpt)) {
< return (EIO);
< }
< }
<
2461,2463d2427
< mpt_lprt(mpt, MPT_PRT_DEBUG, "enabling interrupts\n");
<
< mpt_enable_ints(mpt);
2468c2432
< mpt_enable_ioc(struct mpt_softc *mpt)
---
> mpt_enable_ioc(struct mpt_softc *mpt, int portenable)
2499,2502d2462
< /*
< * Enable asynchronous event reporting
< */
< mpt_send_event_request(mpt, 1);
2505c2465
< * Enable the port
---
> * Enable the port if asked
2507,2511c2467,2471
< if (mpt_send_port_enable(mpt, 0) != MPT_OK) {
< mpt_prt(mpt, "failed to enable port 0\n");
< return (ENXIO);
< }
< mpt_lprt(mpt, MPT_PRT_DEBUG, "enabled port 0\n");
---
> if (portenable) {
> /*
> * Enable asynchronous event reporting
> */
> mpt_send_event_request(mpt, 1);
2513c2473,2477
<
---
> if (mpt_send_port_enable(mpt, 0) != MPT_OK) {
> mpt_prt(mpt, "failed to enable port 0\n");
> return (ENXIO);
> }
> }