Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *
0004  *          Linux MegaRAID Unified device driver
0005  *
0006  * Copyright (c) 2003-2004  LSI Logic Corporation.
0007  *
0008  * FILE     : mbox_defs.h
0009  */
0010 #ifndef _MRAID_MBOX_DEFS_H_
0011 #define _MRAID_MBOX_DEFS_H_
0012 
0013 #include <linux/types.h>
0014 
0015 /*
0016  * Commands and states for mailbox based controllers
0017  */
0018 
0019 #define MBOXCMD_LREAD       0x01
0020 #define MBOXCMD_LWRITE      0x02
0021 #define MBOXCMD_PASSTHRU    0x03
0022 #define MBOXCMD_ADPEXTINQ   0x04
0023 #define MBOXCMD_ADAPTERINQ  0x05
0024 #define MBOXCMD_LREAD64     0xA7
0025 #define MBOXCMD_LWRITE64    0xA8
0026 #define MBOXCMD_PASSTHRU64  0xC3
0027 #define MBOXCMD_EXTPTHRU    0xE3
0028 
0029 #define MAIN_MISC_OPCODE    0xA4
0030 #define GET_MAX_SG_SUPPORT  0x01
0031 #define SUPPORT_EXT_CDB     0x16
0032 
0033 #define FC_NEW_CONFIG       0xA1
0034 #define NC_SUBOP_PRODUCT_INFO   0x0E
0035 #define NC_SUBOP_ENQUIRY3   0x0F
0036 #define ENQ3_GET_SOLICITED_FULL 0x02
0037 #define OP_DCMD_READ_CONFIG 0x04
0038 #define NEW_READ_CONFIG_8LD 0x67
0039 #define READ_CONFIG_8LD     0x07
0040 #define FLUSH_ADAPTER       0x0A
0041 #define FLUSH_SYSTEM        0xFE
0042 
0043 /*
0044  * Command for random deletion of logical drives
0045  */
0046 #define FC_DEL_LOGDRV       0xA4
0047 #define OP_SUP_DEL_LOGDRV   0x2A
0048 #define OP_GET_LDID_MAP     0x18
0049 #define OP_DEL_LOGDRV       0x1C
0050 
0051 /*
0052  * BIOS commands
0053  */
0054 #define IS_BIOS_ENABLED     0x62
0055 #define GET_BIOS        0x01
0056 #define CHNL_CLASS      0xA9
0057 #define GET_CHNL_CLASS      0x00
0058 #define SET_CHNL_CLASS      0x01
0059 #define CH_RAID         0x01
0060 #define CH_SCSI         0x00
0061 #define BIOS_PVT_DATA       0x40
0062 #define GET_BIOS_PVT_DATA   0x00
0063 
0064 
0065 /*
0066  * Commands to support clustering
0067  */
0068 #define GET_TARGET_ID       0x7D
0069 #define CLUSTER_OP      0x70
0070 #define GET_CLUSTER_MODE    0x02
0071 #define CLUSTER_CMD     0x6E
0072 #define RESERVE_LD      0x01
0073 #define RELEASE_LD      0x02
0074 #define RESET_RESERVATIONS  0x03
0075 #define RESERVATION_STATUS  0x04
0076 #define RESERVE_PD      0x05
0077 #define RELEASE_PD      0x06
0078 
0079 
0080 /*
0081  * Module battery status
0082  */
0083 #define BATTERY_MODULE_MISSING      0x01
0084 #define BATTERY_LOW_VOLTAGE     0x02
0085 #define BATTERY_TEMP_HIGH       0x04
0086 #define BATTERY_PACK_MISSING        0x08
0087 #define BATTERY_CHARGE_MASK     0x30
0088 #define BATTERY_CHARGE_DONE     0x00
0089 #define BATTERY_CHARGE_INPROG       0x10
0090 #define BATTERY_CHARGE_FAIL     0x20
0091 #define BATTERY_CYCLES_EXCEEDED     0x40
0092 
0093 /*
0094  * Physical drive states.
0095  */
0096 #define PDRV_UNCNF  0
0097 #define PDRV_ONLINE 3
0098 #define PDRV_FAILED 4
0099 #define PDRV_RBLD   5
0100 #define PDRV_HOTSPARE   6
0101 
0102 
0103 /*
0104  * Raid logical drive states.
0105  */
0106 #define RDRV_OFFLINE    0
0107 #define RDRV_DEGRADED   1
0108 #define RDRV_OPTIMAL    2
0109 #define RDRV_DELETED    3
0110 
0111 /*
0112  * Read, write and cache policies
0113  */
0114 #define NO_READ_AHEAD       0
0115 #define READ_AHEAD      1
0116 #define ADAP_READ_AHEAD     2
0117 #define WRMODE_WRITE_THRU   0
0118 #define WRMODE_WRITE_BACK   1
0119 #define CACHED_IO       0
0120 #define DIRECT_IO       1
0121 
0122 #define MAX_LOGICAL_DRIVES_8LD      8
0123 #define MAX_LOGICAL_DRIVES_40LD     40
0124 #define FC_MAX_PHYSICAL_DEVICES     256
0125 #define MAX_MBOX_CHANNELS       5
0126 #define MAX_MBOX_TARGET         15
0127 #define MBOX_MAX_PHYSICAL_DRIVES    MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
0128 #define MAX_ROW_SIZE_40LD       32
0129 #define MAX_ROW_SIZE_8LD        8
0130 #define SPAN_DEPTH_8_SPANS      8
0131 #define SPAN_DEPTH_4_SPANS      4
0132 #define MAX_REQ_SENSE_LEN       0x20
0133 
0134 
0135 
0136 /**
0137  * struct mbox_t - Driver and f/w handshake structure.
0138  * @cmd     : firmware command
0139  * @cmdid   : command id
0140  * @numsectors  : number of sectors to be transferred
0141  * @lba     : Logical Block Address on LD
0142  * @xferaddr    : DMA address for data transfer
0143  * @logdrv  : logical drive number
0144  * @numsge  : number of scatter gather elements in sg list
0145  * @resvd   : reserved
0146  * @busy    : f/w busy, must wait to issue more commands.
0147  * @numstatus   : number of commands completed.
0148  * @status  : status of the commands completed
0149  * @completed   : array of completed command ids.
0150  * @poll    : poll and ack sequence
0151  * @ack     : poll and ack sequence
0152  *
0153  * The central handshake structure between the driver and the firmware. This
0154  * structure must be allocated by the driver and aligned at 8-byte boundary.
0155  */
0156 #define MBOX_MAX_FIRMWARE_STATUS    46
0157 typedef struct {
0158     uint8_t     cmd;
0159     uint8_t     cmdid;
0160     uint16_t    numsectors;
0161     uint32_t    lba;
0162     uint32_t    xferaddr;
0163     uint8_t     logdrv;
0164     uint8_t     numsge;
0165     uint8_t     resvd;
0166     uint8_t     busy;
0167     uint8_t     numstatus;
0168     uint8_t     status;
0169     uint8_t     completed[MBOX_MAX_FIRMWARE_STATUS];
0170     uint8_t     poll;
0171     uint8_t     ack;
0172 } __attribute__ ((packed)) mbox_t;
0173 
0174 
0175 /**
0176  * mbox64_t - 64-bit extension for the mailbox
0177  * @segment_lo  : the low 32-bits of the address of the scatter-gather list
0178  * @segment_hi  : the upper 32-bits of the address of the scatter-gather list
0179  * @mbox    : 32-bit mailbox, whose xferadder field must be set to
0180  *      0xFFFFFFFF
0181  *
0182  * This is the extension of the 32-bit mailbox to be able to perform DMA
0183  * beyond 4GB address range.
0184  */
0185 typedef struct {
0186     uint32_t    xferaddr_lo;
0187     uint32_t    xferaddr_hi;
0188     mbox_t      mbox32;
0189 } __attribute__ ((packed)) mbox64_t;
0190 
0191 /*
0192  * mailbox structure used for internal commands
0193  */
0194 typedef struct {
0195     u8  cmd;
0196     u8  cmdid;
0197     u8  opcode;
0198     u8  subopcode;
0199     u32 lba;
0200     u32 xferaddr;
0201     u8  logdrv;
0202     u8  rsvd[3];
0203     u8  numstatus;
0204     u8  status;
0205 } __attribute__ ((packed)) int_mbox_t;
0206 
0207 /**
0208  * mraid_passthru_t - passthru structure to issue commands to physical devices
0209  * @timeout     : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
0210  * @ars         : set if ARS required after check condition
0211  * @islogical       : set if command meant for logical devices
0212  * @logdrv      : logical drive number if command for LD
0213  * @channel     : Channel on which physical device is located
0214  * @target      : SCSI target of the device
0215  * @queuetag        : unused
0216  * @queueaction     : unused
0217  * @cdb         : SCSI CDB
0218  * @cdblen      : length of the CDB
0219  * @reqsenselen     : amount of request sense data to be returned
0220  * @reqsensearea    : Sense information buffer
0221  * @numsge      : number of scatter-gather elements in the sg list
0222  * @scsistatus      : SCSI status of the command completed.
0223  * @dataxferaddr    : DMA data transfer address
0224  * @dataxferlen     : amount of the data to be transferred.
0225  */
0226 typedef struct {
0227     uint8_t     timeout     :3;
0228     uint8_t     ars     :1;
0229     uint8_t     reserved    :3;
0230     uint8_t     islogical   :1;
0231     uint8_t     logdrv;
0232     uint8_t     channel;
0233     uint8_t     target;
0234     uint8_t     queuetag;
0235     uint8_t     queueaction;
0236     uint8_t     cdb[10];
0237     uint8_t     cdblen;
0238     uint8_t     reqsenselen;
0239     uint8_t     reqsensearea[MAX_REQ_SENSE_LEN];
0240     uint8_t     numsge;
0241     uint8_t     scsistatus;
0242     uint32_t    dataxferaddr;
0243     uint32_t    dataxferlen;
0244 } __attribute__ ((packed)) mraid_passthru_t;
0245 
0246 typedef struct {
0247 
0248     uint32_t        dataxferaddr_lo;
0249     uint32_t        dataxferaddr_hi;
0250     mraid_passthru_t    pthru32;
0251 
0252 } __attribute__ ((packed)) mega_passthru64_t;
0253 
0254 /**
0255  * mraid_epassthru_t - passthru structure to issue commands to physical devices
0256  * @timeout     : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
0257  * @ars         : set if ARS required after check condition
0258  * @rsvd1       : reserved field
0259  * @cd_rom      : (?)
0260  * @rsvd2       : reserved field
0261  * @islogical       : set if command meant for logical devices
0262  * @logdrv      : logical drive number if command for LD
0263  * @channel     : Channel on which physical device is located
0264  * @target      : SCSI target of the device
0265  * @queuetag        : unused
0266  * @queueaction     : unused
0267  * @cdblen      : length of the CDB
0268  * @rsvd3       : reserved field
0269  * @cdb         : SCSI CDB
0270  * @numsge      : number of scatter-gather elements in the sg list
0271  * @status      : SCSI status of the command completed.
0272  * @reqsenselen     : amount of request sense data to be returned
0273  * @reqsensearea    : Sense information buffer
0274  * @rsvd4       : reserved field
0275  * @dataxferaddr    : DMA data transfer address
0276  * @dataxferlen     : amount of the data to be transferred.
0277  */
0278 typedef struct {
0279     uint8_t     timeout     :3;
0280     uint8_t     ars     :1;
0281     uint8_t     rsvd1       :1;
0282     uint8_t     cd_rom      :1;
0283     uint8_t     rsvd2       :1;
0284     uint8_t     islogical   :1;
0285     uint8_t     logdrv;
0286     uint8_t     channel;
0287     uint8_t     target;
0288     uint8_t     queuetag;
0289     uint8_t     queueaction;
0290     uint8_t     cdblen;
0291     uint8_t     rsvd3;
0292     uint8_t     cdb[16];
0293     uint8_t     numsge;
0294     uint8_t     status;
0295     uint8_t     reqsenselen;
0296     uint8_t     reqsensearea[MAX_REQ_SENSE_LEN];
0297     uint8_t     rsvd4;
0298     uint32_t    dataxferaddr;
0299     uint32_t    dataxferlen;
0300 } __attribute__ ((packed)) mraid_epassthru_t;
0301 
0302 
0303 /**
0304  * mraid_pinfo_t - product info, static information about the controller
0305  * @data_size       : current size in bytes (not including resvd)
0306  * @config_signature    : Current value is 0x00282008
0307  * @fw_version      : Firmware version
0308  * @bios_version    : version of the BIOS
0309  * @product_name    : Name given to the controller
0310  * @max_commands    : Maximum concurrent commands supported
0311  * @nchannels       : Number of SCSI Channels detected
0312  * @fc_loop_present : Number of Fibre Loops detected
0313  * @mem_type        : EDO, FPM, SDRAM etc
0314  * @signature       :
0315  * @dram_size       : In terms of MB
0316  * @subsysid        : device PCI subsystem ID
0317  * @subsysvid       : device PCI subsystem vendor ID
0318  * @notify_counters :
0319  * @pad1k       : 135 + 889 resvd = 1024 total size
0320  *
0321  * This structures holds the information about the controller which is not
0322  * expected to change dynamically.
0323  *
0324  * The current value of config signature is 0x00282008:
0325  * 0x28 = MAX_LOGICAL_DRIVES,
0326  * 0x20 = Number of stripes and
0327  * 0x08 = Number of spans
0328  */
0329 typedef struct {
0330     uint32_t    data_size;
0331     uint32_t    config_signature;
0332     uint8_t     fw_version[16];
0333     uint8_t     bios_version[16];
0334     uint8_t     product_name[80];
0335     uint8_t     max_commands;
0336     uint8_t     nchannels;
0337     uint8_t     fc_loop_present;
0338     uint8_t     mem_type;
0339     uint32_t    signature;
0340     uint16_t    dram_size;
0341     uint16_t    subsysid;
0342     uint16_t    subsysvid;
0343     uint8_t     notify_counters;
0344     uint8_t     pad1k[889];
0345 } __attribute__ ((packed)) mraid_pinfo_t;
0346 
0347 
0348 /**
0349  * mraid_notify_t - the notification structure
0350  * @global_counter      : Any change increments this counter
0351  * @param_counter       : Indicates any params changed
0352  * @param_id            : Param modified - defined below
0353  * @param_val           : New val of last param modified
0354  * @write_config_counter    : write config occurred
0355  * @write_config_rsvd       :
0356  * @ldrv_op_counter     : Indicates ldrv op started/completed
0357  * @ldrv_opid           : ldrv num
0358  * @ldrv_opcmd          : ldrv operation - defined below
0359  * @ldrv_opstatus       : status of the operation
0360  * @ldrv_state_counter      : Indicates change of ldrv state
0361  * @ldrv_state_id       : ldrv num
0362  * @ldrv_state_new      : New state
0363  * @ldrv_state_old      : old state
0364  * @pdrv_state_counter      : Indicates change of ldrv state
0365  * @pdrv_state_id       : pdrv id
0366  * @pdrv_state_new      : New state
0367  * @pdrv_state_old      : old state
0368  * @pdrv_fmt_counter        : Indicates pdrv format started/over
0369  * @pdrv_fmt_id         : pdrv id
0370  * @pdrv_fmt_val        : format started/over
0371  * @pdrv_fmt_rsvd       :
0372  * @targ_xfer_counter       : Indicates SCSI-2 Xfer rate change
0373  * @targ_xfer_id        : pdrv Id
0374  * @targ_xfer_val       : new Xfer params of last pdrv
0375  * @targ_xfer_rsvd      :
0376  * @fcloop_id_chg_counter   : Indicates loopid changed
0377  * @fcloopid_pdrvid     : pdrv id
0378  * @fcloop_id0          : loopid on fc loop 0
0379  * @fcloop_id1          : loopid on fc loop 1
0380  * @fcloop_state_counter    : Indicates loop state changed
0381  * @fcloop_state0       : state of fc loop 0
0382  * @fcloop_state1       : state of fc loop 1
0383  * @fcloop_state_rsvd       :
0384  */
0385 typedef struct {
0386     uint32_t    global_counter;
0387     uint8_t     param_counter;
0388     uint8_t     param_id;
0389     uint16_t    param_val;
0390     uint8_t     write_config_counter;
0391     uint8_t     write_config_rsvd[3];
0392     uint8_t     ldrv_op_counter;
0393     uint8_t     ldrv_opid;
0394     uint8_t     ldrv_opcmd;
0395     uint8_t     ldrv_opstatus;
0396     uint8_t     ldrv_state_counter;
0397     uint8_t     ldrv_state_id;
0398     uint8_t     ldrv_state_new;
0399     uint8_t     ldrv_state_old;
0400     uint8_t     pdrv_state_counter;
0401     uint8_t     pdrv_state_id;
0402     uint8_t     pdrv_state_new;
0403     uint8_t     pdrv_state_old;
0404     uint8_t     pdrv_fmt_counter;
0405     uint8_t     pdrv_fmt_id;
0406     uint8_t     pdrv_fmt_val;
0407     uint8_t     pdrv_fmt_rsvd;
0408     uint8_t     targ_xfer_counter;
0409     uint8_t     targ_xfer_id;
0410     uint8_t     targ_xfer_val;
0411     uint8_t     targ_xfer_rsvd;
0412     uint8_t     fcloop_id_chg_counter;
0413     uint8_t     fcloopid_pdrvid;
0414     uint8_t     fcloop_id0;
0415     uint8_t     fcloop_id1;
0416     uint8_t     fcloop_state_counter;
0417     uint8_t     fcloop_state0;
0418     uint8_t     fcloop_state1;
0419     uint8_t     fcloop_state_rsvd;
0420 } __attribute__ ((packed)) mraid_notify_t;
0421 
0422 
0423 /**
0424  * mraid_inquiry3_t - enquiry for device information
0425  *
0426  * @data_size       : current size in bytes (not including resvd)
0427  * @notify      :
0428  * @notify_rsvd     :
0429  * @rebuild_rate    : rebuild rate (0% - 100%)
0430  * @cache_flush_int : cache flush interval in seconds
0431  * @sense_alert     :
0432  * @drive_insert_count  : drive insertion count
0433  * @battery_status  :
0434  * @num_ldrv        : no. of Log Drives configured
0435  * @recon_state     : state of reconstruct
0436  * @ldrv_op_status  : logdrv Status
0437  * @ldrv_size       : size of each log drv
0438  * @ldrv_prop       :
0439  * @ldrv_state      : state of log drives
0440  * @pdrv_state      : state of phys drvs.
0441  * @pdrv_format     :
0442  * @targ_xfer       : phys device transfer rate
0443  * @pad1k       : 761 + 263reserved = 1024 bytes total size
0444  */
0445 #define MAX_NOTIFY_SIZE     0x80
0446 #define CUR_NOTIFY_SIZE     sizeof(mraid_notify_t)
0447 
0448 typedef struct {
0449     uint32_t    data_size;
0450 
0451     mraid_notify_t  notify;
0452 
0453     uint8_t     notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
0454 
0455     uint8_t     rebuild_rate;
0456     uint8_t     cache_flush_int;
0457     uint8_t     sense_alert;
0458     uint8_t     drive_insert_count;
0459 
0460     uint8_t     battery_status;
0461     uint8_t     num_ldrv;
0462     uint8_t     recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
0463     uint16_t    ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
0464 
0465     uint32_t    ldrv_size[MAX_LOGICAL_DRIVES_40LD];
0466     uint8_t     ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
0467     uint8_t     ldrv_state[MAX_LOGICAL_DRIVES_40LD];
0468     uint8_t     pdrv_state[FC_MAX_PHYSICAL_DEVICES];
0469     uint16_t    pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
0470 
0471     uint8_t     targ_xfer[80];
0472     uint8_t     pad1k[263];
0473 } __attribute__ ((packed)) mraid_inquiry3_t;
0474 
0475 
0476 /**
0477  * mraid_adapinfo_t - information about the adapter
0478  * @max_commands        : max concurrent commands supported
0479  * @rebuild_rate        : rebuild rate - 0% thru 100%
0480  * @max_targ_per_chan       : max targ per channel
0481  * @nchannels           : number of channels on HBA
0482  * @fw_version          : firmware version
0483  * @age_of_flash        : number of times FW has been flashed
0484  * @chip_set_value      : contents of 0xC0000832
0485  * @dram_size           : in MB
0486  * @cache_flush_interval    : in seconds
0487  * @bios_version        :
0488  * @board_type          :
0489  * @sense_alert         :
0490  * @write_config_count      : increase with every configuration change
0491  * @drive_inserted_count    : increase with every drive inserted
0492  * @inserted_drive      : channel:Id of inserted drive
0493  * @battery_status      : bit 0: battery module missing
0494  *              bit 1: VBAD
0495  *              bit 2: temperature high
0496  *              bit 3: battery pack missing
0497  *              bit 4,5:
0498  *                  00 - charge complete
0499  *                  01 - fast charge in progress
0500  *                  10 - fast charge fail
0501  *                  11 - undefined
0502  *              bit 6: counter > 1000
0503  *              bit 7: Undefined
0504  * @dec_fault_bus_info      :
0505  */
0506 typedef struct {
0507     uint8_t     max_commands;
0508     uint8_t     rebuild_rate;
0509     uint8_t     max_targ_per_chan;
0510     uint8_t     nchannels;
0511     uint8_t     fw_version[4];
0512     uint16_t    age_of_flash;
0513     uint8_t     chip_set_value;
0514     uint8_t     dram_size;
0515     uint8_t     cache_flush_interval;
0516     uint8_t     bios_version[4];
0517     uint8_t     board_type;
0518     uint8_t     sense_alert;
0519     uint8_t     write_config_count;
0520     uint8_t     battery_status;
0521     uint8_t     dec_fault_bus_info;
0522 } __attribute__ ((packed)) mraid_adapinfo_t;
0523 
0524 
0525 /**
0526  * mraid_ldrv_info_t - information about the logical drives
0527  * @nldrv   : Number of logical drives configured
0528  * @rsvd    :
0529  * @size    : size of each logical drive
0530  * @prop    :
0531  * @state   : state of each logical drive
0532  */
0533 typedef struct {
0534     uint8_t     nldrv;
0535     uint8_t     rsvd[3];
0536     uint32_t    size[MAX_LOGICAL_DRIVES_8LD];
0537     uint8_t     prop[MAX_LOGICAL_DRIVES_8LD];
0538     uint8_t     state[MAX_LOGICAL_DRIVES_8LD];
0539 } __attribute__ ((packed)) mraid_ldrv_info_t;
0540 
0541 
0542 /**
0543  * mraid_pdrv_info_t - information about the physical drives
0544  * @pdrv_state  : state of each physical drive
0545  */
0546 typedef struct {
0547     uint8_t     pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
0548     uint8_t     rsvd;
0549 } __attribute__ ((packed)) mraid_pdrv_info_t;
0550 
0551 
0552 /**
0553  * mraid_inquiry_t - RAID inquiry, mailbox command 0x05
0554  * @mraid_adapinfo_t    : adapter information
0555  * @mraid_ldrv_info_t   : logical drives information
0556  * @mraid_pdrv_info_t   : physical drives information
0557  */
0558 typedef struct {
0559     mraid_adapinfo_t    adapter_info;
0560     mraid_ldrv_info_t   logdrv_info;
0561     mraid_pdrv_info_t   pdrv_info;
0562 } __attribute__ ((packed)) mraid_inquiry_t;
0563 
0564 
0565 /**
0566  * mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
0567  *
0568  * @raid_inq        : raid inquiry
0569  * @phys_drv_format :
0570  * @stack_attn      :
0571  * @modem_status    :
0572  * @rsvd        :
0573  */
0574 typedef struct {
0575     mraid_inquiry_t raid_inq;
0576     uint16_t    phys_drv_format[MAX_MBOX_CHANNELS];
0577     uint8_t     stack_attn;
0578     uint8_t     modem_status;
0579     uint8_t     rsvd[2];
0580 } __attribute__ ((packed)) mraid_extinq_t;
0581 
0582 
0583 /**
0584  * adap_device_t - device information
0585  * @channel : channel fpor the device
0586  * @target  : target ID of the device
0587  */
0588 typedef struct {
0589     uint8_t     channel;
0590     uint8_t     target;
0591 }__attribute__ ((packed)) adap_device_t;
0592 
0593 
0594 /**
0595  * adap_span_40ld_t - 40LD span
0596  * @start_blk   : starting block
0597  * @num_blks    : number of blocks
0598  */
0599 typedef struct {
0600     uint32_t    start_blk;
0601     uint32_t    num_blks;
0602     adap_device_t   device[MAX_ROW_SIZE_40LD];
0603 }__attribute__ ((packed)) adap_span_40ld_t;
0604 
0605 
0606 /**
0607  * adap_span_8ld_t - 8LD span
0608  * @start_blk   : starting block
0609  * @num_blks    : number of blocks
0610  */
0611 typedef struct {
0612     uint32_t    start_blk;
0613     uint32_t    num_blks;
0614     adap_device_t   device[MAX_ROW_SIZE_8LD];
0615 }__attribute__ ((packed)) adap_span_8ld_t;
0616 
0617 
0618 /**
0619  * logdrv_param_t - logical drives parameters
0620  *
0621  * @span_depth  : total number of spans
0622  * @level   : RAID level
0623  * @read_ahead  : read ahead, no read ahead, adaptive read ahead
0624  * @stripe_sz   : encoded stripe size
0625  * @status  : status of the logical drive
0626  * @write_mode  : write mode, write_through/write_back
0627  * @direct_io   : direct io or through cache
0628  * @row_size    : number of stripes in a row
0629  */
0630 typedef struct {
0631     uint8_t     span_depth;
0632     uint8_t     level;
0633     uint8_t     read_ahead;
0634     uint8_t     stripe_sz;
0635     uint8_t     status;
0636     uint8_t     write_mode;
0637     uint8_t     direct_io;
0638     uint8_t     row_size;
0639 } __attribute__ ((packed)) logdrv_param_t;
0640 
0641 
0642 /**
0643  * logdrv_40ld_t - logical drive definition for 40LD controllers
0644  * @lparam  : logical drives parameters
0645  * @span    : span
0646  */
0647 typedef struct {
0648     logdrv_param_t      lparam;
0649     adap_span_40ld_t    span[SPAN_DEPTH_8_SPANS];
0650 }__attribute__ ((packed)) logdrv_40ld_t;
0651 
0652 
0653 /**
0654  * logdrv_8ld_span8_t - logical drive definition for 8LD controllers
0655  * @lparam  : logical drives parameters
0656  * @span    : span
0657  *
0658  * 8-LD logical drive with up to 8 spans
0659  */
0660 typedef struct {
0661     logdrv_param_t  lparam;
0662     adap_span_8ld_t span[SPAN_DEPTH_8_SPANS];
0663 }__attribute__ ((packed)) logdrv_8ld_span8_t;
0664 
0665 
0666 /**
0667  * logdrv_8ld_span4_t - logical drive definition for 8LD controllers
0668  * @lparam  : logical drives parameters
0669  * @span    : span
0670  *
0671  * 8-LD logical drive with up to 4 spans
0672  */
0673 typedef struct {
0674     logdrv_param_t  lparam;
0675     adap_span_8ld_t span[SPAN_DEPTH_4_SPANS];
0676 }__attribute__ ((packed)) logdrv_8ld_span4_t;
0677 
0678 
0679 /**
0680  * phys_drive_t - physical device information
0681  * @type    : Type of the device
0682  * @cur_status  : current status of the device
0683  * @tag_depth   : Level of tagging
0684  * @sync_neg    : sync negotiation - ENABLE or DISABLE
0685  * @size    : configurable size in terms of 512 byte
0686  */
0687 typedef struct {
0688     uint8_t     type;
0689     uint8_t     cur_status;
0690     uint8_t     tag_depth;
0691     uint8_t     sync_neg;
0692     uint32_t    size;
0693 }__attribute__ ((packed)) phys_drive_t;
0694 
0695 
0696 /**
0697  * disk_array_40ld_t - disk array for 40LD controllers
0698  * @numldrv : number of logical drives
0699  * @resvd   :
0700  * @ldrv    : logical drives information
0701  * @pdrv    : physical drives information
0702  */
0703 typedef struct {
0704     uint8_t     numldrv;
0705     uint8_t     resvd[3];
0706     logdrv_40ld_t   ldrv[MAX_LOGICAL_DRIVES_40LD];
0707     phys_drive_t    pdrv[MBOX_MAX_PHYSICAL_DRIVES];
0708 }__attribute__ ((packed)) disk_array_40ld_t;
0709 
0710 
0711 /**
0712  * disk_array_8ld_span8_t - disk array for 8LD controllers
0713  * @numldrv : number of logical drives
0714  * @resvd   :
0715  * @ldrv    : logical drives information
0716  * @pdrv    : physical drives information
0717  *
0718  * Disk array for 8LD logical drives with up to 8 spans
0719  */
0720 typedef struct {
0721     uint8_t         numldrv;
0722     uint8_t         resvd[3];
0723     logdrv_8ld_span8_t  ldrv[MAX_LOGICAL_DRIVES_8LD];
0724     phys_drive_t        pdrv[MBOX_MAX_PHYSICAL_DRIVES];
0725 }__attribute__ ((packed)) disk_array_8ld_span8_t;
0726 
0727 
0728 /**
0729  * disk_array_8ld_span4_t - disk array for 8LD controllers
0730  * @numldrv : number of logical drives
0731  * @resvd   :
0732  * @ldrv    : logical drives information
0733  * @pdrv    : physical drives information
0734  *
0735  * Disk array for 8LD logical drives with up to 4 spans
0736  */
0737 typedef struct {
0738     uint8_t         numldrv;
0739     uint8_t         resvd[3];
0740     logdrv_8ld_span4_t  ldrv[MAX_LOGICAL_DRIVES_8LD];
0741     phys_drive_t        pdrv[MBOX_MAX_PHYSICAL_DRIVES];
0742 }__attribute__ ((packed)) disk_array_8ld_span4_t;
0743 
0744 
0745 /**
0746  * struct private_bios_data - bios private data for boot devices
0747  * @geometry    : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
0748  *      0x1000 - 8GB, Others values are invalid
0749  * @unused  : bits 4-7 are unused
0750  * @boot_drv    : logical drive set as boot drive, 0..7 - for 8LD cards,
0751  *      0..39 - for 40LD cards
0752  * @cksum   : 0-(sum of first 13 bytes of this structure)
0753  */
0754 struct private_bios_data {
0755     uint8_t     geometry    :4;
0756     uint8_t     unused      :4;
0757     uint8_t     boot_drv;
0758     uint8_t     rsvd[12];
0759     uint16_t    cksum;
0760 } __attribute__ ((packed));
0761 
0762 
0763 /**
0764  * mbox_sgl64 - 64-bit scatter list for mailbox based controllers
0765  * @address : address of the buffer
0766  * @length  : data transfer length
0767  */
0768 typedef struct {
0769     uint64_t    address;
0770     uint32_t    length;
0771 } __attribute__ ((packed)) mbox_sgl64;
0772 
0773 /**
0774  * mbox_sgl32 - 32-bit scatter list for mailbox based controllers
0775  * @address : address of the buffer
0776  * @length  : data transfer length
0777  */
0778 typedef struct {
0779     uint32_t    address;
0780     uint32_t    length;
0781 } __attribute__ ((packed)) mbox_sgl32;
0782 
0783 #endif      // _MRAID_MBOX_DEFS_H_