aacraid.h 77.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
/*
 *	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)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * Module Name:
 *  aacraid.h
 *
 * Abstract: Contains all routines for control of the aacraid driver
 *
 */

33 34
#ifndef _AACRAID_H_
#define _AACRAID_H_
35
#ifndef dprintk
L
Linus Torvalds 已提交
36 37
# define dprintk(x)
#endif
38 39 40 41
/* eg: if (nblank(dprintk(x))) */
#define _nblank(x) #x
#define nblank(x) _nblank(x)[0]

42
#include <linux/interrupt.h>
M
Mahesh Rajashekhara 已提交
43
#include <linux/pci.h>
44
#include <scsi/scsi_host.h>
L
Linus Torvalds 已提交
45 46 47 48 49

/*------------------------------------------------------------------------------
 *              D E F I N E S
 *----------------------------------------------------------------------------*/

50
#define AAC_MAX_MSIX		32	/* vectors */
M
Mahesh Rajashekhara 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
#define AAC_PCI_MSI_ENABLE	0x8000

enum {
	AAC_ENABLE_INTERRUPT	= 0x0,
	AAC_DISABLE_INTERRUPT,
	AAC_ENABLE_MSIX,
	AAC_DISABLE_MSIX,
	AAC_CLEAR_AIF_BIT,
	AAC_CLEAR_SYNC_BIT,
	AAC_ENABLE_INTX
};

#define AAC_INT_MODE_INTX		(1<<0)
#define AAC_INT_MODE_MSI		(1<<1)
#define AAC_INT_MODE_AIF		(1<<2)
#define AAC_INT_MODE_SYNC		(1<<3)
67
#define AAC_INT_MODE_MSIX		(1<<16)
M
Mahesh Rajashekhara 已提交
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

#define AAC_INT_ENABLE_TYPE1_INTX	0xfffffffb
#define AAC_INT_ENABLE_TYPE1_MSIX	0xfffffffa
#define AAC_INT_DISABLE_ALL		0xffffffff

/* Bit definitions in IOA->Host Interrupt Register */
#define PMC_TRANSITION_TO_OPERATIONAL	(1<<31)
#define PMC_IOARCB_TRANSFER_FAILED	(1<<28)
#define PMC_IOA_UNIT_CHECK		(1<<27)
#define PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE (1<<26)
#define PMC_CRITICAL_IOA_OP_IN_PROGRESS	(1<<25)
#define PMC_IOARRIN_LOST		(1<<4)
#define PMC_SYSTEM_BUS_MMIO_ERROR	(1<<3)
#define PMC_IOA_PROCESSOR_IN_ERROR_STATE (1<<2)
#define PMC_HOST_RRQ_VALID		(1<<1)
#define PMC_OPERATIONAL_STATUS		(1<<31)
#define PMC_ALLOW_MSIX_VECTOR0		(1<<0)

#define PMC_IOA_ERROR_INTERRUPTS	(PMC_IOARCB_TRANSFER_FAILED | \
					 PMC_IOA_UNIT_CHECK | \
					 PMC_NO_HOST_RRQ_FOR_CMD_RESPONSE | \
					 PMC_IOARRIN_LOST | \
					 PMC_SYSTEM_BUS_MMIO_ERROR | \
					 PMC_IOA_PROCESSOR_IN_ERROR_STATE)

#define PMC_ALL_INTERRUPT_BITS		(PMC_IOA_ERROR_INTERRUPTS | \
					 PMC_HOST_RRQ_VALID | \
					 PMC_TRANSITION_TO_OPERATIONAL | \
					 PMC_ALLOW_MSIX_VECTOR0)
#define	PMC_GLOBAL_INT_BIT2		0x00000004
#define	PMC_GLOBAL_INT_BIT0		0x00000001

100
#ifndef AAC_DRIVER_BUILD
101
# define AAC_DRIVER_BUILD 50877
102
# define AAC_DRIVER_BRANCH "-custom"
103
#endif
L
Linus Torvalds 已提交
104 105
#define MAXIMUM_NUM_CONTAINERS	32

106
#define AAC_NUM_MGT_FIB         8
107
#define AAC_NUM_IO_FIB		(1024 - AAC_NUM_MGT_FIB)
108
#define AAC_NUM_FIB		(AAC_NUM_IO_FIB + AAC_NUM_MGT_FIB)
L
Linus Torvalds 已提交
109

110
#define AAC_MAX_LUN		256
L
Linus Torvalds 已提交
111 112

#define AAC_MAX_HOSTPHYSMEMPAGES (0xfffff)
S
Salyzyn, Mark 已提交
113
#define AAC_MAX_32BIT_SGBCOUNT	((unsigned short)256)
L
Linus Torvalds 已提交
114

115 116
#define AAC_DEBUG_INSTRUMENT_AIF_DELETE

117 118 119 120
#define AAC_MAX_NATIVE_TARGETS		1024
/* Thor: 5 phys. buses: #0: empty, 1-4: 256 targets each */
#define AAC_MAX_BUSES			5
#define AAC_MAX_TARGETS		256
121
#define AAC_BUS_TARGET_LOOP		(AAC_MAX_BUSES * AAC_MAX_TARGETS)
122
#define AAC_MAX_NATIVE_SIZE		2048
123
#define FW_ERROR_BUFFER_SIZE		512
124

125 126 127
#define get_bus_number(x)	(x/AAC_MAX_TARGETS)
#define get_target_number(x)	(x%AAC_MAX_TARGETS)

128 129 130 131 132 133 134 135
/* Thor AIF events */
#define SA_AIF_HOTPLUG			(1<<1)
#define SA_AIF_HARDWARE		(1<<2)
#define SA_AIF_PDEV_CHANGE		(1<<4)
#define SA_AIF_LDEV_CHANGE		(1<<5)
#define SA_AIF_BPSTAT_CHANGE		(1<<30)
#define SA_AIF_BPCFG_CHANGE		(1<<31)

136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
#define HBA_MAX_SG_EMBEDDED		28
#define HBA_MAX_SG_SEPARATE		90
#define HBA_SENSE_DATA_LEN_MAX		32
#define HBA_REQUEST_TAG_ERROR_FLAG	0x00000002
#define HBA_SGL_FLAGS_EXT		0x80000000UL

struct aac_hba_sgl {
	u32		addr_lo; /* Lower 32-bits of SGL element address */
	u32		addr_hi; /* Upper 32-bits of SGL element address */
	u32		len;	/* Length of SGL element in bytes */
	u32		flags;	/* SGL element flags */
};

enum {
	HBA_IU_TYPE_SCSI_CMD_REQ		= 0x40,
	HBA_IU_TYPE_SCSI_TM_REQ			= 0x41,
	HBA_IU_TYPE_SATA_REQ			= 0x42,
	HBA_IU_TYPE_RESP			= 0x60,
	HBA_IU_TYPE_COALESCED_RESP		= 0x61,
	HBA_IU_TYPE_INT_COALESCING_CFG_REQ	= 0x70
};

enum {
	HBA_CMD_BYTE1_DATA_DIR_IN		= 0x1,
	HBA_CMD_BYTE1_DATA_DIR_OUT		= 0x2,
	HBA_CMD_BYTE1_DATA_TYPE_DDR		= 0x4,
	HBA_CMD_BYTE1_CRYPTO_ENABLE		= 0x8
};

enum {
	HBA_CMD_BYTE1_BITOFF_DATA_DIR_IN	= 0x0,
	HBA_CMD_BYTE1_BITOFF_DATA_DIR_OUT,
	HBA_CMD_BYTE1_BITOFF_DATA_TYPE_DDR,
	HBA_CMD_BYTE1_BITOFF_CRYPTO_ENABLE
};

enum {
	HBA_RESP_DATAPRES_NO_DATA		= 0x0,
	HBA_RESP_DATAPRES_RESPONSE_DATA,
	HBA_RESP_DATAPRES_SENSE_DATA
};

enum {
	HBA_RESP_SVCRES_TASK_COMPLETE		= 0x0,
	HBA_RESP_SVCRES_FAILURE,
	HBA_RESP_SVCRES_TMF_COMPLETE,
	HBA_RESP_SVCRES_TMF_SUCCEEDED,
	HBA_RESP_SVCRES_TMF_REJECTED,
	HBA_RESP_SVCRES_TMF_LUN_INVALID
};

enum {
	HBA_RESP_STAT_IO_ERROR			= 0x1,
	HBA_RESP_STAT_IO_ABORTED,
	HBA_RESP_STAT_NO_PATH_TO_DEVICE,
	HBA_RESP_STAT_INVALID_DEVICE,
	HBA_RESP_STAT_HBAMODE_DISABLED		= 0xE,
	HBA_RESP_STAT_UNDERRUN			= 0x51,
	HBA_RESP_STAT_OVERRUN			= 0x75
};

struct aac_hba_cmd_req {
	u8	iu_type;	/* HBA information unit type */
	/*
	 * byte1:
	 * [1:0] DIR - 0=No data, 0x1 = IN, 0x2 = OUT
	 * [2]   TYPE - 0=PCI, 1=DDR
	 * [3]   CRYPTO_ENABLE - 0=Crypto disabled, 1=Crypto enabled
	 */
	u8	byte1;
	u8	reply_qid;	/* Host reply queue to post response to */
	u8	reserved1;
	__le32	it_nexus;	/* Device handle for the request */
	__le32	request_id;	/* Sender context */
	/* Lower 32-bits of tweak value for crypto enabled IOs */
	__le32	tweak_value_lo;
	u8	cdb[16];	/* SCSI CDB of the command */
	u8	lun[8];		/* SCSI LUN of the command */

	/* Total data length in bytes to be read/written (if any) */
	__le32	data_length;

	/* [2:0] Task Attribute, [6:3] Command Priority */
	u8	attr_prio;

	/* Number of SGL elements embedded in the HBA req */
	u8	emb_data_desc_count;

	__le16	dek_index;	/* DEK index for crypto enabled IOs */

	/* 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;

	/* Upper 32-bits of tweak value for crypto enabled IOs */
	__le32	tweak_value_hi;

	struct aac_hba_sgl sge[HBA_MAX_SG_SEPARATE+2]; /* SG list space */

	/*
	 * structure must not exceed
	 * AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE
	 */
};

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
/* Task Management Functions (TMF) */
#define HBA_TMF_ABORT_TASK	0x01
#define HBA_TMF_LUN_RESET	0x08

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;
};

293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
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];
};

struct aac_native_hba {
	union {
		struct aac_hba_cmd_req cmd;
310
		struct aac_hba_tm_req tmr;
311 312 313 314 315 316 317 318
		u8 cmd_bytes[AAC_MAX_NATIVE_SIZE-FW_ERROR_BUFFER_SIZE];
	} cmd;
	union {
		struct aac_hba_resp err;
		u8 resp_bytes[FW_ERROR_BUFFER_SIZE];
	} resp;
};

319
#define CISS_REPORT_PHYSICAL_LUNS	0xc3
320
#define WRITE_HOST_WELLNESS		0xa5
321
#define CISS_IDENTIFY_PHYSICAL_DEVICE	0x15
322 323
#define BMIC_IN			0x26
#define BMIC_OUT			0x27
324 325 326 327 328 329 330 331 332 333 334 335 336 337

struct aac_ciss_phys_luns_resp {
	u8	list_length[4];		/* LUN list length (N-7, big endian) */
	u8	resp_flag;		/* extended response_flag */
	u8	reserved[3];
	struct _ciss_lun {
		u8	tid[3];		/* Target ID */
		u8	bus;		/* Bus, flag (bits 6,7) */
		u8	level3[2];
		u8	level2[2];
		u8	node_ident[16];	/* phys. node identifier */
	} lun[1];			/* List of phys. devices */
};

338 339 340 341 342
/*
 * Interrupts
 */
#define AAC_MAX_HRRQ		64

343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
struct aac_ciss_identify_pd {
	u8 scsi_bus;			/* SCSI Bus number on controller */
	u8 scsi_id;			/* SCSI ID on this bus */
	u16 block_size;			/* sector size in bytes */
	u32 total_blocks;		/* number for sectors on drive */
	u32 reserved_blocks;		/* controller reserved (RIS) */
	u8 model[40];			/* Physical Drive Model */
	u8 serial_number[40];		/* Drive Serial Number */
	u8 firmware_revision[8];	/* drive firmware revision */
	u8 scsi_inquiry_bits;		/* inquiry byte 7 bits */
	u8 compaq_drive_stamp;		/* 0 means drive not stamped */
	u8 last_failure_reason;

	u8  flags;
	u8  more_flags;
	u8  scsi_lun;			/* SCSI LUN for phys drive */
	u8  yet_more_flags;
	u8  even_more_flags;
	u32 spi_speed_rules;		/* SPI Speed :Ultra disable diagnose */
	u8  phys_connector[2];		/* connector number on controller */
	u8  phys_box_on_bus;		/* phys enclosure this drive resides */
	u8  phys_bay_in_box;		/* phys drv bay this drive resides */
	u32 rpm;			/* Drive rotational speed in rpm */
	u8  device_type;		/* type of drive */
	u8  sata_version;		/* only valid when drive_type is SATA */
	u64 big_total_block_count;
	u64 ris_starting_lba;
	u32 ris_size;
	u8  wwid[20];
	u8  controller_phy_map[32];
	u16 phy_count;
	u8  phy_connected_dev_type[256];
	u8  phy_to_drive_bay_num[256];
	u16 phy_to_attached_dev_index[256];
	u8  box_index;
	u8  spitfire_support;
	u16 extra_physical_drive_flags;
	u8  negotiated_link_rate[256];
	u8  phy_to_phy_map[256];
	u8  redundant_path_present_map;
	u8  redundant_path_failure_map;
	u8  active_path_number;
	u16 alternate_paths_phys_connector[8];
	u8  alternate_paths_phys_box_on_port[8];
	u8  multi_lun_device_lun_count;
	u8  minimum_good_fw_revision[8];
	u8  unique_inquiry_bytes[20];
	u8  current_temperature_degreesC;
	u8  temperature_threshold_degreesC;
	u8  max_temperature_degreesC;
	u8  logical_blocks_per_phys_block_exp;	/* phyblocksize = 512 * 2^exp */
	u16 current_queue_depth_limit;
	u8  switch_name[10];
	u16 switch_port;
	u8  alternate_paths_switch_name[40];
	u8  alternate_paths_switch_port[8];
	u16 power_on_hours;		/* valid only if gas gauge supported */
	u16 percent_endurance_used;	/* valid only if gas gauge supported. */
	u8  drive_authentication;
	u8  smart_carrier_authentication;
	u8  smart_carrier_app_fw_version;
	u8  smart_carrier_bootloader_fw_version;
	u8  SanitizeSecureEraseSupport;
	u8  DriveKeyFlags;
	u8  encryption_key_name[64];
	u32 misc_drive_flags;
	u16 dek_index;
	u16 drive_encryption_flags;
	u8  sanitize_maximum_time[6];
	u8  connector_info_mode;
	u8  connector_info_number[4];
	u8  long_connector_name[64];
	u8  device_unique_identifier[16];
	u8  padto_2K[17];
} __packed;

