1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +00:00

Add big endian support.

Submitted by:	scottl
Reviewed by:	mjacob
This commit is contained in:
John Birrell 2006-11-15 21:46:36 +00:00
parent c686bf2237
commit 3f970273b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164315
2 changed files with 85 additions and 61 deletions

View File

@ -547,6 +547,10 @@ mpt_event_reply_handler(struct mpt_softc *mpt, request_t *req,
handled = 0;
msg = (MSG_EVENT_NOTIFY_REPLY *)reply_frame;
msg->EventDataLength = le16toh(msg->EventDataLength);
msg->IOCStatus = le16toh(msg->IOCStatus);
msg->IOCLogInfo = le32toh(msg->IOCLogInfo);
msg->Event = le32toh(msg->Event);
MPT_PERS_FOREACH(mpt, pers)
handled += pers->event(mpt, req, msg);
@ -566,7 +570,7 @@ mpt_event_reply_handler(struct mpt_softc *mpt, request_t *req,
request_t *ack_req;
uint32_t context;
context = htole32(req->index|MPT_REPLY_HANDLER_EVENTS);
context = req->index | MPT_REPLY_HANDLER_EVENTS;
ack_req = mpt_get_request(mpt, FALSE);
if (ack_req == NULL) {
struct mpt_evtf_record *evtf;
@ -683,9 +687,9 @@ mpt_send_event_ack(struct mpt_softc *mpt, request_t *ack_req,
ackp = (MSG_EVENT_ACK *)ack_req->req_vbuf;
memset(ackp, 0, sizeof (*ackp));
ackp->Function = MPI_FUNCTION_EVENT_ACK;
ackp->Event = msg->Event;
ackp->EventContext = msg->EventContext;
ackp->MsgContext = context;
ackp->Event = htole32(msg->Event);
ackp->EventContext = htole32(msg->EventContext);
ackp->MsgContext = htole32(context);
mpt_check_doorbell(mpt);
mpt_send_cmd(mpt, ack_req);
}
@ -1375,7 +1379,7 @@ mpt_send_handshake_cmd(struct mpt_softc *mpt, size_t len, void *cmd)
/* 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\n",
@ -1392,6 +1396,7 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
{
int left, reply_left;
u_int16_t *data16;
uint32_t data;
MSG_DEFAULT_REPLY *hdr;
/* We move things out in 16 bit chunks */
@ -1405,7 +1410,8 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout1\n");
return ETIMEDOUT;
}
*data16++ = mpt_read(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
*data16++ = le16toh(data & MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
/* Get Second Word */
@ -1413,7 +1419,8 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout2\n");
return ETIMEDOUT;
}
*data16++ = mpt_read(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
*data16++ = le16toh(data & MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
/*
@ -1443,10 +1450,11 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout3\n");
return ETIMEDOUT;
}
datum = mpt_read(mpt, MPT_OFFSET_DOORBELL);
data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
datum = le16toh(data & MPT_DB_DATA_MASK);
if (reply_left-- > 0)
*data16++ = datum & MPT_DB_DATA_MASK;
*data16++ = datum;
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
}
@ -1553,9 +1561,9 @@ mpt_issue_cfg_req(struct mpt_softc *mpt, request_t *req, u_int Action,
cfgp->Header.PageLength = PageLength;
cfgp->Header.PageNumber = PageNumber;
cfgp->Header.PageType = PageType;
cfgp->PageAddress = PageAddress;
cfgp->PageAddress = htole32(PageAddress);
se = (SGE_SIMPLE32 *)&cfgp->PageBufferSGE;
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 |
@ -1563,6 +1571,7 @@ mpt_issue_cfg_req(struct mpt_softc *mpt, request_t *req, u_int Action,
((Action == MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT
|| Action == MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM)
? MPI_SGE_FLAGS_HOST_TO_IOC : MPI_SGE_FLAGS_IOC_TO_HOST)));
se->FlagsLength = htole32(se->FlagsLength);
cfgp->MsgContext = htole32(req->index | MPT_REPLY_HANDLER_CONFIG);
mpt_check_doorbell(mpt);
@ -2488,7 +2497,7 @@ mpt_configure_ioc(struct mpt_softc *mpt)
pfp.MaxDevices);
mpt->mpt_port_type = pfp.PortType;
mpt->mpt_proto_flags = pfp.ProtocolFlags;
mpt->mpt_proto_flags = le16toh(pfp.ProtocolFlags);
if (pfp.PortType != MPI_PORTFACTS_PORTTYPE_SCSI &&
pfp.PortType != MPI_PORTFACTS_PORTTYPE_SAS &&
pfp.PortType != MPI_PORTFACTS_PORTTYPE_FC) {
@ -2521,10 +2530,10 @@ mpt_configure_ioc(struct mpt_softc *mpt)
* if this is different from what is wanted.
*/
mpt->role = MPT_ROLE_NONE;
if (pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) {
if (mpt->mpt_proto_flags & MPI_PORTFACTS_PROTOCOL_INITIATOR) {
mpt->role |= MPT_ROLE_INITIATOR;
}
if (pfp.ProtocolFlags & MPI_PORTFACTS_PROTOCOL_TARGET) {
if (mpt->mpt_proto_flags & MPI_PORTFACTS_PROTOCOL_TARGET) {
mpt->role |= MPT_ROLE_TARGET;
}
if (mpt_enable_ioc(mpt, 0) != MPT_OK) {

View File

@ -1036,6 +1036,7 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_pSGE_SET_FLAGS(se1,
(MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_LIST));
se1->FlagsLength = htole32(se1->FlagsLength);
goto out;
}
@ -1093,7 +1094,7 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
uint32_t tf;
memset(se, 0, sizeof (*se));
se->Address.Low = dm_segs->ds_addr;
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;
}
@ -1107,6 +1108,7 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_SGE_FLAGS_END_OF_BUFFER;
}
MPI_pSGE_SET_FLAGS(se, tf);
se->FlagsLength = htole32(se->FlagsLength);
}
if (seg == nseg) {
@ -1169,9 +1171,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 =
(uint32_t) ((uint64_t)chain_list_addr >> 32);
htole32((uint32_t) ((uint64_t)chain_list_addr >> 32));
}
ce->Address.Low = (uint32_t) chain_list_addr;
ce->Address.Low = htole32((uint32_t) chain_list_addr);
ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT |
MPI_SGE_FLAGS_64_BIT_ADDRESSING;
@ -1208,10 +1210,10 @@ 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 = dm_segs->ds_addr;
se->Address.Low = htole32(dm_segs->ds_addr);
if (sizeof (bus_addr_t) > 4) {
se->Address.High =
((uint64_t)dm_segs->ds_addr) >> 32;
htole32(((uint64_t)dm_segs->ds_addr) >> 32);
}
MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
tf = flags;
@ -1223,6 +1225,7 @@ mpt_execute_req_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_SGE_FLAGS_END_OF_BUFFER;
}
MPI_pSGE_SET_FLAGS(se, tf);
se->FlagsLength = htole32(se->FlagsLength);
se++;
seg++;
dm_segs++;
@ -1436,6 +1439,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_pSGE_SET_FLAGS(se1,
(MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |
MPI_SGE_FLAGS_SIMPLE_ELEMENT | MPI_SGE_FLAGS_END_OF_LIST));
se1->FlagsLength = htole32(se1->FlagsLength);
goto out;
}
@ -1507,6 +1511,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_SGE_FLAGS_END_OF_BUFFER;
}
MPI_pSGE_SET_FLAGS(se, tf);
se->FlagsLength = htole32(se->FlagsLength);
}
if (seg == nseg) {
@ -1622,6 +1627,7 @@ mpt_execute_req(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
MPI_SGE_FLAGS_END_OF_BUFFER;
}
MPI_pSGE_SET_FLAGS(se, tf);
se->FlagsLength = htole32(se->FlagsLength);
se++;
seg++;
dm_segs++;
@ -1866,8 +1872,8 @@ mpt_start(struct cam_sim *sim, union ccb *ccb)
}
mpt_req->CDBLength = csio->cdb_len;
mpt_req->DataLength = csio->dxfer_len;
mpt_req->SenseBufferLowAddr = req->sense_pbuf;
mpt_req->DataLength = htole32(csio->dxfer_len);
mpt_req->SenseBufferLowAddr = htole32(req->sense_pbuf);
/*
* Do a *short* print here if we're set to MPT_PRT_DEBUG
@ -2038,17 +2044,20 @@ static int
mpt_cam_event(struct mpt_softc *mpt, request_t *req,
MSG_EVENT_NOTIFY_REPLY *msg)
{
uint32_t data0, data1;
data0 = le32toh(msg->Data[0]);
data1 = le32toh(msg->Data[1]);
switch(msg->Event & 0xFF) {
case MPI_EVENT_UNIT_ATTENTION:
mpt_prt(mpt, "UNIT ATTENTION: Bus: 0x%02x TargetID: 0x%02x\n",
(msg->Data[0] >> 8) & 0xff, msg->Data[0] & 0xff);
(data0 >> 8) & 0xff, data0 & 0xff);
break;
case MPI_EVENT_IOC_BUS_RESET:
/* We generated a bus reset */
mpt_prt(mpt, "IOC Generated Bus Reset Port: %d\n",
(msg->Data[0] >> 8) & 0xff);
(data0 >> 8) & 0xff);
xpt_async(AC_BUS_RESET, mpt->path, NULL);
break;
@ -2066,81 +2075,81 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req,
/*
* In general this means a device has been added to the loop.
*/
mpt_prt(mpt, "Rescan Port: %d\n", (msg->Data[0] >> 8) & 0xff);
mpt_prt(mpt, "Rescan Port: %d\n", (data0 >> 8) & 0xff);
/* xpt_async(AC_FOUND_DEVICE, path, NULL); */
break;
case MPI_EVENT_LINK_STATUS_CHANGE:
mpt_prt(mpt, "Port %d: LinkState: %s\n",
(msg->Data[1] >> 8) & 0xff,
((msg->Data[0] & 0xff) == 0)? "Failed" : "Active");
(data1 >> 8) & 0xff,
((data0 & 0xff) == 0)? "Failed" : "Active");
break;
case MPI_EVENT_LOOP_STATE_CHANGE:
switch ((msg->Data[0] >> 16) & 0xff) {
switch ((data0 >> 16) & 0xff) {
case 0x01:
mpt_prt(mpt,
"Port 0x%x: FC LinkEvent: LIP(%02x,%02x) "
"(Loop Initialization)\n",
(msg->Data[1] >> 8) & 0xff,
(msg->Data[0] >> 8) & 0xff,
(msg->Data[0] ) & 0xff);
switch ((msg->Data[0] >> 8) & 0xff) {
(data1 >> 8) & 0xff,
(data0 >> 8) & 0xff,
(data0 ) & 0xff);
switch ((data0 >> 8) & 0xff) {
case 0xF7:
if ((msg->Data[0] & 0xff) == 0xF7) {
if ((data0 & 0xff) == 0xF7) {
mpt_prt(mpt, "Device needs AL_PA\n");
} else {
mpt_prt(mpt, "Device %02x doesn't like "
"FC performance\n",
msg->Data[0] & 0xFF);
data0 & 0xFF);
}
break;
case 0xF8:
if ((msg->Data[0] & 0xff) == 0xF7) {
if ((data0 & 0xff) == 0xF7) {
mpt_prt(mpt, "Device had loop failure "
"at its receiver prior to acquiring"
" AL_PA\n");
} else {
mpt_prt(mpt, "Device %02x detected loop"
" failure at its receiver\n",
msg->Data[0] & 0xFF);
data0 & 0xFF);
}
break;
default:
mpt_prt(mpt, "Device %02x requests that device "
"%02x reset itself\n",
msg->Data[0] & 0xFF,
(msg->Data[0] >> 8) & 0xFF);
data0 & 0xFF,
(data0 >> 8) & 0xFF);
break;
}
break;
case 0x02:
mpt_prt(mpt, "Port 0x%x: FC LinkEvent: "
"LPE(%02x,%02x) (Loop Port Enable)\n",
(msg->Data[1] >> 8) & 0xff, /* Port */
(msg->Data[0] >> 8) & 0xff, /* Character 3 */
(msg->Data[0] ) & 0xff /* Character 4 */);
(data1 >> 8) & 0xff, /* Port */
(data0 >> 8) & 0xff, /* Character 3 */
(data0 ) & 0xff /* Character 4 */);
break;
case 0x03:
mpt_prt(mpt, "Port 0x%x: FC LinkEvent: "
"LPB(%02x,%02x) (Loop Port Bypass)\n",
(msg->Data[1] >> 8) & 0xff, /* Port */
(msg->Data[0] >> 8) & 0xff, /* Character 3 */
(msg->Data[0] ) & 0xff /* Character 4 */);
(data1 >> 8) & 0xff, /* Port */
(data0 >> 8) & 0xff, /* Character 3 */
(data0 ) & 0xff /* Character 4 */);
break;
default:
mpt_prt(mpt, "Port 0x%x: FC LinkEvent: Unknown "
"FC event (%02x %02x %02x)\n",
(msg->Data[1] >> 8) & 0xff, /* Port */
(msg->Data[0] >> 16) & 0xff, /* Event */
(msg->Data[0] >> 8) & 0xff, /* Character 3 */
(msg->Data[0] ) & 0xff /* Character 4 */);
(data1 >> 8) & 0xff, /* Port */
(data0 >> 16) & 0xff, /* Event */
(data0 >> 8) & 0xff, /* Character 3 */
(data0 ) & 0xff /* Character 4 */);
}
break;
case MPI_EVENT_LOGOUT:
mpt_prt(mpt, "FC Logout Port: %d N_PortID: %02x\n",
(msg->Data[1] >> 8) & 0xff, msg->Data[0]);
(data1 >> 8) & 0xff, data0);
break;
case MPI_EVENT_EVENT_CHANGE:
mpt_lprt(mpt, MPT_PRT_DEBUG,
@ -2352,6 +2361,7 @@ static void
mpt_fc_els_send_response(struct mpt_softc *mpt, request_t *req,
PTR_MSG_LINK_SERVICE_BUFFER_POST_REPLY rp, U8 length)
{
uint32_t fl;
MSG_LINK_SERVICE_RSP_REQUEST tmp;
PTR_MSG_LINK_SERVICE_RSP_REQUEST rsp;
@ -2391,15 +2401,16 @@ mpt_fc_els_send_response(struct mpt_softc *mpt, request_t *req,
bus_addr_t paddr = req->req_pbuf;
paddr += MPT_RQSL(mpt);
se->FlagsLength =
fl =
MPI_SGE_FLAGS_HOST_TO_IOC |
MPI_SGE_FLAGS_SIMPLE_ELEMENT |
MPI_SGE_FLAGS_LAST_ELEMENT |
MPI_SGE_FLAGS_END_OF_LIST |
MPI_SGE_FLAGS_END_OF_BUFFER;
se->FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
se->FlagsLength |= (length);
se->Address = (uint32_t) paddr;
fl <<= MPI_SGE_FLAGS_SHIFT;
fl |= (length);
se->FlagsLength = htole32(fl);
se->Address = htole32((uint32_t) paddr);
}
#endif
@ -3713,6 +3724,7 @@ mpt_fc_post_els(struct mpt_softc *mpt, request_t *req, int ioindex)
PTR_SGE_TRANSACTION32 tep;
PTR_SGE_SIMPLE32 se;
bus_addr_t paddr;
uint32_t fl;
paddr = req->req_pbuf;
paddr += MPT_RQSL(mpt);
@ -3737,15 +3749,16 @@ mpt_fc_post_els(struct mpt_softc *mpt, request_t *req, int ioindex)
tep->TransactionContext[0] = htole32(ioindex);
se = (PTR_SGE_SIMPLE32) &tep->TransactionDetails[0];
se->FlagsLength =
fl =
MPI_SGE_FLAGS_HOST_TO_IOC |
MPI_SGE_FLAGS_SIMPLE_ELEMENT |
MPI_SGE_FLAGS_LAST_ELEMENT |
MPI_SGE_FLAGS_END_OF_LIST |
MPI_SGE_FLAGS_END_OF_BUFFER;
se->FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
se->FlagsLength |= (MPT_NRFM(mpt) - MPT_RQSL(mpt));
se->Address = (uint32_t) paddr;
fl <<= MPI_SGE_FLAGS_SHIFT;
fl |= (MPT_NRFM(mpt) - MPT_RQSL(mpt));
se->FlagsLength = htole32(fl);
se->Address = htole32((uint32_t) paddr);
mpt_lprt(mpt, MPT_PRT_DEBUG,
"add ELS index %d ioindex %d for %p:%u\n",
req->index, ioindex, req, req->serno);
@ -3773,7 +3786,7 @@ mpt_post_target_command(struct mpt_softc *mpt, request_t *req, int ioindex)
cb = &fc->Buffer[0];
cb->IoIndex = htole16(ioindex);
cb->u.PhysicalAddress32 = (U32) paddr;
cb->u.PhysicalAddress32 = htole32((U32) paddr);
mpt_check_doorbell(mpt);
mpt_send_cmd(mpt, req);
@ -4301,6 +4314,7 @@ mpt_scsi_tgt_status(struct mpt_softc *mpt, union ccb *ccb, request_t *cmd_req,
request_t *req;
bus_addr_t paddr;
int resplen = 0;
uint32_t fl;
cmd_vbuf = cmd_req->req_vbuf;
cmd_vbuf += MPT_RQSL(mpt);
@ -4420,15 +4434,16 @@ mpt_scsi_tgt_status(struct mpt_softc *mpt, union ccb *ccb, request_t *cmd_req,
if (status == SCSI_STATUS_OK && resplen == 0) {
tp->MsgFlags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS;
} else {
tp->StatusDataSGE.u.Address32 = (uint32_t) paddr;
tp->StatusDataSGE.FlagsLength =
tp->StatusDataSGE.u.Address32 = htole32((uint32_t) paddr);
fl =
MPI_SGE_FLAGS_HOST_TO_IOC |
MPI_SGE_FLAGS_SIMPLE_ELEMENT |
MPI_SGE_FLAGS_LAST_ELEMENT |
MPI_SGE_FLAGS_END_OF_LIST |
MPI_SGE_FLAGS_END_OF_BUFFER;
tp->StatusDataSGE.FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
tp->StatusDataSGE.FlagsLength |= resplen;
fl <<= MPI_SGE_FLAGS_SHIFT;
fl |= resplen;
tp->StatusDataSGE.FlagsLength = htole32(fl);
}
mpt_lprt(mpt, MPT_PRT_DEBUG,