Loading...
1/*
2 *
3 * Linux MegaRAID Unified device driver
4 *
5 * Copyright (c) 2003-2004 LSI Logic Corporation.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * FILE : mbox_defs.h
13 *
14 */
15#ifndef _MRAID_MBOX_DEFS_H_
16#define _MRAID_MBOX_DEFS_H_
17
18#include <linux/types.h>
19
20/*
21 * Commands and states for mailbox based controllers
22 */
23
24#define MBOXCMD_LREAD 0x01
25#define MBOXCMD_LWRITE 0x02
26#define MBOXCMD_PASSTHRU 0x03
27#define MBOXCMD_ADPEXTINQ 0x04
28#define MBOXCMD_ADAPTERINQ 0x05
29#define MBOXCMD_LREAD64 0xA7
30#define MBOXCMD_LWRITE64 0xA8
31#define MBOXCMD_PASSTHRU64 0xC3
32#define MBOXCMD_EXTPTHRU 0xE3
33
34#define MAIN_MISC_OPCODE 0xA4
35#define GET_MAX_SG_SUPPORT 0x01
36#define SUPPORT_EXT_CDB 0x16
37
38#define FC_NEW_CONFIG 0xA1
39#define NC_SUBOP_PRODUCT_INFO 0x0E
40#define NC_SUBOP_ENQUIRY3 0x0F
41#define ENQ3_GET_SOLICITED_FULL 0x02
42#define OP_DCMD_READ_CONFIG 0x04
43#define NEW_READ_CONFIG_8LD 0x67
44#define READ_CONFIG_8LD 0x07
45#define FLUSH_ADAPTER 0x0A
46#define FLUSH_SYSTEM 0xFE
47
48/*
49 * Command for random deletion of logical drives
50 */
51#define FC_DEL_LOGDRV 0xA4
52#define OP_SUP_DEL_LOGDRV 0x2A
53#define OP_GET_LDID_MAP 0x18
54#define OP_DEL_LOGDRV 0x1C
55
56/*
57 * BIOS commands
58 */
59#define IS_BIOS_ENABLED 0x62
60#define GET_BIOS 0x01
61#define CHNL_CLASS 0xA9
62#define GET_CHNL_CLASS 0x00
63#define SET_CHNL_CLASS 0x01
64#define CH_RAID 0x01
65#define CH_SCSI 0x00
66#define BIOS_PVT_DATA 0x40
67#define GET_BIOS_PVT_DATA 0x00
68
69
70/*
71 * Commands to support clustering
72 */
73#define GET_TARGET_ID 0x7D
74#define CLUSTER_OP 0x70
75#define GET_CLUSTER_MODE 0x02
76#define CLUSTER_CMD 0x6E
77#define RESERVE_LD 0x01
78#define RELEASE_LD 0x02
79#define RESET_RESERVATIONS 0x03
80#define RESERVATION_STATUS 0x04
81#define RESERVE_PD 0x05
82#define RELEASE_PD 0x06
83
84
85/*
86 * Module battery status
87 */
88#define BATTERY_MODULE_MISSING 0x01
89#define BATTERY_LOW_VOLTAGE 0x02
90#define BATTERY_TEMP_HIGH 0x04
91#define BATTERY_PACK_MISSING 0x08
92#define BATTERY_CHARGE_MASK 0x30
93#define BATTERY_CHARGE_DONE 0x00
94#define BATTERY_CHARGE_INPROG 0x10
95#define BATTERY_CHARGE_FAIL 0x20
96#define BATTERY_CYCLES_EXCEEDED 0x40
97
98/*
99 * Physical drive states.
100 */
101#define PDRV_UNCNF 0
102#define PDRV_ONLINE 3
103#define PDRV_FAILED 4
104#define PDRV_RBLD 5
105#define PDRV_HOTSPARE 6
106
107
108/*
109 * Raid logical drive states.
110 */
111#define RDRV_OFFLINE 0
112#define RDRV_DEGRADED 1
113#define RDRV_OPTIMAL 2
114#define RDRV_DELETED 3
115
116/*
117 * Read, write and cache policies
118 */
119#define NO_READ_AHEAD 0
120#define READ_AHEAD 1
121#define ADAP_READ_AHEAD 2
122#define WRMODE_WRITE_THRU 0
123#define WRMODE_WRITE_BACK 1
124#define CACHED_IO 0
125#define DIRECT_IO 1
126
127#define MAX_LOGICAL_DRIVES_8LD 8
128#define MAX_LOGICAL_DRIVES_40LD 40
129#define FC_MAX_PHYSICAL_DEVICES 256
130#define MAX_MBOX_CHANNELS 5
131#define MAX_MBOX_TARGET 15
132#define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
133#define MAX_ROW_SIZE_40LD 32
134#define MAX_ROW_SIZE_8LD 8
135#define SPAN_DEPTH_8_SPANS 8
136#define SPAN_DEPTH_4_SPANS 4
137#define MAX_REQ_SENSE_LEN 0x20
138
139
140
141/**
142 * struct mbox_t - Driver and f/w handshake structure.
143 * @cmd : firmware command
144 * @cmdid : command id
145 * @numsectors : number of sectors to be transferred
146 * @lba : Logical Block Address on LD
147 * @xferaddr : DMA address for data transfer
148 * @logdrv : logical drive number
149 * @numsge : number of scatter gather elements in sg list
150 * @resvd : reserved
151 * @busy : f/w busy, must wait to issue more commands.
152 * @numstatus : number of commands completed.
153 * @status : status of the commands completed
154 * @completed : array of completed command ids.
155 * @poll : poll and ack sequence
156 * @ack : poll and ack sequence
157 *
158 * The central handshake structure between the driver and the firmware. This
159 * structure must be allocated by the driver and aligned at 8-byte boundary.
160 */
161#define MBOX_MAX_FIRMWARE_STATUS 46
162typedef struct {
163 uint8_t cmd;
164 uint8_t cmdid;
165 uint16_t numsectors;
166 uint32_t lba;
167 uint32_t xferaddr;
168 uint8_t logdrv;
169 uint8_t numsge;
170 uint8_t resvd;
171 uint8_t busy;
172 uint8_t numstatus;
173 uint8_t status;
174 uint8_t completed[MBOX_MAX_FIRMWARE_STATUS];
175 uint8_t poll;
176 uint8_t ack;
177} __attribute__ ((packed)) mbox_t;
178
179
180/**
181 * mbox64_t - 64-bit extension for the mailbox
182 * @segment_lo : the low 32-bits of the address of the scatter-gather list
183 * @segment_hi : the upper 32-bits of the address of the scatter-gather list
184 * @mbox : 32-bit mailbox, whose xferadder field must be set to
185 * 0xFFFFFFFF
186 *
187 * This is the extension of the 32-bit mailbox to be able to perform DMA
188 * beyond 4GB address range.
189 */
190typedef struct {
191 uint32_t xferaddr_lo;
192 uint32_t xferaddr_hi;
193 mbox_t mbox32;
194} __attribute__ ((packed)) mbox64_t;
195
196/*
197 * mailbox structure used for internal commands
198 */
199typedef struct {
200 u8 cmd;
201 u8 cmdid;
202 u8 opcode;
203 u8 subopcode;
204 u32 lba;
205 u32 xferaddr;
206 u8 logdrv;
207 u8 rsvd[3];
208 u8 numstatus;
209 u8 status;
210} __attribute__ ((packed)) int_mbox_t;
211
212/**
213 * mraid_passthru_t - passthru structure to issue commands to physical devices
214 * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
215 * @ars : set if ARS required after check condition
216 * @islogical : set if command meant for logical devices
217 * @logdrv : logical drive number if command for LD
218 * @channel : Channel on which physical device is located
219 * @target : SCSI target of the device
220 * @queuetag : unused
221 * @queueaction : unused
222 * @cdb : SCSI CDB
223 * @cdblen : length of the CDB
224 * @reqsenselen : amount of request sense data to be returned
225 * @reqsensearea : Sense information buffer
226 * @numsge : number of scatter-gather elements in the sg list
227 * @scsistatus : SCSI status of the command completed.
228 * @dataxferaddr : DMA data transfer address
229 * @dataxferlen : amount of the data to be transferred.
230 */
231typedef struct {
232 uint8_t timeout :3;
233 uint8_t ars :1;
234 uint8_t reserved :3;
235 uint8_t islogical :1;
236 uint8_t logdrv;
237 uint8_t channel;
238 uint8_t target;
239 uint8_t queuetag;
240 uint8_t queueaction;
241 uint8_t cdb[10];
242 uint8_t cdblen;
243 uint8_t reqsenselen;
244 uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
245 uint8_t numsge;
246 uint8_t scsistatus;
247 uint32_t dataxferaddr;
248 uint32_t dataxferlen;
249} __attribute__ ((packed)) mraid_passthru_t;
250
251typedef struct {
252
253 uint32_t dataxferaddr_lo;
254 uint32_t dataxferaddr_hi;
255 mraid_passthru_t pthru32;
256
257} __attribute__ ((packed)) mega_passthru64_t;
258
259/**
260 * mraid_epassthru_t - passthru structure to issue commands to physical devices
261 * @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
262 * @ars : set if ARS required after check condition
263 * @rsvd1 : reserved field
264 * @cd_rom : (?)
265 * @rsvd2 : reserved field
266 * @islogical : set if command meant for logical devices
267 * @logdrv : logical drive number if command for LD
268 * @channel : Channel on which physical device is located
269 * @target : SCSI target of the device
270 * @queuetag : unused
271 * @queueaction : unused
272 * @cdblen : length of the CDB
273 * @rsvd3 : reserved field
274 * @cdb : SCSI CDB
275 * @numsge : number of scatter-gather elements in the sg list
276 * @status : SCSI status of the command completed.
277 * @reqsenselen : amount of request sense data to be returned
278 * @reqsensearea : Sense information buffer
279 * @rsvd4 : reserved field
280 * @dataxferaddr : DMA data transfer address
281 * @dataxferlen : amount of the data to be transferred.
282 */
283typedef struct {
284 uint8_t timeout :3;
285 uint8_t ars :1;
286 uint8_t rsvd1 :1;
287 uint8_t cd_rom :1;
288 uint8_t rsvd2 :1;
289 uint8_t islogical :1;
290 uint8_t logdrv;
291 uint8_t channel;
292 uint8_t target;
293 uint8_t queuetag;
294 uint8_t queueaction;
295 uint8_t cdblen;
296 uint8_t rsvd3;
297 uint8_t cdb[16];
298 uint8_t numsge;
299 uint8_t status;
300 uint8_t reqsenselen;
301 uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
302 uint8_t rsvd4;
303 uint32_t dataxferaddr;
304 uint32_t dataxferlen;
305} __attribute__ ((packed)) mraid_epassthru_t;
306
307
308/**
309 * mraid_pinfo_t - product info, static information about the controller
310 * @data_size : current size in bytes (not including resvd)
311 * @config_signature : Current value is 0x00282008
312 * @fw_version : Firmware version
313 * @bios_version : version of the BIOS
314 * @product_name : Name given to the controller
315 * @max_commands : Maximum concurrent commands supported
316 * @nchannels : Number of SCSI Channels detected
317 * @fc_loop_present : Number of Fibre Loops detected
318 * @mem_type : EDO, FPM, SDRAM etc
319 * @signature :
320 * @dram_size : In terms of MB
321 * @subsysid : device PCI subsystem ID
322 * @subsysvid : device PCI subsystem vendor ID
323 * @notify_counters :
324 * @pad1k : 135 + 889 resvd = 1024 total size
325 *
326 * This structures holds the information about the controller which is not
327 * expected to change dynamically.
328 *
329 * The current value of config signature is 0x00282008:
330 * 0x28 = MAX_LOGICAL_DRIVES,
331 * 0x20 = Number of stripes and
332 * 0x08 = Number of spans
333 */
334typedef struct {
335 uint32_t data_size;
336 uint32_t config_signature;
337 uint8_t fw_version[16];
338 uint8_t bios_version[16];
339 uint8_t product_name[80];
340 uint8_t max_commands;
341 uint8_t nchannels;
342 uint8_t fc_loop_present;
343 uint8_t mem_type;
344 uint32_t signature;
345 uint16_t dram_size;
346 uint16_t subsysid;
347 uint16_t subsysvid;
348 uint8_t notify_counters;
349 uint8_t pad1k[889];
350} __attribute__ ((packed)) mraid_pinfo_t;
351
352
353/**
354 * mraid_notify_t - the notification structure
355 * @global_counter : Any change increments this counter
356 * @param_counter : Indicates any params changed
357 * @param_id : Param modified - defined below
358 * @param_val : New val of last param modified
359 * @write_config_counter : write config occurred
360 * @write_config_rsvd :
361 * @ldrv_op_counter : Indicates ldrv op started/completed
362 * @ldrv_opid : ldrv num
363 * @ldrv_opcmd : ldrv operation - defined below
364 * @ldrv_opstatus : status of the operation
365 * @ldrv_state_counter : Indicates change of ldrv state
366 * @ldrv_state_id : ldrv num
367 * @ldrv_state_new : New state
368 * @ldrv_state_old : old state
369 * @pdrv_state_counter : Indicates change of ldrv state
370 * @pdrv_state_id : pdrv id
371 * @pdrv_state_new : New state
372 * @pdrv_state_old : old state
373 * @pdrv_fmt_counter : Indicates pdrv format started/over
374 * @pdrv_fmt_id : pdrv id
375 * @pdrv_fmt_val : format started/over
376 * @pdrv_fmt_rsvd :
377 * @targ_xfer_counter : Indicates SCSI-2 Xfer rate change
378 * @targ_xfer_id : pdrv Id
379 * @targ_xfer_val : new Xfer params of last pdrv
380 * @targ_xfer_rsvd :
381 * @fcloop_id_chg_counter : Indicates loopid changed
382 * @fcloopid_pdrvid : pdrv id
383 * @fcloop_id0 : loopid on fc loop 0
384 * @fcloop_id1 : loopid on fc loop 1
385 * @fcloop_state_counter : Indicates loop state changed
386 * @fcloop_state0 : state of fc loop 0
387 * @fcloop_state1 : state of fc loop 1
388 * @fcloop_state_rsvd :
389 */
390typedef struct {
391 uint32_t global_counter;
392 uint8_t param_counter;
393 uint8_t param_id;
394 uint16_t param_val;
395 uint8_t write_config_counter;
396 uint8_t write_config_rsvd[3];
397 uint8_t ldrv_op_counter;
398 uint8_t ldrv_opid;
399 uint8_t ldrv_opcmd;
400 uint8_t ldrv_opstatus;
401 uint8_t ldrv_state_counter;
402 uint8_t ldrv_state_id;
403 uint8_t ldrv_state_new;
404 uint8_t ldrv_state_old;
405 uint8_t pdrv_state_counter;
406 uint8_t pdrv_state_id;
407 uint8_t pdrv_state_new;
408 uint8_t pdrv_state_old;
409 uint8_t pdrv_fmt_counter;
410 uint8_t pdrv_fmt_id;
411 uint8_t pdrv_fmt_val;
412 uint8_t pdrv_fmt_rsvd;
413 uint8_t targ_xfer_counter;
414 uint8_t targ_xfer_id;
415 uint8_t targ_xfer_val;
416 uint8_t targ_xfer_rsvd;
417 uint8_t fcloop_id_chg_counter;
418 uint8_t fcloopid_pdrvid;
419 uint8_t fcloop_id0;
420 uint8_t fcloop_id1;
421 uint8_t fcloop_state_counter;
422 uint8_t fcloop_state0;
423 uint8_t fcloop_state1;
424 uint8_t fcloop_state_rsvd;
425} __attribute__ ((packed)) mraid_notify_t;
426
427
428/**
429 * mraid_inquiry3_t - enquiry for device information
430 *
431 * @data_size : current size in bytes (not including resvd)
432 * @notify :
433 * @notify_rsvd :
434 * @rebuild_rate : rebuild rate (0% - 100%)
435 * @cache_flush_int : cache flush interval in seconds
436 * @sense_alert :
437 * @drive_insert_count : drive insertion count
438 * @battery_status :
439 * @num_ldrv : no. of Log Drives configured
440 * @recon_state : state of reconstruct
441 * @ldrv_op_status : logdrv Status
442 * @ldrv_size : size of each log drv
443 * @ldrv_prop :
444 * @ldrv_state : state of log drives
445 * @pdrv_state : state of phys drvs.
446 * @pdrv_format :
447 * @targ_xfer : phys device transfer rate
448 * @pad1k : 761 + 263reserved = 1024 bytes total size
449 */
450#define MAX_NOTIFY_SIZE 0x80
451#define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)
452
453typedef struct {
454 uint32_t data_size;
455
456 mraid_notify_t notify;
457
458 uint8_t notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
459
460 uint8_t rebuild_rate;
461 uint8_t cache_flush_int;
462 uint8_t sense_alert;
463 uint8_t drive_insert_count;
464
465 uint8_t battery_status;
466 uint8_t num_ldrv;
467 uint8_t recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
468 uint16_t ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
469
470 uint32_t ldrv_size[MAX_LOGICAL_DRIVES_40LD];
471 uint8_t ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
472 uint8_t ldrv_state[MAX_LOGICAL_DRIVES_40LD];
473 uint8_t pdrv_state[FC_MAX_PHYSICAL_DEVICES];
474 uint16_t pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
475
476 uint8_t targ_xfer[80];
477 uint8_t pad1k[263];
478} __attribute__ ((packed)) mraid_inquiry3_t;
479
480
481/**
482 * mraid_adapinfo_t - information about the adapter
483 * @max_commands : max concurrent commands supported
484 * @rebuild_rate : rebuild rate - 0% thru 100%
485 * @max_targ_per_chan : max targ per channel
486 * @nchannels : number of channels on HBA
487 * @fw_version : firmware version
488 * @age_of_flash : number of times FW has been flashed
489 * @chip_set_value : contents of 0xC0000832
490 * @dram_size : in MB
491 * @cache_flush_interval : in seconds
492 * @bios_version :
493 * @board_type :
494 * @sense_alert :
495 * @write_config_count : increase with every configuration change
496 * @drive_inserted_count : increase with every drive inserted
497 * @inserted_drive : channel:Id of inserted drive
498 * @battery_status : bit 0: battery module missing
499 * bit 1: VBAD
500 * bit 2: temperature high
501 * bit 3: battery pack missing
502 * bit 4,5:
503 * 00 - charge complete
504 * 01 - fast charge in progress
505 * 10 - fast charge fail
506 * 11 - undefined
507 * bit 6: counter > 1000
508 * bit 7: Undefined
509 * @dec_fault_bus_info :
510 */
511typedef struct {
512 uint8_t max_commands;
513 uint8_t rebuild_rate;
514 uint8_t max_targ_per_chan;
515 uint8_t nchannels;
516 uint8_t fw_version[4];
517 uint16_t age_of_flash;
518 uint8_t chip_set_value;
519 uint8_t dram_size;
520 uint8_t cache_flush_interval;
521 uint8_t bios_version[4];
522 uint8_t board_type;
523 uint8_t sense_alert;
524 uint8_t write_config_count;
525 uint8_t battery_status;
526 uint8_t dec_fault_bus_info;
527} __attribute__ ((packed)) mraid_adapinfo_t;
528
529
530/**
531 * mraid_ldrv_info_t - information about the logical drives
532 * @nldrv : Number of logical drives configured
533 * @rsvd :
534 * @size : size of each logical drive
535 * @prop :
536 * @state : state of each logical drive
537 */
538typedef struct {
539 uint8_t nldrv;
540 uint8_t rsvd[3];
541 uint32_t size[MAX_LOGICAL_DRIVES_8LD];
542 uint8_t prop[MAX_LOGICAL_DRIVES_8LD];
543 uint8_t state[MAX_LOGICAL_DRIVES_8LD];
544} __attribute__ ((packed)) mraid_ldrv_info_t;
545
546
547/**
548 * mraid_pdrv_info_t - information about the physical drives
549 * @pdrv_state : state of each physical drive
550 */
551typedef struct {
552 uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
553 uint8_t rsvd;
554} __attribute__ ((packed)) mraid_pdrv_info_t;
555
556
557/**
558 * mraid_inquiry_t - RAID inquiry, mailbox command 0x05
559 * @mraid_adapinfo_t : adapter information
560 * @mraid_ldrv_info_t : logical drives information
561 * @mraid_pdrv_info_t : physical drives information
562 */
563typedef struct {
564 mraid_adapinfo_t adapter_info;
565 mraid_ldrv_info_t logdrv_info;
566 mraid_pdrv_info_t pdrv_info;
567} __attribute__ ((packed)) mraid_inquiry_t;
568
569
570/**
571 * mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
572 *
573 * @raid_inq : raid inquiry
574 * @phys_drv_format :
575 * @stack_attn :
576 * @modem_status :
577 * @rsvd :
578 */
579typedef struct {
580 mraid_inquiry_t raid_inq;
581 uint16_t phys_drv_format[MAX_MBOX_CHANNELS];
582 uint8_t stack_attn;
583 uint8_t modem_status;
584 uint8_t rsvd[2];
585} __attribute__ ((packed)) mraid_extinq_t;
586
587
588/**
589 * adap_device_t - device information
590 * @channel : channel fpor the device
591 * @target : target ID of the device
592 */
593typedef struct {
594 uint8_t channel;
595 uint8_t target;
596}__attribute__ ((packed)) adap_device_t;
597
598
599/**
600 * adap_span_40ld_t - 40LD span
601 * @start_blk : starting block
602 * @num_blks : number of blocks
603 */
604typedef struct {
605 uint32_t start_blk;
606 uint32_t num_blks;
607 adap_device_t device[MAX_ROW_SIZE_40LD];
608}__attribute__ ((packed)) adap_span_40ld_t;
609
610
611/**
612 * adap_span_8ld_t - 8LD span
613 * @start_blk : starting block
614 * @num_blks : number of blocks
615 */
616typedef struct {
617 uint32_t start_blk;
618 uint32_t num_blks;
619 adap_device_t device[MAX_ROW_SIZE_8LD];
620}__attribute__ ((packed)) adap_span_8ld_t;
621
622
623/**
624 * logdrv_param_t - logical drives parameters
625 *
626 * @span_depth : total number of spans
627 * @level : RAID level
628 * @read_ahead : read ahead, no read ahead, adaptive read ahead
629 * @stripe_sz : encoded stripe size
630 * @status : status of the logical drive
631 * @write_mode : write mode, write_through/write_back
632 * @direct_io : direct io or through cache
633 * @row_size : number of stripes in a row
634 */
635typedef struct {
636 uint8_t span_depth;
637 uint8_t level;
638 uint8_t read_ahead;
639 uint8_t stripe_sz;
640 uint8_t status;
641 uint8_t write_mode;
642 uint8_t direct_io;
643 uint8_t row_size;
644} __attribute__ ((packed)) logdrv_param_t;
645
646
647/**
648 * logdrv_40ld_t - logical drive definition for 40LD controllers
649 * @lparam : logical drives parameters
650 * @span : span
651 */
652typedef struct {
653 logdrv_param_t lparam;
654 adap_span_40ld_t span[SPAN_DEPTH_8_SPANS];
655}__attribute__ ((packed)) logdrv_40ld_t;
656
657
658/**
659 * logdrv_8ld_span8_t - logical drive definition for 8LD controllers
660 * @lparam : logical drives parameters
661 * @span : span
662 *
663 * 8-LD logical drive with up to 8 spans
664 */
665typedef struct {
666 logdrv_param_t lparam;
667 adap_span_8ld_t span[SPAN_DEPTH_8_SPANS];
668}__attribute__ ((packed)) logdrv_8ld_span8_t;
669
670
671/**
672 * logdrv_8ld_span4_t - logical drive definition for 8LD controllers
673 * @lparam : logical drives parameters
674 * @span : span
675 *
676 * 8-LD logical drive with up to 4 spans
677 */
678typedef struct {
679 logdrv_param_t lparam;
680 adap_span_8ld_t span[SPAN_DEPTH_4_SPANS];
681}__attribute__ ((packed)) logdrv_8ld_span4_t;
682
683
684/**
685 * phys_drive_t - physical device information
686 * @type : Type of the device
687 * @cur_status : current status of the device
688 * @tag_depth : Level of tagging
689 * @sync_neg : sync negotiation - ENABLE or DISABLE
690 * @size : configurable size in terms of 512 byte
691 */
692typedef struct {
693 uint8_t type;
694 uint8_t cur_status;
695 uint8_t tag_depth;
696 uint8_t sync_neg;
697 uint32_t size;
698}__attribute__ ((packed)) phys_drive_t;
699
700
701/**
702 * disk_array_40ld_t - disk array for 40LD controllers
703 * @numldrv : number of logical drives
704 * @resvd :
705 * @ldrv : logical drives information
706 * @pdrv : physical drives information
707 */
708typedef struct {
709 uint8_t numldrv;
710 uint8_t resvd[3];
711 logdrv_40ld_t ldrv[MAX_LOGICAL_DRIVES_40LD];
712 phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
713}__attribute__ ((packed)) disk_array_40ld_t;
714
715
716/**
717 * disk_array_8ld_span8_t - disk array for 8LD controllers
718 * @numldrv : number of logical drives
719 * @resvd :
720 * @ldrv : logical drives information
721 * @pdrv : physical drives information
722 *
723 * Disk array for 8LD logical drives with up to 8 spans
724 */
725typedef struct {
726 uint8_t numldrv;
727 uint8_t resvd[3];
728 logdrv_8ld_span8_t ldrv[MAX_LOGICAL_DRIVES_8LD];
729 phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
730}__attribute__ ((packed)) disk_array_8ld_span8_t;
731
732
733/**
734 * disk_array_8ld_span4_t - disk array for 8LD controllers
735 * @numldrv : number of logical drives
736 * @resvd :
737 * @ldrv : logical drives information
738 * @pdrv : physical drives information
739 *
740 * Disk array for 8LD logical drives with up to 4 spans
741 */
742typedef struct {
743 uint8_t numldrv;
744 uint8_t resvd[3];
745 logdrv_8ld_span4_t ldrv[MAX_LOGICAL_DRIVES_8LD];
746 phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
747}__attribute__ ((packed)) disk_array_8ld_span4_t;
748
749
750/**
751 * struct private_bios_data - bios private data for boot devices
752 * @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
753 * 0x1000 - 8GB, Others values are invalid
754 * @unused : bits 4-7 are unused
755 * @boot_drv : logical drive set as boot drive, 0..7 - for 8LD cards,
756 * 0..39 - for 40LD cards
757 * @cksum : 0-(sum of first 13 bytes of this structure)
758 */
759struct private_bios_data {
760 uint8_t geometry :4;
761 uint8_t unused :4;
762 uint8_t boot_drv;
763 uint8_t rsvd[12];
764 uint16_t cksum;
765} __attribute__ ((packed));
766
767
768/**
769 * mbox_sgl64 - 64-bit scatter list for mailbox based controllers
770 * @address : address of the buffer
771 * @length : data transfer length
772 */
773typedef struct {
774 uint64_t address;
775 uint32_t length;
776} __attribute__ ((packed)) mbox_sgl64;
777
778/**
779 * mbox_sgl32 - 32-bit scatter list for mailbox based controllers
780 * @address : address of the buffer
781 * @length : data transfer length
782 */
783typedef struct {
784 uint32_t address;
785 uint32_t length;
786} __attribute__ ((packed)) mbox_sgl32;
787
788#endif // _MRAID_MBOX_DEFS_H_
789
790/* vim: set ts=8 sw=8 tw=78: */
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 *
4 * Linux MegaRAID Unified device driver
5 *
6 * Copyright (c) 2003-2004 LSI Logic Corporation.
7 *
8 * FILE : mbox_defs.h
9 */
10#ifndef _MRAID_MBOX_DEFS_H_
11#define _MRAID_MBOX_DEFS_H_
12
13#include <linux/types.h>
14
15/*
16 * Commands and states for mailbox based controllers
17 */
18
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
28
29#define MAIN_MISC_OPCODE 0xA4
30#define GET_MAX_SG_SUPPORT 0x01
31#define SUPPORT_EXT_CDB 0x16
32
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
42
43/*
44 * Command for random deletion of logical drives
45 */
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
50
51/*
52 * BIOS commands
53 */
54#define IS_BIOS_ENABLED 0x62
55#define GET_BIOS 0x01
56#define CHNL_CLASS 0xA9
57#define GET_CHNL_CLASS 0x00
58#define SET_CHNL_CLASS 0x01
59#define CH_RAID 0x01
60#define CH_SCSI 0x00
61#define BIOS_PVT_DATA 0x40
62#define GET_BIOS_PVT_DATA 0x00
63
64
65/*
66 * Commands to support clustering
67 */
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
78
79
80/*
81 * Module battery status
82 */
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
92
93/*
94 * Physical drive states.
95 */
96#define PDRV_UNCNF 0
97#define PDRV_ONLINE 3
98#define PDRV_FAILED 4
99#define PDRV_RBLD 5
100#define PDRV_HOTSPARE 6
101
102
103/*
104 * Raid logical drive states.
105 */
106#define RDRV_OFFLINE 0
107#define RDRV_DEGRADED 1
108#define RDRV_OPTIMAL 2
109#define RDRV_DELETED 3
110
111/*
112 * Read, write and cache policies
113 */
114#define NO_READ_AHEAD 0
115#define READ_AHEAD 1
116#define ADAP_READ_AHEAD 2
117#define WRMODE_WRITE_THRU 0
118#define WRMODE_WRITE_BACK 1
119#define CACHED_IO 0
120#define DIRECT_IO 1
121
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
133
134
135
136/**
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
145 * @resvd : reserved
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
152 *
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.
155 */
156#define MBOX_MAX_FIRMWARE_STATUS 46
157typedef struct {
158 uint8_t cmd;
159 uint8_t cmdid;
160 uint16_t numsectors;
161 uint32_t lba;
162 uint32_t xferaddr;
163 uint8_t logdrv;
164 uint8_t numsge;
165 uint8_t resvd;
166 uint8_t busy;
167 uint8_t numstatus;
168 uint8_t status;
169 uint8_t completed[MBOX_MAX_FIRMWARE_STATUS];
170 uint8_t poll;
171 uint8_t ack;
172} __attribute__ ((packed)) mbox_t;
173
174
175/**
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
180 * 0xFFFFFFFF
181 *
182 * This is the extension of the 32-bit mailbox to be able to perform DMA
183 * beyond 4GB address range.
184 */
185typedef struct {
186 uint32_t xferaddr_lo;
187 uint32_t xferaddr_hi;
188 mbox_t mbox32;
189} __attribute__ ((packed)) mbox64_t;
190
191/*
192 * mailbox structure used for internal commands
193 */
194typedef struct {
195 u8 cmd;
196 u8 cmdid;
197 u8 opcode;
198 u8 subopcode;
199 u32 lba;
200 u32 xferaddr;
201 u8 logdrv;
202 u8 rsvd[3];
203 u8 numstatus;
204 u8 status;
205} __attribute__ ((packed)) int_mbox_t;
206
207/**
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
215 * @queuetag : unused
216 * @queueaction : unused
217 * @cdb : SCSI CDB
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.
225 */
226typedef struct {
227 uint8_t timeout :3;
228 uint8_t ars :1;
229 uint8_t reserved :3;
230 uint8_t islogical :1;
231 uint8_t logdrv;
232 uint8_t channel;
233 uint8_t target;
234 uint8_t queuetag;
235 uint8_t queueaction;
236 uint8_t cdb[10];
237 uint8_t cdblen;
238 uint8_t reqsenselen;
239 uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
240 uint8_t numsge;
241 uint8_t scsistatus;
242 uint32_t dataxferaddr;
243 uint32_t dataxferlen;
244} __attribute__ ((packed)) mraid_passthru_t;
245
246typedef struct {
247
248 uint32_t dataxferaddr_lo;
249 uint32_t dataxferaddr_hi;
250 mraid_passthru_t pthru32;
251
252} __attribute__ ((packed)) mega_passthru64_t;
253
254/**
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
259 * @cd_rom : (?)
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
265 * @queuetag : unused
266 * @queueaction : unused
267 * @cdblen : length of the CDB
268 * @rsvd3 : reserved field
269 * @cdb : SCSI CDB
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.
277 */
278typedef struct {
279 uint8_t timeout :3;
280 uint8_t ars :1;
281 uint8_t rsvd1 :1;
282 uint8_t cd_rom :1;
283 uint8_t rsvd2 :1;
284 uint8_t islogical :1;
285 uint8_t logdrv;
286 uint8_t channel;
287 uint8_t target;
288 uint8_t queuetag;
289 uint8_t queueaction;
290 uint8_t cdblen;
291 uint8_t rsvd3;
292 uint8_t cdb[16];
293 uint8_t numsge;
294 uint8_t status;
295 uint8_t reqsenselen;
296 uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
297 uint8_t rsvd4;
298 uint32_t dataxferaddr;
299 uint32_t dataxferlen;
300} __attribute__ ((packed)) mraid_epassthru_t;
301
302
303/**
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
314 * @signature :
315 * @dram_size : In terms of MB
316 * @subsysid : device PCI subsystem ID
317 * @subsysvid : device PCI subsystem vendor ID
318 * @notify_counters :
319 * @pad1k : 135 + 889 resvd = 1024 total size
320 *
321 * This structures holds the information about the controller which is not
322 * expected to change dynamically.
323 *
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
328 */
329typedef struct {
330 uint32_t data_size;
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;
336 uint8_t nchannels;
337 uint8_t fc_loop_present;
338 uint8_t mem_type;
339 uint32_t signature;
340 uint16_t dram_size;
341 uint16_t subsysid;
342 uint16_t subsysvid;
343 uint8_t notify_counters;
344 uint8_t pad1k[889];
345} __attribute__ ((packed)) mraid_pinfo_t;
346
347
348/**
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
371 * @pdrv_fmt_rsvd :
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
375 * @targ_xfer_rsvd :
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 :
384 */
385typedef struct {
386 uint32_t global_counter;
387 uint8_t param_counter;
388 uint8_t param_id;
389 uint16_t param_val;
390 uint8_t write_config_counter;
391 uint8_t write_config_rsvd[3];
392 uint8_t ldrv_op_counter;
393 uint8_t ldrv_opid;
394 uint8_t ldrv_opcmd;
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;
405 uint8_t pdrv_fmt_id;
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;
414 uint8_t fcloop_id0;
415 uint8_t fcloop_id1;
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;
421
422
423/**
424 * mraid_inquiry3_t - enquiry for device information
425 *
426 * @data_size : current size in bytes (not including resvd)
427 * @notify :
428 * @notify_rsvd :
429 * @rebuild_rate : rebuild rate (0% - 100%)
430 * @cache_flush_int : cache flush interval in seconds
431 * @sense_alert :
432 * @drive_insert_count : drive insertion count
433 * @battery_status :
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
438 * @ldrv_prop :
439 * @ldrv_state : state of log drives
440 * @pdrv_state : state of phys drvs.
441 * @pdrv_format :
442 * @targ_xfer : phys device transfer rate
443 * @pad1k : 761 + 263reserved = 1024 bytes total size
444 */
445#define MAX_NOTIFY_SIZE 0x80
446#define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)
447
448typedef struct {
449 uint32_t data_size;
450
451 mraid_notify_t notify;
452
453 uint8_t notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
454
455 uint8_t rebuild_rate;
456 uint8_t cache_flush_int;
457 uint8_t sense_alert;
458 uint8_t drive_insert_count;
459
460 uint8_t battery_status;
461 uint8_t num_ldrv;
462 uint8_t recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
463 uint16_t ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
464
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];
470
471 uint8_t targ_xfer[80];
472 uint8_t pad1k[263];
473} __attribute__ ((packed)) mraid_inquiry3_t;
474
475
476/**
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
485 * @dram_size : in MB
486 * @cache_flush_interval : in seconds
487 * @bios_version :
488 * @board_type :
489 * @sense_alert :
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
494 * bit 1: VBAD
495 * bit 2: temperature high
496 * bit 3: battery pack missing
497 * bit 4,5:
498 * 00 - charge complete
499 * 01 - fast charge in progress
500 * 10 - fast charge fail
501 * 11 - undefined
502 * bit 6: counter > 1000
503 * bit 7: Undefined
504 * @dec_fault_bus_info :
505 */
506typedef struct {
507 uint8_t max_commands;
508 uint8_t rebuild_rate;
509 uint8_t max_targ_per_chan;
510 uint8_t nchannels;
511 uint8_t fw_version[4];
512 uint16_t age_of_flash;
513 uint8_t chip_set_value;
514 uint8_t dram_size;
515 uint8_t cache_flush_interval;
516 uint8_t bios_version[4];
517 uint8_t board_type;
518 uint8_t sense_alert;
519 uint8_t write_config_count;
520 uint8_t battery_status;
521 uint8_t dec_fault_bus_info;
522} __attribute__ ((packed)) mraid_adapinfo_t;
523
524
525/**
526 * mraid_ldrv_info_t - information about the logical drives
527 * @nldrv : Number of logical drives configured
528 * @rsvd :
529 * @size : size of each logical drive
530 * @prop :
531 * @state : state of each logical drive
532 */
533typedef struct {
534 uint8_t nldrv;
535 uint8_t rsvd[3];
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;
540
541
542/**
543 * mraid_pdrv_info_t - information about the physical drives
544 * @pdrv_state : state of each physical drive
545 */
546typedef struct {
547 uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
548 uint8_t rsvd;
549} __attribute__ ((packed)) mraid_pdrv_info_t;
550
551
552/**
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
557 */
558typedef struct {
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;
563
564
565/**
566 * mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
567 *
568 * @raid_inq : raid inquiry
569 * @phys_drv_format :
570 * @stack_attn :
571 * @modem_status :
572 * @rsvd :
573 */
574typedef struct {
575 mraid_inquiry_t raid_inq;
576 uint16_t phys_drv_format[MAX_MBOX_CHANNELS];
577 uint8_t stack_attn;
578 uint8_t modem_status;
579 uint8_t rsvd[2];
580} __attribute__ ((packed)) mraid_extinq_t;
581
582
583/**
584 * adap_device_t - device information
585 * @channel : channel fpor the device
586 * @target : target ID of the device
587 */
588typedef struct {
589 uint8_t channel;
590 uint8_t target;
591}__attribute__ ((packed)) adap_device_t;
592
593
594/**
595 * adap_span_40ld_t - 40LD span
596 * @start_blk : starting block
597 * @num_blks : number of blocks
598 */
599typedef struct {
600 uint32_t start_blk;
601 uint32_t num_blks;
602 adap_device_t device[MAX_ROW_SIZE_40LD];
603}__attribute__ ((packed)) adap_span_40ld_t;
604
605
606/**
607 * adap_span_8ld_t - 8LD span
608 * @start_blk : starting block
609 * @num_blks : number of blocks
610 */
611typedef struct {
612 uint32_t start_blk;
613 uint32_t num_blks;
614 adap_device_t device[MAX_ROW_SIZE_8LD];
615}__attribute__ ((packed)) adap_span_8ld_t;
616
617
618/**
619 * logdrv_param_t - logical drives parameters
620 *
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
629 */
630typedef struct {
631 uint8_t span_depth;
632 uint8_t level;
633 uint8_t read_ahead;
634 uint8_t stripe_sz;
635 uint8_t status;
636 uint8_t write_mode;
637 uint8_t direct_io;
638 uint8_t row_size;
639} __attribute__ ((packed)) logdrv_param_t;
640
641
642/**
643 * logdrv_40ld_t - logical drive definition for 40LD controllers
644 * @lparam : logical drives parameters
645 * @span : span
646 */
647typedef struct {
648 logdrv_param_t lparam;
649 adap_span_40ld_t span[SPAN_DEPTH_8_SPANS];
650}__attribute__ ((packed)) logdrv_40ld_t;
651
652
653/**
654 * logdrv_8ld_span8_t - logical drive definition for 8LD controllers
655 * @lparam : logical drives parameters
656 * @span : span
657 *
658 * 8-LD logical drive with up to 8 spans
659 */
660typedef struct {
661 logdrv_param_t lparam;
662 adap_span_8ld_t span[SPAN_DEPTH_8_SPANS];
663}__attribute__ ((packed)) logdrv_8ld_span8_t;
664
665
666/**
667 * logdrv_8ld_span4_t - logical drive definition for 8LD controllers
668 * @lparam : logical drives parameters
669 * @span : span
670 *
671 * 8-LD logical drive with up to 4 spans
672 */
673typedef struct {
674 logdrv_param_t lparam;
675 adap_span_8ld_t span[SPAN_DEPTH_4_SPANS];
676}__attribute__ ((packed)) logdrv_8ld_span4_t;
677
678
679/**
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
686 */
687typedef struct {
688 uint8_t type;
689 uint8_t cur_status;
690 uint8_t tag_depth;
691 uint8_t sync_neg;
692 uint32_t size;
693}__attribute__ ((packed)) phys_drive_t;
694
695
696/**
697 * disk_array_40ld_t - disk array for 40LD controllers
698 * @numldrv : number of logical drives
699 * @resvd :
700 * @ldrv : logical drives information
701 * @pdrv : physical drives information
702 */
703typedef struct {
704 uint8_t numldrv;
705 uint8_t resvd[3];
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;
709
710
711/**
712 * disk_array_8ld_span8_t - disk array for 8LD controllers
713 * @numldrv : number of logical drives
714 * @resvd :
715 * @ldrv : logical drives information
716 * @pdrv : physical drives information
717 *
718 * Disk array for 8LD logical drives with up to 8 spans
719 */
720typedef struct {
721 uint8_t numldrv;
722 uint8_t resvd[3];
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;
726
727
728/**
729 * disk_array_8ld_span4_t - disk array for 8LD controllers
730 * @numldrv : number of logical drives
731 * @resvd :
732 * @ldrv : logical drives information
733 * @pdrv : physical drives information
734 *
735 * Disk array for 8LD logical drives with up to 4 spans
736 */
737typedef struct {
738 uint8_t numldrv;
739 uint8_t resvd[3];
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;
743
744
745/**
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)
753 */
754struct private_bios_data {
755 uint8_t geometry :4;
756 uint8_t unused :4;
757 uint8_t boot_drv;
758 uint8_t rsvd[12];
759 uint16_t cksum;
760} __attribute__ ((packed));
761
762
763/**
764 * mbox_sgl64 - 64-bit scatter list for mailbox based controllers
765 * @address : address of the buffer
766 * @length : data transfer length
767 */
768typedef struct {
769 uint64_t address;
770 uint32_t length;
771} __attribute__ ((packed)) mbox_sgl64;
772
773/**
774 * mbox_sgl32 - 32-bit scatter list for mailbox based controllers
775 * @address : address of the buffer
776 * @length : data transfer length
777 */
778typedef struct {
779 uint32_t address;
780 uint32_t length;
781} __attribute__ ((packed)) mbox_sgl32;
782
783#endif // _MRAID_MBOX_DEFS_H_