linux/drivers/message/fusion/mptbase.h

/*
 *  linux/drivers/message/fusion/mptbase.h
 *      High performance SCSI + LAN / Fibre Channel device drivers.
 *      For use with PCI chip/adapter(s):
 *          LSIFC9xx/LSI409xx Fibre Channel
 *      running LSI Fusion MPT (Message Passing Technology) firmware.
 *
 *  Copyright (c) 1999-2008 LSI Corporation
 *  (mailto:[email protected])
 *
 */
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
    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; version 2 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    NO WARRANTY
    THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
    CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
    LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
    solely responsible for determining the appropriateness of using and
    distributing the Program and assumes all risks associated with its
    exercise of rights under this Agreement, including but not limited to
    the risks and costs of program errors, damage to or loss of data,
    programs or equipment, and unavailability or interruption of operations.

    DISCLAIMER OF LIABILITY
    NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
    USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
    HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef MPTBASE_H_INCLUDED
#define MPTBASE_H_INCLUDED
/*{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/mutex.h>

#include "lsi/mpi_type.h"
#include "lsi/mpi.h"		/* Fusion MPI(nterface) basic defs */
#include "lsi/mpi_ioc.h"	/* Fusion MPT IOC(ontroller) defs */
#include "lsi/mpi_cnfg.h"	/* IOC configuration support */
#include "lsi/mpi_init.h"	/* SCSI Host (initiator) protocol support */
#include "lsi/mpi_lan.h"	/* LAN over FC protocol support */
#include "lsi/mpi_raid.h"	/* Integrated Mirroring support */

#include "lsi/mpi_fc.h"		/* Fibre Channel (lowlevel) support */
#include "lsi/mpi_targ.h"	/* SCSI/FCP Target protcol support */
#include "lsi/mpi_tool.h"	/* Tools support */
#include "lsi/mpi_sas.h"	/* SAS support */

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#ifndef MODULEAUTHOR
#define MODULEAUTHOR
#endif

#ifndef COPYRIGHT
#define COPYRIGHT
#endif

#define MPT_LINUX_VERSION_COMMON
#define MPT_LINUX_PACKAGE_NAME
#define WHAT_MAGIC_STRING

#define show_mptmod_ver(s,ver)

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Fusion MPT(linux) driver configurable stuff...
 */
#define MPT_MAX_ADAPTERS
#define MPT_MAX_PROTOCOL_DRIVERS
#define MPT_MAX_CALLBACKNAME_LEN
#define MPT_MAX_BUS
#define MPT_MAX_FC_DEVICES
#define MPT_MAX_SCSI_DEVICES
#define MPT_LAST_LUN
#define MPT_SENSE_BUFFER_ALLOC
	/* allow for 256 max sense alloc, but only 255 max request */
#if MPT_SENSE_BUFFER_ALLOC >= 256
#	undef MPT_SENSE_BUFFER_ALLOC
#define MPT_SENSE_BUFFER_ALLOC
#define MPT_SENSE_BUFFER_SIZE
#else
#define MPT_SENSE_BUFFER_SIZE
#endif

#define MPT_NAME_LENGTH
#define MPT_KOBJ_NAME_LEN

#define MPT_PROCFS_MPTBASEDIR
						/* chg it to "driver/fusion" ? */
#define MPT_PROCFS_SUMMARY_ALL_NODE
#define MPT_PROCFS_SUMMARY_ALL_PATHNAME
#define MPT_FW_REV_MAGIC_ID_STRING

#define MPT_MAX_REQ_DEPTH
#define MPT_DEFAULT_REQ_DEPTH
#define MPT_MIN_REQ_DEPTH

#define MPT_MAX_REPLY_DEPTH
#define MPT_DEFAULT_REPLY_DEPTH
#define MPT_MIN_REPLY_DEPTH
#define MPT_MAX_REPLIES_PER_ISR

#define MPT_MAX_FRAME_SIZE
#define MPT_DEFAULT_FRAME_SIZE

#define MPT_REPLY_FRAME_SIZE

#define MPT_SG_REQ_128_SCALE
#define MPT_SG_REQ_96_SCALE
#define MPT_SG_REQ_64_SCALE

#define CAN_SLEEP
#define NO_SLEEP

#define MPT_COALESCING_TIMEOUT


/*
 * SCSI transfer rate defines.
 */