L
Linus Torvalds 已提交
419 420 421 422
/*
 * These macros convert from physical channels to virtual channels
 */
#define CONTAINER_CHANNEL		(0)
423
#define NATIVE_CHANNEL			(1)
L
Linus Torvalds 已提交
424 425 426
#define CONTAINER_TO_CHANNEL(cont)	(CONTAINER_CHANNEL)
#define CONTAINER_TO_ID(cont)		(cont)
#define CONTAINER_TO_LUN(cont)		(0)
427
#define ENCLOSURE_CHANNEL		(3)
L
Linus Torvalds 已提交
428

M
Mahesh Rajashekhara 已提交
429
#define PMC_DEVICE_S6	0x28b
430 431 432
#define PMC_DEVICE_S7	0x28c
#define PMC_DEVICE_S8	0x28d

433 434
#define aac_phys_to_logical(x)  ((x)+1)
#define aac_logical_to_phys(x)  ((x)?(x)-1:0)
L
Linus Torvalds 已提交
435

436 437 438 439 440 441 442
/*
 * These macros are for keeping track of
 * character device state.
 */
#define AAC_CHARDEV_UNREGISTERED	(-1)
#define AAC_CHARDEV_NEEDS_REINIT	(-2)

L
Linus Torvalds 已提交
443 444 445 446 447 448 449 450 451 452 453
/* #define AAC_DETAILED_STATUS_INFO */

struct diskparm
{
	int heads;
	int sectors;
	int cylinders;
};


/*
454
 *	Firmware constants
L
Linus Torvalds 已提交
455
 */
456

L
Linus Torvalds 已提交
457
#define		CT_NONE			0
458
#define		CT_OK			218
L
Linus Torvalds 已提交
459 460 461 462 463 464 465 466 467 468
#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 {
469 470 471 472 473
	__le32	addr;	/* 32-bit address. */
	__le32	count;	/* Length. */
};

struct user_sgentry {
L
Linus Torvalds 已提交
474 475 476 477 478
	u32	addr;	/* 32-bit address. */
	u32	count;	/* Length. */
};

struct sgentry64 {
479 480 481 482 483
	__le32	addr[2];	/* 64-bit addr. 2 pieces for data alignment */
	__le32	count;	/* Length. */
};

struct user_sgentry64 {
L
Linus Torvalds 已提交
484 485 486 487
	u32	addr[2];	/* 64-bit addr. 2 pieces for data alignment */
	u32	count;	/* Length. */
};

488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
struct sgentryraw {
	__le32		next;	/* reserved for F/W use */
	__le32		prev;	/* reserved for F/W use */
	__le32		addr[2];
	__le32		count;
	__le32		flags;	/* reserved for F/W use */
};

struct user_sgentryraw {
	u32		next;	/* reserved for F/W use */
	u32		prev;	/* reserved for F/W use */
	u32		addr[2];
	u32		count;
	u32		flags;	/* reserved for F/W use */
};

504 505 506 507 508 509 510
struct sge_ieee1212 {
	u32	addrLow;
	u32	addrHigh;
	u32	length;
	u32	flags;
};

L
Linus Torvalds 已提交
511 512 513 514 515 516 517 518
/*
 *	SGMAP
 *
 *	This is the SGMAP structure for all commands that use
 *	32-bit addressing.
 */

struct sgmap {
519
	__le32		count;
520
	struct sgentry	sg[1];
L
Linus Torvalds 已提交
521 522
};

523
struct user_sgmap {
L
Linus Torvalds 已提交
524
	u32		count;
525
	struct user_sgentry	sg[1];
526 527 528 529
};

struct sgmap64 {
	__le32		count;
L
Linus Torvalds 已提交
530 531 532
	struct sgentry64 sg[1];
};

533 534 535 536 537
struct user_sgmap64 {
	u32		count;
	struct user_sgentry64 sg[1];
};

538 539 540 541 542 543 544 545 546 547
struct sgmapraw {
	__le32		  count;
	struct sgentryraw sg[1];
};

struct user_sgmapraw {
	u32		  count;
	struct user_sgentryraw sg[1];
};

L
Linus Torvalds 已提交
548 549
struct creation_info
{
550 551 552 553
	u8		buildnum;		/* e.g., 588 */
	u8		usec;			/* e.g., 588 */
	u8		via;			/* e.g., 1 = FSU,
						 *	 2 = API
L
Linus Torvalds 已提交
554
						 */
555
	u8		year;			/* e.g., 1997 = 97 */
556
	__le32		date;			/*
557 558 559 560 561
						 * unsigned	Month		:4;	// 1 - 12
						 * unsigned	Day		:6;	// 1 - 32
						 * unsigned	Hour		:6;	// 0 - 23
						 * unsigned	Minute		:6;	// 0 - 60
						 * unsigned	Second		:6;	// 0 - 60
L
Linus Torvalds 已提交
562
						 */
563
	__le32		serial[2];			/* e.g., 0x1DEADB0BFAFAF001 */
L
Linus Torvalds 已提交
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596
};


/*
 *	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
 */

#define NUMBER_OF_COMM_QUEUES  8   // 4 command; 4 response
#define HOST_HIGH_CMD_ENTRIES  4
#define HOST_NORM_CMD_ENTRIES  8
#define ADAP_HIGH_CMD_ENTRIES  4
#define ADAP_NORM_CMD_ENTRIES  512
#define HOST_HIGH_RESP_ENTRIES 4
#define HOST_NORM_RESP_ENTRIES 512
#define ADAP_HIGH_RESP_ENTRIES 4
#define ADAP_NORM_RESP_ENTRIES 8

#define TOTAL_QUEUE_ENTRIES  \
    (HOST_NORM_CMD_ENTRIES + HOST_HIGH_CMD_ENTRIES + ADAP_NORM_CMD_ENTRIES + ADAP_HIGH_CMD_ENTRIES + \
	    HOST_NORM_RESP_ENTRIES + HOST_HIGH_RESP_ENTRIES + ADAP_NORM_RESP_ENTRIES + ADAP_HIGH_RESP_ENTRIES)


/*
 *	Set the queues on a 16 byte alignment
 */
597

L
Linus Torvalds 已提交
598 599 600 601 602 603 604 605 606 607
#define QUEUE_ALIGNMENT		16

/*
 *	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 {
608 609
	__le32 size; /* Size in bytes of Fib which this QE points to */
	__le32 addr; /* Receiver address of the FIB */
L
Linus Torvalds 已提交
610 611 612 613 614 615
};

/*
 *	The adapter assumes the ProducerIndex and ConsumerIndex are grouped
 *	adjacently and in that order.
 */
616

L
Linus Torvalds 已提交
617
struct aac_qhdr {
618
	__le64 header_addr;/* Address to hand the adapter to access
619 620 621
			      to this queue head */
	__le32 *producer; /* The producer index for this queue (host address) */
	__le32 *consumer; /* The consumer index for this queue (host address) */
L
Linus Torvalds 已提交
622 623 624 625 626 627
};

/*
 *	Define all the events which the adapter would like to notify
 *	the host of.
 */
628

L
Linus Torvalds 已提交
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
#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		AdapNormCmdQue		2
#define		AdapHighCmdQue		3
#define		AdapNormRespQue		6
#define		AdapHighRespQue		7
#define		HostShutdown		8
#define		HostPowerFail		9
#define		FatalCommError		10
#define		HostNormRespNotFull	11
#define		HostHighRespNotFull	12
#define		HostNormCmdNotFull	13
#define		HostHighCmdNotFull	14
#define		FastIo			15
#define		AdapPrintfDone		16

/*
 *	Define all the queues that the adapter and host use to communicate
 *	Number them to match the physical queue layout.
 */

enum aac_queue_types {
        HostNormCmdQueue = 0,	/* Adapter to host normal priority command traffic */
        HostHighCmdQueue,	/* Adapter to host high priority command traffic */
        AdapNormCmdQueue,	/* Host to adapter normal priority command traffic */
        AdapHighCmdQueue,	/* Host to adapter high priority command traffic */
        HostNormRespQueue,	/* Adapter to host normal priority response traffic */
        HostHighRespQueue,	/* Adapter to host high priority response traffic */
        AdapNormRespQueue,	/* Host to adapter normal priority response traffic */
        AdapHighRespQueue	/* Host to adapter high priority response traffic */
};

/*
 *	Assign type values to the FSA communication data structures
 */

#define		FIB_MAGIC	0x0001
681 682
#define		FIB_MAGIC2	0x0004
#define		FIB_MAGIC2_64	0x0005
L
Linus Torvalds 已提交
683 684 685 686 687 688 689

/*
 *	Define the priority levels the FSA communication routines support.
 */

#define		FsaNormal	1

690 691
/* transport FIB header (PMC) */
struct aac_fib_xporthdr {
692 693 694 695
	__le64	HostAddress;	/* FIB host address w/o xport header */
	__le32	Size;		/* FIB size excluding xport header */
	__le32	Handle;		/* driver handle to reference the FIB */
	__le64	Reserved[2];
696 697 698 699
};

#define		ALIGN32		32

L
Linus Torvalds 已提交
700 701 702 703 704 705
/*
 * 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 {
706 707 708
	__le32 XferState;	/* Current transfer state for this CCB */
	__le16 Command;		/* Routing information for the destination */
	u8 StructType;		/* Type FIB */
709
	u8 Unused;		/* Unused */
710
	__le16 Size;		/* Size of this FIB in bytes */
711
	__le16 SenderSize;	/* Size of the FIB in the sender
712 713
				   (for response sizing) */
	__le32 SenderFibAddress;  /* Host defined data in the FIB */
L
Linus Torvalds 已提交
714
	union {
715 716 717 718 719
		__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;
720
	__le32 Handle;		/* FIB handle used for MSGU commnunication */
721 722
	u32 Previous;		/* FW internal use */
	u32 Next;		/* FW internal use */
L
Linus Torvalds 已提交
723 724 725 726
};

struct hw_fib {
	struct aac_fibhdr header;
727
	u8 data[512-sizeof(struct aac_fibhdr)];	// Command specific data
L
Linus Torvalds 已提交
728 729 730 731 732 733
};

/*
 *	FIB commands
 */

734
#define		TestCommandResponse		1
L
Linus Torvalds 已提交
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770
#define		TestAdapterCommand		2
/*
 *	Lowlevel and comm commands
 */
#define		LastTestCommand			100
#define		ReinitHostNormCommandQueue	101
#define		ReinitHostHighCommandQueue	102
#define		ReinitHostHighRespQueue		103
#define		ReinitHostNormRespQueue		104
#define		ReinitAdapNormCommandQueue	105
#define		ReinitAdapHighCommandQueue	107
#define		ReinitAdapHighRespQueue		108
#define		ReinitAdapNormRespQueue		109
#define		InterfaceShutdown		110
#define		DmaCommandFib			120
#define		StartProfile			121
#define		TermProfile			122
#define		SpeedTest			123
#define		TakeABreakPt			124
#define		RequestPerfData			125
#define		SetInterruptDefTimer		126
#define		SetInterruptDefCount		127
#define		GetInterruptDefStatus		128
#define		LastCommCommand			129
/*
 *	Filesystem commands
 */
#define		NuFileSystem			300
#define		UFS				301
#define		HostFileSystem			302
#define		LastFileSystemCommand		303
/*
 *	Container Commands
 */
#define		ContainerCommand		500
#define		ContainerCommand64		501
771
#define		ContainerRawIo			502
772
#define		ContainerRawIo2			503
L
Linus Torvalds 已提交
773 774 775 776 777 778 779 780 781 782 783 784 785 786
/*
 *	Scsi Port commands (scsi passthrough)
 */
#define		ScsiPortCommand			600
#define		ScsiPortCommand64		601
/*
 *	Misc house keeping and generic adapter initiated commands
 */
#define		AifRequest			700
#define		CheckRevision			701
#define		FsaHostShutdown			702
#define		RequestAdapterInfo		703
#define		IsAdapterPaused			704
#define		SendHostTime			705
787 788
#define		RequestSupplementAdapterInfo	706
#define		LastMiscCommand			707
L
Linus Torvalds 已提交
789

790 791 792
/*
 * Commands that will target the failover level on the FSA adapter
 */
L
Linus Torvalds 已提交
793 794

