linux/drivers/scsi/megaraid/megaraid_sas_fusion.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  Linux MegaRAID driver for SAS based RAID controllers
 *
 *  Copyright (c) 2009-2013  LSI Corporation
 *  Copyright (c) 2013-2016  Avago Technologies
 *  Copyright (c) 2016-2018  Broadcom Inc.
 *
 *  FILE: megaraid_sas_fusion.h
 *
 *  Authors: Broadcom Inc.
 *           Manoj Jose
 *           Sumant Patro
 *           Kashyap Desai <[email protected]>
 *           Sumit Saxena <[email protected]>
 *
 *  Send feedback to: [email protected]
 */

#ifndef _MEGARAID_SAS_FUSION_H_
#define _MEGARAID_SAS_FUSION_H_

/* Fusion defines */
#define MEGASAS_CHAIN_FRAME_SZ_MIN
#define MFI_FUSION_ENABLE_INTERRUPT_MASK
#define MEGASAS_MAX_CHAIN_SHIFT
#define MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK
#define MEGASAS_MAX_CHAIN_SIZE_MASK
#define MEGASAS_256K_IO
#define MEGASAS_1MB_IO
#define MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE
#define MEGASAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST
#define MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST
#define MEGASAS_LOAD_BALANCE_FLAG
#define MEGASAS_DCMD_MBOX_PEND_FLAG
#define HOST_DIAG_WRITE_ENABLE
#define HOST_DIAG_RESET_ADAPTER
#define MEGASAS_FUSION_MAX_RESET_TRIES
#define MAX_MSIX_QUEUES_FUSION
#define RDPQ_MAX_INDEX_IN_ONE_CHUNK
#define RDPQ_MAX_CHUNK_COUNT

/* Invader defines */
#define MPI2_TYPE_CUDA
#define MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH
#define MR_RL_FLAGS_GRANT_DESTINATION_CPU0
#define MR_RL_FLAGS_GRANT_DESTINATION_CPU1
#define MR_RL_FLAGS_GRANT_DESTINATION_CUDA
#define MR_RL_FLAGS_SEQ_NUM_ENABLE
#define MR_RL_WRITE_THROUGH_MODE
#define MR_RL_WRITE_BACK_MODE

/* T10 PI defines */
#define MR_PROT_INFO_TYPE_CONTROLLER
#define MEGASAS_SCSI_VARIABLE_LENGTH_CMD
#define MEGASAS_SCSI_SERVICE_ACTION_READ32
#define MEGASAS_SCSI_SERVICE_ACTION_WRITE32
#define MEGASAS_SCSI_ADDL_CDB_LEN
#define MEGASAS_RD_WR_PROTECT_CHECK_ALL
#define MEGASAS_RD_WR_PROTECT_CHECK_NONE

#define MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET
#define MPI2_REPLY_POST_HOST_INDEX_OFFSET

/*
 * Raid context flags
 */

#define MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT
#define MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_MASK
enum MR_RAID_FLAGS_IO_SUB_TYPE {};

/*
 * Request descriptor types
 */
#define MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
#define MEGASAS_REQ_DESCRIPT_FLAGS_MFA
#define MEGASAS_REQ_DESCRIPT_FLAGS_NO_LOCK
#define MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT

#define MEGASAS_FP_CMD_LEN
#define MEGASAS_FUSION_IN_RESET
#define MEGASAS_FUSION_OCR_NOT_POSSIBLE
#define RAID_1_PEER_CMDS
#define JBOD_MAPS_COUNT
#define MEGASAS_REDUCE_QD_COUNT
#define IOC_INIT_FRAME_SIZE

/*
 * Raid Context structure which describes MegaRAID specific IO Parameters
 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
 */

struct RAID_CONTEXT {};

/*
 * Raid Context structure which describes ventura MegaRAID specific
 * IO Paramenters ,This resides at offset 0x60 where the SGL normally
 * starts in MPT IO Frames
 */
struct RAID_CONTEXT_G35 {};

#define MR_RAID_CTX_ROUTINGFLAGS_SLD_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_C2D_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_FWD_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_SBS_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_RW_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_LOG_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_CPUSEL_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_CPUSEL_MASK
#define MR_RAID_CTX_ROUTINGFLAGS_SETDIVERT_SHIFT
#define MR_RAID_CTX_ROUTINGFLAGS_SETDIVERT_MASK

static inline void set_num_sge(struct RAID_CONTEXT_G35 *rctx_g35,
			       u16 sge_count)
{}

static inline u16 get_num_sge(struct RAID_CONTEXT_G35 *rctx_g35)
{}

#define SET_STREAM_DETECTED(rctx_g35)

#define CLEAR_STREAM_DETECTED(rctx_g35)

static inline bool is_stream_detected(struct RAID_CONTEXT_G35 *rctx_g35)
{}

