/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Adaptec AAC series RAID controller driver * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> * * based on the old aacraid driver that is.. * Adaptec aacraid device driver for Linux. * * Copyright (c) 2000-2010 Adaptec, Inc. * 2010-2015 PMC-Sierra, Inc. (aacraid@pmc-sierra.com) * 2016-2017 Microsemi Corp. (aacraid@microsemi.com) * * Module Name: * aacraid.h * * Abstract: Contains all routines for control of the aacraid driver
*/
/*------------------------------------------------------------------------------ * D E F I N E S
*----------------------------------------------------------------------------*/
struct aac_hba_tm_req {
u8 iu_type; /* HBA information unit type */
u8 reply_qid; /* Host reply queue to post response to */
u8 tmf; /* Task management function */
u8 reserved1;
__le32 it_nexus; /* Device handle for the command */
u8 lun[8]; /* SCSI LUN */
/* Used to hold sender context. */
__le32 request_id; /* Sender context */
__le32 reserved2;
/* Request identifier of managed task */
__le32 managed_request_id; /* Sender context being managed */
__le32 reserved3;
/* Lower 32-bits of reserved error data target location on the host */
__le32 error_ptr_lo; /* Upper 32-bits of reserved error data target location on the host */
__le32 error_ptr_hi; /* Length of reserved error data area on the host in bytes */
__le32 error_length;
};
struct aac_hba_reset_req {
u8 iu_type; /* HBA information unit type */ /* 0 - reset specified device, 1 - reset all devices */
u8 reset_type;
u8 reply_qid; /* Host reply queue to post response to */
u8 reserved1;
__le32 it_nexus; /* Device handle for the command */
__le32 request_id; /* Sender context */ /* Lower 32-bits of reserved error data target location on the host */
__le32 error_ptr_lo; /* Upper 32-bits of reserved error data target location on the host */
__le32 error_ptr_hi; /* Length of reserved error data area on the host in bytes */
__le32 error_length;
};
struct aac_hba_resp {
u8 iu_type; /* HBA information unit type */
u8 reserved1[3];
__le32 request_identifier; /* sender context */
__le32 reserved2;
u8 service_response; /* SCSI service response */
u8 status; /* SCSI status */
u8 datapres; /* [1:0] - data present, [7:2] - reserved */
u8 sense_response_data_len; /* Sense/response data length */
__le32 residual_count; /* Residual data length in bytes */ /* Sense/response data */
u8 sense_response_buf[HBA_SENSE_DATA_LEN_MAX];
};
/* * These macros are for keeping track of * character device state.
*/ #define AAC_CHARDEV_UNREGISTERED (-1) #define AAC_CHARDEV_NEEDS_REINIT (-2)
/* #define AAC_DETAILED_STATUS_INFO */
struct diskparm
{ int heads; int sectors; int cylinders;
};
/* * Firmware constants
*/
#define CT_NONE 0 #define CT_OK 218 #define FT_FILESYS 8 /* ADAPTEC's "FSA"(tm) filesystem */ #define FT_DRIVE 9 /* physical disk - addressable in scsi by bus/id/lun */
/* * Host side memory scatter gather list * Used by the adapter for read, write, and readdirplus operations * We have separate 32 and 64 bit version because even * on 64 bit systems not all cards support the 64 bit version
*/ struct sgentry {
__le32 addr; /* 32-bit address. */
__le32 count; /* Length. */
};
/* * Define all the constants needed for the communication interface
*/
/* * Define how many queue entries each queue will have and the total * number of entries for the entire communication interface. Also define * how many queues we support. * * This has to match the controller
*/
/* * The queue headers define the Communication Region queues. These * are physically contiguous and accessible by both the adapter and the * host. Even though all queue headers are in the same contiguous block * they will be represented as individual units in the data structures.
*/
struct aac_entry {
__le32 size; /* Size in bytes of Fib which this QE points to */
__le32 addr; /* Receiver address of the FIB */
};
/* * The adapter assumes the ProducerIndex and ConsumerIndex are grouped * adjacently and in that order.
*/
struct aac_qhdr {
__le64 header_addr;/* Address to hand the adapter to access
to this queue head */
__le32 *producer; /* The producer index for this queue (host address) */
__le32 *consumer; /* The consumer index for this queue (host address) */
};
/* * Define all the events which the adapter would like to notify * the host of.
*/
#define HostNormCmdQue 1 /* Change in host normal priority command queue */ #define HostHighCmdQue 2 /* Change in host high priority command queue */ #define HostNormRespQue 3 /* Change in host normal priority response queue */ #define HostHighRespQue 4 /* Change in host high priority response queue */ #define AdapNormRespNotFull 5 #define AdapHighRespNotFull 6 #define AdapNormCmdNotFull 7 #define AdapHighCmdNotFull 8 #define SynchCommandComplete 9 #define AdapInternalError 0xfe /* The adapter detected an internal error shutting down */
/* * Define all the events the host wishes to notify the * adapter of. The first four values much match the Qid the * corresponding queue.
*/
/* * Define the FIB. The FIB is the where all the requested data and * command information are put to the application on the FSA adapter.
*/
struct aac_fibhdr {
__le32 XferState; /* Current transfer state for this CCB */
__le16 Command; /* Routing information for the destination */
u8 StructType; /* Type FIB */
u8 Unused; /* Unused */
__le16 Size; /* Size of this FIB in bytes */
__le16 SenderSize; /* Size of the FIB in the sender
(for response sizing) */
__le32 SenderFibAddress; /* Host defined data in the FIB */ union {
__le32 ReceiverFibAddress;/* Logical address of this FIB for
the adapter (old) */
__le32 SenderFibAddressHigh;/* upper 32bit of phys. FIB address */
__le32 TimeStamp; /* otherwise timestamp for FW internal use */
} u;
__le32 Handle; /* FIB handle used for MSGU commnunication */
u32 Previous; /* FW internal use */
u32 Next; /* FW internal use */
};
struct hw_fib { struct aac_fibhdr header;
u8 data[512-sizeof(struct aac_fibhdr)]; // Command specific data
};
/* * Define which interrupt handler needs to be installed
*/
struct aac_driver_ident
{ int (*init)(struct aac_dev *dev); char * name; char * vname; char * model;
u16 channels; int quirks;
}; /* * Some adapter firmware needs communication memory * below 2gig. This tells the init function to set the * dma mask such that fib memory will be allocated where the * adapter firmware can get to it.
*/ #define AAC_QUIRK_31BIT 0x0001
/* * Some adapter firmware, when the raid card's cache is turned off, can not * split up scatter gathers in order to deal with the limits of the * underlying CHIM. This limit is 34 scatter gather elements.
*/ #define AAC_QUIRK_34SG 0x0002
/* * This adapter is a slave (no Firmware)
*/ #define AAC_QUIRK_SLAVE 0x0004
/* * This adapter is a master.
*/ #define AAC_QUIRK_MASTER 0x0008
/* * Some adapter firmware perform poorly when it must split up scatter gathers * in order to deal with the limits of the underlying CHIM. This limit in this * class of adapters is 17 scatter gather elements.
*/ #define AAC_QUIRK_17SG 0x0010
/* * Some adapter firmware does not support 64 bit scsi passthrough * commands.
*/ #define AAC_QUIRK_SCSI_32 0x0020
/* * SRC based adapters support the AifReqEvent functions
*/ #define AAC_QUIRK_SRC 0x0040
/* * The adapter interface specs all queues to be located in the same * physically contiguous block. The host structure that defines the * commuication queues will assume they are each a separate physically * contiguous memory region that will support them all being one big * contiguous block. * There is a command and response queue for each level and direction of * commuication. These regions are accessed by both the host and adapter.
*/
struct aac_queue {
u64 logical; /*address we give the adapter */ struct aac_entry *base; /*system virtual address */ struct aac_qhdr headers; /*producer,consumer q headers*/
u32 entries; /*Number of queue entries */
wait_queue_head_t qfull; /*Event to wait on if q full */
wait_queue_head_t cmdready; /*Cmd ready from the adapter */ /* This is only valid for adapter to host command queues. */
spinlock_t *lock; /* Spinlock for this queue must take this lock before accessing the lock */
spinlock_t lockdata; /* Actual lock (used only on one side of the lock) */ struct list_head cmdq; /* A queue of FIBs which need to be prcessed by the FS thread. This is */ /* only valid for command queues which receive entries from the adapter. */ /* Number of entries on outstanding queue. */
atomic_t numpending; struct aac_dev * dev; /* Back pointer to adapter structure */
};
/* * Message queues. The order here is important, see also the * queue type ordering
*/
struct aac_fib_context {
s16 type; // used for verification of structure
s16 size;
u32 unique; // unique value representing this context
ulong jiffies; // used for cleanup - dmb changed to ulong struct list_head next; // used to link context's into a linked list struct completion completion; // this is used to wait for the next fib to arrive. int wait; // Set to true when thread is in WaitForSingleObject unsignedlong count; // total number of FIBs on FibList struct list_head fib_list; // this holds fibs and their attachd hw_fibs
};
struct sense_data {
u8 error_code; /* 70h (current errors), 71h(deferred errors) */
u8 valid:1; /* A valid bit of one indicates that the information */ /* field contains valid information as defined in the * SCSI-2 Standard.
*/
u8 segment_number; /* Only used for COPY, COMPARE, or COPY AND VERIFY Commands */
u8 sense_key:4; /* Sense Key */
u8 reserved:1;
u8 ILI:1; /* Incorrect Length Indicator */
u8 EOM:1; /* End Of Medium - reserved for random access devices */
u8 filemark:1; /* Filemark - reserved for random access devices */
u8 information[4]; /* for direct-access devices, contains the unsigned * logical block address or residue associated with * the sense key
*/
u8 add_sense_len; /* number of additional sense bytes to follow this field */
u8 cmnd_info[4]; /* not used */
u8 ASC; /* Additional Sense Code */
u8 ASCQ; /* Additional Sense Code Qualifier */
u8 FRUC; /* Field Replaceable Unit Code - not used */
u8 bit_ptr:3; /* indicates which byte of the CDB or parameter data * was in error
*/
u8 BPV:1; /* bit pointer valid (BPV): 1- indicates that * the bit_ptr field has valid value
*/
u8 reserved2:2;
u8 CD:1; /* command data bit: 1- illegal parameter in CDB. * 0- illegal parameter in data.
*/
u8 SKSV:1;
u8 field_ptr[2]; /* byte of the CDB or parameter data in error */
};
struct fib { void *next; /* this is used by the allocator */
s16 type;
s16 size; /* * The Adapter that this I/O is destined for.
*/ struct aac_dev *dev; /* * This is the event the sendfib routine will wait on if the * caller did not pass one and this is synch io.
*/ struct completion event_wait;
spinlock_t event_lock;
u32 done; /* gets set to 1 when fib is complete */
fib_callback callback; void *callback_data;
u32 flags; // u32 dmb was ulong /* * And for the internal issue/reply queues (we may be able * to merge these two)
*/ struct list_head fiblink; void *data;
u32 vector_no; struct hw_fib *hw_fib_va; /* also used for native */
dma_addr_t hw_fib_pa; /* physical address of hw_fib*/
dma_addr_t hw_sgl_pa; /* extra sgl for native */
dma_addr_t hw_error_pa; /* error buffer for native */
u32 hbacmd_size; /* cmd size for native */
};
unsignedint max_cmd_size; /* max_fib_size or MAX_NATIVE */
/* * Map for 128 fib objects (64k)
*/
dma_addr_t hw_fib_pa; /* also used for native cmd */ struct hw_fib *hw_fib_va; /* also used for native cmd */ struct hw_fib *aif_base_va; /* * Fib Headers
*/ struct fib *fibs;
struct fib *free_fib;
spinlock_t fib_lock;
struct mutex ioctl_mutex; struct mutex scan_mutex; struct aac_queue_block *queues; /* * The user API will use an IOCTL to register itself to receive * FIBs from the adapter. The following list is used to keep * track of all the threads that have requested these FIBs. The * mutex is used to synchronize access to all data associated * with the adapter fibs.
*/ struct list_head fib_list;
struct adapter_ops a_ops; unsignedlong fsrev; /* Main driver's revision number */
resource_size_t base_start; /* main IO base */
resource_size_t dbg_base; /* address of UART
* debug buffer */
resource_size_t base_size, dbg_size; /* Size of
* mapped in region */ /* * Holds initialization info * to communicate with adapter
*/ union aac_init *init;
dma_addr_t init_pa; /* Holds physical address of the init struct */ /* response queue (if AAC_COMM_MESSAGE_TYPE1) */
__le32 *host_rrq;
dma_addr_t host_rrq_pa; /* phys. address */ /* index into rrq buffer */
u32 host_rrq_idx[AAC_MAX_MSIX];
atomic_t rrq_outstanding[AAC_MAX_MSIX];
u32 fibs_pushed_no; struct pci_dev *pdev; /* Our PCI interface */ /* pointer to buffer used for printf's from the adapter */ void *printfbuf; void *comm_addr; /* Base address of Comm area */
dma_addr_t comm_phys; /* Physical Address of Comm area */
size_t comm_size;
struct Scsi_Host *scsi_host_ptr; int maximum_num_containers; int maximum_num_physicals; int maximum_num_channels; struct fsa_dev_info *fsa_dev; struct task_struct *thread; struct delayed_work safw_rescan_work; struct delayed_work src_reinit_aif_worker; int cardtype; /* *This lock will protect the two 32-bit *writes to the Inbound Queue
*/
spinlock_t iq_lock;
/* * The following is the device specific extension.
*/ #ifndef AAC_MIN_FOOTPRINT_SIZE # define AAC_MIN_FOOTPRINT_SIZE 8192 # define AAC_MIN_SRC_BAR0_SIZE 0x400000 # define AAC_MIN_SRC_BAR1_SIZE 0x800 # define AAC_MIN_SRCV_BAR0_SIZE 0x100000 # define AAC_MIN_SRCV_BAR1_SIZE 0x400 #endif union
{ struct sa_registers __iomem *sa; struct rx_registers __iomem *rx; struct rkt_registers __iomem *rkt; struct { struct src_registers __iomem *bar0; char __iomem *bar1;
} src;
} regs; volatilevoid __iomem *base, *dbg_base_mapped; volatilestruct rx_inbound __iomem *IndexRegs;
u32 OIMR; /* Mask Register Cache */ /* * AIF thread states
*/
u32 aif_thread; struct aac_adapter_info adapter_info; struct aac_supplement_adapter_info supplement_adapter_info; /* These are in adapter info but they are in the io flow so * lets break them out so we don't have to do an AND to check them
*/
u8 nondasd_support;
u8 jbod;
u8 cache_protected;
u8 dac_support;
u8 needs_dac;
u8 raid_scsi_mode;
u8 comm_interface;
u8 raw_io_interface;
u8 raw_io_64;
u8 printf_enabled;
u8 in_reset;
u8 in_soft_reset;
u8 msi;
u8 sa_firmware; int management_fib_count;
spinlock_t manage_lock;
spinlock_t sync_lock; int sync_mode; struct fib *sync_fib; struct list_head sync_fib_list;
u32 doorbell_mask;
u32 max_msix; /* max. MSI-X vectors */
u32 vector_cap; /* MSI-X vector capab.*/ int msi_enabled; /* MSI/MSI-X enabled */
atomic_t msix_counter;
u32 scan_counter; struct msix_entry msixentry[AAC_MAX_MSIX]; struct aac_msix_ctx aac_msix[AAC_MAX_MSIX]; /* context */ struct aac_hba_map_info hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS]; struct aac_ciss_phys_luns_resp *safw_phys_luns;
u8 adapter_shutdown;
u32 handle_pci_error; bool init_reset;
u8 soft_reset_support;
};
struct aac_read
{
__le32 command;
__le32 cid;
__le32 block;
__le32 count; struct sgmap sg; // Must be last in struct because it is variable
};
struct aac_read64
{
__le32 command;
__le16 cid;
__le16 sector_count;
__le32 block;
__le16 pad;
__le16 flags; struct sgmap64 sg; // Must be last in struct because it is variable
};
struct aac_write
{
__le32 command;
__le32 cid;
__le32 block;
__le32 count;
__le32 stable; // Not used struct sgmap sg; // Must be last in struct because it is variable
};
struct aac_write64
{
__le32 command;
__le16 cid;
__le16 sector_count;
__le32 block;
__le16 pad;
__le16 flags; struct sgmap64 sg; // Must be last in struct because it is variable
}; struct aac_write_reply
{
__le32 status;
__le32 count;
__le32 committed;
};
struct aac_raw_io
{
__le32 block[2];
__le32 count;
__le16 cid;
__le16 flags; /* 00 W, 01 R */
__le16 bpTotal; /* reserved for F/W use */
__le16 bpComplete; /* reserved for F/W use */ struct sgmapraw sg;
};
struct aac_raw_io2 {
__le32 blockLow;
__le32 blockHigh;
__le32 byteCount;
__le16 cid;
__le16 flags; /* RIO2 flags */
__le32 sgeFirstSize; /* size of first sge el. */
__le32 sgeNominalSize; /* size of 2nd sge el. (if conformant) */
u8 sgeCnt; /* only 8 bits required */
u8 bpTotal; /* reserved for F/W use */
u8 bpComplete; /* reserved for F/W use */
u8 sgeFirstIndex; /* reserved for F/W use */
u8 unused[4]; struct sge_ieee1212 sge[];
};
/* * This and associated data structs are used by the * ioctl caller and are in cpu order.
*/ struct user_aac_srb
{
u32 function;
u32 channel;
u32 id;
u32 lun;
u32 timeout;
u32 flags;
u32 count; // Data xfer size
u32 retry_limit;
u32 cdb_size;
u8 cdb[16]; struct user_sgmap sg;
};
#define AAC_SENSE_BUFFERSIZE 30
struct aac_srb_reply
{
__le32 status;
__le32 srb_status;
__le32 scsi_status;
__le32 data_xfer_length;
__le32 sense_data_size;
u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
};
#define MAX_VMCOMMAND_NUM 23 /* used for sizing stats array - leave last */
/* * Descriptive information (eg, vital stats) * that a content manager might report. The * FileArray filesystem component is one example * of a content manager. Raw mode might be * another.
*/
/* * Query for "mountable" objects, ie, objects that are typically * associated with a drive letter on the client (host) side.
*/
struct aac_mntent {
__le32 oid;
u8 name[16]; /* if applicable */ struct creation_info create_info; /* if applicable */
__le32 capacity;
__le32 vol; /* substrate structure */
__le32 obj; /* FT_FILESYS, etc. */
__le32 state; /* unready for mounting,
readonly, etc. */ union aac_contentinfo fileinfo; /* Info specific to content
manager (eg, filesystem) */
__le32 altoid; /* != oid <==> snapshot or
broken mirror exists */
__le32 capacityhigh;
};
#define FSCS_NOTCLEAN 0x0001 /* fsck is necessary before mounting */ #define FSCS_READONLY 0x0002 /* possible result of broken mirror */ #define FSCS_HIDDEN 0x0004 /* should be ignored - set during a clear */ #define FSCS_NOT_READY 0x0008 /* Array spinning up to fulfil request */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.