#define MPT_ULTRA320
#define MPT_ULTRA160
#define MPT_ULTRA2
#define MPT_ULTRA
#define MPT_FAST
#define MPT_SCSI
#define MPT_ASYNC

#define MPT_NARROW
#define MPT_WIDE

#define C0_1030
#define XL_929


/*
 *	Try to keep these at 2^N-1
 */
#define MPT_FC_CAN_QUEUE
#define MPT_SCSI_CAN_QUEUE
#define MPT_SAS_CAN_QUEUE

/*
 * Set the MAX_SGE value based on user input.
 */
#ifdef CONFIG_FUSION_MAX_SGE
#if CONFIG_FUSION_MAX_SGE  < 16
#define MPT_SCSI_SG_DEPTH
#elif CONFIG_FUSION_MAX_SGE  > 128
#define MPT_SCSI_SG_DEPTH
#else
#define MPT_SCSI_SG_DEPTH
#endif
#else
#define MPT_SCSI_SG_DEPTH
#endif

#ifdef CONFIG_FUSION_MAX_FC_SGE
#if CONFIG_FUSION_MAX_FC_SGE  < 16
#define MPT_SCSI_FC_SG_DEPTH
#elif CONFIG_FUSION_MAX_FC_SGE  > 256
#define MPT_SCSI_FC_SG_DEPTH
#else
#define MPT_SCSI_FC_SG_DEPTH
#endif
#else
#define MPT_SCSI_FC_SG_DEPTH
#endif

/* debug print string length used for events and iocstatus */
#define EVENT_DESCR_STR_SZ

#define MPT_POLLING_INTERVAL

#ifdef __KERNEL__	/* { */
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#include <linux/proc_fs.h>

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 * Attempt semi-consistent error & warning msgs across
 * MPT drivers.  NOTE: Users of these macro defs must
 * themselves define their own MYNAM.
 */
#define MYIOC_s_FMT
#define MYIOC_s_DEBUG_FMT
#define MYIOC_s_INFO_FMT
#define MYIOC_s_NOTE_FMT
#define MYIOC_s_WARN_FMT
#define MYIOC_s_ERR_FMT

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  ATTO UL4D associated structures and defines
 */
#define ATTOFLAG_DISC
#define ATTOFLAG_TAGGED
#define ATTOFLAG_WIDE_ENB
#define ATTOFLAG_ID_ENB
#define ATTOFLAG_LUN_ENB

pATTODeviceInfo_t;

pATTO_SCSIPortPage2_t;


/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  MPT protocol driver defs...
 */
MPT_DRIVER_CLASS;

struct mpt_pci_driver{};

/*
 *  MPT adapter / port / bus / device info structures...
 */

MPT_FRAME_TRACKER;

/*
 *  We might want to view/access a frame as:
 *    1) generic request header
 *    2) SCSIIORequest
 *    3) SCSIIOReply
 *    4) MPIDefaultReply
 *    5) frame tracker
 */
MPT_FRAME_HDR;

#define MPT_REQ_MSGFLAGS_DROPME

MPT_SGL_HDR;

MPT_SGL64_HDR;

/*
 *  System interface register set
 */

SYSIF_REGS;

/*
 * NOTE: Use MPI_{DOORBELL,WRITESEQ,DIAG}_xxx defs in lsi/mpi.h
 * in conjunction with SYSIF_REGS accesses!
 */


/*
 *	Dynamic Multi-Pathing specific stuff...
 */

/* VirtTarget negoFlags field */
#define MPT_TARGET_NO_NEGO_WIDE
#define MPT_TARGET_NO_NEGO_SYNC
#define MPT_TARGET_NO_NEGO_QAS
#define MPT_TAPE_NEGO_IDP

/*
 *	VirtDevice - FC LUN device or SCSI target device
 */
VirtTarget;

VirtDevice;

/*
 *  Fibre Channel (SCSI) target device and associated defines...
 */
#define MPT_TARGET_DEFAULT_DV_STATUS
#define MPT_TARGET_FLAGS_VALID_NEGO
#define MPT_TARGET_FLAGS_VALID_INQUIRY
#define MPT_TARGET_FLAGS_Q_YES
#define MPT_TARGET_FLAGS_VALID_56
#define MPT_TARGET_FLAGS_SAF_TE_ISSUED
#define MPT_TARGET_FLAGS_RAID_COMPONENT
#define MPT_TARGET_FLAGS_LED_ON