RAID_CONTEXT_UNION;

#define RAID_CTX_SPANARM_ARM_SHIFT
#define RAID_CTX_SPANARM_ARM_MASK

#define RAID_CTX_SPANARM_SPAN_SHIFT
#define RAID_CTX_SPANARM_SPAN_MASK

/* LogArm[14:10], P-Arm[9:5], Q-Arm[4:0] */
#define RAID_CTX_R56_Q_ARM_MASK
#define RAID_CTX_R56_P_ARM_SHIFT
#define RAID_CTX_R56_P_ARM_MASK
#define RAID_CTX_R56_LOG_ARM_SHIFT
#define RAID_CTX_R56_LOG_ARM_MASK

/* number of bits per index in U32 TrackStream */
#define BITS_PER_INDEX_STREAM
#define INVALID_STREAM_NUM
#define MR_STREAM_BITMAP
#define STREAM_MASK
#define ZERO_LAST_STREAM
#define MAX_STREAMS_TRACKED

/*
 * define region lock types
 */
enum REGION_TYPE {};

/* MPI2 defines */
#define MPI2_FUNCTION_IOC_INIT
#define MPI2_WHOINIT_HOST_DRIVER
#define MPI2_VERSION_MAJOR
#define MPI2_VERSION_MINOR
#define MPI2_VERSION_MAJOR_MASK
#define MPI2_VERSION_MAJOR_SHIFT
#define MPI2_VERSION_MINOR_MASK
#define MPI2_VERSION_MINOR_SHIFT
#define MPI2_VERSION
#define MPI2_HEADER_VERSION_UNIT
#define MPI2_HEADER_VERSION_DEV
#define MPI2_HEADER_VERSION_UNIT_MASK
#define MPI2_HEADER_VERSION_UNIT_SHIFT
#define MPI2_HEADER_VERSION_DEV_MASK
#define MPI2_HEADER_VERSION_DEV_SHIFT
#define MPI2_HEADER_VERSION
#define MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR
#define MPI2_SCSIIO_EEDPFLAGS_INC_PRI_REFTAG
#define MPI2_SCSIIO_EEDPFLAGS_CHECK_REFTAG
#define MPI2_SCSIIO_EEDPFLAGS_CHECK_REMOVE_OP
#define MPI2_SCSIIO_EEDPFLAGS_CHECK_APPTAG
#define MPI2_SCSIIO_EEDPFLAGS_CHECK_GUARD
#define MPI2_SCSIIO_EEDPFLAGS_INSERT_OP
/* EEDP escape mode */
#define MPI25_SCSIIO_EEDPFLAGS_DO_NOT_DISABLE_MODE
#define MPI2_FUNCTION_SCSI_IO_REQUEST
#define MPI2_FUNCTION_SCSI_TASK_MGMT
#define MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY
#define MPI2_REQ_DESCRIPT_FLAGS_FP_IO
#define MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO
#define MPI2_SGE_FLAGS_64_BIT_ADDRESSING
#define MPI2_SCSIIO_CONTROL_WRITE
#define MPI2_SCSIIO_CONTROL_READ
#define MPI2_REQ_DESCRIPT_FLAGS_TYPE_MASK
#define MPI2_RPY_DESCRIPT_FLAGS_UNUSED
#define MPI2_RPY_DESCRIPT_FLAGS_SCSI_IO_SUCCESS
#define MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK
#define MPI2_WRSEQ_FLUSH_KEY_VALUE
#define MPI2_WRITE_SEQUENCE_OFFSET
#define MPI2_WRSEQ_1ST_KEY_VALUE
#define MPI2_WRSEQ_2ND_KEY_VALUE
#define MPI2_WRSEQ_3RD_KEY_VALUE
#define MPI2_WRSEQ_4TH_KEY_VALUE
#define MPI2_WRSEQ_5TH_KEY_VALUE
#define MPI2_WRSEQ_6TH_KEY_VALUE

struct MPI25_IEEE_SGE_CHAIN64 {};

struct MPI2_SGE_SIMPLE_UNION {};

struct MPI2_SCSI_IO_CDB_EEDP32 {};

struct MPI2_SGE_CHAIN_UNION {};

struct MPI2_IEEE_SGE_SIMPLE32 {};

struct MPI2_IEEE_SGE_CHAIN32 {};

struct MPI2_IEEE_SGE_SIMPLE64 {};

struct MPI2_IEEE_SGE_CHAIN64 {};

MPI2_IEEE_SGE_SIMPLE_UNION;

MPI2_IEEE_SGE_CHAIN_UNION;

MPI2_SGE_IO_UNION;

MPI2_SCSI_IO_CDB_UNION;

/****************************************************************************
*  SCSI Task Management messages
****************************************************************************/

