pmcs.h revision 601c90f161ff0319c1b4a2c3362b466043a65d8d
/*
* 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.
*/
/*
* This file is the principle header file for the PMCS driver
*/
#ifndef _PMCS_H
#define _PMCS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/isa_defs.h>
#include <sys/mdi_impldefs.h>
#include <sys/byteorder.h>
#include <sys/sysmacros.h>
typedef struct pmcs_iport pmcs_iport_t;
typedef struct pmcs_phy pmcs_phy_t;
typedef struct lsas_cmd lsas_cmd_t;
typedef struct lsas_result lsas_result_t;
typedef struct lsata_cmd lsata_cmd_t;
typedef struct lsata_result lsata_result_t;
typedef struct pmcs_cmd pmcs_cmd_t;
typedef struct pmcs_xscsi pmcs_xscsi_t;
typedef struct pmcs_lun pmcs_lun_t;
typedef struct pmcs_chunk pmcs_chunk_t;
#define PMCS_MAX_UA_SIZE 32
struct pmcs_xscsi {
draining : 1,
new : 1,
assigned : 1,
dev_gone : 1,
dev_state : 4;
/* statlock protects both target stats and the special queue (sq) */
char unit_address[PMCS_MAX_UA_SIZE];
char *ua;
};
/*
* wq_recovery_tail in the pmcs_xscsi structure is a pointer to a command in
* the wait queue (wq). That pointer is the last command in the wait queue
* that needs to be reissued after device state recovery is complete. Commands
* that need to be retried are reinserted into the wq after wq_recovery_tail
* to maintain the order in which the commands were originally submitted.
*/
#define PMCS_TGT_WAIT_QUEUE 0x01
#define PMCS_TGT_ACTIVE_QUEUE 0x02
#define PMCS_TGT_SPECIAL_QUEUE 0x04
#define PMCS_TGT_ALL_QUEUES 0xff
/*
* LUN representation. Just a LUN (number) and pointer to the target
* structure (pmcs_xscsi).
*/
struct pmcs_lun {
char unit_address[PMCS_MAX_UA_SIZE];
};
/*
* Interrupt coalescing values
*/
#define PMCS_MAX_IO_COMPS_PER_INTR 12
#define PMCS_MAX_IO_COMPS_HIWAT_SHIFT 6
#define PMCS_MAX_IO_COMPS_LOWAT_SHIFT 10
#define PMCS_MAX_CQ_THREADS 4
/*
* This structure is used to maintain state with regard to I/O interrupt
* coalescing.
*/
typedef struct pmcs_io_intr_coal_s {
typedef struct pmcs_cq_thr_info_s {
typedef struct pmcs_cq_info_s {
typedef struct pmcs_iocomp_cb_s {
struct pmcs_iocomp_cb_s *next;
typedef struct pmcs_iqp_trace_s {
char *head;
char *curpos;
/*
* Used by string-based softstate as hint to possible size.
*/
#define PMCS_TGT_SSTATE_SZ 64
#define PMCS_LUN_SSTATE_SZ 4
/*
* HBA iport node softstate
*/
#define PMCS_IPORT_INVALID_PORT_ID 0xf
struct pmcs_iport {
int refcnt; /* refcnt for this iport */
enum { /* unit address state in the phymap */
} ua_state;
char *ua; /* unit address (phy mask) */
int portid; /* portid */
int report_skip; /* skip or report during discovery */
int nphy; /* number of phys in this port */
/* SMP serialization */
};
struct pmcs_chunk {
};
/*
* HBA node (i.e. non-iport) softstate
*/
struct pmcs_hw {
/*
* Identity
*/
/*
* 16 possible initiator PHY WWNs
*/
/*
* Card State
*/
enum pwpstate {
} state;
fw_disable_update : 1,
fw_force_update : 1,
blocked : 1,
stuck : 1,
locks_initted : 1,
mpi_table_setup : 1,
hba_attached : 1,
iports_attached : 1,
suspended : 1,
separate_ports : 1,
fwlog : 4,
phymode : 3,
physpeed : 3,
resource_limited : 1,
configuring : 1,
ds_err_recovering : 1;
/*
* This HBA instance's iportmap and list of iport states.
* Note: iports_lock protects iports, iports_attached, and
* num_iports on the HBA softstate.
*/
int num_iports;
int phymap_active;
/*
* Locks
*/
/*
* FMA Capabilities
*/
int fm_capabilities;
/*
* Register Access Handles
*/
/*
* DMA Handles
*/
/*
* Register Pointers
*/
/*
* Message Passing and other offsets.
*
* mpi_offset is the offset within the fourth register set (mpi_regs)
* that contains the base of the MPI structures. Since this is actually
* set by the card firmware, it can change from startup to startup.
*
* The other offsets (gst, iqc, oqc) are for similar tables in
* MPI space, typically only accessed during setup.
*/
/*
* Inbound and outbound queue depth
*/
/*
* Kernel addresses and offsets for Inbound Queue Producer Indices
*
* See comments in pmcs_iomb.h about Inbound Queues. Since it
* is relatively expensive to go across the PCIe bus to read or
* write inside the card, we maintain shadow copies in kernel
* memory and update the card as needed.
*/
/*
* Kernel addresses and offsets for Outbound Queue Consumer Indices
*/
/*
* Driver's copy of the outbound queue indices
*/
/*
* DMA addresses for both Inbound and Outbound queues.
*/
/*
*
* See discussion in pmcs_def.h about how this is laid out.
*/
/*
* Scratch area pointer and DMA addrress for SATA and SMP operations.
*/
void *scratch;
/*
* Firmware log pointer
*/
/*
* Internal register dump region and flash chunk DMA info
*/
/*
* Card information, some determined during MPI setup
*/
/*
* Interrupt Setup stuff.
*
* int_type defines the kind of interrupt we're using with this card.
* oqvec defines the relationship between an Outbound Queue Number and
* a MSI-X vector.
*/
enum {
} int_type;
/*
* Interrupt handle table and size
*/
int intr_cnt;
int intr_cap;
/*
* DMA S/G chunk list
*/
int nchunks;
/*
* Front of the DMA S/G chunk freelist
*/
/*
* PHY and Discovery Related Stuff
*
* The PMC chip can have up to 16 local phys. We build a level-first
* traversal tree of phys starting with the physical phys on the
* chip itself (i.e., treating the chip as if it were an expander).
*
* Our discovery process goes through a level and discovers what
* each entity is (and it's phy number within that expander's
* address space). It then configures each non-empty item (SAS,
* discover on that expander itself via REPORT GENERAL and
* DISCOVERY SMP commands, attaching the discovered entities
* to the next level. Then we step down a level and continue
* (and so on).
*
* The PMC chip maintains an I_T_NEXUS notion based upon our
* registering each new device found (getting back a device handle).
*
* Like with the number of physical PHYS being a maximum of 16,
* there are a maximum number of PORTS also being 16. Some
* events apply to PORTS entirely, so we track PORTS as well.
*/
/*
* Discovery-related items.
* config_lock: Protects config_changed and should never be held
* outside of getting or setting the value of config_changed.
* config_changed: Boolean indicating whether discovery needs to
* be restarted.
* configuring: 1 = discovery is running, 0 = discovery not running.
* NOTE: configuring is now in the bitfield above.
*/
volatile boolean_t config_changed;
/*
* Work Related Stuff
*
* Each command given to the PMC chip has an associated work structure.
* See the discussion in pmcs_def.h about work structures.
*/
/*
*/
/*
* Thread Level stuff.
*
* A number of tasks are done off worker thread taskq.
*/
volatile ulong_t work_flags;
/*
* Solaris target representation.
* targets = array of pointers to xscsi structures
* allocated by ssoftstate.
*/
#ifdef DEBUG
#endif
};
extern void *pmcs_softc_state;
extern void *pmcs_iport_softstate;
/*
* Some miscellaneous, oft used strings
*/
extern const char pmcs_nowrk[];
extern const char pmcs_nomsg[];
extern const char pmcs_timeo[];
#ifdef __cplusplus
}
#endif
#endif /* _PMCS_H */