Module Name: src
Committed By: chs
Date: Wed Apr 28 22:45:27 UTC 2010
Modified Files:
src/sys/dev/ic: mpt.c mpt.h mpt_debug.c mpt_netbsd.c
Log Message:
add byte-swapping so that this works on BE platforms.
the logic is based on the current freebsd driver.
fixes PR 42870.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/mpt.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/mpt.h src/sys/dev/ic/mpt_debug.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/mpt_netbsd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/mpt.c
diff -u src/sys/dev/ic/mpt.c:1.13 src/sys/dev/ic/mpt.c:1.14
--- src/sys/dev/ic/mpt.c:1.13 Sat Apr 18 14:58:02 2009
+++ src/sys/dev/ic/mpt.c Wed Apr 28 22:45:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt.c,v 1.13 2009/04/18 14:58:02 tsutsui Exp $ */
+/* $NetBSD: mpt.c,v 1.14 2010/04/28 22:45:27 chs Exp $ */
/*
* Copyright (c) 2000, 2001 by Greg Ansley
@@ -27,6 +27,75 @@
/*
* Additional Copyright (c) 2002 by Matthew Jacob under same license.
*/
+/*-
+ * Copyright (c) 2002, 2006 by Matthew Jacob
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon including
+ * a substantially similar Disclaimer requirement for further binary
+ * redistribution.
+ * 3. Neither the names of the above listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
+ * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Support from Chris Ellsworth in order to make SAS adapters work
+ * is gratefully acknowledged.
+ *
+ *
+ * Support from LSI-Logic has also gone a great deal toward making this a
+ * workable subsystem and is gratefully acknowledged.
+ */
+/*-
+ * Copyright (c) 2004, Avid Technology, Inc. and its contributors.
+ * Copyright (c) 2005, WHEEL Sp. z o.o.
+ * Copyright (c) 2004, 2005 Justin T. Gibbs
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon including
+ * a substantially similar Disclaimer requirement for further binary
+ * redistribution.
+ * 3. Neither the names of the above listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
+ * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
/*
@@ -41,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.13 2009/04/18 14:58:02 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.14 2010/04/28 22:45:27 chs Exp $");
#include <dev/ic/mpt.h>
@@ -346,7 +415,7 @@
/* Send the command */
for (i = 0; i < len; i++) {
- mpt_write(mpt, MPT_OFFSET_DOORBELL, *data32++);
+ mpt_write(mpt, MPT_OFFSET_DOORBELL, htole32(*data32++));
if (mpt_wait_db_ack(mpt) != MPT_OK) {
mpt_prt(mpt,
"mpt_send_handshake_cmd timeout! index = %d", i);
@@ -375,7 +444,8 @@
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout1");
return ETIMEDOUT;
}
- *data16++ = mpt_read(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
+ *data16++ = le16toh(mpt_read(mpt, MPT_OFFSET_DOORBELL) &
+ MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
/* Get Second Word */
@@ -383,7 +453,8 @@
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout2");
return ETIMEDOUT;
}
- *data16++ = mpt_read(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
+ *data16++ = le16toh(mpt_read(mpt, MPT_OFFSET_DOORBELL) &
+ MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
/* With the second word, we can now look at the length */
@@ -406,7 +477,7 @@
datum = mpt_read(mpt, MPT_OFFSET_DOORBELL);
if (reply_left-- > 0)
- *data16++ = datum & MPT_DB_DATA_MASK;
+ *data16++ = le16toh(datum & MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
}
@@ -435,7 +506,7 @@
memset(&f_req, 0, sizeof f_req);
f_req.Function = MPI_FUNCTION_IOC_FACTS;
- f_req.MsgContext = 0x12071942;
+ f_req.MsgContext = htole32(0x12071942);
error = mpt_send_handshake_cmd(mpt, sizeof f_req, &f_req);
if (error)
return(error);
@@ -452,7 +523,7 @@
/* XXX: Only getting PORT FACTS for Port 0 */
memset(&f_req, 0, sizeof f_req);
f_req.Function = MPI_FUNCTION_PORT_FACTS;
- f_req.MsgContext = 0x12071943;
+ f_req.MsgContext = htole32(0x12071943);
error = mpt_send_handshake_cmd(mpt, sizeof f_req, &f_req);
if (error)
return(error);
@@ -478,8 +549,8 @@
init.Function = MPI_FUNCTION_IOC_INIT;
init.MaxDevices = mpt->mpt_max_devices;
init.MaxBuses = 1;
- init.ReplyFrameSize = MPT_REPLY_SIZE;
- init.MsgContext = 0x12071941;
+ init.ReplyFrameSize = htole16(MPT_REPLY_SIZE);
+ init.MsgContext = htole32(0x12071941);
if ((error = mpt_send_handshake_cmd(mpt, sizeof init, &init)) != 0) {
return(error);
@@ -515,11 +586,11 @@
cfgp->Function = MPI_FUNCTION_CONFIG;
cfgp->Header.PageNumber = (U8) PageNumber;
cfgp->Header.PageType = (U8) PageType;
- cfgp->PageAddress = PageAddress;
+ cfgp->PageAddress = htole32(PageAddress);
MPI_pSGE_SET_FLAGS(((SGE_SIMPLE32 *) &cfgp->PageBufferSGE),
(MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_LIST));
- cfgp->MsgContext = req->index | 0x80000000;
+ cfgp->MsgContext = htole32(req->index | 0x80000000);
mpt_check_doorbell(mpt);
mpt_send_cmd(mpt, req);
@@ -567,15 +638,16 @@
cfgp->Header = *hdr;
amt = (cfgp->Header.PageLength * sizeof (u_int32_t));
cfgp->Header.PageType &= MPI_CONFIG_PAGETYPE_MASK;
- cfgp->PageAddress = PageAddress;
+ cfgp->PageAddress = htole32(PageAddress);
se = (SGE_SIMPLE32 *) &cfgp->PageBufferSGE;
- se->Address = req->req_pbuf + CFG_DATA_OFF;
+ se->Address = htole32(req->req_pbuf + CFG_DATA_OFF);
MPI_pSGE_SET_LENGTH(se, amt);
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));
+ se->FlagsLength = htole32(se->FlagsLength);
- cfgp->MsgContext = req->index | 0x80000000;
+ cfgp->MsgContext = htole32(req->index | 0x80000000);
mpt_check_doorbell(mpt);
mpt_send_cmd(mpt, req);
@@ -650,16 +722,17 @@
cfgp->Function = MPI_FUNCTION_CONFIG;
cfgp->Header = *hdr;
amt = (cfgp->Header.PageLength * sizeof (u_int32_t));
- cfgp->PageAddress = PageAddress;
+ cfgp->PageAddress = htole32(PageAddress);
se = (SGE_SIMPLE32 *) &cfgp->PageBufferSGE;
- se->Address = req->req_pbuf + CFG_DATA_OFF;
+ se->Address = htole32(req->req_pbuf + CFG_DATA_OFF);
MPI_pSGE_SET_LENGTH(se, amt);
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 | MPI_SGE_FLAGS_HOST_TO_IOC));
+ se->FlagsLength = htole32(se->FlagsLength);
- cfgp->MsgContext = req->index | 0x80000000;
+ cfgp->MsgContext = htole32(req->index | 0x80000000);
if (cfgp->Header.PageType == MPI_CONFIG_PAGETYPE_SCSI_PORT &&
cfgp->Header.PageNumber == 0) {
@@ -697,7 +770,7 @@
reply = (MSG_CONFIG_REPLY *) MPT_REPLY_PTOV(mpt, req->sequence);
if ((reply->IOCStatus & MPI_IOCSTATUS_MASK) != MPI_IOCSTATUS_SUCCESS) {
mpt_prt(mpt, "mpt_write_cfg_page: Config Info Status %x",
- reply->IOCStatus);
+ le16toh(reply->IOCStatus));
mpt_free_reply(mpt, (req->sequence << 1));
return (-1);
}
@@ -792,6 +865,7 @@
*/
rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page0.Header);
+ mpt2host_config_page_scsi_port_0(&mpt->mpt_port_page0);
if (rv) {
mpt_prt(mpt, "failed to read SPI Port Page 0");
} else if (mpt->verbose > 1) {
@@ -802,6 +876,7 @@
}
rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page1.Header);
+ mpt2host_config_page_scsi_port_1(&mpt->mpt_port_page1);
if (rv) {
mpt_prt(mpt, "failed to read SPI Port Page 1");
} else if (mpt->verbose > 1) {
@@ -812,6 +887,7 @@
}
rv = mpt_read_cfg_page(mpt, 0, &mpt->mpt_port_page2.Header);
+ mpt2host_config_page_scsi_port_2(&mpt->mpt_port_page2);
if (rv) {
mpt_prt(mpt, "failed to read SPI Port Page 2");
} else if (mpt->verbose > 1) {
@@ -819,7 +895,7 @@
"SPI Port Page 2: Flags %x Settings %x",
mpt->mpt_port_page2.PortFlags,
mpt->mpt_port_page2.PortSettings);
- for (i = 0; i < 16; i++) {
+ for (i = 0; i < 1; i++) {
mpt_prt(mpt,
"SPI Port Page 2 Tgt %d: timo %x SF %x Flags %x",
i, mpt->mpt_port_page2.DeviceSettings[i].Timeout,
@@ -830,6 +906,7 @@
for (i = 0; i < 16; i++) {
rv = mpt_read_cfg_page(mpt, i, &mpt->mpt_dev_page0[i].Header);
+ mpt2host_config_page_scsi_device_0(&mpt->mpt_dev_page0[i]);
if (rv) {
mpt_prt(mpt, "cannot read SPI Tgt %d Device Page 0", i);
continue;
@@ -841,6 +918,7 @@
mpt->mpt_dev_page0[i].Information);
}
rv = mpt_read_cfg_page(mpt, i, &mpt->mpt_dev_page1[i].Header);
+ mpt2host_config_page_scsi_device_1(&mpt->mpt_dev_page1[i]);
if (rv) {
mpt_prt(mpt, "cannot read SPI Tgt %d Device Page 1", i);
continue;
@@ -870,17 +948,20 @@
if (mpt->mpt_port_page1.Configuration != pp1val) {
fCONFIG_PAGE_SCSI_PORT_1 tmp;
+
mpt_prt(mpt,
"SPI Port Page 1 Config value bad (%x)- should be %x",
mpt->mpt_port_page1.Configuration, pp1val);
tmp = mpt->mpt_port_page1;
tmp.Configuration = pp1val;
+ host2mpt_config_page_scsi_port_1(&tmp);
if (mpt_write_cfg_page(mpt, 0, &tmp.Header)) {
return (-1);
}
if (mpt_read_cfg_page(mpt, 0, &tmp.Header)) {
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");
@@ -889,8 +970,10 @@
mpt->mpt_port_page1 = tmp;
}
+ i = 0;
for (i = 0; i < 16; i++) {
fCONFIG_PAGE_SCSI_DEVICE_1 tmp;
+
tmp = mpt->mpt_dev_page1[i];
tmp.RequestedParameters = 0;
tmp.Configuration = 0;
@@ -899,12 +982,14 @@
"Set Tgt %d SPI DevicePage 1 values to %x 0 %x",
i, tmp.RequestedParameters, tmp.Configuration);
}
+ host2mpt_config_page_scsi_device_1(&tmp);
if (mpt_write_cfg_page(mpt, i, &tmp.Header)) {
return (-1);
}
if (mpt_read_cfg_page(mpt, i, &tmp.Header)) {
return (-1);
}
+ mpt2host_config_page_scsi_device_1(&tmp);
mpt->mpt_dev_page1[i] = tmp;
if (mpt->verbose > 1) {
mpt_prt(mpt,
@@ -932,7 +1017,7 @@
memset(enable_req, 0, sizeof *enable_req);
enable_req->Function = MPI_FUNCTION_PORT_ENABLE;
- enable_req->MsgContext = req->index | 0x80000000;
+ enable_req->MsgContext = htole32(req->index | 0x80000000);
enable_req->PortNumber = port;
mpt_check_doorbell(mpt);
@@ -972,7 +1057,7 @@
memset(enable_req, 0, sizeof *enable_req);
enable_req->Function = MPI_FUNCTION_EVENT_NOTIFICATION;
- enable_req->MsgContext = req->index | 0x80000000;
+ enable_req->MsgContext = htole32(req->index | 0x80000000);
enable_req->Switch = onoff;
mpt_check_doorbell(mpt);
@@ -1075,11 +1160,12 @@
mpt_prt(mpt, "mpt_get_iocfacts failed");
continue;
}
+ mpt2host_iocfacts_reply(&facts);
if (mpt->verbose > 1) {
mpt_prt(mpt,
"IOCFACTS: GlobalCredits=%d BlockSize=%u "
- "Request Frame Size %u\n", facts.GlobalCredits,
+ "Request Frame Size %u", facts.GlobalCredits,
facts.BlockSize, facts.RequestFrameSize);
}
mpt->mpt_max_devices = facts.MaxDevices;
@@ -1090,10 +1176,11 @@
mpt_prt(mpt, "mpt_get_portfacts failed");
continue;
}
+ mpt2host_portfacts_reply(&pfp);
if (mpt->verbose > 1) {
mpt_prt(mpt,
- "PORTFACTS: Type %x PFlags %x IID %d MaxDev %d\n",
+ "PORTFACTS: Type %x PFlags %x IID %d MaxDev %d",
pfp.PortType, pfp.ProtocolFlags, pfp.PortSCSIID,
pfp.MaxDevices);
}
@@ -1202,3 +1289,223 @@
mpt_enable_ints(mpt);
return (0);
}
+
+/*
+ * Endian Conversion Functions- only used on Big Endian machines
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+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);
+}
+
+void
+mpt2host_iocfacts_reply(MSG_IOC_FACTS_REPLY *rp)
+{
+
+ MPT_2_HOST16(rp, MsgVersion);
+#if 0
+ MPT_2_HOST16(rp, HeaderVersion);
+#endif
+ MPT_2_HOST32(rp, MsgContext);
+ MPT_2_HOST16(rp, IOCExceptions);
+ MPT_2_HOST16(rp, IOCStatus);
+ MPT_2_HOST32(rp, IOCLogInfo);
+ MPT_2_HOST16(rp, ReplyQueueDepth);
+ MPT_2_HOST16(rp, RequestFrameSize);
+ MPT_2_HOST16(rp, Reserved_0101_FWVersion);
+ MPT_2_HOST16(rp, ProductID);
+ MPT_2_HOST32(rp, CurrentHostMfaHighAddr);
+ MPT_2_HOST16(rp, GlobalCredits);
+ MPT_2_HOST32(rp, CurrentSenseBufferHighAddr);
+ MPT_2_HOST16(rp, CurReplyFrameSize);
+ MPT_2_HOST32(rp, FWImageSize);
+#if 0
+ MPT_2_HOST32(rp, IOCCapabilities);
+#endif
+ MPT_2_HOST32(rp, FWVersion.Word);
+#if 0
+ MPT_2_HOST16(rp, HighPriorityQueueDepth);
+ MPT_2_HOST16(rp, Reserved2);
+ mpt2host_sge_simple_union(&rp->HostPageBufferSGE);
+ MPT_2_HOST32(rp, ReplyFifoHostSignalingAddr);
+#endif
+}
+
+void
+mpt2host_portfacts_reply(MSG_PORT_FACTS_REPLY *pfp)
+{
+
+ MPT_2_HOST16(pfp, Reserved);
+ MPT_2_HOST16(pfp, Reserved1);
+ MPT_2_HOST32(pfp, MsgContext);
+ MPT_2_HOST16(pfp, Reserved2);
+ MPT_2_HOST16(pfp, IOCStatus);
+ MPT_2_HOST32(pfp, IOCLogInfo);
+ MPT_2_HOST16(pfp, MaxDevices);
+ MPT_2_HOST16(pfp, PortSCSIID);
+ MPT_2_HOST16(pfp, ProtocolFlags);
+ MPT_2_HOST16(pfp, MaxPostedCmdBuffers);
+ MPT_2_HOST16(pfp, MaxPersistentIDs);
+ MPT_2_HOST16(pfp, MaxLanBuckets);
+ MPT_2_HOST16(pfp, Reserved4);
+ MPT_2_HOST32(pfp, Reserved5);
+}
+
+void
+mpt2host_config_page_scsi_port_0(fCONFIG_PAGE_SCSI_PORT_0 *sp0)
+{
+
+ MPT_2_HOST32(sp0, Capabilities);
+ MPT_2_HOST32(sp0, PhysicalInterface);
+}
+
+void
+mpt2host_config_page_scsi_port_1(fCONFIG_PAGE_SCSI_PORT_1 *sp1)
+{
+
+ MPT_2_HOST32(sp1, Configuration);
+ MPT_2_HOST32(sp1, OnBusTimerValue);
+#if 0
+ MPT_2_HOST16(sp1, IDConfig);
+#endif
+}
+
+void
+host2mpt_config_page_scsi_port_1(fCONFIG_PAGE_SCSI_PORT_1 *sp1)
+{
+
+ HOST_2_MPT32(sp1, Configuration);
+ HOST_2_MPT32(sp1, OnBusTimerValue);
+#if 0
+ HOST_2_MPT16(sp1, IDConfig);
+#endif
+}
+
+void
+mpt2host_config_page_scsi_port_2(fCONFIG_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(fCONFIG_PAGE_SCSI_DEVICE_0 *sd0)
+{
+
+ MPT_2_HOST32(sd0, NegotiatedParameters);
+ MPT_2_HOST32(sd0, Information);
+}
+
+void
+host2mpt_config_page_scsi_device_0(fCONFIG_PAGE_SCSI_DEVICE_0 *sd0)
+{
+
+ HOST_2_MPT32(sd0, NegotiatedParameters);
+ HOST_2_MPT32(sd0, Information);
+}
+
+void
+mpt2host_config_page_scsi_device_1(fCONFIG_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(fCONFIG_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(fCONFIG_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(fCONFIG_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(fCONFIG_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(fCONFIG_PAGE_RAID_VOL_0 *volp)
+{
+ int i;
+
+ MPT_2_HOST16(volp, VolumeStatus.Reserved);
+ MPT_2_HOST16(volp, VolumeSettings.Settings);
+ MPT_2_HOST32(volp, MaxLBA);
+#if 0
+ MPT_2_HOST32(volp, MaxLBAHigh);
+#endif
+ MPT_2_HOST32(volp, StripeSize);
+ MPT_2_HOST32(volp, Reserved2);
+ MPT_2_HOST32(volp, Reserved3);
+ for (i = 0; i < MPI_RAID_VOL_PAGE_0_PHYSDISK_MAX; i++) {
+ MPT_2_HOST16(volp, PhysDisk[i].Reserved);
+ }
+}
+
+void
+mpt2host_config_page_raid_phys_disk_0(fCONFIG_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);
+}
+
+#endif
Index: src/sys/dev/ic/mpt.h
diff -u src/sys/dev/ic/mpt.h:1.6 src/sys/dev/ic/mpt.h:1.7
--- src/sys/dev/ic/mpt.h:1.6 Fri Jul 27 13:06:51 2007
+++ src/sys/dev/ic/mpt.h Wed Apr 28 22:45:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt.h,v 1.6 2007/07/27 13:06:51 tron Exp $ */
+/* $NetBSD: mpt.h,v 1.7 2010/04/28 22:45:27 chs Exp $ */
/*
* Copyright (c) 2000, 2001 by Greg Ansley
@@ -185,6 +185,53 @@
void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *);
void mpt_print_config_request(void *);
void mpt_print_request(void *);
+
+/********************************** Endianess *********************************/
+#define MPT_2_HOST64(ptr, tag) ptr->tag = le64toh(ptr->tag)
+#define MPT_2_HOST32(ptr, tag) ptr->tag = le32toh(ptr->tag)
+#define MPT_2_HOST16(ptr, tag) ptr->tag = le16toh(ptr->tag)
+
+#define HOST_2_MPT64(ptr, tag) ptr->tag = htole64(ptr->tag)
+#define HOST_2_MPT32(ptr, tag) ptr->tag = htole32(ptr->tag)
+#define HOST_2_MPT16(ptr, tag) ptr->tag = htole16(ptr->tag)
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+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_scsi_port_0(fCONFIG_PAGE_SCSI_PORT_0 *);
+void mpt2host_config_page_scsi_port_1(fCONFIG_PAGE_SCSI_PORT_1 *);
+void host2mpt_config_page_scsi_port_1(fCONFIG_PAGE_SCSI_PORT_1 *);
+void mpt2host_config_page_scsi_port_2(fCONFIG_PAGE_SCSI_PORT_2 *);
+void mpt2host_config_page_scsi_device_0(fCONFIG_PAGE_SCSI_DEVICE_0 *);
+void host2mpt_config_page_scsi_device_0(fCONFIG_PAGE_SCSI_DEVICE_0 *);
+void mpt2host_config_page_scsi_device_1(fCONFIG_PAGE_SCSI_DEVICE_1 *);
+void host2mpt_config_page_scsi_device_1(fCONFIG_PAGE_SCSI_DEVICE_1 *);
+void mpt2host_config_page_fc_port_0(fCONFIG_PAGE_FC_PORT_0 *);
+void mpt2host_config_page_fc_port_1(fCONFIG_PAGE_FC_PORT_1 *);
+void host2mpt_config_page_fc_port_1(fCONFIG_PAGE_FC_PORT_1 *);
+void mpt2host_config_page_raid_vol_0(fCONFIG_PAGE_RAID_VOL_0 *);
+void mpt2host_config_page_raid_phys_disk_0(fCONFIG_PAGE_RAID_PHYS_DISK_0 *);
+#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_scsi_port_0(x) do { ; } while (0)
+#define host2mpt_config_page_scsi_device_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)
+#endif
+
#endif /* _KERNEL */
#endif /* _DEV_IC_MPT_H_ */
Index: src/sys/dev/ic/mpt_debug.c
diff -u src/sys/dev/ic/mpt_debug.c:1.6 src/sys/dev/ic/mpt_debug.c:1.7
--- src/sys/dev/ic/mpt_debug.c:1.6 Sat Apr 18 14:58:02 2009
+++ src/sys/dev/ic/mpt_debug.c Wed Apr 28 22:45:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt_debug.c,v 1.6 2009/04/18 14:58:02 tsutsui Exp $ */
+/* $NetBSD: mpt_debug.c,v 1.7 2010/04/28 22:45:27 chs Exp $ */
/*
* Copyright (c) 2000, 2001 by Greg Ansley
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt_debug.c,v 1.6 2009/04/18 14:58:02 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_debug.c,v 1.7 2010/04/28 22:45:27 chs Exp $");
#include <dev/ic/mpt.h>
@@ -310,11 +310,11 @@
mpt_print_reply_hdr(MSG_DEFAULT_REPLY *msg)
{
printf("%s Reply @ %p\n", mpt_ioc_function(msg->Function), msg);
- printf("\tIOC Status %s\n", mpt_ioc_status(msg->IOCStatus));
+ printf("\tIOC Status %s\n", mpt_ioc_status(le16toh(msg->IOCStatus)));
printf("\tIOCLogInfo 0x%08x\n", msg->IOCLogInfo);
printf("\tMsgLength 0x%02x\n", msg->MsgLength);
printf("\tMsgFlags 0x%02x\n", msg->MsgFlags);
- printf("\tMsgContext 0x%08x\n", msg->MsgContext);
+ printf("\tMsgContext 0x%08x\n", le32toh(msg->MsgContext));
}
static void
@@ -335,20 +335,22 @@
printf("\tWhoInit %s\n", mpt_who(msg->WhoInit));
printf("\tBlockSize %d\n", msg->BlockSize);
printf("\tFlags %d\n", msg->Flags);
- printf("\tReplyQueueDepth %d\n", msg->ReplyQueueDepth);
- printf("\tReqFrameSize 0x%04x\n", msg->RequestFrameSize);
+ printf("\tReplyQueueDepth %d\n", le16toh(msg->ReplyQueueDepth));
+ printf("\tReqFrameSize 0x%04x\n", le16toh(msg->RequestFrameSize));
printf("\tFW Version 0x%08x\n", msg->FWVersion.Word);
- printf("\tProduct ID 0x%04x\n", msg->ProductID);
- printf("\tCredits 0x%04x\n", msg->GlobalCredits);
+ printf("\tProduct ID 0x%04x\n", le16toh(msg->ProductID));
+ printf("\tCredits 0x%04x\n", le16toh(msg->GlobalCredits));
printf("\tPorts %d\n", msg->NumberOfPorts);
printf("\tEventState 0x%02x\n", msg->EventState);
- printf("\tHostMFA_HA 0x%08x\n", msg->CurrentHostMfaHighAddr);
+ printf("\tHostMFA_HA 0x%08x\n",
+ le32toh(msg->CurrentHostMfaHighAddr));
printf("\tSenseBuf_HA 0x%08x\n",
- msg->CurrentSenseBufferHighAddr);
- printf("\tRepFrameSize 0x%04x\n", msg->CurReplyFrameSize);
+ le32toh(msg->CurrentSenseBufferHighAddr));
+ printf("\tRepFrameSize 0x%04x\n",
+ le16toh(msg->CurReplyFrameSize));
printf("\tMaxDevices 0x%02x\n", msg->MaxDevices);
printf("\tMaxBuses 0x%02x\n", msg->MaxBuses);
- printf("\tFWImageSize 0x%04x\n", msg->FWImageSize);
+ printf("\tFWImageSize 0x%04x\n", le32toh(msg->FWImageSize));
}
static void
@@ -367,9 +369,9 @@
printf("\tCDBLength %d\n", msg->CDBLength);
printf("\tSCSI Status: %s\n", mpt_scsi_status(msg->SCSIStatus));
printf("\tSCSI State: %s\n", mpt_scsi_state(msg->SCSIState));
- printf("\tTransferCnt 0x%04x\n", msg->TransferCount);
- printf("\tSenseCnt 0x%04x\n", msg->SenseCount);
- printf("\tResponseInfo 0x%08x\n", msg->ResponseInfo);
+ printf("\tTransferCnt 0x%04x\n", le32toh(msg->TransferCount));
+ printf("\tSenseCnt 0x%04x\n", le32toh(msg->SenseCount));
+ printf("\tResponseInfo 0x%08x\n", le32toh(msg->ResponseInfo));
}
@@ -378,14 +380,14 @@
mpt_print_event_notice(MSG_EVENT_NOTIFY_REPLY *msg)
{
mpt_print_reply_hdr((MSG_DEFAULT_REPLY *)msg);
- printf("\tEvent: %s\n", mpt_ioc_event(msg->Event));
- printf("\tEventContext 0x%04x\n", msg->EventContext);
+ printf("\tEvent: %s\n", mpt_ioc_event(le32toh(msg->Event)));
+ printf("\tEventContext 0x%04x\n", le32toh(msg->EventContext));
printf("\tAckRequired %d\n", msg->AckRequired);
- printf("\tEventDataLength %d\n", msg->EventDataLength);
+ printf("\tEventDataLength %d\n", le16toh(msg->EventDataLength));
printf("\tContinuation %d\n", msg->MsgFlags & 0x80);
switch(msg->Event) {
case MPI_EVENT_LOG_DATA:
- printf("\tEvtLogData: 0x%04x\n", msg->Data[0]);
+ printf("\tEvtLogData: 0x%04x\n", le32toh(msg->Data[0]));
break;
case MPI_EVENT_UNIT_ATTENTION:
@@ -465,7 +467,7 @@
printf("%s @ %p\n", mpt_ioc_function(req->Function), req);
printf("\tChain Offset 0x%02x\n", req->ChainOffset);
printf("\tMsgFlags 0x%02x\n", req->MsgFlags);
- printf("\tMsgContext 0x%08x\n", req->MsgContext);
+ printf("\tMsgContext 0x%08x\n", le32toh(req->MsgContext));
}
void
@@ -480,13 +482,13 @@
printf("\tTargetID %d\n", msg->TargetID);
printf("\tSenseBufferLength %d\n", msg->SenseBufferLength);
printf("\tLUN: 0x%0x\n", msg->LUN[1]);
- printf("\tControl 0x%08x ", msg->Control);
+ printf("\tControl 0x%08x ", le32toh(msg->Control));
#define MPI_PRINT_FIELD(x) \
case MPI_SCSIIO_CONTROL_ ## x : \
printf(" " #x " "); \
break
- switch (msg->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) {
+ switch (le32toh(msg->Control) & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK) {
MPI_PRINT_FIELD(NODATATRANSFER);
MPI_PRINT_FIELD(WRITE);
MPI_PRINT_FIELD(READ);
@@ -494,7 +496,7 @@
printf(" Invalid DIR! ");
break;
}
- switch (msg->Control & MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK) {
+ switch (le32toh(msg->Control) & MPI_SCSIIO_CONTROL_TASKATTRIBUTE_MASK) {
MPI_PRINT_FIELD(SIMPLEQ);
MPI_PRINT_FIELD(HEADOFQ);
MPI_PRINT_FIELD(ORDEREDQ);
@@ -509,8 +511,8 @@
printf("\n");
#undef MPI_PRINT_FIELD
- printf("\tDataLength\t0x%08x\n", msg->DataLength);
- printf("\tSenseBufAddr\t0x%08x\n", msg->SenseBufferLowAddr);
+ printf("\tDataLength\t0x%08x\n", le32toh(msg->DataLength));
+ printf("\tSenseBufAddr\t0x%08x\n", le32toh(msg->SenseBufferLowAddr));
printf("\tCDB[0:%d]\t", msg->CDBLength);
for (i = 0; i < msg->CDBLength; i++)
printf("%02x ", msg->CDB[i]);
@@ -559,12 +561,12 @@
int iprt;
printf("\t");
- flags = MPI_SGE_GET_FLAGS(se->FlagsLength);
+ flags = MPI_SGE_GET_FLAGS(le32toh(se->FlagsLength));
switch (flags & MPI_SGE_FLAGS_ELEMENT_MASK) {
case MPI_SGE_FLAGS_SIMPLE_ELEMENT:
{
printf("SE32 %p: Addr=0x%0x FlagsLength=0x%0x\n",
- se, se->Address, se->FlagsLength);
+ se, le32toh(se->Address), le32toh(se->FlagsLength));
printf(" ");
break;
}
@@ -572,8 +574,9 @@
{
SGE_CHAIN32 *ce = (SGE_CHAIN32 *) se;
printf("CE32 %p: Addr=0x%0x NxtChnO=0x%x Flgs=0x%x "
- "Len=0x%0x\n", ce, ce->Address, ce->NextChainOffset,
- ce->Flags, ce->Length);
+ "Len=0x%0x\n", ce, le32toh(ce->Address),
+ ce->NextChainOffset, ce->Flags,
+ le16toh(ce->Length));
flags = 0;
break;
}
Index: src/sys/dev/ic/mpt_netbsd.c
diff -u src/sys/dev/ic/mpt_netbsd.c:1.14 src/sys/dev/ic/mpt_netbsd.c:1.15
--- src/sys/dev/ic/mpt_netbsd.c:1.14 Tue Apr 8 12:07:26 2008
+++ src/sys/dev/ic/mpt_netbsd.c Wed Apr 28 22:45:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: mpt_netbsd.c,v 1.14 2008/04/08 12:07:26 cegger Exp $ */
+/* $NetBSD: mpt_netbsd.c,v 1.15 2010/04/28 22:45:27 chs Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.14 2008/04/08 12:07:26 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.15 2010/04/28 22:45:27 chs Exp $");
#include <dev/ic/mpt.h> /* pulls in all headers */
@@ -412,7 +412,7 @@
uint32_t *pReply = (uint32_t *) mpt_reply;
mpt_prt(mpt, "Address Reply (index %u):",
- mpt_reply->MsgContext & 0xffff);
+ le32toh(mpt_reply->MsgContext) & 0xffff);
mpt_prt(mpt, "%08x %08x %08x %08x",
pReply[0], pReply[1], pReply[2], pReply[3]);
mpt_prt(mpt, "%08x %08x %08x %08x",
@@ -420,7 +420,7 @@
mpt_prt(mpt, "%08x %08x %08x %08x",
pReply[8], pReply[9], pReply[10], pReply[11]);
}
- index = mpt_reply->MsgContext;
+ index = le32toh(mpt_reply->MsgContext);
}
/*
@@ -533,7 +533,7 @@
}
xs->status = mpt_reply->SCSIStatus;
- switch (mpt_reply->IOCStatus) {
+ switch (le16toh(mpt_reply->IOCStatus)) {
case MPI_IOCSTATUS_SCSI_DATA_OVERRUN:
xs->error = XS_DRIVER_STUFFUP;
break;
@@ -546,7 +546,7 @@
* that returns status should probably be a status
* error as well.
*/
- xs->resid = xs->datalen - mpt_reply->TransferCount;
+ xs->resid = xs->datalen - le32toh(mpt_reply->TransferCount);
if (mpt_reply->SCSIState &
MPI_SCSI_STATE_NO_SCSI_STATUS) {
xs->error = XS_DRIVER_STUFFUP;
@@ -683,7 +683,7 @@
* We use the message context to find the request structure when
* we get the command completion interrupt from the IOC.
*/
- mpt_req->MsgContext = req->index;
+ mpt_req->MsgContext = htole32(req->index);
/* Which physical device to do the I/O on. */
mpt_req->TargetID = periph->periph_target;
@@ -735,12 +735,14 @@
(1 << periph->periph_target)) == 0))
mpt_req->Control |= MPI_SCSIIO_CONTROL_NO_DISCONNECT;
+ mpt_req->Control = htole32(mpt_req->Control);
+
/* Copy the SCSI command block into place. */
memcpy(mpt_req->CDB, xs->cmd, xs->cmdlen);
mpt_req->CDBLength = xs->cmdlen;
- mpt_req->DataLength = xs->datalen;
- mpt_req->SenseBufferLowAddr = req->sense_pbuf;
+ mpt_req->DataLength = htole32(xs->datalen);
+ mpt_req->SenseBufferLowAddr = htole32(req->sense_pbuf);
/*
* Map the DMA transfer.
@@ -781,8 +783,6 @@
SGE_CHAIN32 *ce;
seg = 0;
-
- mpt_req->DataLength = xs->datalen;
flags = MPI_SGE_FLAGS_SIMPLE_ELEMENT;
if (xs->xs_control & XS_CTL_DATA_OUT)
flags |= MPI_SGE_FLAGS_HOST_TO_IOC;
@@ -793,13 +793,15 @@
uint32_t tf;
memset(se, 0, sizeof(*se));
- se->Address = req->dmap->dm_segs[seg].ds_addr;
+ se->Address =
+ htole32(req->dmap->dm_segs[seg].ds_addr);
MPI_pSGE_SET_LENGTH(se,
req->dmap->dm_segs[seg].ds_len);
tf = flags;
if (i == MPT_NSGL_FIRST(mpt) - 2)
tf |= MPI_SGE_FLAGS_LAST_ELEMENT;
MPI_pSGE_SET_FLAGS(se, tf);
+ se->FlagsLength = htole32(se->FlagsLength);
nleft--;
}
@@ -824,23 +826,23 @@
ntodo = MPT_NSGL(mpt) - 1;
ce->NextChainOffset = (MPT_RQSL(mpt) -
sizeof(SGE_SIMPLE32)) >> 2;
- ce->Length = MPT_NSGL(mpt)
- * sizeof(SGE_SIMPLE32);
+ ce->Length = htole16(MPT_NSGL(mpt)
+ * sizeof(SGE_SIMPLE32));
} else {
ntodo = nleft;
ce->NextChainOffset = 0;
- ce->Length = ntodo
- * sizeof(SGE_SIMPLE32);
+ ce->Length = htole16(ntodo
+ * sizeof(SGE_SIMPLE32));
}
- ce->Address = req->req_pbuf +
- ((char *)se - (char *)mpt_req);
+ ce->Address = htole32(req->req_pbuf +
+ ((char *)se - (char *)mpt_req));
ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT;
for (i = 0; i < ntodo; i++, se++, seg++) {
uint32_t tf;
memset(se, 0, sizeof(*se));
- se->Address =
- req->dmap->dm_segs[seg].ds_addr;
+ se->Address = htole32(
+ req->dmap->dm_segs[seg].ds_addr);
MPI_pSGE_SET_LENGTH(se,
req->dmap->dm_segs[seg].ds_len);
tf = flags;
@@ -854,6 +856,8 @@
}
}
MPI_pSGE_SET_FLAGS(se, tf);
+ se->FlagsLength =
+ htole32(se->FlagsLength);
nleft--;
}
}
@@ -866,7 +870,6 @@
int i;
uint32_t flags;
- mpt_req->DataLength = xs->datalen;
flags = MPI_SGE_FLAGS_SIMPLE_ELEMENT;
if (xs->xs_control & XS_CTL_DATA_OUT)
flags |= MPI_SGE_FLAGS_HOST_TO_IOC;
@@ -878,7 +881,8 @@
uint32_t tf;
memset(se, 0, sizeof(*se));
- se->Address = req->dmap->dm_segs[i].ds_addr;
+ se->Address =
+ htole32(req->dmap->dm_segs[i].ds_addr);
MPI_pSGE_SET_LENGTH(se,
req->dmap->dm_segs[i].ds_len);
tf = flags;
@@ -889,6 +893,7 @@
MPI_SGE_FLAGS_END_OF_LIST;
}
MPI_pSGE_SET_FLAGS(se, tf);
+ se->FlagsLength = htole32(se->FlagsLength);
}
bus_dmamap_sync(mpt->sc_dmat, req->dmap, 0,
req->dmap->dm_mapsize,
@@ -906,6 +911,7 @@
MPI_pSGE_SET_FLAGS(se,
(MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_LIST));
+ se->FlagsLength = htole32(se->FlagsLength);
}
if (mpt->verbose > 1)
@@ -991,6 +997,7 @@
tmp.RequestedParameters |= np;
}
+ host2mpt_config_page_scsi_device_1(&tmp);
if (mpt_write_cfg_page(mpt, xm->xm_target, &tmp.Header)) {
mpt_prt(mpt, "unable to write Device Page 1");
return;
@@ -1001,6 +1008,7 @@
return;
}
+ mpt2host_config_page_scsi_device_1(&tmp);
mpt->mpt_dev_page1[xm->xm_target] = tmp;
if (mpt->verbose > 1) {
mpt_prt(mpt,
@@ -1026,10 +1034,12 @@
int period, offset;
tmp = mpt->mpt_dev_page0[periph->periph_target];
+ host2mpt_config_page_scsi_device_0(&tmp);
if (mpt_read_cfg_page(mpt, periph->periph_target, &tmp.Header)) {
mpt_prt(mpt, "unable to read Device Page 0");
return;
}
+ mpt2host_config_page_scsi_device_0(&tmp);
if (mpt->verbose > 1) {
mpt_prt(mpt,
@@ -1085,7 +1095,7 @@
case MPI_FUNCTION_PORT_ENABLE:
{
MSG_PORT_ENABLE_REPLY *msg = vmsg;
- int index = msg->MsgContext & ~0x80000000;
+ int index = le32toh(msg->MsgContext) & ~0x80000000;
if (mpt->verbose > 1)
mpt_prt(mpt, "enable port reply index %d", index);
if (index >= 0 && index < MPT_MAX_REQUESTS(mpt)) {
@@ -1099,7 +1109,7 @@
case MPI_FUNCTION_CONFIG:
{
MSG_CONFIG_REPLY *msg = vmsg;
- int index = msg->MsgContext & ~0x80000000;
+ int index = le32toh(msg->MsgContext) & ~0x80000000;
if (index >= 0 && index < MPT_MAX_REQUESTS(mpt)) {
request_t *req = &mpt->request_pool[index];
req->debug = REQ_DONE;
@@ -1118,7 +1128,7 @@
mpt_event_notify_reply(mpt_softc_t *mpt, MSG_EVENT_NOTIFY_REPLY *msg)
{
- switch (msg->Event) {
+ switch (le32toh(msg->Event)) {
case MPI_EVENT_LOG_DATA:
{
int i;
@@ -1308,7 +1318,7 @@
ackp->Function = MPI_FUNCTION_EVENT_ACK;
ackp->Event = msg->Event;
ackp->EventContext = msg->EventContext;
- ackp->MsgContext = req->index | 0x80000000;
+ ackp->MsgContext = htole32(req->index | 0x80000000);
mpt_check_doorbell(mpt);
mpt_send_cmd(mpt, req);
}