/*
 *	IOCTL structure and associated defines
 */

#define MPTCTL_RESET_OK

#define MPT_MGMT_STATUS_RF_VALID
#define MPT_MGMT_STATUS_COMMAND_GOOD
#define MPT_MGMT_STATUS_PENDING
#define MPT_MGMT_STATUS_DID_IOCRESET
#define MPT_MGMT_STATUS_SENSE_VALID
#define MPT_MGMT_STATUS_TIMER_ACTIVE
#define MPT_MGMT_STATUS_FREE_MF

#define INITIALIZE_MGMT_STATUS(status)
#define CLEAR_MGMT_STATUS(status)
#define CLEAR_MGMT_PENDING_STATUS(status)
#define SET_MGMT_MSG_CONTEXT(msg_context, value)

MPT_MGMT;

/*
 *  Event Structure and define
 */
#define MPTCTL_EVENT_LOG_SIZE
MPT_IOCTL_EVENTS;

/*
 * CONFIGPARM status  defines
 */
#define MPT_CONFIG_GOOD
#define MPT_CONFIG_ERROR

/*
 *	Substructure to store SCSI specific configuration page data
 */
						/* dvStatus defines: */
#define MPT_SCSICFG_USE_NVRAM
#define MPT_SCSICFG_ALL_IDS
/* #define MPT_SCSICFG_BLK_NEGO		0x10	   WriteSDP1 with WDTR and SDTR disabled */

SpiCfgData;

SasCfgData;

/*
 * Inactive volume link list of raid component data
 * @inactive_list
 */
struct inactive_raid_component_info {};

RaidCfgData;

FcCfgData;

#define MPT_RPORT_INFO_FLAGS_REGISTERED
#define MPT_RPORT_INFO_FLAGS_MISSING

/*
 * data allocated for each fc rport device
 */
struct mptfc_rport_info
{};

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

/*
 * MPT_SCSI_HOST defines - Used by the IOCTL and the SCSI drivers
 * Private to the driver.
 */

#define MPT_HOST_BUS_UNKNOWN
#define MPT_HOST_TOO_MANY_TM
#define MPT_HOST_NVRAM_INVALID
#define MPT_HOST_NO_CHAIN
#define MPT_NVRAM_MASK_TIMEOUT
#define MPT_NVRAM_SYNC_MASK
#define MPT_NVRAM_SYNC_SHIFT
#define MPT_NVRAM_DISCONNECT_ENABLE
#define MPT_NVRAM_ID_SCAN_ENABLE
#define MPT_NVRAM_LUN_SCAN_ENABLE
#define MPT_NVRAM_TAG_QUEUE_ENABLE
#define MPT_NVRAM_WIDE_DISABLE
#define MPT_NVRAM_BOOT_CHOICE

BUS_TYPE;

MPT_SCSI_HOST;

MPT_ADD_SGE;
MPT_ADD_CHAIN;
MPT_SCHEDULE_TARGET_RESET;
MPT_FLUSH_RUNNING_CMDS;

/*
 *  Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS
 */
MPT_ADAPTER;

/*
 *  New return value convention:
 *    1 = Ok to free associated request frame
 *    0 = not Ok ...
 */
MPT_CALLBACK;
MPT_EVHANDLER;
MPT_RESETHANDLER;
/* reset_phase defs */
#define MPT_IOC_PRE_RESET
#define MPT_IOC_POST_RESET
#define MPT_IOC_SETUP_RESET

/*
 * Invent MPT host event (super-set of MPI Events)
 * Fitted to 1030's 64-byte [max] request frame size
 */
MPT_HOST_EVENT;

#define MPT_HOSTEVENT_IOC_BRINGUP
#define MPT_HOSTEVENT_IOC_RECOVER

/* Define the generic types based on the size
 * of the dma_addr_t type.
 */
MptSge_t;


#define mpt_msg_flags(ioc)

#define MPT_SGE_FLAGS_64_BIT_ADDRESSING

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Funky (private) macros...
 */
#include "mptdebug.h"

#define MPT_INDEX_2_MFPTR(ioc,idx)

#define MFPTR_2_MPT_INDEX(ioc,mf)

#define MPT_INDEX_2_RFPTR(ioc,idx)

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

#define SCSI_STD_SENSE_BYTES
#define SCSI_STD_INQUIRY_BYTES
#define SCSI_MAX_INQUIRY_BYTES

