Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
mpt2sas_base.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/pci.h>
#include <linux/kdev_t.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/sort.h>
#include <linux/io.h>
#include <linux/time.h>
#include <linux/kthread.h>
#include <linux/aer.h>
#include "mpt2sas_base.h"

Go to the source code of this file.

Data Structures

union  reply_descriptor
 

Macros

#define FAULT_POLLING_INTERVAL   1000 /* in milliseconds */
 
#define MAX_HBA_QUEUE_DEPTH   30000
 
#define MAX_CHAIN_DEPTH   100000
 
#define convert_to_kb(x)   ((x) << (PAGE_SHIFT - 10))
 

Functions

 module_param (max_queue_depth, int, 0)
 
 MODULE_PARM_DESC (max_queue_depth," max controller queue depth ")
 
 module_param (max_sgl_entries, int, 0)
 
 MODULE_PARM_DESC (max_sgl_entries," max sg entries ")
 
 module_param (msix_disable, int, 0)
 
 MODULE_PARM_DESC (msix_disable," disable msix routed interrupts (default=0)")
 
 module_param_array (missing_delay, int, NULL, 0)
 
 MODULE_PARM_DESC (missing_delay," device missing delay , io missing delay")
 
 MODULE_PARM_DESC (mpt2sas_fwfault_debug," enable detection of firmware fault ""and halt firmware - (default=0)")
 
 module_param (disable_discovery, int, 0)
 
 MODULE_PARM_DESC (disable_discovery," disable discovery ")
 
 module_param_call (mpt2sas_fwfault_debug, _scsih_set_fwfault_debug, param_get_int,&mpt2sas_fwfault_debug, 0644)
 
void mpt2sas_base_start_watchdog (struct MPT2SAS_ADAPTER *ioc)
 
void mpt2sas_base_stop_watchdog (struct MPT2SAS_ADAPTER *ioc)
 
void mpt2sas_base_fault_info (struct MPT2SAS_ADAPTER *ioc, u16 fault_code)
 
void mpt2sas_halt_firmware (struct MPT2SAS_ADAPTER *ioc)
 
