summaryrefslogtreecommitdiffstats
path: root/sys/dev/isp/isp_freebsd.h
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2012-07-28 20:06:29 +0000
committermjacob <mjacob@FreeBSD.org>2012-07-28 20:06:29 +0000
commita41cb450d69215d0da52701d70146c12971be38d (patch)
treee1ac1dcf97e2541ae902e508daa253c99de306c4 /sys/dev/isp/isp_freebsd.h
parent5792096bc677884a34c715613253e90705f70fe3 (diff)
downloadFreeBSD-src-a41cb450d69215d0da52701d70146c12971be38d.zip
FreeBSD-src-a41cb450d69215d0da52701d70146c12971be38d.tar.gz
-----------
MISC CHANGES Add a new async event- ISP_TARGET_NOTIFY_ACK, that will guarantee eventual delivery of a NOTIFY ACK. This is tons better than just ignoring the return from isp_notify_ack and hoping for the best. Clean up the lower level lun enable code to be a bit more sensible. Fix a botch in isp_endcmd which was messing up the sense data. Fix notify ack for SRR to use a sensible error code in the case of a reject. Clean up and make clear what kind of firmware we've loaded and what capabilities it has. ----------- FULL (252 byte) SENSE DATA In CTIOs for the ISP, there's only a limimted amount of space to load SENSE DATA for associated CHECK CONDITIONS (24 or 26 bytes). This makes it difficult to send full SENSE DATA that can be up to 252 bytes. Implement MODE 2 responses which have us build the FCP Response in system memory which the ISP will put onto the wire directly. On the initiator side, the same problem occurs in that a command status response only has a limited amount of space for SENSE DATA. This data is supplemented by status continuation responses that the ISP pushes onto the response queue after the status response. We now pull them all together so that full sense data can be returned to the periph driver. This is supported on 23XX, 24XX and 25XX cards. This is also preparation for doing >16 byte CDBs. ----------- FC TAPE Implement full FC-TAPE on both initiator and target mode side. This capability is driven by firmware loaded, board type, board NVRAM settings, or hint configuration options to enable or disable. This is supported for 23XX, 24XX and 25XX cards. On the initiator side, we pretty much just have to generate a command reference number for each command we send out. This is FCP-4 compliant in that we do this per ITL nexus to generate the allowed 1 thru 255 CRN. In order to support the target side of FC-TAPE, we now pay attention to more of the PRLI word 3 parameters which will tell us whether an initiator wants confirmed responses. While we're at it, we'll pay attention to the initiator view too and report it. On sending back CTIOs, we will notice whether the initiator wants confirmed responses and we'll set up flags to do so. If a response or data frame is lost the initiator sends us an SRR (Sequence Retransmit Request) ELS which shows up as an SRR notify and all outstanding CTIOs are nuked with SRR Received status. The SRR notify contains the offset that the initiator wants us to restart the data transfer from or to retransmit the response frame. If the ISP driver still has the CCB around for which the data segment or response applies, it will retransmit. However, we typically don't know about a lost data frame until we send the FCP Response and the initiator totes up counters for data moved and notices missing segments. In this case we've already completed the data CCBs already and sent themn back up to the periph driver. Because there's no really clean mechanism yet in CAM to handle this, a hack has been put into place to complete the CTIO CCB with the CAM_MESSAGE_RECV status which will have a MODIFY DATA POINTER extended message in it. The internal ISP target groks this and ctl(8) will be modified to deal with this as well. At any rate, the data is retransmitted and an an FCP response is sent. The whole point here is to successfully complete a command so that you don't have to depend on ULP (SCSI) to have to recover, which in the case of tape is not really possible (hence the name FC-TAPE). Sponsored by: Spectralogic MFC after: 1 month
Diffstat (limited to 'sys/dev/isp/isp_freebsd.h')
-rw-r--r--sys/dev/isp/isp_freebsd.h161
1 files changed, 97 insertions, 64 deletions
diff --git a/sys/dev/isp/isp_freebsd.h b/sys/dev/isp/isp_freebsd.h
index 001c699..5bd1268 100644
--- a/sys/dev/isp/isp_freebsd.h
+++ b/sys/dev/isp/isp_freebsd.h
@@ -75,6 +75,16 @@
#define ISP_IFLAGS INTR_TYPE_CAM | INTR_ENTROPY | INTR_MPSAFE
+#define N_XCMDS 64
+#define XCMD_SIZE 512
+struct ispsoftc;
+typedef union isp_ecmd {
+ union isp_ecmd * next;
+ uint8_t data[XCMD_SIZE];
+} isp_ecmd_t;
+isp_ecmd_t * isp_get_ecmd(struct ispsoftc *);
+void isp_put_ecmd(struct ispsoftc *, isp_ecmd_t *);
+
#ifdef ISP_TARGET_MODE
/* Not quite right, but there was no bump for this change */
#if __FreeBSD_version < 225469
@@ -100,12 +110,22 @@ typedef struct {
uint32_t portid;
uint16_t rxid; /* wire rxid */
uint16_t oxid; /* wire oxid */
+ uint16_t word3; /* PRLI word3 params */
+ uint16_t ctcnt; /* number of CTIOs currently active */
uint32_t
- cdb0 : 8,
- : 1,
- dead : 1,
- tattr : 3,
- state : 3;
+ srr_notify_rcvd : 1,
+ cdb0 : 8,
+ sendst : 1,
+ dead : 1,
+ tattr : 3,
+ state : 3;
+ void * ests;
+ /*
+ * The current SRR notify copy
+ */
+ uint8_t srr[64]; /* sb QENTRY_LEN, but order of definitions is wrong */
+ void * srr_ccb;
+ uint32_t nsrr;
} atio_private_data_t;
#define ATPD_STATE_FREE 0
#define ATPD_STATE_ATIO 1
@@ -123,6 +143,11 @@ union inot_private_data {
uint32_t tag_id, seq_id;
} rd;
};
+typedef struct isp_timed_notify_ack {
+ void *isp;
+ void *not;
+ uint8_t data[64]; /* sb QENTRY_LEN, but order of definitions is wrong */
+} isp_tna_t;
typedef struct tstate {
SLIST_ENTRY(tstate) next;
@@ -151,15 +176,32 @@ typedef struct tstate {
*/
struct isp_pcmd {
struct isp_pcmd * next;
- bus_dmamap_t dmap; /* dma map for this command */
- struct ispsoftc * isp; /* containing isp */
- struct callout wdog; /* watchdog timer */
- uint8_t crn; /* command reference number */
+ bus_dmamap_t dmap; /* dma map for this command */
+ struct ispsoftc * isp; /* containing isp */
+ struct callout wdog; /* watchdog timer */
+ uint8_t totslen; /* sense length on status response */
+ uint8_t cumslen; /* sense length on status response */
+ uint8_t crn; /* command reference number */
};
#define ISP_PCMD(ccb) (ccb)->ccb_h.spriv_ptr1
#define PISP_PCMD(ccb) ((struct isp_pcmd *)ISP_PCMD(ccb))
/*
+ * Per nexus info.
+ */
+struct isp_nexus {
+ struct isp_nexus * next;
+ uint32_t
+ crnseed : 8; /* next command reference number */
+ uint32_t
+ tgt : 16, /* TGT for target */
+ lun : 16; /* LUN for target */
+};
+#define NEXUS_HASH_WIDTH 32
+#define INITIAL_NEXUS_COUNT MAX_FC_TARG
+#define NEXUS_HASH(tgt, lun) ((tgt + lun) % NEXUS_HASH_WIDTH)
+
+/*
* Per channel information
*/
SLIST_HEAD(tslist, tstate);
@@ -176,6 +218,11 @@ struct isp_fc {
uint32_t loop_down_time;
uint32_t loop_down_limit;
uint32_t gone_device_time;
+ /*
+ * Per target/lun info- just to keep a per-ITL nexus crn count
+ */
+ struct isp_nexus *nexus_hash[NEXUS_HASH_WIDTH];
+ struct isp_nexus *nexus_free_list;
uint32_t
#ifdef ISP_TARGET_MODE
#ifdef ISP_INTERNAL_TARGET
@@ -202,8 +249,10 @@ struct isp_fc {
#ifdef ISP_INTERNAL_TARGET
struct proc * target_proc;
#endif
+#if defined(DEBUG)
+ unsigned int inject_lost_data_frame;
+#endif
#endif
- uint8_t crnseed; /* next command reference number */
};
struct isp_spi {
@@ -266,6 +315,7 @@ struct isposinfo {
#else
: 2,
#endif
+ sixtyfourbit : 1, /* sixtyfour bit platform */
timer_active : 1,
autoconf : 1,
ehook_active : 1,
@@ -288,6 +338,10 @@ struct isposinfo {
cam_status * rptr;
#endif
+ bus_addr_t ecmd_dma;
+ isp_ecmd_t * ecmd_base;
+ isp_ecmd_t * ecmd_free;
+
/*
* Per-type private storage...
*/
@@ -318,16 +372,7 @@ struct isposinfo {
ISP_FC_PC(isp, chan)-> tag = val; \
}
-#define FCP_NEXT_CRN(isp, cmd, rslt, chan, tgt, lun) \
- if ((isp)->isp_osinfo.pc.fc[(chan)].crnseed == 0) { \
- (isp)->isp_osinfo.pc.fc[(chan)].crnseed = 1; \
- } \
- if (cmd) { \
- PISP_PCMD(cmd)->crn = (isp)->isp_osinfo.pc.fc[(chan)].crnseed; \
- } \
- (rslt) = (isp)->isp_osinfo.pc.fc[(chan)].crnseed++
-
-
+#define FCP_NEXT_CRN isp_fcp_next_crn
#define isp_lock isp_osinfo.lock
#define isp_bus_tag isp_osinfo.bus_tag
#define isp_bus_handle isp_osinfo.bus_handle
@@ -341,7 +386,6 @@ struct isposinfo {
/*
* Required Macros/Defines
*/
-
#define ISP_FC_SCRLEN 0x1000
#define ISP_MEMZERO(a, b) memset(a, 0, b)
@@ -459,20 +503,17 @@ default: \
#define XS_STSP(ccb) (&(ccb)->scsi_status)
#define XS_SNSP(ccb) (&(ccb)->sense_data)
-#define XS_SNSLEN(ccb) \
- imin((sizeof((ccb)->sense_data)), ccb->sense_len - ccb->sense_resid)
+#define XS_TOT_SNSLEN(ccb) ccb->sense_len
+#define XS_CUR_SNSLEN(ccb) (ccb->sense_len - ccb->sense_resid)
#define XS_SNSKEY(ccb) (scsi_get_sense_key(&(ccb)->sense_data, \
- ccb->sense_len - ccb->sense_resid, \
- /*show_errors*/ 1))
+ ccb->sense_len - ccb->sense_resid, 1))
#define XS_SNSASC(ccb) (scsi_get_asc(&(ccb)->sense_data, \
- ccb->sense_len - ccb->sense_resid, \
- /*show_errors*/ 1))
+ ccb->sense_len - ccb->sense_resid, 1))
#define XS_SNSASCQ(ccb) (scsi_get_ascq(&(ccb)->sense_data, \
- ccb->sense_len - ccb->sense_resid, \
- /*show_errors*/ 1))
+ ccb->sense_len - ccb->sense_resid, 1))
#define XS_TAG_P(ccb) \
(((ccb)->ccb_h.flags & CAM_TAG_ACTION_VALID) && \
(ccb)->tag_action != CAM_TAG_ACTION_NONE)
@@ -483,8 +524,7 @@ default: \
#define XS_SETERR(ccb, v) (ccb)->ccb_h.status &= ~CAM_STATUS_MASK, \
- (ccb)->ccb_h.status |= v, \
- (ccb)->ccb_h.spriv_field0 |= ISP_SPRIV_ERRSET
+ (ccb)->ccb_h.status |= v
# define HBA_NOERROR CAM_REQ_INPROG
# define HBA_BOTCH CAM_UNREC_HBA_ERROR
@@ -499,21 +539,31 @@ default: \
#define XS_ERR(ccb) ((ccb)->ccb_h.status & CAM_STATUS_MASK)
-#define XS_NOERR(ccb) \
- (((ccb)->ccb_h.spriv_field0 & ISP_SPRIV_ERRSET) == 0 || \
- ((ccb)->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG)
-
-#define XS_INITERR(ccb) \
- XS_SETERR(ccb, CAM_REQ_INPROG), (ccb)->ccb_h.spriv_field0 = 0
-
-#define XS_SAVE_SENSE(xs, sense_ptr, slen) do { \
- (xs)->ccb_h.status |= CAM_AUTOSNS_VALID; \
- memset(&(xs)->sense_data, 0, sizeof((xs)->sense_data)); \
- memcpy(&(xs)->sense_data, sense_ptr, imin(XS_SNSLEN(xs),\
- slen)); \
- if (slen < (xs)->sense_len) \
- (xs)->sense_resid = (xs)->sense_len - slen; \
- } while (0);
+#define XS_NOERR(ccb) (((ccb)->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG)
+
+#define XS_INITERR(ccb) XS_SETERR(ccb, CAM_REQ_INPROG), ccb->sense_resid = ccb->sense_len
+
+#define XS_SAVE_SENSE(xs, sense_ptr, totslen, slen) do { \
+ uint32_t tlen = slen; \
+ if (tlen > (xs)->sense_len) \
+ tlen = (xs)->sense_len; \
+ PISP_PCMD(xs)->totslen = imin((xs)->sense_len, totslen); \
+ PISP_PCMD(xs)->cumslen = tlen; \
+ memcpy(&(xs)->sense_data, sense_ptr, tlen); \
+ (xs)->sense_resid = (xs)->sense_len - tlen; \
+ (xs)->ccb_h.status |= CAM_AUTOSNS_VALID; \
+ } while (0)
+
+#define XS_SENSE_APPEND(xs, xsnsp, xsnsl) do { \
+ uint32_t off = PISP_PCMD(xs)->cumslen; \
+ uint8_t *ptr = &((uint8_t *)(&(xs)->sense_data))[off]; \
+ uint32_t amt = imin(xsnsl, PISP_PCMD(xs)->totslen - off); \
+ if (amt) { \
+ memcpy(ptr, xsnsp, amt); \
+ (xs)->sense_resid -= amt; \
+ PISP_PCMD(xs)->cumslen += amt; \
+ } \
+ } while (0)
#define XS_SENSE_VALID(xs) (((xs)->ccb_h.status & CAM_AUTOSNS_VALID) != 0)
@@ -634,24 +684,6 @@ extern int isp_autoconfig;
/*
* Platform private flags
*/
-#define ISP_SPRIV_ERRSET 0x1
-#define ISP_SPRIV_TACTIVE 0x2
-#define ISP_SPRIV_DONE 0x8
-#define ISP_SPRIV_WPEND 0x10
-
-#define XS_S_TACTIVE(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_TACTIVE
-#define XS_C_TACTIVE(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_TACTIVE
-#define XS_TACTIVE_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_TACTIVE)
-
-#define XS_CMD_S_DONE(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_DONE
-#define XS_CMD_C_DONE(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_DONE
-#define XS_CMD_DONE_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_DONE)
-
-#define XS_CMD_S_WPEND(sccb) (sccb)->ccb_h.spriv_field0 |= ISP_SPRIV_WPEND
-#define XS_CMD_C_WPEND(sccb) (sccb)->ccb_h.spriv_field0 &= ~ISP_SPRIV_WPEND
-#define XS_CMD_WPEND_P(sccb) ((sccb)->ccb_h.spriv_field0 & ISP_SPRIV_WPEND)
-
-#define XS_CMD_S_CLEAR(sccb) (sccb)->ccb_h.spriv_field0 = 0
/*
* Platform Library Functions
@@ -667,6 +699,7 @@ int isp_fc_scratch_acquire(ispsoftc_t *, int);
int isp_mstohz(int);
void isp_platform_intr(void *);
void isp_common_dmateardown(ispsoftc_t *, struct ccb_scsiio *, uint32_t);
+int isp_fcp_next_crn(ispsoftc_t *, uint8_t *, XS_T *);
/*
* Platform Version specific defines
OpenPOWER on IntegriCloud