/*SCSI Task Management Request Message */
struct MPI2_SCSI_TASK_MANAGE_REQUEST {};


/*SCSI Task Management Reply Message */
struct MPI2_SCSI_TASK_MANAGE_REPLY {};

struct MR_TM_REQUEST {};

struct MR_TM_REPLY {};

/* SCSI Task Management Request Message */
struct MR_TASK_MANAGE_REQUEST {};

/* TaskType values */

#define MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK
#define MPI2_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET
#define MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET
#define MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET
#define MPI2_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET
#define MPI2_SCSITASKMGMT_TASKTYPE_QUERY_TASK
#define MPI2_SCSITASKMGMT_TASKTYPE_CLR_ACA
#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_TASK_SET
#define MPI2_SCSITASKMGMT_TASKTYPE_QRY_ASYNC_EVENT

/* ResponseCode values */

#define MPI2_SCSITASKMGMT_RSP_TM_COMPLETE
#define MPI2_SCSITASKMGMT_RSP_INVALID_FRAME
#define MPI2_SCSITASKMGMT_RSP_TM_NOT_SUPPORTED
#define MPI2_SCSITASKMGMT_RSP_TM_FAILED
#define MPI2_SCSITASKMGMT_RSP_TM_SUCCEEDED
#define MPI2_SCSITASKMGMT_RSP_TM_INVALID_LUN
#define MPI2_SCSITASKMGMT_RSP_TM_OVERLAPPED_TAG
#define MPI2_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC

/*
 * RAID SCSI IO Request Message
 * Total SGE count will be one less than  _MPI2_SCSI_IO_REQUEST
 */
struct MPI2_RAID_SCSI_IO_REQUEST {};

/*
 * MPT RAID MFA IO Descriptor.
 */
struct MEGASAS_RAID_MFA_IO_REQUEST_DESCRIPTOR {};

/* Default Request Descriptor */
struct MPI2_DEFAULT_REQUEST_DESCRIPTOR {};

/* High Priority Request Descriptor */
struct MPI2_HIGH_PRIORITY_REQUEST_DESCRIPTOR {};

/* SCSI IO Request Descriptor */
struct MPI2_SCSI_IO_REQUEST_DESCRIPTOR {};

/* SCSI Target Request Descriptor */
struct MPI2_SCSI_TARGET_REQUEST_DESCRIPTOR {};

/* RAID Accelerator Request Descriptor */
struct MPI2_RAID_ACCEL_REQUEST_DESCRIPTOR {};

/* union of Request Descriptors */
MEGASAS_REQUEST_DESCRIPTOR_UNION;

/* Default Reply Descriptor */
struct MPI2_DEFAULT_REPLY_DESCRIPTOR {};

/* Address Reply Descriptor */
struct MPI2_ADDRESS_REPLY_DESCRIPTOR {};

/* SCSI IO Success Reply Descriptor */
struct MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR {};

/* TargetAssist Success Reply Descriptor */
struct MPI2_TARGETASSIST_SUCCESS_REPLY_DESCRIPTOR {};

/* Target Command Buffer Reply Descriptor */
struct MPI2_TARGET_COMMAND_BUFFER_REPLY_DESCRIPTOR {};

/* RAID Accelerator Success Reply Descriptor */
struct MPI2_RAID_ACCELERATOR_SUCCESS_REPLY_DESCRIPTOR {};

/* union of Reply Descriptors */
MPI2_REPLY_DESCRIPTORS_UNION;

/* IOCInit Request message */
struct MPI2_IOC_INIT_REQUEST {};

/* mrpriv defines */
#define MR_PD_INVALID
#define MR_DEVHANDLE_INVALID
#define MAX_SPAN_DEPTH
#define MAX_QUAD_DEPTH
#define MAX_RAIDMAP_SPAN_DEPTH
#define MAX_ROW_SIZE
#define MAX_RAIDMAP_ROW_SIZE
#define MAX_LOGICAL_DRIVES
#define MAX_LOGICAL_DRIVES_EXT
#define MAX_LOGICAL_DRIVES_DYN
#define MAX_RAIDMAP_LOGICAL_DRIVES
#define MAX_RAIDMAP_VIEWS
#define MAX_ARRAYS
#define MAX_RAIDMAP_ARRAYS
#define MAX_ARRAYS_EXT
#define MAX_API_ARRAYS_EXT
#define MAX_API_ARRAYS_DYN
#define MAX_PHYSICAL_DEVICES
#define MAX_RAIDMAP_PHYSICAL_DEVICES
#define MAX_RAIDMAP_PHYSICAL_DEVICES_DYN
#define MR_DCMD_LD_MAP_GET_INFO
#define MR_DCMD_SYSTEM_PD_MAP_GET_INFO
#define MR_DCMD_DRV_GET_TARGET_PROP
#define MR_DCMD_CTRL_SHARED_HOST_MEM_ALLOC
#define MR_DCMD_LD_VF_MAP_GET_ALL_LDS_111
#define MR_DCMD_LD_VF_MAP_GET_ALL_LDS
#define MR_DCMD_CTRL_SNAPDUMP_GET_PROPERTIES
#define MR_DCMD_CTRL_DEVICE_LIST_GET

struct MR_DEV_HANDLE_INFO {};

struct MR_ARRAY_INFO {};

struct MR_QUAD_ELEMENT {};

struct MR_SPAN_INFO {};

struct MR_LD_SPAN {};

struct MR_SPAN_BLOCK_INFO {};

#define MR_RAID_CTX_CPUSEL_0
#define MR_RAID_CTX_CPUSEL_1
#define MR_RAID_CTX_CPUSEL_2
#define MR_RAID_CTX_CPUSEL_3
#define MR_RAID_CTX_CPUSEL_FCFS

struct MR_CPU_AFFINITY_MASK {};

struct MR_IO_AFFINITY {};

struct MR_LD_RAID {};

struct MR_LD_SPAN_MAP {};

struct MR_FW_RAID_MAP {};

struct IO_REQUEST_INFO {};

struct MR_LD_TARGET_SYNC {};

/*
 * RAID Map descriptor Types.
 * Each element should uniquely idetify one data structure in the RAID map
 */
enum MR_RAID_MAP_DESC_TYPE {};

/*
 * This table defines the offset, size and num elements  of each descriptor
 * type in the RAID Map buffer
 */
struct MR_RAID_MAP_DESC_TABLE {};

/*
 * Dynamic Raid Map Structure.
 */
struct MR_FW_RAID_MAP_DYNAMIC {}; /* Dynamicaly sized RAID MAp structure */

#define IEEE_SGE_FLAGS_ADDR_MASK
#define IEEE_SGE_FLAGS_SYSTEM_ADDR
#define IEEE_SGE_FLAGS_IOCDDR_ADDR
#define IEEE_SGE_FLAGS_IOCPLB_ADDR
#define IEEE_SGE_FLAGS_IOCPLBNTA_ADDR
#define IEEE_SGE_FLAGS_CHAIN_ELEMENT
#define IEEE_SGE_FLAGS_END_OF_LIST

#define MPI2_SGE_FLAGS_SHIFT
#define IEEE_SGE_FLAGS_FORMAT_MASK
#define IEEE_SGE_FLAGS_FORMAT_IEEE
#define IEEE_SGE_FLAGS_FORMAT_NVME

#define MPI26_IEEE_SGE_FLAGS_NSF_MASK
#define MPI26_IEEE_SGE_FLAGS_NSF_MPI_IEEE
#define MPI26_IEEE_SGE_FLAGS_NSF_NVME_PRP
#define MPI26_IEEE_SGE_FLAGS_NSF_NVME_SGL

#define MEGASAS_DEFAULT_SNAP_DUMP_WAIT_TIME
#define MEGASAS_MAX_SNAP_DUMP_WAIT_TIME

struct megasas_register_set;
struct megasas_instance;

desc_word;

struct megasas_cmd_fusion {};

struct LD_LOAD_BALANCE_INFO {};

/* SPAN_SET is info caclulated from span info from Raid map per LD */
PLD_SPAN_SET;

PLD_SPAN_INFO;

struct MR_FW_RAID_MAP_ALL {} __attribute__ ((packed));

struct MR_DRV_RAID_MAP {};

/* Driver raid map size is same as raid map ext
 * MR_DRV_RAID_MAP_ALL is created to sync with old raid.
 * And it is mainly for code re-use purpose.
 */
struct MR_DRV_RAID_MAP_ALL {} __packed;



struct MR_FW_RAID_MAP_EXT {};

/*
 *  * define MR_PD_CFG_SEQ structure for system PDs
 *   */
struct MR_PD_CFG_SEQ {} __packed;

struct MR_PD_CFG_SEQ_NUM_SYNC {} __packed;

/* stream detection */
struct STREAM_DETECT {};

struct LD_STREAM_DETECT {};

struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY {};

struct rdpq_alloc_detail {};

struct fusion_context {};

desc_value;

enum CMD_RET_VALUES {};

struct  MR_SNAPDUMP_PROPERTIES {};

struct megasas_debugfs_buffer {};

void megasas_free_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);
void megasas_release_fusion(struct megasas_instance *instance);
void megasas_reset_reply_desc(struct megasas_instance *instance);
int megasas_check_mpio_paths(struct megasas_instance *instance,
			      struct scsi_cmnd *scmd);
void megasas_fusion_ocr_wq(struct work_struct *work);

#endif /* _MEGARAID_SAS_FUSION_H_ */