u8 mpt2sas_base_done (struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 
void mpt2sas_base_flush_reply_queues (struct MPT2SAS_ADAPTER *ioc)
 
void mpt2sas_base_release_callback_handler (u8 cb_idx)
 
u8 mpt2sas_base_register_callback_handler (MPT_CALLBACK cb_func)
 
void mpt2sas_base_initialize_callback_handler (void)
 
void mpt2sas_base_build_zero_len_sge (struct MPT2SAS_ADAPTER *ioc, void *paddr)
 
int mpt2sas_base_map_resources (struct MPT2SAS_ADAPTER *ioc)
 
voidmpt2sas_base_get_msg_frame (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
voidmpt2sas_base_get_sense_buffer (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
__le32 mpt2sas_base_get_sense_buffer_dma (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
voidmpt2sas_base_get_reply_virt_addr (struct MPT2SAS_ADAPTER *ioc, u32 phys_addr)
 
u16 mpt2sas_base_get_smid (struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
 
u16 mpt2sas_base_get_smid_scsiio (struct MPT2SAS_ADAPTER *ioc, u8 cb_idx, struct scsi_cmnd *scmd)
 
u16 mpt2sas_base_get_smid_hpr (struct MPT2SAS_ADAPTER *ioc, u8 cb_idx)
 
void mpt2sas_base_free_smid (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
void mpt2sas_base_put_smid_scsi_io (struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 handle)
 
void mpt2sas_base_put_smid_hi_priority (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
void mpt2sas_base_put_smid_default (struct MPT2SAS_ADAPTER *ioc, u16 smid)
 
void mpt2sas_base_put_smid_target_assist (struct MPT2SAS_ADAPTER *ioc, u16 smid, u16 io_index)
 
u32 mpt2sas_base_get_iocstate (struct MPT2SAS_ADAPTER *ioc, int cooked)
 
int mpt2sas_base_sas_iounit_control (struct MPT2SAS_ADAPTER *ioc, Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t *mpi_request)
 
int mpt2sas_base_scsi_enclosure_processor (struct MPT2SAS_ADAPTER *ioc, Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request)
 
u8 mpt2sas_port_enable_done (struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 
int mpt2sas_port_enable (struct MPT2SAS_ADAPTER *ioc)
 
void mpt2sas_base_validate_event_type (struct MPT2SAS_ADAPTER *ioc, u32 *event_type)
 
void mpt2sas_base_free_resources (struct MPT2SAS_ADAPTER *ioc)
 
int mpt2sas_base_attach (struct MPT2SAS_ADAPTER *ioc)
 
void mpt2sas_base_detach (struct MPT2SAS_ADAPTER *ioc)
 
int mpt2sas_base_hard_reset_handler (struct MPT2SAS_ADAPTER *ioc, int sleep_flag, enum reset_type type)
 

Macro Definition Documentation

#define convert_to_kb (   x)    ((x) << (PAGE_SHIFT - 10))

Definition at line 1154 of file mpt2sas_base.c.

#define FAULT_POLLING_INTERVAL   1000 /* in milliseconds */

Definition at line 67 of file mpt2sas_base.c.

#define MAX_CHAIN_DEPTH   100000

Definition at line 70 of file mpt2sas_base.c.

#define MAX_HBA_QUEUE_DEPTH   30000

Definition at line 69 of file mpt2sas_base.c.

Function Documentation

module_param ( max_queue_depth  ,
int  ,
 
)
module_param ( max_sgl_entries  ,
int  ,
 
)
module_param ( msix_disable  ,
int  ,
 
)
module_param ( disable_discovery  ,
int  ,
 
)
module_param_array ( missing_delay  ,
int  ,
NULL  ,
 
)
module_param_call ( mpt2sas_fwfault_debug  ,
_scsih_set_fwfault_debug  ,
param_get_int  ,
mpt2sas_fwfault_debug,
0644   
)
MODULE_PARM_DESC ( max_queue_depth  ,
" max controller queue depth  
)
MODULE_PARM_DESC ( max_sgl_entries  ,
" max sg entries  
)
MODULE_PARM_DESC ( msix_disable  ,
" disable msix routed interrupts (default=0)"   
)
MODULE_PARM_DESC ( missing_delay  ,
" device missing  delay,
io missing delay  
)
MODULE_PARM_DESC ( mpt2sas_fwfault_debug  ,
" enable detection of firmware fault ""and halt firmware - (default=0)"   
)
MODULE_PARM_DESC ( disable_discovery  ,
" disable discovery "   
)
int mpt2sas_base_attach ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_attach - attach controller instance : per adapter object

Returns 0 for success, non-zero for failure.

Definition at line 4226 of file mpt2sas_base.c.

void mpt2sas_base_build_zero_len_sge ( struct MPT2SAS_ADAPTER ioc,
void paddr 
)

mpt2sas_base_build_zero_len_sge - build zero length sg entry : per adapter object : virtual address for SGE

Create a zero length scatter gather entry to insure the IOCs hardware has something to use if the target device goes brain dead and tries to send data even when none is asked for.

Return nothing.

Definition at line 1106 of file mpt2sas_base.c.

void mpt2sas_base_detach ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_detach - remove controller instance : per adapter object

Return nothing.

Definition at line 4430 of file mpt2sas_base.c.

u8 mpt2sas_base_done ( struct MPT2SAS_ADAPTER ioc,
u16  smid,
u8  msix_index,
u32  reply 
)

mpt2sas_base_done - base internal command completion routine : per adapter object : system request message index : MSIX table index supplied by the OS : reply message frame(lower 32bit addr)

Return 1 meaning mf should be freed from _base_interrupt 0 means the mf is freed from this function.

Definition at line 730 of file mpt2sas_base.c.

void mpt2sas_base_fault_info ( struct MPT2SAS_ADAPTER ioc,
u16  fault_code 
)

mpt2sas_base_fault_info - verbose translation of firmware FAULT code : per adapter object : fault code

Return nothing.

Definition at line 282 of file mpt2sas_base.c.

void mpt2sas_base_flush_reply_queues ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_flush_reply_queues - flushing the MSIX reply queues : per adapter object Context: ISR conext

Called when a Task Management request has completed. We want to flush the other reply queues so all the outstanding IO has been completed back to OS before we process the TM completetion.

Return nothing.

Definition at line 1029 of file mpt2sas_base.c.

void mpt2sas_base_free_resources ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_free_resources - free resources controller resources (io/irq/memap) : per adapter object

Return nothing.

Definition at line 4197 of file mpt2sas_base.c.

void mpt2sas_base_free_smid ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_free_smid - put smid back on free_list : per adapter object : system request message index

Return nothing.

Definition at line 1717 of file mpt2sas_base.c.

u32 mpt2sas_base_get_iocstate ( struct MPT2SAS_ADAPTER ioc,
int  cooked 
)

mpt2sas_base_get_iocstate - Get the current state of a MPT adapter. : Pointer to MPT_ADAPTER structure : Request raw or cooked IOC state

Returns all IOC Doorbell register bits if cooked==0, else just the Doorbell bits in MPI_IOC_STATE_MASK.

Definition at line 2788 of file mpt2sas_base.c.

void* mpt2sas_base_get_msg_frame ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_get_msg_frame - obtain request mf pointer : per adapter object : system request message index(smid zero is invalid)

Returns virt pointer to message frame.

Definition at line 1567 of file mpt2sas_base.c.

void* mpt2sas_base_get_reply_virt_addr ( struct MPT2SAS_ADAPTER ioc,
u32  phys_addr 
)

mpt2sas_base_get_reply_virt_addr - obtain reply frames virt address : per adapter object : lower 32 physical addr of the reply

Converts 32bit lower physical addr into a virt address.

Definition at line 1607 of file mpt2sas_base.c.

void* mpt2sas_base_get_sense_buffer ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_get_sense_buffer - obtain a sense buffer assigned to a mf request : per adapter object : system request message index

Returns virt pointer to sense buffer.

Definition at line 1580 of file mpt2sas_base.c.

__le32 mpt2sas_base_get_sense_buffer_dma ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_get_sense_buffer_dma - obtain a sense buffer assigned to a mf request : per adapter object : system request message index

Returns phys pointer to the low 32bit address of the sense buffer.

Definition at line 1593 of file mpt2sas_base.c.

u16 mpt2sas_base_get_smid ( struct MPT2SAS_ADAPTER ioc,
u8  cb_idx 
)

mpt2sas_base_get_smid - obtain a free smid from internal queue : per adapter object : callback index

Returns smid (zero is invalid)

Definition at line 1622 of file mpt2sas_base.c.

u16 mpt2sas_base_get_smid_hpr ( struct MPT2SAS_ADAPTER ioc,
u8  cb_idx 
)

mpt2sas_base_get_smid_hpr - obtain a free smid from hi-priority queue : per adapter object : callback index

Returns smid (zero is invalid)

Definition at line 1687 of file mpt2sas_base.c.

u16 mpt2sas_base_get_smid_scsiio ( struct MPT2SAS_ADAPTER ioc,
u8  cb_idx,
struct scsi_cmnd scmd 
)

mpt2sas_base_get_smid_scsiio - obtain a free smid from scsiio queue : per adapter object : callback index : pointer to scsi command object

Returns smid (zero is invalid)

Definition at line 1654 of file mpt2sas_base.c.

int mpt2sas_base_hard_reset_handler ( struct MPT2SAS_ADAPTER ioc,
int  sleep_flag,
enum reset_type  type 
)

mpt2sas_base_hard_reset_handler - reset controller : Pointer to MPT_ADAPTER structure : CAN_SLEEP or NO_SLEEP : FORCE_BIG_HAMMER or SOFT_RESET

Returns 0 for success, non-zero for failure.

Definition at line 4565 of file mpt2sas_base.c.

void mpt2sas_base_initialize_callback_handler ( void  )

mpt2sas_base_initialize_callback_handler - initialize the interrupt callback handler

Return nothing.

Definition at line 1086 of file mpt2sas_base.c.

int mpt2sas_base_map_resources ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_map_resources - map in controller resources (io/irq/memap) : per adapter object

Returns 0 for success, non-zero for failure.

Definition at line 1463 of file mpt2sas_base.c.

void mpt2sas_base_put_smid_default ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_put_smid_default - Default, primarily used for config pages : per adapter object : system request message index

Return nothing.

Definition at line 1861 of file mpt2sas_base.c.

void mpt2sas_base_put_smid_hi_priority ( struct MPT2SAS_ADAPTER ioc,
u16  smid 
)

mpt2sas_base_put_smid_hi_priority - send Task Management request to firmware : per adapter object : system request message index

Return nothing.

Definition at line 1838 of file mpt2sas_base.c.

void mpt2sas_base_put_smid_scsi_io ( struct MPT2SAS_ADAPTER ioc,
u16  smid,
u16  handle 
)

mpt2sas_base_put_smid_scsi_io - send SCSI_IO request to firmware : per adapter object : system request message index : device handle

Return nothing.

Definition at line 1814 of file mpt2sas_base.c.

void mpt2sas_base_put_smid_target_assist ( struct MPT2SAS_ADAPTER ioc,
u16  smid,
u16  io_index 
)

mpt2sas_base_put_smid_target_assist - send Target Assist/Status to firmware : per adapter object : system request message index : value used to track the IO

Return nothing.

Definition at line 1884 of file mpt2sas_base.c.

u8 mpt2sas_base_register_callback_handler ( MPT_CALLBACK  cb_func)

mpt2sas_base_register_callback_handler - obtain index for the interrupt callback handler : callback function

Returns cb_func.

Definition at line 1068 of file mpt2sas_base.c.

void mpt2sas_base_release_callback_handler ( u8  cb_idx)

mpt2sas_base_release_callback_handler - clear interrupt callback handler : callback index

Return nothing.

Definition at line 1056 of file mpt2sas_base.c.

int mpt2sas_base_sas_iounit_control ( struct MPT2SAS_ADAPTER ioc,
Mpi2SasIoUnitControlReply_t mpi_reply,
Mpi2SasIoUnitControlRequest_t mpi_request 
)

mpt2sas_base_sas_iounit_control - send sas iounit control to FW : per adapter object : the reply payload from FW : the request payload sent to FW

The SAS IO Unit Control Request message allows the host to perform low-level operations, such as resets on the PHYs of the IO Unit, also allows the host to obtain the IOC assigned device handles for a device if it has other identifying information about the device, in addition allows the host to remove IOC resources associated with the device.

Returns 0 for success, non-zero for failure.

Definition at line 3139 of file mpt2sas_base.c.

int mpt2sas_base_scsi_enclosure_processor ( struct MPT2SAS_ADAPTER ioc,
Mpi2SepReply_t mpi_reply,
Mpi2SepRequest_t mpi_request 
)

mpt2sas_base_scsi_enclosure_processor - sending request to sep device : per adapter object : the reply payload from FW : the request payload sent to FW

The SCSI Enclosure Processor request message causes the IOC to communicate with SES devices to control LED status signals.

Returns 0 for success, non-zero for failure.

Definition at line 3245 of file mpt2sas_base.c.

void mpt2sas_base_start_watchdog ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_start_watchdog - start the fault_reset_work_q : per adapter object Context: sleep.

Return nothing.

Definition at line 224 of file mpt2sas_base.c.

void mpt2sas_base_stop_watchdog ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_base_stop_watchdog - stop the fault_reset_work_q : per adapter object Context: sleep.

Return nothing.

Definition at line 258 of file mpt2sas_base.c.

void mpt2sas_base_validate_event_type ( struct MPT2SAS_ADAPTER ioc,
u32 event_type 
)

mpt2sas_base_validate_event_type - validating event types : per adapter object : firmware event

This will turn on firmware event notification when application ask for that event. We don't mask events that are already enabled.

Definition at line 3834 of file mpt2sas_base.c.

void mpt2sas_halt_firmware ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_halt_firmware - halt's mpt controller firmware : per adapter object

For debugging timeout related issues. Writing 0xCOFFEE00 to the doorbell register will halt controller firmware. With the purpose to stop both driver and firmware, the enduser can obtain a ring buffer from controller UART.

Definition at line 298 of file mpt2sas_base.c.

int mpt2sas_port_enable ( struct MPT2SAS_ADAPTER ioc)

mpt2sas_port_enable - initiate firmware discovery (don't wait for reply) : per adapter object

Returns 0 for success, non-zero for failure.

Definition at line 3659 of file mpt2sas_base.c.

u8 mpt2sas_port_enable_done ( struct MPT2SAS_ADAPTER ioc,
u16  smid,
u8  msix_index,
u32  reply 
)

mpt2sas_port_enable_done - command completion routine for port enable : per adapter object : system request message index : MSIX table index supplied by the OS : reply message frame(lower 32bit addr)

Return 1 meaning mf should be freed from _base_interrupt 0 means the mf is freed from this function.

Definition at line 3542 of file mpt2sas_base.c.