Enhance debugging mode by storing the string "BB:TT:LL" once and use

it instead of overloading sbp_show_sdev_info().

replace calls to printf with calls to device_printf and cleanup debug
messages

Remove a bit of dead, commented out code.

Reviewed by:	scottl(mentor)
MFC after:	2 weeks
This commit is contained in:
sbruno 2009-02-18 18:41:34 +00:00
parent bcff264488
commit 41356ea1ed

View File

@ -218,6 +218,7 @@ struct sbp_dev{
char vendor[32]; char vendor[32];
char product[32]; char product[32];
char revision[10]; char revision[10];
char bustgtlun[32];
}; };
struct sbp_target { struct sbp_target {
@ -364,36 +365,35 @@ END_DEBUG
return (0); return (0);
} }
/*
* Display device characteristics on the console
*/
static void static void
sbp_show_sdev_info(struct sbp_dev *sdev, int new) sbp_show_sdev_info(struct sbp_dev *sdev)
{ {
struct fw_device *fwdev; struct fw_device *fwdev;
printf("%s:%d:%d ",
device_get_nameunit(sdev->target->sbp->fd.dev),
sdev->target->target_id,
sdev->lun_id
);
if (new == 2) {
return;
}
fwdev = sdev->target->fwdev; fwdev = sdev->target->fwdev;
printf("ordered:%d type:%d EUI:%08x%08x node:%d " device_printf(sdev->target->sbp->fd.dev,
"speed:%d maxrec:%d", "%s: %s: ordered:%d type:%d EUI:%08x%08x node:%d "
"speed:%d maxrec:%d\n",
__func__,
sdev->bustgtlun,
(sdev->type & 0x40) >> 6, (sdev->type & 0x40) >> 6,
(sdev->type & 0x1f), (sdev->type & 0x1f),
fwdev->eui.hi, fwdev->eui.hi,
fwdev->eui.lo, fwdev->eui.lo,
fwdev->dst, fwdev->dst,
fwdev->speed, fwdev->speed,
fwdev->maxrec fwdev->maxrec);
);
if (new) device_printf(sdev->target->sbp->fd.dev,
printf(" new!\n"); "%s: %s '%s' '%s' '%s'\n",
else __func__,
printf("\n"); sdev->bustgtlun,
sbp_show_sdev_info(sdev, 2); sdev->vendor,
printf("'%s' '%s' '%s'\n", sdev->vendor, sdev->product, sdev->revision); sdev->product,
sdev->revision);
} }
static struct { static struct {
@ -549,6 +549,10 @@ END_DEBUG
CALLOUT_INIT(&sdev->login_callout); CALLOUT_INIT(&sdev->login_callout);
sdev->status = SBP_DEV_RESET; sdev->status = SBP_DEV_RESET;
new = 1; new = 1;
snprintf(sdev->bustgtlun, 32, "%s:%d:%d",
device_get_nameunit(sdev->target->sbp->fd.dev),
sdev->target->target_id,
sdev->lun_id);
} }
sdev->flags |= VALID_LUN; sdev->flags |= VALID_LUN;
sdev->type = (reg->val & 0xff0000) >> 16; sdev->type = (reg->val & 0xff0000) >> 16;
@ -717,20 +721,18 @@ static void
sbp_probe_target(void *arg) sbp_probe_target(void *arg)
{ {
struct sbp_target *target = (struct sbp_target *)arg; struct sbp_target *target = (struct sbp_target *)arg;
struct sbp_softc *sbp; struct sbp_softc *sbp = target->sbp;
struct sbp_dev *sdev; struct sbp_dev *sdev;
struct firewire_comm *fc;
int i, alive; int i, alive;
alive = SBP_FWDEV_ALIVE(target->fwdev); alive = SBP_FWDEV_ALIVE(target->fwdev);
SBP_DEBUG(1) SBP_DEBUG(1)
printf("sbp_probe_target %d\n", target->target_id); device_printf(sbp->fd.dev, "%s %d%salive\n",
if (!alive) __func__, target->target_id,
printf("not alive\n"); (!alive) ? " not " : "");
END_DEBUG END_DEBUG
sbp = target->sbp; sbp = target->sbp;
fc = target->sbp->fd.fc;
sbp_alloc_lun(target); sbp_alloc_lun(target);
/* XXX untimeout mgm_ocb and dequeue */ /* XXX untimeout mgm_ocb and dequeue */
@ -746,10 +748,7 @@ END_DEBUG
SBP_UNLOCK(sbp); SBP_UNLOCK(sbp);
} }
sbp_probe_lun(sdev); sbp_probe_lun(sdev);
SBP_DEBUG(0) sbp_show_sdev_info(sdev);
sbp_show_sdev_info(sdev,
(sdev->status == SBP_DEV_RESET));
END_DEBUG
sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET); sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET);
switch (sdev->status) { switch (sdev->status) {
@ -771,8 +770,8 @@ END_DEBUG
case SBP_DEV_ATTACHED: case SBP_DEV_ATTACHED:
SBP_DEBUG(0) SBP_DEBUG(0)
/* the device has gone */ /* the device has gone */
sbp_show_sdev_info(sdev, 2); device_printf(sbp->fd.dev, "%s: lost target\n",
printf("lost target\n"); __func__);
END_DEBUG END_DEBUG
if (sdev->path) { if (sdev->path) {
SBP_LOCK(sbp); SBP_LOCK(sbp);
@ -857,12 +856,10 @@ END_DEBUG
/* traverse device list */ /* traverse device list */
STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) { STAILQ_FOREACH(fwdev, &sbp->fd.fc->devices, link) {
SBP_DEBUG(0) SBP_DEBUG(0)
printf("sbp_post_explore: EUI:%08x%08x ", device_printf(sbp->fd.dev,"%s:: EUI:%08x%08x %s attached, state=%d\n",
fwdev->eui.hi, fwdev->eui.lo); __func__, fwdev->eui.hi, fwdev->eui.lo,
if (fwdev->status != FWDEVATTACHED) (fwdev->status != FWDEVATTACHED) ? "not" : "",
printf("not attached, state=%d.\n", fwdev->status); fwdev->status);
else
printf("attached\n");
END_DEBUG END_DEBUG
alive = SBP_FWDEV_ALIVE(fwdev); alive = SBP_FWDEV_ALIVE(fwdev);
for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){ for(i = 0 ; i < SBP_NUM_TARGETS ; i ++){
@ -899,8 +896,7 @@ sbp_loginres_callback(struct fw_xfer *xfer){
struct sbp_dev *sdev; struct sbp_dev *sdev;
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,"%s\n", __func__);
printf("sbp_loginres_callback\n");
END_DEBUG END_DEBUG
/* recycle */ /* recycle */
s = splfw(); s = splfw();
@ -933,8 +929,8 @@ sbp_reset_start_callback(struct fw_xfer *xfer)
int i; int i;
if (xfer->resp != 0) { if (xfer->resp != 0) {
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_reset_start failed: resp=%d\n", xfer->resp); "%s: %s failed: resp=%d\n", __func__, sdev->bustgtlun, xfer->resp);
} }
for (i = 0; i < target->num_lun; i++) { for (i = 0; i < target->num_lun; i++) {
@ -951,8 +947,8 @@ sbp_reset_start(struct sbp_dev *sdev)
struct fw_pkt *fp; struct fw_pkt *fp;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_reset_start\n"); "%s:%s\n", __func__,sdev->bustgtlun);
END_DEBUG END_DEBUG
xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0); xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0);
@ -973,18 +969,11 @@ sbp_mgm_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_mgm_callback\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
resp = xfer->resp; resp = xfer->resp;
sbp_xfer_free(xfer); sbp_xfer_free(xfer);
#if 0
if (resp != 0) {
sbp_show_sdev_info(sdev, 2);
printf("management ORB failed(%d) ... RESET_START\n", resp);
sbp_reset_start(sdev);
}
#endif
return; return;
} }
@ -1011,14 +1000,14 @@ sbp_cam_scan_lun(struct cam_periph *periph, union ccb *ccb)
sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr; sdev = (struct sbp_dev *) ccb->ccb_h.ccb_sdev_ptr;
target = sdev->target; target = sdev->target;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_cam_scan_lun\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
sdev->status = SBP_DEV_ATTACHED; sdev->status = SBP_DEV_ATTACHED;
} else { } else {
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("scan failed\n"); "%s:%s failed\n", __func__, sdev->bustgtlun);
} }
sdev = sbp_next_dev(target, sdev->lun_id + 1); sdev = sbp_next_dev(target, sdev->lun_id + 1);
if (sdev == NULL) { if (sdev == NULL) {
@ -1047,8 +1036,8 @@ sbp_cam_scan_target(void *arg)
return; return;
} }
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_cam_scan_target\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
ccb = malloc(sizeof(union ccb), M_SBP, M_NOWAIT | M_ZERO); ccb = malloc(sizeof(union ccb), M_SBP, M_NOWAIT | M_ZERO);
if (ccb == NULL) { if (ccb == NULL) {
@ -1089,8 +1078,8 @@ sbp_do_attach(struct fw_xfer *xfer)
target = sdev->target; target = sdev->target;
sbp = target->sbp; sbp = target->sbp;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_do_attach\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
sbp_xfer_free(xfer); sbp_xfer_free(xfer);
@ -1120,12 +1109,12 @@ sbp_agent_reset_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("%s\n", __func__); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
if (xfer->resp != 0) { if (xfer->resp != 0) {
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("%s: resp=%d\n", __func__, xfer->resp); "%s:%s resp=%d\n", __func__, sdev->bustgtlun, xfer->resp);
} }
sbp_xfer_free(xfer); sbp_xfer_free(xfer);
@ -1144,8 +1133,8 @@ sbp_agent_reset(struct sbp_dev *sdev)
struct fw_pkt *fp; struct fw_pkt *fp;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_agent_reset\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x04); xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0x04);
if (xfer == NULL) if (xfer == NULL)
@ -1167,8 +1156,8 @@ sbp_busy_timeout_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_busy_timeout_callback\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
sbp_xfer_free(xfer); sbp_xfer_free(xfer);
sbp_agent_reset(sdev); sbp_agent_reset(sdev);
@ -1180,8 +1169,8 @@ sbp_busy_timeout(struct sbp_dev *sdev)
struct fw_pkt *fp; struct fw_pkt *fp;
struct fw_xfer *xfer; struct fw_xfer *xfer;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_busy_timeout\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0); xfer = sbp_write_cmd(sdev, FWTCODE_WREQQ, 0);
@ -1200,8 +1189,8 @@ sbp_orb_pointer_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(2) SBP_DEBUG(2)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("%s\n", __func__); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
if (xfer->resp != 0) { if (xfer->resp != 0) {
/* XXX */ /* XXX */
@ -1230,8 +1219,10 @@ sbp_orb_pointer(struct sbp_dev *sdev, struct sbp_ocb *ocb)
struct fw_xfer *xfer; struct fw_xfer *xfer;
struct fw_pkt *fp; struct fw_pkt *fp;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("%s: 0x%08x\n", __func__, (uint32_t)ocb->bus_addr); "%s:%s 0x%08x\n",
__func__, sdev->bustgtlun,
(uint32_t)ocb->bus_addr);
END_DEBUG END_DEBUG
mtx_assert(&sdev->target->sbp->mtx, MA_OWNED); mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
@ -1278,12 +1269,13 @@ sbp_doorbell_callback(struct fw_xfer *xfer)
sdev = (struct sbp_dev *)xfer->sc; sdev = (struct sbp_dev *)xfer->sc;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_doorbell_callback\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
if (xfer->resp != 0) { if (xfer->resp != 0) {
/* XXX */ /* XXX */
printf("%s: xfer->resp = %d\n", __func__, xfer->resp); device_printf(sdev->target->sbp->fd.dev,
"%s: xfer->resp = %d\n", __func__, xfer->resp);
} }
sbp_xfer_free(xfer); sbp_xfer_free(xfer);
sdev->flags &= ~ORB_DOORBELL_ACTIVE; sdev->flags &= ~ORB_DOORBELL_ACTIVE;
@ -1302,8 +1294,8 @@ sbp_doorbell(struct sbp_dev *sdev)
struct fw_xfer *xfer; struct fw_xfer *xfer;
struct fw_pkt *fp; struct fw_pkt *fp;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_doorbell\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
if ((sdev->flags & ORB_DOORBELL_ACTIVE) != 0) { if ((sdev->flags & ORB_DOORBELL_ACTIVE) != 0) {
@ -1431,8 +1423,10 @@ sbp_mgm_orb(struct sbp_dev *sdev, int func, struct sbp_ocb *aocb)
ocb->orb[7] = htonl(SBP_DEV2ADDR(target->target_id, sdev->lun_id)); ocb->orb[7] = htonl(SBP_DEV2ADDR(target->target_id, sdev->lun_id));
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("%s\n", orb_fun_name[(func>>16)&0xf]); "%s:%s %s\n",
__func__,sdev->bustgtlun,
orb_fun_name[(func>>16)&0xf]);
END_DEBUG END_DEBUG
switch (func) { switch (func) {
case ORB_FUN_LGI: case ORB_FUN_LGI:
@ -1485,10 +1479,6 @@ END_DEBUG
fp->mode.wreqb.extcode = 0; fp->mode.wreqb.extcode = 0;
xfer->send.payload[0] = htonl(nid << 16); xfer->send.payload[0] = htonl(nid << 16);
xfer->send.payload[1] = htonl(ocb->bus_addr & 0xffffffff); xfer->send.payload[1] = htonl(ocb->bus_addr & 0xffffffff);
SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2);
printf("mgm orb: %08x\n", (uint32_t)ocb->bus_addr);
END_DEBUG
fw_asyreq(xfer->fc, -1, xfer); fw_asyreq(xfer->fc, -1, xfer);
} }
@ -1532,16 +1522,15 @@ sbp_scsi_status(struct sbp_status *sbp_status, struct sbp_ocb *ocb)
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_print_scsi_cmd(ocb); sbp_print_scsi_cmd(ocb);
/* XXX need decode status */ /* XXX need decode status */
sbp_show_sdev_info(ocb->sdev, 2); printf("%s: SCSI status %x sfmt %x valid %x key %x code %x qlfr %x len %d\n",
printf("SCSI status %x sfmt %x valid %x key %x code %x qlfr %x len %d\n", ocb->sdev->bustgtlun,
sbp_cmd_status->status, sbp_cmd_status->status,
sbp_cmd_status->sfmt, sbp_cmd_status->sfmt,
sbp_cmd_status->valid, sbp_cmd_status->valid,
sbp_cmd_status->s_key, sbp_cmd_status->s_key,
sbp_cmd_status->s_code, sbp_cmd_status->s_code,
sbp_cmd_status->s_qlfr, sbp_cmd_status->s_qlfr,
sbp_status->len sbp_status->len);
);
END_DEBUG END_DEBUG
switch (sbp_cmd_status->status) { switch (sbp_cmd_status->status) {
@ -1601,9 +1590,10 @@ END_DEBUG
*/ */
break; break;
default: default:
sbp_show_sdev_info(ocb->sdev, 2); device_printf(ocb->sdev->target->sbp->fd.dev,
printf("sbp_scsi_status: unknown scsi status 0x%x\n", "%s:%s unknown scsi status 0x%x\n",
sbp_cmd_status->status); __func__, ocb->sdev->bustgtlun,
sbp_cmd_status->status);
} }
} }
@ -1620,8 +1610,8 @@ sbp_fix_inq_data(struct sbp_ocb *ocb)
if (ccb->csio.cdb_io.cdb_bytes[1] & SI_EVPD) if (ccb->csio.cdb_io.cdb_bytes[1] & SI_EVPD)
return; return;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("sbp_fix_inq_data\n"); "%s:%s\n", __func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
inq = (struct scsi_inquiry_data *) ccb->csio.data_ptr; inq = (struct scsi_inquiry_data *) ccb->csio.data_ptr;
switch (SID_TYPE(inq)) { switch (SID_TYPE(inq)) {
@ -1730,23 +1720,26 @@ END_DEBUG
} }
ocb = sbp_dequeue_ocb(sdev, sbp_status); ocb = sbp_dequeue_ocb(sdev, sbp_status);
if (ocb == NULL) { if (ocb == NULL) {
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000 #if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("No ocb(%lx) on the queue\n", "%s:%s No ocb(%lx) on the queue\n",
#else #else
printf("No ocb(%x) on the queue\n", "%s:%s No ocb(%x) on the queue\n",
#endif #endif
ntohl(sbp_status->orb_lo)); __func__,sdev->bustgtlun,
ntohl(sbp_status->orb_lo));
} }
break; break;
case 2: case 2:
/* unsolicit */ /* unsolicit */
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("unsolicit status received\n"); "%s:%s unsolicit status received\n",
__func__, sdev->bustgtlun);
break; break;
default: default:
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("unknown sbp_status->src\n"); "%s:%s unknown sbp_status->src\n",
__func__, sdev->bustgtlun);
} }
status_valid0 = (sbp_status->src < 2 status_valid0 = (sbp_status->src < 2
@ -1757,18 +1750,20 @@ END_DEBUG
if (!status_valid0 || debug > 2){ if (!status_valid0 || debug > 2){
int status; int status;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("ORB status src:%x resp:%x dead:%x" "%s:%s ORB status src:%x resp:%x dead:%x"
#if defined(__DragonFly__) || __FreeBSD_version < 500000 #if defined(__DragonFly__) || __FreeBSD_version < 500000
" len:%x stat:%x orb:%x%08lx\n", " len:%x stat:%x orb:%x%08lx\n",
#else #else
" len:%x stat:%x orb:%x%08x\n", " len:%x stat:%x orb:%x%08x\n",
#endif #endif
__func__, sdev->bustgtlun,
sbp_status->src, sbp_status->resp, sbp_status->dead, sbp_status->src, sbp_status->resp, sbp_status->dead,
sbp_status->len, sbp_status->status, sbp_status->len, sbp_status->status,
ntohs(sbp_status->orb_hi), ntohl(sbp_status->orb_lo)); ntohs(sbp_status->orb_hi), ntohl(sbp_status->orb_lo));
END_DEBUG END_DEBUG
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
"%s\n", sdev->bustgtlun);
status = sbp_status->status; status = sbp_status->status;
switch(sbp_status->resp) { switch(sbp_status->resp) {
case 0: case 0:
@ -1827,14 +1822,19 @@ END_DEBUG
login_res->cmd_lo = ntohl(login_res->cmd_lo); login_res->cmd_lo = ntohl(login_res->cmd_lo);
if (status_valid) { if (status_valid) {
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("login: len %d, ID %d, cmd %08x%08x, recon_hold %d\n", login_res->len, login_res->id, login_res->cmd_hi, login_res->cmd_lo, ntohs(login_res->recon_hold)); "%s:%s login: len %d, ID %d, cmd %08x%08x, recon_hold %d\n",
__func__, sdev->bustgtlun,
login_res->len, login_res->id,
login_res->cmd_hi, login_res->cmd_lo,
ntohs(login_res->recon_hold));
END_DEBUG END_DEBUG
sbp_busy_timeout(sdev); sbp_busy_timeout(sdev);
} else { } else {
/* forgot logout? */ /* forgot logout? */
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("login failed\n"); "%s:%s login failed\n",
__func__, sdev->bustgtlun);
sdev->status = SBP_DEV_RESET; sdev->status = SBP_DEV_RESET;
} }
break; break;
@ -1842,23 +1842,22 @@ END_DEBUG
login_res = sdev->login; login_res = sdev->login;
if (status_valid) { if (status_valid) {
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("reconnect: len %d, ID %d, cmd %08x%08x\n", login_res->len, login_res->id, login_res->cmd_hi, login_res->cmd_lo); "%s:%s reconnect: len %d, ID %d, cmd %08x%08x\n",
__func__, sdev->bustgtlun,
login_res->len, login_res->id,
login_res->cmd_hi, login_res->cmd_lo);
END_DEBUG END_DEBUG
#if 1
if (sdev->status == SBP_DEV_ATTACHED) if (sdev->status == SBP_DEV_ATTACHED)
sbp_scan_dev(sdev); sbp_scan_dev(sdev);
else else
sbp_agent_reset(sdev); sbp_agent_reset(sdev);
#else
sdev->status = SBP_DEV_ATTACHED;
sbp_mgm_orb(sdev, ORB_FUN_ATS, NULL);
#endif
} else { } else {
/* reconnection hold time exceed? */ /* reconnection hold time exceed? */
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("reconnect failed\n"); "%s:%s reconnect failed\n",
__func__, sdev->bustgtlun);
END_DEBUG END_DEBUG
sbp_login(sdev); sbp_login(sdev);
} }
@ -1875,8 +1874,9 @@ END_DEBUG
sbp_agent_reset(sdev); sbp_agent_reset(sdev);
break; break;
default: default:
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("unknown function %d\n", orb_fun); "%s:%s unknown function %d\n",
__func__, sdev->bustgtlun, orb_fun);
break; break;
} }
sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL); sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL);
@ -1885,15 +1885,7 @@ END_DEBUG
sdev->timeout = 0; sdev->timeout = 0;
if(ocb->ccb != NULL){ if(ocb->ccb != NULL){
union ccb *ccb; union ccb *ccb;
/*
uint32_t *ld;
ld = ocb->ccb->csio.data_ptr;
if(ld != NULL && ocb->ccb->csio.dxfer_len != 0)
printf("ptr %08x %08x %08x %08x\n", ld[0], ld[1], ld[2], ld[3]);
else
printf("ptr NULL\n");
printf("len %d\n", sbp_status->len);
*/
ccb = ocb->ccb; ccb = ocb->ccb;
if(sbp_status->len > 1){ if(sbp_status->len > 1){
sbp_scsi_status(sbp_status, ocb); sbp_scsi_status(sbp_status, ocb);
@ -2279,9 +2271,9 @@ sbp_mgm_timeout(void *arg)
struct sbp_dev *sdev = ocb->sdev; struct sbp_dev *sdev = ocb->sdev;
struct sbp_target *target = sdev->target; struct sbp_target *target = sdev->target;
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("request timeout(mgm orb:0x%08x) ... ", "%s:%s request timeout(mgm orb:0x%08x)\n",
(uint32_t)ocb->bus_addr); __func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
target->mgm_ocb_cur = NULL; target->mgm_ocb_cur = NULL;
sbp_free_ocb(sdev, ocb); sbp_free_ocb(sdev, ocb);
#if 0 #if 0
@ -2289,10 +2281,10 @@ sbp_mgm_timeout(void *arg)
printf("run next request\n"); printf("run next request\n");
sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL); sbp_mgm_orb(sdev, ORB_FUN_RUNQUEUE, NULL);
#endif #endif
#if 1 device_printf(sdev->target->sbp->fd.dev,
printf("reset start\n"); "%s:%s reset start\n",
__func__, sdev->bustgtlun);
sbp_reset_start(sdev); sbp_reset_start(sdev);
#endif
} }
static void static void
@ -2301,9 +2293,9 @@ sbp_timeout(void *arg)
struct sbp_ocb *ocb = (struct sbp_ocb *)arg; struct sbp_ocb *ocb = (struct sbp_ocb *)arg;
struct sbp_dev *sdev = ocb->sdev; struct sbp_dev *sdev = ocb->sdev;
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("request timeout(cmd orb:0x%08x) ... ", "%s:%s request timeout(cmd orb:0x%08x) ... ",
(uint32_t)ocb->bus_addr); __func__, sdev->bustgtlun, (uint32_t)ocb->bus_addr);
sdev->timeout ++; sdev->timeout ++;
switch(sdev->timeout) { switch(sdev->timeout) {
@ -2760,13 +2752,13 @@ sbp_dequeue_ocb(struct sbp_dev *sdev, struct sbp_status *sbp_status)
int flags; int flags;
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000 #if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("%s: 0x%08lx src %d\n", "%s:%s 0x%08lx src %d\n",
#else #else
printf("%s: 0x%08x src %d\n", "%s:%s 0x%08x src %d\n",
#endif #endif
__func__, ntohl(sbp_status->orb_lo), sbp_status->src); __func__, sdev->bustgtlun, ntohl(sbp_status->orb_lo), sbp_status->src);
END_DEBUG END_DEBUG
SBP_LOCK(sdev->target->sbp); SBP_LOCK(sdev->target->sbp);
for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) { for (ocb = STAILQ_FIRST(&sdev->ocbs); ocb != NULL; ocb = next) {
@ -2823,8 +2815,9 @@ END_DEBUG
splx(s); splx(s);
SBP_DEBUG(0) SBP_DEBUG(0)
if (ocb && order > 0) { if (ocb && order > 0) {
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
printf("unordered execution order:%d\n", order); "%s:%s unordered execution order:%d\n",
__func__, sdev->bustgtlun, order);
} }
END_DEBUG END_DEBUG
return (ocb); return (ocb);
@ -2838,11 +2831,11 @@ sbp_enqueue_ocb(struct sbp_dev *sdev, struct sbp_ocb *ocb)
mtx_assert(&sdev->target->sbp->mtx, MA_OWNED); mtx_assert(&sdev->target->sbp->mtx, MA_OWNED);
SBP_DEBUG(1) SBP_DEBUG(1)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000 #if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("%s: 0x%08x\n", __func__, ocb->bus_addr); "%s:%s 0x%08x\n", __func__, sdev->bustgtlun, ocb->bus_addr);
#else #else
printf("%s: 0x%08jx\n", __func__, (uintmax_t)ocb->bus_addr); "%s:%s 0x%08jx\n", __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr);
#endif #endif
END_DEBUG END_DEBUG
prev2 = prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb); prev2 = prev = STAILQ_LAST(&sdev->ocbs, sbp_ocb, ocb);
@ -2924,11 +2917,11 @@ sbp_abort_ocb(struct sbp_ocb *ocb, int status)
sdev = ocb->sdev; sdev = ocb->sdev;
SBP_DEBUG(0) SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2); device_printf(sdev->target->sbp->fd.dev,
#if defined(__DragonFly__) || __FreeBSD_version < 500000 #if defined(__DragonFly__) || __FreeBSD_version < 500000
printf("sbp_abort_ocb 0x%x\n", ocb->bus_addr); "%s:%s 0x%x\n", __func__, sdev->bustgtlun, ocb->bus_addr);
#else #else
printf("sbp_abort_ocb 0x%jx\n", (uintmax_t)ocb->bus_addr); "%s:%s 0x%jx\n", __func__, sdev->bustgtlun, (uintmax_t)ocb->bus_addr);
#endif #endif
END_DEBUG END_DEBUG
SBP_DEBUG(1) SBP_DEBUG(1)