Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef __MEGARAID_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define __MEGARAID_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define MEGARAID_VERSION	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 	"v2.00.4 (Release Date: Thu Feb 9 08:51:30 EST 2006)\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Driver features - change the values to enable or disable features in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * Command coalescing - This feature allows the driver to be able to combine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * two or more commands and issue as one command in order to boost I/O
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * performance. Useful if the nature of the I/O is sequential. It is not very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * useful for random natured I/Os.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define MEGA_HAVE_COALESCING	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * Clustering support - Set this flag if you are planning to use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * clustering services provided by the megaraid controllers and planning to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * setup a cluster
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define MEGA_HAVE_CLUSTERING	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * Driver statistics - Set this flag if you are interested in statics about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * number of I/O completed on each logical drive and how many interrupts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * generated. If enabled, this information is available through /proc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * interface and through the private ioctl. Setting this flag has a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * performance penalty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define MEGA_HAVE_STATS		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  * Enhanced /proc interface - This feature will allow you to have a more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * detailed /proc interface for megaraid driver. E.g., a real time update of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * the status of the logical drives, battery status, physical drives etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define MEGA_HAVE_ENH_PROC	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #define MAX_DEV_TYPE	32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) #define PCI_DEVICE_ID_DISCOVERY		0x000E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #define PCI_DEVICE_ID_PERC4_DI		0x000F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define PCI_DEVICE_ID_PERC4_QC_VERDE	0x0407
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) #define HBA_SIGNATURE	      		0x3344
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define HBA_SIGNATURE_471	  	0xCCCC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) #define HBA_SIGNATURE_64BIT		0x0299
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define MBOX_BUSY_WAIT			10	/* wait for up to 10 usec for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 						   mailbox to be free */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) #define DEFAULT_INITIATOR_ID	7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) #define MAX_SGLIST		64	/* max supported in f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) #define MIN_SGLIST		26	/* guaranteed to support these many */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) #define MAX_COMMANDS		126
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) #define CMDID_INT_CMDS		MAX_COMMANDS+1	/* make sure CMDID_INT_CMDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 					 	is less than max commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 						supported by any f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) #define MAX_CDB_LEN	     	10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define MAX_EXT_CDB_LEN		16	/* we support cdb length up to 16 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define DEF_CMD_PER_LUN		63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) #define MAX_CMD_PER_LUN		MAX_COMMANDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #define MAX_FIRMWARE_STATUS	46
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) #define MAX_XFER_PER_CMD	(64*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) #define MAX_SECTORS_PER_IO	128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) #define MAX_LOGICAL_DRIVES_40LD		40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) #define FC_MAX_PHYSICAL_DEVICES		256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) #define MAX_LOGICAL_DRIVES_8LD		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) #define MAX_CHANNELS			5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) #define MAX_TARGET			15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) #define MAX_PHYSICAL_DRIVES		MAX_CHANNELS*MAX_TARGET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #define MAX_ROW_SIZE_40LD		32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) #define MAX_ROW_SIZE_8LD		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) #define MAX_SPAN_DEPTH			8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) #define NVIRT_CHAN		4	/* # of virtual channels to represent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 					   up to 60 logical drives */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) struct mbox_out {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* 0x0 */ u8 cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* 0x1 */ u8 cmdid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	/* 0x2 */ u16 numsectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	/* 0x4 */ u32 lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	/* 0x8 */ u32 xferaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/* 0xC */ u8 logdrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	/* 0xD */ u8 numsgelements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* 0xE */ u8 resvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct mbox_in {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	/* 0xF */ volatile u8 busy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	/* 0x10 */ volatile u8 numstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* 0x11 */ volatile u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	/* 0x12 */ volatile u8 completed[MAX_FIRMWARE_STATUS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	volatile u8 poll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	volatile u8 ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct mbox_out	m_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct mbox_in	m_in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) } __attribute__ ((packed)) mbox_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	u32 xfer_segment_lo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	u32 xfer_segment_hi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	mbox_t mbox;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) } __attribute__ ((packed)) mbox64_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  * Passthru definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define MAX_REQ_SENSE_LEN       0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	u8 timeout:3;		/* 0=6sec/1=60sec/2=10min/3=3hrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	u8 ars:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	u8 reserved:3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	u8 islogical:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	u8 logdrv;		/* if islogical == 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	u8 channel;		/* if islogical == 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	u8 target;		/* if islogical == 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	u8 queuetag;		/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	u8 queueaction;		/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	u8 cdb[MAX_CDB_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	u8 cdblen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	u8 reqsenselen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	u8 reqsensearea[MAX_REQ_SENSE_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	u8 numsgelements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	u8 scsistatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	u32 dataxferaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	u32 dataxferlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) } __attribute__ ((packed)) mega_passthru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * Extended passthru: support CDB > 10 bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	u8 timeout:3;		/* 0=6sec/1=60sec/2=10min/3=3hrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	u8 ars:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	u8 rsvd1:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	u8 cd_rom:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	u8 rsvd2:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	u8 islogical:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	u8 logdrv;		/* if islogical == 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	u8 channel;		/* if islogical == 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	u8 target;		/* if islogical == 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	u8 queuetag;		/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	u8 queueaction;		/* unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	u8 cdblen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	u8 rsvd3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	u8 cdb[MAX_EXT_CDB_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	u8 numsgelements;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	u8 reqsenselen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	u8 reqsensearea[MAX_REQ_SENSE_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	u8 rsvd4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	u32 dataxferaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	u32 dataxferlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) } __attribute__ ((packed)) mega_ext_passthru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	u64 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) } __attribute__ ((packed)) mega_sgl64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	u32 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) } __attribute__ ((packed)) mega_sglist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /* Queued command data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	int	idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	u32	state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	u8	raw_mbox[66];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	u32	dma_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	u32	dma_direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	struct scsi_cmnd	*cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	dma_addr_t	dma_h_bulkdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	dma_addr_t	dma_h_sgdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	mega_sglist	*sgl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	mega_sgl64	*sgl64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	dma_addr_t	sgl_dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	mega_passthru		*pthru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	dma_addr_t		pthru_dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	mega_ext_passthru	*epthru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	dma_addr_t		epthru_dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) } scb_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * Flags to follow the scb as it transitions between various stages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #define SCB_FREE	0x0000	/* on the free list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) #define SCB_ACTIVE	0x0001	/* off the free list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define SCB_PENDQ	0x0002	/* on the pending queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) #define SCB_ISSUED	0x0004	/* issued - owner f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) #define SCB_ABORT	0x0008	/* Got an abort for this one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define SCB_RESET	0x0010	/* Got a reset for this one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  * Utilities declare this strcture size as 1024 bytes. So more fields can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * be added in future.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	u32	data_size; /* current size in bytes (not including resvd) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	u32	config_signature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		/* Current value is 0x00282008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		 * 0x28=MAX_LOGICAL_DRIVES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		 * 0x20=Number of stripes and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		 * 0x08=Number of spans */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	u8	fw_version[16];		/* printable ASCI string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	u8	bios_version[16];	/* printable ASCI string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	u8	product_name[80];	/* printable ASCI string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	u8	max_commands;		/* Max. concurrent commands supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	u8	nchannels;		/* Number of SCSI Channels detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	u8	fc_loop_present;	/* Number of Fibre Loops detected */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	u8	mem_type;		/* EDO, FPM, SDRAM etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	u32	signature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	u16	dram_size;		/* In terms of MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	u16	subsysid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	u16	subsysvid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	u8	notify_counters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	u8	pad1k[889];		/* 135 + 889 resvd = 1024 total size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) } __attribute__ ((packed)) mega_product_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct notify {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	u32 global_counter;	/* Any change increments this counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	u8 param_counter;	/* Indicates any params changed  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	u8 param_id;		/* Param modified - defined below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	u16 param_val;		/* New val of last param modified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	u8 write_config_counter;	/* write config occurred */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	u8 write_config_rsvd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	u8 ldrv_op_counter;	/* Indicates ldrv op started/completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	u8 ldrv_opid;		/* ldrv num */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	u8 ldrv_opcmd;		/* ldrv operation - defined below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	u8 ldrv_opstatus;	/* status of the operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	u8 ldrv_state_counter;	/* Indicates change of ldrv state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	u8 ldrv_state_id;		/* ldrv num */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	u8 ldrv_state_new;	/* New state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	u8 ldrv_state_old;	/* old state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	u8 pdrv_state_counter;	/* Indicates change of ldrv state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	u8 pdrv_state_id;		/* pdrv id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	u8 pdrv_state_new;	/* New state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	u8 pdrv_state_old;	/* old state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	u8 pdrv_fmt_counter;	/* Indicates pdrv format started/over */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	u8 pdrv_fmt_id;		/* pdrv id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	u8 pdrv_fmt_val;		/* format started/over */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	u8 pdrv_fmt_rsvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	u8 targ_xfer_counter;	/* Indicates SCSI-2 Xfer rate change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	u8 targ_xfer_id;	/* pdrv Id  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	u8 targ_xfer_val;		/* new Xfer params of last pdrv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	u8 targ_xfer_rsvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	u8 fcloop_id_chg_counter;	/* Indicates loopid changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	u8 fcloopid_pdrvid;		/* pdrv id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	u8 fcloop_id0;			/* loopid on fc loop 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	u8 fcloop_id1;			/* loopid on fc loop 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	u8 fcloop_state_counter;	/* Indicates loop state changed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	u8 fcloop_state0;		/* state of fc loop 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	u8 fcloop_state1;		/* state of fc loop 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	u8 fcloop_state_rsvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) #define MAX_NOTIFY_SIZE     0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #define CUR_NOTIFY_SIZE     sizeof(struct notify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	u32	data_size; /* current size in bytes (not including resvd) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	struct notify notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	u8	notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	u8	rebuild_rate;		/* Rebuild rate (0% - 100%) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	u8	cache_flush_interval;	/* In terms of Seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	u8	sense_alert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	u8	drive_insert_count;	/* drive insertion count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	u8	battery_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	u8	num_ldrv;		/* No. of Log Drives configured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	u8	recon_state[MAX_LOGICAL_DRIVES_40LD / 8];	/* State of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 							   reconstruct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	u16	ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8]; /* logdrv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 								 Status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	u32	ldrv_size[MAX_LOGICAL_DRIVES_40LD];/* Size of each log drv */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	u8	ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	u8	ldrv_state[MAX_LOGICAL_DRIVES_40LD];/* State of log drives */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	u8	pdrv_state[FC_MAX_PHYSICAL_DEVICES];/* State of phys drvs. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	u16	pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	u8	targ_xfer[80];	/* phys device transfer rate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	u8	pad1k[263];	/* 761 + 263reserved = 1024 bytes total size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) } __attribute__ ((packed)) mega_inquiry3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /* Structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	u8	max_commands;	/* Max concurrent commands supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	u8	rebuild_rate;	/* Rebuild rate - 0% thru 100% */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	u8	max_targ_per_chan;	/* Max targ per channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	u8	nchannels;	/* Number of channels on HBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	u8	fw_version[4];	/* Firmware version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	u16	age_of_flash;	/* Number of times FW has been flashed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	u8	chip_set_value;	/* Contents of 0xC0000832 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	u8	dram_size;	/* In MB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	u8	cache_flush_interval;	/* in seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	u8	bios_version[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	u8	board_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	u8	sense_alert;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	u8	write_config_count;	/* Increase with every configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 					   change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	u8	drive_inserted_count;	/* Increase with every drive inserted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	u8	inserted_drive;	/* Channel:Id of inserted drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	u8	battery_status;	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 				 * BIT 0: battery module missing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 				 * BIT 1: VBAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 				 * BIT 2: temperature high
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 				 * BIT 3: battery pack missing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 				 * BIT 4,5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 				 *   00 - charge complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 				 *   01 - fast charge in progress
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 				 *   10 - fast charge fail
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				 *   11 - undefined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 				 * Bit 6: counter > 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 				 * Bit 7: Undefined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	u8	dec_fault_bus_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) } __attribute__ ((packed)) mega_adp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	u8	num_ldrv;	/* Number of logical drives configured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	u8	rsvd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	u32	ldrv_size[MAX_LOGICAL_DRIVES_8LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	u8	ldrv_prop[MAX_LOGICAL_DRIVES_8LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	u8	ldrv_state[MAX_LOGICAL_DRIVES_8LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) } __attribute__ ((packed)) mega_ldrv_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	u8	pdrv_state[MAX_PHYSICAL_DRIVES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	u8	rsvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) } __attribute__ ((packed)) mega_pdrv_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /* RAID inquiry: Mailbox command 0x05*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	mega_adp_info	adapter_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	mega_ldrv_info	logdrv_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	mega_pdrv_info	pdrv_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) } __attribute__ ((packed)) mraid_inquiry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /* RAID extended inquiry: Mailbox command 0x04*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	mraid_inquiry	raid_inq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	u16	phys_drv_format[MAX_CHANNELS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	u8	stack_attn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	u8	modem_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	u8	rsvd[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) } __attribute__ ((packed)) mraid_ext_inquiry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	u8	channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	u8	target;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }__attribute__ ((packed)) adp_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	u32		start_blk;	/* starting block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	u32		num_blks;	/* # of blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	adp_device	device[MAX_ROW_SIZE_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }__attribute__ ((packed)) adp_span_40ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	u32		start_blk;	/* starting block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	u32		num_blks;	/* # of blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	adp_device	device[MAX_ROW_SIZE_8LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }__attribute__ ((packed)) adp_span_8ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	u8	span_depth;	/* Total # of spans */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	u8	level;		/* RAID level */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	u8	read_ahead;	/* read ahead, no read ahead, adaptive read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 				   ahead */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	u8	stripe_sz;	/* Encoded stripe size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	u8	status;		/* Status of the logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	u8	write_mode;	/* write mode, write_through/write_back */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	u8	direct_io;	/* direct io or through cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	u8	row_size;	/* Number of stripes in a row */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) } __attribute__ ((packed)) logdrv_param;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	logdrv_param	lparam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	adp_span_40ld	span[MAX_SPAN_DEPTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) }__attribute__ ((packed)) logdrv_40ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	logdrv_param	lparam;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	adp_span_8ld	span[MAX_SPAN_DEPTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }__attribute__ ((packed)) logdrv_8ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	u8	type;		/* Type of the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	u8	cur_status;	/* current status of the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	u8	tag_depth;	/* Level of tagging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	u8	sync_neg;	/* sync negotiation - ENABLE or DISABLE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	u32	size;		/* configurable size in terms of 512 byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 				   blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }__attribute__ ((packed)) phys_drv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	u8		nlog_drives;		/* number of logical drives */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	u8		resvd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	logdrv_40ld	ldrv[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	phys_drv	pdrv[MAX_PHYSICAL_DRIVES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }__attribute__ ((packed)) disk_array_40ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	u8		nlog_drives;	/* number of logical drives */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	u8		resvd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	logdrv_8ld	ldrv[MAX_LOGICAL_DRIVES_8LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	phys_drv	pdrv[MAX_PHYSICAL_DRIVES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) }__attribute__ ((packed)) disk_array_8ld;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)  * User ioctl structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)  * This structure will be used for Traditional Method ioctl interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)  * commands (0x80),Alternate Buffer Method (0x81) ioctl commands and the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)  * Driver ioctls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)  * The Driver ioctl interface handles the commands at the driver level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)  * without being sent to the card.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) /* system call imposed limit. Change accordingly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) #define IOCTL_MAX_DATALEN       4096
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) struct uioctl_t {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	u32 inlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	u32 outlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		u8 fca[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			u8 opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			u8 subopcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 			u16 adapno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) #if BITS_PER_LONG == 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 			u8 *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 			u8 pad[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) #if BITS_PER_LONG == 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 			u8 *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 			u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 		} __attribute__ ((packed)) fcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	} __attribute__ ((packed)) ui;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	u8 mbox[18];		/* 16 bytes + 2 status bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	mega_passthru pthru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) #if BITS_PER_LONG == 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	char __user *data;		/* buffer <= 4096 for 0x80 commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	char pad[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) #if BITS_PER_LONG == 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	char __user *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)  * struct mcontroller is used to pass information about the controllers in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)  * system. Its up to the application how to use the information. We are passing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)  * as much info about the cards as possible and useful. Before issuing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503)  * call to find information about the cards, the application needs to issue a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)  * ioctl first to find out the number of controllers in the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) #define MAX_CONTROLLERS 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) struct mcontroller {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 	u64 base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	u8 irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	u8 numldrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	u8 pcibus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	u16 pcidev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	u8 pcifun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	u16 pciid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	u16 pcivendor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	u8 pcislot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	u32 uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)  * mailbox structure used for internal commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	u8	cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 	u8	cmdid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	u8	opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	u8	subopcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	u32	lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	u32	xferaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	u8	logdrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	u8	rsvd[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	u8	numstatus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	u8	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) } __attribute__ ((packed)) megacmd_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)  * Defines for Driver IOCTL interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) #define MEGAIOC_MAGIC  	'm'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) #define MEGAIOC_QNADAP		'm'	/* Query # of adapters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) #define MEGAIOC_QDRVRVER	'e'	/* Query driver version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) #define MEGAIOC_QADAPINFO   	'g'	/* Query adapter information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) #define MKADAP(adapno)	  	(MEGAIOC_MAGIC << 8 | (adapno) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) #define GETADAP(mkadap)	 	( (mkadap) ^ MEGAIOC_MAGIC << 8 )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)  * Definition for the new ioctl interface (NIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)  * Vendor specific Group-7 commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) #define VENDOR_SPECIFIC_COMMANDS	0xE0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) #define MEGA_INTERNAL_CMD		VENDOR_SPECIFIC_COMMANDS + 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)  * The ioctl command. No other command shall be used for this interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) #define USCSICMD	VENDOR_SPECIFIC_COMMANDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)  * Data direction flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) #define UIOC_RD		0x00001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) #define UIOC_WR		0x00002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)  * ioctl opcodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) #define MBOX_CMD	0x00000	/* DCMD or passthru command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) #define GET_DRIVER_VER	0x10000	/* Get driver version */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) #define GET_N_ADAP	0x20000	/* Get number of adapters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) #define GET_ADAP_INFO	0x30000	/* Get information about a adapter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) #define GET_CAP		0x40000	/* Get ioctl capabilities */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) #define GET_STATS	0x50000	/* Get statistics, including error info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)  * The ioctl structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)  * MBOX macro converts a nitioctl_t structure to megacmd_t pointer and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)  * MBOX_P macro converts a nitioctl_t pointer to megacmd_t pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	char		signature[8];	/* Must contain "MEGANIT" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 	u32		opcode;		/* opcode for the command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	u32		adapno;		/* adapter number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 		u8	__raw_mbox[18];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 		void __user *__uaddr; /* xferaddr for non-mbox cmds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	}__ua;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) #define uioc_rmbox	__ua.__raw_mbox
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) #define MBOX(uioc)	((megacmd_t *)&((uioc).__ua.__raw_mbox[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) #define MBOX_P(uioc)	((megacmd_t __user *)&((uioc)->__ua.__raw_mbox[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) #define uioc_uaddr	__ua.__uaddr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	u32		xferlen;	/* xferlen for DCMD and non-mbox
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 					   commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 	u32		flags;		/* data direction flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) }nitioctl_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)  * I/O statistics for some applications like SNMP agent. The caller must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)  * provide the number of logical drives for which status should be reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	int	num_ldrv;	/* Number for logical drives for which the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 				   status should be reported. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	u32	nreads[MAX_LOGICAL_DRIVES_40LD];	/* number of reads for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 							each logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	u32	nreadblocks[MAX_LOGICAL_DRIVES_40LD];	/* number of blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 							read for each logical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 							drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	u32	nwrites[MAX_LOGICAL_DRIVES_40LD];	/* number of writes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 							for each logical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 							drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 	u32	nwriteblocks[MAX_LOGICAL_DRIVES_40LD];	/* number of blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 							writes for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 							logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	u32	rd_errors[MAX_LOGICAL_DRIVES_40LD];	/* number of read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 							   errors for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 							   logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	u32	wr_errors[MAX_LOGICAL_DRIVES_40LD];	/* number of write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 							   errors for each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 							   logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }megastat_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) struct private_bios_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	u8	geometry:4;	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 				 * bits 0-3 - BIOS geometry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 				 * 0x0001 - 1GB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 				 * 0x0010 - 2GB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 				 * 0x1000 - 8GB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 				 * Others values are invalid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 							 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	u8	unused:4;	/* bits 4-7 are unused */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	u8	boot_drv;	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 				 * logical drive set as boot drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 				 * 0..7 - for 8LD cards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) 				 * 0..39 - for 40LD cards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 	u8	rsvd[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) 	u16	cksum;	/* 0-(sum of first 13 bytes of this structure) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) } __attribute__ ((packed));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)  * Mailbox and firmware commands and subopcodes used in this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) #define MEGA_MBOXCMD_LREAD	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) #define MEGA_MBOXCMD_LWRITE	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) #define MEGA_MBOXCMD_PASSTHRU	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) #define MEGA_MBOXCMD_ADPEXTINQ	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) #define MEGA_MBOXCMD_ADAPTERINQ	0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) #define MEGA_MBOXCMD_LREAD64	0xA7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) #define MEGA_MBOXCMD_LWRITE64	0xA8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) #define MEGA_MBOXCMD_PASSTHRU64	0xC3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) #define MEGA_MBOXCMD_EXTPTHRU	0xE3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) #define MAIN_MISC_OPCODE	0xA4	/* f/w misc opcode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) #define GET_MAX_SG_SUPPORT	0x01	/* get max sg len supported by f/w */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) #define FC_NEW_CONFIG		0xA1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) #define NC_SUBOP_PRODUCT_INFO	0x0E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) #define NC_SUBOP_ENQUIRY3	0x0F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) #define ENQ3_GET_SOLICITED_FULL	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) #define OP_DCMD_READ_CONFIG	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) #define NEW_READ_CONFIG_8LD	0x67
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) #define READ_CONFIG_8LD		0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) #define FLUSH_ADAPTER		0x0A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) #define FLUSH_SYSTEM		0xFE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)  * Command for random deletion of logical drives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) #define	FC_DEL_LOGDRV		0xA4	/* f/w command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) #define	OP_SUP_DEL_LOGDRV	0x2A	/* is feature supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) #define OP_GET_LDID_MAP		0x18	/* get ldid and logdrv number map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) #define OP_DEL_LOGDRV		0x1C	/* delete logical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689)  * BIOS commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) #define IS_BIOS_ENABLED		0x62
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) #define GET_BIOS		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) #define CHNL_CLASS		0xA9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) #define GET_CHNL_CLASS		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) #define SET_CHNL_CLASS		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) #define CH_RAID			0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) #define CH_SCSI			0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) #define BIOS_PVT_DATA		0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) #define GET_BIOS_PVT_DATA	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)  * Commands to support clustering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) #define MEGA_GET_TARGET_ID	0x7D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) #define MEGA_CLUSTER_OP		0x70
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) #define MEGA_GET_CLUSTER_MODE	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #define MEGA_CLUSTER_CMD	0x6E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) #define MEGA_RESERVE_LD		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) #define MEGA_RELEASE_LD		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) #define MEGA_RESET_RESERVATIONS	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) #define MEGA_RESERVATION_STATUS	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) #define MEGA_RESERVE_PD		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #define MEGA_RELEASE_PD		0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718)  * Module battery status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) #define MEGA_BATT_MODULE_MISSING	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) #define MEGA_BATT_LOW_VOLTAGE		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) #define MEGA_BATT_TEMP_HIGH		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) #define MEGA_BATT_PACK_MISSING		0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) #define MEGA_BATT_CHARGE_MASK		0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) #define MEGA_BATT_CHARGE_DONE		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) #define MEGA_BATT_CHARGE_INPROG		0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) #define MEGA_BATT_CHARGE_FAIL		0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) #define MEGA_BATT_CYCLES_EXCEEDED	0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)  * Physical drive states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #define PDRV_UNCNF	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define PDRV_ONLINE	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) #define PDRV_FAILED	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) #define PDRV_RBLD	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) #define PDRV_HOTSPARE	6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)  * Raid logical drive states.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) #define RDRV_OFFLINE	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) #define RDRV_DEGRADED	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) #define RDRV_OPTIMAL	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) #define RDRV_DELETED	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)  * Read, write and cache policies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) #define NO_READ_AHEAD		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) #define READ_AHEAD		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) #define ADAP_READ_AHEAD		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) #define WRMODE_WRITE_THRU	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) #define WRMODE_WRITE_BACK	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) #define CACHED_IO		0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) #define DIRECT_IO		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) #define SCSI_LIST(scp) ((struct list_head *)(&(scp)->SCp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763)  * Each controller's soft state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 	int	this_id;	/* our id, may set to different than 7 if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 				   clustering is available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	u32	flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 	unsigned long		base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 	void __iomem		*mmio_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 	/* mbox64 with mbox not aligned on 16-byte boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 	mbox64_t	*una_mbox64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	dma_addr_t	una_mbox64_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 	volatile mbox64_t	*mbox64;/* ptr to 64-bit mailbox */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 	volatile mbox_t		*mbox;	/* ptr to standard mailbox */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 	dma_addr_t		mbox_dma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 	struct pci_dev	*dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	struct list_head	free_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 	struct list_head	pending_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 	struct list_head	completed_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	struct Scsi_Host	*host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) #define MEGA_BUFFER_SIZE (2*1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	u8		*mega_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	dma_addr_t	buf_dma_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	mega_product_info	product_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 	u8		max_cmds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	scb_t		*scb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	atomic_t	pend_cmds;	/* maintain a counter for pending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 					   commands in firmware */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) #if MEGA_HAVE_STATS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 	u32	nreads[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	u32	nreadblocks[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 	u32	nwrites[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 	u32	nwriteblocks[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 	u32	rd_errors[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	u32	wr_errors[MAX_LOGICAL_DRIVES_40LD];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	/* Host adapter parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 	u8	numldrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 	u8	fw_version[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 	u8	bios_version[7];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 	struct proc_dir_entry	*controller_proc_dir_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 	int	has_64bit_addr;		/* are we using 64-bit addressing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	int	support_ext_cdb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 	int	boot_ldrv_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 	int	boot_ldrv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 	int	boot_pdrv_enabled;	/* boot from physical drive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) 	int	boot_pdrv_ch;		/* boot physical drive channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 	int	boot_pdrv_tgt;		/* boot physical drive target */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) 	int	support_random_del;	/* Do we support random deletion of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 					   logdrvs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 	int	read_ldidmap;	/* set after logical drive deltion. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 				   logical drive number must be read from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 				   map */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	atomic_t	quiescent;	/* a stage reached when delete logical
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 					   drive needs to be done. Stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 					   sending requests to the hba till
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 					   delete operation is completed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 	spinlock_t	lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	u8	logdrv_chan[MAX_CHANNELS+NVIRT_CHAN]; /* logical drive are on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 							what channels. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 	int	mega_ch_class;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 	u8	sglen;	/* f/w supported scatter-gather list length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 	scb_t			int_scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) 	struct mutex		int_mtx;	/* To synchronize the internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 						commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 	int			int_status;	/* status of internal cmd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 	struct completion	int_waitq;	/* wait queue for internal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 						 cmds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 	int	has_cluster;	/* cluster support on this HBA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }adapter_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) struct mega_hbas {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) 	int is_bios_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 	adapter_t *hostdata_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863)  * For state flag. Do not use LSB(8 bits) which are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864)  * reserved for storing info about channels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) #define IN_ABORT	0x80000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) #define IN_RESET	0x40000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) #define BOARD_MEMMAP	0x20000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) #define BOARD_IOMAP	0x10000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) #define BOARD_40LD   	0x08000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) #define BOARD_64BIT	0x04000000L
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) #define INTR_VALID			0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) #define PCI_CONF_AMISIG			0xa0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) #define PCI_CONF_AMISIG64		0xa4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) #define MEGA_DMA_TYPE_NONE		0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) #define MEGA_BULK_DATA			0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) #define MEGA_SGLIST			0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)  * Parameters for the io-mapped controllers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) /* I/O Port offsets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) #define CMD_PORT	 	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) #define ACK_PORT	 	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) #define TOGGLE_PORT		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) #define INTR_PORT	  	0x0a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) #define MBOX_BUSY_PORT     	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) #define MBOX_PORT0	 	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) #define MBOX_PORT1	 	0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) #define MBOX_PORT2	 	0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) #define MBOX_PORT3	 	0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) #define ENABLE_MBOX_REGION 	0x0B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) /* I/O Port Values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) #define ISSUE_BYTE	 	0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) #define ACK_BYTE	   	0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) #define ENABLE_INTR_BYTE   	0xc0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) #define DISABLE_INTR_BYTE  	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) #define VALID_INTR_BYTE    	0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) #define MBOX_BUSY_BYTE     	0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) #define ENABLE_MBOX_BYTE   	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) /* Setup some port macros here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) #define issue_command(adapter)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) 		outb_p(ISSUE_BYTE, (adapter)->base + CMD_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) #define irq_state(adapter)	inb_p((adapter)->base + INTR_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) #define set_irq_state(adapter, value)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) 		outb_p((value), (adapter)->base + INTR_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) #define irq_ack(adapter)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) 		outb_p(ACK_BYTE, (adapter)->base + ACK_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) #define irq_enable(adapter)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) 	outb_p(ENABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) #define irq_disable(adapter)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) 	outb_p(DISABLE_INTR_BYTE, (adapter)->base + TOGGLE_PORT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)  * This is our SYSDEP area. All kernel specific detail should be placed here -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)  * as much as possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)  * End of SYSDEP area
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) const char *megaraid_info (struct Scsi_Host *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) static int mega_query_adapter(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) static int issue_scb(adapter_t *, scb_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) static int mega_setup_mailbox(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) static int megaraid_queue (struct Scsi_Host *, struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) static scb_t * mega_build_cmd(adapter_t *, struct scsi_cmnd *, int *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) static void __mega_runpendq(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) static int issue_scb_block(adapter_t *, u_char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) static irqreturn_t megaraid_isr_memmapped(int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) static irqreturn_t megaraid_isr_iomapped(int, void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) static void mega_free_scb(adapter_t *, scb_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) static int megaraid_abort(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) static int megaraid_reset(struct scsi_cmnd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static int megaraid_abort_and_reset(adapter_t *, struct scsi_cmnd *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) static int megaraid_biosparam(struct scsi_device *, struct block_device *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) 		sector_t, int []);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) static int mega_build_sglist (adapter_t *adapter, scb_t *scb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) 			      u32 *buffer, u32 *length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) static int __mega_busywait_mbox (adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) static void mega_rundoneq (adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) static void mega_cmd_done(adapter_t *, u8 [], int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) static inline void mega_free_sgl (adapter_t *adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) static void mega_8_to_40ld (mraid_inquiry *inquiry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) 		mega_inquiry3 *enquiry3, mega_product_info *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) static int megadev_open (struct inode *, struct file *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) static int megadev_ioctl (struct file *, unsigned int, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) static int mega_m_to_n(void __user *, nitioctl_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) static int mega_n_to_m(void __user *, megacmd_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) static int mega_init_scb (adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) static int mega_is_bios_enabled (adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) static void mega_create_proc_entry(int, struct proc_dir_entry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) static int mega_adapinq(adapter_t *, dma_addr_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) static int mega_internal_dev_inquiry(adapter_t *, u8, u8, dma_addr_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) static int mega_support_ext_cdb(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) static mega_passthru* mega_prepare_passthru(adapter_t *, scb_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) 		struct scsi_cmnd *, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) static mega_ext_passthru* mega_prepare_extpassthru(adapter_t *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) 		scb_t *, struct scsi_cmnd *, int, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) static void mega_enum_raid_scsi(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) static void mega_get_boot_drv(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) static int mega_support_random_del(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) static int mega_del_logdrv(adapter_t *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) static int mega_do_del_logdrv(adapter_t *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) static void mega_get_max_sgl(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) static int mega_internal_command(adapter_t *, megacmd_t *, mega_passthru *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) static int mega_support_cluster(adapter_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) /* vi: set ts=8 sw=8 tw=78: */