enum fib_xfer_state {
795 796 797 798 799 800 801 802 803 804 805 806 807
	HostOwned			= (1<<0),
	AdapterOwned			= (1<<1),
	FibInitialized			= (1<<2),
	FibEmpty			= (1<<3),
	AllocatedFromPool		= (1<<4),
	SentFromHost			= (1<<5),
	SentFromAdapter			= (1<<6),
	ResponseExpected		= (1<<7),
	NoResponseExpected		= (1<<8),
	AdapterProcessed		= (1<<9),
	HostProcessed			= (1<<10),
	HighPriority			= (1<<11),
	NormalPriority			= (1<<12),
L
Linus Torvalds 已提交
808 809 810 811 812 813 814 815
	Async				= (1<<13),
	AsyncIo				= (1<<13),	// rpbfix: remove with new regime
	PageFileIo			= (1<<14),	// rpbfix: remove with new regime
	ShutdownRequest			= (1<<15),
	LazyWrite			= (1<<16),	// rpbfix: remove with new regime
	AdapterMicroFib			= (1<<17),
	BIOSFibPath			= (1<<18),
	FastResponseCapable		= (1<<19),
816 817 818
	ApiFib				= (1<<20),	/* Its an API Fib */
	/* PMC NEW COMM: There is no more AIF data pending */
	NoMoreAifDataAvailable		= (1<<21)
L
Linus Torvalds 已提交
819 820 821 822 823 824 825 826
};

/*
 *	The following defines needs to be updated any time there is an
 *	incompatible change made to the aac_init structure.
 */

#define ADAPTER_INIT_STRUCT_REVISION		3
827
#define ADAPTER_INIT_STRUCT_REVISION_4		4 // rocket science
828
#define ADAPTER_INIT_STRUCT_REVISION_6		6 /* PMC src */
829
#define ADAPTER_INIT_STRUCT_REVISION_7		7 /* Denali */
830
#define ADAPTER_INIT_STRUCT_REVISION_8		8 // Thor
L
Linus Torvalds 已提交
831

832
union aac_init
L
Linus Torvalds 已提交
833
{
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
	struct _r7 {
		__le32	init_struct_revision;
		__le32	no_of_msix_vectors;
		__le32	fsrev;
		__le32	comm_header_address;
		__le32	fast_io_comm_area_address;
		__le32	adapter_fibs_physical_address;
		__le32	adapter_fibs_virtual_address;
		__le32	adapter_fibs_size;
		__le32	adapter_fib_align;
		__le32	printfbuf;
		__le32	printfbufsiz;
		/* number of 4k pages of host phys. mem. */
		__le32	host_phys_mem_pages;
		/* number of seconds since 1970. */
		__le32	host_elapsed_seconds;
		/* ADAPTER_INIT_STRUCT_REVISION_4 begins here */
		__le32	init_flags;	/* flags for supported features */
852
#define INITFLAGS_NEW_COMM_SUPPORTED	0x00000001
853 854
#define INITFLAGS_DRIVER_USES_UTC_TIME	0x00000010
#define INITFLAGS_DRIVER_SUPPORTS_PM	0x00000020
855 856 857
#define INITFLAGS_NEW_COMM_TYPE1_SUPPORTED	0x00000040
#define INITFLAGS_FAST_JBOD_SUPPORTED	0x00000080
#define INITFLAGS_NEW_COMM_TYPE2_SUPPORTED	0x00000100
858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
#define INITFLAGS_DRIVER_SUPPORTS_HBA_MODE  0x00000400
		__le32	max_io_commands;	/* max outstanding commands */
		__le32	max_io_size;	/* largest I/O command */
		__le32	max_fib_size;	/* largest FIB to adapter */
		/* ADAPTER_INIT_STRUCT_REVISION_5 begins here */
		__le32	max_num_aif;	/* max number of aif */
		/* ADAPTER_INIT_STRUCT_REVISION_6 begins here */
		/* Host RRQ (response queue) for SRC */
		__le32	host_rrq_addr_low;
		__le32	host_rrq_addr_high;
	} r7;
	struct _r8 {
		/* ADAPTER_INIT_STRUCT_REVISION_8 */
		__le32	init_struct_revision;
		__le32	rr_queue_count;
		__le32	host_elapsed_seconds; /* number of secs since 1970. */
		__le32	init_flags;
		__le32	max_io_size;	/* largest I/O command */
		__le32	max_num_aif;	/* max number of aif */
		__le32	reserved1;
		__le32	reserved2;
		struct _rrq {
			__le32	host_addr_low;
			__le32	host_addr_high;
			__le16	msix_id;
			__le16	element_count;
			__le16	comp_thresh;
			__le16	unused;
		} rrq[1];		/* up to 64 RRQ addresses */
	} r8;
L
Linus Torvalds 已提交
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
};

enum aac_log_level {
	LOG_AAC_INIT			= 10,
	LOG_AAC_INFORMATIONAL		= 20,
	LOG_AAC_WARNING			= 30,
	LOG_AAC_LOW_ERROR		= 40,
	LOG_AAC_MEDIUM_ERROR		= 50,
	LOG_AAC_HIGH_ERROR		= 60,
	LOG_AAC_PANIC			= 70,
	LOG_AAC_DEBUG			= 80,
	LOG_AAC_WINDBG_PRINT		= 90
};

#define FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT	0x030b
#define FSAFS_NTC_FIB_CONTEXT			0x030c

struct aac_dev;
906
struct fib;
907
struct scsi_cmnd;
L
Linus Torvalds 已提交
908 909 910

struct adapter_ops
{
911
	/* Low level operations */
L
Linus Torvalds 已提交
912 913
	void (*adapter_interrupt)(struct aac_dev *dev);
	void (*adapter_notify)(struct aac_dev *dev, u32 event);
914
	void (*adapter_disable_int)(struct aac_dev *dev);
915
	void (*adapter_enable_int)(struct aac_dev *dev);
916
	int  (*adapter_sync_cmd)(struct aac_dev *dev, u32 command, u32 p1, u32 p2, u32 p3, u32 p4, u32 p5, u32 p6, u32 *status, u32 *r1, u32 *r2, u32 *r3, u32 *r4);
L
Linus Torvalds 已提交
917
	int  (*adapter_check_health)(struct aac_dev *dev);
918
	int  (*adapter_restart)(struct aac_dev *dev, int bled, u8 reset_type);
919
	void (*adapter_start)(struct aac_dev *dev);
920
	/* Transport operations */
921
	int  (*adapter_ioremap)(struct aac_dev * dev, u32 size);
922
	irq_handler_t adapter_intr;
923 924
	/* Packet operations */
	int  (*adapter_deliver)(struct fib * fib);
925 926
	int  (*adapter_bounds)(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba);
	int  (*adapter_read)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count);
927
	int  (*adapter_write)(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count, int fua);
928
	int  (*adapter_scsi)(struct fib * fib, struct scsi_cmnd * cmd);
929 930
	/* Administrative operations */
	int  (*adapter_comm)(struct aac_dev * dev, int comm);
L
Linus Torvalds 已提交
931 932 933 934 935 936 937 938
};

/*
 *	Define which interrupt handler needs to be installed
 */

struct aac_driver_ident
{
939
	int	(*init)(struct aac_dev *dev);
L
Linus Torvalds 已提交
940 941 942 943 944 945 946
	char *	name;
	char *	vname;
	char *	model;
	u16	channels;
	int	quirks;
};
/*
947
 * Some adapter firmware needs communication memory
L
Linus Torvalds 已提交
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
 * 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

971 972 973 974 975 976 977
/*
 * 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

978 979 980 981 982 983
/*
 *	Some adapter firmware does not support 64 bit scsi passthrough
 * commands.
 */
#define AAC_QUIRK_SCSI_32	0x0020

984 985 986 987 988
/*
 * SRC based adapters support the AifReqEvent functions
 */
#define AAC_QUIRK_SRC 0x0040

L
Linus Torvalds 已提交
989 990
/*
 *	The adapter interface specs all queues to be located in the same
991
 *	physically contiguous block. The host structure that defines the
L
Linus Torvalds 已提交
992
 *	commuication queues will assume they are each a separate physically
993 994
 *	contiguous memory region that will support them all being one big
 *	contiguous block.
L
Linus Torvalds 已提交
995 996 997
 *	There is a command and response queue for each level and direction of
 *	commuication. These regions are accessed by both the host and adapter.
 */
998

L
Linus Torvalds 已提交
999
struct aac_queue {
1000
	u64			logical;	/*address we give the adapter */
L
Linus Torvalds 已提交
1001
	struct aac_entry	*base;		/*system virtual address */
1002 1003
	struct aac_qhdr		headers;	/*producer,consumer q headers*/
	u32			entries;	/*Number of queue entries */
L
Linus Torvalds 已提交
1004 1005
	wait_queue_head_t	qfull;		/*Event to wait on if q full */
	wait_queue_head_t	cmdready;	/*Cmd ready from the adapter */
1006 1007
		/* 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 */
L
Linus Torvalds 已提交
1008
	spinlock_t		lockdata;	/* Actual lock (used only on one side of the lock) */
1009 1010
	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. */
1011 1012
	/* Number of entries on outstanding queue. */
	atomic_t		numpending;
L
Linus Torvalds 已提交
1013 1014 1015 1016
	struct aac_dev *	dev;		/* Back pointer to adapter structure */
};

/*
1017
 *	Message queues. The order here is important, see also the
L
Linus Torvalds 已提交
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028
 *	queue type ordering
 */

struct aac_queue_block
{
	struct aac_queue queue[8];
};

/*
 *	SaP1 Message Unit Registers
 */
1029

L
Linus Torvalds 已提交
1030
struct sa_drawbridge_CSR {
1031
				/*	Offset	|  Name */
L
Linus Torvalds 已提交
1032 1033
	__le32	reserved[10];	/*	00h-27h |  Reserved */
	u8	LUT_Offset;	/*	28h	|  Lookup Table Offset */
1034
	u8	reserved1[3];	/*	29h-2bh	|  Reserved */
L
Linus Torvalds 已提交
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
	__le32	LUT_Data;	/*	2ch	|  Looup Table Data */
	__le32	reserved2[26];	/*	30h-97h	|  Reserved */
	__le16	PRICLEARIRQ;	/*	98h	|  Primary Clear Irq */
	__le16	SECCLEARIRQ;	/*	9ah	|  Secondary Clear Irq */
	__le16	PRISETIRQ;	/*	9ch	|  Primary Set Irq */
	__le16	SECSETIRQ;	/*	9eh	|  Secondary Set Irq */
	__le16	PRICLEARIRQMASK;/*	a0h	|  Primary Clear Irq Mask */
	__le16	SECCLEARIRQMASK;/*	a2h	|  Secondary Clear Irq Mask */
	__le16	PRISETIRQMASK;	/*	a4h	|  Primary Set Irq Mask */
	__le16	SECSETIRQMASK;	/*	a6h	|  Secondary Set Irq Mask */
	__le32	MAILBOX0;	/*	a8h	|  Scratchpad 0 */
	__le32	MAILBOX1;	/*	ach	|  Scratchpad 1 */
	__le32	MAILBOX2;	/*	b0h	|  Scratchpad 2 */
	__le32	MAILBOX3;	/*	b4h	|  Scratchpad 3 */
	__le32	MAILBOX4;	/*	b8h	|  Scratchpad 4 */
	__le32	MAILBOX5;	/*	bch	|  Scratchpad 5 */
	__le32	MAILBOX6;	/*	c0h	|  Scratchpad 6 */
	__le32	MAILBOX7;	/*	c4h	|  Scratchpad 7 */
1053 1054
	__le32	ROM_Setup_Data;	/*	c8h	|  Rom Setup and Data */
	__le32	ROM_Control_Addr;/*	cch	|  Rom Control and Address */
L
Linus Torvalds 已提交
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
	__le32	reserved3[12];	/*	d0h-ffh	|  reserved */
	__le32	LUT[64];	/*    100h-1ffh	|  Lookup Table Entries */
};

#define Mailbox0	SaDbCSR.MAILBOX0
#define Mailbox1	SaDbCSR.MAILBOX1
#define Mailbox2	SaDbCSR.MAILBOX2
#define Mailbox3	SaDbCSR.MAILBOX3
#define Mailbox4	SaDbCSR.MAILBOX4
#define Mailbox5	SaDbCSR.MAILBOX5
1065
#define Mailbox6	SaDbCSR.MAILBOX6
L
Linus Torvalds 已提交
1066
#define Mailbox7	SaDbCSR.MAILBOX7
1067

L
Linus Torvalds 已提交
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080
#define DoorbellReg_p SaDbCSR.PRISETIRQ
#define DoorbellReg_s SaDbCSR.SECSETIRQ
#define DoorbellClrReg_p SaDbCSR.PRICLEARIRQ


#define	DOORBELL_0	0x0001
#define DOORBELL_1	0x0002
#define DOORBELL_2	0x0004
#define DOORBELL_3	0x0008
#define DOORBELL_4	0x0010
#define DOORBELL_5	0x0020
#define DOORBELL_6	0x0040

1081

L
Linus Torvalds 已提交
1082 1083
#define PrintfReady	DOORBELL_5
#define PrintfDone	DOORBELL_5
1084

L
Linus Torvalds 已提交
1085 1086 1087
struct sa_registers {
	struct sa_drawbridge_CSR	SaDbCSR;			/* 98h - c4h */
};
1088

L
Linus Torvalds 已提交
1089

1090
#define SA_INIT_NUM_MSIXVECTORS		1
1091
#define SA_MINIPORT_REVISION		SA_INIT_NUM_MSIXVECTORS
L
Linus Torvalds 已提交
1092 1093

#define sa_readw(AEP, CSR)		readl(&((AEP)->regs.sa->CSR))
1094
#define sa_readl(AEP, CSR)		readl(&((AEP)->regs.sa->CSR))
L
Linus Torvalds 已提交
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
#define sa_writew(AEP, CSR, value)	writew(value, &((AEP)->regs.sa->CSR))
#define sa_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.sa->CSR))

/*
 *	Rx Message Unit Registers
 */

