Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
megaraid_sas_fusion.c File Reference
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/list.h>
#include <linux/moduleparam.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/uio.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <linux/compat.h>
#include <linux/blkdev.h>
#include <linux/mutex.h>
#include <linux/poll.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_host.h>
#include "megaraid_sas_fusion.h"
#include "megaraid_sas.h"

Go to the source code of this file.

Functions

void megasas_free_cmds (struct megasas_instance *instance)
 
struct megasas_cmdmegasas_get_cmd (struct megasas_instance *instance)
 
void megasas_complete_cmd (struct megasas_instance *instance, struct megasas_cmd *cmd, u8 alt_status)
 
int megasas_is_ldio (struct scsi_cmnd *cmd)
 
int wait_and_poll (struct megasas_instance *instance, struct megasas_cmd *cmd)
 
void megasas_return_cmd (struct megasas_instance *instance, struct megasas_cmd *cmd)
 
int megasas_alloc_cmds (struct megasas_instance *instance)
 
int megasas_clear_intr_fusion (struct megasas_register_set __iomem *regs)
 
int megasas_issue_polled (struct megasas_instance *instance, struct megasas_cmd *cmd)
 
u8 MR_BuildRaidContext (struct megasas_instance *instance, struct IO_REQUEST_INFO *io_info, struct RAID_CONTEXT *pRAID_Context, struct MR_FW_RAID_MAP_ALL *map)
 
u16 MR_TargetIdToLdGet (u32 ldTgtId, struct MR_FW_RAID_MAP_ALL *map)
 
struct MR_LD_RAIDMR_LdRaidGet (u32 ld, struct MR_FW_RAID_MAP_ALL *map)
 
u16 MR_GetLDTgtId (u32 ld, struct MR_FW_RAID_MAP_ALL *map)
 
void megasas_check_and_restore_queue_depth (struct megasas_instance *instance)
 
u8 MR_ValidateMapInfo (struct MR_FW_RAID_MAP_ALL *map, struct LD_LOAD_BALANCE_INFO *lbInfo)
 
u16 get_updated_dev_handle (struct LD_LOAD_BALANCE_INFO *lbInfo, struct IO_REQUEST_INFO *in_info)
 
int megasas_transition_to_ready (struct megasas_instance *instance, int ocr)
 
void megaraid_sas_kill_hba (struct megasas_instance *instance)
 
void megasas_enable_intr_fusion (struct megasas_register_set __iomem *regs)
 
void megasas_disable_intr_fusion (struct megasas_register_set __iomem *regs)
 
struct megasas_cmd_fusionmegasas_get_cmd_fusion (struct megasas_instance *instance)
 
void megasas_free_cmds_fusion (struct megasas_instance *instance)
 
int megasas_alloc_cmds_fusion (struct megasas_instance *instance)
 
int megasas_ioc_init_fusion (struct megasas_instance *instance)
 
u8 megasas_get_map_info (struct megasas_instance *instance)
 
int megasas_sync_map_info (struct megasas_instance *instance)
 
u32 megasas_init_adapter_fusion (struct megasas_instance *instance)
 
void megasas_fire_cmd_fusion (struct megasas_instance *instance, dma_addr_t req_desc_lo, u32 req_desc_hi, struct megasas_register_set __iomem *regs)
 
void map_cmd_status (struct megasas_cmd_fusion *cmd, u8 status, u8 ext_status)
 
void megasas_set_pd_lba (struct MPI2_RAID_SCSI_IO_REQUEST *io_request, u8 cdb_len, struct IO_REQUEST_INFO *io_info, struct scsi_cmnd *scp, struct MR_FW_RAID_MAP_ALL *local_map_ptr, u32 ref_tag)
 
void megasas_build_ldio_fusion (struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_cmd_fusion *cmd)
 
int megasas_build_io_fusion (struct megasas_instance *instance, struct scsi_cmnd *scp, struct megasas_cmd_fusion *cmd)
 
union
MEGASAS_REQUEST_DESCRIPTOR_UNION
megasas_get_request_descriptor (struct megasas_instance *instance, u16 index)
 
int complete_cmd_fusion (struct megasas_instance *instance, u32 MSIxIndex)
 
void megasas_complete_cmd_dpc_fusion (unsigned long instance_addr)
 
irqreturn_t megasas_isr_fusion (int irq, void *devp)
 
u8 build_mpt_mfi_pass_thru (struct megasas_instance *instance, struct megasas_cmd *mfi_cmd)
 
union
MEGASAS_REQUEST_DESCRIPTOR_UNION
build_mpt_cmd (struct megasas_instance *instance, struct megasas_cmd *cmd)
 
