diff options
author | mjacob <mjacob@FreeBSD.org> | 2001-12-11 00:18:45 +0000 |
---|---|---|
committer | mjacob <mjacob@FreeBSD.org> | 2001-12-11 00:18:45 +0000 |
commit | 991ffbae5691ddb93149381b3c23fcf0763b63bd (patch) | |
tree | c9f72bc76f2873325753abbad1598b1881e3e759 /sys/dev/isp/isp_target.h | |
parent | 356efe3c0b9c059153349979d7c80cd8b40c104c (diff) | |
download | FreeBSD-src-991ffbae5691ddb93149381b3c23fcf0763b63bd.zip FreeBSD-src-991ffbae5691ddb93149381b3c23fcf0763b63bd.tar.gz |
Major restructuring for swizzling to the request queue and unswizzling from
the response queue. Instead of the ad hoc ISP_SWIZZLE_REQUEST, we now have
a complete set of inline functions in isp_inline.h. Each platform is
responsible for providing just one of a set of ISP_IOX_{GET,PUT}{8,16,32}
macros.
The reason this needs to be done is that we need to have a single set of
functions that will work correctly on multiple architectures for both little
and big endian machines. It also needs to work correctly in the case that
we have the request or response queues in memory that has to be treated
specially (e.g., have ddi_dma_sync called on it for Solaris after we update
it or before we read from it). It also has to handle the SBus cards (for
platforms that have them) which, while on a Big Endian machine, do *not*
require *most* of the request/response queue entry fields to be swizzled
or unswizzled.
One thing that falls out of this is that we no longer build requests in the
request queue itself. Instead, we build the request locally (e.g., on the
stack) and then as part of the swizzling operation, copy it to the request
queue entry we've allocated. I thought long and hard about whether this was
too expensive a change to make as it in a lot of cases requires an extra
copy. On balance, the flexbility is worth it. With any luck, the entry that
we build locally stays in a processor writeback cache (after all, it's only
64 bytes) so that the cost of actually flushing it to the memory area that is
the shared queue with the PCI device is not all that expensive. We may examine
this again and try to get clever in the future to try and avoid copies.
Another change that falls out of this is that MEMORYBARRIER should be taken
a lot more seriously. The macro ISP_ADD_REQUEST does a MEMORYBARRIER on the
entry being added. But there had been many other places this had been missing.
It's now very important that it be done.
Additional changes:
Fix a longstanding buglet of sorts. When we get an entry via isp_getrqentry,
the iptr value that gets returned is the value we intend to eventually plug
into the ISP registers as the entry *one past* the last one we've written-
*not* the current entry we're updating. All along we've been calling sync
functions on the wrong index value. Argh. The 'fix' here is to rename all
'iptr' variables as 'nxti' to remember that this is the 'next' pointer-
not the current pointer.
Devote a single bit to mboxbsy- and set aside bits for output mbox registers
that we need to pick up- we can have at least one command which does not
have any defined output registers (MBOX_EXECUTE_FIRMWARE).
MFC after: 2 weeks
Diffstat (limited to 'sys/dev/isp/isp_target.h')
-rw-r--r-- | sys/dev/isp/isp_target.h | 215 |
1 files changed, 21 insertions, 194 deletions
diff --git a/sys/dev/isp/isp_target.h b/sys/dev/isp/isp_target.h index bc6627a..f714f1e 100644 --- a/sys/dev/isp/isp_target.h +++ b/sys/dev/isp/isp_target.h @@ -320,7 +320,14 @@ typedef struct { u_int32_t ct_resid; /* residual length */ u_int16_t ct_timeout; u_int16_t ct_seg_count; - ispds_t ct_dataseg[ISP_RQDSEG]; + /* + * This is so we can share tag name space with + * CTIO{2,3,4} with the minimum of pain. + */ + union { + ispds_t ct_a[ISP_RQDSEG]; + } _u; +#define ct_dataseg _u.ct_a } ct_entry_t; /* @@ -413,7 +420,7 @@ typedef struct { union { /* * The three different modes that the target driver - * can set the CTIO2 up as. + * can set the CTIO{2,3,4} up as. * * The first is for sending FCP_DATA_IUs as well as * (optionally) sending a terminal SCSI status FCP_RSP_IU. @@ -429,15 +436,14 @@ typedef struct { u_int16_t _reserved2; u_int16_t ct_scsi_status; u_int32_t ct_xfrlen; - ispds_t ct_dataseg[ISP_RQDSEG_T2]; - /* - * For CTIO3, an ispds64_t would go here, padded - * to the end of the request. - */ - /* - * For CTIO4, an ispdlist_t would go here, padded - * to the end of the request. - */ + union { + ispds_t ct_a[ISP_RQDSEG_T2]; /* CTIO2 */ + ispds64_t ct_b[ISP_RQDSEG_T3]; /* CTIO3 */ + ispdslist_t ct_c; /* CTIO4 */ + } _u; +#define ct_dataseg _u.ct_a +#define ct_dataseg64 _u.ct_b +#define ct_dslist _u.ct_c } m0; struct { u_int16_t _reserved; @@ -495,195 +501,16 @@ typedef struct { #define CT2_DATA_UNDER 0x0800 /* - * Macros for packing/unpacking the above structures - */ - -#ifdef __sparc__ -#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 { \ - dst -> taga = src -> taga; \ - dst -> tagb = src -> taga; \ - } -#else -#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, vdst, vsrc) \ -{ \ - 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_ATIO2(isp, vdst, vsrc) \ -{ \ - 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_CTIO(isp, vdst, vsrc) \ -{ \ - 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_CTIO2(isp, vdst, vsrc) \ -{ \ - 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_ENABLE_LUN(isp, vdst, vsrc) \ -{ \ - 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); \ -} -#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) -#endif - -/* * Debug macros */ #define ISP_TDQE(isp, msg, idx, arg) \ if (isp->isp_dblev & ISP_LOGTDEBUG2) isp_print_qentry(isp, msg, idx, arg) +#ifdef ISP_TARGET_FUNCTIONS /* - * The functions below are target mode functions that - * are generally internal to the Qlogic driver. + * The functions below are for the publicly available + * target mode functions that are internal to the Qlogic driver. */ /* @@ -724,5 +551,5 @@ int isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t); */ void isp_target_async(struct ispsoftc *, int, int); - +#endif #endif /* _ISP_TARGET_H */ |