1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Linux MegaRAID Unified device driver
6 * Copyright (c) 2003-2004 LSI Logic Corporation.
10 #ifndef _MRAID_MBOX_DEFS_H_
11 #define _MRAID_MBOX_DEFS_H_
13 #include <linux/types.h>
16 * Commands and states for mailbox based controllers
19 #define MBOXCMD_LREAD 0x01
20 #define MBOXCMD_LWRITE 0x02
21 #define MBOXCMD_PASSTHRU 0x03
22 #define MBOXCMD_ADPEXTINQ 0x04
23 #define MBOXCMD_ADAPTERINQ 0x05
24 #define MBOXCMD_LREAD64 0xA7
25 #define MBOXCMD_LWRITE64 0xA8
26 #define MBOXCMD_PASSTHRU64 0xC3
27 #define MBOXCMD_EXTPTHRU 0xE3
29 #define MAIN_MISC_OPCODE 0xA4
30 #define GET_MAX_SG_SUPPORT 0x01
31 #define SUPPORT_EXT_CDB 0x16
33 #define FC_NEW_CONFIG 0xA1
34 #define NC_SUBOP_PRODUCT_INFO 0x0E
35 #define NC_SUBOP_ENQUIRY3 0x0F
36 #define ENQ3_GET_SOLICITED_FULL 0x02
37 #define OP_DCMD_READ_CONFIG 0x04
38 #define NEW_READ_CONFIG_8LD 0x67
39 #define READ_CONFIG_8LD 0x07
40 #define FLUSH_ADAPTER 0x0A
41 #define FLUSH_SYSTEM 0xFE
44 * Command for random deletion of logical drives
46 #define FC_DEL_LOGDRV 0xA4
47 #define OP_SUP_DEL_LOGDRV 0x2A
48 #define OP_GET_LDID_MAP 0x18
49 #define OP_DEL_LOGDRV 0x1C
54 #define IS_BIOS_ENABLED 0x62
56 #define CHNL_CLASS 0xA9
57 #define GET_CHNL_CLASS 0x00
58 #define SET_CHNL_CLASS 0x01
61 #define BIOS_PVT_DATA 0x40
62 #define GET_BIOS_PVT_DATA 0x00
66 * Commands to support clustering
68 #define GET_TARGET_ID 0x7D
69 #define CLUSTER_OP 0x70
70 #define GET_CLUSTER_MODE 0x02
71 #define CLUSTER_CMD 0x6E
72 #define RESERVE_LD 0x01
73 #define RELEASE_LD 0x02
74 #define RESET_RESERVATIONS 0x03
75 #define RESERVATION_STATUS 0x04
76 #define RESERVE_PD 0x05
77 #define RELEASE_PD 0x06
81 * Module battery status
83 #define BATTERY_MODULE_MISSING 0x01
84 #define BATTERY_LOW_VOLTAGE 0x02
85 #define BATTERY_TEMP_HIGH 0x04
86 #define BATTERY_PACK_MISSING 0x08
87 #define BATTERY_CHARGE_MASK 0x30
88 #define BATTERY_CHARGE_DONE 0x00
89 #define BATTERY_CHARGE_INPROG 0x10
90 #define BATTERY_CHARGE_FAIL 0x20
91 #define BATTERY_CYCLES_EXCEEDED 0x40
94 * Physical drive states.
100 #define PDRV_HOTSPARE 6
104 * Raid logical drive states.
106 #define RDRV_OFFLINE 0
107 #define RDRV_DEGRADED 1
108 #define RDRV_OPTIMAL 2
109 #define RDRV_DELETED 3
112 * Read, write and cache policies
114 #define NO_READ_AHEAD 0
116 #define ADAP_READ_AHEAD 2
117 #define WRMODE_WRITE_THRU 0
118 #define WRMODE_WRITE_BACK 1
122 #define MAX_LOGICAL_DRIVES_8LD 8
123 #define MAX_LOGICAL_DRIVES_40LD 40
124 #define FC_MAX_PHYSICAL_DEVICES 256
125 #define MAX_MBOX_CHANNELS 5
126 #define MAX_MBOX_TARGET 15
127 #define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
128 #define MAX_ROW_SIZE_40LD 32
129 #define MAX_ROW_SIZE_8LD 8
130 #define SPAN_DEPTH_8_SPANS 8
131 #define SPAN_DEPTH_4_SPANS 4
132 #define MAX_REQ_SENSE_LEN 0x20
137 * struct mbox_t - Driver and f/w handshake structure.
138 * @cmd : firmware command
139 * @cmdid : command id
140 * @numsectors : number of sectors to be transferred
141 * @lba : Logical Block Address on LD
142 * @xferaddr : DMA address for data transfer
143 * @logdrv : logical drive number
144 * @numsge : number of scatter gather elements in sg list
146 * @busy : f/w busy, must wait to issue more commands.
147 * @numstatus : number of commands completed.
148 * @status : status of the commands completed
149 * @completed : array of completed command ids.
150 * @poll : poll and ack sequence
151 * @ack : poll and ack sequence
153 * The central handshake structure between the driver and the firmware. This
154 * structure must be allocated by the driver and aligned at 8-byte boundary.
156 #define MBOX_MAX_FIRMWARE_STATUS 46
169 uint8_t completed
[MBOX_MAX_FIRMWARE_STATUS
];
172 } __attribute__ ((packed
)) mbox_t
;
176 * mbox64_t - 64-bit extension for the mailbox
177 * @segment_lo : the low 32-bits of the address of the scatter-gather list
178 * @segment_hi : the upper 32-bits of the address of the scatter-gather list
179 * @mbox : 32-bit mailbox, whose xferadder field must be set to
182 * This is the extension of the 32-bit mailbox to be able to perform DMA
183 * beyond 4GB address range.
186 uint32_t xferaddr_lo
;
187 uint32_t xferaddr_hi
;
189 } __attribute__ ((packed
)) mbox64_t
;
192 * mailbox structure used for internal commands
205 } __attribute__ ((packed
)) int_mbox_t
;
208 * mraid_passthru_t - passthru structure to issue commands to physical devices
209 * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
210 * @ars : set if ARS required after check condition
211 * @islogical : set if command meant for logical devices
212 * @logdrv : logical drive number if command for LD
213 * @channel : Channel on which physical device is located
214 * @target : SCSI target of the device
216 * @queueaction : unused
218 * @cdblen : length of the CDB
219 * @reqsenselen : amount of request sense data to be returned
220 * @reqsensearea : Sense information buffer
221 * @numsge : number of scatter-gather elements in the sg list
222 * @scsistatus : SCSI status of the command completed.
223 * @dataxferaddr : DMA data transfer address
224 * @dataxferlen : amount of the data to be transferred.
230 uint8_t islogical
:1;
239 uint8_t reqsensearea
[MAX_REQ_SENSE_LEN
];
242 uint32_t dataxferaddr
;
243 uint32_t dataxferlen
;
244 } __attribute__ ((packed
)) mraid_passthru_t
;
248 uint32_t dataxferaddr_lo
;
249 uint32_t dataxferaddr_hi
;
250 mraid_passthru_t pthru32
;
252 } __attribute__ ((packed
)) mega_passthru64_t
;
255 * mraid_epassthru_t - passthru structure to issue commands to physical devices
256 * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
257 * @ars : set if ARS required after check condition
258 * @rsvd1 : reserved field
260 * @rsvd2 : reserved field
261 * @islogical : set if command meant for logical devices
262 * @logdrv : logical drive number if command for LD
263 * @channel : Channel on which physical device is located
264 * @target : SCSI target of the device
266 * @queueaction : unused
267 * @cdblen : length of the CDB
268 * @rsvd3 : reserved field
270 * @numsge : number of scatter-gather elements in the sg list
271 * @status : SCSI status of the command completed.
272 * @reqsenselen : amount of request sense data to be returned
273 * @reqsensearea : Sense information buffer
274 * @rsvd4 : reserved field
275 * @dataxferaddr : DMA data transfer address
276 * @dataxferlen : amount of the data to be transferred.
284 uint8_t islogical
:1;
296 uint8_t reqsensearea
[MAX_REQ_SENSE_LEN
];
298 uint32_t dataxferaddr
;
299 uint32_t dataxferlen
;
300 } __attribute__ ((packed
)) mraid_epassthru_t
;
304 * mraid_pinfo_t - product info, static information about the controller
305 * @data_size : current size in bytes (not including resvd)
306 * @config_signature : Current value is 0x00282008
307 * @fw_version : Firmware version
308 * @bios_version : version of the BIOS
309 * @product_name : Name given to the controller
310 * @max_commands : Maximum concurrent commands supported
311 * @nchannels : Number of SCSI Channels detected
312 * @fc_loop_present : Number of Fibre Loops detected
313 * @mem_type : EDO, FPM, SDRAM etc
315 * @dram_size : In terms of MB
316 * @subsysid : device PCI subsystem ID
317 * @subsysvid : device PCI subsystem vendor ID
319 * @pad1k : 135 + 889 resvd = 1024 total size
321 * This structures holds the information about the controller which is not
322 * expected to change dynamically.
324 * The current value of config signature is 0x00282008:
325 * 0x28 = MAX_LOGICAL_DRIVES,
326 * 0x20 = Number of stripes and
327 * 0x08 = Number of spans
331 uint32_t config_signature
;
332 uint8_t fw_version
[16];
333 uint8_t bios_version
[16];
334 uint8_t product_name
[80];
335 uint8_t max_commands
;
337 uint8_t fc_loop_present
;
343 uint8_t notify_counters
;
345 } __attribute__ ((packed
)) mraid_pinfo_t
;
349 * mraid_notify_t - the notification structure
350 * @global_counter : Any change increments this counter
351 * @param_counter : Indicates any params changed
352 * @param_id : Param modified - defined below
353 * @param_val : New val of last param modified
354 * @write_config_counter : write config occurred
355 * @write_config_rsvd :
356 * @ldrv_op_counter : Indicates ldrv op started/completed
357 * @ldrv_opid : ldrv num
358 * @ldrv_opcmd : ldrv operation - defined below
359 * @ldrv_opstatus : status of the operation
360 * @ldrv_state_counter : Indicates change of ldrv state
361 * @ldrv_state_id : ldrv num
362 * @ldrv_state_new : New state
363 * @ldrv_state_old : old state
364 * @pdrv_state_counter : Indicates change of ldrv state
365 * @pdrv_state_id : pdrv id
366 * @pdrv_state_new : New state
367 * @pdrv_state_old : old state
368 * @pdrv_fmt_counter : Indicates pdrv format started/over
369 * @pdrv_fmt_id : pdrv id
370 * @pdrv_fmt_val : format started/over
372 * @targ_xfer_counter : Indicates SCSI-2 Xfer rate change
373 * @targ_xfer_id : pdrv Id
374 * @targ_xfer_val : new Xfer params of last pdrv
376 * @fcloop_id_chg_counter : Indicates loopid changed
377 * @fcloopid_pdrvid : pdrv id
378 * @fcloop_id0 : loopid on fc loop 0
379 * @fcloop_id1 : loopid on fc loop 1
380 * @fcloop_state_counter : Indicates loop state changed
381 * @fcloop_state0 : state of fc loop 0
382 * @fcloop_state1 : state of fc loop 1
383 * @fcloop_state_rsvd :
386 uint32_t global_counter
;
387 uint8_t param_counter
;
390 uint8_t write_config_counter
;
391 uint8_t write_config_rsvd
[3];
392 uint8_t ldrv_op_counter
;
395 uint8_t ldrv_opstatus
;
396 uint8_t ldrv_state_counter
;
397 uint8_t ldrv_state_id
;
398 uint8_t ldrv_state_new
;
399 uint8_t ldrv_state_old
;
400 uint8_t pdrv_state_counter
;
401 uint8_t pdrv_state_id
;
402 uint8_t pdrv_state_new
;
403 uint8_t pdrv_state_old
;
404 uint8_t pdrv_fmt_counter
;
406 uint8_t pdrv_fmt_val
;
407 uint8_t pdrv_fmt_rsvd
;
408 uint8_t targ_xfer_counter
;
409 uint8_t targ_xfer_id
;
410 uint8_t targ_xfer_val
;
411 uint8_t targ_xfer_rsvd
;
412 uint8_t fcloop_id_chg_counter
;
413 uint8_t fcloopid_pdrvid
;
416 uint8_t fcloop_state_counter
;
417 uint8_t fcloop_state0
;
418 uint8_t fcloop_state1
;
419 uint8_t fcloop_state_rsvd
;
420 } __attribute__ ((packed
)) mraid_notify_t
;
424 * mraid_inquiry3_t - enquiry for device information
426 * @data_size : current size in bytes (not including resvd)
429 * @rebuild_rate : rebuild rate (0% - 100%)
430 * @cache_flush_int : cache flush interval in seconds
432 * @drive_insert_count : drive insertion count
434 * @num_ldrv : no. of Log Drives configured
435 * @recon_state : state of reconstruct
436 * @ldrv_op_status : logdrv Status
437 * @ldrv_size : size of each log drv
439 * @ldrv_state : state of log drives
440 * @pdrv_state : state of phys drvs.
442 * @targ_xfer : phys device transfer rate
443 * @pad1k : 761 + 263reserved = 1024 bytes total size
445 #define MAX_NOTIFY_SIZE 0x80
446 #define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)
451 mraid_notify_t notify
;
453 uint8_t notify_rsvd
[MAX_NOTIFY_SIZE
- CUR_NOTIFY_SIZE
];
455 uint8_t rebuild_rate
;
456 uint8_t cache_flush_int
;
458 uint8_t drive_insert_count
;
460 uint8_t battery_status
;
462 uint8_t recon_state
[MAX_LOGICAL_DRIVES_40LD
/ 8];
463 uint16_t ldrv_op_status
[MAX_LOGICAL_DRIVES_40LD
/ 8];
465 uint32_t ldrv_size
[MAX_LOGICAL_DRIVES_40LD
];
466 uint8_t ldrv_prop
[MAX_LOGICAL_DRIVES_40LD
];
467 uint8_t ldrv_state
[MAX_LOGICAL_DRIVES_40LD
];
468 uint8_t pdrv_state
[FC_MAX_PHYSICAL_DEVICES
];
469 uint16_t pdrv_format
[FC_MAX_PHYSICAL_DEVICES
/ 16];
471 uint8_t targ_xfer
[80];
473 } __attribute__ ((packed
)) mraid_inquiry3_t
;
477 * mraid_adapinfo_t - information about the adapter
478 * @max_commands : max concurrent commands supported
479 * @rebuild_rate : rebuild rate - 0% thru 100%
480 * @max_targ_per_chan : max targ per channel
481 * @nchannels : number of channels on HBA
482 * @fw_version : firmware version
483 * @age_of_flash : number of times FW has been flashed
484 * @chip_set_value : contents of 0xC0000832
486 * @cache_flush_interval : in seconds
490 * @write_config_count : increase with every configuration change
491 * @drive_inserted_count : increase with every drive inserted
492 * @inserted_drive : channel:Id of inserted drive
493 * @battery_status : bit 0: battery module missing
495 * bit 2: temperature high
496 * bit 3: battery pack missing
498 * 00 - charge complete
499 * 01 - fast charge in progress
500 * 10 - fast charge fail
502 * bit 6: counter > 1000
504 * @dec_fault_bus_info :
507 uint8_t max_commands
;
508 uint8_t rebuild_rate
;
509 uint8_t max_targ_per_chan
;
511 uint8_t fw_version
[4];
512 uint16_t age_of_flash
;
513 uint8_t chip_set_value
;
515 uint8_t cache_flush_interval
;
516 uint8_t bios_version
[4];
519 uint8_t write_config_count
;
520 uint8_t battery_status
;
521 uint8_t dec_fault_bus_info
;
522 } __attribute__ ((packed
)) mraid_adapinfo_t
;
526 * mraid_ldrv_info_t - information about the logical drives
527 * @nldrv : Number of logical drives configured
529 * @size : size of each logical drive
531 * @state : state of each logical drive
536 uint32_t size
[MAX_LOGICAL_DRIVES_8LD
];
537 uint8_t prop
[MAX_LOGICAL_DRIVES_8LD
];
538 uint8_t state
[MAX_LOGICAL_DRIVES_8LD
];
539 } __attribute__ ((packed
)) mraid_ldrv_info_t
;
543 * mraid_pdrv_info_t - information about the physical drives
544 * @pdrv_state : state of each physical drive
547 uint8_t pdrv_state
[MBOX_MAX_PHYSICAL_DRIVES
];
549 } __attribute__ ((packed
)) mraid_pdrv_info_t
;
553 * mraid_inquiry_t - RAID inquiry, mailbox command 0x05
554 * @mraid_adapinfo_t : adapter information
555 * @mraid_ldrv_info_t : logical drives information
556 * @mraid_pdrv_info_t : physical drives information
559 mraid_adapinfo_t adapter_info
;
560 mraid_ldrv_info_t logdrv_info
;
561 mraid_pdrv_info_t pdrv_info
;
562 } __attribute__ ((packed
)) mraid_inquiry_t
;
566 * mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
568 * @raid_inq : raid inquiry
575 mraid_inquiry_t raid_inq
;
576 uint16_t phys_drv_format
[MAX_MBOX_CHANNELS
];
578 uint8_t modem_status
;
580 } __attribute__ ((packed
)) mraid_extinq_t
;
584 * adap_device_t - device information
585 * @channel : channel fpor the device
586 * @target : target ID of the device
591 }__attribute__ ((packed
)) adap_device_t
;
595 * adap_span_40ld_t - 40LD span
596 * @start_blk : starting block
597 * @num_blks : number of blocks
602 adap_device_t device
[MAX_ROW_SIZE_40LD
];
603 }__attribute__ ((packed
)) adap_span_40ld_t
;
607 * adap_span_8ld_t - 8LD span
608 * @start_blk : starting block
609 * @num_blks : number of blocks
614 adap_device_t device
[MAX_ROW_SIZE_8LD
];
615 }__attribute__ ((packed
)) adap_span_8ld_t
;
619 * logdrv_param_t - logical drives parameters
621 * @span_depth : total number of spans
622 * @level : RAID level
623 * @read_ahead : read ahead, no read ahead, adaptive read ahead
624 * @stripe_sz : encoded stripe size
625 * @status : status of the logical drive
626 * @write_mode : write mode, write_through/write_back
627 * @direct_io : direct io or through cache
628 * @row_size : number of stripes in a row
639 } __attribute__ ((packed
)) logdrv_param_t
;
643 * logdrv_40ld_t - logical drive definition for 40LD controllers
644 * @lparam : logical drives parameters
648 logdrv_param_t lparam
;
649 adap_span_40ld_t span
[SPAN_DEPTH_8_SPANS
];
650 }__attribute__ ((packed
)) logdrv_40ld_t
;
654 * logdrv_8ld_span8_t - logical drive definition for 8LD controllers
655 * @lparam : logical drives parameters
658 * 8-LD logical drive with up to 8 spans
661 logdrv_param_t lparam
;
662 adap_span_8ld_t span
[SPAN_DEPTH_8_SPANS
];
663 }__attribute__ ((packed
)) logdrv_8ld_span8_t
;
667 * logdrv_8ld_span4_t - logical drive definition for 8LD controllers
668 * @lparam : logical drives parameters
671 * 8-LD logical drive with up to 4 spans
674 logdrv_param_t lparam
;
675 adap_span_8ld_t span
[SPAN_DEPTH_4_SPANS
];
676 }__attribute__ ((packed
)) logdrv_8ld_span4_t
;
680 * phys_drive_t - physical device information
681 * @type : Type of the device
682 * @cur_status : current status of the device
683 * @tag_depth : Level of tagging
684 * @sync_neg : sync negotiation - ENABLE or DISABLE
685 * @size : configurable size in terms of 512 byte
693 }__attribute__ ((packed
)) phys_drive_t
;
697 * disk_array_40ld_t - disk array for 40LD controllers
698 * @numldrv : number of logical drives
700 * @ldrv : logical drives information
701 * @pdrv : physical drives information
706 logdrv_40ld_t ldrv
[MAX_LOGICAL_DRIVES_40LD
];
707 phys_drive_t pdrv
[MBOX_MAX_PHYSICAL_DRIVES
];
708 }__attribute__ ((packed
)) disk_array_40ld_t
;
712 * disk_array_8ld_span8_t - disk array for 8LD controllers
713 * @numldrv : number of logical drives
715 * @ldrv : logical drives information
716 * @pdrv : physical drives information
718 * Disk array for 8LD logical drives with up to 8 spans
723 logdrv_8ld_span8_t ldrv
[MAX_LOGICAL_DRIVES_8LD
];
724 phys_drive_t pdrv
[MBOX_MAX_PHYSICAL_DRIVES
];
725 }__attribute__ ((packed
)) disk_array_8ld_span8_t
;
729 * disk_array_8ld_span4_t - disk array for 8LD controllers
730 * @numldrv : number of logical drives
732 * @ldrv : logical drives information
733 * @pdrv : physical drives information
735 * Disk array for 8LD logical drives with up to 4 spans
740 logdrv_8ld_span4_t ldrv
[MAX_LOGICAL_DRIVES_8LD
];
741 phys_drive_t pdrv
[MBOX_MAX_PHYSICAL_DRIVES
];
742 }__attribute__ ((packed
)) disk_array_8ld_span4_t
;
746 * struct private_bios_data - bios private data for boot devices
747 * @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
748 * 0x1000 - 8GB, Others values are invalid
749 * @unused : bits 4-7 are unused
750 * @boot_drv : logical drive set as boot drive, 0..7 - for 8LD cards,
751 * 0..39 - for 40LD cards
752 * @cksum : 0-(sum of first 13 bytes of this structure)
754 struct private_bios_data
{
760 } __attribute__ ((packed
));
764 * mbox_sgl64 - 64-bit scatter list for mailbox based controllers
765 * @address : address of the buffer
766 * @length : data transfer length
771 } __attribute__ ((packed
)) mbox_sgl64
;
774 * mbox_sgl32 - 32-bit scatter list for mailbox based controllers
775 * @address : address of the buffer
776 * @length : data transfer length
781 } __attribute__ ((packed
)) mbox_sgl32
;
783 #endif // _MRAID_MBOX_DEFS_H_
785 /* vim: set ts=8 sw=8 tw=78: */