void megasas_issue_dcmd_fusion (struct megasas_instance *instance, struct megasas_cmd *cmd)
 
void megasas_release_fusion (struct megasas_instance *instance)
 
int megasas_wait_for_outstanding_fusion (struct megasas_instance *instance)
 
void megasas_reset_reply_desc (struct megasas_instance *instance)
 
int megasas_reset_fusion (struct Scsi_Host *shost)
 
void megasas_fusion_ocr_wq (struct work_struct *work)
 

Variables

u32 megasas_dbg_lvl
 
int resetwaittime
 
struct megasas_instance_template megasas_instance_template_fusion
 

Function Documentation

union MEGASAS_REQUEST_DESCRIPTOR_UNION* build_mpt_cmd ( struct megasas_instance instance,
struct megasas_cmd cmd 
)
write

build_mpt_cmd - Calls helper function to build a cmd MFI Pass thru cmd : Adapter soft state : mfi cmd to build

Definition at line 1963 of file megaraid_sas_fusion.c.

u8 build_mpt_mfi_pass_thru ( struct megasas_instance instance,
struct megasas_cmd mfi_cmd 
)

build_mpt_mfi_pass_thru - builds a cmd fo MFI Pass thru : Adapter soft state mfi_cmd: megasas_cmd pointer

Definition at line 1901 of file megaraid_sas_fusion.c.

int complete_cmd_fusion ( struct megasas_instance instance,
u32  MSIxIndex 
)

complete_cmd_fusion - Completes command : Adapter soft state Completes all commands that is in reply descriptor queue

Definition at line 1702 of file megaraid_sas_fusion.c.

u16 get_updated_dev_handle ( struct LD_LOAD_BALANCE_INFO lbInfo,
struct IO_REQUEST_INFO in_info 
)

Definition at line 516 of file megaraid_sas_fp.c.

void map_cmd_status ( struct megasas_cmd_fusion cmd,
u8  status,
u8  ext_status 
)

map_cmd_status - Maps FW cmd status to OS cmd status : Pointer to cmd : status of cmd returned by FW : ext status of cmd returned by FW

Definition at line 1013 of file megaraid_sas_fusion.c.

void megaraid_sas_kill_hba ( struct megasas_instance instance)

Definition at line 1589 of file megaraid_sas_base.c.

int megasas_alloc_cmds ( struct megasas_instance instance)

megasas_alloc_cmds - Allocates the command packets : Adapter soft state

Each command that is issued to the FW, whether IO commands from the OS or internal commands like IOCTLs, are wrapped in local data structure called megasas_cmd. The frame embedded in this megasas_cmd is actually issued to the FW.

Each frame has a 32-bit field called context (tag). This context is used to get back the megasas_cmd from the frame when a frame gets completed in the ISR. Typically the address of the megasas_cmd itself would be used as the context. But we wanted to keep the differences between 32 and 64 bit systems to the mininum. We always use 32 bit integers for the context. In this driver, the 32 bit values are the indices into an array cmd_list. This array is used only to look up the megasas_cmd given the context. The free commands themselves are maintained in a linked list called cmd_pool.

Definition at line 3000 of file megaraid_sas_base.c.

int megasas_alloc_cmds_fusion ( struct megasas_instance instance)

megasas_alloc_cmds_fusion - Allocates the command packets : Adapter soft state

Each frame has a 32-bit field called context. This context is used to get back the megasas_cmd_fusion from the frame when a frame gets completed In this driver, the 32 bit values are the indices into an array cmd_list. This array is used only to look up the megasas_cmd_fusion given the context. The free commands themselves are maintained in a linked list called cmd_pool.

cmds are formed in the io_request and sg_frame members of the megasas_cmd_fusion. The context field is used to get a request descriptor and is used as SMID of the cmd. SMID value range is from 1 to max_fw_cmds.

Definition at line 387 of file megaraid_sas_fusion.c.

int megasas_build_io_fusion ( struct megasas_instance instance,
struct scsi_cmnd scp,
struct megasas_cmd_fusion cmd 
)

megasas_build_io_fusion - Prepares IOs to devices : Adapter soft state : SCSI command : Command to be prepared

Invokes helper functions to prepare request frames and sets flags appropriate for IO/Non-IO cmd

Definition at line 1551 of file megaraid_sas_fusion.c.

void megasas_build_ldio_fusion ( struct megasas_instance instance,
struct scsi_cmnd scp,
struct megasas_cmd_fusion cmd 
)

megasas_build_ldio_fusion - Prepares IOs to devices : Adapter soft state : SCSI command : Command to be prepared