struct rx_mu_registers {
			    /*	Local  | PCI*| Name */
	__le32	ARSR;	    /*	1300h  | 00h | APIC Register Select Register */
	__le32	reserved0;  /*	1304h  | 04h | Reserved */
	__le32	AWR;	    /*	1308h  | 08h | APIC Window Register */
	__le32	reserved1;  /*	130Ch  | 0Ch | Reserved */
	__le32	IMRx[2];    /*	1310h  | 10h | Inbound Message Registers */
	__le32	OMRx[2];    /*	1318h  | 18h | Outbound Message Registers */
	__le32	IDR;	    /*	1320h  | 20h | Inbound Doorbell Register */
1111
	__le32	IISR;	    /*	1324h  | 24h | Inbound Interrupt
L
Linus Torvalds 已提交
1112
						Status Register */
1113 1114
	__le32	IIMR;	    /*	1328h  | 28h | Inbound Interrupt
						Mask Register */
L
Linus Torvalds 已提交
1115
	__le32	ODR;	    /*	132Ch  | 2Ch | Outbound Doorbell Register */
1116
	__le32	OISR;	    /*	1330h  | 30h | Outbound Interrupt
L
Linus Torvalds 已提交
1117
						Status Register */
1118
	__le32	OIMR;	    /*	1334h  | 34h | Outbound Interrupt
L
Linus Torvalds 已提交
1119
						Mask Register */
1120 1121 1122 1123
	__le32	reserved2;  /*	1338h  | 38h | Reserved */
	__le32	reserved3;  /*	133Ch  | 3Ch | Reserved */
	__le32	InboundQueue;/*	1340h  | 40h | Inbound Queue Port relative to firmware */
	__le32	OutboundQueue;/*1344h  | 44h | Outbound Queue Port relative to firmware */
1124 1125
			    /* * Must access through ATU Inbound
				 Translation Window */
L
Linus Torvalds 已提交
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149
};

struct rx_inbound {
	__le32	Mailbox[8];
};

#define	INBOUNDDOORBELL_0	0x00000001
#define INBOUNDDOORBELL_1	0x00000002
#define INBOUNDDOORBELL_2	0x00000004
#define INBOUNDDOORBELL_3	0x00000008
#define INBOUNDDOORBELL_4	0x00000010
#define INBOUNDDOORBELL_5	0x00000020
#define INBOUNDDOORBELL_6	0x00000040

#define	OUTBOUNDDOORBELL_0	0x00000001
#define OUTBOUNDDOORBELL_1	0x00000002
#define OUTBOUNDDOORBELL_2	0x00000004
#define OUTBOUNDDOORBELL_3	0x00000008
#define OUTBOUNDDOORBELL_4	0x00000010

#define InboundDoorbellReg	MUnit.IDR
#define OutboundDoorbellReg	MUnit.ODR

struct rx_registers {
1150
	struct rx_mu_registers		MUnit;		/* 1300h - 1347h */
1151
	__le32				reserved1[2];	/* 1348h - 134ch */
L
Linus Torvalds 已提交
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167
	struct rx_inbound		IndexRegs;
};

#define rx_readb(AEP, CSR)		readb(&((AEP)->regs.rx->CSR))
#define rx_readl(AEP, CSR)		readl(&((AEP)->regs.rx->CSR))
#define rx_writeb(AEP, CSR, value)	writeb(value, &((AEP)->regs.rx->CSR))
#define rx_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.rx->CSR))

/*
 *	Rkt Message Unit Registers (same as Rx, except a larger reserve region)
 */

#define rkt_mu_registers rx_mu_registers
#define rkt_inbound rx_inbound

struct rkt_registers {
1168
	struct rkt_mu_registers		MUnit;		 /* 1300h - 1347h */
1169
	__le32				reserved1[1006]; /* 1348h - 22fch */
L
Linus Torvalds 已提交
1170 1171 1172 1173 1174 1175 1176 1177
	struct rkt_inbound		IndexRegs;	 /* 2300h - */
};

#define rkt_readb(AEP, CSR)		readb(&((AEP)->regs.rkt->CSR))
#define rkt_readl(AEP, CSR)		readl(&((AEP)->regs.rkt->CSR))
#define rkt_writeb(AEP, CSR, value)	writeb(value, &((AEP)->regs.rkt->CSR))
#define rkt_writel(AEP, CSR, value)	writel(value, &((AEP)->regs.rkt->CSR))

1178 1179 1180 1181 1182 1183 1184
/*
 * PMC SRC message unit registers
 */

#define src_inbound rx_inbound

struct src_mu_registers {
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198
				/*  PCI*| Name */
	__le32	reserved0[6];	/*  00h | Reserved */
	__le32	IOAR[2];	/*  18h | IOA->host interrupt register */
	__le32	IDR;		/*  20h | Inbound Doorbell Register */
	__le32	IISR;		/*  24h | Inbound Int. Status Register */
	__le32	reserved1[3];	/*  28h | Reserved */
	__le32	OIMR;		/*  34h | Outbound Int. Mask Register */
	__le32	reserved2[25];  /*  38h | Reserved */
	__le32	ODR_R;		/*  9ch | Outbound Doorbell Read */
	__le32	ODR_C;		/*  a0h | Outbound Doorbell Clear */
	__le32	reserved3[3];	/*  a4h | Reserved */
	__le32	SCR0;		/*  b0h | Scratchpad 0 */
	__le32	reserved4[2];	/*  b4h | Reserved */
	__le32	OMR;		/*  bch | Outbound Message Register */
1199 1200
	__le32	IQ_L;		/*  c0h | Inbound Queue (Low address) */
	__le32	IQ_H;		/*  c4h | Inbound Queue (High address) */
M
Mahesh Rajashekhara 已提交
1201
	__le32	ODR_MSI;	/*  c8h | MSI register for sync./AIF */
1202 1203 1204
	__le32  reserved5;	/*  cch | Reserved */
	__le32	IQN_L;		/*  d0h | Inbound (native cmd) low  */
	__le32	IQN_H;		/*  d4h | Inbound (native cmd) high */
1205 1206 1207
};

struct src_registers {
M
Mahesh Rajashekhara 已提交
1208
	struct src_mu_registers MUnit;	/* 00h - cbh */
1209 1210
	union {
		struct {
1211
			__le32 reserved1[130786];	/* d8h - 7fc5fh */
1212 1213 1214
			struct src_inbound IndexRegs;	/* 7fc60h */
		} tupelo;
		struct {
1215
			__le32 reserved1[970];		/* d8h - fffh */
1216 1217 1218
			struct src_inbound IndexRegs;	/* 1000h */
		} denali;
	} u;
1219 1220 1221 1222 1223 1224 1225 1226
};

#define src_readb(AEP, CSR)		readb(&((AEP)->regs.src.bar0->CSR))
#define src_readl(AEP, CSR)		readl(&((AEP)->regs.src.bar0->CSR))
#define src_writeb(AEP, CSR, value)	writeb(value, \
						&((AEP)->regs.src.bar0->CSR))
#define src_writel(AEP, CSR, value)	writel(value, \
						&((AEP)->regs.src.bar0->CSR))
1227 1228 1229 1230
#if defined(writeq)
#define	src_writeq(AEP, CSR, value)	writeq(value, \
						&((AEP)->regs.src.bar0->CSR))
#endif
1231 1232 1233

#define SRC_ODR_SHIFT		12
#define SRC_IDR_SHIFT		9
1234
#define SRC_MSI_READ_MASK	0x1000
1235

L
Linus Torvalds 已提交
1236 1237 1238
typedef void (*fib_callback)(void *ctxt, struct fib *fibctx);

struct aac_fib_context {
1239 1240
	s16			type;		// used for verification of structure
	s16			size;
L
Linus Torvalds 已提交
1241 1242 1243
	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
1244
	struct semaphore	wait_sem;	// this is used to wait for the next fib to arrive.
L
Linus Torvalds 已提交
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
	int			wait;		// Set to true when thread is in WaitForSingleObject
	unsigned long		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 */

1263 1264 1265
	u8 information[4];	/* for direct-access devices, contains the unsigned
				 * logical block address or residue associated with
				 * the sense key
L
Linus Torvalds 已提交
1266 1267 1268 1269 1270 1271 1272 1273 1274
				 */
	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
				 */
1275
	u8 BPV:1;		/* bit pointer valid (BPV): 1- indicates that
L
Linus Torvalds 已提交
1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
				 * 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 fsa_dev_info {
	u64		last;
	u64		size;
	u32		type;
1290
	u32		config_waiting_on;
1291
	unsigned long	config_waiting_stamp;
L
Linus Torvalds 已提交
1292
	u16		queue_depth;
1293
	u8		config_needed;
L
Linus Torvalds 已提交
1294 1295 1296 1297 1298 1299
	u8		valid;
	u8		ro;
	u8		locked;
	u8		deleted;
	char		devname[8];
	struct sense_data sense_data;
1300
	u32		block_size;
1301
	u8		identifier[16];
L
Linus Torvalds 已提交
1302 1303 1304 1305 1306 1307 1308 1309 1310
};

struct fib {
	void			*next;	/* this is used by the allocator */
	s16			type;
	s16			size;
	/*
	 *	The Adapter that this I/O is destined for.
	 */
1311
	struct aac_dev		*dev;
L
Linus Torvalds 已提交
1312 1313 1314 1315
	/*
	 *	This is the event the sendfib routine will wait on if the
	 *	caller did not pass one and this is synch io.
	 */
1316
	struct semaphore	event_wait;
L
Linus Torvalds 已提交
1317 1318 1319
	spinlock_t		event_lock;

	u32			done;	/* gets set to 1 when fib is complete */
1320 1321
	fib_callback		callback;
	void			*callback_data;
L
Linus Torvalds 已提交
1322 1323 1324 1325 1326 1327
	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;
1328
	void			*data;
1329
	u32			vector_no;
1330 1331 1332 1333
	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 */
1334
	u32			hbacmd_size;	/* cmd size for native */
L
Linus Torvalds 已提交
1335 1336
};

1337 1338 1339
#define AAC_INIT			0
#define AAC_RESCAN			1

1340 1341 1342 1343
#define AAC_DEVTYPE_RAID_MEMBER	1
#define AAC_DEVTYPE_ARC_RAW		2
#define AAC_DEVTYPE_NATIVE_RAW		3

1344
#define AAC_SAFW_RESCAN_DELAY		(10 * HZ)
1345 1346 1347 1348

struct aac_hba_map_info {
	__le32	rmw_nexus;		/* nexus for native HBA devices */
	u8		devtype;	/* device type */
1349
	s8		reset_state;	/* 0 - no reset, 1..x - */
1350
					/* after xth TM LUN reset */
1351
	u16		qd_limit;
1352
	u32		scan_counter;
1353
	struct aac_ciss_identify_pd  *safw_identify_resp;
1354 1355
};

L
Linus Torvalds 已提交
1356 1357 1358 1359 1360
/*
 *	Adapter Information Block
 *
 *	This is returned by the RequestAdapterInfo block
 */
1361

L
Linus Torvalds 已提交
1362 1363
struct aac_adapter_info
{
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
	__le32	platform;
	__le32	cpu;
	__le32	subcpu;
	__le32	clock;
	__le32	execmem;
	__le32	buffermem;
	__le32	totalmem;
	__le32	kernelrev;
	__le32	kernelbuild;
	__le32	monitorrev;
	__le32	monitorbuild;
	__le32	hwrev;
	__le32	hwbuild;
	__le32	biosrev;
	__le32	biosbuild;
	__le32	cluster;
1380
	__le32	clusterchannelmask;
1381 1382 1383 1384
	__le32	serial[2];
	__le32	battery;
	__le32	options;
	__le32	OEM;
L
Linus Torvalds 已提交
1385 1386
};

1387 1388
struct aac_supplement_adapter_info
{
1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399
	u8	adapter_type_text[17+1];
	u8	pad[2];
	__le32	flash_memory_byte_size;
	__le32	flash_image_id;
	__le32	max_number_ports;
	__le32	version;
	__le32	feature_bits;
	u8	slot_number;
	u8	reserved_pad0[3];
	u8	build_date[12];
	__le32	current_number_ports;
1400
	struct {
1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415
		u8	assembly_pn[8];
		u8	fru_pn[8];
		u8	battery_fru_pn[8];
		u8	ec_version_string[8];
		u8	tsid[12];
	}	vpd_info;
	__le32	flash_firmware_revision;
	__le32	flash_firmware_build;
	__le32	raid_type_morph_options;
	__le32	flash_firmware_boot_revision;
	__le32	flash_firmware_boot_build;
	u8	mfg_pcba_serial_no[12];
	u8	mfg_wwn_name[8];
	__le32	supported_options2;
	__le32	struct_expansion;
L
Leubner, Achim 已提交
1416
	/* StructExpansion == 1 */
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
	__le32	feature_bits3;
	__le32	supported_performance_modes;
	u8	host_bus_type;		/* uses HOST_BUS_TYPE_xxx defines */
	u8	host_bus_width;		/* actual width in bits or links */
	u16	host_bus_speed;		/* actual bus speed/link rate in MHz */
	u8	max_rrc_drives;		/* max. number of ITP-RRC drives/pool */
	u8	max_disk_xtasks;	/* max. possible num of DiskX Tasks */

	u8	cpld_ver_loaded;
	u8	cpld_ver_in_flash;

	__le64	max_rrc_capacity;
	__le32	compiled_max_hist_log_level;
	u8	custom_board_name[12];
	u16	supported_cntlr_mode;	/* identify supported controller mode */
	u16	reserved_for_future16;
	__le32	supported_options3;	/* reserved for future options */

	__le16	virt_device_bus;		/* virt. SCSI device for Thor */
	__le16	virt_device_target;
	__le16	virt_device_lun;
	__le16	unused;
	__le32	reserved_for_future_growth[68];
1440

1441
};
1442
#define AAC_FEATURE_FALCON	cpu_to_le32(0x00000010)
1443
#define AAC_FEATURE_JBOD	cpu_to_le32(0x08000000)
1444 1445 1446 1447
/* SupportedOptions2 */
#define AAC_OPTION_MU_RESET		cpu_to_le32(0x00000001)
#define AAC_OPTION_IGNORE_RESET		cpu_to_le32(0x00000002)
#define AAC_OPTION_POWER_MANAGEMENT	cpu_to_le32(0x00000004)
1448
#define AAC_OPTION_DOORBELL_RESET	cpu_to_le32(0x00004000)
1449 1450
/* 4KB sector size */
#define AAC_OPTION_VARIABLE_BLOCK_SIZE	cpu_to_le32(0x00040000)
1451 1452
/* 240 simple volume support */
#define AAC_OPTION_SUPPORTED_240_VOLUMES cpu_to_le32(0x10000000)
1453 1454 1455 1456
/*
 * Supports FIB dump sync command send prior to IOP_RESET
 */
