Message-based devices

Fusion message devices

u8mpt_register(MPT_CALLBACKcbfunc,MPT_DRIVER_CLASSdclass,char*func_name)

Register protocol-specific main callback handler.

Parameters

MPT_CALLBACKcbfunc

callback function pointer

MPT_DRIVER_CLASSdclass

Protocol driver’s class (MPT_DRIVER_CLASSenumvalue)

char*func_name

call function’s name

Description

This routine is called by a protocol-specific driver (SCSI host,LAN, SCSI target) to register its reply callback routine. Eachprotocol-specific driver must do this before it will be able touse any IOC resources, such as obtaining request frames.

NOTES

The SCSI protocol driver currently calls this routine thrice

in order to register separate callbacks; one for “normal” SCSI IO;one for MptScsiTaskMgmt requests; one for Scan/DV requests.

Returns u8 valued “handle” in the range (and S.O.D. order){N,...,7,6,5,...,1} if successful.A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should beconsidered an error by the caller.

voidmpt_deregister(u8cb_idx)

Deregister a protocol drivers resources.

Parameters

u8cb_idx

previously registered callback handle

Description

Each protocol-specific driver should call this routine when itsmodule is unloaded.

intmpt_event_register(u8cb_idx,MPT_EVHANDLERev_cbfunc)

Register protocol-specific event callback handler.

Parameters

u8cb_idx

previously registered (via mpt_register) callback handle

MPT_EVHANDLERev_cbfunc

callback function

Description

This routine can be called by one or more protocol-specific driversif/when they choose to be notified of MPT events.

Returns 0 for success.

voidmpt_event_deregister(u8cb_idx)

Deregister protocol-specific event callback handler

Parameters

u8cb_idx

previously registered callback handle

Description

Each protocol-specific driver should call this routinewhen it does not (or can no longer) handle events,or when its module is unloaded.

intmpt_reset_register(u8cb_idx,MPT_RESETHANDLERreset_func)

Register protocol-specific IOC reset handler.

Parameters

u8cb_idx

previously registered (via mpt_register) callback handle

MPT_RESETHANDLERreset_func

reset function

Description

This routine can be called by one or more protocol-specific driversif/when they choose to be notified of IOC resets.

Returns 0 for success.

voidmpt_reset_deregister(u8cb_idx)

Deregister protocol-specific IOC reset handler.

Parameters

u8cb_idx

previously registered callback handle

Description

Each protocol-specific driver should call this routinewhen it does not (or can no longer) handle IOC reset handling,or when its module is unloaded.

intmpt_device_driver_register(structmpt_pci_driver*dd_cbfunc,u8cb_idx)

Register device driver hooks

Parameters

structmpt_pci_driver*dd_cbfunc

driver callbacks struct

u8cb_idx

MPT protocol driver index

voidmpt_device_driver_deregister(u8cb_idx)

DeRegister device driver hooks

Parameters

u8cb_idx

MPT protocol driver index

MPT_FRAME_HDR*mpt_get_msg_frame(u8cb_idx,MPT_ADAPTER*ioc)

Obtain an MPT request frame from the pool

Parameters

u8cb_idx

Handle of registered MPT protocol driver

MPT_ADAPTER*ioc

Pointer to MPT adapter structure

Description

Obtain an MPT request frame from the pool (of 1024) that areallocated per MPT adapter.

Returns pointer to a MPT request frame orNULL if none are availableor IOC is not active.

voidmpt_put_msg_frame(u8cb_idx,MPT_ADAPTER*ioc,MPT_FRAME_HDR*mf)

Send a protocol-specific MPT request frame to an IOC

Parameters

u8cb_idx

Handle of registered MPT protocol driver

MPT_ADAPTER*ioc

Pointer to MPT adapter structure

MPT_FRAME_HDR*mf

Pointer to MPT request frame

Description

This routine posts an MPT request frame to the request post FIFO of aspecific MPT adapter.

voidmpt_put_msg_frame_hi_pri(u8cb_idx,MPT_ADAPTER*ioc,MPT_FRAME_HDR*mf)

Send a hi-pri protocol-specific MPT request frame