Prepares the io_request and chain elements (sg_frame) for IO The IO can be for PD (Fast Path) or LD

Definition at line 1325 of file megaraid_sas_fusion.c.

void megasas_check_and_restore_queue_depth ( struct megasas_instance instance)

megasas_check_and_restore_queue_depth - Check if queue depth needs to be restored to max value : Adapter soft state

Definition at line 1608 of file megaraid_sas_base.c.

int megasas_clear_intr_fusion ( struct megasas_register_set __iomem regs)

Definition at line 132 of file megaraid_sas_fusion.c.

void megasas_complete_cmd ( struct megasas_instance instance,
struct megasas_cmd cmd,
u8  alt_status 
)

megasas_complete_cmd - Completes a command : Adapter soft state : Command to be completed : If non-zero, use this value as status to SCSI mid-layer instead of the value returned by the FW. This should be used if caller wants an alternate status (as in the case of aborted commands)

Definition at line 2158 of file megaraid_sas_base.c.

void megasas_complete_cmd_dpc_fusion ( unsigned long  instance_addr)

megasas_complete_cmd_dpc_fusion - Completes command : Adapter soft state

Tasklet to complete cmds

Definition at line 1840 of file megaraid_sas_fusion.c.

void megasas_disable_intr_fusion ( struct megasas_register_set __iomem regs)

megasas_disable_intr_fusion - Disables interrupt : MFI register set

Definition at line 121 of file megaraid_sas_fusion.c.

void megasas_enable_intr_fusion ( struct megasas_register_set __iomem regs)

megasas_enable_intr_fusion - Enables interrupts : MFI register set

Definition at line 104 of file megaraid_sas_fusion.c.

void megasas_fire_cmd_fusion ( struct megasas_instance instance,
dma_addr_t  req_desc_lo,
u32  req_desc_hi,
struct megasas_register_set __iomem regs 
)

megasas_fire_cmd_fusion - Sends command to the FW : Physical address of cmd : Number of frames for the command : MFI register set

Definition at line 990 of file megaraid_sas_fusion.c.

void megasas_free_cmds ( struct megasas_instance instance)

megasas_free_cmds - Free all the cmds in the free cmd pool : Adapter soft state

Definition at line 2964 of file megaraid_sas_base.c.

void megasas_free_cmds_fusion ( struct megasas_instance instance)

megasas_free_cmds_fusion - Free all the cmds in the free cmd pool : Adapter soft state

Definition at line 253 of file megaraid_sas_fusion.c.

void megasas_fusion_ocr_wq ( struct work_struct work)

Definition at line 2330 of file megaraid_sas_fusion.c.

struct megasas_cmd* megasas_get_cmd ( struct megasas_instance instance)
read

megasas_get_cmd - Get a command from the free pool : Adapter soft state

Returns a free command from the pool

Definition at line 190 of file megaraid_sas_base.c.

struct megasas_cmd_fusion* megasas_get_cmd_fusion ( struct megasas_instance instance)
read

megasas_get_cmd_fusion - Get a command from the free pool : Adapter soft state

Returns a free command from the pool

Definition at line 157 of file megaraid_sas_fusion.c.

u8 megasas_get_map_info ( struct megasas_instance instance)

Definition at line 767 of file megaraid_sas_fusion.c.

union MEGASAS_REQUEST_DESCRIPTOR_UNION* megasas_get_request_descriptor ( struct megasas_instance instance,
u16  index 
)
write

Definition at line 1622 of file megaraid_sas_fusion.c.

u32 megasas_init_adapter_fusion ( struct megasas_instance instance)

megasas_init_adapter_fusion - Initializes the FW : Adapter soft state

This is the main function for initializing firmware.

Definition at line 874 of file megaraid_sas_fusion.c.

int megasas_ioc_init_fusion ( struct megasas_instance instance)

megasas_ioc_init_fusion - Initializes the FW : Adapter soft state

Issues the IOC Init cmd

Definition at line 587 of file megaraid_sas_fusion.c.

int megasas_is_ldio ( struct scsi_cmnd cmd)
inline

megasas_is_ldio - Checks if the cmd is for logical drive : SCSI command

Called by megasas_queue_command to find out if the command to be queued is a logical drive command

Definition at line 1334 of file megaraid_sas_base.c.

irqreturn_t megasas_isr_fusion ( int  irq,
void devp 
)

megasas_isr_fusion - isr entry point

Definition at line 1864 of file megaraid_sas_fusion.c.

void megasas_issue_dcmd_fusion ( struct megasas_instance instance,
struct megasas_cmd cmd 
)

megasas_issue_dcmd_fusion - Issues a MFI Pass thru cmd : Adapter soft state : mfi cmd pointer

