summaryrefslogtreecommitdiff
path: root/sys/dev/ic/isp_openbsd.h
diff options
context:
space:
mode:
authormjacob <mjacob@cvs.openbsd.org>2001-12-14 00:20:56 +0000
committermjacob <mjacob@cvs.openbsd.org>2001-12-14 00:20:56 +0000
commit17d4cdf5fb28cbcf2a7f35a2029314c30369a46f (patch)
treeb39666b472468774f4e8f103699528500aa0af0b /sys/dev/ic/isp_openbsd.h
parentb3b7dc842a6cac27f1954516ba9e702ba2b1ef05 (diff)
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). 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. For OpenSD, it does a ddi_dmamap_sync as appropriate. This gets us out of the explicit ddi_dmamap_sync on the whole response queue that we did for SBus cards at each interrupt. Now, because SBus/sparc doesn't use bus_dma, some shenanigans were done to support this. But Jason was nice enough to test the SBus/sparcv9 changes for me, and they did the right thing as well. Set things up so that platforms that cannot have an SBus don't get a lot of the SBus code checks (dead coded out). 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). Explicitly decode GetAllNext SNS Response back *as* a GetAllNext response. Otherwise, we won't unswizzle it correctly. Nuke some additional __P macros.
Diffstat (limited to 'sys/dev/ic/isp_openbsd.h')
-rw-r--r--sys/dev/ic/isp_openbsd.h120
1 files changed, 94 insertions, 26 deletions
diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h
index 408551e8303..7cafc074cbc 100644
--- a/sys/dev/ic/isp_openbsd.h
+++ b/sys/dev/ic/isp_openbsd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: isp_openbsd.h,v 1.17 2001/11/06 19:53:18 miod Exp $ */
+/* $OpenBSD: isp_openbsd.h,v 1.18 2001/12/14 00:20:55 mjacob Exp $ */
/*
* OpenBSD Specific definitions for the Qlogic ISP Host Adapter
*/
@@ -41,6 +41,10 @@
#include <sys/user.h>
#include <sys/queue.h>
+#if !(defined(__sparc__) && !defined(__sparcv9__))
+#include <machine/bus.h>
+#endif
+
#include <scsi/scsi_all.h>
#include <scsi/scsi_all.h>
#include <scsi/scsiconf.h>
@@ -50,9 +54,17 @@
#include <uvm/uvm_extern.h>
+/*
+ * Efficiency- get rid of SBus code && tests unless we need them.
+ */
+#if defined(__sparcv9__ ) || defined(__sparc__)
+#define ISP_SBUS_SUPPORTED 1
+#else
+#define ISP_SBUS_SUPPORTED 0
+#endif
#define ISP_PLATFORM_VERSION_MAJOR 2
-#define ISP_PLATFORM_VERSION_MINOR 0
+#define ISP_PLATFORM_VERSION_MINOR 1
struct isposinfo {
struct device _dev;
@@ -63,6 +75,16 @@ struct isposinfo {
int mboxwaiting;
u_int32_t islocked;
u_int32_t onintstack;
+#if !(defined(__sparc__) && !defined(__sparcv9__))
+ bus_dma_tag_t dmatag;
+ bus_dmamap_t rqdmap;
+ bus_dmamap_t rsdmap;
+ bus_dmamap_t scdmap; /* FC only */
+#define isp_dmatag isp_osinfo.dmatag
+#define isp_rqdmap isp_osinfo.rqdmap
+#define isp_rsdmap isp_osinfo.rsdmap
+#define isp_scdmap isp_osinfo.scdmap
+#endif
unsigned int : 28,
rtpend : 1,
@@ -112,14 +134,52 @@ struct isposinfo {
#define MAXISPREQUEST(isp) 256
-#ifdef __alpha__
-#define MEMORYBARRIER(isp, type, offset, size) alpha_mb()
+#if !(defined(__sparc__) && !defined(__sparcv9__))
+#define MEMORYBARRIER(isp, type, offset, size) \
+switch (type) { \
+case SYNC_REQUEST: \
+{ \
+ off_t off = (off_t) offset * QENTRY_LEN; \
+ bus_dmamap_sync(isp->isp_dmatag, isp->isp_rqdmap, \
+ off, size, BUS_DMASYNC_PREWRITE); \
+ break; \
+} \
+case SYNC_RESULT: \
+{ \
+ off_t off = (off_t) offset * QENTRY_LEN; \
+ off += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)); \
+ bus_dmamap_sync(isp->isp_dmatag, isp->isp_rsdmap, \
+ off, size, BUS_DMASYNC_POSTREAD); \
+ break; \
+} \
+case SYNC_SFORDEV: \
+{ \
+ off_t off = \
+ ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) + \
+ ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)) + offset; \
+ bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \
+ off, size, BUS_DMASYNC_PREWRITE); \
+ break; \
+} \
+case SYNC_SFORCPU: \
+{ \
+ off_t off = \
+ ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) + \
+ ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp)) + offset; \
+ bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap, \
+ off, size, BUS_DMASYNC_POSTREAD); \
+ break; \
+} \
+case SYNC_REG: \
+default: \
+ break; \
+}
#else
#define MEMORYBARRIER(isp, type, offset, size)
#endif
#define MBOX_ACQUIRE(isp)
-#define MBOX_WAIT_COMPLETE isp_wait_complete
+#define MBOX_WAIT_COMPLETE isp_wait_complete
#define MBOX_NOTIFY_COMPLETE(isp) \
if (isp->isp_osinfo.mboxwaiting) { \
@@ -194,29 +254,37 @@ struct isposinfo {
#define ISP_NODEWWN(isp) FCPARAM(isp)->isp_nodewwn
#define ISP_PORTWWN(isp) FCPARAM(isp)->isp_portwwn
-#define ISP_UNSWIZZLE_AND_COPY_PDBP(isp, dest, src) \
- if((void *)src != (void *)dest) bcopy(src, dest, sizeof (isp_pdb_t))
-#define ISP_SWIZZLE_ICB(a, b)
-#ifdef __sparc__
-#define ISP_SWIZZLE_REQUEST(a, b) \
- ISP_SBUSIFY_ISPHDR(a, &(b)->req_header); \
- ISP_SBUSIFY_ISPREQ(a, b)
-#define ISP_UNSWIZZLE_RESPONSE(a, b, c) \
- ISP_SBUSIFY_ISPHDR(a, &(b)->req_header)
+#if BYTE_ORDER == BIG_ENDIAN
+#ifdef ISP_SBUS_SUPPORTED
+#define ISP_IOXPUT_8(isp, s, d) *(d) = s
+#define ISP_IOXPUT_16(isp, s, d) \
+ *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : swap16(s)
+#define ISP_IOXPUT_32(isp, s, d) \
+ *(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : swap32(s)
+
+#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s))
+#define ISP_IOXGET_16(isp, s, d) \
+ d = (isp->isp_bustype == ISP_BT_SBUS)? \
+ *((u_int16_t *)s) : swap16(*((u_int16_t *)s))
+#define ISP_IOXGET_32(isp, s, d) \
+ d = (isp->isp_bustype == ISP_BT_SBUS)? \
+ *((u_int32_t *)s) : swap32(*((u_int32_t *)s))
#else
-#define ISP_SWIZZLE_REQUEST(a, b)
-#define ISP_UNSWIZZLE_RESPONSE(a, b, c)
+#define ISP_IOXPUT_8(isp, s, d) *(d) = s
+#define ISP_IOXPUT_16(isp, s, d) *(d) = swap16(s)
+#define ISP_IOXPUT_32(isp, s, d) *(d) = swap32(s)
+#define ISP_IOXGET_8(isp, s, d) d = (*((u_int8_t *)s))
+#define ISP_IOXGET_16(isp, s, d) d = swap16(*((u_int16_t *)s))
+#define ISP_IOXGET_32(isp, s, d) d = swap32(*((u_int32_t *)s))
#endif
-#define ISP_SWIZZLE_SNS_REQ(a, b)
-#define ISP_UNSWIZZLE_SNS_RSP(a, b, c)
-#ifdef __sparc__
-#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) \
- { \
- u_int16_t tmp = *rp >> 8; \
- tmp |= ((*rp & 0xff) << 8); \
- *rp = tmp; \
- }
+#define ISP_SWIZZLE_NVRAM_WORD(isp, rp) *rp = swap16(*rp)
#else
+#define ISP_IOXPUT_8(isp, s, d) *(d) = s
+#define ISP_IOXPUT_16(isp, s, d) *(d) = s
+#define ISP_IOXPUT_32(isp, s, d) *(d) = s
+#define ISP_IOXGET_8(isp, s, d) d = *(s)
+#define ISP_IOXGET_16(isp, s, d) d = *(s)
+#define ISP_IOXGET_32(isp, s, d) d = *(s)
#define ISP_SWIZZLE_NVRAM_WORD(isp, rp)
#endif
@@ -336,7 +404,7 @@ isp_wait_complete(struct ispsoftc *isp)
{
if (MUST_POLL(isp)) {
int usecs = 0;
- while (usecs < 2 * 1000000) {
+ while (usecs < 5 * 1000000) {
u_int16_t isr, sema, mbox;
if (isp->isp_mboxbsy == 0) {
break;