/*
 * MPT_SCSI_HOST defines - Used by the IOCTL and the SCSI drivers
 * Private to the driver.
 */
/* LOCAL structure and fields used when processing
 * internally generated commands. These include:
 * bus scan, dv and config requests.
 */
MPT_LOCAL_REPLY;


/* The TM_STATE variable is used to provide strict single threading of TM
 * requests as well as communicate TM error conditions.
 */
#define TM_STATE_NONE
#define TM_STATE_IN_PROGRESS
#define TM_STATE_ERROR

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *	More Dynamic Multi-Pathing stuff...
 */

/* Forward decl, a strange C thing, to prevent gcc compiler warnings */
struct scsi_cmnd;

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 * Generic structure passed to the base mpt_config function.
 */
CONFIGPARMS;

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Public entry points...
 */
extern int	 mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id);
extern void	 mpt_detach(struct pci_dev *pdev);
#ifdef CONFIG_PM
extern int	 mpt_suspend(struct pci_dev *pdev, pm_message_t state);
extern int	 mpt_resume(struct pci_dev *pdev);
#endif
extern u8	 mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass,
		char *func_name);
extern void	 mpt_deregister(u8 cb_idx);
extern int	 mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc);
extern void	 mpt_event_deregister(u8 cb_idx);
extern int	 mpt_reset_register(u8 cb_idx, MPT_RESETHANDLER reset_func);
extern void	 mpt_reset_deregister(u8 cb_idx);
extern int	 mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, u8 cb_idx);
extern void	 mpt_device_driver_deregister(u8 cb_idx);
extern MPT_FRAME_HDR	*mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc);
extern void	 mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
extern void	 mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
extern void	 mpt_put_msg_frame_hi_pri(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);

extern int	 mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag);
extern int	 mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp);
extern u32	 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked);
extern void	 mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
extern int	 mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
extern int	 mpt_Soft_Hard_ResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
extern int	 mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
extern int	 mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
extern void	 mpt_free_fw_memory(MPT_ADAPTER *ioc);
extern int	 mpt_findImVolumes(MPT_ADAPTER *ioc);
extern int	 mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
extern int	 mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk);
extern int	mpt_raid_phys_disk_pg1(MPT_ADAPTER *ioc, u8 phys_disk_num,
		pRaidPhysDiskPage1_t phys_disk);
extern int	mpt_raid_phys_disk_get_num_paths(MPT_ADAPTER *ioc,
		u8 phys_disk_num);
extern int	 mpt_set_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc);
extern void	 mpt_clear_taskmgmt_in_progress_flag(MPT_ADAPTER *ioc);
extern void __noreturn mpt_halt_firmware(MPT_ADAPTER *ioc);


/*
 *  Public data decl's...
 */
extern struct list_head	  ioc_list;
extern int mpt_fwfault_debug;

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#endif		/* } __KERNEL__ */

#ifdef CONFIG_64BIT
#define CAST_U32_TO_PTR(x)
#define CAST_PTR_TO_U32(x)
#else
#define CAST_U32_TO_PTR
#define CAST_PTR_TO_U32
#endif

#define MPT_PROTOCOL_FLAGS_c_c_c_c(pflags)

/*
 *  Shifted SGE Defines - Use in SGE with FlagsLength member.
 *  Otherwise, use MPI_xxx defines (refer to "lsi/mpi.h" header).
 *  Defaults: 32 bit SGE, SYSTEM_ADDRESS if direction bit is 0, read
 */
#define MPT_TRANSFER_IOC_TO_HOST
#define MPT_TRANSFER_HOST_TO_IOC
#define MPT_SGE_FLAGS_LAST_ELEMENT
#define MPT_SGE_FLAGS_END_OF_BUFFER
#define MPT_SGE_FLAGS_LOCAL_ADDRESS
#define MPT_SGE_FLAGS_DIRECTION
#define MPT_SGE_FLAGS_END_OF_LIST

#define MPT_SGE_FLAGS_TRANSACTION_ELEMENT
#define MPT_SGE_FLAGS_SIMPLE_ELEMENT
#define MPT_SGE_FLAGS_CHAIN_ELEMENT
#define MPT_SGE_FLAGS_ELEMENT_MASK

#define MPT_SGE_FLAGS_SSIMPLE_READ
#define MPT_SGE_FLAGS_SSIMPLE_WRITE

/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#endif