Keep up with the Joneses: sync with common core target mode code. Eventually

we'll do something with it here.
This commit is contained in:
mjacob 2001-04-05 02:28:17 +00:00
parent 6c28def28f
commit ad454c818c
2 changed files with 67 additions and 50 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: isp_target.c,v 1.12 2001/03/14 05:45:16 mjacob Exp $ */
/* $NetBSD: isp_target.c,v 1.13 2001/04/05 02:28:17 mjacob Exp $ */
/*
* This driver, which is contained in NetBSD in the files:
*
@ -74,14 +74,14 @@
#endif
#ifdef ISP_TARGET_MODE
static char *atiocope =
static const char atiocope[] =
"ATIO returned for lun %d because it was in the middle of Bus Device Reset";
static char *atior =
static const char atior[] =
"ATIO returned for lun %d from initiator %d because a Bus Reset occurred";
static void isp_got_msg __P((struct ispsoftc *, int, in_entry_t *));
static void isp_got_msg_fc __P((struct ispsoftc *, int, in_fcentry_t *));
static void isp_notify_ack __P((struct ispsoftc *, void *));
static void isp_got_msg(struct ispsoftc *, int, in_entry_t *);
static void isp_got_msg_fc(struct ispsoftc *, int, in_fcentry_t *);
static void isp_notify_ack(struct ispsoftc *, void *);
static void isp_handle_atio(struct ispsoftc *, at_entry_t *);
static void isp_handle_atio2(struct ispsoftc *, at2_entry_t *);
static void isp_handle_ctio(struct ispsoftc *, ct_entry_t *);
@ -293,8 +293,8 @@ isp_target_notify(struct ispsoftc *isp, void *vptr, u_int16_t *optrp)
* response entry. The caller is responsible for synchronizing this.
*/
int
isp_lun_cmd(struct ispsoftc *isp, int cmd, int bus, int tgt,
int lun, u_int32_t opaque)
isp_lun_cmd(struct ispsoftc *isp, int cmd, int bus, int tgt, int lun,
u_int32_t opaque)
{
lun_entry_t el;
u_int16_t iptr, optr;
@ -332,6 +332,7 @@ isp_lun_cmd(struct ispsoftc *isp, int cmd, int bus, int tgt,
} else if (isp->isp_maxluns <= 16) {
el.le_lun = lun;
}
el.le_timeout = 2;
if (isp_getrqentry(isp, &iptr, &optr, &outp)) {
isp_prt(isp, ISP_LOGWARN,
@ -383,8 +384,7 @@ isp_target_put_entry(struct ispsoftc *isp, void *ap)
}
int
isp_target_put_atio(struct ispsoftc *isp, int iid, int tgt, int lun, int ttype,
int tval)
isp_target_put_atio(struct ispsoftc *isp, void *arg)
{
union {
at_entry_t _atio;
@ -393,23 +393,27 @@ isp_target_put_atio(struct ispsoftc *isp, int iid, int tgt, int lun, int ttype,
MEMZERO(&atun, sizeof atun);
if (IS_FC(isp)) {
at2_entry_t *aep = arg;
atun._atio2.at_header.rqs_entry_type = RQSTYPE_ATIO2;
atun._atio2.at_header.rqs_entry_count = 1;
if (isp->isp_maxluns > 16) {
atun._atio2.at_scclun = (u_int16_t) lun;
atun._atio2.at_scclun = (u_int16_t) aep->at_scclun;
} else {
atun._atio2.at_lun = (u_int8_t) lun;
atun._atio2.at_lun = (u_int8_t) aep->at_scclun;
}
atun._atio2.at_status = CT_OK;
} else {
at_entry_t *aep = arg;
atun._atio.at_header.rqs_entry_type = RQSTYPE_ATIO;
atun._atio.at_header.rqs_entry_count = 1;
atun._atio.at_iid = iid;
atun._atio.at_tgt = tgt;
atun._atio.at_lun = lun;
atun._atio.at_tag_type = ttype;
atun._atio.at_tag_val = tval;
atun._atio.at_status = CT_OK;
atun._atio.at_handle = aep->at_handle;
atun._atio.at_iid = aep->at_iid;
atun._atio.at_tgt = aep->at_tgt;
atun._atio.at_lun = aep->at_lun;
atun._atio.at_tag_type = aep->at_tag_type;
atun._atio.at_tag_val = aep->at_tag_val;
atun._atio.at_status = (aep->at_flags & AT_TQAE);
atun._atio.at_status |= CT_OK;
}
return (isp_target_put_entry(isp, &atun));
}
@ -425,7 +429,7 @@ isp_target_put_atio(struct ispsoftc *isp, int iid, int tgt, int lun, int ttype,
* values.
*
* NB: the key, asc, ascq, cannot be used for parallel SCSI as it doesn't
* NB: inline SCSI sense reporting.
* NB: inline SCSI sense reporting. As such, we lose this information. XXX.
*
* For both parallel && fibre channel, we use the feature that does
* an automatic resource autoreplenish so we don't have then later do
@ -486,6 +490,9 @@ isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int16_t hdl)
cto->ct_lun = aep->at_lun;
cto->ct_tag_type = aep->at_tag_type;
cto->ct_tag_val = aep->at_tag_val;
if (aep->at_flags & AT_TQAE) {
cto->ct_flags |= CT_TQAE;
}
cto->ct_flags = CT_SENDSTATUS | CT_NO_DATA;
if (hdl == 0) {
cto->ct_flags |= CT_CCINCR;
@ -588,8 +595,8 @@ isp_got_msg(struct ispsoftc *isp, int bus, in_entry_t *inp)
static void
isp_got_msg_fc(struct ispsoftc *isp, int bus, in_fcentry_t *inp)
{
static char *f1 = "%s from iid %d lun %d seq 0x%x";
static char *f2 =
static const char f1[] = "%s from iid %d lun %d seq 0x%x";
static const char f2[] =
"unknown %s 0x%x lun %d iid %d task flags 0x%x seq 0x%x\n";
if (inp->in_status != IN_MSG_RECEIVED) {
@ -776,8 +783,7 @@ isp_handle_atio(struct ispsoftc *isp, at_entry_t *aep)
isp_prt(isp, ISP_LOGERR,
"Unknown ATIO status 0x%x from initiator %d for lun %d",
aep->at_status, aep->at_iid, lun);
(void) isp_target_put_atio(isp, aep->at_iid, aep->at_tgt,
lun, aep->at_tag_type, aep->at_tag_val);
(void) isp_target_put_atio(isp, aep);
break;
}
}
@ -860,7 +866,7 @@ isp_handle_atio2(struct ispsoftc *isp, at2_entry_t *aep)
isp_prt(isp, ISP_LOGERR,
"Unknown ATIO2 status 0x%x from initiator %d for lun %d",
aep->at_status, aep->at_iid, lun);
(void) isp_target_put_atio(isp, aep->at_iid, 0, lun, 0, 0);
(void) isp_target_put_atio(isp, aep);
break;
}
}
@ -877,7 +883,6 @@ isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct)
if (xs == NULL)
pl = ISP_LOGALL;
} else {
pl = ISP_LOGTDEBUG1;
xs = NULL;
}
@ -962,8 +967,13 @@ isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct)
isp_prt(isp, ISP_LOGERR, "Firmware timed out on %s", fmsg);
break;
case CT_PANIC:
if (fmsg == NULL)
fmsg = "Unrecoverable Error";
/*FALLTHROUGH*/
case CT_ERR:
fmsg = "Completed with Error";
if (fmsg == NULL)
fmsg = "Completed with Error";
/*FALLTHROUGH*/
case CT_PHASE_ERROR:
if (fmsg == NULL)
@ -1015,28 +1025,18 @@ isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct)
ct->ct_syshandle, ct->ct_status & ~QLTM_SVALID);
}
} else {
if (ct->ct_flags & CT_SENDSTATUS) {
/*
* Sent status and command complete.
*
* We're now really done with this command, so we
* punt to the platform dependent layers because
* only there can we do the appropriate command
* complete thread synchronization.
*/
isp_prt(isp, pl, "status CTIO complete");
} else {
/*
* Final CTIO completed. Release DMA resources and
* notify platform dependent layers.
*/
isp_prt(isp, pl, "data CTIO complete");
if (ct->ct_flags & CT_DATAMASK) {
ISP_DMAFREE(isp, xs, ct->ct_syshandle);
}
(void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct);
isp_prt(isp, pl, "final CTIO complete");
/*
* The platform layer will destroy the handle if appropriate.
*/
(void) isp_async(isp, ISPASYNC_TARGET_ACTION, ct);
}
}
@ -1052,7 +1052,6 @@ isp_handle_ctio2(struct ispsoftc *isp, ct2_entry_t *ct)
if (xs == NULL)
pl = ISP_LOGALL;
} else {
pl = ISP_LOGTDEBUG1;
xs = NULL;
}
@ -1166,7 +1165,7 @@ isp_handle_ctio2(struct ispsoftc *isp, ct2_entry_t *ct)
break;
default:
isp_prt(isp, ISP_LOGERR, "Unknown CTIO status 0x%x",
isp_prt(isp, ISP_LOGERR, "Unknown CTIO2 status 0x%x",
ct->ct_status & ~QLTM_SVALID);
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: isp_target.h,v 1.11 2001/03/14 05:46:50 mjacob Exp $ */
/* $NetBSD: isp_target.h,v 1.12 2001/04/05 02:28:17 mjacob Exp $ */
/*
* This driver, which is contained in NetBSD in the files:
*
@ -94,7 +94,7 @@ typedef struct {
/*
* le_flags values
*/
#define LUN_TQAE 0x00000001 /* bit1 Tagged Queue Action Enable */
#define LUN_TQAE 0x00000002 /* bit1 Tagged Queue Action Enable */
#define LUN_DSSM 0x01000000 /* bit24 Disable Sending SDP Message */
#define LUN_DISAD 0x02000000 /* bit25 Disable autodisconnect */
#define LUN_DM 0x40000000 /* bit30 Disconnects Mandatory */
@ -259,7 +259,7 @@ typedef struct {
* at_flags values
*/
#define AT_NODISC 0x00008000 /* disconnect disabled */
#define AT_TQAE 0x00000001 /* Tagged Queue Action enabled */
#define AT_TQAE 0x00000002 /* Tagged Queue Action enabled */
/*
* at_status values
@ -271,6 +271,24 @@ typedef struct {
#define AT_BDR_MSG 0x17 /* Bus Device Reset msg received */
#define AT_CDB 0x3D /* CDB received */
/*
* Macros to create and fetch and test concatenated handle and tag value macros
*/
#define AT_MAKE_TAGID(tid, aep) \
tid = ((aep)->at_handle << 16); \
if ((aep)->at_flags & AT_TQAE) \
(tid) |= ((aep)->at_tag_val + 1)
#define CT_MAKE_TAGID(tid, ct) \
tid = ((ct)->ct_fwhandle << 16); \
if ((ct)->ct_flags & CT_TQAE) \
(tid) |= ((ct)->ct_tag_val + 1)
#define AT_HAS_TAG(val) ((val) & 0xffff)
#define AT_GET_TAG(val) AT_HAS_TAG(val) - 1
#define AT_GET_HANDLE(val) ((val) >> 16)
/*
* Accept Target I/O Entry structure, Type 2
*/
@ -349,7 +367,7 @@ typedef struct {
/*
* ct_flags values
*/
#define CT_TQAE 0x00000001 /* bit 1, Tagged Queue Action enable */
#define CT_TQAE 0x00000002 /* bit 1, Tagged Queue Action enable */
#define CT_DATA_IN 0x00000040 /* bits 6&7, Data direction */
#define CT_DATA_OUT 0x00000080 /* bits 6&7, Data direction */
#define CT_NO_DATA 0x000000C0 /* bits 6&7, Data direction */
@ -700,21 +718,21 @@ int isp_lun_cmd(struct ispsoftc *, int, int, int, int, u_int32_t);
/*
* General request queue 'put' routine for target mode entries.
*/
int isp_target_put_entry __P((struct ispsoftc *isp, void *));
int isp_target_put_entry(struct ispsoftc *isp, void *);
/*
* General routine to put back an ATIO entry-
* used for replenishing f/w resource counts.
* The argument is a pointer to a source ATIO
* or ATIO2.
*/
int
isp_target_put_atio(struct ispsoftc *, int, int, int, int, int);
int isp_target_put_atio(struct ispsoftc *, void *);
/*
* General routine to send a final CTIO for a command- used mostly for
* local responses.
*/
int
isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t);
int isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t);
#define ECMD_SVALID 0x100
/*