diff options
author | mjacob <mjacob@cvs.openbsd.org> | 2001-04-04 22:08:56 +0000 |
---|---|---|
committer | mjacob <mjacob@cvs.openbsd.org> | 2001-04-04 22:08:56 +0000 |
commit | c0ee793c66e660b1fe8115086304d2f7dcc32be0 (patch) | |
tree | 53523c53a3607c65fd2121361390e11b0f3cc451 /sys | |
parent | 67d058b1560bba330ae0d7170737bcdb7e9b7f8b (diff) |
Keep up with the Joneses- sync up with core code for (eventual) usage here.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/isp_target.c | 168 | ||||
-rw-r--r-- | sys/dev/ic/isp_target.h | 324 | ||||
-rw-r--r-- | sys/dev/ic/isp_tpublic.h | 18 |
3 files changed, 268 insertions, 242 deletions
diff --git a/sys/dev/ic/isp_target.c b/sys/dev/ic/isp_target.c index 4718c2b6f61..8706bb16027 100644 --- a/sys/dev/ic/isp_target.c +++ b/sys/dev/ic/isp_target.c @@ -1,8 +1,8 @@ -/* $OpenBSD: isp_target.c,v 1.3 2000/10/16 01:02:00 mjacob Exp $ */ +/* $OpenBSD: isp_target.c,v 1.4 2001/04/04 22:08:55 mjacob Exp $ */ /* * Machine and OS Independent Target Mode Code for the Qlogic SCSI/FC adapters. * - * Copyright (c) 1999, 2000 by Matthew Jacob + * Copyright (c) 1999, 2000, 2001 by Matthew Jacob * All rights reserved. * mjacob@feral.com * @@ -46,14 +46,14 @@ #endif #ifdef ISP_TARGET_MODE -static char *atiocope = +static const char atiocope[] = "ATIO returned for lun %d because it was in the middle of Bus Device Reset"; -static char *atior = +static const char atior[] = "ATIO returned for lun %d from initiator %d because a Bus Reset occurred"; -static void isp_got_msg __P((struct ispsoftc *, int, in_entry_t *)); -static void isp_got_msg_fc __P((struct ispsoftc *, int, in_fcentry_t *)); -static void isp_notify_ack __P((struct ispsoftc *, void *)); +static void isp_got_msg(struct ispsoftc *, int, in_entry_t *); +static void isp_got_msg_fc(struct ispsoftc *, int, in_fcentry_t *); +static void isp_notify_ack(struct ispsoftc *, void *); static void isp_handle_atio(struct ispsoftc *, at_entry_t *); static void isp_handle_atio2(struct ispsoftc *, at2_entry_t *); static void isp_handle_ctio(struct ispsoftc *, ct_entry_t *); @@ -87,7 +87,7 @@ static void isp_handle_ctio2(struct ispsoftc *, ct2_entry_t *); * The third group that can show up in the response queue are Immediate * Notification events. These include things like notifications of SCSI bus * resets, or Bus Device Reset messages or other messages received. This - * a classic oddbins area. It can get a little wierd because you then turn + * a classic oddbins area. It can get a little weird because you then turn * around and acknowledge the Immediate Notify by writing an entry onto the * request queue and then the f/w turns around and gives you an acknowledgement * to *your* acknowledgement on the response queue (the idea being to let @@ -106,10 +106,7 @@ static void isp_handle_ctio2(struct ispsoftc *, ct2_entry_t *); */ int -isp_target_notify(isp, vptr, optrp) - struct ispsoftc *isp; - void *vptr; - u_int16_t *optrp; +isp_target_notify(struct ispsoftc *isp, void *vptr, u_int16_t *optrp) { u_int16_t status, seqid; union { @@ -268,13 +265,8 @@ isp_target_notify(isp, vptr, optrp) * response entry. The caller is responsible for synchronizing this. */ int -isp_lun_cmd(isp, cmd, bus, tgt, lun, opaque) - struct ispsoftc *isp; - int cmd; - int bus; - int tgt; - int lun; - u_int32_t opaque; +isp_lun_cmd(struct ispsoftc *isp, int cmd, int bus, int tgt, int lun, + u_int32_t opaque) { lun_entry_t el; u_int16_t iptr, optr; @@ -312,6 +304,7 @@ isp_lun_cmd(isp, cmd, bus, tgt, lun, opaque) } else if (isp->isp_maxluns <= 16) { el.le_lun = lun; } + el.le_timeout = 2; if (isp_getrqentry(isp, &iptr, &optr, &outp)) { isp_prt(isp, ISP_LOGWARN, @@ -326,9 +319,7 @@ isp_lun_cmd(isp, cmd, bus, tgt, lun, opaque) int -isp_target_put_entry(isp, ap) - struct ispsoftc *isp; - void *ap; +isp_target_put_entry(struct ispsoftc *isp, void *ap) { void *outp; u_int16_t iptr, optr; @@ -365,13 +356,7 @@ isp_target_put_entry(isp, ap) } int -isp_target_put_atio(isp, iid, tgt, lun, ttype, tval) - struct ispsoftc *isp; - int iid; - int tgt; - int lun; - int ttype; - int tval; +isp_target_put_atio(struct ispsoftc *isp, void *arg) { union { at_entry_t _atio; @@ -380,23 +365,27 @@ isp_target_put_atio(isp, iid, tgt, lun, ttype, tval) MEMZERO(&atun, sizeof atun); if (IS_FC(isp)) { + at2_entry_t *aep = arg; atun._atio2.at_header.rqs_entry_type = RQSTYPE_ATIO2; atun._atio2.at_header.rqs_entry_count = 1; if (isp->isp_maxluns > 16) { - atun._atio2.at_scclun = (u_int16_t) lun; + atun._atio2.at_scclun = (u_int16_t) aep->at_scclun; } else { - atun._atio2.at_lun = (u_int8_t) lun; + atun._atio2.at_lun = (u_int8_t) aep->at_scclun; } atun._atio2.at_status = CT_OK; } else { + at_entry_t *aep = arg; atun._atio.at_header.rqs_entry_type = RQSTYPE_ATIO; atun._atio.at_header.rqs_entry_count = 1; - atun._atio.at_iid = iid; - atun._atio.at_tgt = tgt; - atun._atio.at_lun = lun; - atun._atio.at_tag_type = ttype; - atun._atio.at_tag_val = tval; - atun._atio.at_status = CT_OK; + atun._atio.at_handle = aep->at_handle; + atun._atio.at_iid = aep->at_iid; + atun._atio.at_tgt = aep->at_tgt; + atun._atio.at_lun = aep->at_lun; + atun._atio.at_tag_type = aep->at_tag_type; + atun._atio.at_tag_val = aep->at_tag_val; + atun._atio.at_status = (aep->at_flags & AT_TQAE); + atun._atio.at_status |= CT_OK; } return (isp_target_put_entry(isp, &atun)); } @@ -412,7 +401,7 @@ isp_target_put_atio(isp, iid, tgt, lun, ttype, tval) * values. * * NB: the key, asc, ascq, cannot be used for parallel SCSI as it doesn't - * NB: inline SCSI sense reporting. + * NB: inline SCSI sense reporting. As such, we lose this information. XXX. * * For both parallel && fibre channel, we use the feature that does * an automatic resource autoreplenish so we don't have then later do @@ -420,7 +409,7 @@ isp_target_put_atio(isp, iid, tgt, lun, ttype, tval) */ int -isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int32_t hdl) +isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int16_t hdl) { int sts; union { @@ -460,33 +449,34 @@ isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int32_t hdl) cto->rsp.m1.ct_senselen = 16; cto->ct_flags |= CT2_SNSLEN_VALID; } - cto->ct_reserved = hdl; + cto->ct_syshandle = hdl; } else { at_entry_t *aep = arg; ct_entry_t *cto = &un._ctio; cto->ct_header.rqs_entry_type = RQSTYPE_CTIO; cto->ct_header.rqs_entry_count = 1; + cto->ct_fwhandle = aep->at_handle; cto->ct_iid = aep->at_iid; cto->ct_tgt = aep->at_tgt; cto->ct_lun = aep->at_lun; cto->ct_tag_type = aep->at_tag_type; cto->ct_tag_val = aep->at_tag_val; + if (aep->at_flags & AT_TQAE) { + cto->ct_flags |= CT_TQAE; + } cto->ct_flags = CT_SENDSTATUS | CT_NO_DATA; if (hdl == 0) { cto->ct_flags |= CT_CCINCR; } cto->ct_scsi_status = sts; - cto->ct_reserved = hdl; + cto->ct_syshandle = hdl; } return (isp_target_put_entry(isp, &un)); } void -isp_target_async(isp, bus, event) - struct ispsoftc *isp; - int bus; - int event; +isp_target_async(struct ispsoftc *isp, int bus, int event) { tmd_event_t evt; tmd_msg_t msg; @@ -549,10 +539,7 @@ isp_target_async(isp, bus, event) */ static void -isp_got_msg(isp, bus, inp) - struct ispsoftc *isp; - int bus; - in_entry_t *inp; +isp_got_msg(struct ispsoftc *isp, int bus, in_entry_t *inp) { u_int8_t status = inp->in_status & ~QLTM_SVALID; @@ -578,13 +565,10 @@ isp_got_msg(isp, bus, inp) * Synthesize a message from the task management flags in a FCP_CMND_IU. */ static void -isp_got_msg_fc(isp, bus, inp) - struct ispsoftc *isp; - int bus; - in_fcentry_t *inp; +isp_got_msg_fc(struct ispsoftc *isp, int bus, in_fcentry_t *inp) { - static char *f1 = "%s from iid %d lun %d seq 0x%x"; - static char *f2 = + static const char f1[] = "%s from iid %d lun %d seq 0x%x"; + static const char f2[] = "unknown %s 0x%x lun %d iid %d task flags 0x%x seq 0x%x\n"; if (inp->in_status != IN_MSG_RECEIVED) { @@ -637,9 +621,7 @@ isp_got_msg_fc(isp, bus, inp) } static void -isp_notify_ack(isp, arg) - struct ispsoftc *isp; - void *arg; +isp_notify_ack(struct ispsoftc *isp, void *arg) { char storage[QENTRY_LEN]; u_int16_t iptr, optr; @@ -700,9 +682,7 @@ isp_notify_ack(isp, arg) } static void -isp_handle_atio(isp, aep) - struct ispsoftc *isp; - at_entry_t *aep; +isp_handle_atio(struct ispsoftc *isp, at_entry_t *aep) { int lun; lun = aep->at_lun; @@ -775,16 +755,13 @@ isp_handle_atio(isp, aep) isp_prt(isp, ISP_LOGERR, "Unknown ATIO status 0x%x from initiator %d for lun %d", aep->at_status, aep->at_iid, lun); - (void) isp_target_put_atio(isp, aep->at_iid, aep->at_tgt, - lun, aep->at_tag_type, aep->at_tag_val); + (void) isp_target_put_atio(isp, aep); break; } } static void -isp_handle_atio2(isp, aep) - struct ispsoftc *isp; - at2_entry_t *aep; +isp_handle_atio2(struct ispsoftc *isp, at2_entry_t *aep) { int lun; @@ -861,26 +838,23 @@ isp_handle_atio2(isp, aep) isp_prt(isp, ISP_LOGERR, "Unknown ATIO2 status 0x%x from initiator %d for lun %d", aep->at_status, aep->at_iid, lun); - (void) isp_target_put_atio(isp, aep->at_iid, 0, lun, 0, 0); + (void) isp_target_put_atio(isp, aep); break; } } static void -isp_handle_ctio(isp, ct) - struct ispsoftc *isp; - ct_entry_t *ct; +isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct) { - XS_T *xs; + void *xs; int pl = ISP_LOGTDEBUG2; char *fmsg = NULL; - if (ct->ct_reserved) { - xs = isp_find_xs(isp, ct->ct_reserved); + if (ct->ct_syshandle) { + xs = isp_find_xs(isp, ct->ct_syshandle); if (xs == NULL) pl = ISP_LOGALL; } else { - pl = ISP_LOGTDEBUG1; xs = NULL; } @@ -965,8 +939,13 @@ isp_handle_ctio(isp, ct) isp_prt(isp, ISP_LOGERR, "Firmware timed out on %s", fmsg); break; + case CT_PANIC: + if (fmsg == NULL) + fmsg = "Unrecoverable Error"; + /*FALLTHROUGH*/ case CT_ERR: - fmsg = "Completed with Error"; + if (fmsg == NULL) + fmsg = "Completed with Error"; /*FALLTHROUGH*/ case CT_PHASE_ERROR: if (fmsg == NULL) @@ -1004,7 +983,7 @@ isp_handle_ctio(isp, ct) * The assumption is that they'll all be returned in the * order we got them. */ - if (ct->ct_reserved == 0) { + if (ct->ct_syshandle == 0) { if ((ct->ct_flags & CT_SENDSTATUS) == 0) { isp_prt(isp, pl, "intermediate CTIO completed ok"); @@ -1015,49 +994,36 @@ isp_handle_ctio(isp, ct) } else { isp_prt(isp, pl, "NO xs for CTIO (handle 0x%x) status 0x%x", - ct->ct_reserved, ct->ct_status & ~QLTM_SVALID); + ct->ct_syshandle, ct->ct_status & ~QLTM_SVALID); } } else { - if (ct->ct_flags & CT_SENDSTATUS) { - /* - * Sent status and command complete. - * - * We're now really done with this command, so we - * punt to the platform dependent layers because - * only there can we do the appropriate command - * complete thread synchronization. - */ - isp_prt(isp, pl, "status CTIO complete"); - } else { /* * Final CTIO completed. Release DMA resources and * notify platform dependent layers. */ - isp_prt(isp, pl, "data CTIO complete"); - ISP_DMAFREE(isp, xs, ct->ct_reserved); + if (ct->ct_flags & CT_DATAMASK) { + ISP_DMAFREE(isp, xs, ct->ct_syshandle); } - (void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct); + isp_prt(isp, pl, "final CTIO complete"); /* * The platform layer will destroy the handle if appropriate. */ + (void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct); } } static void -isp_handle_ctio2(isp, ct) - struct ispsoftc *isp; - ct2_entry_t *ct; +isp_handle_ctio2(struct ispsoftc *isp, ct2_entry_t *ct) { XS_T *xs; int pl = ISP_LOGTDEBUG2; char *fmsg = NULL; - if (ct->ct_reserved) { - xs = isp_find_xs(isp, ct->ct_reserved); + if (ct->ct_syshandle) { + xs = isp_find_xs(isp, ct->ct_syshandle); if (xs == NULL) pl = ISP_LOGALL; } else { - pl = ISP_LOGTDEBUG1; xs = NULL; } @@ -1171,7 +1137,7 @@ isp_handle_ctio2(isp, ct) break; default: - isp_prt(isp, ISP_LOGERR, "Unknown CTIO status 0x%x", + isp_prt(isp, ISP_LOGERR, "Unknown CTIO2 status 0x%x", ct->ct_status & ~QLTM_SVALID); break; } @@ -1184,7 +1150,7 @@ isp_handle_ctio2(isp, ct) * The assumption is that they'll all be returned in the * order we got them. */ - if (ct->ct_reserved == 0) { + if (ct->ct_syshandle == 0) { if ((ct->ct_flags & CT_SENDSTATUS) == 0) { isp_prt(isp, pl, "intermediate CTIO completed ok"); @@ -1195,7 +1161,7 @@ isp_handle_ctio2(isp, ct) } else { isp_prt(isp, pl, "NO xs for CTIO (handle 0x%x) status 0x%x", - ct->ct_reserved, ct->ct_status & ~QLTM_SVALID); + ct->ct_syshandle, ct->ct_status & ~QLTM_SVALID); } } else { if (ct->ct_flags & CT_SENDSTATUS) { @@ -1214,7 +1180,7 @@ isp_handle_ctio2(isp, ct) * notify platform dependent layers. */ isp_prt(isp, pl, "data CTIO complete"); - ISP_DMAFREE(isp, xs, ct->ct_reserved); + ISP_DMAFREE(isp, xs, ct->ct_syshandle); } (void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct); /* diff --git a/sys/dev/ic/isp_target.h b/sys/dev/ic/isp_target.h index 316017edc4a..2e44f930187 100644 --- a/sys/dev/ic/isp_target.h +++ b/sys/dev/ic/isp_target.h @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_target.h,v 1.4 2001/01/09 03:27:28 mjacob Exp $ */ +/* @(#)isp_target.h 1.3 */ /* * Qlogic Target Mode Structure and Flag Definitions * @@ -7,7 +7,7 @@ * pms@psconsult.com * All rights reserved. * - * Additional Copyright (c) 1999< 2000 + * Additional Copyright (c) 1999, 2000, 2001 * Matthew Jacob * mjacob@feral.com * All rights reserved. @@ -33,8 +33,8 @@ * SUCH DAMAGE. * */ -#ifndef _ISPTARGET_H -#define _ISPTARGET_H +#ifndef _ISP_TARGET_H +#define _ISP_TARGET_H /* * Defines for all entry types @@ -66,7 +66,7 @@ typedef struct { /* * le_flags values */ -#define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */ +#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */ #define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */ #define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */ #define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */ @@ -212,7 +212,8 @@ typedef struct { typedef struct { isphdr_t at_header; - u_int32_t at_reserved; + u_int16_t at_reserved; + u_int16_t at_handle; u_int8_t at_lun; /* lun */ u_int8_t at_iid; /* initiator */ u_int8_t at_cdblen; /* cdb length */ @@ -230,7 +231,7 @@ typedef struct { * at_flags values */ #define AT_NODISC 0x00008000 /* disconnect disabled */ -#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */ +#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */ /* * at_status values @@ -243,6 +244,24 @@ typedef struct { #define AT_CDB 0x3D /* CDB received */ /* + * Macros to create and fetch and test concatenated handle and tag value macros + */ + +#define AT_MAKE_TAGID(tid, aep) \ + tid = ((aep)->at_handle << 16); \ + if ((aep)->at_flags & AT_TQAE) \ + (tid) |= ((aep)->at_tag_val + 1) + +#define CT_MAKE_TAGID(tid, ct) \ + tid = ((ct)->ct_fwhandle << 16); \ + if ((ct)->ct_flags & CT_TQAE) \ + (tid) |= ((ct)->ct_tag_val + 1) + +#define AT_HAS_TAG(val) ((val) & 0xffff) +#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1 +#define AT_GET_HANDLE(val) ((val) >> 16) + +/* * Accept Target I/O Entry structure, Type 2 */ #define ATIO2_CDBLEN 16 @@ -262,9 +281,8 @@ typedef struct { u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */ u_int32_t at_datalen; /* allocated data len */ u_int16_t at_scclun; /* SCC Lun or reserved */ - u_int16_t at_reserved2; - u_int16_t at_scsi_status; - u_int8_t at_sense[QLTM_SENSELEN]; + u_int16_t at_reserved2[10]; + u_int16_t at_oxid; } at2_entry_t; #define ATIO2_WWPN_OFFSET 0x2A @@ -286,7 +304,9 @@ typedef struct { */ typedef struct { isphdr_t ct_header; - u_int32_t ct_reserved; + u_int16_t ct_reserved; +#define ct_syshandle ct_reserved /* we use this */ + u_int16_t ct_fwhandle; /* required by f/w */ u_int8_t ct_lun; /* lun */ u_int8_t ct_iid; /* initiator id */ u_int8_t ct_reserved2; @@ -319,7 +339,7 @@ typedef struct { /* * ct_flags values */ -#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */ +#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */ #define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */ #define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */ #define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */ @@ -376,7 +396,8 @@ typedef struct { #define MAXRESPLEN 26 typedef struct { isphdr_t ct_header; - u_int32_t ct_reserved; + u_int16_t ct_reserved; + u_int16_t ct_fwhandle; /* just to match CTIO */ u_int8_t ct_lun; /* lun */ u_int8_t ct_iid; /* initiator id */ u_int16_t ct_rxid; /* response ID */ @@ -467,144 +488,179 @@ typedef struct { */ #ifdef __sparc__ -#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ - if (isp->isp_bus == ISP_SBUS) { \ - source -> taga = dest -> tagb; \ - source -> tagb = dest -> taga; \ +#define ISP_SBUS_SWOZZLE(isp, src, dst, taga, tagb) \ + if (isp->isp_bustype == ISP_BT_SBUS) { \ + u_int8_t tmp = src -> taga; \ + dst -> taga = dst -> tagb; \ + src -> tagb = tmp; \ } else { \ - source -> taga = dest -> taga; \ - source -> tagb = dest -> taga; \ + dst -> taga = src -> taga; \ + dst -> tagb = src -> taga; \ } #else -#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \ - source -> taga = dest -> taga; \ - source -> tagb = dest -> taga; +#define ISP_SBUS_SWOZZLE(isp, src, dst, taga, tagb) \ + dst -> taga = src -> taga; \ + dst -> tagb = src -> taga #endif #define MCIDF(d, s) if ((void *) d != (void *)s) MEMCPY(d, s, QENTRY_LEN) /* This is really only for SBus cards on a sparc */ #ifdef __sparc__ -#define ISP_SWIZ_ATIO(isp, dest, vsrc) \ +#define ISP_SWIZ_ATIO(isp, vdst, vsrc) \ { \ - at_entry_t *source = (at_entry_t *) vsrc; \ - at_entry_t local, *vdst; \ - if ((void *)dest == (void *)vsrc) { \ - MEMCPY(vsrc, &local, sizeof (at_entry_t)); \ - vdst = &local; \ - } else { \ - vdst = dest; \ - } \ - vdst->at_header = source->at_header; \ - vdst->at_reserved2 = source->at_reserved2; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, at_lun, at_iid); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, at_cdblen, at_tgt); \ - vdst->at_flags = source->at_flags; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, at_status, at_scsi_status); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, at_tag_val, at_tag_type); \ - MEMCPY(vdst->at_cdb, source->at_cdb, ATIO_CDBLEN); \ - MEMCPY(vdst->at_sense, source->at_sense, QLTM_SENSELEN); \ + at_entry_t *src = (at_entry_t *) vsrc; \ + at_entry_t *dst = (at_entry_t *) vdst; \ + dst->at_header = src->at_header; \ + dst->at_reserved = src->at_reserved; \ + dst->at_handle = src->at_handle; \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_lun, at_iid); \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_cdblen, at_tgt); \ + dst->at_flags = src->at_flags; \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_status, at_scsi_status); \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_tag_val, at_tag_type); \ + MEMCPY(dst->at_cdb, src->at_cdb, ATIO_CDBLEN); \ + MEMCPY(dst->at_sense, src->at_sense, QLTM_SENSELEN); \ } - -#define ISP_SWIZ_CTIO(isp, dest, vsrc) \ +#define ISP_SWIZ_ATIO2(isp, vdst, vsrc) \ { \ - ct_entry_t *source = (ct_entry_t *) vsrc; \ - ct_entry_t *local, *vdst; \ - if ((void *)dest == (void *)vsrc) { \ - MEMCPY(vsrc, &local, sizeof (ct_entry_t)); \ - vdst = &local; \ - } else { \ - vdst = dest; \ - } \ - vdst->ct_header = source->ct_header; \ - vdst->ct_reserved = source->ct_reserved; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, ct_lun, ct_iid); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, ct_rsvd, ct_tgt); \ - vdst->ct_flags = source->ct_flags; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, ct_status, ct_scsi_status); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, ct_tag_val, ct_tag_type); \ - vdst->ct_xfrlen = source->ct_xfrlen; \ - vdst->ct_resid = source->ct_resid; \ - vdst->ct_timeout = source->ct_timeout; \ - vdst->ct_seg_count = source->ct_seg_count; \ - MEMCPY(vdst->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \ - MEMCPY(vdst->ct_sense, source->ct_sense, QLTM_SENSELEN); \ - vdst->ct_dataseg = source->ct_dataseg; \ + at2_entry_t *src = (at2_entry_t *) vsrc; \ + at2_entry_t *dst = (at2_entry_t *) vdst; \ + dst->at_reserved = src->at_reserved; \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_lun, at_iid); \ + dst->at_rxid = src->at_rxid; \ + dst->at_flags = src->at_flags; \ + dst->at_status = src->at_status; \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_reserved1, at_taskcodes); \ + ISP_SBUS_SWOZZLE(isp, src, dst, at_taskflags, at_execodes); \ + MEMCPY(dst->at_cdb, src->at_cdb, ATIO2_CDBLEN); \ + dst->at_datalen = src->at_datalen; \ + dst->at_scclun = src->at_scclun; \ + MEMCPY(dst->at_reserved2, src->at_reserved2, sizeof dst->at_reserved2);\ + dst->at_oxid = src->at_oxid; \ } -#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \ +#define ISP_SWIZ_CTIO(isp, vdst, vsrc) \ { \ - lun_entry_t *source = (lun_entry_t *)vsrc; \ - lun_entry_t *local, *vdst; \ - if ((void *)dest == (void *)vsrc) { \ - MEMCPY(vsrc, &local, sizeof (lun_entry_t)); \ - vdst = &local; \ - } else { \ - vdst = dest; \ - } \ - vdst->le_header = source->le_header; \ - vdst->le_reserved2 = source->le_reserved2; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, le_lun, le_rsvd); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, le_ops, le_tgt); \ - vdst->le_flags = source->le_flags; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, le_status, le_rsvd2); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, le_cmd_count, le_in_count); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, le_cdb6len, le_cdb7len); \ - vdst->le_timeout = source->le_timeout; \ - vdst->le_reserved = source->le_reserved; \ + ct_entry_t *src = (ct_entry_t *) vsrc; \ + ct_entry_t *dst = (ct_entry_t *) vdst; \ + dst->ct_header = src->ct_header; \ + dst->ct_syshandle = src->ct_syshandle; \ + dst->ct_fwhandle = src->ct_fwhandle; \ + dst->ct_fwhandle = src->ct_fwhandle; \ + ISP_SBUS_SWOZZLE(isp, src, dst, ct_lun, ct_iid); \ + ISP_SBUS_SWOZZLE(isp, src, dst, ct_reserved2, ct_tgt); \ + dst->ct_flags = src->ct_flags; \ + ISP_SBUS_SWOZZLE(isp, src, dst, ct_status, ct_scsi_status); \ + ISP_SBUS_SWOZZLE(isp, src, dst, ct_tag_val, ct_tag_type); \ + dst->ct_xfrlen = src->ct_xfrlen; \ + dst->ct_resid = src->ct_resid; \ + dst->ct_timeout = src->ct_timeout; \ + dst->ct_seg_count = src->ct_seg_count; \ + MEMCPY(dst->ct_dataseg, src->ct_dataseg, sizeof (dst->ct_dataseg)); \ } -#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \ +#define ISP_SWIZ_CTIO2(isp, vdst, vsrc) \ { \ - in_entry_type *source = (in_entry_t *)vsrc; \ - in_entry_t *local, *vdst; \ - if ((void *)dest == (void *)vsrc) { \ - MEMCPY(vsrc, &local, sizeof (in_entry_t)); \ - vdst = &local; \ - } else { \ - vdst = dest; \ - } \ - vdst->in_header = source->in_header; \ - vdst->in_reserved2 = source->in_reserved2; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, in_lun, in_iid); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, in_rsvd, in_tgt); \ - vdst->in_flags = source->in_flags; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, in_status, in_rsvd2); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, in_tag_val, in_tag_type); \ - vdst->in_seqid = source->in_seqid; \ - MEMCPY(vdst->in_msg, source->in_msg, IN_MSGLEN); \ - MEMCPY(vdst->in_reserved, source->in_reserved, IN_RESERVED); \ - MEMCPY(vdst->in_sense, source->in_sense, QLTM_SENSELEN); \ + ct2_entry_t *src = (ct2_entry_t *) vsrc; \ + ct2_entry_t *dst = (ct2_entry_t *) vdst; \ + dst->ct_header = src->ct_header; \ + dst->ct_syshandle = src->ct_syshandle; \ + dst->ct_fwhandle = src->ct_fwhandle; \ + dst->ct_fwhandle = src->ct_fwhandle; \ + ISP_SBUS_SWOZZLE(isp, src, dst, ct_lun, ct_iid); \ + dst->ct_rxid = src->ct_rxid; \ + dst->ct_flags = src->ct_flags; \ + dst->ct_status = src->ct_status; \ + dst->ct_timeout = src->ct_timeout; \ + dst->ct_seg_count = src->ct_seg_count; \ + dst->ct_reloff = src->ct_reloff; \ + dst->ct_resid = src->ct_resid; \ + dst->rsp = src->rsp; \ } -#define ISP_SWIZ_NOT_ACK(isp, dest) \ +#define ISP_SWIZ_ENABLE_LUN(isp, vdst, vsrc) \ { \ - na_entry_t *source = (na_entry_t *)vsrc; \ - na_entry_t *local, *vdst; \ - if ((void *)dest == (void *)vsrc) { \ - MEMCPY(vsrc, &local, sizeof (na_entry_t)); \ - vdst = &local; \ - } else { \ - vdst = dest; \ - } \ - vdst->na_header = source->na_header; \ - vdst->na_reserved2 = source->na_reserved2; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, na_lun, na_iid); \ - ISP_SBUS_SWOZZLE(isp, source, vdst, na_rsvd, na_tgt); \ - vdst->na_flags = source->na_flags; \ - ISP_SBUS_SWOZZLE(isp, source, vdst, na_status, na_event); \ - vdst->na_seqid = source->na_seqid; \ - MEMCPY(vdst->na_reserved, source->na_reserved, NA_RSVDLEN); \ + lun_entry_t *src = (lun_entry_t *)vsrc; \ + lun_entry_t *dst = (lun_entry_t *)vdst; \ + dst->le_header = src->le_header; \ + dst->le_reserved2 = src->le_reserved2; \ + ISP_SBUS_SWOZZLE(isp, src, dst, le_lun, le_rsvd); \ + ISP_SBUS_SWOZZLE(isp, src, dst, le_ops, le_tgt); \ + dst->le_flags = src->le_flags; \ + ISP_SBUS_SWOZZLE(isp, src, dst, le_status, le_reserved2); \ + ISP_SBUS_SWOZZLE(isp, src, dst, le_cmd_count, le_in_count); \ + ISP_SBUS_SWOZZLE(isp, src, dst, le_cdb6len, le_cdb7len); \ + dst->le_timeout = src->le_timeout; \ + dst->le_reserved = src->le_reserved; \ +} +#define ISP_SWIZ_NOTIFY(isp, vdst, vsrc) \ +{ \ + in_entry_type *src = (in_entry_t *)vsrc; \ + in_entry_type *dst = (in_entry_t *)vdst; \ + dst->in_header = src->in_header; \ + dst->in_reserved2 = src->in_reserved2; \ + ISP_SBUS_SWOZZLE(isp, src, dst, in_lun, in_iid); \ + ISP_SBUS_SWOZZLE(isp, src, dst, in_reserved2, in_tgt); \ + dst->in_flags = src->in_flags; \ + ISP_SBUS_SWOZZLE(isp, src, dst, in_status, in_rsvd2); \ + ISP_SBUS_SWOZZLE(isp, src, dst, in_tag_val, in_tag_type); \ + dst->in_seqid = src->in_seqid; \ + MEMCPY(dst->in_msg, src->in_msg, IN_MSGLEN); \ + MEMCPY(dst->in_reserved, src->in_reserved, IN_RESERVED); \ + MEMCPY(dst->in_sense, src->in_sense, QLTM_SENSELEN); \ +} +#define ISP_SWIZ_NOTIFY_FC(isp, vdst, vsrc) \ +{ \ + in_fcentry_type *src = (in_fcentry_t *)vsrc; \ + in_fcentry_type *dst = (in_fcentry_t *)vdst; \ + dst->in_header = src->in_header; \ + dst->in_reserved2 = src->in_reserved2; \ + ISP_SBUS_SWOZZLE(isp, src, dst, in_lun, in_iid); \ + dst->in_scclun = src->in_scclun; \ + dst->in_reserved2 = src->in_reserved2; \ + dst->in_status = src->in_status; \ + dst->in_task_flags = src->in_task_flags; \ + dst->in_seqid = src->in_seqid; \ +} +#define ISP_SWIZ_NOT_ACK(isp, vdst, vsrc) \ +{ \ + na_entry_t *src = (na_entry_t *)vsrc; \ + na_entry_t *dst = (na_entry_t *)vdst; \ + dst->na_header = src->na_header; \ + dst->na_reserved = src->na_reserved; \ + ISP_SBUS_SWOZZLE(isp, src, dst, na_lun, na_iid); \ + dst->na_reserved2 = src->na_reserved2; \ + ISP_SBUS_SWOZZLE(isp, src, dst, na_reserved, na_tgt); \ + dst->na_flags = src->na_flags; \ + ISP_SBUS_SWOZZLE(isp, src, dst, na_status, na_event); \ + dst->na_seqid = src->na_seqid; \ + MEMCPY(dst->na_reserved3, src->na_reserved3, NA_RSVDLEN); \ +} +#define ISP_SWIZ_NOT_ACK_FC(isp, vdst, vsrc) \ +{ \ + na_fcentry_t *src = (na_fcentry_t *)vsrc; \ + na_fcentry_t *dst = (na_fcentry_t *)vdst; \ + dst->na_header = src->na_header; \ + dst->na_reserved = src->na_reserved; \ + ISP_SBUS_SWOZZLE(isp, src, dst, na_lun, na_iid); \ + dst->na_scclun = src->na_scclun; \ + dst->na_flags = src->na_flags; \ + dst->na_reserved2 = src->na_reserved2; \ + dst->na_status = src->na_status; \ + dst->na_task_flags = src->na_task_flags; \ + dst->na_seqid = src->na_seqid; \ + MEMCPY(dst->na_reserved3, src->na_reserved3, NA2_RSVDLEN); \ } -#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) -#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) -#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) #else #define ISP_SWIZ_ATIO(isp, d, s) MCIDF(d, s) +#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) #define ISP_SWIZ_CTIO(isp, d, s) MCIDF(d, s) +#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) #define ISP_SWIZ_ENABLE_LUN(isp, d, s) MCIDF(d, s) +#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) +#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) #define ISP_SWIZ_NOTIFY(isp, d, s) MCIDF(d, s) +#define ISP_SWIZ_NOTIFY_FC(isp, d, s) MCIDF(d, s) #define ISP_SWIZ_NOT_ACK(isp, d, s) MCIDF(d, s) #define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s) -#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s) -#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s) #endif /* @@ -622,39 +678,39 @@ typedef struct { /* * This function handles new response queue entry appropriate for target mode. */ -int isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *)); +int isp_target_notify(struct ispsoftc *, void *, u_int16_t *); /* * Enable/Disable/Modify a logical unit. */ #define DFLT_CMD_CNT 32 /* XX */ #define DFLT_INOTIFY (4) -int isp_lun_cmd __P((struct ispsoftc *, int, int, int, int, u_int32_t)); +int isp_lun_cmd(struct ispsoftc *, int, int, int, int, u_int32_t); /* * General request queue 'put' routine for target mode entries. */ -int isp_target_put_entry __P((struct ispsoftc *isp, void *)); +int isp_target_put_entry(struct ispsoftc *isp, void *); /* * General routine to put back an ATIO entry- * used for replenishing f/w resource counts. + * The argument is a pointer to a source ATIO + * or ATIO2. */ -int -isp_target_put_atio __P((struct ispsoftc *, int, int, int, int, int)); +int isp_target_put_atio(struct ispsoftc *, void *); /* * General routine to send a final CTIO for a command- used mostly for * local responses. */ -int -isp_endcmd __P((struct ispsoftc *, void *, u_int32_t, u_int32_t)); +int isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); #define ECMD_SVALID 0x100 /* * Handle an asynchronous event */ -void isp_target_async __P((struct ispsoftc *, int, int)); +void isp_target_async(struct ispsoftc *, int, int); -#endif /* _ISPTARGET_H */ +#endif /* _ISP_TARGET_H */ diff --git a/sys/dev/ic/isp_tpublic.h b/sys/dev/ic/isp_tpublic.h index 34619b99df7..696dec6bc9b 100644 --- a/sys/dev/ic/isp_tpublic.h +++ b/sys/dev/ic/isp_tpublic.h @@ -1,8 +1,8 @@ -/* $OpenBSD: isp_tpublic.h,v 1.2 2000/07/06 05:31:48 mjacob Exp $ */ +/* $OpenBSD: isp_tpublic.h,v 1.3 2001/04/04 22:08:55 mjacob Exp $ */ /* * Qlogic ISP Host Adapter Public Target Interface Structures && Routines *--------------------------------------- - * Copyright (c) 2000 by Matthew Jacob + * Copyright (c) 2000, 2001 by Matthew Jacob * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -101,7 +101,9 @@ typedef struct { * layer maintains a port database, for example). * * The cd_tagtype field specifies what kind of command tag has been - * sent with the command. The cd_tagval is the tag's value. + * sent with the command. The cd_tagval is the tag's value (low 16 + * bits). It also contains (in the upper 16 bits) any command handle. + * * * N.B.: when the MD layer sends this command to outside software * the outside software likely *MUST* return the same cd_tagval that @@ -175,7 +177,9 @@ typedef struct { * The tag cd_error is to communicate between the MD layer and outer software * the current error conditions. * - * The tag cd_reserved pads out the structure to 128 bytes. + * The tag cd_reserved pads out the structure to 128 bytes. The first + * half of the pad area is reserved to the MD layer, and the second half + * may be used by outer layers, for scratch purposes. */ #ifndef _LP64 @@ -206,7 +210,7 @@ typedef struct tmd_cmd { u_int64_t cd_lun; /* logical unit */ u_int8_t cd_bus; /* bus */ u_int8_t cd_tagtype; /* tag type */ - u_int16_t cd_tagval; /* tag value */ + u_int32_t cd_tagval; /* tag value */ u_int8_t cd_cdb[ATIO_CDBLEN]; /* Command */ u_int8_t cd_lflags; /* flags lower level sets */ u_int8_t cd_hflags; /* flags higher level sets */ @@ -266,7 +270,7 @@ typedef enum { * When the HBA is enabled for receiving commands, one may show up * without notice. When that happens, the Qlogic target mode driver * gets a tmd_cmd_t, fills it with the info that just arrived, and - * calls the outer layer with a QIN_TMD_START code and pointer to + * calls the outer layer with a QOUT_TMD_START code and pointer to * the tmd_cmd_t. * * The outer layer decodes the command, fetches data, prepares stuff, @@ -325,5 +329,5 @@ typedef struct { int r_inst; int r_lunwidth; int r_buswidth; - void (*r_action) __P((int, void *)); + void (*r_action)(int, void *); } hba_register_t; |