PERFORCE change 109632 for review
Matt Jacob
mjacob at FreeBSD.org
Thu Nov 9 18:40:26 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=109632
Change 109632 by mjacob at newisp on 2006/11/09 18:40:10
Eliminate so-called 'inline' functions. They aren't really
functions that can be inlined and the minor amount of kernel
symbol table pollution is a small price to pay to put them
where they belong.
Add back in the ability to sleep for some mailbox commands.
Affected files ...
.. //depot/projects/newisp/dev/isp/isp_freebsd.c#22 edit
.. //depot/projects/newisp/dev/isp/isp_freebsd.h#14 edit
Differences ...
==== //depot/projects/newisp/dev/isp/isp_freebsd.c#22 (text+ko) ====
@@ -48,8 +48,9 @@
int isp_announced = 0;
int isp_fabric_hysteresis = 5;
int isp_loop_down_limit = 300; /* default loop down limit */
+int isp_change_is_bad = 0; /* "changed" devices are bad */
int isp_quickboot_time = 5; /* don't wait more than N secs for loop up */
-int isp_lost_device_time = 30; /* grace time before reporting device lost */
+int isp_lost_device_time = 60; /* grace time before reporting device lost */
static const char *roles[4] = {
"(none)", "Target", "Initiator", "Target/Initiator"
};
@@ -2113,7 +2114,7 @@
struct cam_path *tmppath;
int dbidx, tgt;
- isp_prt(isp, ISP_LOGALL, "LDT EXPIRED");
+ isp_prt(isp, ISP_LOGDEBUG0, "LDT timer expired");
ISP_LOCK(isp);
/*
@@ -2194,7 +2195,9 @@
int wasfrozen, lb;
isp_prt(isp, ISP_LOGDEBUG0, "kthread: checking FC state");
+ isp->isp_osinfo.mbox_sleep_ok = 1;
lb = isp_fc_runstate(isp, 250000);
+ isp->isp_osinfo.mbox_sleep_ok = 0;
if (lb) {
unsigned int inc = 1;
@@ -2988,7 +2991,7 @@
isp->isp_osinfo.ldt = timeout(isp_ldt, isp,
isp->isp_osinfo.loop_down_limit * hz);
isp->isp_osinfo.ldt_running = 1;
-isp_prt(isp, ISP_LOGALL, "LDT: starting loop down timer for %d seconds", isp->isp_osinfo.loop_down_limit);
+ isp_prt(isp, ISP_LOGDEBUG0, "starting LDT timer");
}
isp_prt(isp, ISP_LOGINFO, msg);
break;
@@ -3145,6 +3148,9 @@
} else {
msg = "Other Change Notify";
}
+ /*
+ * If the loop down timer is running, cancel it.
+ */
if (isp->isp_osinfo.ldt_running) {
isp->isp_osinfo.ldt_running = 0;
untimeout(isp_ldt, isp, isp->isp_osinfo.ldt);
@@ -3269,3 +3275,94 @@
va_end(ap);
printf("\n");
}
+
+uint64_t
+isp_nanotime_sub(struct timespec *b, struct timespec *a)
+{
+ uint64_t elapsed;
+ struct timespec x = *b;
+ timespecsub(&x, a);
+ elapsed = GET_NANOSEC(&x);
+ if (elapsed == 0)
+ elapsed++;
+ return (elapsed);
+}
+
+int
+isp_mbox_acquire(ispsoftc_t *isp)
+{
+ if (isp->isp_osinfo.mboxbsy) {
+ return (1);
+ } else {
+ isp->isp_osinfo.mboxcmd_done = 0;
+ isp->isp_osinfo.mboxbsy = 1;
+ return (0);
+ }
+}
+
+void
+isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp)
+{
+ int usecs = mbp->timeout;
+ int j;
+
+ if (usecs == 0) {
+ usecs = MBCMD_DEFAULT_TIMEOUT;
+ }
+ if (isp->isp_mbxwrk0) {
+ usecs *= isp->isp_mbxwrk0;
+ }
+ if (isp->isp_osinfo.mbox_sleep_ok) {
+ struct timeval t;
+ t.tv_sec = usecs / 1000000;
+ t.tv_usec = usecs % 1000000;
+ isp->isp_osinfo.mbox_sleep_ok = 0;
+ isp->isp_osinfo.mbox_sleeping = 1;
+#if __FreeBSD_version < 500000 || !defined(ISP_SMPLOCK)
+ tsleep(&isp->isp_mbxworkp, PRIBIO, "ispmbx_sleep", tvtohz(&t));
+#else
+ msleep(&isp->isp_mbxworkp, &isp->isp_mtx, PRIBIO,
+ "ispmbx_sleep", tvtohz(&t));
+#endif
+ isp->isp_osinfo.mbox_sleep_ok = 1;
+ isp->isp_osinfo.mbox_sleeping = 0;
+ } else {
+ for (j = 0; j < usecs; j += 100) {
+ uint32_t isr;
+ uint16_t sema, mbox;
+ if (isp->isp_osinfo.mboxcmd_done) {
+ break;
+ }
+ if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
+ isp_intr(isp, isr, sema, mbox);
+ if (isp->isp_osinfo.mboxcmd_done) {
+ break;
+ }
+ }
+ USEC_DELAY(100);
+ }
+ }
+ if (isp->isp_osinfo.mboxcmd_done == 0) {
+ isp_prt(isp, ISP_LOGWARN,
+ "%s Mailbox Command (0x%x) Timeout",
+ isp->isp_osinfo.mbox_sleep_ok? "Interrupting" : "Polled",
+ isp->isp_lastmbxcmd);
+ mbp->param[0] = MBOX_TIMEOUT;
+ isp->isp_osinfo.mboxcmd_done = 1;
+ }
+}
+
+void
+isp_mbox_notify_done(ispsoftc_t *isp)
+{
+ if (isp->isp_osinfo.mbox_sleeping) {
+ wakeup(&isp->isp_mbxworkp);
+ }
+ isp->isp_osinfo.mboxcmd_done = 1;
+}
+
+void
+isp_mbox_release(ispsoftc_t *isp)
+{
+ isp->isp_osinfo.mboxbsy = 0;
+}
==== //depot/projects/newisp/dev/isp/isp_freebsd.h#14 (text+ko) ====
@@ -154,10 +154,12 @@
uint32_t : 5,
simqfrozen : 3,
hysteresis : 8,
- : 3,
+ : 1,
ldt_running : 1,
disabled : 1,
fcbsy : 1,
+ mbox_sleeping : 1,
+ mbox_sleep_ok : 1,
mboxcmd_done : 1,
mboxbsy : 1;
struct callout_handle ldt; /* loop down timer */
@@ -231,7 +233,7 @@
#define NANOTIME_T struct timespec
#define GET_NANOTIME nanotime
#define GET_NANOSEC(x) ((x)->tv_sec * 1000000000 + (x)->tv_nsec)
-#define NANOTIME_SUB nanotime_sub
+#define NANOTIME_SUB isp_nanotime_sub
#define MAXISPREQUEST(isp) ((IS_FC(isp) || IS_ULTRA2(isp))? 1024 : 256)
@@ -253,7 +255,7 @@
#define MBOX_ACQUIRE isp_mbox_acquire
#define MBOX_WAIT_COMPLETE isp_mbox_wait_complete
-#define MBOX_NOTIFY_COMPLETE(isp) isp->isp_osinfo.mboxcmd_done = 1
+#define MBOX_NOTIFY_COMPLETE isp_mbox_notify_done
#define MBOX_RELEASE isp_mbox_release
#define FC_SCRATCH_ACQUIRE(isp) \
@@ -410,7 +412,6 @@
#include <dev/isp/isp_tpublic.h>
#endif
-void isp_prt(ispsoftc_t *, int level, const char *, ...) __printflike(3, 4);
/*
* isp_osinfo definiitions && shorthand
*/
@@ -461,100 +462,21 @@
#define XS_CMD_S_CLEAR(sccb) (sccb)->ccb_h.spriv_field0 = 0
/*
+ * Platform Library Functions
+ */
+void isp_prt(ispsoftc_t *, int level, const char *, ...) __printflike(3, 4);
+uint64_t isp_nanotime_sub(struct timespec *, struct timespec *);
+int isp_mbox_acquire(ispsoftc_t *);
+void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *);
+void isp_mbox_notify_done(ispsoftc_t *);
+void isp_mbox_release(ispsoftc_t *);
+
+/*
* Platform specific inline functions
*/
-static __inline int isp_mbox_acquire(ispsoftc_t *);
-static __inline void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *);
-static __inline void isp_mbox_release(ispsoftc_t *);
-
-static __inline int
-isp_mbox_acquire(ispsoftc_t *isp)
-{
- if (isp->isp_osinfo.mboxbsy) {
- return (1);
- } else {
- isp->isp_osinfo.mboxcmd_done = 0;
- isp->isp_osinfo.mboxbsy = 1;
- return (0);
- }
-}
-
-static __inline void
-isp_mbox_wait_complete(ispsoftc_t *isp, mbreg_t *mbp)
-{
- int lim = mbp->timeout;
- int j;
-
- if (lim == 0) {
- lim = MBCMD_DEFAULT_TIMEOUT;
- }
- if (isp->isp_mbxwrk0) {
- lim *= isp->isp_mbxwrk0;
- }
- for (j = 0; j < lim; j += 100) {
- uint32_t isr;
- uint16_t sema, mbox;
- if (isp->isp_osinfo.mboxcmd_done) {
- break;
- }
- if (ISP_READ_ISR(isp, &isr, &sema, &mbox)) {
- isp_intr(isp, isr, sema, mbox);
- if (isp->isp_osinfo.mboxcmd_done) {
- break;
- }
- }
- USEC_DELAY(100);
- }
- if (isp->isp_osinfo.mboxcmd_done == 0) {
- isp_prt(isp, ISP_LOGWARN,
- "Polled Mailbox Command (0x%x) Timeout",
- isp->isp_lastmbxcmd);
- mbp->param[0] = MBOX_TIMEOUT;
- isp->isp_osinfo.mboxcmd_done = 1;
- }
-}
-
-static __inline void
-isp_mbox_release(ispsoftc_t *isp)
-{
- isp->isp_osinfo.mboxbsy = 0;
-}
-
-static __inline uint64_t nanotime_sub(struct timespec *, struct timespec *);
-static __inline uint64_t
-nanotime_sub(struct timespec *b, struct timespec *a)
-{
- uint64_t elapsed;
- struct timespec x = *b;
- timespecsub(&x, a);
- elapsed = GET_NANOSEC(&x);
- if (elapsed == 0)
- elapsed++;
- return (elapsed);
-}
-
-static __inline char *strncat(char *, const char *, size_t);
-static __inline char *
-strncat(char *d, const char *s, size_t c)
-{
- char *t = d;
-
- if (c) {
- while (*d)
- d++;
- while ((*d++ = *s++)) {
- if (--c == 0) {
- *d = '\0';
- break;
- }
- }
- }
- return (t);
-}
-
/*
- * ISP Library functions
+ * ISP General Library functions
*/
#include <dev/isp/isp_library.h>
More information about the p4-projects
mailing list