b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * CDDL HEADER START
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * The contents of this file are subject to the terms of the
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Common Development and Distribution License, Version 1.0 only
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * (the "License"). You may not use this file except in compliance
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * with the License.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * See the License for the specific language governing permissions
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * and limitations under the License.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * When distributing Covered Code, include this CDDL HEADER in each
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * If applicable, add the following below this CDDL HEADER, with the
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * fields enclosed by brackets "[]" replaced with your own identifying
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * information: Portions Copyright [yyyy] [name of copyright owner]
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * CDDL HEADER END
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Use is subject to license terms.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#pragma ident "%Z%%M% %I% %E% SMI"
b1dd958f54f8bfa984d306bb8ca8264855761d7bcthextern "C" {
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Convenient short hand defines
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define CNUM(emul64) (ddi_get_instance(emul64->emul64_tran.tran_dev))
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_INITIAL_SOFT_SPACE 5 /* Used for the softstate_init func */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * max number of LUNs per target
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Default emul64 scsi-options
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Tag reject
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Interrupt actions returned by emul64_i_flag_event()
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Reset actions for emul64_i_reset_interface()
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_RESET_BUS_IF_BUSY 0x01 /* reset scsi bus if it is busy */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_FORCE_RESET_BUS 0x02 /* reset scsi bus on error reco */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * extracting period and offset from emul64_synch
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * timeout values
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_TIMEOUT_DELAY(secs, delay) (secs * (1000000 / delay))
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * delay time for polling loops
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * busy wait delay time after chip reset
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * timeout for EMUL64 coming out of reset
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * emul64_softstate flags for introducing hot plug
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * ioctl command definitions
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Debugging macros
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define RESP_CQ_FLAGS(resp) ((resp->resp_header.cq_flags_seq) & 0xff)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * translate scsi_pkt flags into EMUL64 request packet flags
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * It would be illegal if two flags are set; the driver does not
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * check for this. Setting NODISCON and a tag flag is harmless.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_SET_PKT_FLAGS(scsa_flags, emul64_flags) { \
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth emul64_flags |= (scsa_flags >> 1) & 0x1; /* no disconnect */ \
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * throttle values for EMUL64 request queue
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define SHUTDOWN_THROTTLE -1 /* do not submit any requests */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_GET_PKT_STATE(state) ((uint32_t)(state >> 8))
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * mutex short hands
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_REQ_MUTEX(emul64) (&emul64->emul64_request_mutex)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_RESP_MUTEX(emul64) (&emul64->emul64_response_mutex)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_HOTPLUG_MUTEX(emul64) (&emul64->emul64_hotplug_mutex)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_MUTEX_ENTER(emul64) mutex_enter(EMUL64_RESP_MUTEX(emul64)), \
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define EMUL64_MUTEX_EXIT(emul64) mutex_exit(EMUL64_RESP_MUTEX(emul64)), \
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * HBA interface macros
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define TRAN2EMUL64(tran) ((struct emul64 *)(tran)->tran_hba_private)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#define CMD2TRAN(cmd) (CMD2PKT(cmd)->pkt_address.a_hba_tran)
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Results of checking for range overlap.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Rather than keep the entire image of the disk, we only keep
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * the blocks which have been written with non-zeros. As the
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * purpose of this driver is to exercise format and perhaps other
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * large-disk management tools, only recording the label for
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * i/o is sufficient
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Structure to track a range of blocks where writes are to be ignored.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth struct emul64_nowrite *emul64_nwnext; /* next item in list */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth emul64_range_t emul64_blocked; /* range to ignore writes */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth struct emul64_tgt *emul64_tgt_next; /* Next tgt on ctlr */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth emul64_nowrite_t *emul64_tgt_nowrite; /* List of regions to */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth /* skip writes */
cefe316e0be5ef06d07788f53ad6c498a0701d1dpd /* Fields for error injection */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * emul64 softstate structure
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * deadline slot structure for timeout handling
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Record the reset notification requests from target drivers.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Transport structure for this instance of the hba
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * dev_info_t reference can be found in the transport structure
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Interrupt block cookie
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Firmware revision number
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * timeout id
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * scsi options, scsi_tag_age_limit per emul64
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * scsi_reset_delay per emul64
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * current host ID
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * suspended flag for power management
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * Host adapter capabilities and offset/period values per target
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * EMUL64 Hardware register pointer.
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * for keeping track of the max LUNs per target on this bus
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth * for keeping track of each target/lun
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth int nt_total_sectors[NTARGETS_WIDE][EMUL64_NLUNS_PER_TARGET];
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth struct emul64_reset_notify_entry *emul64_reset_notify_listf;
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth kcondvar_t emul64_cv; /* cv for bus quiesce/unquiesce */
b1dd958f54f8bfa984d306bb8ca8264855761d7bcthextern void emul64_bsd_init();
b1dd958f54f8bfa984d306bb8ca8264855761d7bcthextern void emul64_bsd_fini();
b1dd958f54f8bfa984d306bb8ca8264855761d7bcthextern emul64_rng_overlap_t emul64_overlap(emul64_range_t *,
b1dd958f54f8bfa984d306bb8ca8264855761d7bcthextern int emul64_bsd_blkcompare(const void *, const void *);
b1dd958f54f8bfa984d306bb8ca8264855761d7bcth#endif /* _SYS_SCSI_ADAPTERS_EMUL64VAR_H */