Import Upstream version 0.4.5

This commit is contained in:
geos_one
2025-08-06 16:36:24 +02:00
parent 64807cf811
commit cfe47daa9a
122 changed files with 489 additions and 1254 deletions

View File

@@ -0,0 +1,823 @@
/*
*
* Linux MegaRAID Unified device driver
*
* Copyright (c) 2003-2004 LSI Logic Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* FILE : mbox_defs.h
*
*/
#ifndef _MRAID_MBOX_DEFS_H_
#define _MRAID_MBOX_DEFS_H_
#include <linux/types.h>
/*
* Commands and states for mailbox based controllers
*/
#define MBOXCMD_LREAD 0x01
#define MBOXCMD_LWRITE 0x02
#define MBOXCMD_PASSTHRU 0x03
#define MBOXCMD_ADPEXTINQ 0x04
#define MBOXCMD_ADAPTERINQ 0x05
#define MBOXCMD_LREAD64 0xA7
#define MBOXCMD_LWRITE64 0xA8
#define MBOXCMD_PASSTHRU64 0xC3
#define MBOXCMD_EXTPTHRU 0xE3
#define MAIN_MISC_OPCODE 0xA4
#define GET_MAX_SG_SUPPORT 0x01
#define SUPPORT_EXT_CDB 0x16
#define FC_NEW_CONFIG 0xA1
#define NC_SUBOP_PRODUCT_INFO 0x0E
#define NC_SUBOP_ENQUIRY3 0x0F
#define ENQ3_GET_SOLICITED_FULL 0x02
#define OP_DCMD_READ_CONFIG 0x04
#define NEW_READ_CONFIG_8LD 0x67
#define READ_CONFIG_8LD 0x07
#define FLUSH_ADAPTER 0x0A
#define FLUSH_SYSTEM 0xFE
/*
* Command for random deletion of logical drives
*/
#define FC_DEL_LOGDRV 0xA4
#define OP_SUP_DEL_LOGDRV 0x2A
#define OP_GET_LDID_MAP 0x18
#define OP_DEL_LOGDRV 0x1C
/*
* BIOS commands
*/
#define IS_BIOS_ENABLED 0x62
#define GET_BIOS 0x01
#define CHNL_CLASS 0xA9
#define GET_CHNL_CLASS 0x00
#define SET_CHNL_CLASS 0x01
#define CH_RAID 0x01
#define CH_SCSI 0x00
#define BIOS_PVT_DATA 0x40
#define GET_BIOS_PVT_DATA 0x00
/*
* Commands to support clustering
*/
#define GET_TARGET_ID 0x7D
#define CLUSTER_OP 0x70
#define GET_CLUSTER_MODE 0x02
#define CLUSTER_CMD 0x6E
#define RESERVE_LD 0x01
#define RELEASE_LD 0x02
#define RESET_RESERVATIONS 0x03
#define RESERVATION_STATUS 0x04
#define RESERVE_PD 0x05
#define RELEASE_PD 0x06
/*
* Module battery status
*/
#define BATTERY_MODULE_MISSING 0x01
#define BATTERY_LOW_VOLTAGE 0x02
#define BATTERY_TEMP_HIGH 0x04
#define BATTERY_PACK_MISSING 0x08
#define BATTERY_CHARGE_MASK 0x30
#define BATTERY_CHARGE_DONE 0x00
#define BATTERY_CHARGE_INPROG 0x10
#define BATTERY_CHARGE_FAIL 0x20
#define BATTERY_CYCLES_EXCEEDED 0x40
/*
* Physical drive states.
*/
#define PDRV_UNCNF 0
#define PDRV_ONLINE 3
#define PDRV_FAILED 4
#define PDRV_RBLD 5
#define PDRV_HOTSPARE 6
/*
* Raid logical drive states.
*/
#define RDRV_OFFLINE 0
#define RDRV_DEGRADED 1
#define RDRV_OPTIMAL 2
#define RDRV_DELETED 3
/*
* Read, write and cache policies
*/
#define NO_READ_AHEAD 0
#define READ_AHEAD 1
#define ADAP_READ_AHEAD 2
#define WRMODE_WRITE_THRU 0
#define WRMODE_WRITE_BACK 1
#define CACHED_IO 0
#define DIRECT_IO 1
#define MAX_LOGICAL_DRIVES_8LD 8
#define MAX_LOGICAL_DRIVES_40LD 40
#define FC_MAX_PHYSICAL_DEVICES 256
#define MAX_MBOX_CHANNELS 5
#define MAX_MBOX_TARGET 15
#define MBOX_MAX_PHYSICAL_DRIVES MAX_MBOX_CHANNELS*MAX_MBOX_TARGET
#define MAX_ROW_SIZE_40LD 32
#define MAX_ROW_SIZE_8LD 8
#define SPAN_DEPTH_8_SPANS 8
#define SPAN_DEPTH_4_SPANS 4
#define MAX_REQ_SENSE_LEN 0x20
/**
* struct mbox_t - Driver and f/w handshake structure.
* @cmd : firmware command
* @cmdid : command id
* @numsectors : number of sectors to be transferred
* @lba : Logical Block Address on LD
* @xferaddr : DMA address for data transfer
* @logdrv : logical drive number
* @numsge : number of scatter gather elements in sg list
* @resvd : reserved
* @busy : f/w busy, must wait to issue more commands.
* @numstatus : number of commands completed.
* @status : status of the commands completed
* @completed : array of completed command ids.
* @poll : poll and ack sequence
* @ack : poll and ack sequence
*
* The central handshake structure between the driver and the firmware. This
* structure must be allocated by the driver and aligned at 8-byte boundary.
*/
#define MBOX_MAX_FIRMWARE_STATUS 46
typedef struct {
uint8_t cmd;
uint8_t cmdid;
uint16_t numsectors;
uint32_t lba;
uint32_t xferaddr;
uint8_t logdrv;
uint8_t numsge;
uint8_t resvd;
uint8_t busy;
uint8_t numstatus;
uint8_t status;
uint8_t completed[MBOX_MAX_FIRMWARE_STATUS];
uint8_t poll;
uint8_t ack;
} __attribute__ ((packed)) mbox_t;
/**
* mbox64_t - 64-bit extension for the mailbox
* @segment_lo : the low 32-bits of the address of the scatter-gather list
* @segment_hi : the upper 32-bits of the address of the scatter-gather list
* @mbox : 32-bit mailbox, whose xferadder field must be set to
* 0xFFFFFFFF
*
* This is the extension of the 32-bit mailbox to be able to perform DMA
* beyond 4GB address range.
*/
typedef struct {
uint32_t xferaddr_lo;
uint32_t xferaddr_hi;
mbox_t mbox32;
} __attribute__ ((packed)) mbox64_t;
/*
* mailbox structure used for internal commands
*/
typedef struct {
u8 cmd;
u8 cmdid;
u8 opcode;
u8 subopcode;
u32 lba;
u32 xferaddr;
u8 logdrv;
u8 rsvd[3];
u8 numstatus;
u8 status;
} __attribute__ ((packed)) int_mbox_t;
/**
* mraid_passthru_t - passthru structure to issue commands to physical devices
* @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
* @ars : set if ARS required after check condition
* @islogical : set if command meant for logical devices
* @logdrv : logical drive number if command for LD
* @channel : Channel on which physical device is located
* @target : SCSI target of the device
* @queuetag : unused
* @queueaction : unused
* @cdb : SCSI CDB
* @cdblen : length of the CDB
* @reqsenselen : amount of request sense data to be returned
* @reqsensearea : Sense information buffer
* @numsge : number of scatter-gather elements in the sg list
* @scsistatus : SCSI status of the command completed.
* @dataxferaddr : DMA data transfer address
* @dataxferlen : amount of the data to be transferred.
*/
typedef struct {
uint8_t timeout :3;
uint8_t ars :1;
uint8_t reserved :3;
uint8_t islogical :1;
uint8_t logdrv;
uint8_t channel;
uint8_t target;
uint8_t queuetag;
uint8_t queueaction;
uint8_t cdb[10];
uint8_t cdblen;
uint8_t reqsenselen;
uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
uint8_t numsge;
uint8_t scsistatus;
uint32_t dataxferaddr;
uint32_t dataxferlen;
} __attribute__ ((packed)) mraid_passthru_t;
typedef struct {
uint32_t dataxferaddr_lo;
uint32_t dataxferaddr_hi;
mraid_passthru_t pthru32;
} __attribute__ ((packed)) mega_passthru64_t;
/**
* mraid_epassthru_t - passthru structure to issue commands to physical devices
* @timeout : command timeout, 0=6sec, 1=60sec, 2=10min, 3=3hr
* @ars : set if ARS required after check condition
* @rsvd1 : reserved field
* @cd_rom : (?)
* @rsvd2 : reserved field
* @islogical : set if command meant for logical devices
* @logdrv : logical drive number if command for LD
* @channel : Channel on which physical device is located
* @target : SCSI target of the device
* @queuetag : unused
* @queueaction : unused
* @cdblen : length of the CDB
* @rsvd3 : reserved field
* @cdb : SCSI CDB
* @numsge : number of scatter-gather elements in the sg list
* @status : SCSI status of the command completed.
* @reqsenselen : amount of request sense data to be returned
* @reqsensearea : Sense information buffer
* @rsvd4 : reserved field
* @dataxferaddr : DMA data transfer address
* @dataxferlen : amount of the data to be transferred.
*/
typedef struct {
uint8_t timeout :3;
uint8_t ars :1;
uint8_t rsvd1 :1;
uint8_t cd_rom :1;
uint8_t rsvd2 :1;
uint8_t islogical :1;
uint8_t logdrv;
uint8_t channel;
uint8_t target;
uint8_t queuetag;
uint8_t queueaction;
uint8_t cdblen;
uint8_t rsvd3;
uint8_t cdb[16];
uint8_t numsge;
uint8_t status;
uint8_t reqsenselen;
uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
uint8_t rsvd4;
uint32_t dataxferaddr;
uint32_t dataxferlen;
} __attribute__ ((packed)) mraid_epassthru_t;
/**
* mraid_pinfo_t - product info, static information about the controller
* @data_size : current size in bytes (not including resvd)
* @config_signature : Current value is 0x00282008
* @fw_version : Firmware version
* @bios_version : version of the BIOS
* @product_name : Name given to the controller
* @max_commands : Maximum concurrent commands supported
* @nchannels : Number of SCSI Channels detected
* @fc_loop_present : Number of Fibre Loops detected
* @mem_type : EDO, FPM, SDRAM etc
* @signature :
* @dram_size : In terms of MB
* @subsysid : device PCI subsystem ID
* @subsysvid : device PCI subsystem vendor ID
* @notify_counters :
* @pad1k : 135 + 889 resvd = 1024 total size
*
* This structures holds the information about the controller which is not
* expected to change dynamically.
*
* The current value of config signature is 0x00282008:
* 0x28 = MAX_LOGICAL_DRIVES,
* 0x20 = Number of stripes and
* 0x08 = Number of spans
*/
typedef struct {
uint32_t data_size;
uint32_t config_signature;
uint8_t fw_version[16];
uint8_t bios_version[16];
uint8_t product_name[80];
uint8_t max_commands;
uint8_t nchannels;
uint8_t fc_loop_present;
uint8_t mem_type;
uint32_t signature;
uint16_t dram_size;
uint16_t subsysid;
uint16_t subsysvid;
uint8_t notify_counters;
uint8_t pad1k[889];
} __attribute__ ((packed)) mraid_pinfo_t;
/**
* mraid_notify_t - the notification structure
* @global_counter : Any change increments this counter
* @param_counter : Indicates any params changed
* @param_id : Param modified - defined below
* @param_val : New val of last param modified
* @write_config_counter : write config occurred
* @write_config_rsvd :
* @ldrv_op_counter : Indicates ldrv op started/completed
* @ldrv_opid : ldrv num
* @ldrv_opcmd : ldrv operation - defined below
* @ldrv_opstatus : status of the operation
* @ldrv_state_counter : Indicates change of ldrv state
* @ldrv_state_id : ldrv num
* @ldrv_state_new : New state
* @ldrv_state_old : old state
* @pdrv_state_counter : Indicates change of ldrv state
* @pdrv_state_id : pdrv id
* @pdrv_state_new : New state
* @pdrv_state_old : old state
* @pdrv_fmt_counter : Indicates pdrv format started/over
* @pdrv_fmt_id : pdrv id
* @pdrv_fmt_val : format started/over
* @pdrv_fmt_rsvd :
* @targ_xfer_counter : Indicates SCSI-2 Xfer rate change
* @targ_xfer_id : pdrv Id
* @targ_xfer_val : new Xfer params of last pdrv
* @targ_xfer_rsvd :
* @fcloop_id_chg_counter : Indicates loopid changed
* @fcloopid_pdrvid : pdrv id
* @fcloop_id0 : loopid on fc loop 0
* @fcloop_id1 : loopid on fc loop 1
* @fcloop_state_counter : Indicates loop state changed
* @fcloop_state0 : state of fc loop 0
* @fcloop_state1 : state of fc loop 1
* @fcloop_state_rsvd :
*/
typedef struct {
uint32_t global_counter;
uint8_t param_counter;
uint8_t param_id;
uint16_t param_val;
uint8_t write_config_counter;
uint8_t write_config_rsvd[3];
uint8_t ldrv_op_counter;
uint8_t ldrv_opid;
uint8_t ldrv_opcmd;
uint8_t ldrv_opstatus;
uint8_t ldrv_state_counter;
uint8_t ldrv_state_id;
uint8_t ldrv_state_new;
uint8_t ldrv_state_old;
uint8_t pdrv_state_counter;
uint8_t pdrv_state_id;
uint8_t pdrv_state_new;
uint8_t pdrv_state_old;
uint8_t pdrv_fmt_counter;
uint8_t pdrv_fmt_id;
uint8_t pdrv_fmt_val;
uint8_t pdrv_fmt_rsvd;
uint8_t targ_xfer_counter;
uint8_t targ_xfer_id;
uint8_t targ_xfer_val;
uint8_t targ_xfer_rsvd;
uint8_t fcloop_id_chg_counter;
uint8_t fcloopid_pdrvid;
uint8_t fcloop_id0;
uint8_t fcloop_id1;
uint8_t fcloop_state_counter;
uint8_t fcloop_state0;
uint8_t fcloop_state1;
uint8_t fcloop_state_rsvd;
} __attribute__ ((packed)) mraid_notify_t;
/**
* mraid_inquiry3_t - enquiry for device information
*
* @data_size : current size in bytes (not including resvd)
* @notify :
* @notify_rsvd :
* @rebuild_rate : rebuild rate (0% - 100%)
* @cache_flush_int : cache flush interval in seconds
* @sense_alert :
* @drive_insert_count : drive insertion count
* @battery_status :
* @num_ldrv : no. of Log Drives configured
* @recon_state : state of reconstruct
* @ldrv_op_status : logdrv Status
* @ldrv_size : size of each log drv
* @ldrv_prop :
* @ldrv_state : state of log drives
* @pdrv_state : state of phys drvs.
* @pdrv_format :
* @targ_xfer : phys device transfer rate
* @pad1k : 761 + 263reserved = 1024 bytes total size
*/
#define MAX_NOTIFY_SIZE 0x80
#define CUR_NOTIFY_SIZE sizeof(mraid_notify_t)
typedef struct {
uint32_t data_size;
mraid_notify_t notify;
uint8_t notify_rsvd[MAX_NOTIFY_SIZE - CUR_NOTIFY_SIZE];
uint8_t rebuild_rate;
uint8_t cache_flush_int;
uint8_t sense_alert;
uint8_t drive_insert_count;
uint8_t battery_status;
uint8_t num_ldrv;
uint8_t recon_state[MAX_LOGICAL_DRIVES_40LD / 8];
uint16_t ldrv_op_status[MAX_LOGICAL_DRIVES_40LD / 8];
uint32_t ldrv_size[MAX_LOGICAL_DRIVES_40LD];
uint8_t ldrv_prop[MAX_LOGICAL_DRIVES_40LD];
uint8_t ldrv_state[MAX_LOGICAL_DRIVES_40LD];
uint8_t pdrv_state[FC_MAX_PHYSICAL_DEVICES];
uint16_t pdrv_format[FC_MAX_PHYSICAL_DEVICES / 16];
uint8_t targ_xfer[80];
uint8_t pad1k[263];
} __attribute__ ((packed)) mraid_inquiry3_t;
/**
* mraid_adapinfo_t - information about the adapter
* @max_commands : max concurrent commands supported
* @rebuild_rate : rebuild rate - 0% thru 100%
* @max_targ_per_chan : max targ per channel
* @nchannels : number of channels on HBA
* @fw_version : firmware version
* @age_of_flash : number of times FW has been flashed
* @chip_set_value : contents of 0xC0000832
* @dram_size : in MB
* @cache_flush_interval : in seconds
* @bios_version :
* @board_type :
* @sense_alert :
* @write_config_count : increase with every configuration change
* @drive_inserted_count : increase with every drive inserted
* @inserted_drive : channel:Id of inserted drive
* @battery_status : bit 0: battery module missing
* bit 1: VBAD
* bit 2: temprature high
* bit 3: battery pack missing
* bit 4,5:
* 00 - charge complete
* 01 - fast charge in progress
* 10 - fast charge fail
* 11 - undefined
* bit 6: counter > 1000
* bit 7: Undefined
* @dec_fault_bus_info :
*/
typedef struct {
uint8_t max_commands;
uint8_t rebuild_rate;
uint8_t max_targ_per_chan;
uint8_t nchannels;
uint8_t fw_version[4];
uint16_t age_of_flash;
uint8_t chip_set_value;
uint8_t dram_size;
uint8_t cache_flush_interval;
uint8_t bios_version[4];
uint8_t board_type;
uint8_t sense_alert;
uint8_t write_config_count;
uint8_t battery_status;
uint8_t dec_fault_bus_info;
} __attribute__ ((packed)) mraid_adapinfo_t;
/**
* mraid_ldrv_info_t - information about the logical drives
* @nldrv : Number of logical drives configured
* @rsvd :
* @size : size of each logical drive
* @prop :
* @state : state of each logical drive
*/
typedef struct {
uint8_t nldrv;
uint8_t rsvd[3];
uint32_t size[MAX_LOGICAL_DRIVES_8LD];
uint8_t prop[MAX_LOGICAL_DRIVES_8LD];
uint8_t state[MAX_LOGICAL_DRIVES_8LD];
} __attribute__ ((packed)) mraid_ldrv_info_t;
/**
* mraid_pdrv_info_t - information about the physical drives
* @pdrv_state : state of each physical drive
*/
typedef struct {
uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
uint8_t rsvd;
} __attribute__ ((packed)) mraid_pdrv_info_t;
/**
* mraid_inquiry_t - RAID inquiry, mailbox command 0x05
* @mraid_adapinfo_t : adapter information
* @mraid_ldrv_info_t : logical drives information
* @mraid_pdrv_info_t : physical drives information
*/
typedef struct {
mraid_adapinfo_t adapter_info;
mraid_ldrv_info_t logdrv_info;
mraid_pdrv_info_t pdrv_info;
} __attribute__ ((packed)) mraid_inquiry_t;
/**
* mraid_extinq_t - RAID extended inquiry, mailbox command 0x04
*
* @raid_inq : raid inquiry
* @phys_drv_format :
* @stack_attn :
* @modem_status :
* @rsvd :
*/
typedef struct {
mraid_inquiry_t raid_inq;
uint16_t phys_drv_format[MAX_MBOX_CHANNELS];
uint8_t stack_attn;
uint8_t modem_status;
uint8_t rsvd[2];
} __attribute__ ((packed)) mraid_extinq_t;
/**
* adap_device_t - device information
* @channel : channel fpor the device
* @target : target ID of the device
*/
typedef struct {
uint8_t channel;
uint8_t target;
}__attribute__ ((packed)) adap_device_t;
/**
* adap_span_40ld_t - 40LD span
* @start_blk : starting block
* @num_blks : number of blocks
*/
typedef struct {
uint32_t start_blk;
uint32_t num_blks;
adap_device_t device[MAX_ROW_SIZE_40LD];
}__attribute__ ((packed)) adap_span_40ld_t;
/**
* adap_span_8ld_t - 8LD span
* @start_blk : starting block
* @num_blks : number of blocks
*/
typedef struct {
uint32_t start_blk;
uint32_t num_blks;
adap_device_t device[MAX_ROW_SIZE_8LD];
}__attribute__ ((packed)) adap_span_8ld_t;
/**
* logdrv_param_t - logical drives parameters
*
* @span_depth : total number of spans
* @level : RAID level
* @read_ahead : read ahead, no read ahead, adaptive read ahead
* @stripe_sz : encoded stripe size
* @status : status of the logical drive
* @write_mode : write mode, write_through/write_back
* @direct_io : direct io or through cache
* @row_size : number of stripes in a row
*/
typedef struct {
uint8_t span_depth;
uint8_t level;
uint8_t read_ahead;
uint8_t stripe_sz;
uint8_t status;
uint8_t write_mode;
uint8_t direct_io;
uint8_t row_size;
} __attribute__ ((packed)) logdrv_param_t;
/**
* logdrv_40ld_t - logical drive definition for 40LD controllers
* @lparam : logical drives parameters
* @span : span
*/
typedef struct {
logdrv_param_t lparam;
adap_span_40ld_t span[SPAN_DEPTH_8_SPANS];
}__attribute__ ((packed)) logdrv_40ld_t;
/**
* logdrv_8ld_span8_t - logical drive definition for 8LD controllers
* @lparam : logical drives parameters
* @span : span
*
* 8-LD logical drive with upto 8 spans
*/
typedef struct {
logdrv_param_t lparam;
adap_span_8ld_t span[SPAN_DEPTH_8_SPANS];
}__attribute__ ((packed)) logdrv_8ld_span8_t;
/**
* logdrv_8ld_span4_t - logical drive definition for 8LD controllers
* @lparam : logical drives parameters
* @span : span
*
* 8-LD logical drive with upto 4 spans
*/
typedef struct {
logdrv_param_t lparam;
adap_span_8ld_t span[SPAN_DEPTH_4_SPANS];
}__attribute__ ((packed)) logdrv_8ld_span4_t;
/**
* phys_drive_t - physical device information
* @type : Type of the device
* @cur_status : current status of the device
* @tag_depth : Level of tagging
* @sync_neg : sync negotiation - ENABLE or DISBALE
* @size : configurable size in terms of 512 byte
*/
typedef struct {
uint8_t type;
uint8_t cur_status;
uint8_t tag_depth;
uint8_t sync_neg;
uint32_t size;
}__attribute__ ((packed)) phys_drive_t;
/**
* disk_array_40ld_t - disk array for 40LD controllers
* @numldrv : number of logical drives
* @resvd :
* @ldrv : logical drives information
* @pdrv : physical drives information
*/
typedef struct {
uint8_t numldrv;
uint8_t resvd[3];
logdrv_40ld_t ldrv[MAX_LOGICAL_DRIVES_40LD];
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
}__attribute__ ((packed)) disk_array_40ld_t;
/**
* disk_array_8ld_span8_t - disk array for 8LD controllers
* @numldrv : number of logical drives
* @resvd :
* @ldrv : logical drives information
* @pdrv : physical drives information
*
* Disk array for 8LD logical drives with upto 8 spans
*/
typedef struct {
uint8_t numldrv;
uint8_t resvd[3];
logdrv_8ld_span8_t ldrv[MAX_LOGICAL_DRIVES_8LD];
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
}__attribute__ ((packed)) disk_array_8ld_span8_t;
/**
* disk_array_8ld_span4_t - disk array for 8LD controllers
* @numldrv : number of logical drives
* @resvd :
* @ldrv : logical drives information
* @pdrv : physical drives information
*
* Disk array for 8LD logical drives with upto 4 spans
*/
typedef struct {
uint8_t numldrv;
uint8_t resvd[3];
logdrv_8ld_span4_t ldrv[MAX_LOGICAL_DRIVES_8LD];
phys_drive_t pdrv[MBOX_MAX_PHYSICAL_DRIVES];
}__attribute__ ((packed)) disk_array_8ld_span4_t;
/**
* private_bios_data - bios private data for boot devices
* @geometry : bits 0-3 - BIOS geometry, 0x0001 - 1GB, 0x0010 - 2GB,
* 0x1000 - 8GB, Others values are invalid
* @unused : bits 4-7 are unused
* @boot_drv : logical drive set as boot drive, 0..7 - for 8LD cards,
* 0..39 - for 40LD cards
* @cksum : 0-(sum of first 13 bytes of this structure)
*/
struct private_bios_data {
uint8_t geometry :4;
uint8_t unused :4;
uint8_t boot_drv;
uint8_t rsvd[12];
uint16_t cksum;
} __attribute__ ((packed));
/**
* mbox_sgl64 - 64-bit scatter list for mailbox based controllers
* @address : address of the buffer
* @length : data transfer length
*/
typedef struct {
uint64_t address;
uint32_t length;
} __attribute__ ((packed)) mbox_sgl64;
/**
* mbox_sgl32 - 32-bit scatter list for mailbox based controllers
* @address : address of the buffer
* @length : data transfer length
*/
typedef struct {
uint32_t address;
uint32_t length;
} __attribute__ ((packed)) mbox_sgl32;
#undef wait_event
#define wait_event mraid_mm_diskdump_wait_event
#undef wake_up
#define wake_up mraid_mm_diskdump_wake_up
extern void mraid_mm_diskdump_schedule(void);
extern void mraid_mm_diskdump_wake_up(wait_queue_head_t *q);
#define __mraid_mm_diskdump_wait_event(wq, condition) \
do { \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
\
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_UNINTERRUPTIBLE); \
if (condition) \
break; \
mraid_mm_diskdump_schedule(); \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)
#define mraid_mm_diskdump_wait_event(wq, condition) \
do { \
if (condition) \
break; \
__mraid_mm_diskdump_wait_event(wq, condition); \
} while (0)
#endif // _MRAID_MBOX_DEFS_H_
/* vim: set ts=8 sw=8 tw=78: */

