fcpvar.h revision d42c7aec1963a7ded6694ac33a5bd96422fc8ca7
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _FCPVAR_H
#define _FCPVAR_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Maximum number of times FCP will re-issue a REPORTS_LUNS command if the
* device couldn't return all of them in the submitted buffer.
*/
#define FCP_MAX_REPORTLUNS_ATTEMPTS 2
/*
* Maximum number of LUNs supported. This limit is enforced to accommodate
* certain HBAs.
*/
#define FCP_MAX_LUNS_SUPPORTED 65535
/*
* Stuff to be defined in fc_ulpif.h FIXIT
*/
#define PORT_DEVICE_CREATE 0x40
#define FCP_QUEUE_DELAY (4)
#define FCP_FAILED_DELAY 20
/*
* Highest possible timeout value to indicate
* the watch thread to return the I/O
*/
#define FCP_INVALID_TIMEOUT (0xFFFFFFFF)
/*
* The max inquiry page 83 size as expected in the code today
* is 0xf0 bytes. Defining a constant to make it easy incase
* this needs to be changed at a later time.
*/
#define SCMD_MAX_INQUIRY_PAGE83_SIZE 0xF0
/*
* Events generated for Target drivers; "SUNW,sf:" prefix
* is a legacy fcal stuff hardcoded into ssd via the use of
* FCAL_INSERT_EVENT defined in an fcal header file; We
* just need to continue to use this.
*/
#define FCAL_INSERT_EVENT "SUNW,sf:DEVICE-INSERTION.1"
#define FCAL_REMOVE_EVENT "SUNW,sf:DEVICE-REMOVAL.1"
/*
* for debug trace
*/
#define FCP_STACK_DEPTH 14
/*
* All the stuff above needs to move intp appropriate header files.
*/
#define FCP_NUM_HASH 128
x[4] + x[5] + x[6] + x[7]) & \
(FCP_NUM_HASH-1))
#define PKT_PRIV_SIZE 2
#ifdef KSTATS_CODE
/*
* fcp_stats : Statistics provided for fcp.
*/
struct fcp_stats {
/* response after forcing lip */
};
#endif
/*
* Structure fcp_port
* --------------------
*
* This structure is the FCP representation of an N_Port on a local FC HBA card.
* This is the master structure off of which all the others will be hanging at
* some point and is the Solaris per-instance soft-state structure.
*/
struct fcp_port {
/*
* This mutex protects the access to this structure (or most of its
* fields).
*/
/*
* This is the link to the next fcp_port structure in the global
* list. The head of the global list is fcp_port_head and is
* defined in fcp.c. This field is NULL for the last element of
* the global list.
*/
/*
* This field points to the head of a list of internal requests that
* will be retried later. Examples of internal requests are:
* 'Send a PRLI ELS', 'Send a PRLO ELS', 'Send a PLOGI ELS' or
* 'Send an Inquiry command'. If the submission of the request to the
* request can be resubmitted later, it is queued here. The watchdog
* timer (fcp_watch()) will walk this queue and resubmit the requests.
*/
struct fcp_ipkt *port_ipkt_list;
/*
* This seems to be used as a temporary device counter during a
* discovery process (or reconfiguration as some comments put it).
* It seems to be initialized in fcp_statec_callback() with the
* is supposed to reached zero when the reconfiguration process is
* over.
*/
int port_tmp_cnt;
/*
* This is supposed to indicate the state of this port. It is a
* bitmap which means several bits can be set simultaneously. The list
* of the different bits and their meaning is given further down in
* this file.
*/
/*
* This field is initialized at the very end of the function
* fcp_handle_port_attach() if the attachment of the port was
* successful. It is set to the value stored in lbolt64 at the
* time of the attachment. This value is only used in the function
* fcp_scsi_bus_config(). It is used to determine the value of the
* parameter timeout when ndi_busop_bus_config() and cv_wait() are
* called. It actually serves to figure out how long the enumeration
* can be delayed (the max value being FCP_INIT_WAIT_TIMEOUT).
*/
/*
* This field contains the topology of the SAN the port is connected
* to.
*/
/*
* when calling fcp_statec_callback() and fcp_port_attach(). This
* value is used to build Fibre Channel headers (like for PLOGI or
* PRLI).
*/
/*
* This field keeps track of the physical port state (fcp_port being
* more like the FCP software port state). The information stored here
* fcp_handle_port_attach() and fcp_handle_port_resume(). The values
* this field can take are defined in fctl.h.
*/
/*
* This field points to the first element of a list of fcp_reset_elem
* structures. Those structures are created when the target driver
* calls fcp_reset_target(). The target or the LUN specified by the
* target driver is reset by sending a Task Management command. After
* the response has been received, a fcp_reset_elem structure is
* queued here and will remain queued for FCP_RESET_DELAY. While
* the fcp_reset_elem structure is in this queue the LUNs of
* the target to reset or the LUN to reset is set to LUN_BUSY state.
* In fcp_watch() the timeout is tested. If the timout has expired,
* the fcp_reset_elem structure is unqueued and freed, and all the
* active commands for the target or LUNs are aborted.
*/
struct fcp_reset_elem *port_reset_list;
/*
* This points to the first element of a list of fcp_tgt_elem
* structures. This list is a list of targets to offline. The list
* is walked in fcp_watch(). After the target is offlined the
* structure fcp_tgt_elem is freed.
*/
struct fcp_tgt_elem *port_offline_tgts;
/*
* This points to the first element of a list of fcp_lun_elem
* structures. This list is a list of LUNs to offline. The list
* is walked in fcp_watch(). After the lun is offlined the
* structure fcp_lun_elem is freed.
*/
struct fcp_lun_elem *port_offline_luns;
/*
* This field is a counter initialized to 1 when the port attaches.
* It is incremented when the line goes from online to offline and
* vice versa. It is also incremented when the port detaches. The
* value stored in this counter is used as a reference in time of the
* link state. For example, when the line comes up internal requests
* are generated (fcp_ipkt) such as PRLI and INQUIRY. Those requests
* are tagged with the value contained in this field at the time the
* request is built. When the callback for the request is called, the
* current value of port_link_cnt is checked against the one set in
* the internal request structure. If they don't match, it means the
* the request is not relevant anymore to the current line state and
* must be discarded (in between a request is issued and the callback
* routine is called the line may have bounced). This is the way FCP
* identifies the requests that were hanging out when the state of the
* line changed.
*/
/*
* This field, as its name suggests, specifies a deadline for the
* overall discovery process. It is initialized in three cases:
*
* 1) When the line goes from the offline state to the online state.
* a notification was received from the fabric indicating that a new
* port showed up or that one disappeared.
* 3) In the fcp_create_on_demand() function (called because of an
* ioctl).
*
* In all instances it is set to:
*
* fcp_watchdog_time + FCP_ICMD_DEADLINE
*
* In all those instances a discovery process is started or extended
* (2). The value stored in port_deadline is only checked in one
* function: fcp_is_retryable(). That function checks if an
* internal command (fcp_ipkt) is retryable or not. Usually
* there's a counter that limits the number of times a command is
* retried (Max value is FCP_MAX_RETRIES). However, even if the
* counter hasn't exceeded that value, the command will not be retried
* past the deadline. This means that the discovery process has to
* be finished before port_deadline. In other words, an internal
* command retry capability is limited numerically and in time.
*/
int port_deadline;
/*
* This is the Node WWN of the local port. It is initialized
* during the port attachment.
*/
/*
* This is the Port WWN of the local port. It is initialized during
* the port attachment.
*/
/*
*/
/*
* The following 4 fields handle the queue of fcp_pkt outstanding for
* this port.
*
* port_pkt_mutex Protects the access to the queue
* port_pkt_head Points to the head of the queue
* port_pkt_tail Points to the tail of the queue
* port_npkts Number of commands outstanding (used only when
* DEBUG is defined).
*/
struct fcp_pkt *port_pkt_head;
struct fcp_pkt *port_pkt_tail;
/*
* This field is the counter of allocated and currently active
* fcp_ipkt.
*/
int port_ipkt_cnt;
/*
* ddi_get_instance() in fcp_port_attach().
*/
/*
* Maximum number of exchanges the underlying physical FibreChannel
* port can handle. This field is initialized during the port
* attachment but is never used.
*/
/*
* This port stores the behavior expected of the underlying FCA driver
* when a port reset occurs. The values stored here are defined in the
* file fc_types.h.
*/
/*
* This port stores the DMA behavior of the underlying FCA driver. It
* is checked only once in fcp_prepare_pkt() and, as the comment
* suggests, to work around an issue with an Intel PCI bridge.
*/
/*
* The value stored here indicates if the underlying FCA driver
* supports DMA transfers with non SCSI data (Ex: PRLI request).
*/
/*
* This field contains the size of the private space required by the
* underlying FCA driver in a FibreChannel packet (fc_packet_t).
*/
/*
* This field contains the port's modlink info. It is provided by
*/
struct modlinkage port_fp_modlinkage;
/*
* DMA attributes for data packets, commands and responses.
*/
/*
* Field containing the hba_tran structure registered with SCSA.
*/
struct scsi_hba_tran *port_tran;
/*
* representing the local physical fibre channel port.
*/
/*
* Head of the list of callback routines to call when a bus reset
* occurs. This list is populated by the targets drivers by calling
* fcp_scsi_reset_notify() (tran_reset_notify(9E)).
*/
/*
* for framework event management
*/
/*
* hash lists of targets attached to this port. The hashing is based
* on the WWN.
*/
/*
* per-Port control flag. By default mpxio is enabled on ports unless
* explicitly disabled through driver.conf.
*/
int port_mpxio;
/*
* Value used as a flag to determine if the throttling has been
* set/initialized in the FCA driver.
*/
int port_notify;
/*
* This field contains a string initialized at attachment time and used
* when calling the function the function fc_trace_debug() (through
* the macro FCP_TRACE and FCP_DTRACE) to identify the port that
* logged the message.
*/
char port_instbuf[24];
#ifdef DEBUG
/*
* Use once in fcp_finish_init() when calling getpcstack().
*/
int port_finish_depth;
#endif /* DEBUG */
/*
* Condition variable used during the bus enumeration process.
*/
/*
* list.
*/
int port_dmacookie_sz;
};
/*
* We need to save the target change count values in a map tag so as
* to uniquely identify the cause and handle it better as they change
* counts are bound to change upon receiving more state changes.
*/
typedef int fcp_map_tag_t;
/*
* fcp_state definitions.
*/
#define FCP_STATE_INIT 0x0001
#define FCP_STATE_OFFLINE 0x0002
#define FCP_STATE_ONLINE 0x0004
#define FCP_STATE_SUSPENDED 0x0008
#define FCP_STATE_POWER_DOWN 0x0010
#define FCP_STATE_ONLINING 0x0020
#define FCP_STATE_DETACHING 0x0040
#define FCP_STATE_IN_WATCHDOG 0x0080
/*
* FCP_STATE_IN_CB_DEVC indicates that we're handling a state change
* notification that will be changing the state of devices. This is an
* indication to fcp_scsi_start that the target's status might change.
*/
#define FCP_STATE_IN_CB_DEVC 0x0400
#define FCP_MAX_DEVICES 127
/* To remember that dip was allocated for a lun on this target. */
#define FCP_DEVICE_CREATED 0x1
#define FCP_EVENT_TAG_INSERT 0
#define FCP_EVENT_TAG_REMOVE 1
/*
* fcp_pkt: FCP packet
* ---------------------
*
* This structure is the one initialized/created in the tran_init_pkt(9E). It
* the scsi_pkt returned by tran_init_pkt(9E) to the target driver. There is
* a 1-to-1 correlation between the scsi_pkt, the fcp_pkt and the
* fc_packet.
*
* This is what a fcp_pkt looks like after allocation:
*
* +================================+
* +---> | struct scsi_pkt |
* | | |
* | +--- | pkt_ha_private |
* | | | |
* | | +================================+
* | |
* | | +================================+
* | +--> | struct fcp_pkt | <---------+
* +----- | cmd_pkt | |
* | cmd_fp_pkt | ---+ |
* +--------->| cmd_fcp_rsp[] | | |
* | +------->| cmd_fcp_cmd[] | | |
* | | |--------------------------------| | |
* | | | struct fc_packet | <--+ |
* | | | | |
* | | | pkt_ulp_private | ----------+
* | | | pkt_fca_private | -----+
* | | | pkt_data_cookie | ---+ |
* | | | pkt_cmdlen | | |
* | |(a) | pkt_rsplen | | |
* | +--------| .......... pkt_cmd ........... | ---|-|-------+
* | (a) | pkt_cmd_cookie | ---|-|-----+ |
* +----------| .......... pkt_resp .......... | ---|-|---+ | |
* | pkt_resp_cookie | ---|-|-+ | | |
* | pkt_cmd_dma | | | | | | |
* | pkt_cmd_acc | | | | | | |
* +================================+ | | | | | |
* | dma_cookies | <--+ | | | | |
* | | | | | | |
* +================================+ | | | | |
* | fca_private | <----+ | | | |
* | | | | | |
* +================================+ | | | |
* | | | |
* | | | |
* +================================+ (b) | | | |
* | fcp_resp cookies | <------+ | | |
* | | | | |
* +================================+ | | |
* | | |
* +================================+ (b) | | |
* | fcp_resp | <--------+ | |
* | (DMA resources associated) | | |
* +================================+ | |
* | |
* | |
* | |
* +================================+ (b) | |
* | fcp_cmd cookies | <----------+ |
* | | |
* +================================+ |
* |
* +================================+ (b) |
* | fcp_cmd | <------------+
* | (DMA resources associated) |
* +================================+
*
*
* (a) The underlying FCA does NOT support DMA for this field
* (b) The underlying FCA supports DMA for this field
*/
struct fcp_pkt {
/*
* The two following fields are used to queue fcp_pkt in the double
* link list of the lun structure. The packet is queued in
* tran_init_pkt(9E) and unqueued in tran_destroy_pkt(9E).
*/
/*
* This field is used to queue the packet in the single link list of the
* port structure. The port keeps a list of all the commands issued
* through it and scans it, for example, when all of those commands
* have to be aborted.
*/
/*
* This field points back to the scsi_pkt.
*/
/*
* This field points to the field cmd_fc_packet defined further in this
* same structure.
*/
struct fc_packet *cmd_fp_pkt;
/*
* Structure where the FCP_CMD information unit is going to be built.
*/
/*
* State of the packet. The values for the state seem to indicate
* that it isn't a bitmap. However, in several instances the code
* treats it as a bitmap doing a "&= ~FCP_PKT_ISSUED" to it
* eventhough the value stored is always checked using "!=" and "==".
*/
/*
* This field is a bitmap indicating if
* the cmd is queued
*/
/* Contains the number of bytes DMA mappped. */
/*
* Contains the timeout value for the packet. This is not a delay or
* a delta but an absolute value.
*/
/*
* This array is used to store the FCP_RSP information unit returned by
* the device when the underlying FCA cannot DMA it in.
*/
char cmd_fcp_rsp[FCP_MAX_RSP_IU_SIZE];
/*
* This is the fc_packet structure used to forward the request to
*/
struct fc_packet cmd_fc_packet;
};
/*
* fcp_ipkt : Packet for internal commands.
* ------------------------------------------
*
* +================================+
* | struct fcp_ipkt | <---------+
* | (kmem_zalloc()) | |
* | ipkt_fpkt | ---+ |
* | | | |
* | ipkt_cmdlen = cmd_len | | |
* | | | |
* | | | |
* | | | |
* |--------------------------------| | |
* | struct fc_packet | <--+ |
* | | |
* | pkt_ulp_private | ----------+
* | pkt_fca_private | -----+
* | pkt_data_cookie | ---+ |
* | pkt_cmdlen | | |
* | pkt_rsplen | | |
* | pkt_cmd ...................... | ---|-|-------+
* | pkt_cmd_cookie | ---|-|-----+ |
* | pkt_resp ..................... | ---|-|---+ | |
* | pkt_resp_cookie | ---|-|-+ | | |
* | pkt_cmd_dma | | | | | | |
* | pkt_cmd_acc | | | | | | |
* +================================+ | | | | | |
* | dma_cookies | <--+ | | | | |
* | | | | | | |
* | | | | | | |
* | | | | | | |
* +================================+ | | | | |
* | fca_private | <----+ | | | |
* | | | | | |
* | | | | | |
* | | | | | |
* +================================+ | | | |
* | | | |
* | | | |
* +================================+ (b) | | | |
* | fcp_resp cookies | <------+ | | |
* | | | | |
* +================================+ | | |
* | | |
* +================================+ (b) | | |
* | fcp_resp | <--------+ | |
* | (DMA resources associated) | | |
* +================================+ | |
* | |
* | |
* | |
* +================================+ (b) | |
* | fcp_cmd cookies | <----------+ |
* | | |
* +================================+ |
* |
* +================================+ (b) |
* | fcp_cmd | <------------+
* | (DMA resources associated) |
* +================================+
*
* (a) The underlying FCA does NOT support DMA for this field
* (b) The underlying FCA supports DMA for this field
*/
struct fcp_ipkt {
/*
* Pointer to the port (fcp_port) in behalf of which this internal
* packet was allocated.
*/
/*
* Pointer to the target (fcp_tgt) in behalf of which this internal
* packet was allocated.
*/
/*
* Pointer to the lun (fcp_lun) in behalf of which this internal
* packet was allocated. This field is only meaningful when the
* internal packet has been allocated for a "scsi passthru" command or
* for an internal SCSI command such as REPORT LUNs and INQUIRY.
*/
/*
* Fields used to queue the internal packet into the double linked list
* of the FCP port (fcp_port).
*/
/*
* This field points to the field ipkt_fc_packet defined farther in
* this same structure.
*/
/*
* This is the timeout value for the internal packet. It seems to
* increase with the number of retries. It is initialized like this
* in the code:
*
* icmd->ipkt_restart = fcp_watchdog_time + icmd->ipkt_retries++
*
* First time ipkt_retries is zero. As it increases, the timeout
* value for the internal packet also increases.
*/
/*
* Link state counter when the internal packet was built.
*/
int ipkt_cause;
/*
* Counter of the times an internal packet has been retried. Its
* value is checked against FCP_MAX_RETRIES.
*/
int ipkt_nodma;
/*
* Semaphore used to wait for completion on.
*/
/*
* Opcode indicating what internal command the packet contains (PLOGI,
* PRLI, INQUIRY...).
*/
/*
* FC packet.
*/
struct fc_packet ipkt_fc_packet;
};
/*
* cmd_state definitions
*/
#define FCP_PKT_IDLE 0x1
#define FCP_PKT_ISSUED 0x2
#define FCP_PKT_ABORTING 0x3
/*
* These are the defined cmd_flags for this structure.
*/
/*
* Target structure
* ----------------
*
* This structure holds the information relative to a SCSI target. This
* structure doesn't represent the object registered with the OS (NDI or
* MPxIO...).
*/
struct fcp_tgt {
/*
* This field is used to queue the target structure in one of the
* buckets of the fcp_port target hash table port_tgt_hash_table[].
*/
/* Points to the fcp_port the target belongs to. */
/*
* This field is a bitmap indicating the state of the target. Several
* bits can be set simultaneously.
*/
/*
* State controlling if the LUNs attached to this target will be
* automatically onlined or not.
*/
/*
* Mutex protecting this structure.
*/
/*
* List of LUNs (single link list).
*/
/*
* Number of LUNs in this target.
*/
/*
* Counter of LUNs to probe. It is used during the discovery
* process. Starts with the number of LUNs returned by REPORT_LUN
* and is decremented until it reaches zero.
*/
/*
*/
/*
* Node World Wide Name.
*/
/*
* Port World Wide Name.
*/
/*
* Fibre Channel Port ID.
*/
/*
* Fibre Channel Port ID. Uses bit fields to represent it.
*/
/*
* Becomes 1 when the LUNs are created.
*/
/*
* Counter of how many REPORT_LUN commands were sent. It is used to
* allow the REPORT_LUN command to be sent twice in case the buffer
* allocated the first time wasn't big enough.
*/
/*
* This field is incremented each time the field tgt_state is updated.
* Its use is similar to the use of the field port_link_cnt in the
* fcp_port structure. The internal packets are, for example, tagged
* with the value stored here.
*/
/*
* This field contains the cause of the last change in state.
*/
int tgt_statec_cause;
/*
* The following two fields indicate whether the remote port is an
* FCP initiator or an FCP target. They are treated as booleans.
*/
#ifdef DEBUG
/*
* Updated in fcp_call_finish_init_held() when DEBUG is defined
*/
int tgt_tmp_cnt_depth;
#endif /* DEBUG */
/*
* This field holds the timer id of the timer started when a LUN
* reconfiguration is needed for the target. The reconfiguration
* is done in the timeout function.
*/
int tgt_done;
/*
* Bitmap used to trace the discovery process.
*/
/*
* This field is used when the code is sorting out which devices
* were known which ones are new and which ones went away.
*/
/*
* Number of internal packets allocated in behalf of the target.
*/
int tgt_ipkt_cnt;
/*
* used to detect user unconfig when auto configuration is enabled.
*/
};
/*
* Target States
*/
#define FCP_TGT_INIT 0x01
#define FCP_TGT_BUSY 0x02
#define FCP_TGT_MARK 0x04
#define FCP_TGT_OFFLINE 0x08
#define FCP_TGT_ORPHAN 0x80
#define FCP_TGT_ILLREQ 0x10
/*
* Target Aux Stat
*/
#define FCP_TGT_TAGGED 0x01
/*
* Target discovery tracing
*/
#define FCP_TGT_TRACE_1 0x00000001
#define FCP_TGT_TRACE_2 0x00000002
#define FCP_TGT_TRACE_3 0x00000004
#define FCP_TGT_TRACE_4 0x00000008
#define FCP_TGT_TRACE_5 0x00000010
#define FCP_TGT_TRACE_6 0x00000020
#define FCP_TGT_TRACE_7 0x00000040
#define FCP_TGT_TRACE_8 0x00000080
#define FCP_TGT_TRACE_9 0x00000100
#define FCP_TGT_TRACE_10 0x00000200
#define FCP_TGT_TRACE_11 0x00000400
#define FCP_TGT_TRACE_12 0x00000800
#define FCP_TGT_TRACE_13 0x00001000
#define FCP_TGT_TRACE_14 0x00002000
#define FCP_TGT_TRACE_15 0x00004000
#define FCP_TGT_TRACE_16 0x00008000
#define FCP_TGT_TRACE_17 0x00010000
#define FCP_TGT_TRACE_18 0x00020000
#define FCP_TGT_TRACE_19 0x00040000
#define FCP_TGT_TRACE_20 0x00080000
#define FCP_TGT_TRACE_21 0x00100000
#define FCP_TGT_TRACE_22 0x00200000
#define FCP_TGT_TRACE_23 0x00400000
#define FCP_TGT_TRACE_24 0x00800000
#define FCP_TGT_TRACE_25 0x01000000
#define FCP_TGT_TRACE_26 0x02000000
#define FCP_TGT_TRACE_27 0x04000000
#define FCP_TGT_TRACE_28 0x08000000
#define FCP_TGT_TRACE_29 0x10000000
#ifndef __lock_lint
if (ptgt) {\
}\
}\
}
#else /* __lock_lint */
#endif /* __lock_lint */
/*
* state change cause
*/
#define FCP_CAUSE_TGT_CHANGE 0x01
#define FCP_CAUSE_LINK_CHANGE 0x02
#define FCP_CAUSE_LINK_DOWN 0x04
#define FCP_CAUSE_USER_CREATE 0x08
/*
* Target node states (applicable to LUNs behind the target)
*/
#define FCP_NO_CHANGE 0x1
#define FCP_LINK_CHANGE 0x2
#define FCP_DEV_CHANGE 0x3
/* hotplug event struct */
struct fcp_hp_event {
int (*callback)();
void *arg;
};
/*
* We talk to both NDI and MDI framework to enumerate our child devices.
* We internally define a generic child handle and assign either dev_info
* or mdi_pathinfo handle depending on the device.
*/
typedef void *child_info_t;
/*
* LUN structure
* -------------
*
* This structure holds the information relative to a SCSI LUN. This
* structure is the one representing the object registered with the OS (NDI
* or MPxIO...).
*/
struct fcp_lun {
/*
* Mutex protecting the access to this structure.
*/
/*
* Logical unit number. It is a SCSI3 format.
*/
/*
* The two following fields are respectively the head and tail of a
* double link list of fcp_packets. It is populated in
* tran_init_pkt(9E) (fcp_scsi_init_pkt) and emptied in
* tran_destroy_pkt(9E) (fcp_scsi_destroy_pkt).
*/
struct fcp_pkt *lun_pkt_head;
struct fcp_pkt *lun_pkt_tail;
/*
* This field is treated like a union. It may contain the dev_info_t
* or the mdi_pathinfo_t depending on how the device associated with
* this LUN was registered.
*/
/*
*/
int lun_event_count;
/*
* Back pointer to the target the LUN belongs to.
*/
/*
* Bit map reflecting the state of the LUN.
*/
/*
* LUN type (disk, tape...). The value stored here is taken from the
* inquiry data.
*/
/*
* This field is incremented each time fcp_scsi_tgt_init()
* (tran_tgt_init(9E)) is called and decremented each time
* fcp_scsi_tgt_free() (tran_tgt_free(9E)) is called. The
* incrementation and decrementation will also have an effect on
* lun_state bit FCP_SCSI_LUN_TGT_INIT.
*/
/*
* LUN number as it is returned by REPORT_LUNS.
*/
/*
* Pointer to the next LUN.
*/
/*
* SCSI Host Bus Adapter (HBA) driver transport vector structure.
*/
struct scsi_hba_tran *lun_tran;
/*
* per-Lun control flag. A value of '1' means the LUN is managed by
* mpxio. A value of '0' means the LUN has been physically enumerated
* as a child of corresponding port driver node.
*/
int lun_mpxio;
/*
* Length of the GUID.
*/
/*
* Pointer to a buffer that contains the GUID.
*/
char *lun_guid;
/*
* Pointer to a buffer that contains the old GUID.
*/
char *lun_old_guid;
/*
* Length of the old GUID
*/
/*
* Bitmap used to track the LUN discovery process.
*/
/*
* Bitmap representing the SCSI capabilities.
*/
/*
* LUN inquiry data (as returned by the INQUIRY command).
*/
struct scsi_inquiry lun_inq;
};
/*
* Lun discovery tracing
*/
#define FCP_LUN_TRACE_1 0x0000001
#define FCP_LUN_TRACE_2 0x0000002
#define FCP_LUN_TRACE_3 0x0000004
#define FCP_LUN_TRACE_4 0x0000008
#define FCP_LUN_TRACE_5 0x0000010
#define FCP_LUN_TRACE_6 0x0000020
#define FCP_LUN_TRACE_7 0x0000040
#define FCP_LUN_TRACE_8 0x0000080
#define FCP_LUN_TRACE_9 0x0000100
#define FCP_LUN_TRACE_10 0x0000200
#define FCP_LUN_TRACE_11 0x0000400
#define FCP_LUN_TRACE_12 0x0000800
#define FCP_LUN_TRACE_13 0x0001000
#define FCP_LUN_TRACE_14 0x0002000
#define FCP_LUN_TRACE_15 0x0004000
#define FCP_LUN_TRACE_16 0x0008000
#define FCP_LUN_TRACE_17 0x0010000
#define FCP_LUN_TRACE_18 0x0020000
#define FCP_LUN_TRACE_19 0x0040000
#define FCP_LUN_TRACE_20 0x0080000
#define FCP_LUN_TRACE_21 0x0100000
#define FCP_LUN_TRACE_22 0x0200000
#define FCP_LUN_TRACE_23 0x0400000
#define FCP_LUN_TRACE_24 0x0800000
#define FCP_LUN_TRACE_25 0x1000000
#define FCP_LUN_TRACE_26 0x2000000
#define FCP_LUN_TRACE_27 0x4000000
#define FCP_LUN_TRACE_28 0x8000000
}\
}
#define FCP_LUN_CAP_RESET 0x01
/*
* Lun State -- these have the same values as the target states so
* that they can be interchanged (in cases where the same state occurs
* for both targets and luns)
*/
#define FCP_LUN_INIT FCP_TGT_INIT
#define FCP_LUN_BUSY FCP_TGT_BUSY
#define FCP_LUN_MARK FCP_TGT_MARK
#define FCP_LUN_OFFLINE FCP_TGT_OFFLINE
#define FCP_LUN_DISAPPEARED 0x40
/*
* Use the below flag with caution as it is can cause a delay in
* fcp_scsi_start() which is in the normal I/O performance path
*/
#define FCP_LUN_ONLINING 0x80
/*
* Set the below flag when the DTYPE or GUID of a LUN changes during discovery
*/
#define FCP_LUN_CHANGED 0x100
/*
* This flag is used specifically for the special lun: lun 0.
*/
#define FCP_LUN_DEVICE_NOT_CONNECTED 0x200
/*
* Report Lun Format
*/
struct fcp_reportlun_resp {
};
/*
* This structure actually represents a request executed by the hot plug task.
*/
struct fcp_hp_elem {
/*
* FCP port concerned by the request.
*/
/*
* LUN concerned by the request.
*/
/*
* dev_info_t or mdi_pathinfo_t pointer.
*/
/*
* lun_mpxio when the event is submitted
*/
int old_lun_mpxio;
/*
* What to do (offline, online...).
*/
int what;
/*
* FLags used when calling NDI fucntions.
*/
int flags;
/*
* Link state change count when the structure was created.
*/
int link_cnt;
/*
* Target state change count when the structure was created.
*/
int tgt_cnt;
/*
*/
int event_cnt;
/*
* This is the flag protected by the mutex and condition variable
* defined further in this structure. It is the flag indicating
* that the hot plug task is done with the treatment of the structure.
*/
int wait;
/*
* This is where the result of the request is returned when the sender
* waits for the completion.
*/
int result;
/*
* Condition variable used when wait is true.
*/
/*
* Mutex used in conjunction with the previous condition variable.
*/
};
struct fcp_reset_elem {
struct fcp_reset_elem *next;
};
/*
* This structure is used to offline targets. It is queued in the FCP port
* structure single linked list port_offline_tgts and walked by the watchdog
* timer.
*/
struct fcp_tgt_elem {
/*
* Points to the next element of the list.
*/
struct fcp_tgt_elem *next;
/*
* Points to the target to offline.
*/
/*
* Absolute time after which the target must be offlined.
*/
int time;
/*
* Link state change count when the structure was created.
*/
int link_cnt;
/*
* Target state change count when the structure was created.
*/
int tgt_cnt;
/*
* Flags providing information for the offline (when calling mdi or
* ndi).
*/
int flags;
};
/*
* This structure is used to offline LUNs. It is queued in the FCP port
* structure single linked list port_offline_luns and walked by the watchdog
* timer.
*/
struct fcp_lun_elem {
/*
* Points to the next element of the list.
*/
struct fcp_lun_elem *next;
/*
* Points to the LUN to offline.
*/
/*
* Absolute time after which the LUN must be offlined.
*/
int time;
/*
* Link state change count when the structure was created.
*/
int link_cnt;
/*
* Target state change count when the structure was created.
*/
int tgt_cnt;
/*
* Flags providing information for the offline (when calling mdi or
* ndi).
*/
int flags;
};
/*
* LUN masking
*/
typedef struct fcp_black_list_entry {
/*
* Points to the next element of the list.
*/
struct fcp_black_list_entry *next;
/*
* Port WWN of the target.
*/
/*
* LUN number which need to be masked.
*/
/*
* Counter of access times.
*/
int masked;
/*
* timeout values
*/
#define FCP_MAX_RETRIES 4
#if !defined(__lint)
#endif /* __lint */
(len), DDI_DEV_AUTOINCR))
(len), DDI_DEV_AUTOINCR))
#define FCP_ONLINE 0x1
#define FCP_OFFLINE 0x2
#define FCP_MPXIO_PATH_CLEAR_BUSY 0x3
#define FCP_MPXIO_PATH_SET_BUSY 0x4
#define FCP_IDLE 0x00
#define FCP_OPEN 0x01
#define FCP_EXCL 0x02
#define FCP_BUSY 0x04
#define LFA(x) (x & 0xFFFF00)
#define FCP_SET 1
#define FCP_RESET 0
/* init() and attach() wait timeout values (in usecs) */
#ifdef TRUE
#endif
#define TRUE 1
#ifdef FALSE
#endif
#define FALSE 0
#define UNDEFINED -1
/* for softstate */
#define FCP_INIT_ITEMS 5
#ifdef __cplusplus
}
#endif
#endif /* _FCPVAR_H */