Make ISPCTL_PLOGX find a handle to log into the management server

with- not hope for the best. Change some things which were gated
off of 24XX to be gated off of 2K login support. Convert some
isp_prt calls to xpt_print calls.
This commit is contained in:
mjacob 2006-12-05 07:50:23 +00:00
parent 126f5f8f47
commit 644694d746
3 changed files with 88 additions and 75 deletions

View File

@ -3195,6 +3195,10 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp)
isp_put_ct_hdr(isp, ct, (ct_hdr_t *) &scp[XTXOFF]);
rp = (uint32_t *) &scp[XTXOFF+sizeof (*ct)];
ISP_IOZPUT_32(isp, FC4_SCSI, rp);
if (isp->isp_dblev & ISP_LOGDEBUG1) {
isp_print_bytes(isp, "CT HDR + payload after put",
sizeof (*ct) + sizeof (uint32_t), &scp[XTXOFF]);
}
MEMZERO(&scp[ZTXOFF], QENTRY_LEN);
MEMZERO(&mbs, sizeof (mbs));
mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64;
@ -3222,6 +3226,9 @@ isp_gid_ft_ct_passthru(ispsoftc_t *isp)
return (-1);
}
MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN + 16);
if (isp->isp_dblev & ISP_LOGDEBUG1) {
isp_print_bytes(isp, "CT response", GIDLEN+16, &scp[IGPOFF]);
}
return (0);
}
@ -3301,7 +3308,7 @@ isp_scan_fabric(ispsoftc_t *isp)
/*
* Prime the handle we will start using.
*/
oldhandle = 0xffff;
oldhandle = NIL_HANDLE;
/*
* Okay, we now have a list of Port IDs for all FC4 SCSI devices
@ -3698,8 +3705,8 @@ isp_login_device(ispsoftc_t *isp, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
int lim, i, r;
uint16_t handle;
if (IS_24XX(isp)) {
lim = NPH_MAX_24XX;
if (FCPARAM(isp)->isp_2klogin) {
lim = NPH_MAX_2K;
} else {
lim = NPH_MAX;
}
@ -3713,7 +3720,7 @@ isp_login_device(ispsoftc_t *isp, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
*/
r = isp_getpdb(isp, handle, p, 0);
if (r == 0 && p->portid != portid) {
(void) isp_plogx(isp, handle,portid,
(void) isp_plogx(isp, handle, portid,
PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT, 1);
} else if (r == 0) {
break;
@ -3919,7 +3926,7 @@ isp_register_fc4_type_24xx(ispsoftc_t *isp)
static uint16_t
isp_nxt_handle(ispsoftc_t *isp, uint16_t handle)
{
if (handle == 0xffff) {
if (handle == NIL_HANDLE) {
if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) {
handle = 0;
} else {
@ -3927,17 +3934,18 @@ isp_nxt_handle(ispsoftc_t *isp, uint16_t handle)
}
} else {
handle += 1;
if (handle == NPH_MGT_ID) {
handle++;
}
if (handle >= FL_ID && handle <= SNS_ID) {
handle = SNS_ID+1;
} else if (IS_24XX(isp)) {
if (handle == 0xffff) {
}
if (handle >= NPH_RESERVED && handle <= NPH_FL_ID) {
handle = NPH_FL_ID+1;
}
if (FCPARAM(isp)->isp_2klogin) {
if (handle == NPH_MAX_2K) {
handle = 0;
}
} else {
if (handle == MAX_FC_TARG) {
if (handle == NPH_MAX) {
handle = 0;
}
}
@ -4427,7 +4435,23 @@ isp_control(ispsoftc_t *isp, ispctl_t ctl, void *arg)
case ISPCTL_PLOGX:
{
isp_plcmd_t *p = arg;
return (isp_plogx(isp, p->handle, p->portid, p->flags, 0));
int r;
if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI ||
(p->handle != NIL_HANDLE)) {
return (isp_plogx(isp, p->handle, p->portid,
p->flags, 0));
}
do {
p->handle = isp_nxt_handle(isp, p->handle);
r = isp_plogx(isp, p->handle, p->portid, p->flags, 0);
if ((r & 0xffff) == MBOX_PORT_ID_USED) {
p->handle = r >> 16;
r = 0;
break;
}
} while ((r & 0xffff) == MBOX_LOOP_ID_USED);
return (r);
}
#ifdef ISP_TARGET_MODE
case ISPCTL_TOGGLE_TMODE:

View File

@ -897,18 +897,17 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
bus = XS_CHANNEL(ccb);
if (bus > 1) {
xpt_print_path(ccb->ccb_h.path);
printf("illegal bus %d\n", bus);
xpt_print(ccb->ccb_h.path, "illegal bus %d\n", bus);
ccb->ccb_h.status = CAM_PATH_INVALID;
return (-1);
}
tgt = ccb->ccb_h.target_id;
lun = ccb->ccb_h.target_lun;
isp_prt(isp, ISP_LOGTDEBUG0,
"isp_en_lun: %sabling lun 0x%x on channel %d",
cel->enable? "en" : "dis", lun, bus);
if (isp->isp_dblev & ISP_LOGTDEBUG0) {
xpt_print(ccb->ccb_h.path, "%sabling lun 0x%x on channel %d\n",
cel->enable? "en" : "dis", lun, bus);
}
if ((lun != CAM_LUN_WILDCARD) &&
(lun < 0 || lun >= (lun_id_t) isp->isp_maxluns)) {
@ -940,17 +939,18 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
* This is as a good a place as any to check f/w capabilities.
*/
if (FCPARAM(isp)->isp_tmode == 0) {
isp_prt(isp, ISP_LOGERR,
"firmware does not support target mode");
xpt_print(ccb->ccb_h.path,
"firmware does not support target mode\n");
ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
return (-1);
}
/*
* XXX: We *could* handle non-SCCLUN f/w, but we'd have to
* XXX: dorks with our already fragile enable/disable code.
* XXX: dork with our already fragile enable/disable code.
*/
if (FCPARAM(isp)->isp_sccfw == 0) {
isp_prt(isp, ISP_LOGERR, "firmware not SCCLUN capable");
xpt_print(ccb->ccb_h.path,
"firmware not SCCLUN capable\n");
ccb->ccb_h.status = CAM_FUNC_NOTAVAIL;
return (-1);
}
@ -1027,8 +1027,7 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
return (-1);
}
isp->isp_osinfo.tmflags[bus] |= TM_TMODE_ENABLED;
isp_prt(isp, ISP_LOGINFO,
"Target Mode enabled on channel %d", bus);
xpt_print(ccb->ccb_h.path, "Target Mode Enabled\n");
} else if (cel->enable == 0 && tm_on && wildcard) {
if (are_any_luns_enabled(isp, bus)) {
ccb->ccb_h.status = CAM_SCSI_BUSY;
@ -1040,8 +1039,7 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
return (-1);
}
isp->isp_osinfo.tmflags[bus] &= ~TM_TMODE_ENABLED;
isp_prt(isp, ISP_LOGINFO,
"Target Mode disabled on channel %d", bus);
xpt_print(ccb->ccb_h.path, "Target Mode Disabled\n");
}
if (wildcard) {
@ -1120,8 +1118,7 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
}
}
rls_lun_statep(isp, tptr);
xpt_print_path(ccb->ccb_h.path);
printf("isp_lun_cmd failed\n");
xpt_print(ccb->ccb_h.path, "isp_lun_cmd failed\n");
isp->isp_osinfo.leact[seq] = 0;
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
return (-1);
@ -1130,7 +1127,7 @@ isp_en_lun(ispsoftc_t *isp, union ccb *ccb)
static void
isp_ledone(ispsoftc_t *isp, lun_entry_t *lep)
{
const char lfmt[] = "lun %d now %sabled for target mode on channel %d";
const char lfmt[] = "now %sabled for target mode";
union ccb *ccb;
uint32_t seq;
tstate_t *tptr;
@ -1152,18 +1149,16 @@ isp_ledone(ispsoftc_t *isp, lun_entry_t *lep)
cel = &ccb->cel;
tptr = get_lun_statep(isp, XS_CHANNEL(ccb), XS_LUN(ccb));
if (tptr == NULL) {
xpt_print_path(ccb->ccb_h.path);
printf("null tptr in isp_ledone\n");
xpt_print(ccb->ccb_h.path, "null tptr in isp_ledone\n");
isp->isp_osinfo.leact[seq] = 0;
return;
}
if (lep->le_status != LUN_OK) {
xpt_print_path(ccb->ccb_h.path);
printf("ENABLE/MODIFY LUN returned 0x%x\n", lep->le_status);
xpt_print(ccb->ccb_h.path,
"ENABLE/MODIFY LUN returned 0x%x\n", lep->le_status);
err:
ccb->ccb_h.status = CAM_REQ_CMP_ERR;
xpt_print_path(ccb->ccb_h.path);
rls_lun_statep(isp, tptr);
isp->isp_osinfo.leact[seq] = 0;
ISPLOCK_2_CAMLOCK(isp);
@ -1178,8 +1173,7 @@ err:
if (cel->enable) {
ccb->ccb_h.status = CAM_REQ_CMP;
isp_prt(isp, ISP_LOGINFO, lfmt,
XS_LUN(ccb), "en", XS_CHANNEL(ccb));
xpt_print(ccb->ccb_h.path, lfmt, "en");
rls_lun_statep(isp, tptr);
isp->isp_osinfo.leact[seq] = 0;
ISPLOCK_2_CAMLOCK(isp);
@ -1191,15 +1185,15 @@ err:
if (lep->le_header.rqs_entry_type == RQSTYPE_MODIFY_LUN) {
if (isp_lun_cmd(isp, -RQSTYPE_ENABLE_LUN, XS_CHANNEL(ccb),
XS_TGT(ccb), XS_LUN(ccb), 0, 0, seq+1)) {
xpt_print_path(ccb->ccb_h.path);
printf("isp_ledone: isp_lun_cmd failed\n");
xpt_print(ccb->ccb_h.path,
"isp_ledone: isp_lun_cmd failed\n");
goto err;
}
rls_lun_statep(isp, tptr);
return;
}
isp_prt(isp, ISP_LOGINFO, lfmt, XS_LUN(ccb), "dis", XS_CHANNEL(ccb));
xpt_print(ccb->ccb_h.path, lfmt, "dis");
rls_lun_statep(isp, tptr);
destroy_lun_state(isp, tptr);
ccb->ccb_h.status = CAM_REQ_CMP;
@ -1214,9 +1208,6 @@ err:
if (av) {
isp_prt(isp, ISP_LOGWARN,
"disable target mode on channel %d failed", bus);
} else {
isp_prt(isp, ISP_LOGINFO,
"Target Mode disabled on channel %d", bus);
}
isp->isp_osinfo.tmflags[bus] &= ~TM_TMODE_ENABLED;
}
@ -1232,7 +1223,7 @@ isp_abort_tgt_ccb(ispsoftc_t *isp, union ccb *ccb)
int found, *ctr;
union ccb *accb = ccb->cab.abort_ccb;
isp_prt(isp, ISP_LOGTDEBUG0, "aborting ccb %p", accb);
xpt_print(ccb->ccb_h.path, "aborting ccb %p\n", accb);
if (accb->ccb_h.target_id != CAM_TARGET_WILDCARD) {
int badpath = 0;
if (IS_FC(isp) && (accb->ccb_h.target_id !=
@ -1255,8 +1246,7 @@ isp_abort_tgt_ccb(ispsoftc_t *isp, union ccb *ccb)
}
tptr = get_lun_statep(isp, XS_CHANNEL(ccb), accb->ccb_h.target_lun);
if (tptr == NULL) {
isp_prt(isp, ISP_LOGTDEBUG0,
"isp_abort_tgt_ccb: can't get statep");
xpt_print(ccb->ccb_h.path, "can't get statep\n");
return (CAM_PATH_INVALID);
}
if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) {
@ -1267,8 +1257,8 @@ isp_abort_tgt_ccb(ispsoftc_t *isp, union ccb *ccb)
ctr = &tptr->inot_count;
} else {
rls_lun_statep(isp, tptr);
isp_prt(isp, ISP_LOGTDEBUG0,
"isp_abort_tgt_ccb: bad func %d\n", accb->ccb_h.func_code);
xpt_print(ccb->ccb_h.path, "bad function code %d\n",
accb->ccb_h.func_code);
return (CAM_UA_ABORT);
}
curelm = SLIST_FIRST(lp);
@ -1297,8 +1287,7 @@ isp_abort_tgt_ccb(ispsoftc_t *isp, union ccb *ccb)
xpt_done(accb);
return (CAM_REQ_CMP);
}
isp_prt(isp, ISP_LOGTDEBUG0,
"isp_abort_tgt_ccb: CCB %p not found\n", ccb);
xpt_print(ccb->ccb_h.path, "ccb %p not found\n", accb);
return (CAM_PATH_INVALID);
}
@ -1312,8 +1301,8 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb)
if (isp_getrqentry(isp, &nxti, &optr, &qe)) {
xpt_print_path(ccb->ccb_h.path);
printf("Request Queue Overflow in isp_target_start_ctio\n");
xpt_print(ccb->ccb_h.path,
"Request Queue Overflow in isp_target_start_ctio\n");
XS_SETERR(ccb, CAM_REQUEUE_REQ);
goto out;
}
@ -1340,8 +1329,8 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb)
atp = isp_get_atpd(isp, cso->tag_id);
if (atp == NULL) {
isp_prt(isp, ISP_LOGERR,
"cannot find private data adjunct for tag %x",
xpt_print(ccb->ccb_h.path,
"cannot find private data adjunct for tag %x\n",
cso->tag_id);
XS_SETERR(ccb, CAM_REQ_CMP_ERR);
goto out;
@ -1450,8 +1439,8 @@ isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb)
}
if (isp_save_xs_tgt(isp, ccb, &handle)) {
xpt_print_path(ccb->ccb_h.path);
printf("No XFLIST pointers for isp_target_start_ctio\n");
xpt_print(ccb->ccb_h.path,
"No XFLIST pointers for isp_target_start_ctio\n");
XS_SETERR(ccb, CAM_REQUEUE_REQ);
goto out;
}
@ -1514,9 +1503,9 @@ isp_target_putback_atio(union ccb *ccb)
isp = XS_ISP(ccb);
if (isp_getrqentry(isp, &nxti, &optr, &qe)) {
xpt_print(ccb->ccb_h.path,
"isp_target_putback_atio: Request Queue Overflow\n");
(void) timeout(isp_refire_putback_atio, ccb, 10);
isp_prt(isp, ISP_LOGWARN,
"isp_target_putback_atio: Request Queue Overflow");
return;
}
memset(qe, 0, QENTRY_LEN);
@ -1637,9 +1626,8 @@ isp_handle_platform_atio(ispsoftc_t *isp, at_entry_t *aep)
* should, in fact, get this, is in the case that we've
* run out of ATIOS.
*/
xpt_print_path(tptr->owner);
isp_prt(isp, ISP_LOGWARN,
"no ATIOS for lun %d from initiator %d on channel %d",
xpt_print(tptr->owner,
"no ATIOS for lun %d from initiator %d on channel %d\n",
aep->at_lun, GET_IID_VAL(aep->at_iid), bus);
if (aep->at_flags & AT_TQAE)
isp_endcmd(isp, aep, SCSI_STATUS_QUEUE_FULL, 0);
@ -1745,9 +1733,8 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
* should, in fact, get this, is in the case that we've
* run out of ATIOS.
*/
xpt_print_path(tptr->owner);
isp_prt(isp, ISP_LOGWARN,
"no %s for lun %d from initiator %d",
xpt_print(tptr->owner,
"no %s for lun %d from initiator %d\n",
(atp == NULL && atiop == NULL)? "ATIO2s *or* ATPS" :
((atp == NULL)? "ATPs" : "ATIO2s"), lun, aep->at_iid);
rls_lun_statep(isp, tptr);
@ -2100,9 +2087,8 @@ isp_watchdog_work(ispsoftc_t *isp, XS_T *xs)
ISP_DMAFREE(isp, xs, handle);
}
isp_destroy_handle(isp, handle);
xpt_print_path(xs->ccb_h.path);
isp_prt(isp, ISP_LOGWARN,
"watchdog timeout for handle 0x%x", handle);
xpt_print(xs->ccb_h.path,
"watchdog timeout for handle 0x%x\n", handle);
XS_SETERR(xs, CAM_CMD_TIMEOUT);
XS_CMD_C_WDOG(xs);
ISPLOCK_2_CAMLOCK(isp);
@ -2459,14 +2445,13 @@ isp_action(struct cam_sim *sim, union ccb *ccb)
}
#ifdef DIAGNOSTIC
if (ccb->ccb_h.target_id > (ISP_MAX_TARGETS(isp) - 1)) {
xpt_print(ccb->ccb_h.path, "invalid target\n");
ccb->ccb_h.status = CAM_PATH_INVALID;
} else if (ccb->ccb_h.target_lun > (ISP_MAX_LUNS(isp) - 1)) {
xpt_print(ccb->ccb_h.path, "invalid lun\n");
ccb->ccb_h.status = CAM_PATH_INVALID;
}
if (ccb->ccb_h.status == CAM_PATH_INVALID) {
isp_prt(isp, ISP_LOGERR,
"invalid tgt/lun (%d.%d) in XPT_SCSI_IO",
ccb->ccb_h.target_id, ccb->ccb_h.target_lun);
xpt_done(ccb);
break;
}
@ -3002,9 +2987,8 @@ isp_done(struct ccb_scsiio *sccb)
if ((CAM_DEBUGGED(sccb->ccb_h.path, ISPDDB)) &&
(sccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
xpt_print_path(sccb->ccb_h.path);
isp_prt(isp, ISP_LOGINFO,
"cam completion status 0x%x", sccb->ccb_h.status);
xpt_print(sccb->ccb_h.path,
"cam completion status 0x%x\n", sccb->ccb_h.status);
}
XS_CMD_S_DONE(sccb);

View File

@ -228,17 +228,22 @@ typedef struct {
/*
* Fibre Channel Specifics
*/
/* These are for 2100/2200/2300 cards */
/* These are for non-2K Login Firmware cards */
#define FL_ID 0x7e /* FL_Port Special ID */
#define SNS_ID 0x80 /* SNS Server Special ID */
#define NPH_MAX 0xfe
/* These are for 24XX cards */
/* These are for 2K Login Firmware cards */
#define NPH_RESERVED 0x7F0 /* begin of reserved N-port handles */
#define NPH_MGT_ID 0x7FA /* Management Server Special ID */
#define NPH_SNS_ID 0x7FC /* SNS Server Special ID */
#define NPH_FL_ID 0x7FE /* FL Port Special ID */
#define NPH_MAX_24XX 0x800
#define NPH_MAX_2K 0x800
/*
* "Unassigned" handle to be used internally
*/
#define NIL_HANDLE 0xffff
/*
* Limit for devices on an arbitrated loop.