Parameters

u8cb_idx

Handle of registered MPT protocol driver

MPT_ADAPTER*ioc

Pointer to MPT adapter structure

MPT_FRAME_HDR*mf

Pointer to MPT request frame

Description

Send a protocol-specific MPT request frame to an IOC usinghi-priority request queue.

This routine posts an MPT request frame to the request post FIFO of aspecific MPT adapter.

voidmpt_free_msg_frame(MPT_ADAPTER*ioc,MPT_FRAME_HDR*mf)

Place MPT request frame back on FreeQ.

Parameters

MPT_ADAPTER*ioc

Pointer to MPT adapter structure

MPT_FRAME_HDR*mf

Pointer to MPT request frame

Description

This routine places a MPT request frame back on the MPT adapter’sFreeQ.

intmpt_send_handshake_request(u8cb_idx,MPT_ADAPTER*ioc,intreqBytes,u32*req,intsleepFlag)

Send MPT request via doorbell handshake method.

Parameters

u8cb_idx

Handle of registered MPT protocol driver

MPT_ADAPTER*ioc

Pointer to MPT adapter structure

intreqBytes

Size of the request in bytes

u32*req

Pointer to MPT request frame

intsleepFlag

Use schedule if CAN_SLEEP else use udelay.

Description

This routine is used exclusively to send MptScsiTaskMgmtrequests since they are required to be sent via doorbell handshake.

NOTE

It is the callers responsibility to byte-swap fields in the

request which are greater than 1 byte in size.

Returns 0 for success, non-zero for failure.

intmpt_verify_adapter(intiocid,MPT_ADAPTER**iocpp)

Given IOC identifier, set pointer to its adapter structure.

Parameters

intiocid

IOC unique identifier (integer)

MPT_ADAPTER**iocpp

Pointer to pointer to IOC adapter

Description

Given a unique IOC identifier, set pointer to the associated MPTadapter structure.

Returns iocid and sets iocpp if iocid is found.Returns -1 if iocid is not found.

intmpt_attach(structpci_dev*pdev,conststructpci_device_id*id)

Install a PCI intelligent MPT adapter.

Parameters

structpci_dev*pdev

Pointer to pci_dev structure

conststructpci_device_id*id

PCI device ID information

Description

This routine performs all the steps necessary to bring the IOC ofa MPT adapter to a OPERATIONAL state. This includes registeringmemory regions, registering the interrupt, and allocating requestand reply memory pools.

This routine also pre-fetches the LAN MAC address of a Fibre ChannelMPT adapter.

Returns 0 for success, non-zero for failure.

TODO: Add support for polled controllers

voidmpt_detach(structpci_dev*pdev)

Remove a PCI intelligent MPT adapter.

Parameters

structpci_dev*pdev

Pointer to pci_dev structure

intmpt_suspend(structpci_dev*pdev,pm_message_tstate)

Fusion MPT base driver suspend routine.

Parameters

structpci_dev*pdev

Pointer to pci_dev structure

pm_message_tstate

new state to enter

intmpt_resume(structpci_dev*pdev)

Fusion MPT base driver resume routine.

Parameters

structpci_dev*pdev

Pointer to pci_dev structure

u32mpt_GetIocState(MPT_ADAPTER*ioc,intcooked)

Get the current state of a MPT adapter.

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

intcooked

Request raw or cooked IOC state

Description

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

intmpt_alloc_fw_memory(MPT_ADAPTER*ioc,intsize)

allocate firmware memory

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

intsize

total FW bytes

Description

If memory has already been allocated, the same (cached) valueis returned.

Return 0 if successful, or non-zero for failure

voidmpt_free_fw_memory(MPT_ADAPTER*ioc)

free firmware memory

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

Description

If alt_img is NULL, delete from ioc structure.Else, delete a secondary image in same format.

intmptbase_sas_persist_operation(MPT_ADAPTER*ioc,u8persist_opcode)

Perform operation on SAS Persistent Table

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

u8persist_opcode

see below

Description

MPI_SAS_OP_CLEAR_NOT_PRESENT

Free all persist TargetID mappings fordevices not currently present.

