diff --git a/sys/dev/mpt/mpt.c b/sys/dev/mpt/mpt.c index 445df5518d64..1b44333bfb36 100644 --- a/sys/dev/mpt/mpt.c +++ b/sys/dev/mpt/mpt.c @@ -1637,7 +1637,7 @@ mpt_read_extcfg_header(struct mpt_softc *mpt, int PageVersion, int PageNumber, rslt->PageVersion = cfgp->Header.PageVersion; rslt->PageNumber = cfgp->Header.PageNumber; rslt->PageType = cfgp->Header.PageType; - rslt->ExtPageLength = cfgp->ExtPageLength; + rslt->ExtPageLength = le16toh(cfgp->ExtPageLength); rslt->ExtPageType = cfgp->ExtPageType; error = 0; break; @@ -1668,7 +1668,7 @@ mpt_read_extcfg_page(struct mpt_softc *mpt, int Action, uint32_t PageAddress, req = mpt_get_request(mpt, sleep_ok); if (req == NULL) { - mpt_prt(mpt, "mpt_read_cfg_page: Get request failed!\n"); + mpt_prt(mpt, "mpt_read_extcfg_page: Get request failed!\n"); return (-1); } @@ -2025,6 +2025,7 @@ mpt_read_config_info_ioc(struct mpt_softc *mpt) mpt_raid_free_mem(mpt); return (EIO); } + mpt2host_config_page_ioc3(mpt->ioc_page3); mpt_raid_wakeup(mpt); return (0); } @@ -2760,6 +2761,7 @@ mpt_enable_ioc(struct mpt_softc *mpt, int portenable) void mpt2host_sge_simple_union(SGE_SIMPLE_UNION *sge) { + MPT_2_HOST32(sge, FlagsLength); MPT_2_HOST32(sge, u.Address64.Low); MPT_2_HOST32(sge, u.Address64.High); @@ -2768,6 +2770,7 @@ mpt2host_sge_simple_union(SGE_SIMPLE_UNION *sge) void mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *rp) { + MPT_2_HOST16(rp, MsgVersion); MPT_2_HOST16(rp, HeaderVersion); MPT_2_HOST32(rp, MsgContext); @@ -2794,6 +2797,7 @@ mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *rp) void mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *pfp) { + MPT_2_HOST16(pfp, Reserved); MPT_2_HOST16(pfp, Reserved1); MPT_2_HOST32(pfp, MsgContext); @@ -2809,20 +2813,139 @@ mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *pfp) MPT_2_HOST16(pfp, Reserved4); MPT_2_HOST32(pfp, Reserved5); } + void mpt2host_config_page_ioc2(CONFIG_PAGE_IOC_2 *ioc2) { int i; - ioc2->CapabilitiesFlags = htole32(ioc2->CapabilitiesFlags); + + MPT_2_HOST32(ioc2, CapabilitiesFlags); for (i = 0; i < MPI_IOC_PAGE_2_RAID_VOLUME_MAX; i++) { MPT_2_HOST16(ioc2, RaidVolume[i].Reserved3); } } +void +mpt2host_config_page_ioc3(CONFIG_PAGE_IOC_3 *ioc3) +{ + + MPT_2_HOST16(ioc3, Reserved2); +} + +void +mpt2host_config_page_scsi_port_0(CONFIG_PAGE_SCSI_PORT_0 *sp0) +{ + + MPT_2_HOST32(sp0, Capabilities); + MPT_2_HOST32(sp0, PhysicalInterface); +} + +void +mpt2host_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *sp1) +{ + + MPT_2_HOST32(sp1, Configuration); + MPT_2_HOST32(sp1, OnBusTimerValue); + MPT_2_HOST16(sp1, IDConfig); +} + +void +host2mpt_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *sp1) +{ + + HOST_2_MPT32(sp1, Configuration); + HOST_2_MPT32(sp1, OnBusTimerValue); + HOST_2_MPT16(sp1, IDConfig); +} + +void +mpt2host_config_page_scsi_port_2(CONFIG_PAGE_SCSI_PORT_2 *sp2) +{ + int i; + + MPT_2_HOST32(sp2, PortFlags); + MPT_2_HOST32(sp2, PortSettings); + for (i = 0; i < sizeof(sp2->DeviceSettings) / + sizeof(*sp2->DeviceSettings); i++) { + MPT_2_HOST16(sp2, DeviceSettings[i].DeviceFlags); + } +} + +void +mpt2host_config_page_scsi_device_0(CONFIG_PAGE_SCSI_DEVICE_0 *sd0) +{ + + MPT_2_HOST32(sd0, NegotiatedParameters); + MPT_2_HOST32(sd0, Information); +} + +void +mpt2host_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *sd1) +{ + + MPT_2_HOST32(sd1, RequestedParameters); + MPT_2_HOST32(sd1, Reserved); + MPT_2_HOST32(sd1, Configuration); +} + +void +host2mpt_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *sd1) +{ + + HOST_2_MPT32(sd1, RequestedParameters); + HOST_2_MPT32(sd1, Reserved); + HOST_2_MPT32(sd1, Configuration); +} + +void +mpt2host_config_page_fc_port_0(CONFIG_PAGE_FC_PORT_0 *fp0) +{ + + MPT_2_HOST32(fp0, Flags); + MPT_2_HOST32(fp0, PortIdentifier); + MPT_2_HOST32(fp0, WWNN.Low); + MPT_2_HOST32(fp0, WWNN.High); + MPT_2_HOST32(fp0, WWPN.Low); + MPT_2_HOST32(fp0, WWPN.High); + MPT_2_HOST32(fp0, SupportedServiceClass); + MPT_2_HOST32(fp0, SupportedSpeeds); + MPT_2_HOST32(fp0, CurrentSpeed); + MPT_2_HOST32(fp0, MaxFrameSize); + MPT_2_HOST32(fp0, FabricWWNN.Low); + MPT_2_HOST32(fp0, FabricWWNN.High); + MPT_2_HOST32(fp0, FabricWWPN.Low); + MPT_2_HOST32(fp0, FabricWWPN.High); + MPT_2_HOST32(fp0, DiscoveredPortsCount); + MPT_2_HOST32(fp0, MaxInitiators); +} + +void +mpt2host_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *fp1) +{ + + MPT_2_HOST32(fp1, Flags); + MPT_2_HOST32(fp1, NoSEEPROMWWNN.Low); + MPT_2_HOST32(fp1, NoSEEPROMWWNN.High); + MPT_2_HOST32(fp1, NoSEEPROMWWPN.Low); + MPT_2_HOST32(fp1, NoSEEPROMWWPN.High); +} + +void +host2mpt_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *fp1) +{ + + HOST_2_MPT32(fp1, Flags); + HOST_2_MPT32(fp1, NoSEEPROMWWNN.Low); + HOST_2_MPT32(fp1, NoSEEPROMWWNN.High); + HOST_2_MPT32(fp1, NoSEEPROMWWPN.Low); + HOST_2_MPT32(fp1, NoSEEPROMWWPN.High); +} + void mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0 *volp) { int i; + MPT_2_HOST16(volp, VolumeStatus.Reserved); MPT_2_HOST16(volp, VolumeSettings.Settings); MPT_2_HOST32(volp, MaxLBA); @@ -2835,9 +2958,22 @@ mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0 *volp) } } +void +mpt2host_config_page_raid_phys_disk_0(CONFIG_PAGE_RAID_PHYS_DISK_0 *rpd0) +{ + + MPT_2_HOST32(rpd0, Reserved1); + MPT_2_HOST16(rpd0, PhysDiskStatus.Reserved); + MPT_2_HOST32(rpd0, MaxLBA); + MPT_2_HOST16(rpd0, ErrorData.Reserved); + MPT_2_HOST16(rpd0, ErrorData.ErrorCount); + MPT_2_HOST16(rpd0, ErrorData.SmartCount); +} + void mpt2host_mpi_raid_vol_indicator(MPI_RAID_VOL_INDICATOR *vi) { + MPT_2_HOST16(vi, TotalBlocks.High); MPT_2_HOST16(vi, TotalBlocks.Low); MPT_2_HOST16(vi, BlocksRemaining.High); diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h index 56a023942b94..6817c4730cd6 100644 --- a/sys/dev/mpt/mpt.h +++ b/sys/dev/mpt/mpt.h @@ -317,14 +317,39 @@ void mpt2host_sge_simple_union(SGE_SIMPLE_UNION *); void mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *); void mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *); void mpt2host_config_page_ioc2(CONFIG_PAGE_IOC_2 *); +void mpt2host_config_page_ioc3(CONFIG_PAGE_IOC_3 *); +void mpt2host_config_page_scsi_port_0(CONFIG_PAGE_SCSI_PORT_0 *); +void mpt2host_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *); +void host2mpt_config_page_scsi_port_1(CONFIG_PAGE_SCSI_PORT_1 *); +void mpt2host_config_page_scsi_port_2(CONFIG_PAGE_SCSI_PORT_2 *); +void mpt2host_config_page_scsi_device_0(CONFIG_PAGE_SCSI_DEVICE_0 *); +void mpt2host_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *); +void host2mpt_config_page_scsi_device_1(CONFIG_PAGE_SCSI_DEVICE_1 *); +void mpt2host_config_page_fc_port_0(CONFIG_PAGE_FC_PORT_0 *); +void mpt2host_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *); +void host2mpt_config_page_fc_port_1(CONFIG_PAGE_FC_PORT_1 *); void mpt2host_config_page_raid_vol_0(CONFIG_PAGE_RAID_VOL_0 *); +void mpt2host_config_page_raid_phys_disk_0(CONFIG_PAGE_RAID_PHYS_DISK_0 *); void mpt2host_mpi_raid_vol_indicator(MPI_RAID_VOL_INDICATOR *); #else #define mpt2host_sge_simple_union(x) do { ; } while (0) #define mpt2host_iocfacts_reply(x) do { ; } while (0) #define mpt2host_portfacts_reply(x) do { ; } while (0) #define mpt2host_config_page_ioc2(x) do { ; } while (0) +#define mpt2host_config_page_ioc3(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_0(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_1(x) do { ; } while (0) +#define host2mpt_config_page_scsi_port_1(x) do { ; } while (0) +#define mpt2host_config_page_scsi_port_2(x) do { ; } while (0) +#define mpt2host_config_page_scsi_device_0(x) do { ; } while (0) +#define mpt2host_config_page_scsi_device_1(x) do { ; } while (0) +#define host2mpt_config_page_scsi_device_1(x) do { ; } while (0) +#define mpt2host_config_page_fc_port_0(x) do { ; } while (0) +#define mpt2host_config_page_fc_port_1(x) do { ; } while (0) +#define host2mpt_config_page_fc_port_1(x) do { ; } while (0) #define mpt2host_config_page_raid_vol_0(x) do { ; } while (0) +#define mpt2host_config_page_raid_phys_disk_0(x) \ + do { ; } while (0) #define mpt2host_mpi_raid_vol_indicator(x) do { ; } while (0) #endif diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c index eab2083ebc7f..9f28925e0bb1 100644 --- a/sys/dev/mpt/mpt_cam.c +++ b/sys/dev/mpt/mpt_cam.c @@ -437,6 +437,7 @@ mpt_read_config_info_fc(struct mpt_softc *mpt) mpt_prt(mpt, "failed to read FC Port Page 0\n"); return (-1); } + mpt2host_config_page_fc_port_0(&mpt->mpt_fcport_page0); mpt->mpt_fcport_speed = mpt->mpt_fcport_page0.CurrentSpeed; @@ -527,13 +528,14 @@ mpt_set_initial_config_fc(struct mpt_softc *mpt) mpt_prt(mpt, "failed to read FC page 1\n"); return (mpt_fc_reset_link(mpt, 1)); } + mpt2host_config_page_fc_port_1(&fc); /* * Check our flags to make sure we support the role we want. */ doit = 0; role = 0; - fl = le32toh(fc.Flags);; + fl = fc.Flags; if (fl & MPI_FCPORTPAGE1_FLAGS_PROT_FCP_INIT) { role |= MPT_ROLE_INITIATOR; @@ -587,7 +589,8 @@ mpt_set_initial_config_fc(struct mpt_softc *mpt) } if (doit) { - fc.Flags = htole32(fl); + fc.Flags = fl; + host2mpt_config_page_fc_port_1(&fc); r = mpt_write_cfg_page(mpt, MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM, 0, &fc.Header, sizeof(fc), FALSE, 5000); @@ -982,6 +985,7 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 0\n"); } else { + mpt2host_config_page_scsi_port_0(&mpt->mpt_port_page0); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "SPI Port Page 0: Capabilities %x PhysicalInterface %x\n", mpt->mpt_port_page0.Capabilities, @@ -993,6 +997,7 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) if (rv) { mpt_prt(mpt, "failed to read SPI Port Page 1\n"); } else { + mpt2host_config_page_scsi_port_1(&mpt->mpt_port_page1); mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 1: Configuration %x OnBusTimerValue %x\n", mpt->mpt_port_page1.Configuration, @@ -1008,6 +1013,7 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) "Port Page 2: Flags %x Settings %x\n", mpt->mpt_port_page2.PortFlags, mpt->mpt_port_page2.PortSettings); + mpt2host_config_page_scsi_port_2(&mpt->mpt_port_page2); for (i = 0; i < 16; i++) { mpt_lprt(mpt, MPT_PRT_NEGOTIATION, " Port Page 2 Tgt %d: timo %x SF %x Flags %x\n", @@ -1026,6 +1032,7 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) "cannot read SPI Target %d Device Page 0\n", i); continue; } + mpt2host_config_page_scsi_device_0(&mpt->mpt_dev_page0[i]); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "target %d page 0: Negotiated Params %x Information %x\n", i, mpt->mpt_dev_page0[i].NegotiatedParameters, @@ -1039,6 +1046,7 @@ mpt_read_config_info_spi(struct mpt_softc *mpt) "cannot read SPI Target %d Device Page 1\n", i); continue; } + mpt2host_config_page_scsi_device_1(&mpt->mpt_dev_page1[i]); mpt_lprt(mpt, MPT_PRT_NEGOTIATION, "target %d page 1: Requested Params %x Configuration %x\n", i, mpt->mpt_dev_page1[i].RequestedParameters, @@ -1068,6 +1076,7 @@ mpt_set_initial_config_spi(struct mpt_softc *mpt) "be %x\n", mpt->mpt_port_page1.Configuration, pp1val); tmp = mpt->mpt_port_page1; tmp.Configuration = pp1val; + host2mpt_config_page_scsi_port_1(&tmp); error = mpt_write_cur_cfg_page(mpt, 0, &tmp.Header, sizeof(tmp), FALSE, 5000); if (error) { @@ -1078,6 +1087,7 @@ mpt_set_initial_config_spi(struct mpt_softc *mpt) if (error) { return (-1); } + mpt2host_config_page_scsi_port_1(&tmp); if (tmp.Configuration != pp1val) { mpt_prt(mpt, "failed to reset SPI Port Page 1 Config value\n"); @@ -1432,7 +1442,8 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) memset(se, 0, sizeof (*se)); se->Address.Low = htole32(dm_segs->ds_addr & 0xffffffff); if (sizeof(bus_addr_t) > 4) { - se->Address.High = ((uint64_t) dm_segs->ds_addr) >> 32; + se->Address.High = + htole32(((uint64_t)dm_segs->ds_addr) >> 32); } MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); tf = flags; @@ -1507,9 +1518,9 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) chain_list_addr += cur_off; if (sizeof (bus_addr_t) > 4) { ce->Address.High = - htole32((uint32_t) ((uint64_t)chain_list_addr >> 32)); + htole32(((uint64_t)chain_list_addr) >> 32); } - ce->Address.Low = htole32((uint32_t) chain_list_addr); + ce->Address.Low = htole32(chain_list_addr & 0xffffffff); ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT | MPI_SGE_FLAGS_64_BIT_ADDRESSING; @@ -1536,6 +1547,7 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) ce->Length = (this_seg_lim - seg) * sizeof (SGE_SIMPLE64); } + ce->Length = htole16(ce->Length); /* * Fill in the chain list SGE elements with our segment data. @@ -1546,7 +1558,8 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) */ while (seg < this_seg_lim) { memset(se, 0, sizeof (*se)); - se->Address.Low = htole32(dm_segs->ds_addr); + se->Address.Low = htole32(dm_segs->ds_addr & + 0xffffffff); if (sizeof (bus_addr_t) > 4) { se->Address.High = htole32(((uint64_t)dm_segs->ds_addr) >> 32); @@ -1830,7 +1843,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) uint32_t tf; memset(se, 0,sizeof (*se)); - se->Address = dm_segs->ds_addr; + se->Address = htole32(dm_segs->ds_addr); @@ -1908,7 +1921,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) - ce->Address = chain_list_addr; + ce->Address = htole32(chain_list_addr); ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; @@ -1935,6 +1948,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) ce->Length = (this_seg_lim - seg) * sizeof (SGE_SIMPLE32); } + ce->Length = htole16(ce->Length); /* * Fill in the chain list SGE elements with our segment data. @@ -1945,7 +1959,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) */ while (seg < this_seg_lim) { memset(se, 0, sizeof (*se)); - se->Address = dm_segs->ds_addr; + se->Address = htole32(dm_segs->ds_addr); @@ -2193,6 +2207,7 @@ mpt_start(struct cam_sim *sim, union ccb *ccb) mpt_req->Control |= MPI_SCSIIO_CONTROL_NO_DISCONNECT; } } + mpt_req->Control = htole32(mpt_req->Control); /* Copy the scsi command block into place */ if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) { @@ -2317,7 +2332,7 @@ mpt_bus_reset(struct mpt_softc *mpt, target_id_t tgt, lun_id_t lun, error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, REQ_STATE_DONE, sleep_ok, 5000); - status = mpt->tmf_req->IOCStatus; + status = le16toh(mpt->tmf_req->IOCStatus); response = mpt->tmf_req->ResponseCode; mpt->tmf_req->state = REQ_STATE_FREE; @@ -2524,10 +2539,11 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req, struct cam_sim *sim; struct cam_path *tmppath; struct ccb_relsim crs; - PTR_EVENT_DATA_QUEUE_FULL pqf = - (PTR_EVENT_DATA_QUEUE_FULL) msg->Data; + PTR_EVENT_DATA_QUEUE_FULL pqf; lun_id_t lun_id; + pqf = (PTR_EVENT_DATA_QUEUE_FULL)msg->Data; + pqf->CurrentDepth = le16toh(pqf->CurrentDepth); mpt_prt(mpt, "QUEUE FULL EVENT: Bus 0x%02x Target 0x%02x Depth " "%d\n", pqf->Bus, pqf->TargetID, pqf->CurrentDepth); if (mpt->phydisk_sim) { @@ -3086,9 +3102,10 @@ mpt_scsi_reply_frame_handler(struct mpt_softc *mpt, request_t *req, && (ccb->ccb_h.flags & (CAM_SENSE_PHYS | CAM_SENSE_PTR)) == 0) { ccb->ccb_h.status |= CAM_AUTOSNS_VALID; ccb->csio.sense_resid = - ccb->csio.sense_len - scsi_io_reply->SenseCount; + ccb->csio.sense_len - le32toh(scsi_io_reply->SenseCount); bcopy(req->sense_vbuf, &ccb->csio.sense_data, - min(ccb->csio.sense_len, scsi_io_reply->SenseCount)); + min(ccb->csio.sense_len, + le32toh(scsi_io_reply->SenseCount))); } if ((sstate & MPI_SCSI_STATE_QUEUE_TAG_REJECTED) != 0) { @@ -3776,6 +3793,8 @@ mpt_get_spi_settings(struct mpt_softc *mpt, struct ccb_trans_settings *cts) mpt_prt(mpt, "can't get tgt %d config page 0\n", tgt); return (rv); } + mpt2host_config_page_scsi_device_0(&tmp); + MPTLOCK_2_CAMLOCK(mpt); mpt_lprt(mpt, MPT_PRT_DEBUG, "mpt_get_spi_settings[%d]: current NP %x Info %x\n", tgt, @@ -3905,6 +3924,7 @@ mpt_update_spi_config(struct mpt_softc *mpt, int tgt) "mpt_update_spi_config[%d].page1: Requested Params 0x%08x\n", tgt, mpt->mpt_dev_page1[tgt].RequestedParameters); tmp = mpt->mpt_dev_page1[tgt]; + host2mpt_config_page_scsi_device_1(&tmp); rv = mpt_write_cur_cfg_page(mpt, tgt, &tmp.Header, sizeof(tmp), FALSE, 5000); if (rv) { @@ -4156,7 +4176,7 @@ mpt_recover_commands(struct mpt_softc *mpt) error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, REQ_STATE_DONE, TRUE, 500); - status = mpt->tmf_req->IOCStatus; + status = le16toh(mpt->tmf_req->IOCStatus); response = mpt->tmf_req->ResponseCode; mpt->tmf_req->state = REQ_STATE_FREE; diff --git a/sys/dev/mpt/mpt_raid.c b/sys/dev/mpt/mpt_raid.c index cde0fec0b654..0d5e03a730aa 100644 --- a/sys/dev/mpt/mpt_raid.c +++ b/sys/dev/mpt/mpt_raid.c @@ -564,7 +564,7 @@ mpt_raid_reply_frame_handler(struct mpt_softc *mpt, request_t *req, action_result = REQ_TO_RAID_ACTION_RESULT(req); memcpy(&action_result->action_data, &reply->ActionData, sizeof(action_result->action_data)); - action_result->action_status = reply->ActionStatus; + action_result->action_status = le16toh(reply->ActionStatus); return (TRUE); } @@ -583,7 +583,7 @@ mpt_issue_raid_req(struct mpt_softc *mpt, struct mpt_raid_volume *vol, rap = req->req_vbuf; memset(rap, 0, sizeof *rap); rap->Action = Action; - rap->ActionDataWord = ActionDataWord; + rap->ActionDataWord = htole32(ActionDataWord); rap->Function = MPI_FUNCTION_RAID_ACTION; rap->VolumeID = vol->config_page->VolumeID; rap->VolumeBus = vol->config_page->VolumeBus; @@ -592,12 +592,13 @@ mpt_issue_raid_req(struct mpt_softc *mpt, struct mpt_raid_volume *vol, else rap->PhysDiskNum = 0xFF; se = (SGE_SIMPLE32 *)&rap->ActionDataSGE; - se->Address = addr; + se->Address = htole32(addr); MPI_pSGE_SET_LENGTH(se, len); MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_END_OF_LIST | write ? MPI_SGE_FLAGS_HOST_TO_IOC : MPI_SGE_FLAGS_IOC_TO_HOST)); + se->FlagsLength = htole32(se->FlagsLength); rap->MsgContext = htole32(req->index | raid_handler_id); mpt_check_doorbell(mpt); @@ -1226,6 +1227,7 @@ mpt_refresh_raid_disk(struct mpt_softc *mpt, struct mpt_raid_disk *mpt_disk, mpt_prt(mpt, "mpt_refresh_raid_disk: " "Failed to read RAID Disk Page(%d)\n", ioc_disk->PhysDiskNum); + mpt2host_config_page_raid_phys_disk_0(&mpt_disk->config_page); } static void @@ -1354,6 +1356,7 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) "mpt_refresh_raid_data: Failed to read IOC Page 3\n"); return (-1); } + mpt2host_config_page_ioc3(mpt->ioc_page3); ioc_disk = mpt->ioc_page3->PhysDisk; ioc_last_disk = ioc_disk + mpt->ioc_page3->NumPhysDisks; @@ -1384,6 +1387,7 @@ mpt_refresh_raid_data(struct mpt_softc *mpt) "Failed to read IOC Page 2\n"); return (-1); } + mpt2host_config_page_ioc2(mpt->ioc_page2); ioc_vol = mpt->ioc_page2->RaidVolume; ioc_last_vol = ioc_vol + mpt->ioc_page2->NumActiveVolumes; diff --git a/sys/dev/mpt/mpt_user.c b/sys/dev/mpt/mpt_user.c index a87b3301a1c2..971c26232414 100644 --- a/sys/dev/mpt/mpt_user.c +++ b/sys/dev/mpt/mpt_user.c @@ -256,7 +256,7 @@ mpt_user_read_cfg_header(struct mpt_softc *mpt, params.PageLength = 0; params.PageNumber = page_req->header.PageNumber; params.PageType = page_req->header.PageType; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0, TRUE, 5000); if (error != 0) { @@ -270,7 +270,7 @@ mpt_user_read_cfg_header(struct mpt_softc *mpt, return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) { cfgp = req->req_vbuf; bcopy(&cfgp->Header, &page_req->header, @@ -301,15 +301,15 @@ mpt_user_read_cfg_page(struct mpt_softc *mpt, struct mpt_cfg_page_req *page_req, params.PageLength = hdr->PageLength; params.PageNumber = hdr->PageNumber; params.PageType = hdr->PageType & MPI_CONFIG_PAGETYPE_MASK; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - page_req->len, TRUE, 5000); + le32toh(page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_user_read_cfg_page timed out\n"); return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD); @@ -337,7 +337,7 @@ mpt_user_read_extcfg_header(struct mpt_softc *mpt, params.PageLength = 0; params.PageNumber = ext_page_req->header.PageNumber; params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; - params.PageAddress = ext_page_req->page_address; + params.PageAddress = le32toh(ext_page_req->page_address); params.ExtPageType = ext_page_req->header.ExtPageType; params.ExtPageLength = 0; error = mpt_issue_cfg_req(mpt, req, ¶ms, /*addr*/0, /*len*/0, @@ -353,7 +353,7 @@ mpt_user_read_extcfg_header(struct mpt_softc *mpt, return (ETIMEDOUT); } - ext_page_req->ioc_status = req->IOCStatus; + ext_page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) { cfgp = req->req_vbuf; ext_page_req->header.PageVersion = cfgp->Header.PageVersion; @@ -387,17 +387,17 @@ mpt_user_read_extcfg_page(struct mpt_softc *mpt, params.PageLength = 0; params.PageNumber = hdr->PageNumber; params.PageType = MPI_CONFIG_PAGETYPE_EXTENDED; - params.PageAddress = ext_page_req->page_address; + params.PageAddress = le32toh(ext_page_req->page_address); params.ExtPageType = hdr->ExtPageType; params.ExtPageLength = hdr->ExtPageLength; error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - ext_page_req->len, TRUE, 5000); + le32toh(ext_page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_user_read_extcfg_page timed out\n"); return (ETIMEDOUT); } - ext_page_req->ioc_status = req->IOCStatus; + ext_page_req->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) == MPI_IOCSTATUS_SUCCESS) bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_POSTREAD); @@ -446,7 +446,7 @@ mpt_user_write_cfg_page(struct mpt_softc *mpt, params.PageVersion = hdr->PageVersion; params.PageLength = hdr->PageLength; params.PageNumber = hdr->PageNumber; - params.PageAddress = page_req->page_address; + params.PageAddress = le32toh(page_req->page_address); #if 0 /* Restore stripped out attributes */ hdr->PageType |= hdr_attr; @@ -455,13 +455,13 @@ mpt_user_write_cfg_page(struct mpt_softc *mpt, params.PageType = hdr->PageType; #endif error = mpt_issue_cfg_req(mpt, req, ¶ms, mpt_page->paddr, - page_req->len, TRUE, 5000); + le32toh(page_req->len), TRUE, 5000); if (error != 0) { mpt_prt(mpt, "mpt_write_cfg_page timed out\n"); return (ETIMEDOUT); } - page_req->ioc_status = req->IOCStatus; + page_req->ioc_status = htole16(req->IOCStatus); mpt_free_request(mpt, req); return (0); } @@ -536,14 +536,15 @@ mpt_user_raid_action(struct mpt_softc *mpt, struct mpt_raid_action *raid_act, if (mpt_page->vaddr != NULL && raid_act->len != 0) { bus_dmamap_sync(mpt_page->tag, mpt_page->map, BUS_DMASYNC_PREWRITE); - se->Address = mpt_page->paddr; - MPI_pSGE_SET_LENGTH(se, raid_act->len); + se->Address = htole32(mpt_page->paddr); + MPI_pSGE_SET_LENGTH(se, le32toh(raid_act->len)); MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER | MPI_SGE_FLAGS_END_OF_LIST | raid_act->write ? MPI_SGE_FLAGS_HOST_TO_IOC : MPI_SGE_FLAGS_IOC_TO_HOST)); } + se->FlagsLength = htole32(se->FlagsLength); rap->MsgContext = htole32(req->index | user_handler_id); mpt_check_doorbell(mpt); @@ -559,7 +560,7 @@ mpt_user_raid_action(struct mpt_softc *mpt, struct mpt_raid_action *raid_act, return (error); } - raid_act->ioc_status = req->IOCStatus; + raid_act->ioc_status = htole16(req->IOCStatus); if ((req->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) { mpt_free_request(mpt, req); return (0);