summaryrefslogtreecommitdiffstats
path: root/sys/dev/mpt
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2006-09-07 23:08:21 +0000
committermjacob <mjacob@FreeBSD.org>2006-09-07 23:08:21 +0000
commitfd58e8e716ba29ae72c1317b36ba3712939a5326 (patch)
tree9bed386eb1b182b5def3bf1c1188968fcbf13a17 /sys/dev/mpt
parent50839278da46102d66fbb4dc57e4fb6b59650651 (diff)
downloadFreeBSD-src-fd58e8e716ba29ae72c1317b36ba3712939a5326.zip
FreeBSD-src-fd58e8e716ba29ae72c1317b36ba3712939a5326.tar.gz
Create a 'ready' handler for each personality. The purpose of this handler
is to able to be called after *all* attach and enable events are done. We establish a SYSINIT hook to call this handler. The current usage for it is to add scsi target resources *after* all enables are done. There seems to be some dependencies between different halves of a dual-port with respect to target mode. Put in more meaningful event messages for some events- in particular QUEUE FULL events so we can see what the queue depth was when the IOC sent us this message. MFC after: 1 week
Diffstat (limited to 'sys/dev/mpt')
-rw-r--r--sys/dev/mpt/mpt.c33
-rw-r--r--sys/dev/mpt/mpt.h2
-rw-r--r--sys/dev/mpt/mpt_cam.c44
3 files changed, 66 insertions, 13 deletions
diff --git a/sys/dev/mpt/mpt.c b/sys/dev/mpt/mpt.c
index 2b8028a..0e83761 100644
--- a/sys/dev/mpt/mpt.c
+++ b/sys/dev/mpt/mpt.c
@@ -116,7 +116,7 @@ static int maxwait_ack = 0;
static int maxwait_int = 0;
static int maxwait_state = 0;
-TAILQ_HEAD(, mpt_softc) mpt_tailq = TAILQ_HEAD_INITIALIZER(mpt_tailq);
+static TAILQ_HEAD(, mpt_softc) mpt_tailq = TAILQ_HEAD_INITIALIZER(mpt_tailq);
mpt_reply_handler_t *mpt_reply_handlers[MPT_NUM_REPLY_HANDLERS];
static mpt_reply_handler_t mpt_default_reply_handler;
@@ -186,6 +186,7 @@ static mpt_load_handler_t mpt_stdload;
static mpt_probe_handler_t mpt_stdprobe;
static mpt_attach_handler_t mpt_stdattach;
static mpt_enable_handler_t mpt_stdenable;
+static mpt_ready_handler_t mpt_stdready;
static mpt_event_handler_t mpt_stdevent;
static mpt_reset_handler_t mpt_stdreset;
static mpt_shutdown_handler_t mpt_stdshutdown;
@@ -197,6 +198,7 @@ static struct mpt_personality mpt_default_personality =
.probe = mpt_stdprobe,
.attach = mpt_stdattach,
.enable = mpt_stdenable,
+ .ready = mpt_stdready,
.event = mpt_stdevent,
.reset = mpt_stdreset,
.shutdown = mpt_stdshutdown,
@@ -238,7 +240,6 @@ MODULE_VERSION(mpt_core, 1);
#define MPT_PERS_ATTACHED(pers, mpt) ((mpt)->mpt_pers_mask & (0x1 << pers->id))
-
int
mpt_modevent(module_t mod, int type, void *data)
{
@@ -326,6 +327,12 @@ mpt_stdenable(struct mpt_softc *mpt)
return (0);
}
+void
+mpt_stdready(struct mpt_softc *mpt)
+{
+}
+
+
int
mpt_stdevent(struct mpt_softc *mpt, request_t *req, MSG_EVENT_NOTIFY_REPLY *msg)
{
@@ -356,6 +363,25 @@ mpt_stdunload(struct mpt_personality *pers)
return (0);
}
+/*
+ * Post driver attachment, we may want to perform some global actions.
+ * Here is the hook to do so.
+ */
+
+static void
+mpt_postattach(void *unused)
+{
+ struct mpt_softc *mpt;
+ struct mpt_personality *pers;
+
+ TAILQ_FOREACH(mpt, &mpt_tailq, links) {
+ MPT_PERS_FOREACH(mpt, pers)
+ pers->ready(mpt);
+ }
+}
+SYSINIT(mptdev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, mpt_postattach, NULL);
+
+
/******************************* Bus DMA Support ******************************/
void
mpt_map_rquest(void *arg, bus_dma_segment_t *segs, int nseg, int error)
@@ -1980,6 +2006,7 @@ mpt_attach(struct mpt_softc *mpt)
int i;
int error;
+ TAILQ_INSERT_TAIL(&mpt_tailq, mpt, links);
for (i = 0; i < MPT_MAX_PERSONALITIES; i++) {
pers = mpt_personalities[i];
if (pers == NULL) {
@@ -2038,7 +2065,7 @@ mpt_detach(struct mpt_softc *mpt)
mpt->mpt_pers_mask &= ~(0x1 << pers->id);
pers->use_count--;
}
-
+ TAILQ_REMOVE(&mpt_tailq, mpt, links);
return (0);
}
diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h
index 48fa2a8..f27c397 100644
--- a/sys/dev/mpt/mpt.h
+++ b/sys/dev/mpt/mpt.h
@@ -177,6 +177,7 @@ typedef int mpt_load_handler_t(struct mpt_personality *);
typedef int mpt_probe_handler_t(struct mpt_softc *);
typedef int mpt_attach_handler_t(struct mpt_softc *);
typedef int mpt_enable_handler_t(struct mpt_softc *);
+typedef void mpt_ready_handler_t(struct mpt_softc *);
typedef int mpt_event_handler_t(struct mpt_softc *, request_t *,
MSG_EVENT_NOTIFY_REPLY *);
typedef void mpt_reset_handler_t(struct mpt_softc *, int /*type*/);
@@ -195,6 +196,7 @@ struct mpt_personality
mpt_probe_handler_t *probe; /* configure personailty */
mpt_attach_handler_t *attach; /* initialize device instance */
mpt_enable_handler_t *enable; /* enable device */
+ mpt_ready_handler_t *ready; /* final open for business */
mpt_event_handler_t *event; /* Handle MPI event. */
mpt_reset_handler_t *reset; /* Re-init after reset. */
mpt_shutdown_handler_t *shutdown; /* Shutdown instance. */
diff --git a/sys/dev/mpt/mpt_cam.c b/sys/dev/mpt/mpt_cam.c
index 468242e..4b25fda 100644
--- a/sys/dev/mpt/mpt_cam.c
+++ b/sys/dev/mpt/mpt_cam.c
@@ -161,6 +161,7 @@ static uint32_t fc_els_handler_id = MPT_HANDLER_ID_NONE;
static mpt_probe_handler_t mpt_cam_probe;
static mpt_attach_handler_t mpt_cam_attach;
static mpt_enable_handler_t mpt_cam_enable;
+static mpt_ready_handler_t mpt_cam_ready;
static mpt_event_handler_t mpt_cam_event;
static mpt_reset_handler_t mpt_cam_ioc_reset;
static mpt_detach_handler_t mpt_cam_detach;
@@ -171,6 +172,7 @@ static struct mpt_personality mpt_cam_personality =
.probe = mpt_cam_probe,
.attach = mpt_cam_attach,
.enable = mpt_cam_enable,
+ .ready = mpt_cam_ready,
.event = mpt_cam_event,
.reset = mpt_cam_ioc_reset,
.detach = mpt_cam_detach,
@@ -246,7 +248,8 @@ mpt_cam_attach(struct mpt_softc *mpt)
/*
* If we support target mode, we register a reply handler for it,
- * but don't add resources until we actually enable target mode.
+ * but don't add command resources until we actually enable target
+ * mode.
*/
if (mpt->is_fc && (mpt->role & MPT_ROLE_TARGET) != 0) {
handler.reply_handler = mpt_scsi_tgt_reply_handler;
@@ -812,6 +815,12 @@ mpt_cam_enable(struct mpt_softc *mpt)
return (EIO);
}
}
+ return (0);
+}
+
+void
+mpt_cam_ready(struct mpt_softc *mpt)
+{
/*
* If we're in target mode, hang out resources now
* so we don't cause the world to hang talking to us.
@@ -820,11 +829,12 @@ mpt_cam_enable(struct mpt_softc *mpt)
/*
* Try to add some target command resources
*/
+ MPT_LOCK(mpt);
if (mpt_add_target_commands(mpt) == FALSE) {
- return (ENOMEM);
+ mpt_prt(mpt, "failed to add target commands\n");
}
+ MPT_UNLOCK(mpt);
}
- return (0);
}
void
@@ -2028,15 +2038,16 @@ static int
mpt_cam_event(struct mpt_softc *mpt, request_t *req,
MSG_EVENT_NOTIFY_REPLY *msg)
{
+
switch(msg->Event & 0xFF) {
case MPI_EVENT_UNIT_ATTENTION:
- mpt_prt(mpt, "Bus: 0x%02x TargetID: 0x%02x\n",
+ mpt_prt(mpt, "UNIT ATTENTION: Bus: 0x%02x TargetID: 0x%02x\n",
(msg->Data[0] >> 8) & 0xff, msg->Data[0] & 0xff);
break;
case MPI_EVENT_IOC_BUS_RESET:
/* We generated a bus reset */
- mpt_prt(mpt, "IOC Bus Reset Port: %d\n",
+ mpt_prt(mpt, "IOC Generated Bus Reset Port: %d\n",
(msg->Data[0] >> 8) & 0xff);
xpt_async(AC_BUS_RESET, mpt->path, NULL);
break;
@@ -2135,13 +2146,26 @@ mpt_cam_event(struct mpt_softc *mpt, request_t *req,
mpt_lprt(mpt, MPT_PRT_DEBUG,
"mpt_cam_event: MPI_EVENT_EVENT_CHANGE\n");
break;
+ case MPI_EVENT_QUEUE_FULL:
+ {
+ PTR_EVENT_DATA_QUEUE_FULL pqf =
+ (PTR_EVENT_DATA_QUEUE_FULL) msg->Data;
+ mpt_prt(mpt, "QUEUE_FULL: Bus 0x%02x Target 0x%02x Depth %d\n",
+ pqf->Bus, pqf->TargetID, pqf->CurrentDepth);
+ break;
+ }
case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
- /*
- * Devices are attachin'.....
- */
- mpt_prt(mpt,
- "mpt_cam_event: MPI_EVENT_SAS_DEVICE_STATUS_CHANGE\n");
+ {
+ mpt_lprt(mpt, MPT_PRT_DEBUG,
+ "mpt_cam_event: SAS_DEVICE_STATUS_CHANGE\n");
break;
+ }
+ case MPI_EVENT_SAS_SES:
+ {
+ mpt_lprt(mpt, MPT_PRT_DEBUG,
+ "mpt_cam_event: MPI_EVENT_SAS_SES\n");
+ break;
+ }
default:
mpt_lprt(mpt, MPT_PRT_WARN, "mpt_cam_event: 0x%x\n",
msg->Event & 0xFF);
OpenPOWER on IntegriCloud