MPI_SAS_OP_CLEAR_ALL_PERSISTENT

Clear al persist TargetID mappings

NOTE

Don’t use not this function during interrupt time.

Returns 0 for success, non-zero error

intmpt_raid_phys_disk_pg0(MPT_ADAPTER*ioc,u8phys_disk_num,RaidPhysDiskPage0_t*phys_disk)

returns phys disk page zero

Parameters

MPT_ADAPTER*ioc

Pointer to a Adapter Structure

u8phys_disk_num

io unit unique phys disk num generated by the ioc

RaidPhysDiskPage0_t*phys_disk

requested payload data returned

Return

0 on success-EFAULT if read of config page header fails or data pointer not NULL-ENOMEM if pci_alloc failed

intmpt_raid_phys_disk_get_num_paths(MPT_ADAPTER*ioc,u8phys_disk_num)

returns number paths associated to this phys_num

Parameters

MPT_ADAPTER*ioc

Pointer to a Adapter Structure

u8phys_disk_num

io unit unique phys disk num generated by the ioc

Return

returns number paths

intmpt_raid_phys_disk_pg1(MPT_ADAPTER*ioc,u8phys_disk_num,RaidPhysDiskPage1_t*phys_disk)

returns phys disk page 1

Parameters

MPT_ADAPTER*ioc

Pointer to a Adapter Structure

u8phys_disk_num

io unit unique phys disk num generated by the ioc

RaidPhysDiskPage1_t*phys_disk

requested payload data returned

Return

0 on success-EFAULT if read of config page header fails or data pointer not NULL-ENOMEM if pci_alloc failed

intmpt_findImVolumes(MPT_ADAPTER*ioc)

Identify IDs of hidden disks and RAID Volumes

Parameters

MPT_ADAPTER*ioc

Pointer to a Adapter Strucutre

Return

0 on success-EFAULT if read of config page header fails or data pointer not NULL-ENOMEM if pci_alloc failed

intmpt_config(MPT_ADAPTER*ioc,CONFIGPARMS*pCfg)

Generic function to issue config message

Parameters

MPT_ADAPTER*ioc

Pointer to an adapter structure

CONFIGPARMS*pCfg

Pointer to a configuration structure. Struct containsaction, page address, direction, physical addressand pointer to a configuration page headerPage header is updated.

Description

Returns 0 for success-EAGAIN if no msg frames currently available-EFAULT for non-successful reply or no reply (timeout)

voidmpt_print_ioc_summary(MPT_ADAPTER*ioc,char*buffer,int*size,intlen,intshowlan)

Write ASCII summary of IOC to a buffer.

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

char*buffer

Pointer to buffer where IOC summary info should be written

int*size

Pointer to number of bytes we wrote (set by this routine)

intlen

Offset at which to start writing in buffer

intshowlan

Display LAN stuff?

Description

This routine writes (english readable) ASCII text, which representsa summary of IOC information, to a buffer.

intmpt_set_taskmgmt_in_progress_flag(MPT_ADAPTER*ioc)

set flags associated with task management

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

Description

Returns 0 for SUCCESS or -1 if FAILED.

If -1 is return, then it was not possible to set the flags

voidmpt_clear_taskmgmt_in_progress_flag(MPT_ADAPTER*ioc)

clear flags associated with task management

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

void__noreturnmpt_halt_firmware(MPT_ADAPTER*ioc)

Halts the firmware if it is operational and panic the kernel

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

intmpt_Soft_Hard_ResetHandler(MPT_ADAPTER*ioc,intsleepFlag)

Try less expensive reset

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

intsleepFlag

Indicates if sleep or schedule must be called.

Description

Returns 0 for SUCCESS or -1 if FAILED.Try for softreset first, only if it fails go for expensiveHardReset.

intmpt_HardResetHandler(MPT_ADAPTER*ioc,intsleepFlag)

Generic reset handler

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

intsleepFlag

Indicates if sleep or schedule must be called.

Description

Issues SCSI Task Management call based on input arg values.If TaskMgmt fails, returns associated SCSI request.

Remark: _HardResetHandler can be invoked from an interrupt thread (timer)or a non-interrupt thread. In the former, must not callschedule().

