Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
megaraid_sas.h
Go to the documentation of this file.
1 /*
2  * Linux MegaRAID driver for SAS based RAID controllers
3  *
4  * Copyright (c) 2003-2012 LSI Corporation.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * FILE: megaraid_sas.h
21  *
22  * Authors: LSI Corporation
23  *
24  * Send feedback to: <[email protected]>
25  *
26  * Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035
27  * ATTN: Linuxraid
28  */
29 
30 #ifndef LSI_MEGARAID_SAS_H
31 #define LSI_MEGARAID_SAS_H
32 
33 /*
34  * MegaRAID SAS Driver meta data
35  */
36 #define MEGASAS_VERSION "06.504.01.00-rc1"
37 #define MEGASAS_RELDATE "Oct. 1, 2012"
38 #define MEGASAS_EXT_VERSION "Mon. Oct. 1 17:00:00 PDT 2012"
39 
40 /*
41  * Device IDs
42  */
43 #define PCI_DEVICE_ID_LSI_SAS1078R 0x0060
44 #define PCI_DEVICE_ID_LSI_SAS1078DE 0x007C
45 #define PCI_DEVICE_ID_LSI_VERDE_ZCR 0x0413
46 #define PCI_DEVICE_ID_LSI_SAS1078GEN2 0x0078
47 #define PCI_DEVICE_ID_LSI_SAS0079GEN2 0x0079
48 #define PCI_DEVICE_ID_LSI_SAS0073SKINNY 0x0073
49 #define PCI_DEVICE_ID_LSI_SAS0071SKINNY 0x0071
50 #define PCI_DEVICE_ID_LSI_FUSION 0x005b
51 #define PCI_DEVICE_ID_LSI_INVADER 0x005d
52 
53 /*
54  * =====================================
55  * MegaRAID SAS MFI firmware definitions
56  * =====================================
57  */
58 
59 /*
60  * MFI stands for MegaRAID SAS FW Interface. This is just a moniker for
61  * protocol between the software and firmware. Commands are issued using
62  * "message frames"
63  */
64 
65 /*
66  * FW posts its state in upper 4 bits of outbound_msg_0 register
67  */
68 #define MFI_STATE_MASK 0xF0000000
69 #define MFI_STATE_UNDEFINED 0x00000000
70 #define MFI_STATE_BB_INIT 0x10000000
71 #define MFI_STATE_FW_INIT 0x40000000
72 #define MFI_STATE_WAIT_HANDSHAKE 0x60000000
73 #define MFI_STATE_FW_INIT_2 0x70000000
74 #define MFI_STATE_DEVICE_SCAN 0x80000000
75 #define MFI_STATE_BOOT_MESSAGE_PENDING 0x90000000
76 #define MFI_STATE_FLUSH_CACHE 0xA0000000
77 #define MFI_STATE_READY 0xB0000000
78 #define MFI_STATE_OPERATIONAL 0xC0000000
79 #define MFI_STATE_FAULT 0xF0000000
80 #define MFI_RESET_REQUIRED 0x00000001
81 #define MFI_RESET_ADAPTER 0x00000002
82 #define MEGAMFI_FRAME_SIZE 64
83 
84 /*
85  * During FW init, clear pending cmds & reset state using inbound_msg_0
86  *
87  * ABORT : Abort all pending cmds
88  * READY : Move from OPERATIONAL to READY state; discard queue info
89  * MFIMODE : Discard (possible) low MFA posted in 64-bit mode (??)
90  * CLR_HANDSHAKE: FW is waiting for HANDSHAKE from BIOS or Driver
91  * HOTPLUG : Resume from Hotplug
92  * MFI_STOP_ADP : Send signal to FW to stop processing
93  */
94 #define WRITE_SEQUENCE_OFFSET (0x0000000FC) /* I20 */
95 #define HOST_DIAGNOSTIC_OFFSET (0x000000F8) /* I20 */
96 #define DIAG_WRITE_ENABLE (0x00000080)
97 #define DIAG_RESET_ADAPTER (0x00000004)
98 
99 #define MFI_ADP_RESET 0x00000040
100 #define MFI_INIT_ABORT 0x00000001
101 #define MFI_INIT_READY 0x00000002
102 #define MFI_INIT_MFIMODE 0x00000004
103 #define MFI_INIT_CLEAR_HANDSHAKE 0x00000008
104 #define MFI_INIT_HOTPLUG 0x00000010
105 #define MFI_STOP_ADP 0x00000020
106 #define MFI_RESET_FLAGS MFI_INIT_READY| \
107  MFI_INIT_MFIMODE| \
108  MFI_INIT_ABORT
109 
110 /*
111  * MFI frame flags
112  */
113 #define MFI_FRAME_POST_IN_REPLY_QUEUE 0x0000
114 #define MFI_FRAME_DONT_POST_IN_REPLY_QUEUE 0x0001
115 #define MFI_FRAME_SGL32 0x0000
116 #define MFI_FRAME_SGL64 0x0002
117 #define MFI_FRAME_SENSE32 0x0000
118 #define MFI_FRAME_SENSE64 0x0004
119 #define MFI_FRAME_DIR_NONE 0x0000
120 #define MFI_FRAME_DIR_WRITE 0x0008
121 #define MFI_FRAME_DIR_READ 0x0010
122 #define MFI_FRAME_DIR_BOTH 0x0018
123 #define MFI_FRAME_IEEE 0x0020
124 
125 /*
126  * Definition for cmd_status
127  */
128 #define MFI_CMD_STATUS_POLL_MODE 0xFF
129 
130 /*
131  * MFI command opcodes
132  */
133 #define MFI_CMD_INIT 0x00
134 #define MFI_CMD_LD_READ 0x01
135 #define MFI_CMD_LD_WRITE 0x02
136 #define MFI_CMD_LD_SCSI_IO 0x03
137 #define MFI_CMD_PD_SCSI_IO 0x04
138 #define MFI_CMD_DCMD 0x05
139 #define MFI_CMD_ABORT 0x06
140 #define MFI_CMD_SMP 0x07
141 #define MFI_CMD_STP 0x08
142 #define MFI_CMD_INVALID 0xff
143 
144 #define MR_DCMD_CTRL_GET_INFO 0x01010000
145 #define MR_DCMD_LD_GET_LIST 0x03010000
146 
147 #define MR_DCMD_CTRL_CACHE_FLUSH 0x01101000
148 #define MR_FLUSH_CTRL_CACHE 0x01
149 #define MR_FLUSH_DISK_CACHE 0x02
150 
151 #define MR_DCMD_CTRL_SHUTDOWN 0x01050000
152 #define MR_DCMD_HIBERNATE_SHUTDOWN 0x01060000
153 #define MR_ENABLE_DRIVE_SPINDOWN 0x01
154 
155 #define MR_DCMD_CTRL_EVENT_GET_INFO 0x01040100
156 #define MR_DCMD_CTRL_EVENT_GET 0x01040300
157 #define MR_DCMD_CTRL_EVENT_WAIT 0x01040500
158 #define MR_DCMD_LD_GET_PROPERTIES 0x03030000
159 
160 #define MR_DCMD_CLUSTER 0x08000000
161 #define MR_DCMD_CLUSTER_RESET_ALL 0x08010100
162 #define MR_DCMD_CLUSTER_RESET_LD 0x08010200
163 #define MR_DCMD_PD_LIST_QUERY 0x02010100
164 
165 /*
166  * MFI command completion codes
167  */
168 enum MFI_STAT {
169  MFI_STAT_OK = 0x00,
227 
229 };
230 
231 /*
232  * Number of mailbox bytes in DCMD message frame
233  */
234 #define MFI_MBOX_SIZE 12
235 
237 
245 
246 };
247 
249 
259 
260 };
261 
263 
301 };
302 
303 /*
304  * define constants for device list query options
305  */
313 };
314 
315 #define MR_EVT_CFG_CLEARED 0x0004
316 #define MR_EVT_LD_STATE_CHANGE 0x0051
317 #define MR_EVT_PD_INSERTED 0x005b
318 #define MR_EVT_PD_REMOVED 0x0070
319 #define MR_EVT_LD_CREATED 0x008a
320 #define MR_EVT_LD_DELETED 0x008b
321 #define MR_EVT_FOREIGN_CFG_IMPORTED 0x00db
322 #define MR_EVT_LD_OFFLINE 0x00fc
323 #define MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED 0x0152
324 #define MAX_LOGICAL_DRIVES 64
325 
336  };
337 
338 
339  /*
340  * defines the physical drive address structure
341  */
345 
346  union {
347  struct {
350  } mrPdAddress;
351  struct {
354  } mrEnclAddress;
355  };
357  union {
360  };
362 } __packed;
363 
364 /*
365  * defines the physical drive list structure
366  */
367 struct MR_PD_LIST {
370  struct MR_PD_ADDRESS addr[1];
371 } __packed;
372 
377 } __packed;
378 
379  /*
380  * defines the logical drive reference structure
381  */
382 union MR_LD_REF {
383  struct {
387  };
389 } __packed;
390 
391 /*
392  * defines the logical drive list structure
393  */
394 struct MR_LD_LIST {
397  struct {
398  union MR_LD_REF ref;
403 } __packed;
404 
405 /*
406  * SAS controller properties
407  */
409 
436 
438 
439  /*
440  * Add properties that can be controlled by
441  * a bit in the following structure.
442  */
443  struct {
459  } OnOffProperties;
464 } __packed;
465 
466 /*
467  * SAS controller information
468  */
470 
471  /*
472  * PCI device information
473  */
474  struct {
475 
481 
482  } __attribute__ ((packed)) pci;
483 
484  /*
485  * Host interface information
486  */
489  u8 PCIX:1;
490  u8 PCIE:1;
497 
498  } __attribute__ ((packed)) host_interface;
499 
500  /*
501  * Device (backend) interface information
502  */
505  u8 SPI:1;
509  u8 reserved_0:4;
510  u8 reserved_1[6];
511  u8 port_count;
512  u64 port_addr[8];
513 
514  } __attribute__ ((packed)) device_interface;
515 
516  /*
517  * List of components residing in flash. All str are null terminated
518  */
521 
522  struct {
523 
524  char name[8];
525  char version[32];
526  char build_date[16];
527  char built_time[16];
528 
529  } __attribute__ ((packed)) image_component[8];
530 
531  /*
532  * List of flash components that have been flashed on the card, but
533  * are not in use, pending reset of the adapter. This list will be
534  * empty if a flash operation has not occurred. All stings are null
535  * terminated
536  */
538 
539  struct {
540 
541  char name[8];
542  char version[32];
543  char build_date[16];
544  char build_time[16];
545 
546  } __attribute__ ((packed)) pending_image_component[8];
547 
552 
553  char product_name[80];
554  char serial_no[32];
555 
556  /*
557  * Other physical/controller/operation information. Indicates the
558  * presence of the hardware
559  */
560  struct {
561 
562  u32 bbu:1;
567 
568  } __attribute__ ((packed)) hw_present;
569 
572  /*
573  * Maximum data transfer sizes
574  */
578 
579  /*
580  * Logical and physical device counts
581  */
585 
590 
591  /*
592  * Memory size information
593  */
597 
598  /*
599  * Error counters
600  */
603 
604  /*
605  * Cluster information
606  */
609 
610  /*
611  * Additional max data transfer sizes
612  */
614 
615  /*
616  * Controller capabilities structures
617  */
618  struct {
619 
625  u32 reserved:27;
626 
627  } __attribute__ ((packed)) raid_levels;
628 
638  u32 bbu:1;
646  u32 reserved:17;
647 
648  } __attribute__ ((packed)) adapter_operations;
649 
657  u32 reserved:27;
659  } __attribute__ ((packed)) ld_operations;
666 
667  } __attribute__ ((packed)) stripe_sz_ops;
668 
674  u32 reserved:29;
675 
676  } __attribute__ ((packed)) pd_operations;
677 
685  u32 reserved:27;
686 
687  } __attribute__ ((packed)) pd_mix_support;
688 
689  /*
690  * Define ECC single-bit-error bucket information
691  */
694 
695  /*
696  * Include the controller properties (changeable items)
697  */
699 
700  /*
701  * Define FW pkg version (set in envt v'bles on OEM basis)
702  */
703  char package_version[0x60];
704 
705  u8 pad[0x800 - 0x6a0];
706 
707 } __packed;
708 
709 /*
710  * ===============================
711  * MegaRAID SAS driver definitions
712  * ===============================
713  */
714 #define MEGASAS_MAX_PD_CHANNELS 2
715 #define MEGASAS_MAX_LD_CHANNELS 2
716 #define MEGASAS_MAX_CHANNELS (MEGASAS_MAX_PD_CHANNELS + \
717  MEGASAS_MAX_LD_CHANNELS)
718 #define MEGASAS_MAX_DEV_PER_CHANNEL 128
719 #define MEGASAS_DEFAULT_INIT_ID -1
720 #define MEGASAS_MAX_LUN 8
721 #define MEGASAS_MAX_LD 64
722 #define MEGASAS_DEFAULT_CMD_PER_LUN 256
723 #define MEGASAS_MAX_PD (MEGASAS_MAX_PD_CHANNELS * \
724  MEGASAS_MAX_DEV_PER_CHANNEL)
725 #define MEGASAS_MAX_LD_IDS (MEGASAS_MAX_LD_CHANNELS * \
726  MEGASAS_MAX_DEV_PER_CHANNEL)
727 
728 #define MEGASAS_MAX_SECTORS (2*1024)
729 #define MEGASAS_MAX_SECTORS_IEEE (2*128)
730 #define MEGASAS_DBG_LVL 1
731 
732 #define MEGASAS_FW_BUSY 1
733 
734 /* Frame Type */
735 #define IO_FRAME 0
736 #define PTHRU_FRAME 1
737 
738 /*
739  * When SCSI mid-layer calls driver's reset routine, driver waits for
740  * MEGASAS_RESET_WAIT_TIME seconds for all outstanding IO to complete. Note
741  * that the driver cannot _actually_ abort or reset pending commands. While
742  * it is waiting for the commands to complete, it prints a diagnostic message
743  * every MEGASAS_RESET_NOTICE_INTERVAL seconds
744  */
745 #define MEGASAS_RESET_WAIT_TIME 180
746 #define MEGASAS_INTERNAL_CMD_WAIT_TIME 180
747 #define MEGASAS_RESET_NOTICE_INTERVAL 5
748 #define MEGASAS_IOCTL_CMD 0
749 #define MEGASAS_DEFAULT_CMD_TIMEOUT 90
750 #define MEGASAS_THROTTLE_QUEUE_DEPTH 16
751 
752 /*
753  * FW reports the maximum of number of commands that it can accept (maximum
754  * commands that can be outstanding) at any time. The driver must report a
755  * lower number to the mid layer because it can issue a few internal commands
756  * itself (E.g, AEN, abort cmd, IOCTLs etc). The number of commands it needs
757  * is shown below
758  */
759 #define MEGASAS_INT_CMDS 32
760 #define MEGASAS_SKINNY_INT_CMDS 5
761 
762 #define MEGASAS_MAX_MSIX_QUEUES 16
763 /*
764  * FW can accept both 32 and 64 bit SGLs. We want to allocate 32/64 bit
765  * SGLs based on the size of dma_addr_t
766  */
767 #define IS_DMA64 (sizeof(dma_addr_t) == 8)
768 
769 #define MFI_XSCALE_OMR0_CHANGE_INTERRUPT 0x00000001
770 
771 #define MFI_INTR_FLAG_REPLY_MESSAGE 0x00000001
772 #define MFI_INTR_FLAG_FIRMWARE_STATE_CHANGE 0x00000002
773 #define MFI_G2_OUTBOUND_DOORBELL_CHANGE_INTERRUPT 0x00000004
774 
775 #define MFI_OB_INTR_STATUS_MASK 0x00000002
776 #define MFI_POLL_TIMEOUT_SECS 60
777 
778 #define MFI_REPLY_1078_MESSAGE_INTERRUPT 0x80000000
779 #define MFI_REPLY_GEN2_MESSAGE_INTERRUPT 0x00000001
780 #define MFI_GEN2_ENABLE_INTERRUPT_MASK (0x00000001 | 0x00000004)
781 #define MFI_REPLY_SKINNY_MESSAGE_INTERRUPT 0x40000000
782 #define MFI_SKINNY_ENABLE_INTERRUPT_MASK (0x00000001)
783 
784 #define MFI_1068_PCSR_OFFSET 0x84
785 #define MFI_1068_FW_HANDSHAKE_OFFSET 0x64
786 #define MFI_1068_FW_READY 0xDDDD0000
787 /*
788 * register set for both 1068 and 1078 controllers
789 * structure extended for 1078 registers
790 */
791 
793  u32 doorbell; /*0000h*/
796  u32 reserved_01; /*000Ch*/
797 
798  u32 inbound_msg_0; /*0010h*/
799  u32 inbound_msg_1; /*0014h*/
800  u32 outbound_msg_0; /*0018h*/
801  u32 outbound_msg_1; /*001Ch*/
802 
806 
810 
811  u32 reserved_1[2]; /*0038h*/
812 
815 
816  u32 reserved_2[9]; /*0048h*/
818  u32 reserved_2_2[12]; /*0070h*/
819 
821 
822  u32 reserved_3[3]; /*00A4h*/
823 
826 
827  u32 reserved_4[2]; /*00B8h*/
828 
830 
832 
833  u32 reserved_5; /*00C8h*/
834  u32 res_6[11]; /*CCh*/
837  u32 index_registers[807]; /*00CCh*/
838 } __attribute__ ((packed));
845 } __attribute__ ((packed));
852 } __attribute__ ((packed));
858 } __packed;
860 union megasas_sgl {
861 
862  struct megasas_sge32 sge32[1];
863  struct megasas_sge64 sge64[1];
865 
866 } __attribute__ ((packed));
867 
870  u8 cmd; /*00h */
871  u8 sense_len; /*01h */
872  u8 cmd_status; /*02h */
873  u8 scsi_status; /*03h */
874 
875  u8 target_id; /*04h */
876  u8 lun; /*05h */
877  u8 cdb_len; /*06h */
878  u8 sge_count; /*07h */
880  u32 context; /*08h */
881  u32 pad_0; /*0Ch */
883  u16 flags; /*10h */
884  u16 timeout; /*12h */
885  u32 data_xferlen; /*14h */
886 
887 } __attribute__ ((packed));
888 
891  struct megasas_sge32 sge32[8];
892  struct megasas_sge64 sge64[5];
893 
894 } __attribute__ ((packed));
898  u8 cmd; /*00h */
899  u8 reserved_0; /*01h */
900  u8 cmd_status; /*02h */
901 
902  u8 reserved_1; /*03h */
903  u32 reserved_2; /*04h */
905  u32 context; /*08h */
906  u32 pad_0; /*0Ch */
907 
908  u16 flags; /*10h */
909  u16 reserved_3; /*12h */
910  u32 data_xfer_len; /*14h */
911 
916 
917  u32 reserved_4[6]; /*28h */
918 
919 } __attribute__ ((packed));
920 
922 
923  u32 init_flags; /*00h */
925 
932 
933 } __attribute__ ((packed));
934 
937  u8 cmd; /*00h */
938  u8 sense_len; /*01h */
939  u8 cmd_status; /*02h */
940  u8 scsi_status; /*03h */
942  u8 target_id; /*04h */
943  u8 access_byte; /*05h */
944  u8 reserved_0; /*06h */
945  u8 sge_count; /*07h */
946 
947  u32 context; /*08h */
948  u32 pad_0; /*0Ch */
949 
950  u16 flags; /*10h */
951  u16 timeout; /*12h */
952  u32 lba_count; /*14h */
953 
956 
957  u32 start_lba_lo; /*20h */
958  u32 start_lba_hi; /*24h */
959 
960  union megasas_sgl sgl; /*28h */
961 
962 } __attribute__ ((packed));
963 
965 
966  u8 cmd; /*00h */
967  u8 sense_len; /*01h */
968  u8 cmd_status; /*02h */
969  u8 scsi_status; /*03h */
971  u8 target_id; /*04h */
972  u8 lun; /*05h */
973  u8 cdb_len; /*06h */
974  u8 sge_count; /*07h */
975 
976  u32 context; /*08h */
977  u32 pad_0; /*0Ch */
978 
979  u16 flags; /*10h */
980  u16 timeout; /*12h */
981  u32 data_xfer_len; /*14h */
986  u8 cdb[16]; /*20h */
987  union megasas_sgl sgl; /*30h */
988 
989 } __attribute__ ((packed));
990 
992 
993  u8 cmd; /*00h */
994  u8 reserved_0; /*01h */
995  u8 cmd_status; /*02h */
996  u8 reserved_1[4]; /*03h */
997  u8 sge_count; /*07h */
998 
999  u32 context; /*08h */
1000  u32 pad_0; /*0Ch */
1001 
1002  u16 flags; /*10h */
1003  u16 timeout; /*12h */
1004 
1005  u32 data_xfer_len; /*14h */
1006  u32 opcode; /*18h */
1007 
1008  union { /*1Ch */
1009  u8 b[12];
1010  u16 s[6];
1011  u32 w[3];
1012  } mbox;
1013 
1014  union megasas_sgl sgl; /*28h */
1015 
1016 } __attribute__ ((packed));
1017 
1019 
1020  u8 cmd; /*00h */
1021  u8 reserved_0; /*01h */
1022  u8 cmd_status; /*02h */
1023 
1024  u8 reserved_1; /*03h */
1025  u32 reserved_2; /*04h */
1026 
1027  u32 context; /*08h */
1028  u32 pad_0; /*0Ch */
1029 
1030  u16 flags; /*10h */
1031  u16 reserved_3; /*12h */
1032  u32 reserved_4; /*14h */
1033 
1034  u32 abort_context; /*18h */
1035  u32 pad_1; /*1Ch */
1039 
1040  u32 reserved_5[6]; /*28h */
1041 
1042 } __attribute__ ((packed));
1043 
1045 
1046  u8 cmd; /*00h */
1047  u8 reserved_1; /*01h */
1048  u8 cmd_status; /*02h */
1050 
1051  u8 reserved_2[3]; /*04h */
1052  u8 sge_count; /*07h */
1053 
1054  u32 context; /*08h */
1055  u32 pad_0; /*0Ch */
1056 
1057  u16 flags; /*10h */
1058  u16 timeout; /*12h */
1060  u32 data_xfer_len; /*14h */
1061  u64 sas_addr; /*18h */
1063  union {
1064  struct megasas_sge32 sge32[2]; /* [0]: resp [1]: req */
1065  struct megasas_sge64 sge64[2]; /* [0]: resp [1]: req */
1066  } sgl;
1067 
1068 } __attribute__ ((packed));
1069 
1071 
1072  u8 cmd; /*00h */
1073  u8 reserved_1; /*01h */
1074  u8 cmd_status; /*02h */
1075  u8 reserved_2; /*03h */
1076 
1077  u8 target_id; /*04h */
1078  u8 reserved_3[2]; /*05h */
1079  u8 sge_count; /*07h */
1080 
1081  u32 context; /*08h */
1082  u32 pad_0; /*0Ch */
1083 
1084  u16 flags; /*10h */
1085  u16 timeout; /*12h */
1086 
1087  u32 data_xfer_len; /*14h */
1088 
1089  u16 fis[10]; /*18h */
1091 
1092  union {
1093  struct megasas_sge32 sge32[2]; /* [0]: resp [1]: data */
1094  struct megasas_sge64 sge64[2]; /* [0]: resp [1]: data */
1095  } sgl;
1096 
1097 } __attribute__ ((packed));
1098 
1100 
1108  struct megasas_stp_frame stp;
1109 
1110  u8 raw_bytes[64];
1111 };
1112 
1113 struct megasas_cmd;
1114 
1117  struct {
1120  s8 class;
1121  } __attribute__ ((packed)) members;
1125 } __attribute__ ((packed));
1126 
1134 } __attribute__ ((packed));
1140 
1141 } __attribute__ ((packed));
1142 
1148 
1149 } __attribute__ ((packed));
1150 
1155 
1156 } __attribute__ ((packed));
1157 
1166 
1167  union {
1168  struct {
1173  u8 cdb[16];
1174  u8 sense[64];
1175  } __attribute__ ((packed)) cdbSense;
1179  struct {
1180  struct megasas_evtarg_ld ld;
1182  } __attribute__ ((packed)) ld_count;
1186  struct megasas_evtarg_ld ld;
1187  } __attribute__ ((packed)) ld_lba;
1189  struct {
1190  struct megasas_evtarg_ld ld;
1193  } __attribute__ ((packed)) ld_owner;
1194 
1198  struct megasas_evtarg_ld ld;
1199  struct megasas_evtarg_pd pd;
1200  } __attribute__ ((packed)) ld_lba_pd_lba;
1203  struct megasas_evtarg_ld ld;
1205  } __attribute__ ((packed)) ld_prog;
1206 
1208  struct megasas_evtarg_ld ld;
1211  } __attribute__ ((packed)) ld_state;
1212 
1215  struct megasas_evtarg_ld ld;
1216  } __attribute__ ((packed)) ld_strip;
1219 
1220  struct {
1221  struct megasas_evtarg_pd pd;
1223  } __attribute__ ((packed)) pd_err;
1224 
1226  u64 lba;
1227  struct megasas_evtarg_pd pd;
1228  } __attribute__ ((packed)) pd_lba;
1229 
1230  struct {
1231  u64 lba;
1232  struct megasas_evtarg_pd pd;
1233  struct megasas_evtarg_ld ld;
1234  } __attribute__ ((packed)) pd_lba_ld;
1235 
1236  struct {
1237  struct megasas_evtarg_pd pd;
1238  struct megasas_progress prog;
1239  } __attribute__ ((packed)) pd_prog;
1240 
1241  struct {
1242  struct megasas_evtarg_pd pd;
1245  } __attribute__ ((packed)) pd_state;
1246 
1252  } __attribute__ ((packed)) pci;
1255  char str[96];
1257  struct {
1260  } __attribute__ ((packed)) time;
1265  char str[64];
1266  } __attribute__ ((packed)) ecc;
1268  u8 b[96];
1269  u16 s[48];
1270  u32 w[24];
1271  u64 d[12];
1272  } args;
1273 
1274  char description[128];
1275 
1276 } __attribute__ ((packed));
1277 
1279  struct delayed_work hotplug_work;
1280  struct megasas_instance *instance;
1281 };
1286 };
1287 
1289 
1294 
1297 
1298  unsigned long base_addr;
1300 
1304 
1307  /* For Fusion its num IOCTL cmds, for others MFI based its
1308  max_fw_cmds */
1312 
1314  struct list_head cmd_pool;
1315  /* used to sync fire the cmd to fw */
1317  /* used to sync fire the cmd to fw */
1319  /* used to synch producer, consumer ptrs in dpc */
1323 
1327  struct mutex aen_mutex;
1328  struct semaphore ioctl_sem;
1329 
1330  struct Scsi_Host *host;
1331 
1334 
1335  struct pci_dev *pdev;
1338 
1341 
1343  struct tasklet_struct isr_tasklet;
1344  struct work_struct work_init;
1345 
1352  unsigned long last_time;
1355 
1356  struct list_head internal_reset_pending_q;
1357 
1358  /* Ptr to hba specific information */
1360  unsigned int msix_vectors;
1361  struct msix_entry msixentry[MEGASAS_MAX_MSIX_QUEUES];
1365  unsigned long bar;
1367  struct mutex reset_mutex;
1369 };
1370 
1371 enum {
1378 };
1379 
1381  void (*fire_cmd)(struct megasas_instance *, dma_addr_t, \
1382  u32, struct megasas_register_set __iomem *);
1383 
1384  void (*enable_intr)(struct megasas_register_set __iomem *) ;
1385  void (*disable_intr)(struct megasas_register_set __iomem *);
1386 
1387  int (*clear_intr)(struct megasas_register_set __iomem *);
1388 
1389  u32 (*read_fw_status_reg)(struct megasas_register_set __iomem *);
1390  int (*adp_reset)(struct megasas_instance *, \
1392  int (*check_reset)(struct megasas_instance *, \
1394  irqreturn_t (*service_isr)(int irq, void *devp);
1395  void (*tasklet)(unsigned long);
1396  u32 (*init_adapter)(struct megasas_instance *);
1397  u32 (*build_and_issue_cmd) (struct megasas_instance *,
1398  struct scsi_cmnd *);
1399  void (*issue_dcmd) (struct megasas_instance *instance,
1400  struct megasas_cmd *cmd);
1401 };
1402 
1403 #define MEGASAS_IS_LOGICAL(scp) \
1404  (scp->device->channel < MEGASAS_MAX_PD_CHANNELS) ? 0 : 1
1405 
1406 #define MEGASAS_DEV_INDEX(inst, scp) \
1407  ((scp->device->channel % 2) * MEGASAS_MAX_DEV_PER_CHANNEL) + \
1408  scp->device->id
1409 
1410 struct megasas_cmd {
1411 
1416 
1422 
1423 
1424  struct list_head list;
1425  struct scsi_cmnd *scmd;
1427  union {
1428  struct {
1431  } context;
1433  };
1434 };
1435 
1436 #define MAX_MGMT_ADAPTERS 1024
1437 #define MAX_IOCTL_SGE 16
1438 
1440 
1447  union {
1448  u8 raw[128];
1450  } frame;
1451 
1453 
1454 } __attribute__ ((packed));
1455 
1456 struct megasas_aen {
1461 } __attribute__ ((packed));
1462 
1463 #ifdef CONFIG_COMPAT
1464 struct compat_megasas_iocpacket {
1466  u16 __pad1;
1467  u32 sgl_off;
1468  u32 sge_count;
1469  u32 sense_off;
1470  u32 sense_len;
1471  union {
1472  u8 raw[128];
1473  struct megasas_header hdr;
1474  } frame;
1475  struct compat_iovec sgl[MAX_IOCTL_SGE];
1476 } __attribute__ ((packed));
1477 
1478 #define MEGASAS_IOC_FIRMWARE32 _IOWR('M', 1, struct compat_megasas_iocpacket)
1479 #endif
1480 
1481 #define MEGASAS_IOC_FIRMWARE _IOWR('M', 1, struct megasas_iocpacket)
1482 #define MEGASAS_IOC_GET_AEN _IOW('M', 3, struct megasas_aen)
1483 
1485 
1489 };
1490 
1491 #define msi_control_reg(base) (base + PCI_MSI_FLAGS)
1492 #define PCI_MSIX_FLAGS_ENABLE (1 << 15)
1493 
1494 #endif /*LSI_MEGARAID_SAS_H */