#define AAC_OPTION_SUPPORTED3_IOP_RESET_FIB_DUMP	cpu_to_le32(0x00004000)
1457 1458 1459
#define AAC_SIS_VERSION_V3	3
#define AAC_SIS_SLOT_UNKNOWN	0xFF

1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481
#define GetBusInfo 0x00000009
struct aac_bus_info {
	__le32	Command;	/* VM_Ioctl */
	__le32	ObjType;	/* FT_DRIVE */
	__le32	MethodId;	/* 1 = SCSI Layer */
	__le32	ObjectId;	/* Handle */
	__le32	CtlCmd;		/* GetBusInfo */
};

struct aac_bus_info_response {
	__le32	Status;		/* ST_OK */
	__le32	ObjType;
	__le32	MethodId;	/* unused */
	__le32	ObjectId;	/* unused */
	__le32	CtlCmd;		/* unused */
	__le32	ProbeComplete;
	__le32	BusCount;
	__le32	TargetsPerBus;
	u8	InitiatorBusId[10];
	u8	BusValid[10];
};

L
Linus Torvalds 已提交
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506
/*
 * Battery platforms
 */
#define AAC_BAT_REQ_PRESENT	(1)
#define AAC_BAT_REQ_NOTPRESENT	(2)
#define AAC_BAT_OPT_PRESENT	(3)
#define AAC_BAT_OPT_NOTPRESENT	(4)
#define AAC_BAT_NOT_SUPPORTED	(5)
/*
 * cpu types
 */
#define AAC_CPU_SIMULATOR	(1)
#define AAC_CPU_I960		(2)
#define AAC_CPU_STRONGARM	(3)

/*
 * Supported Options
 */
#define AAC_OPT_SNAPSHOT		cpu_to_le32(1)
#define AAC_OPT_CLUSTERS		cpu_to_le32(1<<1)
#define AAC_OPT_WRITE_CACHE		cpu_to_le32(1<<2)
#define AAC_OPT_64BIT_DATA		cpu_to_le32(1<<3)
#define AAC_OPT_HOST_TIME_FIB		cpu_to_le32(1<<4)
#define AAC_OPT_RAID50			cpu_to_le32(1<<5)
#define AAC_OPT_4GB_WINDOW		cpu_to_le32(1<<6)
1507
#define AAC_OPT_SCSI_UPGRADEABLE	cpu_to_le32(1<<7)
L
Linus Torvalds 已提交
1508
#define AAC_OPT_SOFT_ERR_REPORT		cpu_to_le32(1<<8)
1509
#define AAC_OPT_SUPPORTED_RECONDITION	cpu_to_le32(1<<9)
L
Linus Torvalds 已提交
1510 1511 1512
#define AAC_OPT_SGMAP_HOST64		cpu_to_le32(1<<10)
#define AAC_OPT_ALARM			cpu_to_le32(1<<11)
#define AAC_OPT_NONDASD			cpu_to_le32(1<<12)
1513
#define AAC_OPT_SCSI_MANAGED		cpu_to_le32(1<<13)
L
Linus Torvalds 已提交
1514 1515 1516 1517
#define AAC_OPT_RAID_SCSI_MODE		cpu_to_le32(1<<14)
#define AAC_OPT_SUPPLEMENT_ADAPTER_INFO	cpu_to_le32(1<<16)
#define AAC_OPT_NEW_COMM		cpu_to_le32(1<<17)
#define AAC_OPT_NEW_COMM_64		cpu_to_le32(1<<18)
1518
#define AAC_OPT_EXTENDED		cpu_to_le32(1<<23)
1519
#define AAC_OPT_NATIVE_HBA		cpu_to_le32(1<<25)
1520
#define AAC_OPT_NEW_COMM_TYPE1		cpu_to_le32(1<<28)
1521 1522 1523 1524
#define AAC_OPT_NEW_COMM_TYPE2		cpu_to_le32(1<<29)
#define AAC_OPT_NEW_COMM_TYPE3		cpu_to_le32(1<<30)
#define AAC_OPT_NEW_COMM_TYPE4		cpu_to_le32(1<<31)

1525 1526 1527 1528 1529 1530
#define AAC_COMM_PRODUCER		0
#define AAC_COMM_MESSAGE		1
#define AAC_COMM_MESSAGE_TYPE1		3
#define AAC_COMM_MESSAGE_TYPE2		4
#define AAC_COMM_MESSAGE_TYPE3		5

1531
#define AAC_EXTOPT_SA_FIRMWARE		cpu_to_le32(1<<1)
1532
#define AAC_EXTOPT_SOFT_RESET		cpu_to_le32(1<<16)
1533

M
Mahesh Rajashekhara 已提交
1534 1535 1536 1537 1538
/* MSIX context */
struct aac_msix_ctx {
	int		vector_no;
	struct aac_dev	*dev;
};
L
Linus Torvalds 已提交
1539 1540 1541 1542 1543 1544 1545

struct aac_dev
{
	struct list_head	entry;
	const char		*name;
	int			id;

1546 1547 1548
	/*
	 *	negotiated FIB settings
	 */
1549 1550 1551 1552 1553
	unsigned int		max_fib_size;
	unsigned int		sg_tablesize;
	unsigned int		max_num_aif;

	unsigned int		max_cmd_size;	/* max_fib_size or MAX_NATIVE */
1554

L
Linus Torvalds 已提交
1555 1556
	/*
	 *	Map for 128 fib objects (64k)
1557
	 */
1558 1559
	dma_addr_t		hw_fib_pa;	/* also used for native cmd */
	struct hw_fib		*hw_fib_va;	/* also used for native cmd */
L
Linus Torvalds 已提交
1560 1561 1562 1563 1564 1565 1566 1567
	struct hw_fib		*aif_base_va;
	/*
	 *	Fib Headers
	 */
	struct fib              *fibs;

	struct fib		*free_fib;
	spinlock_t		fib_lock;
1568

1569
	struct mutex		ioctl_mutex;
1570
	struct mutex		scan_mutex;
L
Linus Torvalds 已提交
1571 1572 1573 1574 1575
	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
1576
	 *	mutex is used to synchronize access to all data associated
L
Linus Torvalds 已提交
1577 1578 1579 1580 1581 1582
	 *	with the adapter fibs.
	 */
	struct list_head	fib_list;

	struct adapter_ops	a_ops;
	unsigned long		fsrev;		/* Main driver's revision number */
1583

1584 1585
	resource_size_t		base_start;	/* main IO base */
	resource_size_t		dbg_base;	/* address of UART
1586 1587
						 * debug buffer */

1588
	resource_size_t		base_size, dbg_size;	/* Size of
1589
							 *  mapped in region */
1590 1591 1592 1593 1594
	/*
	 * Holds initialization info
	 * to communicate with adapter
	 */
	union aac_init		*init;
1595
	dma_addr_t		init_pa;	/* Holds physical address of the init struct */
1596 1597
	/* response queue (if AAC_COMM_MESSAGE_TYPE1) */
	__le32			*host_rrq;
1598
	dma_addr_t		host_rrq_pa;	/* phys. address */
M
Mahesh Rajashekhara 已提交
1599 1600 1601 1602
	/* index into rrq buffer */
	u32			host_rrq_idx[AAC_MAX_MSIX];
	atomic_t		rrq_outstanding[AAC_MAX_MSIX];
	u32			fibs_pushed_no;
L
Linus Torvalds 已提交
1603
	struct pci_dev		*pdev;		/* Our PCI interface */
1604 1605 1606
	/* pointer to buffer used for printf's from the adapter */
	void			*printfbuf;
	void			*comm_addr;	/* Base address of Comm area */
L
Linus Torvalds 已提交
1607 1608 1609 1610 1611
	dma_addr_t		comm_phys;	/* Physical Address of Comm area */
	size_t			comm_size;

	struct Scsi_Host	*scsi_host_ptr;
	int			maximum_num_containers;
1612 1613
	int			maximum_num_physicals;
	int			maximum_num_channels;
L
Linus Torvalds 已提交
1614
	struct fsa_dev_info	*fsa_dev;
1615
	struct task_struct	*thread;
1616
	struct delayed_work	safw_rescan_work;
L
Linus Torvalds 已提交
1617
	int			cardtype;
1618 1619 1620 1621 1622
	/*
	 *This lock will protect the two 32-bit
	 *writes to the Inbound Queue
	 */
	spinlock_t		iq_lock;
1623

L
Linus Torvalds 已提交
1624 1625 1626
	/*
	 *	The following is the device specific extension.
	 */
1627
#ifndef AAC_MIN_FOOTPRINT_SIZE
1628
#	define AAC_MIN_FOOTPRINT_SIZE 8192
1629 1630
#	define AAC_MIN_SRC_BAR0_SIZE 0x400000
#	define AAC_MIN_SRC_BAR1_SIZE 0x800
1631 1632
#	define AAC_MIN_SRCV_BAR0_SIZE 0x100000
#	define AAC_MIN_SRCV_BAR1_SIZE 0x400
1633
#endif
L
Linus Torvalds 已提交
1634 1635 1636 1637 1638
	union
	{
		struct sa_registers __iomem *sa;
		struct rx_registers __iomem *rx;
		struct rkt_registers __iomem *rkt;
1639 1640 1641 1642
		struct {
			struct src_registers __iomem *bar0;
			char __iomem *bar1;
		} src;
L
Linus Torvalds 已提交
1643
	} regs;
1644
	volatile void __iomem *base, *dbg_base_mapped;
1645
	volatile struct rx_inbound __iomem *IndexRegs;
L
Linus Torvalds 已提交
1646 1647 1648 1649 1650 1651
	u32			OIMR; /* Mask Register Cache */
	/*
	 *	AIF thread states
	 */
	u32			aif_thread;
	struct aac_adapter_info adapter_info;
1652
	struct aac_supplement_adapter_info supplement_adapter_info;
L
Linus Torvalds 已提交
1653 1654 1655
	/* 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
	 */
1656
	u8			nondasd_support;
1657
	u8			jbod;
1658
	u8			cache_protected;
L
Linus Torvalds 已提交
1659
	u8			dac_support;
L
Leubner, Achim 已提交
1660
	u8			needs_dac;
L
Linus Torvalds 已提交
1661
	u8			raid_scsi_mode;
1662
	u8			comm_interface;
1663
	u8			raw_io_interface;
1664
	u8			raw_io_64;
1665
	u8			printf_enabled;
1666
	u8			in_reset;
1667
	u8			in_soft_reset;
1668
	u8			msi;
1669
	u8			sa_firmware;
1670 1671
	int			management_fib_count;
	spinlock_t		manage_lock;
1672 1673 1674 1675
	spinlock_t		sync_lock;
	int			sync_mode;
	struct fib		*sync_fib;
	struct list_head	sync_fib_list;
1676
	u32			doorbell_mask;
M
Mahesh Rajashekhara 已提交
1677 1678 1679
	u32			max_msix;	/* max. MSI-X vectors */
	u32			vector_cap;	/* MSI-X vector capab.*/
	int			msi_enabled;	/* MSI/MSI-X enabled */
1680
	atomic_t		msix_counter;
1681
	u32			scan_counter;
1682
	struct msix_entry	msixentry[AAC_MAX_MSIX];
M
Mahesh Rajashekhara 已提交
1683
	struct aac_msix_ctx	aac_msix[AAC_MAX_MSIX]; /* context */
1684
	struct aac_hba_map_info	hba_map[AAC_MAX_BUSES][AAC_MAX_TARGETS];
1685
	struct aac_ciss_phys_luns_resp *safw_phys_luns;
M
Mahesh Rajashekhara 已提交
1686
	u8			adapter_shutdown;
1687
	u32			handle_pci_error;
1688
	bool			init_reset;
L
Linus Torvalds 已提交
1689 1690 1691 1692 1693 1694 1695 1696
};

#define aac_adapter_interrupt(dev) \
	(dev)->a_ops.adapter_interrupt(dev)

#define aac_adapter_notify(dev, event) \
	(dev)->a_ops.adapter_notify(dev, event)

1697 1698 1699
#define aac_adapter_disable_int(dev) \
	(dev)->a_ops.adapter_disable_int(dev)

1700 1701 1702
#define aac_adapter_enable_int(dev) \
	(dev)->a_ops.adapter_enable_int(dev)

1703 1704
#define aac_adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4) \
	(dev)->a_ops.adapter_sync_cmd(dev, command, p1, p2, p3, p4, p5, p6, status, r1, r2, r3, r4)
L
Linus Torvalds 已提交
1705

1706 1707
#define aac_adapter_restart(dev, bled, reset_type) \
	((dev)->a_ops.adapter_restart(dev, bled, reset_type))
1708

1709 1710 1711
#define aac_adapter_start(dev) \
	((dev)->a_ops.adapter_start(dev))

1712 1713 1714
#define aac_adapter_ioremap(dev, size) \
	(dev)->a_ops.adapter_ioremap(dev, size)

1715 1716 1717
#define aac_adapter_deliver(fib) \
	((fib)->dev)->a_ops.adapter_deliver(fib)

1718 1719 1720 1721 1722 1723
#define aac_adapter_bounds(dev,cmd,lba) \
	dev->a_ops.adapter_bounds(dev,cmd,lba)

#define aac_adapter_read(fib,cmd,lba,count) \
	((fib)->dev)->a_ops.adapter_read(fib,cmd,lba,count)

1724 1725
#define aac_adapter_write(fib,cmd,lba,count,fua) \
	((fib)->dev)->a_ops.adapter_write(fib,cmd,lba,count,fua)
1726 1727 1728 1729

#define aac_adapter_scsi(fib,cmd) \
	((fib)->dev)->a_ops.adapter_scsi(fib,cmd)

1730 1731 1732
#define aac_adapter_comm(dev,comm) \
	(dev)->a_ops.adapter_comm(dev, comm)