Note

A return of -1 is a FATAL error case, as it means a

FW reload/initialization failed.

Returns 0 for SUCCESS or -1 if FAILED.

constchar*mptscsih_info(structScsi_Host*SChost)

Return information about MPT adapter

Parameters

structScsi_Host*SChost

Pointer to Scsi_Host structure

Description

(linux scsi_host_template.info routine)

Returns pointer to buffer where information was written.

intmptscsih_qcmd(structscsi_cmnd*SCpnt)

Primary Fusion MPT SCSI initiator IO start routine.

Parameters

structscsi_cmnd*SCpnt

Pointer to scsi_cmnd structure

Description

(linux scsi_host_template.queuecommand routine)This is the primary SCSI IO start routine. Create a MPI SCSIIORequestfrom a linux scsi_cmnd request and send it to the IOC.

Returns 0. (rtn value discarded by linux scsi mid-layer)

intmptscsih_IssueTaskMgmt(MPT_SCSI_HOST*hd,u8type,u8channel,u8id,u64lun,intctx2abort,ulongtimeout)

Generic send Task Management function.

Parameters

MPT_SCSI_HOST*hd

Pointer to MPT_SCSI_HOST structure

u8type

Task Management type

u8channel

channel number for task management

u8id

Logical Target ID for reset (if appropriate)

u64lun

Logical Unit for reset (if appropriate)

intctx2abort

Context for the task to be aborted (if appropriate)

ulongtimeout

timeout for task management control

Description

Remark: _HardResetHandler can be invoked from an interrupt thread (timer)or a non-interrupt thread. In the former, must not callschedule().

Not all fields are meaningfull for all task types.

Returns 0 for SUCCESS, or FAILED.

intmptscsih_abort(structscsi_cmnd*SCpnt)

Abort linux scsi_cmnd routine, new_eh variant

Parameters

structscsi_cmnd*SCpnt

Pointer to scsi_cmnd structure, IO to be aborted

Description

(linux scsi_host_template.eh_abort_handler routine)

Returns SUCCESS or FAILED.

intmptscsih_dev_reset(structscsi_cmnd*SCpnt)

Perform a SCSI LOGICAL_UNIT_RESET!

Parameters

structscsi_cmnd*SCpnt

Pointer to scsi_cmnd structure, IO which reset is due to

Description

(linux scsi_host_template.eh_dev_reset_handler routine)

Returns SUCCESS or FAILED.

intmptscsih_bus_reset(structscsi_cmnd*SCpnt)

Perform a SCSI BUS_RESET! new_eh variant

Parameters

structscsi_cmnd*SCpnt

Pointer to scsi_cmnd structure, IO which reset is due to

Description

(linux scsi_host_template.eh_bus_reset_handler routine)

Returns SUCCESS or FAILED.

intmptscsih_host_reset(structscsi_cmnd*SCpnt)

Perform a SCSI host adapter RESET (new_eh variant)

Parameters

structscsi_cmnd*SCpnt

Pointer to scsi_cmnd structure, IO which reset is due to

Description

(linux scsi_host_template.eh_host_reset_handler routine)

Returns SUCCESS or FAILED.

intmptscsih_taskmgmt_complete(MPT_ADAPTER*ioc,MPT_FRAME_HDR*mf,MPT_FRAME_HDR*mr)

Registered with Fusion MPT base driver

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

MPT_FRAME_HDR*mf

Pointer to SCSI task mgmt request frame

MPT_FRAME_HDR*mr

Pointer to SCSI task mgmt reply frame

Description

This routine is called from mptbase.c::mpt_interrupt() at the completionof any SCSI task management request.This routine is registered with the MPT (base) driver at driverload/init time via thempt_register() API call.

Returns 1 indicating alloc’d request frame ptr should be freed.

structscsi_cmnd*mptscsih_get_scsi_lookup(MPT_ADAPTER*ioc,inti)

retrieves scmd entry

Parameters

MPT_ADAPTER*ioc

Pointer to MPT_ADAPTER structure

inti

index into the array

Description

Returns the scsi_cmd pointer