Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/dev/ic Pull up revisions 1.10-1.13 (requested by mj...



details:   https://anonhg.NetBSD.org/src/rev/7db3b75e0386
branches:  netbsd-1-5
changeset: 490882:7db3b75e0386
user:      he <he%NetBSD.org@localhost>
date:      Fri Mar 16 19:13:47 2001 +0000

description:
Pull up revisions 1.10-1.13 (requested by mjacob):
  Add isp_fc_runstate function.  Fix pathnames in comment.
  Fix isp_print_qentry function.
  Handles are u_int16_t now.  ANSIfy.

diffstat:

 sys/dev/ic/isp_inline.h |  162 ++++++++++++++++++++++++++---------------------
 1 files changed, 89 insertions(+), 73 deletions(-)

diffs (256 lines):

diff -r a59f216cbe05 -r 7db3b75e0386 sys/dev/ic/isp_inline.h
--- a/sys/dev/ic/isp_inline.h   Fri Mar 16 19:13:01 2001 +0000
+++ b/sys/dev/ic/isp_inline.h   Fri Mar 16 19:13:47 2001 +0000
@@ -1,18 +1,17 @@
-/* $NetBSD: isp_inline.h,v 1.5.4.1 2000/08/28 17:45:08 mjacob Exp $ */
+/* $NetBSD: isp_inline.h,v 1.5.4.2 2001/03/16 19:13:47 he Exp $ */
 /*
  * This driver, which is contained in NetBSD in the files:
  *
  *     sys/dev/ic/isp.c
- *     sys/dev/ic/ic/isp.c
- *     sys/dev/ic/ic/isp_inline.h
- *     sys/dev/ic/ic/isp_netbsd.c
- *     sys/dev/ic/ic/isp_netbsd.h
- *     sys/dev/ic/ic/isp_target.c
- *     sys/dev/ic/ic/isp_target.h
- *     sys/dev/ic/ic/isp_tpublic.h
- *     sys/dev/ic/ic/ispmbox.h
- *     sys/dev/ic/ic/ispreg.h
- *     sys/dev/ic/ic/ispvar.h
+ *     sys/dev/ic/isp_inline.h
+ *     sys/dev/ic/isp_netbsd.c
+ *     sys/dev/ic/isp_netbsd.h
+ *     sys/dev/ic/isp_target.c
+ *     sys/dev/ic/isp_target.h
+ *     sys/dev/ic/isp_tpublic.h
+ *     sys/dev/ic/ispmbox.h
+ *     sys/dev/ic/ispreg.h
+ *     sys/dev/ic/ispvar.h
  *     sys/microcode/isp/asm_sbus.h
  *     sys/microcode/isp/asm_1040.h
  *     sys/microcode/isp/asm_1080.h
@@ -68,29 +67,15 @@
  * will be a seed for the last handled allocated.
  */
 
-static INLINE int
-isp_save_xs __P((struct ispsoftc *, XS_T *, u_int32_t *));
-
-static INLINE XS_T *
-isp_find_xs __P((struct ispsoftc *, u_int32_t));
-
-static INLINE u_int32_t
-isp_find_handle __P((struct ispsoftc *, XS_T *));
+static INLINE int isp_save_xs(struct ispsoftc *, XS_T *, u_int16_t *);
+static INLINE XS_T *isp_find_xs(struct ispsoftc *, u_int16_t);
+static INLINE u_int16_t isp_find_handle(struct ispsoftc *, XS_T *);
+static INLINE int isp_handle_index(u_int16_t);
+static INLINE void isp_destroy_handle(struct ispsoftc *, u_int16_t);
+static INLINE void isp_remove_handle(struct ispsoftc *, XS_T *);
 
 static INLINE int
-isp_handle_index __P((u_int32_t));
-
-static INLINE void
-isp_destroy_handle __P((struct ispsoftc *, u_int32_t));
-
-static INLINE void
-isp_remove_handle __P((struct ispsoftc *, XS_T *));
-
-static INLINE int
-isp_save_xs(isp, xs, handlep)
-       struct ispsoftc *isp;
-       XS_T *xs;
-       u_int32_t *handlep;
+isp_save_xs(struct ispsoftc *isp, XS_T *xs, u_int16_t *handlep)
 {
        int i, j;
 
@@ -114,27 +99,23 @@
 }
 
 static INLINE XS_T *
-isp_find_xs(isp, handle)
-       struct ispsoftc *isp;
-       u_int32_t handle;
+isp_find_xs(struct ispsoftc *isp, u_int16_t handle)
 {
-       if (handle < 1 || handle > (u_int32_t) isp->isp_maxcmds) {
+       if (handle < 1 || handle > (u_int16_t) isp->isp_maxcmds) {
                return (NULL);
        } else {
                return (isp->isp_xflist[handle - 1]);
        }
 }
 
-static INLINE u_int32_t
-isp_find_handle(isp, xs)
-       struct ispsoftc *isp;
-       XS_T *xs;
+static INLINE u_int16_t
+isp_find_handle(struct ispsoftc *isp, XS_T *xs)
 {
        int i;
        if (xs != NULL) {
                for (i = 0; i < isp->isp_maxcmds; i++) {
                        if (isp->isp_xflist[i] == xs) {
-                               return ((u_int32_t) i+1);
+                               return ((u_int16_t) i+1);
                        }
                }
        }
@@ -142,39 +123,31 @@
 }
 
 static INLINE int
-isp_handle_index(handle)
-       u_int32_t handle;
+isp_handle_index(u_int16_t handle)
 {
        return (handle-1);
 }
 
 static INLINE void
-isp_destroy_handle(isp, handle)
-       struct ispsoftc *isp;
-       u_int32_t handle;
+isp_destroy_handle(struct ispsoftc *isp, u_int16_t handle)
 {
-       if (handle > 0 && handle <= (u_int32_t) isp->isp_maxcmds) {
+       if (handle > 0 && handle <= (u_int16_t) isp->isp_maxcmds) {
                isp->isp_xflist[isp_handle_index(handle)] = NULL;
        }
 }
 
 static INLINE void
-isp_remove_handle(isp, xs)
-       struct ispsoftc *isp;
-       XS_T *xs;
+isp_remove_handle(struct ispsoftc *isp, XS_T *xs)
 {
        isp_destroy_handle(isp, isp_find_handle(isp, xs));
 }
 
 static INLINE int
-isp_getrqentry __P((struct ispsoftc *, u_int16_t *, u_int16_t *, void **));
+isp_getrqentry(struct ispsoftc *, u_int16_t *, u_int16_t *, void **);
 
 static INLINE int
-isp_getrqentry(isp, iptrp, optrp, resultp)
-       struct ispsoftc *isp;
-       u_int16_t *iptrp;
-       u_int16_t *optrp;
-       void **resultp;
+isp_getrqentry(struct ispsoftc *isp, u_int16_t *iptrp,
+    u_int16_t *optrp, void **resultp)
 {
        volatile u_int16_t iptr, optr;
 
@@ -192,41 +165,32 @@
        return (0);
 }
 
-static INLINE void
-isp_print_qentry __P((struct ispsoftc *, char *, int, void *));
+static INLINE void isp_print_qentry (struct ispsoftc *, char *, int, void *);
 
 
 #define        TBA     (4 * (((QENTRY_LEN >> 2) * 3) + 1) + 1)
 static INLINE void
-isp_print_qentry(isp, msg, idx, arg)
-       struct ispsoftc *isp;
-       char *msg;
-       int idx;
-       void *arg;
+isp_print_qentry(struct ispsoftc *isp, char *msg, int idx, void *arg)
 {
        char buf[TBA];
        int amt, i, j;
        u_int8_t *ptr = arg;
 
+       isp_prt(isp, ISP_LOGALL, "%s index %d=>", msg, idx);
        for (buf[0] = 0, amt = i = 0; i < 4; i++) {
                buf[0] = 0;
+               SNPRINTF(buf, TBA, "  ");
                for (j = 0; j < (QENTRY_LEN >> 2); j++) {
                        SNPRINTF(buf, TBA, "%s %02x", buf, ptr[amt++] & 0xff);
                }
-               STRNCAT(buf, "\n", TBA);
+               isp_prt(isp, ISP_LOGALL, buf);
        }
-       isp_prt(isp, ISP_LOGALL, "%s index %d:%s", msg, idx, buf);
 }
 
+static INLINE void isp_print_bytes(struct ispsoftc *, char *, int, void *);
+
 static INLINE void
-isp_print_bytes __P((struct ispsoftc *, char *, int, void *));
-
-static INLINE void
-isp_print_bytes(isp, msg, amt, arg)
-       struct ispsoftc *isp;
-       char *msg;
-       int amt;
-       void *arg;
+isp_print_bytes(struct ispsoftc *isp, char *msg, int amt, void *arg)
 {
        char buf[128];
        u_int8_t *ptr = arg;
@@ -248,4 +212,56 @@
                buf[0] = 0;
        }
 }
+
+/*
+ * Do the common path to try and ensure that link is up, we've scanned
+ * the fabric (if we're on a fabric), and that we've synchronized this
+ * all with our own database and done the appropriate logins.
+ *
+ * We repeatedly check for firmware state and loop state after each
+ * action because things may have changed while we were doing this.
+ * Any failure or change of state causes us to return a nonzero value.
+ *
+ * We honor HBA roles in that if we're not in Initiator mode, we don't
+ * attempt to sync up the database (that's for somebody else to do,
+ * if ever).
+ *
+ * We assume we enter here with any locks held.
+ */
+
+static INLINE int isp_fc_runstate(struct ispsoftc *, int);
+
+static INLINE int
+isp_fc_runstate(struct ispsoftc *isp, int tval)
+{
+       fcparam *fcp;
+       int *tptr;
+
+       if (IS_SCSI(isp))
+               return (0);
+
+       tptr = tval? &tval : NULL;
+       if (isp_control(isp, ISPCTL_FCLINK_TEST, tptr) != 0) {
+               return (-1);
+       }
+       fcp = FCPARAM(isp);
+       if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_PDB_RCVD)
+               return (-1);
+       if (isp_control(isp, ISPCTL_SCAN_FABRIC, NULL) != 0) {
+               return (-1);
+       }
+       if (isp_control(isp, ISPCTL_SCAN_LOOP, NULL) != 0) {
+               return (-1);
+       }
+       if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) {
+               return (0);
+       }
+       if (isp_control(isp, ISPCTL_PDB_SYNC, NULL) != 0) {
+               return (-1);
+       }
+       if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
+               return (-1);
+       }
+       return (0);
+}
 #endif /* _ISP_INLINE_H */



Home | Main Index | Thread Index | Old Index