L
Linus Torvalds 已提交
1733
#define FIB_CONTEXT_FLAG_TIMED_OUT		(0x00000001)
1734
#define FIB_CONTEXT_FLAG			(0x00000002)
1735
#define FIB_CONTEXT_FLAG_WAIT			(0x00000004)
1736
#define FIB_CONTEXT_FLAG_FASTRESP		(0x00000008)
1737 1738
#define FIB_CONTEXT_FLAG_NATIVE_HBA		(0x00000010)
#define FIB_CONTEXT_FLAG_NATIVE_HBA_TMF	(0x00000020)
1739
#define FIB_CONTEXT_FLAG_SCSI_CMD	(0x00000040)
1740
#define FIB_CONTEXT_FLAG_EH_RESET	(0x00000080)
L
Linus Torvalds 已提交
1741 1742 1743 1744

/*
 *	Define the command values
 */
1745

L
Linus Torvalds 已提交
1746
#define		Null			0
1747 1748 1749 1750 1751 1752
#define		GetAttributes		1
#define		SetAttributes		2
#define		Lookup			3
#define		ReadLink		4
#define		Read			5
#define		Write			6
L
Linus Torvalds 已提交
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798
#define		Create			7
#define		MakeDirectory		8
#define		SymbolicLink		9
#define		MakeNode		10
#define		Removex			11
#define		RemoveDirectoryx	12
#define		Rename			13
#define		Link			14
#define		ReadDirectory		15
#define		ReadDirectoryPlus	16
#define		FileSystemStatus	17
#define		FileSystemInfo		18
#define		PathConfigure		19
#define		Commit			20
#define		Mount			21
#define		UnMount			22
#define		Newfs			23
#define		FsCheck			24
#define		FsSync			25
#define		SimReadWrite		26
#define		SetFileSystemStatus	27
#define		BlockRead		28
#define		BlockWrite		29
#define		NvramIoctl		30
#define		FsSyncWait		31
#define		ClearArchiveBit		32
#define		SetAcl			33
#define		GetAcl			34
#define		AssignAcl		35
#define		FaultInsertion		36	/* Fault Insertion Command */
#define		CrazyCache		37	/* Crazycache */

#define		MAX_FSACOMMAND_NUM	38


/*
 *	Define the status returns. These are very unixlike although
 *	most are not in fact used
 */

#define		ST_OK		0
#define		ST_PERM		1
#define		ST_NOENT	2
#define		ST_IO		5
#define		ST_NXIO		6
#define		ST_E2BIG	7
1799
#define		ST_MEDERR	8
L
Linus Torvalds 已提交
1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816
#define		ST_ACCES	13
#define		ST_EXIST	17
#define		ST_XDEV		18
#define		ST_NODEV	19
#define		ST_NOTDIR	20
#define		ST_ISDIR	21
#define		ST_INVAL	22
#define		ST_FBIG		27
#define		ST_NOSPC	28
#define		ST_ROFS		30
#define		ST_MLINK	31
#define		ST_WOULDBLOCK	35
#define		ST_NAMETOOLONG	63
#define		ST_NOTEMPTY	66
#define		ST_DQUOT	69
#define		ST_STALE	70
#define		ST_REMOTE	71
1817
#define		ST_NOT_READY	72
L
Linus Torvalds 已提交
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837
#define		ST_BADHANDLE	10001
#define		ST_NOT_SYNC	10002
#define		ST_BAD_COOKIE	10003
#define		ST_NOTSUPP	10004
#define		ST_TOOSMALL	10005
#define		ST_SERVERFAULT	10006
#define		ST_BADTYPE	10007
#define		ST_JUKEBOX	10008
#define		ST_NOTMOUNTED	10009
#define		ST_MAINTMODE	10010
#define		ST_STALEACL	10011

/*
 *	On writes how does the client want the data written.
 */

#define	CACHE_CSTABLE		1
#define CACHE_UNSTABLE		2

/*
L
Lucas De Marchi 已提交
1838
 *	Lets the client know at which level the data was committed on
L
Linus Torvalds 已提交
1839 1840 1841 1842 1843 1844 1845 1846 1847
 *	a write request
 */

#define	CMFILE_SYNCH_NVRAM	1
#define	CMDATA_SYNCH_NVRAM	2
#define	CMFILE_SYNCH		3
#define CMDATA_SYNCH		4
#define CMUNSTABLE		5

1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863
#define	RIO_TYPE_WRITE 			0x0000
#define	RIO_TYPE_READ			0x0001
#define	RIO_SUREWRITE			0x0008

#define RIO2_IO_TYPE			0x0003
#define RIO2_IO_TYPE_WRITE		0x0000
#define RIO2_IO_TYPE_READ		0x0001
#define RIO2_IO_TYPE_VERIFY		0x0002
#define RIO2_IO_ERROR			0x0004
#define RIO2_IO_SUREWRITE		0x0008
#define RIO2_SGL_CONFORMANT		0x0010
#define RIO2_SG_FORMAT			0xF000
#define RIO2_SG_FORMAT_ARC		0x0000
#define RIO2_SG_FORMAT_SRL		0x1000
#define RIO2_SG_FORMAT_IEEE1212		0x2000

L
Linus Torvalds 已提交
1864 1865
struct aac_read
{
1866 1867 1868 1869
	__le32		command;
	__le32		cid;
	__le32		block;
	__le32		count;
L
Linus Torvalds 已提交
1870 1871 1872 1873 1874
	struct sgmap	sg;	// Must be last in struct because it is variable
};

struct aac_read64
{
1875 1876 1877 1878
	__le32		command;
	__le16		cid;
	__le16		sector_count;
	__le32		block;
1879 1880
	__le16		pad;
	__le16		flags;
L
Linus Torvalds 已提交
1881 1882 1883 1884 1885
	struct sgmap64	sg;	// Must be last in struct because it is variable
};

struct aac_read_reply
{
1886 1887
	__le32		status;
	__le32		count;
L
Linus Torvalds 已提交
1888 1889 1890 1891
};

struct aac_write
{
1892
	__le32		command;
1893 1894 1895 1896
	__le32		cid;
	__le32		block;
	__le32		count;
	__le32		stable;	// Not used
L
Linus Torvalds 已提交
1897 1898 1899 1900 1901
	struct sgmap	sg;	// Must be last in struct because it is variable
};

struct aac_write64
{
1902 1903 1904 1905
	__le32		command;
	__le16		cid;
	__le16		sector_count;
	__le32		block;
1906 1907
	__le16		pad;
	__le16		flags;
L
Linus Torvalds 已提交
1908 1909 1910 1911
	struct sgmap64	sg;	// Must be last in struct because it is variable
};
struct aac_write_reply
{
1912
	__le32		status;
1913
	__le32		count;
1914
	__le32		committed;
L
Linus Torvalds 已提交
1915 1916
};

1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927
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;
};

1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943
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[1];
};

L
Linus Torvalds 已提交
1944 1945
#define CT_FLUSH_CACHE 129
struct aac_synchronize {
1946 1947 1948 1949 1950 1951 1952 1953
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_FLUSH_CACHE */
	__le32		cid;
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		count;	/* sizeof(((struct aac_synchronize_reply *)NULL)->data) */
L
Linus Torvalds 已提交
1954 1955 1956
};

struct aac_synchronize_reply {
1957 1958 1959 1960 1961 1962 1963 1964
	__le32		dummy0;
	__le32		dummy1;
	__le32		status;	/* CT_OK */
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		parm5;
L
Linus Torvalds 已提交
1965 1966 1967
	u8		data[16];
};

1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979
#define CT_POWER_MANAGEMENT	245
#define CT_PM_START_UNIT	2
#define CT_PM_STOP_UNIT		3
#define CT_PM_UNIT_IMMEDIATE	1
struct aac_power_management {
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_POWER_MANAGEMENT */
	__le32		sub;		/* CT_PM_* */
	__le32		cid;
	__le32		parm;		/* CT_PM_sub_* */
};

1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992
#define CT_PAUSE_IO    65
#define CT_RELEASE_IO  66
struct aac_pause {
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_PAUSE_IO */
	__le32		timeout;	/* 10ms ticks */
	__le32		min;
	__le32		noRescan;
	__le32		parm3;
	__le32		parm4;
	__le32		count;	/* sizeof(((struct aac_pause_reply *)NULL)->data) */
};

L
Linus Torvalds 已提交
1993
struct aac_srb
1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
{
	__le32		function;
	__le32		channel;
	__le32		id;
	__le32		lun;
	__le32		timeout;
	__le32		flags;
	__le32		count;		// Data xfer size
	__le32		retry_limit;
	__le32		cdb_size;
	u8		cdb[16];
	struct	sgmap	sg;
};

/*
2009
 * This and associated data structs are used by the
2010 2011 2012
 * ioctl caller and are in cpu order.
 */
struct user_aac_srb
L
Linus Torvalds 已提交
2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023
{
	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];
2024
	struct	user_sgmap	sg;
L
Linus Torvalds 已提交
2025 2026 2027 2028 2029 2030
};

#define		AAC_SENSE_BUFFERSIZE	 30

struct aac_srb_reply
{
2031 2032 2033 2034 2035
	__le32		status;
	__le32		srb_status;
	__le32		scsi_status;
	__le32		data_xfer_length;
	__le32		sense_data_size;
L
Linus Torvalds 已提交
2036 2037
	u8		sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE
};
2038 2039 2040 2041 2042 2043

struct aac_srb_unit {
	struct aac_srb		srb;
	struct aac_srb_reply	srb_reply;
};

L
Linus Torvalds 已提交
2044 2045 2046 2047 2048 2049
/*
 * SRB Flags
 */
#define		SRB_NoDataXfer		 0x0000
#define		SRB_DisableDisconnect	 0x0004
#define		SRB_DisableSynchTransfer 0x0008
2050
#define		SRB_BypassFrozenQueue	 0x0010
L
Linus Torvalds 已提交
2051 2052
#define		SRB_DisableAutosense	 0x0020
#define		SRB_DataIn		 0x0040
2053
#define		SRB_DataOut		 0x0080
L
Linus Torvalds 已提交
2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075

/*
 * SRB Functions - set in aac_srb->function
 */
#define	SRBF_ExecuteScsi	0x0000
#define	SRBF_ClaimDevice	0x0001
#define	SRBF_IO_Control		0x0002
#define	SRBF_ReceiveEvent	0x0003
#define	SRBF_ReleaseQueue	0x0004
#define	SRBF_AttachDevice	0x0005
#define	SRBF_ReleaseDevice	0x0006
#define	SRBF_Shutdown		0x0007
#define	SRBF_Flush		0x0008
#define	SRBF_AbortCommand	0x0010
#define	SRBF_ReleaseRecovery	0x0011
#define	SRBF_ResetBus		0x0012
#define	SRBF_ResetDevice	0x0013
#define	SRBF_TerminateIO	0x0014
#define	SRBF_FlushQueue		0x0015
#define	SRBF_RemoveDevice	0x0016
#define	SRBF_DomainValidation	0x0017

2076
/*
L
Linus Torvalds 已提交
2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135
 * SRB SCSI Status - set in aac_srb->scsi_status
 */
#define SRB_STATUS_PENDING                  0x00
#define SRB_STATUS_SUCCESS                  0x01
#define SRB_STATUS_ABORTED                  0x02
#define SRB_STATUS_ABORT_FAILED             0x03
#define SRB_STATUS_ERROR                    0x04
#define SRB_STATUS_BUSY                     0x05
#define SRB_STATUS_INVALID_REQUEST          0x06
#define SRB_STATUS_INVALID_PATH_ID          0x07
#define SRB_STATUS_NO_DEVICE                0x08
#define SRB_STATUS_TIMEOUT                  0x09
#define SRB_STATUS_SELECTION_TIMEOUT        0x0A
#define SRB_STATUS_COMMAND_TIMEOUT          0x0B
#define SRB_STATUS_MESSAGE_REJECTED         0x0D
#define SRB_STATUS_BUS_RESET                0x0E
#define SRB_STATUS_PARITY_ERROR             0x0F
#define SRB_STATUS_REQUEST_SENSE_FAILED     0x10
#define SRB_STATUS_NO_HBA                   0x11
#define SRB_STATUS_DATA_OVERRUN             0x12
#define SRB_STATUS_UNEXPECTED_BUS_FREE      0x13
#define SRB_STATUS_PHASE_SEQUENCE_FAILURE   0x14
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH     0x15
#define SRB_STATUS_REQUEST_FLUSHED          0x16
#define SRB_STATUS_DELAYED_RETRY	    0x17
#define SRB_STATUS_INVALID_LUN              0x20
#define SRB_STATUS_INVALID_TARGET_ID        0x21
#define SRB_STATUS_BAD_FUNCTION             0x22
#define SRB_STATUS_ERROR_RECOVERY           0x23
#define SRB_STATUS_NOT_STARTED		    0x24
#define SRB_STATUS_NOT_IN_USE		    0x30
#define SRB_STATUS_FORCE_ABORT		    0x31
#define SRB_STATUS_DOMAIN_VALIDATION_FAIL   0x32

/*
 * Object-Server / Volume-Manager Dispatch Classes
 */

#define		VM_Null			0
#define		VM_NameServe		1
#define		VM_ContainerConfig	2
#define		VM_Ioctl		3
#define		VM_FilesystemIoctl	4
#define		VM_CloseAll		5
#define		VM_CtBlockRead		6
#define		VM_CtBlockWrite		7
#define		VM_SliceBlockRead	8	/* raw access to configured "storage objects" */
#define		VM_SliceBlockWrite	9
#define		VM_DriveBlockRead	10	/* raw access to physical devices */
#define		VM_DriveBlockWrite	11
#define		VM_EnclosureMgt		12	/* enclosure management */
#define		VM_Unused		13	/* used to be diskset management */
#define		VM_CtBlockVerify	14
#define		VM_CtPerf		15	/* performance test */
#define		VM_CtBlockRead64	16
#define		VM_CtBlockWrite64	17
#define		VM_CtBlockVerify64	18
#define		VM_CtHostRead64		19
#define		VM_CtHostWrite64	20
2136 2137
#define		VM_DrvErrTblLog		21
#define		VM_NameServe64		22
2138
#define		VM_NameServeAllBlk	30
L
Linus Torvalds 已提交
2139

