Clean up and update copyright (remove advertising clause). Clean

up header guard.  Clean up structure definition for at2_entry so
it's correct rather than derived from at_entry- this is important
for unswizzling purposes. Add a whole bunch of unswizzle macros-
they're not quite right yet but at least they're a start. Note that
we now have, for at_entry, a 16 bit firmware handle as part of what
had been at_reserved- this is to correlate ATIOs with CTIOs- and
this must be carried along as part of a tag value to use with all
CTIOs we send in relation to this ATIO. ANSIfy.
This commit is contained in:
mjacob 2001-03-14 05:46:50 +00:00
parent 98381c7a2d
commit c67c3d855d

View File

@ -1,4 +1,4 @@
/* $NetBSD: isp_target.h,v 1.10 2000/12/28 08:23:48 mjacob Exp $ */
/* $NetBSD: isp_target.h,v 1.11 2001/03/14 05:46:50 mjacob Exp $ */
/*
* This driver, which is contained in NetBSD in the files:
*
@ -35,7 +35,7 @@
* pms@psconsult.com
* All rights reserved.
*
* Additional Copyright (c) 1999
* Additional Copyright (c) 1999, 2000, 2001
* Matthew Jacob
* mjacob@feral.com
* All rights reserved.
@ -47,10 +47,7 @@
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* 2. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
@ -64,8 +61,8 @@
* SUCH DAMAGE.
*
*/
#ifndef _ISPTARGET_H
#define _ISPTARGET_H
#ifndef _ISP_TARGET_H
#define _ISP_TARGET_H
/*
* Defines for all entry types
@ -243,7 +240,8 @@ typedef struct {
typedef struct {
isphdr_t at_header;
u_int32_t at_reserved;
u_int16_t at_reserved;
u_int16_t at_handle;
u_int8_t at_lun; /* lun */
u_int8_t at_iid; /* initiator */
u_int8_t at_cdblen; /* cdb length */
@ -293,9 +291,8 @@ typedef struct {
u_int8_t at_cdb[ATIO2_CDBLEN]; /* received CDB */
u_int32_t at_datalen; /* allocated data len */
u_int16_t at_scclun; /* SCC Lun or reserved */
u_int16_t at_reserved2;
u_int16_t at_scsi_status;
u_int8_t at_sense[QLTM_SENSELEN];
u_int16_t at_reserved2[10];
u_int16_t at_oxid;
} at2_entry_t;
#define ATIO2_WWPN_OFFSET 0x2A
@ -317,7 +314,9 @@ typedef struct {
*/
typedef struct {
isphdr_t ct_header;
u_int32_t ct_reserved;
u_int16_t ct_reserved;
#define ct_syshandle ct_reserved /* we use this */
u_int16_t ct_fwhandle; /* required by f/w */
u_int8_t ct_lun; /* lun */
u_int8_t ct_iid; /* initiator id */
u_int8_t ct_reserved2;
@ -407,7 +406,8 @@ typedef struct {
#define MAXRESPLEN 26
typedef struct {
isphdr_t ct_header;
u_int32_t ct_reserved;
u_int16_t ct_reserved;
u_int16_t ct_fwhandle; /* just to match CTIO */
u_int8_t ct_lun; /* lun */
u_int8_t ct_iid; /* initiator id */
u_int16_t ct_rxid; /* response ID */
@ -498,144 +498,179 @@ typedef struct {
*/
#ifdef __sparc__
#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \
if (isp->isp_bus == ISP_SBUS) { \
source -> taga = dest -> tagb; \
source -> tagb = dest -> taga; \
#define ISP_SBUS_SWOZZLE(isp, src, dst, taga, tagb) \
if (isp->isp_bustype == ISP_BT_SBUS) { \
u_int8_t tmp = src -> taga; \
dst -> taga = dst -> tagb; \
src -> tagb = tmp; \
} else { \
source -> taga = dest -> taga; \
source -> tagb = dest -> taga; \
dst -> taga = src -> taga; \
dst -> tagb = src -> taga; \
}
#else
#define ISP_SBUS_SWOZZLE(isp, src, dest, taga, tagb) \
source -> taga = dest -> taga; \
source -> tagb = dest -> taga;
#define ISP_SBUS_SWOZZLE(isp, src, dst, taga, tagb) \
dst -> taga = src -> taga; \
dst -> tagb = src -> taga
#endif
#define MCIDF(d, s) if ((void *) d != (void *)s) MEMCPY(d, s, QENTRY_LEN)
/* This is really only for SBus cards on a sparc */
#ifdef __sparc__
#define ISP_SWIZ_ATIO(isp, dest, vsrc) \
#define ISP_SWIZ_ATIO(isp, vdst, vsrc) \
{ \
at_entry_t *source = (at_entry_t *) vsrc; \
at_entry_t local, *vdst; \
if ((void *)dest == (void *)vsrc) { \
MEMCPY(vsrc, &local, sizeof (at_entry_t)); \
vdst = &local; \
} else { \
vdst = dest; \
} \
vdst->at_header = source->at_header; \
vdst->at_reserved2 = source->at_reserved2; \
ISP_SBUS_SWOZZLE(isp, source, vdst, at_lun, at_iid); \
ISP_SBUS_SWOZZLE(isp, source, vdst, at_cdblen, at_tgt); \
vdst->at_flags = source->at_flags; \
ISP_SBUS_SWOZZLE(isp, source, vdst, at_status, at_scsi_status); \
ISP_SBUS_SWOZZLE(isp, source, vdst, at_tag_val, at_tag_type); \
MEMCPY(vdst->at_cdb, source->at_cdb, ATIO_CDBLEN); \
MEMCPY(vdst->at_sense, source->at_sense, QLTM_SENSELEN); \
at_entry_t *src = (at_entry_t *) vsrc; \
at_entry_t *dst = (at_entry_t *) vdst; \
dst->at_header = src->at_header; \
dst->at_reserved = src->at_reserved; \
dst->at_handle = src->at_handle; \
ISP_SBUS_SWOZZLE(isp, src, dst, at_lun, at_iid); \
ISP_SBUS_SWOZZLE(isp, src, dst, at_cdblen, at_tgt); \
dst->at_flags = src->at_flags; \
ISP_SBUS_SWOZZLE(isp, src, dst, at_status, at_scsi_status); \
ISP_SBUS_SWOZZLE(isp, src, dst, at_tag_val, at_tag_type); \
MEMCPY(dst->at_cdb, src->at_cdb, ATIO_CDBLEN); \
MEMCPY(dst->at_sense, src->at_sense, QLTM_SENSELEN); \
}
#define ISP_SWIZ_CTIO(isp, dest, vsrc) \
#define ISP_SWIZ_ATIO2(isp, vdst, vsrc) \
{ \
ct_entry_t *source = (ct_entry_t *) vsrc; \
ct_entry_t *local, *vdst; \
if ((void *)dest == (void *)vsrc) { \
MEMCPY(vsrc, &local, sizeof (ct_entry_t)); \
vdst = &local; \
} else { \
vdst = dest; \
} \
vdst->ct_header = source->ct_header; \
vdst->ct_reserved = source->ct_reserved; \
ISP_SBUS_SWOZZLE(isp, source, vdst, ct_lun, ct_iid); \
ISP_SBUS_SWOZZLE(isp, source, vdst, ct_rsvd, ct_tgt); \
vdst->ct_flags = source->ct_flags; \
ISP_SBUS_SWOZZLE(isp, source, vdst, ct_status, ct_scsi_status); \
ISP_SBUS_SWOZZLE(isp, source, vdst, ct_tag_val, ct_tag_type); \
vdst->ct_xfrlen = source->ct_xfrlen; \
vdst->ct_resid = source->ct_resid; \
vdst->ct_timeout = source->ct_timeout; \
vdst->ct_seg_count = source->ct_seg_count; \
MEMCPY(vdst->ct_cdb, source->ct_cdb, ATIO_CDBLEN); \
MEMCPY(vdst->ct_sense, source->ct_sense, QLTM_SENSELEN); \
vdst->ct_dataseg = source->ct_dataseg; \
at2_entry_t *src = (at2_entry_t *) vsrc; \
at2_entry_t *dst = (at2_entry_t *) vdst; \
dst->at_reserved = src->at_reserved; \
ISP_SBUS_SWOZZLE(isp, src, dst, at_lun, at_iid); \
dst->at_rxid = src->at_rxid; \
dst->at_flags = src->at_flags; \
dst->at_status = src->at_status; \
ISP_SBUS_SWOZZLE(isp, src, dst, at_reserved1, at_taskcodes); \
ISP_SBUS_SWOZZLE(isp, src, dst, at_taskflags, at_execodes); \
MEMCPY(dst->at_cdb, src->at_cdb, ATIO2_CDBLEN); \
dst->at_datalen = src->at_datalen; \
dst->at_scclun = src->at_scclun; \
MEMCPY(dst->at_reserved2, src->at_reserved2, sizeof dst->at_reserved2);\
dst->at_oxid = src->at_oxid; \
}
#define ISP_SWIZ_ENABLE_LUN(isp, dest, vsrc) \
#define ISP_SWIZ_CTIO(isp, vdst, vsrc) \
{ \
lun_entry_t *source = (lun_entry_t *)vsrc; \
lun_entry_t *local, *vdst; \
if ((void *)dest == (void *)vsrc) { \
MEMCPY(vsrc, &local, sizeof (lun_entry_t)); \
vdst = &local; \
} else { \
vdst = dest; \
} \
vdst->le_header = source->le_header; \
vdst->le_reserved2 = source->le_reserved2; \
ISP_SBUS_SWOZZLE(isp, source, vdst, le_lun, le_rsvd); \
ISP_SBUS_SWOZZLE(isp, source, vdst, le_ops, le_tgt); \
vdst->le_flags = source->le_flags; \
ISP_SBUS_SWOZZLE(isp, source, vdst, le_status, le_rsvd2); \
ISP_SBUS_SWOZZLE(isp, source, vdst, le_cmd_count, le_in_count); \
ISP_SBUS_SWOZZLE(isp, source, vdst, le_cdb6len, le_cdb7len); \
vdst->le_timeout = source->le_timeout; \
vdst->le_reserved = source->le_reserved; \
ct_entry_t *src = (ct_entry_t *) vsrc; \
ct_entry_t *dst = (ct_entry_t *) vdst; \
dst->ct_header = src->ct_header; \
dst->ct_syshandle = src->ct_syshandle; \
dst->ct_fwhandle = src->ct_fwhandle; \
dst->ct_fwhandle = src->ct_fwhandle; \
ISP_SBUS_SWOZZLE(isp, src, dst, ct_lun, ct_iid); \
ISP_SBUS_SWOZZLE(isp, src, dst, ct_reserved2, ct_tgt); \
dst->ct_flags = src->ct_flags; \
ISP_SBUS_SWOZZLE(isp, src, dst, ct_status, ct_scsi_status); \
ISP_SBUS_SWOZZLE(isp, src, dst, ct_tag_val, ct_tag_type); \
dst->ct_xfrlen = src->ct_xfrlen; \
dst->ct_resid = src->ct_resid; \
dst->ct_timeout = src->ct_timeout; \
dst->ct_seg_count = src->ct_seg_count; \
MEMCPY(dst->ct_dataseg, src->ct_dataseg, sizeof (dst->ct_dataseg)); \
}
#define ISP_SWIZ_NOTIFY(isp, dest, vsrc) \
#define ISP_SWIZ_CTIO2(isp, vdst, vsrc) \
{ \
in_entry_type *source = (in_entry_t *)vsrc; \
in_entry_t *local, *vdst; \
if ((void *)dest == (void *)vsrc) { \
MEMCPY(vsrc, &local, sizeof (in_entry_t)); \
vdst = &local; \
} else { \
vdst = dest; \
} \
vdst->in_header = source->in_header; \
vdst->in_reserved2 = source->in_reserved2; \
ISP_SBUS_SWOZZLE(isp, source, vdst, in_lun, in_iid); \
ISP_SBUS_SWOZZLE(isp, source, vdst, in_rsvd, in_tgt); \
vdst->in_flags = source->in_flags; \
ISP_SBUS_SWOZZLE(isp, source, vdst, in_status, in_rsvd2); \
ISP_SBUS_SWOZZLE(isp, source, vdst, in_tag_val, in_tag_type); \
vdst->in_seqid = source->in_seqid; \
MEMCPY(vdst->in_msg, source->in_msg, IN_MSGLEN); \
MEMCPY(vdst->in_reserved, source->in_reserved, IN_RESERVED); \
MEMCPY(vdst->in_sense, source->in_sense, QLTM_SENSELEN); \
ct2_entry_t *src = (ct2_entry_t *) vsrc; \
ct2_entry_t *dst = (ct2_entry_t *) vdst; \
dst->ct_header = src->ct_header; \
dst->ct_syshandle = src->ct_syshandle; \
dst->ct_fwhandle = src->ct_fwhandle; \
dst->ct_fwhandle = src->ct_fwhandle; \
ISP_SBUS_SWOZZLE(isp, src, dst, ct_lun, ct_iid); \
dst->ct_rxid = src->ct_rxid; \
dst->ct_flags = src->ct_flags; \
dst->ct_status = src->ct_status; \
dst->ct_timeout = src->ct_timeout; \
dst->ct_seg_count = src->ct_seg_count; \
dst->ct_reloff = src->ct_reloff; \
dst->ct_resid = src->ct_resid; \
dst->rsp = src->rsp; \
}
#define ISP_SWIZ_NOT_ACK(isp, dest) \
#define ISP_SWIZ_ENABLE_LUN(isp, vdst, vsrc) \
{ \
na_entry_t *source = (na_entry_t *)vsrc; \
na_entry_t *local, *vdst; \
if ((void *)dest == (void *)vsrc) { \
MEMCPY(vsrc, &local, sizeof (na_entry_t)); \
vdst = &local; \
} else { \
vdst = dest; \
} \
vdst->na_header = source->na_header; \
vdst->na_reserved2 = source->na_reserved2; \
ISP_SBUS_SWOZZLE(isp, source, vdst, na_lun, na_iid); \
ISP_SBUS_SWOZZLE(isp, source, vdst, na_rsvd, na_tgt); \
vdst->na_flags = source->na_flags; \
ISP_SBUS_SWOZZLE(isp, source, vdst, na_status, na_event); \
vdst->na_seqid = source->na_seqid; \
MEMCPY(vdst->na_reserved, source->na_reserved, NA_RSVDLEN); \
lun_entry_t *src = (lun_entry_t *)vsrc; \
lun_entry_t *dst = (lun_entry_t *)vdst; \
dst->le_header = src->le_header; \
dst->le_reserved2 = src->le_reserved2; \
ISP_SBUS_SWOZZLE(isp, src, dst, le_lun, le_rsvd); \
ISP_SBUS_SWOZZLE(isp, src, dst, le_ops, le_tgt); \
dst->le_flags = src->le_flags; \
ISP_SBUS_SWOZZLE(isp, src, dst, le_status, le_reserved2); \
ISP_SBUS_SWOZZLE(isp, src, dst, le_cmd_count, le_in_count); \
ISP_SBUS_SWOZZLE(isp, src, dst, le_cdb6len, le_cdb7len); \
dst->le_timeout = src->le_timeout; \
dst->le_reserved = src->le_reserved; \
}
#define ISP_SWIZ_NOTIFY(isp, vdst, vsrc) \
{ \
in_entry_type *src = (in_entry_t *)vsrc; \
in_entry_type *dst = (in_entry_t *)vdst; \
dst->in_header = src->in_header; \
dst->in_reserved2 = src->in_reserved2; \
ISP_SBUS_SWOZZLE(isp, src, dst, in_lun, in_iid); \
ISP_SBUS_SWOZZLE(isp, src, dst, in_reserved2, in_tgt); \
dst->in_flags = src->in_flags; \
ISP_SBUS_SWOZZLE(isp, src, dst, in_status, in_rsvd2); \
ISP_SBUS_SWOZZLE(isp, src, dst, in_tag_val, in_tag_type); \
dst->in_seqid = src->in_seqid; \
MEMCPY(dst->in_msg, src->in_msg, IN_MSGLEN); \
MEMCPY(dst->in_reserved, src->in_reserved, IN_RESERVED); \
MEMCPY(dst->in_sense, src->in_sense, QLTM_SENSELEN); \
}
#define ISP_SWIZ_NOTIFY_FC(isp, vdst, vsrc) \
{ \
in_fcentry_type *src = (in_fcentry_t *)vsrc; \
in_fcentry_type *dst = (in_fcentry_t *)vdst; \
dst->in_header = src->in_header; \
dst->in_reserved2 = src->in_reserved2; \
ISP_SBUS_SWOZZLE(isp, src, dst, in_lun, in_iid); \
dst->in_scclun = src->in_scclun; \
dst->in_reserved2 = src->in_reserved2; \
dst->in_status = src->in_status; \
dst->in_task_flags = src->in_task_flags; \
dst->in_seqid = src->in_seqid; \
}
#define ISP_SWIZ_NOT_ACK(isp, vdst, vsrc) \
{ \
na_entry_t *src = (na_entry_t *)vsrc; \
na_entry_t *dst = (na_entry_t *)vdst; \
dst->na_header = src->na_header; \
dst->na_reserved = src->na_reserved; \
ISP_SBUS_SWOZZLE(isp, src, dst, na_lun, na_iid); \
dst->na_reserved2 = src->na_reserved2; \
ISP_SBUS_SWOZZLE(isp, src, dst, na_reserved, na_tgt); \
dst->na_flags = src->na_flags; \
ISP_SBUS_SWOZZLE(isp, src, dst, na_status, na_event); \
dst->na_seqid = src->na_seqid; \
MEMCPY(dst->na_reserved3, src->na_reserved3, NA_RSVDLEN); \
}
#define ISP_SWIZ_NOT_ACK_FC(isp, vdst, vsrc) \
{ \
na_fcentry_t *src = (na_fcentry_t *)vsrc; \
na_fcentry_t *dst = (na_fcentry_t *)vdst; \
dst->na_header = src->na_header; \
dst->na_reserved = src->na_reserved; \
ISP_SBUS_SWOZZLE(isp, src, dst, na_lun, na_iid); \
dst->na_scclun = src->na_scclun; \
dst->na_flags = src->na_flags; \
dst->na_reserved2 = src->na_reserved2; \
dst->na_status = src->na_status; \
dst->na_task_flags = src->na_task_flags; \
dst->na_seqid = src->na_seqid; \
MEMCPY(dst->na_reserved3, src->na_reserved3, NA2_RSVDLEN); \
}
#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s)
#else
#define ISP_SWIZ_ATIO(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_CTIO(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_ENABLE_LUN(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOTIFY(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOT_ACK(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_ATIO2(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_CTIO2(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOTIFY(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOTIFY_FC(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOT_ACK(isp, d, s) MCIDF(d, s)
#define ISP_SWIZ_NOT_ACK_FC(isp, d, s) MCIDF(d, s)
#endif
/*
@ -653,14 +688,14 @@ typedef struct {
/*
* This function handles new response queue entry appropriate for target mode.
*/
int isp_target_notify __P((struct ispsoftc *, void *, u_int16_t *));
int isp_target_notify(struct ispsoftc *, void *, u_int16_t *);
/*
* Enable/Disable/Modify a logical unit.
*/
#define DFLT_CMD_CNT 32 /* XX */
#define DFLT_INOTIFY (4)
int isp_lun_cmd __P((struct ispsoftc *, int, int, int, int, u_int32_t));
int isp_lun_cmd(struct ispsoftc *, int, int, int, int, u_int32_t);
/*
* General request queue 'put' routine for target mode entries.
@ -672,20 +707,20 @@ int isp_target_put_entry __P((struct ispsoftc *isp, void *));
* used for replenishing f/w resource counts.
*/
int
isp_target_put_atio __P((struct ispsoftc *, int, int, int, int, int));
isp_target_put_atio(struct ispsoftc *, int, int, int, int, int);
/*
* General routine to send a final CTIO for a command- used mostly for
* local responses.
*/
int
isp_endcmd __P((struct ispsoftc *, void *, u_int32_t, u_int32_t));
isp_endcmd(struct ispsoftc *, void *, u_int32_t, u_int16_t);
#define ECMD_SVALID 0x100
/*
* Handle an asynchronous event
*/
void isp_target_async __P((struct ispsoftc *, int, int));
void isp_target_async(struct ispsoftc *, int, int);
#endif /* _ISPTARGET_H */
#endif /* _ISP_TARGET_H */