Definition at line 1996 of file megaraid_sas_fusion.c.

int megasas_issue_polled ( struct megasas_instance instance,
struct megasas_cmd cmd 
)

megasas_issue_polled - Issues a polling command : Adapter soft state : Command packet to be issued

For polling, MFI requires the cmd_status to be set to 0xFF before posting.

Definition at line 860 of file megaraid_sas_base.c.

void megasas_release_fusion ( struct megasas_instance instance)

megasas_release_fusion - Reverses the FW initialization : Adapter soft state

Definition at line 2015 of file megaraid_sas_fusion.c.

int megasas_reset_fusion ( struct Scsi_Host shost)

Definition at line 2112 of file megaraid_sas_fusion.c.

void megasas_reset_reply_desc ( struct megasas_instance instance)

Definition at line 2096 of file megaraid_sas_fusion.c.

void megasas_return_cmd ( struct megasas_instance instance,
struct megasas_cmd cmd 
)
inline

megasas_return_cmd - Return a cmd to free command pool : Adapter soft state : Command packet to be returned to free command pool

Definition at line 216 of file megaraid_sas_base.c.

void megasas_set_pd_lba ( struct MPI2_RAID_SCSI_IO_REQUEST io_request,
u8  cdb_len,
struct IO_REQUEST_INFO io_info,
struct scsi_cmnd scp,
struct MR_FW_RAID_MAP_ALL local_map_ptr,
u32  ref_tag 
)

megasas_set_pd_lba - Sets PD LBA : CDB : cdb length : Start block of IO

Used to set the PD LBA in CDB for FP IOs

Definition at line 1148 of file megaraid_sas_fusion.c.

int megasas_sync_map_info ( struct megasas_instance instance)

Definition at line 791 of file megaraid_sas_fusion.c.

int megasas_transition_to_ready ( struct megasas_instance instance,
int  ocr 
)

megasas_transition_to_ready - Move the FW to READY state : Adapter soft state

During the initialization, FW passes can potentially be in any one of several possible states. If the FW in operational, waiting-for-handshake states, driver must take steps to bring it to ready state. Otherwise, it has to wait for the ready state.

Definition at line 2636 of file megaraid_sas_base.c.

int megasas_wait_for_outstanding_fusion ( struct megasas_instance instance)

Definition at line 2058 of file megaraid_sas_fusion.c.

u8 MR_BuildRaidContext ( struct megasas_instance instance,
struct IO_REQUEST_INFO io_info,
struct RAID_CONTEXT pRAID_Context,
struct MR_FW_RAID_MAP_ALL map 
)

Definition at line 314 of file megaraid_sas_fp.c.

u16 MR_GetLDTgtId ( u32  ld,
struct MR_FW_RAID_MAP_ALL map 
)

Definition at line 132 of file megaraid_sas_fp.c.

struct MR_LD_RAID* MR_LdRaidGet ( u32  ld,
struct MR_FW_RAID_MAP_ALL map 
)
read

Definition at line 100 of file megaraid_sas_fp.c.

u16 MR_TargetIdToLdGet ( u32  ldTgtId,
struct MR_FW_RAID_MAP_ALL map 
)

Definition at line 137 of file megaraid_sas_fp.c.

u8 MR_ValidateMapInfo ( struct MR_FW_RAID_MAP_ALL map,
struct LD_LOAD_BALANCE_INFO lbInfo 
)

Definition at line 151 of file megaraid_sas_fp.c.

int wait_and_poll ( struct megasas_instance instance,
struct megasas_cmd cmd 
)

wait_and_poll - Issues a polling command : Adapter soft state : Command packet to be issued

For polling, MFI requires the cmd_status to be set to 0xFF before posting.

Definition at line 559 of file megaraid_sas_fusion.c.

Variable Documentation

u32 megasas_dbg_lvl

Definition at line 138 of file megaraid_sas_base.c.

struct megasas_instance_template megasas_instance_template_fusion
Initial value:
= {
.disable_intr = megasas_disable_intr_fusion,
.read_fw_status_reg = megasas_read_fw_status_reg_fusion,
.adp_reset = megasas_adp_reset_fusion,
.check_reset = megasas_check_reset_fusion,
.service_isr = megasas_isr_fusion,
.init_adapter = megasas_init_adapter_fusion,
.build_and_issue_cmd = megasas_build_and_issue_cmd_fusion,
}

This is the end of set of functions & definitions specific to gen2 (deviceid : 0x78, 0x79) controllers

Definition at line 2338 of file megaraid_sas_fusion.c.

int resetwaittime

Definition at line 83 of file megaraid_sas_base.c.