2140
#define		MAX_VMCOMMAND_NUM	23	/* used for sizing stats array - leave last */
L
Linus Torvalds 已提交
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150

/*
 *	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.
 */

struct aac_fsinfo {
2151 2152 2153 2154 2155 2156 2157 2158
	__le32  fsTotalSize;	/* Consumed by fs, incl. metadata */
	__le32  fsBlockSize;
	__le32  fsFragSize;
	__le32  fsMaxExtendSize;
	__le32  fsSpaceUnits;
	__le32  fsMaxNumFiles;
	__le32  fsNumFreeFiles;
	__le32  fsInodeDensity;
L
Linus Torvalds 已提交
2159 2160
};	/* valid iff ObjType == FT_FILESYS && !(ContentState & FSCS_NOTCLEAN) */

2161 2162
struct  aac_blockdevinfo {
	__le32	block_size;
2163 2164
	__le32  logical_phys_map;
	u8	identifier[16];
2165 2166
};

L
Linus Torvalds 已提交
2167
union aac_contentinfo {
2168 2169
	struct	aac_fsinfo		filesys;
	struct	aac_blockdevinfo	bdevinfo;
L
Linus Torvalds 已提交
2170 2171 2172 2173 2174 2175 2176 2177
};

/*
 *	Query for Container Configuration Status
 */

#define CT_GET_CONFIG_STATUS 147
struct aac_get_config_status {
2178 2179 2180 2181 2182 2183 2184 2185
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_GET_CONFIG_STATUS */
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		parm5;
	__le32		count;	/* sizeof(((struct aac_get_config_status_resp *)NULL)->data) */
L
Linus Torvalds 已提交
2186 2187 2188 2189 2190 2191
};

#define CFACT_CONTINUE 0
#define CFACT_PAUSE    1
#define CFACT_ABORT    2
struct aac_get_config_status_resp {
2192 2193 2194 2195 2196 2197 2198 2199
	__le32		response; /* ST_OK */
	__le32		dummy0;
	__le32		status;	/* CT_OK */
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		parm5;
L
Linus Torvalds 已提交
2200
	struct {
2201 2202 2203
		__le32	action; /* CFACT_CONTINUE, CFACT_PAUSE or CFACT_ABORT */
		__le16	flags;
		__le16	count;
L
Linus Torvalds 已提交
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213
	}		data;
};

/*
 *	Accept the configuration as-is
 */

#define CT_COMMIT_CONFIG 152

struct aac_commit_config {
2214 2215
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_COMMIT_CONFIG */
L
Linus Torvalds 已提交
2216 2217 2218
};

/*
2219
 *	Query for Container Configuration Status
L
Linus Torvalds 已提交
2220 2221 2222 2223
 */

#define CT_GET_CONTAINER_COUNT 4
struct aac_get_container_count {
2224 2225
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_GET_CONTAINER_COUNT */
L
Linus Torvalds 已提交
2226 2227 2228
};

struct aac_get_container_count_resp {
2229 2230 2231 2232 2233
	__le32		response; /* ST_OK */
	__le32		dummy0;
	__le32		MaxContainers;
	__le32		ContainerSwitchEntries;
	__le32		MaxPartitions;
2234
	__le32		MaxSimpleVolumes;
L
Linus Torvalds 已提交
2235 2236 2237 2238 2239 2240 2241 2242 2243
};


/*
 *	Query for "mountable" objects, ie, objects that are typically
 *	associated with a drive letter on the client (host) side.
 */

struct aac_mntent {
2244
	__le32			oid;
2245 2246 2247
	u8			name[16];	/* if applicable */
	struct creation_info	create_info;	/* if applicable */
	__le32			capacity;
2248 2249 2250
	__le32			vol;		/* substrate structure */
	__le32			obj;		/* FT_FILESYS, etc. */
	__le32			state;		/* unready for mounting,
2251
						   readonly, etc. */
2252
	union aac_contentinfo	fileinfo;	/* Info specific to content
2253
						   manager (eg, filesystem) */
2254
	__le32			altoid;		/* != oid <==> snapshot or
2255
						   broken mirror exists */
2256
	__le32			capacityhigh;
L
Linus Torvalds 已提交
2257 2258
};

2259
#define FSCS_NOTCLEAN	0x0001  /* fsck is necessary before mounting */
L
Linus Torvalds 已提交
2260 2261
#define FSCS_READONLY	0x0002	/* possible result of broken mirror */
#define FSCS_HIDDEN	0x0004	/* should be ignored - set during a clear */
2262
#define FSCS_NOT_READY	0x0008	/* Array spinning up to fulfil request */
L
Linus Torvalds 已提交
2263 2264

struct aac_query_mount {
2265 2266 2267
	__le32		command;
	__le32		type;
	__le32		count;
L
Linus Torvalds 已提交
2268 2269 2270
};

struct aac_mount {
2271
	__le32		status;
2272
	__le32		type;           /* should be same as that requested */
2273
	__le32		count;
L
Linus Torvalds 已提交
2274 2275 2276 2277 2278
	struct aac_mntent mnt[1];
};

#define CT_READ_NAME 130
struct aac_get_name {
2279 2280 2281 2282 2283 2284 2285 2286
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_READ_NAME */
	__le32		cid;
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		count;	/* sizeof(((struct aac_get_name_resp *)NULL)->data) */
L
Linus Torvalds 已提交
2287 2288 2289
};

struct aac_get_name_resp {
2290 2291 2292 2293 2294 2295 2296 2297
	__le32		dummy0;
	__le32		dummy1;
	__le32		status;	/* CT_OK */
	__le32		parm1;
	__le32		parm2;
	__le32		parm3;
	__le32		parm4;
	__le32		parm5;
2298
	u8		data[17];
L
Linus Torvalds 已提交
2299 2300
};

2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314
#define CT_CID_TO_32BITS_UID 165
struct aac_get_serial {
	__le32		command;	/* VM_ContainerConfig */
	__le32		type;		/* CT_CID_TO_32BITS_UID */
	__le32		cid;
};

struct aac_get_serial_resp {
	__le32		dummy0;
	__le32		dummy1;
	__le32		status;	/* CT_OK */
	__le32		uid;
};

L
Linus Torvalds 已提交
2315 2316 2317 2318 2319
/*
 * The following command is sent to shut down each container.
 */

struct aac_close {
2320 2321
	__le32	command;
	__le32	cid;
L
Linus Torvalds 已提交
2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
};

struct aac_query_disk
{
	s32	cnum;
	s32	bus;
	s32	id;
	s32	lun;
	u32	valid;
	u32	locked;
	u32	deleted;
	s32	instance;
	s8	name[10];
	u32	unmapped;
};

struct aac_delete_disk {
	u32	disknum;
	u32	cnum;
};
2342

L
Linus Torvalds 已提交
2343 2344 2345 2346 2347 2348 2349 2350 2351
struct fib_ioctl
{
	u32	fibctx;
	s32	wait;
	char	__user *fib;
};

struct revision
{
2352
	u32 compat;
2353 2354
	__le32 version;
	__le32 build;
L
Linus Torvalds 已提交
2355
};
2356

2357

L
Linus Torvalds 已提交
2358
/*
2359
 *	Ugly - non Linux like ioctl coding for back compat.
L
Linus Torvalds 已提交
2360 2361 2362 2363 2364 2365 2366
 */

#define CTL_CODE(function, method) (                 \
    (4<< 16) | ((function) << 2) | (method) \
)

/*
2367
 *	Define the method codes for how buffers are passed for I/O and FS
L
Linus Torvalds 已提交
2368 2369 2370 2371 2372 2373 2374 2375 2376 2377
 *	controls
 */

#define METHOD_BUFFERED                 0
#define METHOD_NEITHER                  3

/*
 *	Filesystem ioctls
 */

2378 2379
#define FSACTL_SENDFIB				CTL_CODE(2050, METHOD_BUFFERED)
#define FSACTL_SEND_RAW_SRB			CTL_CODE(2067, METHOD_BUFFERED)
L
Linus Torvalds 已提交
2380 2381 2382 2383 2384 2385
#define FSACTL_DELETE_DISK			0x163
#define FSACTL_QUERY_DISK			0x173
#define FSACTL_OPEN_GET_ADAPTER_FIB		CTL_CODE(2100, METHOD_BUFFERED)
#define FSACTL_GET_NEXT_ADAPTER_FIB		CTL_CODE(2101, METHOD_BUFFERED)
#define FSACTL_CLOSE_GET_ADAPTER_FIB		CTL_CODE(2102, METHOD_BUFFERED)
#define FSACTL_MINIPORT_REV_CHECK               CTL_CODE(2107, METHOD_BUFFERED)
2386
#define FSACTL_GET_PCI_INFO			CTL_CODE(2119, METHOD_BUFFERED)
L
Linus Torvalds 已提交
2387 2388
#define FSACTL_FORCE_DELETE_DISK		CTL_CODE(2120, METHOD_NEITHER)
#define FSACTL_GET_CONTAINERS			2131
2389
#define FSACTL_SEND_LARGE_FIB			CTL_CODE(2138, METHOD_BUFFERED)
2390
#define FSACTL_RESET_IOP			CTL_CODE(2140, METHOD_BUFFERED)
2391
#define FSACTL_GET_HBA_INFO			CTL_CODE(2150, METHOD_BUFFERED)
2392 2393 2394 2395 2396 2397 2398
/* flags defined for IOP & HW SOFT RESET */
#define HW_IOP_RESET				0x01
#define HW_SOFT_RESET				0x02
#define IOP_HWSOFT_RESET			(HW_IOP_RESET | HW_SOFT_RESET)
/* HW Soft Reset register offset */
#define IBW_SWR_OFFSET				0x4000
#define SOFT_RESET_TIME			60
L
Linus Torvalds 已提交
2399 2400


2401

L
Linus Torvalds 已提交
2402 2403 2404
struct aac_common
{
	/*
2405
	 *	If this value is set to 1 then interrupt moderation will occur
L
Linus Torvalds 已提交
2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417
	 *	in the base commuication support.
	 */
	u32 irq_mod;
	u32 peak_fibs;
	u32 zero_fibs;
	u32 fib_timeouts;
	/*
	 *	Statistical counters in debug mode
	 */
#ifdef DBG
	u32 FibsSent;
	u32 FibRecved;
2418 2419
	u32 NativeSent;
	u32 NativeRecved;
L
Linus Torvalds 已提交
2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430
	u32 NoResponseSent;
	u32 NoResponseRecved;
	u32 AsyncSent;
	u32 AsyncRecved;
	u32 NormalSent;
	u32 NormalRecved;
#endif
};

extern struct aac_common aac_config;

2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481
/*
 * This is for management ioctl purpose only.
 */
struct aac_hba_info {

	u8	driver_name[50];
	u8	adapter_number;
	u8	system_io_bus_number;
	u8	device_number;
	u32	function_number;
	u32	vendor_id;
	u32	device_id;
	u32	sub_vendor_id;
	u32	sub_system_id;
	u32	mapped_base_address_size;
	u32	base_physical_address_high_part;
	u32	base_physical_address_low_part;

	u32	max_command_size;
	u32	max_fib_size;
	u32	max_scatter_gather_from_os;
	u32	max_scatter_gather_to_fw;
	u32	max_outstanding_fibs;

	u32	queue_start_threshold;
	u32	queue_dump_threshold;
	u32	max_io_size_queued;
	u32	outstanding_io;

	u32	firmware_build_number;
	u32	bios_build_number;
	u32	driver_build_number;
	u32	serial_number_high_part;
	u32	serial_number_low_part;
	u32	supported_options;
	u32	feature_bits;
	u32	currentnumber_ports;

	u8	new_comm_interface:1;
	u8	new_commands_supported:1;
	u8	disable_passthrough:1;
	u8	expose_non_dasd:1;
	u8	queue_allowed:1;
	u8	bled_check_enabled:1;
	u8	reserved1:1;
	u8	reserted2:1;

	u32	reserved3[10];

};

L
Linus Torvalds 已提交
2482 2483 2484 2485
/*
 *	The following macro is used when sending and receiving FIBs. It is
 *	only used for debugging.
 */
2486

L
Linus Torvalds 已提交
2487 2488 2489
#ifdef DBG
#define	FIB_COUNTER_INCREMENT(counter)		(counter)++
#else
2490
#define	FIB_COUNTER_INCREMENT(counter)
L
Linus Torvalds 已提交
2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508
#endif

/*
 *	Adapter direct commands
 *	Monitor/Kernel API
 */

#define	BREAKPOINT_REQUEST		0x00000004
#define	INIT_STRUCT_BASE_ADDRESS	0x00000005
#define READ_PERMANENT_PARAMETERS	0x0000000a
#define WRITE_PERMANENT_PARAMETERS	0x0000000b
#define HOST_CRASHING			0x0000000d
#define	SEND_SYNCHRONOUS_FIB		0x0000000c
#define COMMAND_POST_RESULTS		0x00000014
#define GET_ADAPTER_PROPERTIES		0x00000019
#define GET_DRIVER_BUFFER_PROPERTIES	0x00000023
#define RCV_TEMP_READINGS		0x00000025
#define GET_COMM_PREFERRED_SETTINGS	0x00000026
2509
#define IOP_RESET_FW_FIB_DUMP		0x00000034
2510
#define DROP_IO			0x00000035
L
Linus Torvalds 已提交
2511
#define IOP_RESET			0x00001000
2512
#define IOP_RESET_ALWAYS		0x00001001
2513 2514 2515
#define RE_INIT_ADAPTER		0x000000ee

#define IOP_SRC_RESET_MASK		0x00000100
L
Linus Torvalds 已提交
2516 2517 2518 2519 2520 2521 2522 2523 2524 2525

/*
 *	Adapter Status Register
 *
 *  Phase Staus mailbox is 32bits:
 *	<31:16> = Phase Status
 *	<15:0>  = Phase
 *
 *	The adapter reports is present state through the phase.  Only
 *	a single phase should be ever be set.  Each phase can have multiple
2526 2527
 *	phase status bits to provide more detailed information about the
 *	state of the board.  Care should be taken to ensure that any phase
L
Linus Torvalds 已提交
2528 2529
 *	status bits that are set when changing the phase are also valid
 *	for the new phase or be cleared out.  Adapter software (monitor,
2530
 *	iflash, kernel) is responsible for properly maintining the phase
L
Linus Torvalds 已提交
2531 2532
 *	status mailbox when it is running.
 *
2533 2534 2535 2536
 *	MONKER_API Phases
 *
 *	Phases are bit oriented.  It is NOT valid  to have multiple bits set
 */
L
Linus Torvalds 已提交
2537 2538 2539

#define	SELF_TEST_FAILED		0x00000004
#define	MONITOR_PANIC			0x00000020
2540
#define	KERNEL_BOOTING			0x00000040
L
Linus Torvalds 已提交
2541 2542
#define	KERNEL_UP_AND_RUNNING		0x00000080
#define	KERNEL_PANIC			0x00000100
2543 2544 2545
#define	FLASH_UPD_PENDING		0x00002000
#define	FLASH_UPD_SUCCESS		0x00004000
#define	FLASH_UPD_FAILED		0x00008000
2546
#define	INVALID_OMR			0xffffffff
2547
#define	FWUPD_TIMEOUT			(5 * 60)
L
Linus Torvalds 已提交
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559

/*
 *	Doorbell bit defines
 */

#define DoorBellSyncCmdAvailable	(1<<0)	/* Host -> Adapter */
#define DoorBellPrintfDone		(1<<5)	/* Host -> Adapter */
#define DoorBellAdapterNormCmdReady	(1<<1)	/* Adapter -> Host */
#define DoorBellAdapterNormRespReady	(1<<2)	/* Adapter -> Host */
#define DoorBellAdapterNormCmdNotFull	(1<<3)	/* Adapter -> Host */
#define DoorBellAdapterNormRespNotFull	(1<<4)	/* Adapter -> Host */
#define DoorBellPrintfReady		(1<<5)	/* Adapter -> Host */
2560 2561 2562 2563
#define DoorBellAifPending		(1<<6)	/* Adapter -> Host */

/* PMC specific outbound doorbell bits */
#define PmDoorBellResponseSent		(1<<1)	/* Adapter -> Host */
L
Linus Torvalds 已提交
2564 2565 2566 2567 2568

/*
 *	For FIB communication, we need all of the following things
 *	to send back to the user.
 */
2569 2570

#define		AifCmdEventNotify	1	/* Notify of event */
L
Linus Torvalds 已提交
2571 2572 2573
#define			AifEnConfigChange	3	/* Adapter configuration change */
#define			AifEnContainerChange	4	/* Container configuration change */
#define			AifEnDeviceFailure	5	/* SCSI device failed */
2574 2575 2576
#define			AifEnEnclosureManagement 13	/* EM_DRIVE_* */
#define				EM_DRIVE_INSERTION	31
#define				EM_DRIVE_REMOVAL	32
2577 2578
#define			EM_SES_DRIVE_INSERTION	33
#define			EM_SES_DRIVE_REMOVAL	26
2579
#define			AifEnBatteryEvent	14	/* Change in Battery State */
L
Linus Torvalds 已提交
2580 2581 2582 2583 2584
#define			AifEnAddContainer	15	/* A new array was created */
#define			AifEnDeleteContainer	16	/* A container was deleted */
#define			AifEnExpEvent		23	/* Firmware Event Log */
#define			AifExeFirmwarePanic	3	/* Firmware Event Panic */
#define			AifHighPriority		3	/* Highest Priority Event */
2585 2586
#define			AifEnAddJBOD		30	/* JBOD created */
#define			AifEnDeleteJBOD		31	/* JBOD deleted */
L
Linus Torvalds 已提交
2587

2588 2589 2590 2591
#define			AifBuManagerEvent		42 /* Bu management*/
#define			AifBuCacheDataLoss		10
#define			AifBuCacheDataRecover	11

L
Linus Torvalds 已提交
2592 2593 2594
#define		AifCmdJobProgress	2	/* Progress report */
#define			AifJobCtrZero	101	/* Array Zero progress */
#define			AifJobStsSuccess 1	/* Job completes */
2595
#define			AifJobStsRunning 102	/* Job running */
L
Linus Torvalds 已提交
2596 2597 2598 2599 2600 2601
#define		AifCmdAPIReport		3	/* Report from other user of API */
#define		AifCmdDriverNotify	4	/* Notify host driver of event */
#define			AifDenMorphComplete 200	/* A morph operation completed */
#define			AifDenVolumeExtendComplete 201 /* A volume extend completed */
#define		AifReqJobList		100	/* Gets back complete job list */
#define		AifReqJobsForCtr	101	/* Gets back jobs for specific container */
2602 2603
#define		AifReqJobsForScsi	102	/* Gets back jobs for specific SCSI device */
#define		AifReqJobReport		103	/* Gets back a specific job report or list of them */
L
Linus Torvalds 已提交
2604 2605
#define		AifReqTerminateJob	104	/* Terminates job */
#define		AifReqSuspendJob	105	/* Suspends a job */
2606
#define		AifReqResumeJob		106	/* Resumes a job */
L
Linus Torvalds 已提交
2607 2608 2609 2610 2611
#define		AifReqSendAPIReport	107	/* API generic report requests */
#define		AifReqAPIJobStart	108	/* Start a job from the API */
#define		AifReqAPIJobUpdate	109	/* Update a job report from the API */
#define		AifReqAPIJobFinish	110	/* Finish a job from the API */

2612 2613
/* PMC NEW COMM: Request the event data */
#define		AifReqEvent		200
2614 2615 2616
#define		AifRawDeviceRemove	203	/* RAW device deleted */
#define		AifNativeDeviceAdd	204	/* native HBA device added */
#define		AifNativeDeviceRemove	205	/* native HBA device removed */
2617

2618

L
Linus Torvalds 已提交
2619 2620 2621 2622 2623 2624 2625
/*
 *	Adapter Initiated FIB command structures. Start with the adapter
 *	initiated FIBs that really come from the adapter, and get responded
 *	to by the host.
 */

struct aac_aifcmd {
2626 2627
	__le32 command;		/* Tell host what type of notify this is */
	__le32 seqnum;		/* To allow ordering of reports (if necessary) */
L
Linus Torvalds 已提交
2628 2629 2630 2631
	u8 data[1];		/* Undefined length (from kernel viewpoint) */
};

/**
2632 2633
 *	Convert capacity to cylinders
 *	accounting for the fact capacity could be a 64 bit value
L
Linus Torvalds 已提交
2634 2635
 *
 */
2636
static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
L
Linus Torvalds 已提交
2637 2638
{
	sector_div(capacity, divisor);
2639
	return capacity;
L
Linus Torvalds 已提交
2640 2641
}

2642 2643 2644 2645 2646 2647 2648 2649
static inline int aac_adapter_check_health(struct aac_dev *dev)
{
	if (unlikely(pci_channel_offline(dev->pdev)))
		return -1;

	return (dev)->a_ops.adapter_check_health(dev);
}

2650

2651
int aac_scan_host(struct aac_dev *dev);
2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662

static inline void aac_schedule_safw_scan_worker(struct aac_dev *dev)
{
	schedule_delayed_work(&dev->safw_rescan_work, AAC_SAFW_RESCAN_DELAY);
}

static inline void aac_safw_rescan_worker(struct work_struct *work)
{
	struct aac_dev *dev = container_of(to_delayed_work(work),
		struct aac_dev, safw_rescan_work);

2663 2664 2665
	wait_event(dev->scsi_host_ptr->host_wait,
		!scsi_host_in_recovery(dev->scsi_host_ptr));

2666
	aac_scan_host(dev);
2667 2668 2669 2670 2671 2672 2673 2674
}

static inline void aac_cancel_safw_rescan_worker(struct aac_dev *dev)
{
	if (dev->sa_firmware)
		cancel_delayed_work_sync(&dev->safw_rescan_work);
}

2675 2676 2677 2678 2679
/* SCp.phase values */
#define AAC_OWNER_MIDLEVEL	0x101
#define AAC_OWNER_LOWLEVEL	0x102
#define AAC_OWNER_ERROR_HANDLER	0x103
#define AAC_OWNER_FIRMWARE	0x106
L
Linus Torvalds 已提交
2680

2681
void aac_safw_rescan_worker(struct work_struct *work);
2682 2683
int aac_acquire_irq(struct aac_dev *dev);
void aac_free_irq(struct aac_dev *dev);
2684
int aac_setup_safw_adapter(struct aac_dev *dev);
L
Linus Torvalds 已提交
2685
const char *aac_driverinfo(struct Scsi_Host *);
2686
void aac_fib_vector_assign(struct aac_dev *dev);
2687
struct fib *aac_fib_alloc(struct aac_dev *dev);
2688
struct fib *aac_fib_alloc_tag(struct aac_dev *dev, struct scsi_cmnd *scmd);
2689 2690 2691 2692
int aac_fib_setup(struct aac_dev *dev);
void aac_fib_map_free(struct aac_dev *dev);
void aac_fib_free(struct fib * context);
void aac_fib_init(struct fib * context);
L
Linus Torvalds 已提交
2693
void aac_printf(struct aac_dev *dev, u32 val);
2694
int aac_fib_send(u16 command, struct fib * context, unsigned long size, int priority, int wait, int reply, fib_callback callback, void *ctxt);
2695 2696
int aac_hba_send(u8 command, struct fib *context,
		fib_callback callback, void *ctxt);
L
Linus Torvalds 已提交
2697 2698
int aac_consumer_get(struct aac_dev * dev, struct aac_queue * q, struct aac_entry **entry);
void aac_consumer_free(struct aac_dev * dev, struct aac_queue * q, u32 qnum);
2699
int aac_fib_complete(struct fib * context);
2700
void aac_hba_callback(void *context, struct fib *fibptr);
2701
#define fib_data(fibctx) ((void *)(fibctx)->hw_fib_va->data)
L
Linus Torvalds 已提交
2702
struct aac_dev *aac_init_adapter(struct aac_dev *dev);
M
Mahesh Rajashekhara 已提交
2703
void aac_src_access_devreg(struct aac_dev *dev, int mode);
2704
void aac_set_intx_mode(struct aac_dev *dev);
2705
int aac_get_config_status(struct aac_dev *dev, int commit_flag);
L
Linus Torvalds 已提交
2706 2707 2708
int aac_get_containers(struct aac_dev *dev);
int aac_scsi_cmd(struct scsi_cmnd *cmd);
int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
2709
#ifndef shost_to_class
2710
#define shost_to_class(shost) &shost->shost_dev
2711
#endif
2712
ssize_t aac_get_serial_number(struct device *dev, char *buf);
L
Linus Torvalds 已提交
2713 2714 2715
int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg);
int aac_rx_init(struct aac_dev *dev);
int aac_rkt_init(struct aac_dev *dev);
2716
int aac_nark_init(struct aac_dev *dev);
L
Linus Torvalds 已提交
2717
int aac_sa_init(struct aac_dev *dev);
2718
int aac_src_init(struct aac_dev *dev);
2719
int aac_srcv_init(struct aac_dev *dev);
2720
int aac_queue_get(struct aac_dev * dev, u32 * index, u32 qid, struct hw_fib * hw_fib, int wait, struct fib * fibptr, unsigned long *nonotify);
2721
void aac_define_int_mode(struct aac_dev *dev);
L
Linus Torvalds 已提交
2722 2723
unsigned int aac_response_normal(struct aac_queue * q);
unsigned int aac_command_normal(struct aac_queue * q);
2724 2725 2726
unsigned int aac_intr_normal(struct aac_dev *dev, u32 Index,
			int isAif, int isFastResponse,
			struct hw_fib *aif_fib);
2727
int aac_reset_adapter(struct aac_dev *dev, int forced, u8 reset_type);
2728
int aac_check_health(struct aac_dev * dev);
2729
int aac_command_thread(void *data);
L
Linus Torvalds 已提交
2730
int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context *fibctx);
2731
int aac_fib_adapter_complete(struct fib * fibptr, unsigned short size);
L
Linus Torvalds 已提交
2732 2733 2734
struct aac_driver_ident* aac_get_driver_ident(int devtype);
int aac_get_adapter_info(struct aac_dev* dev);
int aac_send_shutdown(struct aac_dev *dev);
2735
int aac_probe_container(struct aac_dev *dev, int cid);
A
Adrian Bunk 已提交
2736 2737
int _aac_rx_init(struct aac_dev *dev);
int aac_rx_select_comm(struct aac_dev *dev, int comm);
2738
int aac_rx_deliver_producer(struct fib * fib);
2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750

static inline int aac_is_src(struct aac_dev *dev)
{
	u16 device = dev->pdev->device;

	if (device == PMC_DEVICE_S6 ||
		device == PMC_DEVICE_S7 ||
		device == PMC_DEVICE_S8)
		return 1;
	return 0;
}

2751 2752 2753 2754 2755
static inline int aac_supports_2T(struct aac_dev *dev)
{
	return (dev->adapter_info.options & AAC_OPT_NEW_COMM_64);
}

2756
char * get_container_type(unsigned type);
2757
extern int numacb;
2758
extern char aac_driver_version[];
2759 2760
extern int startup_timeout;
extern int aif_timeout;
A
Adrian Bunk 已提交
2761
extern int expose_physicals;
2762
extern int aac_reset_devices;
2763
extern int aac_msi;
2764
extern int aac_commit;
2765 2766
extern int update_interval;
extern int check_interval;
A
Andrew Morton 已提交
2767
extern int aac_check_reset;
2768
extern int aac_fib_dump;
2769
#endif