View File

@@ -0,0 +1,290 @@
/*
*
* Linux MegaRAID device driver
*
* Copyright (c) 2003-2004 LSI Logic Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* FILE : mega_common.h
*
* Libaray of common routine used by all low-level megaraid drivers
*/
#ifndef _MEGA_COMMON_H_
#define _MEGA_COMMON_H_
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/blkdev.h>
#include <linux/list.h>
#include <linux/version.h>
#include <linux/moduleparam.h>
#include <linux/dma-mapping.h>
#include <linux/diskdump.h>
#include <asm/semaphore.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#define LSI_MAX_CHANNELS 16
#define LSI_MAX_LOGICAL_DRIVES_64LD (64+1)
#define HBA_SIGNATURE_64BIT 0x0299
#define PCI_CONF_AMISIG64 0xa4
/**
* scb_t - scsi command control block
* @param ccb : command control block for individual driver
* @param list : list of control blocks
* @param gp : general purpose field for LLDs
* @param sno : all SCBs have a serial number
* @param scp : associated scsi command
* @param state : current state of scb
* @param dma_dir : direction of data transfer
* @param dma_type : transfer with sg list, buffer, or no data transfer
* @param dev_channel : actual channel on the device
* @param dev_target : actual target on the device
* @param status : completion status
*
* This is our central data structure to issue commands the each driver.
* Driver specific data structures are maintained in the ccb field.
* scb provides a field 'gp', which can be used by LLD for its own purposes
*
* dev_channel and dev_target must be initialized with the actual channel and
* target on the controller.
*/
typedef struct {
caddr_t ccb;
struct list_head list;
unsigned long gp;
unsigned int sno;
struct scsi_cmnd *scp;
uint32_t state;
uint32_t dma_direction;
uint32_t dma_type;
uint16_t dev_channel;
uint16_t dev_target;
uint32_t status;
} scb_t;
/*
* SCB states as it transitions from one state to another
*/
#define SCB_FREE 0x0000 /* on the free list */
#define SCB_ACTIVE 0x0001 /* off the free list */
#define SCB_PENDQ 0x0002 /* on the pending queue */
#define SCB_ISSUED 0x0004 /* issued - owner f/w */
#define SCB_ABORT 0x0008 /* Got an abort for this one */
#define SCB_RESET 0x0010 /* Got a reset for this one */
/*
* DMA types for scb
*/
#define MRAID_DMA_NONE 0x0000 /* no data transfer for this command */
#define MRAID_DMA_WSG 0x0001 /* data transfer using a sg list */
#define MRAID_DMA_WBUF 0x0002 /* data transfer using a contiguous buffer */
/**
* struct adapter_t - driver's initialization structure
* @param dpc_h : tasklet handle
* @param pdev : pci configuration pointer for kernel
* @param host : pointer to host structure of mid-layer
* @param host_lock : pointer to appropriate lock
* @param lock : synchronization lock for mid-layer and driver
* @param quiescent : driver is quiescent for now.
* @param outstanding_cmds : number of commands pending in the driver
* @param kscb_list : pointer to the bulk of SCBs pointers for IO
* @param kscb_pool : pool of free scbs for IO
* @param kscb_pool_lock : lock for pool of free scbs
* @param pend_list : pending commands list
* @param pend_list_lock : exlusion lock for pending commands list
* @param completed_list : list of completed commands
* @param completed_list_lock : exclusion lock for list of completed commands
* @param sglen : max sg elements supported
* @param device_ids : to convert kernel device addr to our devices.
* @param raid_device : raid adapter specific pointer
* @param max_channel : maximum channel number supported - inclusive
* @param max_target : max target supported - inclusive
* @param max_lun : max lun supported - inclusive
* @param unique_id : unique identifier for each adapter
* @param irq : IRQ for this adapter
* @param ito : internal timeout value, (-1) means no timeout
* @param ibuf : buffer to issue internal commands
* @param ibuf_dma_h : dma handle for the above buffer
* @param uscb_list : SCB pointers for user cmds, common mgmt module
* @param uscb_pool : pool of SCBs for user commands
* @param uscb_pool_lock : exclusion lock for these SCBs
* @param max_cmds : max outstanding commands
* @param fw_version : firmware version
* @param bios_version : bios version
* @param max_cdb_sz : biggest CDB size supported.
* @param ha : is high availability present - clustering
* @param init_id : initiator ID, the default value should be 7
* @param max_sectors : max sectors per request
* @param cmd_per_lun : max outstanding commands per LUN
* @param being_detached : set when unloading, no more mgmt calls
*
*
* mraid_setup_device_map() can be called anytime after the device map is
* available and MRAID_GET_DEVICE_MAP() can be called whenever the mapping is
* required, usually from LLD's queue entry point. The formar API sets up the
* MRAID_IS_LOGICAL(adapter_t *, struct scsi_cmnd *) to find out if the
* device in question is a logical drive.
*
* quiescent flag should be set by the driver if it is not accepting more
* commands
*
* NOTE: The fields of this structures are placed to minimize cache misses
*/
// amount of space required to store the bios and firmware version strings
#define VERSION_SIZE 16
typedef struct {
struct tasklet_struct dpc_h;
struct pci_dev *pdev;
struct Scsi_Host *host;
spinlock_t *host_lock;
spinlock_t lock;
uint8_t quiescent;
int outstanding_cmds;
scb_t *kscb_list;
struct list_head kscb_pool;
spinlock_t kscb_pool_lock;
struct list_head pend_list;
spinlock_t pend_list_lock;
struct list_head completed_list;
spinlock_t completed_list_lock;
uint16_t sglen;
int device_ids[LSI_MAX_CHANNELS]
[LSI_MAX_LOGICAL_DRIVES_64LD];
caddr_t raid_device;
uint8_t max_channel;
uint16_t max_target;
uint8_t max_lun;
uint32_t unique_id;
uint8_t irq;
uint8_t ito;
caddr_t ibuf;
dma_addr_t ibuf_dma_h;
scb_t *uscb_list;
struct list_head uscb_pool;
spinlock_t uscb_pool_lock;
int max_cmds;
uint8_t fw_version[VERSION_SIZE];
uint8_t bios_version[VERSION_SIZE];
uint8_t max_cdb_sz;
uint8_t ha;
uint16_t init_id;
uint16_t max_sectors;
uint16_t cmd_per_lun;
atomic_t being_detached;
} adapter_t;
#define SCSI_FREE_LIST_LOCK(adapter) (&adapter->kscb_pool_lock)
#define USER_FREE_LIST_LOCK(adapter) (&adapter->uscb_pool_lock)
#define PENDING_LIST_LOCK(adapter) (&adapter->pend_list_lock)
#define COMPLETED_LIST_LOCK(adapter) (&adapter->completed_list_lock)
// conversion from scsi command
#define SCP2HOST(scp) (scp)->device->host // to host
#define SCP2HOSTDATA(scp) SCP2HOST(scp)->hostdata // to soft state
#define SCP2CHANNEL(scp) (scp)->device->channel // to channel
#define SCP2TARGET(scp) (scp)->device->id // to target
#define SCP2LUN(scp) (scp)->device->lun // to LUN
// generic macro to convert scsi command and host to controller's soft state
#define SCSIHOST2ADAP(host) (((caddr_t *)(host->hostdata))[0])
#define SCP2ADAPTER(scp) (adapter_t *)SCSIHOST2ADAP(SCP2HOST(scp))
/**
* MRAID_GET_DEVICE_MAP - device ids
* @param adp - Adapter's soft state
* @param scp - mid-layer scsi command pointer
* @param p_chan - physical channel on the controller
* @param target - target id of the device or logical drive number
* @param islogical - set if the command is for the logical drive
*
* Macro to retrieve information about device class, logical or physical and
* the corresponding physical channel and target or logical drive number
**/
#define MRAID_IS_LOGICAL(adp, scp) \
(SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
#define MRAID_IS_LOGICAL_SDEV(adp, sdev) \
(sdev->channel == (adp)->max_channel) ? 1 : 0
#define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical) \
/* \
* Is the request coming for the virtual channel \
*/ \
islogical = MRAID_IS_LOGICAL(adp, scp); \
\
/* \
* Get an index into our table of drive ids mapping \
*/ \
if (islogical) { \
p_chan = 0xFF; \
target = \
(adp)->device_ids[(adp)->max_channel][SCP2TARGET(scp)]; \
} \
else { \
p_chan = ((adp)->device_ids[SCP2CHANNEL(scp)] \
[SCP2TARGET(scp)] >> 8) & 0xFF; \
target = ((adp)->device_ids[SCP2CHANNEL(scp)] \
[SCP2TARGET(scp)] & 0xFF); \
}
/*
* ### Helper routines ###
*/
#define LSI_DBGLVL mraid_debug_level // each LLD must define a global
// mraid_debug_level
#ifdef DEBUG
#if defined (_ASSERT_PANIC)
#define ASSERT_ACTION panic
#else
#define ASSERT_ACTION printk
#endif
#define ASSERT(expression) \
if (!(expression)) { \
ASSERT_ACTION("assertion failed:(%s), file: %s, line: %d:%s\n", \
#expression, __FILE__, __LINE__, __FUNCTION__); \
}
#else
#define ASSERT(expression)
#endif
/*
* struct mraid_pci_blk - structure holds DMA memory block info
* @param vaddr : virtual address to a memory block
* @param dma_addr : DMA handle to a memory block
*
* This structure is filled up for the caller. It is the responsibilty of the
* caller to allocate this array big enough to store addresses for all
* requested elements
*/
struct mraid_pci_blk {
caddr_t vaddr;
dma_addr_t dma_addr;
};
#endif // _MEGA_COMMON_H_
// vim: set ts=8 sw=8 tw=78:

View File

@@ -0,0 +1,300 @@
/*
*
* Linux MegaRAID device driver
*
* Copyright (c) 2003-2004 LSI Logic Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_ioctl.h
*
* Definitions to interface with user level applications
*/
#ifndef _MEGARAID_IOCTL_H_
#define _MEGARAID_IOCTL_H_
#include <linux/types.h>
#include <asm/semaphore.h>
#include "mbox_defs.h"
/**
* con_log() - console log routine
* @param level : indicates the severity of the message.
* @fparam mt : format string
*
* con_log displays the error messages on the console based on the current
* debug level. Also it attaches the appropriate kernel severity level with
* the message.
*
*
* consolge messages debug levels
*/
#define CL_ANN 0 /* print unconditionally, announcements */
#define CL_DLEVEL1 1 /* debug level 1, informative */
#define CL_DLEVEL2 2 /* debug level 2, verbose */
#define CL_DLEVEL3 3 /* debug level 3, very verbose */
#define con_log(level, fmt) if (LSI_DBGLVL >= level) printk fmt;
/*
* Definitions & Declarations needed to use common management module
*/
#define MEGAIOC_MAGIC 'm'
#define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, mimd_t)
#define MEGAIOC_QNADAP 'm' /* Query # of adapters */
#define MEGAIOC_QDRVRVER 'e' /* Query driver version */
#define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
#define USCSICMD 0x80
#define UIOC_RD 0x00001
#define UIOC_WR 0x00002
#define MBOX_CMD 0x00000
#define GET_DRIVER_VER 0x10000
#define GET_N_ADAP 0x20000
#define GET_ADAP_INFO 0x30000
#define GET_CAP 0x40000
#define GET_STATS 0x50000
#define GET_IOCTL_VERSION 0x01
#define EXT_IOCTL_SIGN_SZ 16
#define EXT_IOCTL_SIGN "$$_EXTD_IOCTL_$$"
#define MBOX_LEGACY 0x00 /* ioctl has legacy mbox*/
#define MBOX_HPE 0x01 /* ioctl has hpe mbox */
#define APPTYPE_MIMD 0x00 /* old existing apps */
#define APPTYPE_UIOC 0x01 /* new apps using uioc */
#define IOCTL_ISSUE 0x00000001 /* Issue ioctl */
#define IOCTL_ABORT 0x00000002 /* Abort previous ioctl */
#define DRVRTYPE_MBOX 0x00000001 /* regular mbox driver */
#define DRVRTYPE_HPE 0x00000002 /* new hpe driver */
#define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | (adapno) )
#define GETADAP(mkadap) ((mkadap) ^ MEGAIOC_MAGIC << 8)
#define MAX_DMA_POOLS 5 /* 4k, 8k, 16k, 32k, 64k*/
/**
* struct uioc_t - the common ioctl packet structure
*
* @signature : Must be "$$_EXTD_IOCTL_$$"
* @mb_type : Type of the mail box (MB_LEGACY or MB_HPE)
* @app_type : Type of the issuing application (existing or new)
* @opcode : Opcode of the command
* @adapno : Adapter number
* @cmdbuf : Pointer to buffer - can point to mbox or plain data buffer
* @xferlen : xferlen for DCMD and non mailbox commands
* @data_dir : Direction of the data transfer
* @status : Status from the driver
* @reserved : reserved bytes for future expansion
*
* @user_data : user data transfer address is saved in this
* @user_data_len: length of the data buffer sent by user app
* @user_pthru : user passthru address is saves in this (null if DCMD)
* @pthru32 : kernel address passthru (allocated per kioc)
* @pthru32_h : physicall address of @pthru32
* @list : for kioc free pool list maintenance
* @done : call back routine for llds to call when kioc is completed
* @buf_vaddr : dma pool buffer attached to kioc for data transfer
* @buf_paddr : physical address of the dma pool buffer
* @pool_index : index of the dma pool that @buf_vaddr is taken from
* @free_buf : indicates if buffer needs to be freed after kioc completes
*
* Note : All LSI drivers understand only this packet. Any other
* : format sent by applications would be converted to this.
*/
typedef struct uioc {
/* User Apps: */
uint8_t signature[EXT_IOCTL_SIGN_SZ];
uint16_t mb_type;
uint16_t app_type;
uint32_t opcode;
uint32_t adapno;
uint64_t cmdbuf;
uint32_t xferlen;
uint32_t data_dir;
int32_t status;
uint8_t reserved[128];
/* Driver Data: */
void __user * user_data;
uint32_t user_data_len;
/* 64bit alignment */
uint32_t pad_for_64bit_align;
mraid_passthru_t __user *user_pthru;
mraid_passthru_t *pthru32;
dma_addr_t pthru32_h;
struct list_head list;
void (*done)(struct uioc*);
caddr_t buf_vaddr;
dma_addr_t buf_paddr;
int8_t pool_index;
uint8_t free_buf;
uint8_t timedout;
} __attribute__ ((aligned(1024),packed)) uioc_t;
/**
* struct mraid_hba_info - information about the controller
*
* @param pci_vendor_id : PCI vendor id
* @param pci_device_id : PCI device id
* @param subsystem_vendor_id : PCI subsystem vendor id
* @param subsystem_device_id : PCI subsystem device id
* @param baseport : base port of hba memory
* @param pci_bus : PCI bus
* @param pci_dev_fn : PCI device/function values
* @param irq : interrupt vector for the device
*
* Extended information of 256 bytes about the controller. Align on the single
* byte boundary so that 32-bit applications can be run on 64-bit platform
* drivers withoug re-compilation.
* NOTE: reduce the number of reserved bytes whenever new field are added, so
* that total size of the structure remains 256 bytes.
*/
typedef struct mraid_hba_info {
uint16_t pci_vendor_id;
uint16_t pci_device_id;
uint16_t subsys_vendor_id;
uint16_t subsys_device_id;
uint64_t baseport;
uint8_t pci_bus;
uint8_t pci_dev_fn;
uint8_t pci_slot;
uint8_t irq;
uint32_t unique_id;
uint32_t host_no;
uint8_t num_ldrv;
} __attribute__ ((aligned(256), packed)) mraid_hba_info_t;
/**
* mcontroller : adapter info structure for old mimd_t apps
*
* @base : base address
* @irq : irq number
* @numldrv : number of logical drives
* @pcibus : pci bus
* @pcidev : pci device
* @pcifun : pci function
* @pciid : pci id
* @pcivendor : vendor id
* @pcislot : slot number
* @uid : unique id
*/
typedef struct mcontroller {
uint64_t base;
uint8_t irq;
uint8_t numldrv;
uint8_t pcibus;
uint16_t pcidev;
uint8_t pcifun;
uint16_t pciid;
uint16_t pcivendor;
uint8_t pcislot;
uint32_t uid;
} __attribute__ ((packed)) mcontroller_t;
/**
* mm_dmapool_t : Represents one dma pool with just one buffer
*
* @vaddr : Virtual address
* @paddr : DMA physicall address
* @bufsize : In KB - 4 = 4k, 8 = 8k etc.
* @handle : Handle to the dma pool
* @lock : lock to synchronize access to the pool
* @in_use : If pool already in use, attach new block
*/
typedef struct mm_dmapool {
caddr_t vaddr;
dma_addr_t paddr;
uint32_t buf_size;
struct dma_pool *handle;
spinlock_t lock;
uint8_t in_use;
} mm_dmapool_t;
/**
* mraid_mmadp_t: Structure that drivers pass during (un)registration
*
* @unique_id : Any unique id (usually PCI bus+dev+fn)
* @drvr_type : megaraid or hpe (DRVRTYPE_MBOX or DRVRTYPE_HPE)
* @drv_data : Driver specific; not touched by the common module
* @timeout : timeout for issued kiocs
* @max_kioc : Maximum ioctl packets acceptable by the lld
* @pdev : pci dev; used for allocating dma'ble memory
* @issue_uioc : Driver supplied routine to issue uioc_t commands
* : issue_uioc(drvr_data, kioc, ISSUE/ABORT, uioc_done)
* @quiescent : flag to indicate if ioctl can be issued to this adp
* @list : attach with the global list of adapters
* @kioc_list : block of mem for @max_kioc number of kiocs
* @kioc_pool : pool of free kiocs
* @kioc_pool_lock : protection for free pool
* @kioc_semaphore : so as not to exceed @max_kioc parallel ioctls
* @mbox_list : block of mem for @max_kioc number of mboxes
* @pthru_dma_pool : DMA pool to allocate passthru packets
* @dma_pool_list : array of dma pools
*/
typedef struct mraid_mmadp {
/* Filled by driver */
uint32_t unique_id;
uint32_t drvr_type;
unsigned long drvr_data;
uint16_t timeout;
uint8_t max_kioc;
struct pci_dev *pdev;
int(*issue_uioc)(unsigned long, uioc_t *, uint32_t);
/* Maintained by common module */
uint32_t quiescent;
struct list_head list;
uioc_t *kioc_list;
struct list_head kioc_pool;
spinlock_t kioc_pool_lock;
struct semaphore kioc_semaphore;
mbox64_t *mbox_list;
struct dma_pool *pthru_dma_pool;
mm_dmapool_t dma_pool_list[MAX_DMA_POOLS];
} mraid_mmadp_t;
int mraid_mm_register_adp(mraid_mmadp_t *);
int mraid_mm_unregister_adp(uint32_t);
uint32_t mraid_mm_adapter_app_handle(uint32_t);
#endif /* _MEGARAID_IOCTL_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,237 @@
/*
*
* Linux MegaRAID device driver
*
* Copyright (c) 2003-2004 LSI Logic Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_mbox.h
*/
#ifndef _MEGARAID_H_
#define _MEGARAID_H_
#include "mega_common.h"
#include "mbox_defs.h"
#include "megaraid_ioctl.h"
#define MEGARAID_VERSION "2.20.4.6-rh2"
#define MEGARAID_EXT_VERSION "(Release Date: Wed Jun 28 12:27:22 EST 2006)"
/*
* Define some PCI values here until they are put in the kernel
*/
#define PCI_DEVICE_ID_PERC4_DI_DISCOVERY 0x000E
#define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY 0x0123
#define PCI_DEVICE_ID_PERC4_SC 0x1960
#define PCI_SUBSYS_ID_PERC4_SC 0x0520
#define PCI_DEVICE_ID_PERC4_DC 0x1960
#define PCI_SUBSYS_ID_PERC4_DC 0x0518
#define PCI_DEVICE_ID_VERDE 0x0407
#define PCI_DEVICE_ID_PERC4_DI_EVERGLADES 0x000F
#define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES 0x014A
#define PCI_DEVICE_ID_PERC4E_SI_BIGBEND 0x0013
#define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND 0x016c
#define PCI_DEVICE_ID_PERC4E_DI_KOBUK 0x0013
#define PCI_SUBSYS_ID_PERC4E_DI_KOBUK 0x016d
#define PCI_DEVICE_ID_PERC4E_DI_CORVETTE 0x0013
#define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE 0x016e
#define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION 0x0013
#define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION 0x016f
#define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE 0x0013
#define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE 0x0170
#define PCI_DEVICE_ID_DOBSON 0x0408
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_0 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0 0xA520
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_1 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1 0x0520
#define PCI_DEVICE_ID_MEGARAID_SCSI_320_2 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2 0x0518
#define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960
#define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522
#define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523
#define PCI_DEVICE_ID_MEGARAID_SATA_150_6 0x1960
#define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523
#define PCI_DEVICE_ID_LINDSAY 0x0409
#define PCI_DEVICE_ID_INTEL_RAID_SRCS16 0x1960
#define PCI_SUBSYS_ID_INTEL_RAID_SRCS16 0x0523
#define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x1960
#define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x0520
#define PCI_SUBSYS_ID_PERC3_QC 0x0471
#define PCI_SUBSYS_ID_PERC3_DC 0x0493
#define PCI_SUBSYS_ID_PERC3_SC 0x0475
#define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel
#define MBOX_MAX_USER_CMDS 32 // number of cmds for applications
#define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun
#define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw
#define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size
#define MBOX_MAX_SECTORS 128 // maximum sectors per IO
#define MBOX_TIMEOUT 30 // timeout value for internal cmds
#define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox
#define MBOX_RESET_WAIT 180 // wait these many seconds in reset
#define MBOX_RESET_EXT_WAIT 120 // extended wait reset
#define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode
#define MBOX_SYNC_DELAY_200 200 // 200 micro-secondes
/*
* maximum transfer that can happen through the firmware commands issued
* internnaly from the driver.
*/
#define MBOX_IBUF_SIZE 4096
/**
* mbox_ccb_t - command control block specific to mailbox based controllers
* @raw_mbox : raw mailbox pointer
* @mbox : mailbox
* @mbox64 : extended mailbox
* @mbox_dma_h : maibox dma address
* @sgl64 : 64-bit scatter-gather list
* @sgl32 : 32-bit scatter-gather list
* @sgl_dma_h : dma handle for the scatter-gather list
* @pthru : passthru structure
* @pthru_dma_h : dma handle for the passthru structure
* @epthru : extended passthru structure
* @epthru_dma_h : dma handle for extended passthru structure
* @buf_dma_h : dma handle for buffers w/o sg list
*
* command control block specific to the mailbox based controllers
*/
typedef struct {
uint8_t *raw_mbox;
mbox_t *mbox;
mbox64_t *mbox64;
dma_addr_t mbox_dma_h;
mbox_sgl64 *sgl64;
mbox_sgl32 *sgl32;
dma_addr_t sgl_dma_h;
mraid_passthru_t *pthru;
dma_addr_t pthru_dma_h;
mraid_epassthru_t *epthru;
dma_addr_t epthru_dma_h;
dma_addr_t buf_dma_h;
} mbox_ccb_t;
/**
* mraid_device_t - adapter soft state structure for mailbox controllers
* @param una_mbox64 : 64-bit mbox - unaligned
* @param una_mbox64_dma : mbox dma addr - unaligned
* @param mbox : 32-bit mbox - aligned
* @param mbox64 : 64-bit mbox - aligned
* @param mbox_dma : mbox dma addr - aligned
* @param mailbox_lock : exclusion lock for the mailbox
* @param baseport : base port of hba memory
* @param baseaddr : mapped addr of hba memory
* @param mbox_pool : pool of mailboxes
* @param mbox_pool_handle : handle for the mailbox pool memory
* @param epthru_pool : a pool for extended passthru commands
* @param epthru_pool_handle : handle to the pool above
* @param sg_pool : pool of scatter-gather lists for this driver
* @param sg_pool_handle : handle to the pool above
* @param ccb_list : list of our command control blocks
* @param uccb_list : list of cmd control blocks for mgmt module
* @param umbox64 : array of mailbox for user commands (cmm)
* @param pdrv_state : array for state of each physical drive.
* @param last_disp : flag used to show device scanning
* @param hw_error : set if FW not responding
* @param fast_load : If set, skip physical device scanning
* @channel_class : channel class, RAID or SCSI
* @sysfs_sem : semaphore to serialize access to sysfs res.
* @sysfs_uioc : management packet to issue FW calls from sysfs
* @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs
* @sysfs_buffer : data buffer for FW commands issued from sysfs
* @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs
* @sysfs_wait_q : wait queue for sysfs operations
* @random_del_supported : set if the random deletion is supported
* @curr_ldmap : current LDID map
*
* Initialization structure for mailbox controllers: memory based and IO based
* All the fields in this structure are LLD specific and may be discovered at
* init() or start() time.
*
* NOTE: The fields of this structures are placed to minimize cache misses
*/
#define MAX_LD_EXTENDED64 64
typedef struct {
mbox64_t *una_mbox64;
dma_addr_t una_mbox64_dma;
mbox_t *mbox;
mbox64_t *mbox64;
dma_addr_t mbox_dma;
spinlock_t mailbox_lock;
unsigned long baseport;
void __iomem * baseaddr;
struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS];
struct dma_pool *mbox_pool_handle;
struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS];
struct dma_pool *epthru_pool_handle;
struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS];
struct dma_pool *sg_pool_handle;
mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS];
mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS];
mbox64_t umbox64[MBOX_MAX_USER_CMDS];
uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
uint32_t last_disp;
int hw_error;
int fast_load;
uint8_t channel_class;
struct semaphore sysfs_sem;
uioc_t *sysfs_uioc;
mbox64_t *sysfs_mbox64;
caddr_t sysfs_buffer;
dma_addr_t sysfs_buffer_dma;
wait_queue_head_t sysfs_wait_q;
int random_del_supported;
uint16_t curr_ldmap[MAX_LD_EXTENDED64];
} mraid_device_t;
// route to raid device from adapter
#define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device))
#define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock)
// Find out if this channel is a RAID or SCSI
#define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01)
#define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20)
#define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C)
#define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20)
#define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C)
#endif // _MEGARAID_H_
// vim: set ts=8 sw=8 tw=78:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,105 @@
/*
*
* Linux MegaRAID device driver
*
* Copyright (c) 2003-2004 LSI Logic Corporation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_mm.h
*/
#ifndef MEGARAID_MM_H
#define MEGARAID_MM_H
#include <linux/spinlock.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/moduleparam.h>
#include <linux/pci.h>
#include <linux/list.h>
#include <linux/ioctl32.h>
#include <linux/diskdump.h>
#include <scsi/scsi_device.h>
#include "mbox_defs.h"
#include "megaraid_ioctl.h"
#define LSI_COMMON_MOD_VERSION "2.20.2.6rh"
#define LSI_COMMON_MOD_EXT_VERSION \
"(Release Date: Tue Jan 16 12:35:06 PST 2007)"
#define LSI_DBGLVL dbglevel
// The smallest dma pool
#define MRAID_MM_INIT_BUFF_SIZE 4096
/**
* mimd_t : Old style ioctl packet structure (deprecated)
*
* @inlen :
* @outlen :
* @fca :
* @opcode :
* @subopcode :
* @adapno :
* @buffer :
* @pad :
* @length :
* @mbox :
* @pthru :
* @data :
* @pad :
*
* Note : This structure is DEPRECATED. New applications must use
* : uioc_t structure instead. All new hba drivers use the new
* : format. If we get this mimd packet, we will convert it into
* : new uioc_t format and send it to the hba drivers.
*/
typedef struct mimd {
uint32_t inlen;
uint32_t outlen;
union {
uint8_t fca[16];
struct {
uint8_t opcode;
uint8_t subopcode;
uint16_t adapno;
#if BITS_PER_LONG == 32
uint8_t __user *buffer;
uint8_t pad[4];
#endif
#if BITS_PER_LONG == 64
uint8_t __user *buffer;
#endif
uint32_t length;
} __attribute__ ((packed)) fcs;
} __attribute__ ((packed)) ui;
uint8_t mbox[18]; /* 16 bytes + 2 status bytes */
mraid_passthru_t pthru;
#if BITS_PER_LONG == 32
char __user *data; /* buffer <= 4096 for 0x80 commands */
char pad[4];
#endif
#if BITS_PER_LONG == 64
char __user *data;
#endif
} __attribute__ ((packed))mimd_t;
#endif // MEGARAID_MM_H
// vi: set ts=8 sw=8 tw=78:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff