From fe4166ee9d9f4c2d4557e82b7270d26e0fc946b3 Mon Sep 17 00:00:00 2001 From: liujie-answer Date: Tue, 25 Aug 2026 10:10:59 +0800 Subject: [PATCH] Linkdata: update HBA/RAID controller driver Signed-off-by: liujie-answer --- .../ps3stor/include/htp_v200/ps3_htp.h | 402 +- .../ps3stor/include/htp_v200/ps3_htp_def.h | 730 ++-- .../ps3stor/include/htp_v200/ps3_htp_dev.h | 451 ++- .../ps3stor/include/htp_v200/ps3_htp_event.h | 73 +- .../ps3stor/include/htp_v200/ps3_htp_ioctl.h | 132 +- .../ps3stor/include/htp_v200/ps3_htp_pci.h | 88 +- .../include/htp_v200/ps3_htp_req_frame_hw.h | 128 +- .../include/htp_v200/ps3_htp_reqframe.h | 473 +-- .../ps3stor/include/htp_v200/ps3_htp_sas.h | 555 ++- .../s1861_regs/s1861_global_baseaddr.h | 14 +- .../s1861_hil_reg0_ps3_register_f_reg.h | 2121 +++++----- .../s1861_hil_reg0_ps3_register_s_reg.h | 57 +- .../s1861_hil_reg0_ps3_request_queue_reg.h | 834 ++-- .../linkdata/ps3stor/include/ps3_define.h | 244 -- .../linkdata/ps3stor/include/ps3_dev_type.h | 98 - .../ps3stor/include/ps3_evtcode_trans.h | 971 ++--- .../ps3stor/include/ps3_htp_dev_info.h | 87 + .../linkdata/ps3stor/include/ps3_htp_meta.h | 126 + .../ps3stor/include/ps3_htp_mgr_evt.h | 15 + .../ps3stor/include/ps3_htp_mgr_evt_raidhba.h | 1869 +++++++++ .../ps3stor/include/ps3_htp_nvme_spec.h | 190 + ...egister_fifo.h => ps3_htp_register_fifo.h} | 46 +- .../ps3stor/include/ps3_htp_trace_id.h | 20 + .../scsi/linkdata/ps3stor/include/ps3_meta.h | 166 - .../linkdata/ps3stor/include/ps3_mgr_evt.h | 198 - .../ps3stor/include/ps3_mgr_evt_common.h | 104 +- .../ps3stor/include/ps3_mgr_evt_raidhba.h | 1509 -------- .../ps3stor/include/ps3_mgr_evt_swexp.h | 477 --- .../linkdata/ps3stor/include/ps3_nvme_spec.h | 2215 ----------- .../linkdata/ps3stor/include/ps3_trace_id.h | 40 - .../scsi/linkdata/ps3stor/include/ps3_types.h | 123 - .../ps3stor/include/ps3lib/ps3lib_event.h | 789 ---- .../scsi/linkdata/ps3stor/linux/ps3_base.c | 1230 +++--- drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c | 162 +- drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h | 21 +- .../linkdata/ps3stor/linux/ps3_cli_debug.c | 3408 +++++++++-------- .../linkdata/ps3stor/linux/ps3_cli_debug.h | 7 +- .../linkdata/ps3stor/linux/ps3_driver_log.c | 626 ++- .../linkdata/ps3stor/linux/ps3_driver_log.h | 894 +++-- .../scsi/linkdata/ps3stor/linux/ps3_dump.c | 544 +-- .../ps3stor/linux/ps3_pcie_err_handle.c | 144 +- .../ps3stor/linux/ps3_pcie_err_handle.h | 8 +- .../scsi/linkdata/ps3stor/ps3_cmd_channel.c | 1051 ++--- .../scsi/linkdata/ps3stor/ps3_cmd_channel.h | 380 +- .../scsi/linkdata/ps3stor/ps3_cmd_complete.c | 305 +- .../scsi/linkdata/ps3stor/ps3_cmd_complete.h | 13 +- .../scsi/linkdata/ps3stor/ps3_cmd_stat_def.h | 205 +- .../linkdata/ps3stor/ps3_cmd_statistics.c | 949 +++-- .../linkdata/ps3stor/ps3_cmd_statistics.h | 459 ++- drivers/scsi/linkdata/ps3stor/ps3_debug.c | 916 +++-- drivers/scsi/linkdata/ps3stor/ps3_debug.h | 169 +- .../linkdata/ps3stor/ps3_device_manager.c | 1819 +++++---- .../linkdata/ps3stor/ps3_device_manager.h | 691 ++-- .../linkdata/ps3stor/ps3_device_manager_sas.c | 1478 +++---- .../linkdata/ps3stor/ps3_device_manager_sas.h | 148 +- .../scsi/linkdata/ps3stor/ps3_device_update.c | 1332 ++++--- .../scsi/linkdata/ps3stor/ps3_device_update.h | 31 +- drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h | 13 +- drivers/scsi/linkdata/ps3stor/ps3_dump.h | 142 +- drivers/scsi/linkdata/ps3stor/ps3_err_def.h | 64 +- .../scsi/linkdata/ps3stor/ps3_err_inject.c | 2489 +++++++----- .../scsi/linkdata/ps3stor/ps3_err_inject.h | 145 +- drivers/scsi/linkdata/ps3stor/ps3_event.c | 1343 ++++--- drivers/scsi/linkdata/ps3stor/ps3_event.h | 38 +- drivers/scsi/linkdata/ps3stor/ps3_inject.c | 695 ++-- drivers/scsi/linkdata/ps3stor/ps3_inject.h | 97 +- .../scsi/linkdata/ps3stor/ps3_inner_data.h | 506 +-- .../linkdata/ps3stor/ps3_instance_manager.c | 476 +-- .../linkdata/ps3stor/ps3_instance_manager.h | 534 +-- drivers/scsi/linkdata/ps3stor/ps3_io_trace.c | 95 +- drivers/scsi/linkdata/ps3stor/ps3_io_trace.h | 23 +- drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c | 373 +- .../scsi/linkdata/ps3stor/ps3_ioc_manager.c | 812 ++-- .../scsi/linkdata/ps3stor/ps3_ioc_manager.h | 927 +++-- drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c | 722 ++-- drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h | 92 +- drivers/scsi/linkdata/ps3stor/ps3_ioctl.c | 565 +-- drivers/scsi/linkdata/ps3stor/ps3_ioctl.h | 29 +- drivers/scsi/linkdata/ps3stor/ps3_irq.c | 1103 +++--- drivers/scsi/linkdata/ps3stor/ps3_irq.h | 109 +- .../linkdata/ps3stor/ps3_kernel_version.h | 290 ++ drivers/scsi/linkdata/ps3stor/ps3_load.c | 316 +- drivers/scsi/linkdata/ps3stor/ps3_load.h | 5 +- .../scsi/linkdata/ps3stor/ps3_mgr_channel.c | 342 +- .../scsi/linkdata/ps3stor/ps3_mgr_channel.h | 27 +- drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c | 1375 +++---- drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h | 94 +- .../scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c | 190 +- .../scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h | 17 +- .../scsi/linkdata/ps3stor/ps3_module_para.c | 560 +-- .../scsi/linkdata/ps3stor/ps3_module_para.h | 127 +- .../linkdata/ps3stor/ps3_nvme_resp_to_scsi.c | 362 +- .../linkdata/ps3stor/ps3_nvme_resp_to_scsi.h | 20 +- drivers/scsi/linkdata/ps3stor/ps3_pci.c | 683 ++-- drivers/scsi/linkdata/ps3stor/ps3_pci.h | 66 +- .../linkdata/ps3stor/ps3_platform_utils.c | 385 +- .../linkdata/ps3stor/ps3_platform_utils.h | 487 +-- drivers/scsi/linkdata/ps3stor/ps3_qos.c | 2931 ++++++++------ drivers/scsi/linkdata/ps3stor/ps3_qos.h | 316 +- .../linkdata/ps3stor/ps3_r1x_write_lock.c | 1529 ++++---- .../linkdata/ps3stor/ps3_r1x_write_lock.h | 57 +- drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c | 1141 +++--- drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h | 406 +- drivers/scsi/linkdata/ps3stor/ps3_recovery.c | 3098 ++++++++------- drivers/scsi/linkdata/ps3stor/ps3_recovery.h | 147 +- .../scsi/linkdata/ps3stor/ps3_sas_transport.c | 717 ++-- .../scsi/linkdata/ps3stor/ps3_sas_transport.h | 26 +- .../scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c | 1025 ++--- .../scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h | 119 +- drivers/scsi/linkdata/ps3stor/ps3_scsih.c | 2844 ++++++++------ drivers/scsi/linkdata/ps3stor/ps3_scsih.h | 150 +- .../linkdata/ps3stor/ps3_scsih_cmd_parse.c | 639 ++-- .../linkdata/ps3stor/ps3_scsih_cmd_parse.h | 147 +- .../linkdata/ps3stor/ps3_scsih_raid_engine.c | 1210 +++--- .../linkdata/ps3stor/ps3_scsih_raid_engine.h | 18 +- .../linkdata/ps3stor/ps3_trace_id_alloc.c | 37 +- .../linkdata/ps3stor/ps3_trace_id_alloc.h | 22 +- drivers/scsi/linkdata/ps3stor/ps3_util.h | 231 +- drivers/scsi/linkdata/ps3stor/ps3_watchdog.c | 261 +- drivers/scsi/linkdata/ps3stor/ps3_watchdog.h | 16 +- 120 files changed, 33525 insertions(+), 32635 deletions(-) delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_define.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_dev_type.h create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h rename drivers/scsi/linkdata/ps3stor/include/{ps3_register_fifo.h => ps3_htp_register_fifo.h} (38%) create mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_meta.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_raidhba.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_swexp.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_nvme_spec.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_trace_id.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3_types.h delete mode 100644 drivers/scsi/linkdata/ps3stor/include/ps3lib/ps3lib_event.h create mode 100644 drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h index 7167a2998215..4fc3d828cd37 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_H_ #define _PS3_HTP_H_ @@ -6,273 +6,273 @@ #include "ps3_htp_dev.h" #include "ps3_htp_req_frame_hw.h" -#define PS3_DUMP_CTRL_COPY_FINISH 0x1 -#define PS3_DUMP_CTRL_DUMP_ABORT 0x2 -#define PS3_DUMP_CTRL_DUMP_FW_LOG 0x3 -#define PS3_DUMP_CTRL_DUMP_BAR_DATA 0x4 -#define PS3_DUMP_CTRL_DUMP_CORE_FILE 0x5 -#define PS3_DUMP_CTRL_DUMP_END 0x6 -#define PS3_DUMP_CTRL_DUMP_INT_READY 0x7 -#define PS3_DUMP_DMA_DONE (0x1) -#define PS3_DUMP_DMA_ABORT (0x1 << 6) -#define PS3_DUMP_DATA_UNIT_SIZE (0x400) -#define PS3_DREICT_SENSE_DATA_BUF_SIZE 72 - -#define PS3_ATU_FLAG_LOW_BITS_MASK (0x0000FFFF) -#define PS3_ATU_FLAG_HIGH_BITS_MASK (0xFFFFFFFFFFFF0000) -#define PS3_ATU_FLAG_DRIVER_SET (0xC0DE) +#define PS3_DUMP_CTRL_COPY_FINISH 0x1 +#define PS3_DUMP_CTRL_DUMP_ABORT 0x2 +#define PS3_DUMP_CTRL_DUMP_FW_LOG 0x3 +#define PS3_DUMP_CTRL_DUMP_BAR_DATA 0x4 +#define PS3_DUMP_CTRL_DUMP_CORE_FILE 0x5 +#define PS3_DUMP_CTRL_DUMP_END 0x6 +#define PS3_DUMP_CTRL_DUMP_INT_READY 0x7 +#define PS3_DUMP_DMA_DONE (0x1) +#define PS3_DUMP_DMA_ABORT (0x1 << 6) +#define PS3_DUMP_DATA_UNIT_SIZE (0x400) +#define PS3_DREICT_SENSE_DATA_BUF_SIZE 72 + +#define PS3_ATU_FLAG_LOW_BITS_MASK (0x0000FFFF) +#define PS3_ATU_FLAG_HIGH_BITS_MASK (0xFFFFFFFFFFFF0000) +#define PS3_ATU_FLAG_DRIVER_SET (0xC0DE) #define PS3_IOCTL_VERSION (0x2000000) -typedef enum{ - HIL_MODEL_SW = 0, - HIL_MODEL_HW, - HIL_MODEL_HW_ENHANCED, - HIL_MODEL_SW_ASSIST, -}hilModel_e; - -enum Ps3DumpType{ - PS3_DUMP_TYPE_UNKNOWN = 0, - PS3_DUMP_TYPE_CRASH = 1, - PS3_DUMP_TYPE_FW_LOG = 2, - PS3_DUMP_TYPE_BAR_DATA = 3, +enum { + HIL_MODEL_SW = 0, + HIL_MODEL_HW, + HIL_MODEL_HW_ENHANCED, + HIL_MODEL_SW_ASSIST, +}; + +enum Ps3DumpType { + PS3_DUMP_TYPE_UNKNOWN = 0, + PS3_DUMP_TYPE_CRASH = 1, + PS3_DUMP_TYPE_FW_LOG = 2, + PS3_DUMP_TYPE_BAR_DATA = 3, }; enum Ps3DumpState { - PS3_DUMP_STATE_INVALID = 0, - PS3_DUMP_STATE_PRE_ABORT, - PS3_DUMP_STATE_ABORTED, - PS3_DUMP_STATE_START, - PS3_DUMP_STATE_COPYING, - PS3_DUMP_STATE_COPY_DONE, - PS3_DUMP_STATE_READY = 7, + PS3_DUMP_STATE_INVALID = 0, + PS3_DUMP_STATE_PRE_ABORT, + PS3_DUMP_STATE_ABORTED, + PS3_DUMP_STATE_START, + PS3_DUMP_STATE_COPYING, + PS3_DUMP_STATE_COPY_DONE, + PS3_DUMP_STATE_READY = 7, }; enum Ps3CtrlSecurityState { - PS3_CTRL_SECURITY_STATE_DECRYPT = 0, - PS3_CTRL_SECURITY_STATE_ENCRYPT, + PS3_CTRL_SECURITY_STATE_DECRYPT = 0, + PS3_CTRL_SECURITY_STATE_ENCRYPT, }; struct Ps3DumpNotifyInfo { - S32 dumpType; + int dumpType; }; struct PS3LinkErrInfo { - U32 invalidDwordCount; - U32 runningDisparityErrCount; - U32 lossOfDwordSyncCount; - U32 phyResetProblemCount; + unsigned int invalidDwordCount; + unsigned int runningDisparityErrCount; + unsigned int lossOfDwordSyncCount; + unsigned int phyResetProblemCount; }; enum PhyCtrl { - PS3_SAS_CTRL_UNKNOWN = 0, - PS3_SAS_CTRL_RESET = 1, - PS3_SAS_CTRL_RESET_HARD = 2, - PS3_SAS_CTRL_DISABLE = 3 + PS3_SAS_CTRL_UNKNOWN = 0, + PS3_SAS_CTRL_RESET = 1, + PS3_SAS_CTRL_RESET_HARD = 2, + PS3_SAS_CTRL_DISABLE = 3 }; enum { PS3_UNLOAD_SUB_TYPE_RESERVED = 0, - PS3_UNLOAD_SUB_TYPE_REMOVE = 1, + PS3_UNLOAD_SUB_TYPE_REMOVE = 1, PS3_UNLOAD_SUB_TYPE_SHUTDOWN = 2, - PS3_UNLOAD_SUB_TYPE_SUSPEND = 3, + PS3_UNLOAD_SUB_TYPE_SUSPEND = 3, }; enum { - PS3_SUSPEND_TYPE_NONE = 0, - PS3_SUSPEND_TYPE_SLEEP = 1, + PS3_SUSPEND_TYPE_NONE = 0, + PS3_SUSPEND_TYPE_SLEEP = 1, PS3_SUSPEND_TYPE_HIBERNATE = 2, }; -static inline const S8 * namePhyCtrl(enum PhyCtrl e) +static inline const char *namePhyCtrl(enum PhyCtrl e) { - static const S8 *myNames[] = { - [PS3_SAS_CTRL_UNKNOWN] = "PS3_SAS_CTRL_UNKNOWN", - [PS3_SAS_CTRL_RESET] = "PS3_SAS_CTRL_RESET", - [PS3_SAS_CTRL_RESET_HARD] = "PS3_SAS_CTRL_RESET_HARD", - [PS3_SAS_CTRL_DISABLE] = "PS3_SAS_CTRL_DISABLE" - }; - - return myNames[e]; + static const char * const myNames[] = { + [PS3_SAS_CTRL_UNKNOWN] = "PS3_SAS_CTRL_UNKNOWN", + [PS3_SAS_CTRL_RESET] = "PS3_SAS_CTRL_RESET", + [PS3_SAS_CTRL_RESET_HARD] = "PS3_SAS_CTRL_RESET_HARD", + [PS3_SAS_CTRL_DISABLE] = "PS3_SAS_CTRL_DISABLE" + }; + + return myNames[e]; } struct PS3InitCmdWord { - union { - struct { - U32 type : 2; - U32 reserved1 : 1; - U32 direct : 2; - U32 reserved2 : 27; - }; - U32 lowAddr; - }; - - U32 highAddr; + union { + struct { + unsigned int type : 2; + unsigned int reserved1 : 1; + unsigned int direct : 2; + unsigned int reserved2 : 27; + }; + unsigned int lowAddr; + }; + + unsigned int highAddr; }; -typedef struct PS3CmdWord { - U16 type : 2; - U16 reserved1 : 2; - U16 direct : 2; - U16 isrSN : 8; - U16 reserved2 : 2; - U16 cmdFrameID : 13; - U16 reserved3 : 3; - U16 phyDiskID : 12; - U16 reserved4 : 4; - U16 virtDiskID : 8; - U16 reserved5 : 4; - U16 qMask : 4; -} PS3CmdWord_s; +struct PS3CmdWord { + unsigned short type : 2; + unsigned short reserved1 : 2; + unsigned short direct : 2; + unsigned short isrSN : 8; + unsigned short reserved2 : 2; + unsigned short cmdFrameID : 13; + unsigned short reserved3 : 3; + unsigned short phyDiskID : 12; + unsigned short reserved4 : 4; + unsigned short virtDiskID : 8; + unsigned short reserved5 : 4; + unsigned short qMask : 4; +}; struct PS3CmdWordSw { - U32 type : 2; - U32 noReplyWord : 1; - U32 cmdFrameID : 13; - U32 isrSN : 8; - U32 cmdIndex : 8; + unsigned int type : 2; + unsigned int noReplyWord : 1; + unsigned int cmdFrameID : 13; + unsigned int isrSN : 8; + unsigned int cmdIndex : 8; }; union PS3CmdWordU32 { struct PS3CmdWordSw cmdWord; - U32 val; + unsigned int val; }; union PS3DefaultCmdWord { - struct PS3CmdWord cmdWord; - union { - struct{ - U32 low; - U32 high; - } u; - U64 words; - }; + struct PS3CmdWord cmdWord; + union { + struct { + unsigned int low; + unsigned int high; + } u; + unsigned long long words; + }; }; -enum{ - PS3_ISR_ACC_MODE_LATENCY = 0, - PS3_ISR_ACC_MODE_SSD_IOPS, - PS3_ISR_ACC_MODE_HDD_IOPS, - PS3_ISR_ACC_MODE_IOPS_VER0 = 2, - PS3_ISR_ACC_MODE_DEV_IOPS, - PS3_ISR_ACC_MODE_MAX, +enum { + PS3_ISR_ACC_MODE_LATENCY = 0, + PS3_ISR_ACC_MODE_SSD_IOPS, + PS3_ISR_ACC_MODE_HDD_IOPS, + PS3_ISR_ACC_MODE_IOPS_VER0 = 2, + PS3_ISR_ACC_MODE_DEV_IOPS, + PS3_ISR_ACC_MODE_MAX, }; struct PS3ReplyFifoDesc { - U64 ReplyFifoBaseAddr; - U32 irqNo; - U16 depthReplyFifo; - U8 isrAccMode; - U8 reserved; + unsigned long long ReplyFifoBaseAddr; + unsigned int irqNo; + unsigned short depthReplyFifo; + unsigned char isrAccMode; + unsigned char reserved; }; -typedef struct PS3ReplyWord { - U16 type : 2; - U16 diskType : 1; - U16 reserved1 : 1; - U16 mode : 2; - U16 reserved2 : 10; - U16 cmdFrameID : 13; - U16 reserved3 : 2; - U16 reserved4 : 1; - U16 retStatus : 15; - U16 retType : 1; - U16 reserved5 : 12; - U16 qMask : 4; -} PS3ReplyWord_s; +struct PS3ReplyWord { + unsigned short type : 2; + unsigned short diskType : 1; + unsigned short reserved1 : 1; + unsigned short mode : 2; + unsigned short reserved2 : 10; + unsigned short cmdFrameID : 13; + unsigned short reserved3 : 2; + unsigned short reserved4 : 1; + unsigned short retStatus : 15; + unsigned short retType : 1; + unsigned short reserved5 : 12; + unsigned short qMask : 4; +}; struct PS3MgrTaskRespInfo { - U8 iocStatus; - U8 reserved1; - U16 iocLogInfo; - U32 terminationCnt; - U32 respInfo; - U32 reserved2; + unsigned char iocStatus; + unsigned char reserved1; + unsigned short iocLogInfo; + unsigned int terminationCnt; + unsigned int respInfo; + unsigned int reserved2; }; struct PS3MgrCmdReplyRespInfo { - U8 cmdReplyStatus; - U8 reserved[15]; + unsigned char cmdReplyStatus; + unsigned char reserved[15]; }; union PS3RespDetails { - U32 xfer_cnt; - U32 respData[4]; - struct PS3MgrTaskRespInfo taskMgrRespInfo; - struct PS3MgrCmdReplyRespInfo replyCmdRespInfo; + unsigned int xfer_cnt; + unsigned int respData[4]; + struct PS3MgrTaskRespInfo taskMgrRespInfo; + struct PS3MgrCmdReplyRespInfo replyCmdRespInfo; +}; + + +struct PS3SasDirectRespStatus { + unsigned int status : 8; + unsigned int dataPres : 2; + unsigned int reserved : 22; }; -typedef struct PS3SasDirectRespStatus { - U32 status:8; - U32 dataPres:2; - U32 reserved:22; -} PS3SasStatus_s; - - -typedef struct Ps3SasDirectRespFrameIU { - union { - U8 reserved0[8]; - U64 mediumErrorLba; - }; - U8 reserved1[2]; - U8 dataPres; - U8 status; - union { - U32 reserved2; - U32 xfer_cnt; - }; - U32 senseDataLen; - U32 respDataLen; - U8 data[PS3_SENSE_BUFFER_SIZE]; - U8 reserved3[8]; -} Ps3SasDirectRespFrameIU_s; - - -typedef struct PS3NormalRespFrame { - union PS3RespDetails respDetail; - U8 reserved1[8]; - U8 sense[PS3_SENSE_BUFFER_SIZE]; - U8 type; - U8 reserved2[3]; - U8 respStatus; - U8 dataPre; - U8 reserved3[2]; -} PS3NormalRespFrame_s; - -typedef union PS3RespFrame{ - Ps3SasDirectRespFrameIU_s sasRespFrame; - PS3NormalRespFrame_s normalRespFrame; -}PS3RespFrame_u; - - -typedef struct Ps3DebugMemEntry { - U64 debugMemAddr; - U32 debugMemSize; - U32 reserved; -} Ps3DebugMemEntry_s; - - -typedef struct PS3NvmeCmdStatus { - union { - struct { - U16 sc : 8; - U16 sct : 3; - U16 crd : 2; - U16 m : 1; - U16 dnr : 1; - U16 p : 1; - }; - U16 cmdStatus; - }; -} PS3NvmeCmdStatus_s; - -#endif +struct Ps3SasDirectRespFrameIU { + union { + unsigned char reserved0[8]; + unsigned long long mediumErrorLba; + }; + unsigned char reserved1[2]; + unsigned char dataPres; + unsigned char status; + union { + unsigned int reserved2; + unsigned int xfer_cnt; + }; + unsigned int senseDataLen; + unsigned int respDataLen; + unsigned char data[PS3_SENSE_BUFFER_SIZE]; + unsigned char reserved3[8]; +}; + + +struct PS3NormalRespFrame { + union PS3RespDetails respDetail; + unsigned char reserved1[8]; + unsigned char sense[PS3_SENSE_BUFFER_SIZE]; + unsigned char type; + unsigned char reserved2[3]; + unsigned char respStatus; + unsigned char dataPre; + unsigned char reserved3[2]; +}; + +union PS3RespFrame { + struct Ps3SasDirectRespFrameIU sasRespFrame; + struct PS3NormalRespFrame normalRespFrame; +}; + + +struct Ps3DebugMemEntry { + unsigned long long debugMemAddr; + unsigned int debugMemSize; + unsigned int reserved; +}; + + +struct PS3NvmeCmdStatus { + union { + struct { + unsigned short sc : 8; + unsigned short sct : 3; + unsigned short crd : 2; + unsigned short m : 1; + unsigned short dnr : 1; + unsigned short p : 1; + }; + unsigned short cmdStatus; + }; +}; + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h index c59080cc7e9e..bff9b17ba26a 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_def.h @@ -1,559 +1,561 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_DEF_H_ #define _PS3_HTP_DEF_H_ -#include "ps3_types.h" - -typedef unsigned char Bool; - #define PCIE_DMA_HOST_ADDR_BIT_POS (44) -#define PCIE_DMA_HOST_ADDR_BIT_POS_SET(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_SET(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS)) | (addr)) -#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR(addr) \ ((~((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS))) & (addr)) #define PCIE_DMA_HOST_ADDR_BIT_POS_F0 (54) #define PCIE_DMA_HOST_ADDR_BIT_POS_F1 (53) #define PCIE_DMA_HOST_ADDR_BIT_POS_VALID (52) -#define PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(bit_pos, addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(bit_pos, addr) \ ((addr) + ((1ULL) << (bit_pos))) -#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, addr) \ +#define PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, addr) \ ((addr) - ((1ULL) << (bit_pos))) enum PS3FWDiagKey { - PS3_FW_DIAG_FLUSH = 0X00, - PS3_FW_DIAG_1ST_KEY = 0x52, - PS3_FW_DIAG_2ND_KEY = 0x5F, - PS3_FW_DIAG_3RD_KEY = 0x55, - PS3_FW_DIAG_4TH_KEY = 0x5F, - PS3_FW_DIAG_5TH_KEY = 0x52, - PS3_FW_DIAG_6TH_KEY = 0x45, - PS3_FW_DIAG_7TH_KEY = 0x41, - PS3_FW_DIAG_8TH_KEY = 0x44, - PS3_FW_DIAG_9TH_KEY = 0x59, + PS3_FW_DIAG_FLUSH = 0X00, + PS3_FW_DIAG_1ST_KEY = 0x52, + PS3_FW_DIAG_2ND_KEY = 0x5F, + PS3_FW_DIAG_3RD_KEY = 0x55, + PS3_FW_DIAG_4TH_KEY = 0x5F, + PS3_FW_DIAG_5TH_KEY = 0x52, + PS3_FW_DIAG_6TH_KEY = 0x45, + PS3_FW_DIAG_7TH_KEY = 0x41, + PS3_FW_DIAG_8TH_KEY = 0x44, + PS3_FW_DIAG_9TH_KEY = 0x59, }; enum PS3FWStateAct { - PS3_FW_STATE_ACT_INIT_READY = 0X00000001, + PS3_FW_STATE_ACT_INIT_READY = 0X00000001, }; enum PS3RegDoorBellType { - PS3_REG_DOORBELL_STATE_TO_READY = 1, - PS3_REG_DOORBELL_STATE_TO_FAULT = 2, - PS3_REG_DOORBELL_STATE_TO_HALT = 3, + PS3_REG_DOORBELL_STATE_TO_READY = 1, + PS3_REG_DOORBELL_STATE_TO_FAULT = 2, + PS3_REG_DOORBELL_STATE_TO_HALT = 3, }; enum PS3FWSoftResetAct { - PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET = 0X00000001, - PS3_FW_STATE_ACT_DEEP_SOFT_RESET = 0X00000002, + PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET = 0X00000001, + PS3_FW_STATE_ACT_DEEP_SOFT_RESET = 0X00000002, }; enum PS3PerfModeType { - PS3_PERF_MODE_BALANCE = 0, - PS3_PERF_MODE_IOPS = 1, - PS3_PERF_MODE_LATENCY = 2, + PS3_PERF_MODE_BALANCE = 0, + PS3_PERF_MODE_IOPS = 1, + PS3_PERF_MODE_LATENCY = 2, }; enum PS3BitPos { - PS3_BIT_POS_DEFAULT = 0, - PS3_BIT_POS_44 = 1, - PS3_BIT_POS_45 = 2, - PS3_BIT_POS_46 = 3, - PS3_BIT_POS_47 = 4, - PS3_BIT_POS_48 = 5, - PS3_BIT_POS_49 = 6, - PS3_BIT_POS_50 = 7, - PS3_BIT_POS_51 = 8, - PS3_BIT_POS_52 = 9, - PS3_BIT_POS_53 = 10, - PS3_BIT_POS_54 = 11, + PS3_BIT_POS_DEFAULT = 0, + PS3_BIT_POS_44 = 1, + PS3_BIT_POS_45 = 2, + PS3_BIT_POS_46 = 3, + PS3_BIT_POS_47 = 4, + PS3_BIT_POS_48 = 5, + PS3_BIT_POS_49 = 6, + PS3_BIT_POS_50 = 7, + PS3_BIT_POS_51 = 8, + PS3_BIT_POS_52 = 9, + PS3_BIT_POS_53 = 10, + PS3_BIT_POS_54 = 11, }; enum PS3CmdType { - PS3_CMD_INIT_IOC = 0x0, - PS3_CMD_VD_SCSI_IO_RW = 0x1, - PS3_CMD_VD_SCSI_IO_NORW = 0x2, - PS3_CMD_PD_SCSI_IO_RW = 0x3, - PS3_CMD_PD_SCSI_IO_NORW = 0x4, - PS3_CMD_MANAGEMENT = 0x5, - PS3_CMD_SCSI_TASK_MANAGEMENT = 0x6, - PS3_CMD_IOCTL = 0x7, - PS3_CMD_SAS_MANAGEMENT = 0x8, - PS3_CMD_COUNT = 0x9, - PS3_CMD_INVALID = 0xff, + PS3_CMD_INIT_IOC = 0x0, + PS3_CMD_VD_SCSI_IO_RW = 0x1, + PS3_CMD_VD_SCSI_IO_NORW = 0x2, + PS3_CMD_PD_SCSI_IO_RW = 0x3, + PS3_CMD_PD_SCSI_IO_NORW = 0x4, + PS3_CMD_MANAGEMENT = 0x5, + PS3_CMD_SCSI_TASK_MANAGEMENT = 0x6, + PS3_CMD_IOCTL = 0x7, + PS3_CMD_SAS_MANAGEMENT = 0x8, + PS3_CMD_COUNT = 0x9, + PS3_CMD_INVALID = 0xff, }; enum { - PS3_SGL = 0x0, - PS3_PRP = 0x1, + PS3_SGL = 0x0, + PS3_PRP = 0x1, }; enum { - PS3_CMD_OPERATOR_TYPE_HOST = 0x0, - PS3_CMD_OPERATOR_TYPE_UEFI = 0x1, - PS3_CMD_OPERATOR_TYPE_IOC = 0x2, + PS3_CMD_OPERATOR_TYPE_HOST = 0x0, + PS3_CMD_OPERATOR_TYPE_UEFI = 0x1, + PS3_CMD_OPERATOR_TYPE_IOC = 0x2, }; enum { - PS3_PCI_IRQ_LEGACY = 0, - PS3_PCI_IRQ_MSI = 1, - PS3_PCI_IRQ_MSIX = 2, + PS3_PCI_IRQ_LEGACY = 0, + PS3_PCI_IRQ_MSI = 1, + PS3_PCI_IRQ_MSIX = 2, }; -#define PS3_DRV_SYSTEM_ID_MAX_LEN 64 -#define PS3_SENSE_BUFFER_SIZE (96) -#define PS3_RESP_FRAME_BUFFER_SIZE (128) +#define PS3_DRV_SYSTEM_ID_MAX_LEN 64 +#define PS3_SENSE_BUFFER_SIZE (96) +#define PS3_RESP_FRAME_BUFFER_SIZE (128) -#define PS3_REQUEST_CONTROL_DIR_NONE 0x00 -#define PS3_REQUEST_CONTROL_DIR_READ 0x01 -#define PS3_REQUEST_CONTROL_DIR_WRITE 0x02 -#define PS3_REQUEST_CONTROL_DIR_BOTH 0x03 +#define PS3_REQUEST_CONTROL_DIR_NONE 0x00 +#define PS3_REQUEST_CONTROL_DIR_READ 0x01 +#define PS3_REQUEST_CONTROL_DIR_WRITE 0x02 +#define PS3_REQUEST_CONTROL_DIR_BOTH 0x03 -#define PS3_MAX_PD_COUNT_IN_SPAN 32 -#define PS3_MAX_SPAN_IN_VD 8 +#define PS3_MAX_PD_COUNT_IN_SPAN 32 +#define PS3_MAX_SPAN_IN_VD 8 -#define PS3_IOC_INIT_STATE_MASK 0xFFFF -#define PS3_IOC_RECOVERY_COUNT_MASK 0xFFFFFFFF +#define PS3_IOC_INIT_STATE_MASK 0xFFFF +#define PS3_IOC_RECOVERY_COUNT_MASK 0xFFFFFFFF -#define PS3_START_STATE_SPACE 0x0100 +#define PS3_START_STATE_SPACE 0x0100 #define PS3_DRV_MGR_FLUSH_RETRY_MAX_COUNT 1 -#define MAX_MGR_CMD_TOTAL_COUNT (16) +#define MAX_MGR_CMD_TOTAL_COUNT (16) -#define PS3_HOT_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG10_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_HOT_RESET_OFFSET \ + (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG10_ADDR - \ + HIL_REG1_PS3_REGISTER_F_BASEADDR) -typedef union HilRegPs3RegisterHotReset{ - U64 val; - struct{ +union HilRegPs3RegisterHotReset { + unsigned long long val; + struct { - U8 isHotReset : 1; - U8 reserved0 : 7; - U8 reserved1[7] ; - }reg; -}HilRegPs3RegisterHotReset_u; + unsigned char isHotReset : 1; + unsigned char reserved0 : 7; + unsigned char reserved1[7]; + } reg; +}; -#define PS3_ATU_SUPPORT_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG8_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_ATU_SUPPORT_OFFSET \ + (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG8_ADDR - \ + HIL_REG1_PS3_REGISTER_F_BASEADDR) -typedef union HilRegPs3RegisterFPs3AtuSupport{ - volatile U64 val; - struct{ +union HilRegPs3RegisterFPs3AtuSupport { + volatile unsigned long long val; + struct { - U8 bitPos ; - U8 reserved[7] ; - }reg; -}HilRegPs3RegisterFPs3AtuSupport_u; + unsigned char bitPos; + unsigned char reserved[7]; + } reg; +}; -#define PS3_CAN_HARD_RESET_OFFSET (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG9_ADDR - HIL_REG1_PS3_REGISTER_F_BASEADDR) +#define PS3_CAN_HARD_RESET_OFFSET \ + (HIL_REG1_PS3_REGISTER_F_PS3_DEBUG9_ADDR - \ + HIL_REG1_PS3_REGISTER_F_BASEADDR) -typedef union HilRegPs3RegisterFPs3CanHardReset{ - volatile U64 val; - struct{ +union HilRegPs3RegisterFPs3CanHardReset { + volatile unsigned long long val; + struct { - U8 canHardReset : 1; - U8 reserved0 : 7; - U8 reserved1[7] ; - }reg; -}HilRegPs3RegisterFPs3CanHardReset_u; + unsigned char canHardReset : 1; + unsigned char reserved0 : 7; + unsigned char reserved1[7]; + } reg; +}; -typedef enum PS3FWRunState { - PS3_FW_STATE_UNDEFINED = 0x00, - PS3_FW_STATE_START = 0x01, - PS3_FW_STATE_READY = 0x02, - PS3_FW_STATE_WAIT = 0x03, - PS3_FW_STATE_RUNNING = 0x04, - PS3_FW_STATE_FLUSHING = 0x05, - PS3_FW_STATE_RESET = 0x06, - PS3_FW_STATE_CRITICAL = 0x09, - PS3_FW_STATE_FAULT = 0xE0, - PS3_FW_STATE_HALT = 0xF0, - PS3_FW_STATE_END, - PS3_FW_STATE_MASK = 0xFF, - PS3_FW_STATE_WDT_MASK = 0xFF0000FF, -}PS3FWRunState_e; +enum PS3FWRunState { + PS3_FW_STATE_UNDEFINED = 0x00, + PS3_FW_STATE_START = 0x01, + PS3_FW_STATE_READY = 0x02, + PS3_FW_STATE_WAIT = 0x03, + PS3_FW_STATE_RUNNING = 0x04, + PS3_FW_STATE_FLUSHING = 0x05, + PS3_FW_STATE_RESET = 0x06, + PS3_FW_STATE_CRITICAL = 0x09, + PS3_FW_STATE_FAULT = 0xE0, + PS3_FW_STATE_HALT = 0xF0, + PS3_FW_STATE_END, + PS3_FW_STATE_MASK = 0xFF, + PS3_FW_STATE_WDT_MASK = 0xFF0000FF, +}; -typedef enum PS3FWStartState { - PS3_START_STATE_UNDEFINED = 0x0000, - PS3_START_STATE_INIT_BASE = 0x0100, - PS3_START_STATE_INIT_HARDWARE = 0x0200, - PS3_START_STATE_INIT_SOFTWARE = 0x0300, - PS3_START_STATE_INIT_DATAPATH = 0x0400, - PS3_START_STATE_INIT_THREAD = 0x0500, - PS3_START_STATE_SCAN_DEVICE = 0x0600, - PS3_START_STATE_FLUSH_CACHE = 0x0700, - PS3_START_STATE_INIT_RESET = 0x0800, - PS3_START_STATE_FINISHED = 0x0900, - PS3_START_STATE_MASK = 0xFF00, - PS3_START_STATE_WDT_MASK = 0xFF00FF00, -}PS3FWStartState_e; +enum PS3FWStartState { + PS3_START_STATE_UNDEFINED = 0x0000, + PS3_START_STATE_INIT_BASE = 0x0100, + PS3_START_STATE_INIT_HARDWARE = 0x0200, + PS3_START_STATE_INIT_SOFTWARE = 0x0300, + PS3_START_STATE_INIT_DATAPATH = 0x0400, + PS3_START_STATE_INIT_THREAD = 0x0500, + PS3_START_STATE_SCAN_DEVICE = 0x0600, + PS3_START_STATE_FLUSH_CACHE = 0x0700, + PS3_START_STATE_INIT_RESET = 0x0800, + PS3_START_STATE_FINISHED = 0x0900, + PS3_START_STATE_MASK = 0xFF00, + PS3_START_STATE_WDT_MASK = 0xFF00FF00, +}; -#define PS3_FW_RESET_FLAG (0X00000001) -#define PS3_FW_DIAG_ENABLE (0X00000001) -#define PS3_FW_HARD_RESET_ACT (0X00000001) +#define PS3_FW_RESET_FLAG (0X00000001) +#define PS3_FW_DIAG_ENABLE (0X00000001) +#define PS3_FW_HARD_RESET_ACT (0X00000001) -#define PS3_FW_MAX_CMD_MASK (0X0000FFFF) -#define PS3_FW_MAX_MSIX_VECTORS_MASK (0X0000FFFF) -#define PS3_FW_MAX_CHAIN_SIZE_MASK (0XFFFFFFFF) -#define PS3_FW_MAX_RAID_MAP_SIZE_MASK (0XFFFFFFFF) -#define PS3_FW_MAX_NVME_PAGE_SIZE_MASK (0xFFFFFFFF) +#define PS3_FW_MAX_CMD_MASK (0X0000FFFF) +#define PS3_FW_MAX_MSIX_VECTORS_MASK (0X0000FFFF) +#define PS3_FW_MAX_CHAIN_SIZE_MASK (0XFFFFFFFF) +#define PS3_FW_MAX_RAID_MAP_SIZE_MASK (0XFFFFFFFF) +#define PS3_FW_MAX_NVME_PAGE_SIZE_MASK (0xFFFFFFFF) -#define PS3_FW_INTERRUPT_STATUS_MASK (0X00000001) -#define PS3_FW_INTERRUPT_CMD_INTR_CAP_MASK (0X00000004) -#define PS3_FW_INTERRUPT_CMD_MSI_CAP_MASK (0X00000002) -#define PS3_FW_INTERRUPT_CMD_MSIX_CAP_MASK (0X00000001) -#define PS3_FW_INTERRUPT_CLEAR_MASK (0X00000001) +#define PS3_FW_INTERRUPT_STATUS_MASK (0X00000001) +#define PS3_FW_INTERRUPT_CMD_INTR_CAP_MASK (0X00000004) +#define PS3_FW_INTERRUPT_CMD_MSI_CAP_MASK (0X00000002) +#define PS3_FW_INTERRUPT_CMD_MSIX_CAP_MASK (0X00000001) +#define PS3_FW_INTERRUPT_CLEAR_MASK (0X00000001) enum PS3FWFeatureSupportMask { - PS3_FW_FEATURE_SUPPORT_SYNC_CACHE = 0X00000001, - PS3_FW_FEATURE_SUPPORT_DMA64 = 0X00000002, + PS3_FW_FEATURE_SUPPORT_SYNC_CACHE = 0X00000001, + PS3_FW_FEATURE_SUPPORT_DMA64 = 0X00000002, }; enum PS3FWCtrlMask { - PS3_FW_CTRL_CMD_TRIGGER_SNAPSHOT = 0X00000001, - PS3_FW_CTRL_CMD_CRASHDUMP_COLLECTION_DONE = 0X00000002, - PS3_FW_CTRL_CMD_CRASHDUMP_DMA_CLEAR = 0X00000004, + PS3_FW_CTRL_CMD_TRIGGER_SNAPSHOT = 0X00000001, + PS3_FW_CTRL_CMD_CRASHDUMP_COLLECTION_DONE = 0X00000002, + PS3_FW_CTRL_CMD_CRASHDUMP_DMA_CLEAR = 0X00000004, }; enum PS3FWCtrlStatusMask { - PS3_FW_CTRL_STATUS_CRASHDUMP_DONE = 0X00000001, - PS3_FW_CTRL_STATUS_RSVR = 0X00000002, - PS3_FW_CTRL_STATUS_CRASHDUMP_MAP = 0X00000004, + PS3_FW_CTRL_STATUS_CRASHDUMP_DONE = 0X00000001, + PS3_FW_CTRL_STATUS_RSVR = 0X00000002, + PS3_FW_CTRL_STATUS_CRASHDUMP_MAP = 0X00000004, }; enum PS3CmdTrigger { - PS3_CMD_TRIGGER_UNLOAD = 0X0001, - PS3_CMD_TRIGGER_UNLOAD_SUSPEND = 0X0002, + PS3_CMD_TRIGGER_UNLOAD = 0X0001, + PS3_CMD_TRIGGER_UNLOAD_SUSPEND = 0X0002, }; enum PS3RegCmdState { - PS3_DOORBELL_DONE = 0X0001, + PS3_DOORBELL_DONE = 0X0001, }; enum PS3Debug12Mask { - PS3_DEBUG12__HOT_RESET = 0X00000001, + PS3_DEBUG12__HOT_RESET = 0X00000001, }; enum PS3MgrControlFlag { - PS3_REQUEST_CONTROL_SKIP_REFIRE = 0x0, - PS3_REQUEST_CONTROL_SENSE32 = 0x1, - PS3_REQUEST_CONTROL_SENSE64 = 0x2, + PS3_REQUEST_CONTROL_SKIP_REFIRE = 0x0, + PS3_REQUEST_CONTROL_SENSE32 = 0x1, + PS3_REQUEST_CONTROL_SENSE64 = 0x2, }; enum PS3TaskCmdSubType { - PS3_TASK_CMD_SCSI_TASK_ABORT, - PS3_TASK_CMD_SCSI_TASK_RESET, - PS3_TASK_CMD_COUNT, + PS3_TASK_CMD_SCSI_TASK_ABORT, + PS3_TASK_CMD_SCSI_TASK_RESET, + PS3_TASK_CMD_COUNT, - PS3_TASK_CMD_INVALID = 0xffff, + PS3_TASK_CMD_INVALID = 0xffff, }; - enum PS3MgrCmdSubType { - PS3_MGR_CMD_GET_CTRL_INFO = 0x0, - PS3_MGR_CMD_UNLOAD, - PS3_MGR_CMD_SUBSCRIBE_EVENT, - PS3_MGR_CMD_GET_VD_LIST, - PS3_MGR_CMD_GET_PD_LIST, - PS3_MGR_CMD_GET_VD_INFO, - PS3_MGR_CMD_GET_PD_INFO, - PS3_MGR_CMD_GET_BOOTDRIVE_INFO, - PS3_MGR_CMD_GET_BIOS_INFO, - - PS3_MGR_CMD_GET_SNAPSHOT_ATTR, - PS3_MGR_CMD_SET_CRASH_DUMP, - PS3_MGR_CMD_CANCEL, - PS3_MGR_CMD_ABORT, - PS3_MGR_CMD_DEV_ADD_ACK, - PS3_MGR_CMD_DEV_DEL_DONE, - - PS3_SAS_SMP_REQUEST, - PS3_SAS_GET_LINK_ERR, - PS3_SAS_PHY_CTRL, - PS3_SAS_GET_EXPANDERS, - PS3_SAS_GET_PHY_INFO, - PS3_SAS_GET_EXPANDER_INFO, - - PS3_MGR_CMD_AUTODUMP_NOTIFY, - - PS3_MGR_CMD_SECURITY_RANDOM_GET, - PS3_MGR_CMD_SECURITY_PASSWORD, - PS3_MGR_CMD_WEBSUBSCRIBE_EVENT, - - PS3_MGR_CMD_PRESERVED_INFO_GET, - PS3_MGR_CMD_GET_PD_SN_LIST, - PS3_MGR_CMD_PD_REF_CLEAR, - PS3_MGR_CMD_COUNT, - PS3_MGR_CMD_INVALID = 0xff -}; - -static inline const S8 * namePS3MgrCmdSubType(enum PS3MgrCmdSubType type) + PS3_MGR_CMD_GET_CTRL_INFO = 0x0, + PS3_MGR_CMD_UNLOAD, + PS3_MGR_CMD_SUBSCRIBE_EVENT, + PS3_MGR_CMD_GET_VD_LIST, + PS3_MGR_CMD_GET_PD_LIST, + PS3_MGR_CMD_GET_VD_INFO, + PS3_MGR_CMD_GET_PD_INFO, + PS3_MGR_CMD_GET_BOOTDRIVE_INFO, + PS3_MGR_CMD_GET_BIOS_INFO, + + PS3_MGR_CMD_GET_SNAPSHOT_ATTR, + PS3_MGR_CMD_SET_CRASH_DUMP, + PS3_MGR_CMD_CANCEL, + PS3_MGR_CMD_ABORT, + PS3_MGR_CMD_DEV_ADD_ACK, + PS3_MGR_CMD_DEV_DEL_DONE, + + PS3_SAS_SMP_REQUEST, + PS3_SAS_GET_LINK_ERR, + PS3_SAS_PHY_CTRL, + PS3_SAS_GET_EXPANDERS, + PS3_SAS_GET_PHY_INFO, + PS3_SAS_GET_EXPANDER_INFO, + + PS3_MGR_CMD_AUTODUMP_NOTIFY, + + PS3_MGR_CMD_SECURITY_RANDOM_GET, + PS3_MGR_CMD_SECURITY_PASSWORD, + PS3_MGR_CMD_WEBSUBSCRIBE_EVENT, + + PS3_MGR_CMD_PRESERVED_INFO_GET, + PS3_MGR_CMD_GET_PD_SN_LIST, + PS3_MGR_CMD_PD_REF_CLEAR, + PS3_MGR_CMD_COUNT, + PS3_MGR_CMD_INVALID = 0xff +}; + +static inline const char *namePS3MgrCmdSubType(enum PS3MgrCmdSubType type) { - static const S8 *myNames[] = { - [PS3_MGR_CMD_GET_CTRL_INFO] = "PS3_MGR_CMD_GET_CTRL_INFO", - [PS3_MGR_CMD_UNLOAD] = "PS3_MGR_CMD_UNLOAD", - [PS3_MGR_CMD_SUBSCRIBE_EVENT] = "PS3_MGR_CMD_SUBSCRIBE_EVENT", - [PS3_MGR_CMD_GET_VD_LIST] = "PS3_MGR_CMD_GET_VD_LIST", - [PS3_MGR_CMD_GET_PD_LIST] = "PS3_MGR_CMD_GET_PD_LIST", - [PS3_MGR_CMD_GET_VD_INFO] = "PS3_MGR_CMD_GET_VD_INFO", - [PS3_MGR_CMD_GET_PD_INFO] = "PS3_MGR_CMD_GET_PD_INFO", - [PS3_MGR_CMD_GET_BOOTDRIVE_INFO] = "PS3_MGR_CMD_GET_BOOTDRIVE_INFO", - [PS3_MGR_CMD_GET_BIOS_INFO] = "PS3_MGR_CMD_GET_BIOS_INFO", - - [PS3_MGR_CMD_GET_SNAPSHOT_ATTR] = "PS3_MGR_CMD_GET_SNAPSHOT_ATTR", - [PS3_MGR_CMD_SET_CRASH_DUMP] = "PS3_MGR_CMD_SET_CRASH_DUMP", - [PS3_MGR_CMD_CANCEL] = "PS3_MGR_CMD_CANCEL", - [PS3_MGR_CMD_ABORT] = "PS3_MGR_CMD_ABORT", - [PS3_MGR_CMD_DEV_ADD_ACK] = "PS3_MGR_CMD_DEV_ADD_ACK", - [PS3_MGR_CMD_DEV_DEL_DONE] = "PS3_MGR_CMD_DEV_DEL_DONE", - - [PS3_SAS_SMP_REQUEST] = "PS3_SAS_SMP_REQUEST", - [PS3_SAS_GET_LINK_ERR] = "PS3_SAS_GET_LINK_ERR", - [PS3_SAS_PHY_CTRL] = "PS3_SAS_PHY_CTRL", - [PS3_SAS_GET_EXPANDERS] = "PS3_SAS_GET_EXPANDERS", - [PS3_SAS_GET_PHY_INFO] = "PS3_SAS_GET_PHY_INFO", - [PS3_SAS_GET_EXPANDER_INFO] = "PS3_SAS_GET_EXPANDER_INFO", - [PS3_MGR_CMD_AUTODUMP_NOTIFY] = "PS3_MGR_CMD_AUTODUMP_NOTIFY", - - [PS3_MGR_CMD_SECURITY_RANDOM_GET] = "PS3_MGR_CMD_SECURITY_RANDOM_GET", - [PS3_MGR_CMD_SECURITY_PASSWORD] = "PS3_MGR_CMD_SECURITY_PASSWORD", - [PS3_MGR_CMD_WEBSUBSCRIBE_EVENT] = "PS3_MGR_CMD_WEBSUBSCRIBE_EVENT", - - [PS3_MGR_CMD_PRESERVED_INFO_GET] = "PS3_MGR_CMD_PRESERVED_INFO_GET", - [PS3_MGR_CMD_GET_PD_SN_LIST] = "PS3_MGR_CMD_GET_PD_SN_LIST", - [PS3_MGR_CMD_PD_REF_CLEAR] = "PS3_MGR_CMD_PD_REF_CLEAR", - [PS3_MGR_CMD_COUNT] = "PS3_MGR_CMD_INVALID", - }; - - if (type < PS3_MGR_CMD_COUNT && type < (sizeof(myNames) / sizeof(myNames[0]))) { + static const char * const myNames[] = { + [PS3_MGR_CMD_GET_CTRL_INFO] = "PS3_MGR_CMD_GET_CTRL_INFO", + [PS3_MGR_CMD_UNLOAD] = "PS3_MGR_CMD_UNLOAD", + [PS3_MGR_CMD_SUBSCRIBE_EVENT] = "PS3_MGR_CMD_SUBSCRIBE_EVENT", + [PS3_MGR_CMD_GET_VD_LIST] = "PS3_MGR_CMD_GET_VD_LIST", + [PS3_MGR_CMD_GET_PD_LIST] = "PS3_MGR_CMD_GET_PD_LIST", + [PS3_MGR_CMD_GET_VD_INFO] = "PS3_MGR_CMD_GET_VD_INFO", + [PS3_MGR_CMD_GET_PD_INFO] = "PS3_MGR_CMD_GET_PD_INFO", + [PS3_MGR_CMD_GET_BOOTDRIVE_INFO] = + "PS3_MGR_CMD_GET_BOOTDRIVE_INFO", + [PS3_MGR_CMD_GET_BIOS_INFO] = "PS3_MGR_CMD_GET_BIOS_INFO", + + [PS3_MGR_CMD_GET_SNAPSHOT_ATTR] = + "PS3_MGR_CMD_GET_SNAPSHOT_ATTR", + [PS3_MGR_CMD_SET_CRASH_DUMP] = "PS3_MGR_CMD_SET_CRASH_DUMP", + [PS3_MGR_CMD_CANCEL] = "PS3_MGR_CMD_CANCEL", + [PS3_MGR_CMD_ABORT] = "PS3_MGR_CMD_ABORT", + [PS3_MGR_CMD_DEV_ADD_ACK] = "PS3_MGR_CMD_DEV_ADD_ACK", + [PS3_MGR_CMD_DEV_DEL_DONE] = "PS3_MGR_CMD_DEV_DEL_DONE", + + [PS3_SAS_SMP_REQUEST] = "PS3_SAS_SMP_REQUEST", + [PS3_SAS_GET_LINK_ERR] = "PS3_SAS_GET_LINK_ERR", + [PS3_SAS_PHY_CTRL] = "PS3_SAS_PHY_CTRL", + [PS3_SAS_GET_EXPANDERS] = "PS3_SAS_GET_EXPANDERS", + [PS3_SAS_GET_PHY_INFO] = "PS3_SAS_GET_PHY_INFO", + [PS3_SAS_GET_EXPANDER_INFO] = "PS3_SAS_GET_EXPANDER_INFO", + [PS3_MGR_CMD_AUTODUMP_NOTIFY] = "PS3_MGR_CMD_AUTODUMP_NOTIFY", + + [PS3_MGR_CMD_SECURITY_RANDOM_GET] = + "PS3_MGR_CMD_SECURITY_RANDOM_GET", + [PS3_MGR_CMD_SECURITY_PASSWORD] = + "PS3_MGR_CMD_SECURITY_PASSWORD", + [PS3_MGR_CMD_WEBSUBSCRIBE_EVENT] = + "PS3_MGR_CMD_WEBSUBSCRIBE_EVENT", + + [PS3_MGR_CMD_PRESERVED_INFO_GET] = + "PS3_MGR_CMD_PRESERVED_INFO_GET", + [PS3_MGR_CMD_GET_PD_SN_LIST] = "PS3_MGR_CMD_GET_PD_SN_LIST", + [PS3_MGR_CMD_PD_REF_CLEAR] = "PS3_MGR_CMD_PD_REF_CLEAR", + [PS3_MGR_CMD_COUNT] = "PS3_MGR_CMD_INVALID", + }; + + if (type < PS3_MGR_CMD_COUNT && type < ARRAY_SIZE(myNames)) return myNames[type]; - } return "PS3_MGR_CMD_INVALID"; - } enum PS3CmdIocErrCode { - PS3_IOC_ERR_CODE_OK = 0x00, - PS3_IOC_ERR_CODE_ERR = 0x01, - PS3_IOC_STATE_INVALID_STATUS = 0xFFFF, -}; - -typedef enum PS3CmdStatusCode { - SCSI_STATUS_GOOD = 0x00, - SCSI_STATUS_CHECK_CONDITION = 0x02, - SCSI_STATUS_CONDITION_MET = 0x04, - SCSI_STATUS_BUSY = 0x08, - SCSI_STATUS_RESERVATION_CONFLICT = 0x18, - SCSI_STATUS_TASK_SET_FULL = 0x28, - SCSI_STATUS_ACA_ACTIVE = 0x30, - SCSI_STATUS_TASK_ABORTED = 0x40, - - PS3_STATUS_DEVICE_NOT_FOUND = 0x80, - PS3_STATUS_IO_ABORTED = 0x81, - PS3_STATUS_REQ_ILLEGAL = 0x82, - PS3_STATUS_RESET_FAIL = 0x83, - PS3_STATUS_VD_OFFLINE = 0x84, - PS3_STATUS_ACCESS_BLOCK = 0x85, - PS3_STATUS_INTERNAL_SOFT_ERR = 0x86, - PS3_STATUS_INTERNAL_ERR = 0x87, - PS3_STATUS_HOST_NOT_FOUND = 0x88, - PS3_STATUS_HOST_RESET = 0x89, - PS3_STATUS_PCI_RECOVERY = 0x8A, - PS3_STATUS_VD_MEMBER_OFFLINE = 0x8B, - PS3_STATUS_UNDERRUN = 0x8C, - PS3_STATUS_OVERRUN = 0x8D, - PS3_STATUS_DIF_GRD_ERROR = 0x8E, - PS3_STATUS_DIF_REF_ERROR = 0x8F, - PS3_STATUS_DIF_APP_ERROR = 0x90, - PS3_STATUS_ACCESS_RO = 0x91, -} PS3CmdStatusCode_e; + PS3_IOC_ERR_CODE_OK = 0x00, + PS3_IOC_ERR_CODE_ERR = 0x01, + PS3_IOC_STATE_INVALID_STATUS = 0xFFFF, +}; + +enum PS3CmdStatusCode { + SCSI_STATUS_GOOD = 0x00, + SCSI_STATUS_CHECK_CONDITION = 0x02, + SCSI_STATUS_CONDITION_MET = 0x04, + SCSI_STATUS_BUSY = 0x08, + SCSI_STATUS_RESERVATION_CONFLICT = 0x18, + SCSI_STATUS_TASK_SET_FULL = 0x28, + SCSI_STATUS_ACA_ACTIVE = 0x30, + SCSI_STATUS_TASK_ABORTED = 0x40, + + PS3_STATUS_DEVICE_NOT_FOUND = 0x80, + PS3_STATUS_IO_ABORTED = 0x81, + PS3_STATUS_REQ_ILLEGAL = 0x82, + PS3_STATUS_RESET_FAIL = 0x83, + PS3_STATUS_VD_OFFLINE = 0x84, + PS3_STATUS_ACCESS_BLOCK = 0x85, + PS3_STATUS_INTERNAL_SOFT_ERR = 0x86, + PS3_STATUS_INTERNAL_ERR = 0x87, + PS3_STATUS_HOST_NOT_FOUND = 0x88, + PS3_STATUS_HOST_RESET = 0x89, + PS3_STATUS_PCI_RECOVERY = 0x8A, + PS3_STATUS_VD_MEMBER_OFFLINE = 0x8B, + PS3_STATUS_UNDERRUN = 0x8C, + PS3_STATUS_OVERRUN = 0x8D, + PS3_STATUS_DIF_GRD_ERROR = 0x8E, + PS3_STATUS_DIF_REF_ERROR = 0x8F, + PS3_STATUS_DIF_APP_ERROR = 0x90, + PS3_STATUS_ACCESS_RO = 0x91, +}; enum PS3CmdWordType { - PS3_CMDWORD_TYPE_INIT = 0x00, - PS3_CMDWORD_TYPE_ABORT = 0x00, - PS3_CMDWORD_TYPE_MGR = 0x01, - PS3_CMDWORD_TYPE_READ = 0x02, - PS3_CMDWORD_TYPE_WRITE = 0x03, + PS3_CMDWORD_TYPE_INIT = 0x00, + PS3_CMDWORD_TYPE_ABORT = 0x00, + PS3_CMDWORD_TYPE_MGR = 0x01, + PS3_CMDWORD_TYPE_READ = 0x02, + PS3_CMDWORD_TYPE_WRITE = 0x03, }; -#define PS3_CMD_TYPE_IS_RW(type) \ +#define PS3_CMD_TYPE_IS_RW(type) \ ((type) == PS3_CMDWORD_TYPE_READ || (type) == PS3_CMDWORD_TYPE_WRITE) enum PS3ReqFrameCtrl { - PS3_DATA_BUF_SGL = 0x00, + PS3_DATA_BUF_SGL = 0x00, - PS3_DATA_BUF_PRP = 0x02, + PS3_DATA_BUF_PRP = 0x02, }; enum PS3CmdWordDirect { - PS3_CMDWORD_DIRECT_NORMAL = 0x00, - PS3_CMDWORD_DIRECT_RESERVE = 0x01, - PS3_CMDWORD_DIRECT_OK = 0x02, - PS3_CMDWORD_DIRECT_ADVICE = 0x03, + PS3_CMDWORD_DIRECT_NORMAL = 0x00, + PS3_CMDWORD_DIRECT_RESERVE = 0x01, + PS3_CMDWORD_DIRECT_OK = 0x02, + PS3_CMDWORD_DIRECT_ADVICE = 0x03, }; enum PS3CmdWordPort { - PS3_CMDWORD_PORT_SAS0 = 0x00, - PS3_CMDWORD_PORT_SAS1 = 0x01, - PS3_CMDWORD_PORT_NVME = 0x02, - PS3_CMDWORD_PORT_RESERVE = 0x03, + PS3_CMDWORD_PORT_SAS0 = 0x00, + PS3_CMDWORD_PORT_SAS1 = 0x01, + PS3_CMDWORD_PORT_NVME = 0x02, + PS3_CMDWORD_PORT_RESERVE = 0x03, }; enum PS3CmdWordFormat { - PS3_CMDWORD_FORMAT_FRONTEND = 0x00, - PS3_CMDWORD_FORMAT_HARDWARE = 0x01, + PS3_CMDWORD_FORMAT_FRONTEND = 0x00, + PS3_CMDWORD_FORMAT_HARDWARE = 0x01, }; enum PS3ReplyWordFlag { - PS3_REPLY_WORD_FLAG_SUCCESS = 0x00, - PS3_REPLY_WORD_FLAG_FAIL = 0X01, - PS3_REPLY_WORD_FLAG_REPEAT_REPLY = 0x0F, - PS3_REPLY_WORD_FLAG_INVALID = 0X7FFF, + PS3_REPLY_WORD_FLAG_SUCCESS = 0x00, + PS3_REPLY_WORD_FLAG_FAIL = 0X01, + PS3_REPLY_WORD_FLAG_REPEAT_REPLY = 0x0F, + PS3_REPLY_WORD_FLAG_INVALID = 0X7FFF, }; enum PS3ReplyWordMask { - PS3_REPLY_WORD_MASK_FLAG = 0X7FFF, + PS3_REPLY_WORD_MASK_FLAG = 0X7FFF, }; -enum PS3ReplyWordMode{ - PS3_REPLY_WORD_MODE_NORMAL = 0x00, - PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_NORMAL = 0X01, - PS3_REPLY_WORD_MODE_DIRECT_OK = 0X02, - PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT = 0X03, +enum PS3ReplyWordMode { + PS3_REPLY_WORD_MODE_NORMAL = 0x00, + PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_NORMAL = 0X01, + PS3_REPLY_WORD_MODE_DIRECT_OK = 0X02, + PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT = 0X03, }; -enum PS3RetType{ - PS3_NOT_HARD_RET = 0x00, - PS3_HARD_RET = 0X01, +enum PS3RetType { + PS3_NOT_HARD_RET = 0x00, + PS3_HARD_RET = 0X01, }; enum PS3CmdWordVer { - PS3_CMDWORD_VER_0 = 0x0, - PS3_CMDWORD_VER_1 = 0x1, - PS3_CMDWORD_VER_UPDATING = 0x2, - PS3_CMDWORD_VER_INVALID = 0x3, + PS3_CMDWORD_VER_0 = 0x0, + PS3_CMDWORD_VER_1 = 0x1, + PS3_CMDWORD_VER_UPDATING = 0x2, + PS3_CMDWORD_VER_INVALID = 0x3, }; enum PS3CmdWordNoReplyWord { - PS3_CMD_WORD_NEED_REPLY_WORD = 0, - PS3_CMD_WORD_NO_REPLY_WORD = 1, + PS3_CMD_WORD_NEED_REPLY_WORD = 0, + PS3_CMD_WORD_NO_REPLY_WORD = 1, }; enum PS3ChannelType { - PS3_CHAN_TYPE_UNKNOWN = 0, - PS3_CHAN_TYPE_VD = 1, - PS3_CHAN_TYPE_PD = 2, + PS3_CHAN_TYPE_UNKNOWN = 0, + PS3_CHAN_TYPE_VD = 1, + PS3_CHAN_TYPE_PD = 2, }; enum PS3DiskType { - PS3_DISK_TYPE_UNKNOWN = 0, - PS3_DISK_TYPE_VD = 1, - PS3_DISK_TYPE_PD = 2, + PS3_DISK_TYPE_UNKNOWN = 0, + PS3_DISK_TYPE_VD = 1, + PS3_DISK_TYPE_PD = 2, }; -#define PS3_CONTROL_PAGE_TYPE_BIT_OFFSET (0x1) -#define PS3_CONTROL_PAGE_TYPE_BIT_NUM (0x1) -#define PS3_CONTROL_PAGE_TYPE_MASK (0x1) +#define PS3_CONTROL_PAGE_TYPE_BIT_OFFSET (0x1) +#define PS3_CONTROL_PAGE_TYPE_BIT_NUM (0x1) +#define PS3_CONTROL_PAGE_TYPE_MASK (0x1) enum PS3PageType { - PS3_CONTROL_PAGE_TYPE_OF_SGE = 0, - PS3_CONTROL_PAGE_TYPE_OF_PRP = 1, - PS3_CONTROL_PAGE_TYPE_MAX = 2, + PS3_CONTROL_PAGE_TYPE_OF_SGE = 0, + PS3_CONTROL_PAGE_TYPE_OF_PRP = 1, + PS3_CONTROL_PAGE_TYPE_MAX = 2, }; -static inline const S8 * namePS3DiskType(enum PS3DiskType e) +static inline const char *namePS3DiskType(enum PS3DiskType e) { - static const S8 *myNames[] = { - [PS3_DISK_TYPE_UNKNOWN] = "PS3_DISK_TYPE_UNKNOWN", - [PS3_DISK_TYPE_VD] = "PS3_DISK_TYPE_VD", - [PS3_DISK_TYPE_PD] = "PS3_DISK_TYPE_PD" - }; + static const char * const myNames[] = { + [PS3_DISK_TYPE_UNKNOWN] = "PS3_DISK_TYPE_UNKNOWN", + [PS3_DISK_TYPE_VD] = "PS3_DISK_TYPE_VD", + [PS3_DISK_TYPE_PD] = "PS3_DISK_TYPE_PD" + }; - return myNames[e]; + return myNames[e]; } -static inline const S8 * namePS3ChannelType(enum PS3ChannelType e) +static inline const char *namePS3ChannelType(enum PS3ChannelType e) { - static const S8 *myNames[] = { - [PS3_CHAN_TYPE_UNKNOWN] = "PS3_CHAN_TYPE_UNKNOWN", - [PS3_CHAN_TYPE_VD] = "PS3_CHAN_TYPE_VD", - [PS3_CHAN_TYPE_PD] = "PS3_CHAN_TYPE_PD" - }; + static const char * const myNames[] = { + [PS3_CHAN_TYPE_UNKNOWN] = "PS3_CHAN_TYPE_UNKNOWN", + [PS3_CHAN_TYPE_VD] = "PS3_CHAN_TYPE_VD", + [PS3_CHAN_TYPE_PD] = "PS3_CHAN_TYPE_PD" + }; - return myNames[e]; + return myNames[e]; } - enum PS3DrvMgrErrorCode { - PS3_DRV_MGR_TIMEOUT = 1, - PS3_DRV_MGR_UNRUNING, - PS3_DRV_MGR_INVAL_CMD, - PS3_DRV_MGR_NORESOURCE, - PS3_DRV_MGR_INVAL_PARAM, - PS3_DRV_MGR_DEV_NOEXIST, - PS3_DRV_MGR_DEV_DATA_ERR, - PS3_DRV_MGR_BUSY, - PS3_DRV_MGR_EVT_REPEAT, - PS3_DRV_MGR_EVT_CANCLE_ERR, - PS3_DRV_MGR_FLUSH_FAIELD, - PS3_DRV_MGR_SMP_BACKEND_ERR, - PS3_DRV_MGR_LINK_GET_BACKEND_ERR, - PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, - PS3_DRV_MGR_RESTART_COMMAND_RSP, - PS3_DRV_MGR_TM_FAILED, + PS3_DRV_MGR_TIMEOUT = 1, + PS3_DRV_MGR_UNRUNING, + PS3_DRV_MGR_INVAL_CMD, + PS3_DRV_MGR_NORESOURCE, + PS3_DRV_MGR_INVAL_PARAM, + PS3_DRV_MGR_DEV_NOEXIST, + PS3_DRV_MGR_DEV_DATA_ERR, + PS3_DRV_MGR_BUSY, + PS3_DRV_MGR_EVT_REPEAT, + PS3_DRV_MGR_EVT_CANCEL_ERR, + PS3_DRV_MGR_FLUSH_FAILED, + PS3_DRV_MGR_SMP_BACKEND_ERR, + PS3_DRV_MGR_LINK_GET_BACKEND_ERR, + PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, + PS3_DRV_MGR_RESTART_COMMAND_RSP, + PS3_DRV_MGR_TM_FAILED, }; - enum PS3IoctlRetCode { - PS3_IOCTL_STATUS_OK = 0, - PS3_IOCTL_STATUS_INVALID_REQ = 1, - PS3_IOCTL_STATUS_NO_HBA = 2, - PS3_IOCTL_STATUS_BUSY = 3, - PS3_IOCTL_STATUS_NOT_READY = 4, - PS3_IOCTL_STATUS_INVALIED_PARAM = 5, - PS3_IOCTL_STATUS_REQ_ERR = 6, - PS3_IOCTL_STATUS_NEED_RETRY = 7, + PS3_IOCTL_STATUS_OK = 0, + PS3_IOCTL_STATUS_INVALID_REQ = 1, + PS3_IOCTL_STATUS_NO_HBA = 2, + PS3_IOCTL_STATUS_BUSY = 3, + PS3_IOCTL_STATUS_NOT_READY = 4, + PS3_IOCTL_STATUS_INVALIED_PARAM = 5, + PS3_IOCTL_STATUS_REQ_ERR = 6, + PS3_IOCTL_STATUS_NEED_RETRY = 7, }; - enum PS3HwVdMaxIOSize { - PS3_ENUM_HW_VD_MAX_IO_SIZE_1M = 0, - PS3_ENUM_HW_VD_MAX_IO_SIZE_OTHER, + PS3_ENUM_HW_VD_MAX_IO_SIZE_1M = 0, + PS3_ENUM_HW_VD_MAX_IO_SIZE_OTHER, }; -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h index cd230dda1e45..7716a4b98a41 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_dev.h @@ -1,333 +1,330 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_DEV_H_ #define _PS3_HTP_DEV_H_ #include "ps3_htp_def.h" -#define PS3_MAX_CHANNEL_NUM 15 -#define PS3_MAX_RANDOM_NUM 32 -#define PS3_MAX_IV_NUM 16 -#define PS3_SECURITY_CIPHER_NUM_MAX 2 -#define PS3_STABLE_WRITES_MASK (0x1) +#define PS3_MAX_CHANNEL_NUM 15 +#define PS3_MAX_RANDOM_NUM 32 +#define PS3_MAX_IV_NUM 16 +#define PS3_SECURITY_CIPHER_NUM_MAX 2 +#define PS3_STABLE_WRITES_MASK (0x1) struct PS3IocCtrlProp { - U32 enableSnapshot : 1; - U32 enableSoftReset : 1; - U32 reserved1:30; - U32 reserved2; + unsigned int enableSnapshot : 1; + unsigned int enableSoftReset : 1; + unsigned int reserved1 : 30; + unsigned int reserved2; }; struct PS3IocCtrlCapable { - U32 supportUnevenSpans : 1; - U32 supportJbodSecure : 1; - U32 supportNvmePassthru : 1; - U32 supportDirectCmd : 1; - U32 supportAcceleration : 1; - U32 supportSataDirectCmd: 1; - U32 supportSataNcq : 1; - U32 reserved1 : 25; - U32 reserved2[3]; + unsigned int supportUnevenSpans : 1; + unsigned int supportJbodSecure : 1; + unsigned int supportNvmePassthru : 1; + unsigned int supportDirectCmd : 1; + unsigned int supportAcceleration : 1; + unsigned int supportSataDirectCmd : 1; + unsigned int supportSataNcq : 1; + unsigned int reserved1 : 25; + unsigned int reserved2[3]; }; #define PS3_IOC_CLUSTER_SERIAL_NO_SIZE 16 struct PS3ChannelAttr { - U16 channelType : 4; - U16 maxDevNum : 12; + unsigned short channelType : 4; + unsigned short maxDevNum : 12; }; struct PS3ChannelInfo { - U8 channelNum; - U8 reserved; - struct PS3ChannelAttr channels[PS3_MAX_CHANNEL_NUM]; + unsigned char channelNum; + unsigned char reserved; + struct PS3ChannelAttr channels[PS3_MAX_CHANNEL_NUM]; }; struct PS3QosInfo { - U16 tfifoDepth; - U16 sataHddQuota; - U16 sataSsdQuota; - U16 sasHddQuota; - U16 sasSsdQuota; - U16 nvmeVdQuota; - U16 nvmeDirectQuota; - U16 nvmeNormalQuota; + unsigned short tfifoDepth; + unsigned short sataHddQuota; + unsigned short sataSsdQuota; + unsigned short sasHddQuota; + unsigned short sasSsdQuota; + unsigned short nvmeVdQuota; + unsigned short nvmeDirectQuota; + unsigned short nvmeNormalQuota; }; struct PS3IocCtrlInfo { - U16 maxVdCount; - - U16 maxPdCount; + unsigned short maxVdCount; + unsigned short maxPdCount; - U32 maxSectors; - struct PS3IocCtrlProp properties; - struct PS3IocCtrlCapable capabilities; + unsigned int maxSectors; + struct PS3IocCtrlProp properties; + struct PS3IocCtrlCapable capabilities; - U8 scsiTaskAbortTimeout; - U8 scsiTaskResetTimeout; + unsigned char scsiTaskAbortTimeout; + unsigned char scsiTaskResetTimeout; - U16 offsetOfVDID; - U8 reserved1[2]; + unsigned short offsetOfVDID; + unsigned char reserved1[2]; - U16 cancelTimeOut; + unsigned short cancelTimeOut; + unsigned int vdIOThreshold; - U32 vdIOThreshold; + unsigned char iocPerfMode; - U8 iocPerfMode; + unsigned char vdQueueNum; - U8 vdQueueNum; + unsigned char ioTimeOut; + unsigned char hwVdMaxIOSize : 4; + unsigned char reserved2 : 4; - U8 ioTimeOut; - U8 hwVdMaxIOSize:4; - U8 reserved2:4; + struct PS3ChannelInfo channelInfo; - struct PS3ChannelInfo channelInfo; + struct PS3QosInfo qosInfo; + unsigned short isotoneTimeOut; + unsigned char reserved3[2]; - struct PS3QosInfo qosInfo; - U16 isotoneTimeOut; - U8 reserved3[2]; - - - U8 reserved4[32]; + unsigned char reserved4[32]; }; struct PS3Dev { - union { - U16 phyDiskID; - U16 virtDiskID; - }; - U16 softChan : 4; - U16 devID : 12; + union { + unsigned short phyDiskID; + unsigned short virtDiskID; + }; + unsigned short softChan : 4; + unsigned short devID : 12; }; -typedef union PS3DiskDev { - U32 diskID; - struct PS3Dev ps3Dev; -}PS3DiskDev_u; +union PS3DiskDev { + unsigned int diskID; + struct PS3Dev ps3Dev; +}; struct PS3DiskDevPos { - union { - struct { - U8 checkSum; - U8 enclId; - U8 phyId; - }; - U32 diskMagicNum; - }; - PS3DiskDev_u diskDev; + union { + struct { + unsigned char checkSum; + unsigned char enclId; + unsigned char phyId; + }; + unsigned int diskMagicNum; + }; + union PS3DiskDev diskDev; }; - struct PS3PhyDevice { - struct PS3DiskDevPos diskPos; - U8 diskState; - U8 configFlag; - U8 driverType:4; - U8 mediumType:4; - U8 reserved; - U8 reserved1[4]; + struct PS3DiskDevPos diskPos; + unsigned char diskState; + unsigned char configFlag; + unsigned char driverType : 4; + unsigned char mediumType : 4; + unsigned char reserved; + unsigned char reserved1[4]; }; - struct PS3VirtDevice { - struct PS3DiskDevPos diskPos; - U8 accessPolicy; - U8 isHidden; - U8 diskState; - U8 reserved; - U8 reserved1[4]; + struct PS3DiskDevPos diskPos; + unsigned char accessPolicy; + unsigned char isHidden; + unsigned char diskState; + unsigned char reserved; + unsigned char reserved1[4]; }; union PS3Device { - struct PS3PhyDevice pd; - struct PS3VirtDevice vd; + struct PS3PhyDevice pd; + struct PS3VirtDevice vd; }; struct PS3DevList { - U16 count; - U8 reserved[6]; - union PS3Device devs[0]; + unsigned short count; + unsigned char reserved[6]; + union PS3Device devs[0]; }; struct PS3PDInfo { - struct PS3DiskDevPos diskPos; - U8 diskState; - U8 configFlag; - U8 driverType:4; - U8 mediumType:4; - U8 scsiInterfaceType; - U8 taskAbortTimeout; - U8 taskResetTimeout; - union { - struct { - U8 supportNCQ:1; - U8 protect:1; - U8 isDirectDisable:1; - U8 reserved:5; - }; - U8 pdFlags; - }; - U8 reserved1; - U16 sectorSize; - U8 reserved2[2]; - U8 enclId; - U8 phyId; - U8 dmaAddrAlignShift; - U8 dmaLenAlignShift; - U8 reserved3[4]; - U32 maxIOSize; - U32 devQueDepth; - U16 normalQuota; - U16 directQuota; - U8 reserved4[20]; + struct PS3DiskDevPos diskPos; + unsigned char diskState; + unsigned char configFlag; + unsigned char driverType : 4; + unsigned char mediumType : 4; + unsigned char scsiInterfaceType; + unsigned char taskAbortTimeout; + unsigned char taskResetTimeout; + union { + struct { + unsigned char supportNCQ : 1; + unsigned char protect : 1; + unsigned char isDirectDisable : 1; + unsigned char supportNcqPrio:1; + unsigned char reserved : 4; + }; + unsigned char pdFlags; + }; + unsigned char reserved1; + unsigned short sectorSize; + unsigned char reserved2[2]; + unsigned char enclId; + unsigned char phyId; + unsigned char dmaAddrAlignShift; + unsigned char dmaLenAlignShift; + unsigned char reserved3[4]; + unsigned int maxIOSize; + unsigned int devQueDepth; + unsigned short normalQuota; + unsigned short directQuota; + unsigned char reserved4[20]; }; -struct PS3Extent { - PS3DiskDev_u phyDiskID; - U8 state; - U8 reserved[3]; +struct PS3Extent { + union PS3DiskDev phyDiskID; + unsigned char state; + unsigned char reserved[3]; }; struct PS3Span { - U32 spanStripeDataSize; - U8 spanState; - U8 spanPdNum; - U8 reserved[2]; - struct PS3Extent extent[PS3_MAX_PD_COUNT_IN_SPAN]; + unsigned int spanStripeDataSize; + unsigned char spanState; + unsigned char spanPdNum; + unsigned char reserved[2]; + struct PS3Extent extent[PS3_MAX_PD_COUNT_IN_SPAN]; }; struct PS3VDEntry { - struct PS3DiskDevPos diskPos; - U16 sectorSize; - U16 stripSize; - U32 stripeDataSize; - U16 physDrvCnt; - U16 diskGrpId; - U8 accessPolicy; - - U8 reserved1; - U8 dmaAddrAlignShift; - U8 dmaLenAlignShift; - U8 isDirectEnable:1; - U8 isHidden:1; - U8 isNvme:1; - U8 isSsd:1; - U8 bdev_bdi_cap:2; - U8 isWriteDirectEnable:1; - U8 reserved2:1; - U8 raidLevel; - U8 spanCount; - U8 diskState; - U16 umapBlkDescCnt:3; - U16 umapNumblk:13; - U16 dev_busy_scale; - U64 startLBA; - U64 extentSize; - U64 mapBlock; - U64 capacity; - U8 isTaskMgmtEnable; - U8 taskAbortTimeout; - U8 taskResetTimeout; - U8 mapBlockVer; - U32 maxIOSize; - U32 devQueDepth; - U16 virtDiskSeq; - U16 normalQuota; - U16 directQuota; - U16 reserved4[21]; - struct PS3Span span[PS3_MAX_SPAN_IN_VD]; - + struct PS3DiskDevPos diskPos; + unsigned short sectorSize; + unsigned short stripSize; + unsigned int stripeDataSize; + unsigned short physDrvCnt; + unsigned short diskGrpId; + unsigned char accessPolicy; + + unsigned char isReadNeedSeq:1; + unsigned char isWriteNeedSeq:1; + unsigned char reserved1:6; + unsigned char dmaAddrAlignShift; + unsigned char dmaLenAlignShift; + unsigned char isDirectEnable : 1; + unsigned char isHidden : 1; + unsigned char isNvme : 1; + unsigned char isSsd : 1; + unsigned char bdev_bdi_cap : 2; + unsigned char isWriteDirectEnable : 1; + unsigned char reserved2 : 1; + unsigned char raidLevel; + unsigned char spanCount; + unsigned char diskState; + unsigned short umapBlkDescCnt : 3; + unsigned short umapNumblk : 13; + unsigned short dev_busy_scale; + unsigned long long startLBA; + unsigned long long extentSize; + unsigned long long mapBlock; + unsigned long long capacity; + unsigned char isTaskMgmtEnable; + unsigned char taskAbortTimeout; + unsigned char taskResetTimeout; + unsigned char mapBlockVer; + unsigned int maxIOSize; + unsigned int devQueDepth; + unsigned short virtDiskSeq; + unsigned short normalQuota; + unsigned short directQuota; + unsigned short reserved4[21]; + struct PS3Span span[PS3_MAX_SPAN_IN_VD]; }; struct PS3VDInfo { - U16 count; - U8 reserved[6]; - struct PS3VDEntry vds[0]; + unsigned short count; + unsigned char reserved[6]; + struct PS3VDEntry vds[0]; }; struct PS3DrvSysInfo { - U8 version; - U8 systemIDLen; - U8 reserved[6]; - U8 systemID[PS3_DRV_SYSTEM_ID_MAX_LEN]; + unsigned char version; + unsigned char systemIDLen; + unsigned char reserved[6]; + unsigned char systemID[PS3_DRV_SYSTEM_ID_MAX_LEN]; }; struct PS3PhyInfo { - U64 sasAddr; - U64 attachedSasAddr; - U8 phyId; - U8 negLinkRate; - U8 slotId; - U8 attachDevType; - U8 initiatorPortProtocol:4; - U8 targetPortProtocols:4; - U8 attachInitiatorPortProtocol:4; - U8 attachTargetPortProtocols:4; - U8 minLinkRateHw:4; - U8 maxLinkRateHw:4; - U8 minLinkRate:4; - U8 maxLinkRate:4; - U8 enable:1; - U8 reserve:7; - U8 reserved[7]; + unsigned long long sasAddr; + unsigned long long attachedSasAddr; + unsigned char phyId; + unsigned char negLinkRate; + unsigned char slotId; + unsigned char attachDevType; + unsigned char initiatorPortProtocol : 4; + unsigned char targetPortProtocols : 4; + unsigned char attachInitiatorPortProtocol : 4; + unsigned char attachTargetPortProtocols : 4; + unsigned char minLinkRateHw : 4; + unsigned char maxLinkRateHw : 4; + unsigned char minLinkRate : 4; + unsigned char maxLinkRate : 4; + unsigned char enable : 1; + unsigned char reserve : 7; + unsigned char reserved[7]; }; struct PS3ExpanderInfo { - U64 sasAddr; - U64 parentSasAddr; - U8 parentId; - U8 enclID; - U8 devType; - U8 phyCount; - U8 reserved[4]; + unsigned long long sasAddr; + unsigned long long parentSasAddr; + unsigned char parentId; + unsigned char enclID; + unsigned char devType; + unsigned char phyCount; + unsigned char reserved[4]; }; struct PS3Expanders { - U8 count; - U8 reserved[7]; - U64 hbaSasAddr[3]; - struct PS3ExpanderInfo expanders[0]; + unsigned char count; + unsigned char reserved[7]; + unsigned long long hbaSasAddr[3]; + struct PS3ExpanderInfo expanders[0]; }; struct PS3BiosInfo { - U8 biosState; - U8 biosMode; + unsigned char biosState; + unsigned char biosMode; - U8 biosAbs; - U8 devMaxNum; + unsigned char biosAbs; + unsigned char devMaxNum; }; struct PS3BootDriveInfo { - U8 hasBootDrive :1; - U8 isPD :1; - U8 reserved_9 :6; - U8 enclID ; - U16 slotID ; - U16 vdID ; - U8 pad[2]; + unsigned char hasBootDrive : 1; + unsigned char isPD : 1; + unsigned char reserved_9 : 6; + unsigned char enclID; + unsigned short slotID; + unsigned short vdID; + unsigned char pad[2]; }; struct PS3RandomInfo { - U8 randomNum[PS3_MAX_RANDOM_NUM]; - U8 iv[PS3_MAX_IV_NUM]; + unsigned char randomNum[PS3_MAX_RANDOM_NUM]; + unsigned char iv[PS3_MAX_IV_NUM]; }; struct PS3SecurityPwHead { - U8 cipherNum; - U32 cipherLegth[PS3_SECURITY_CIPHER_NUM_MAX]; - U32 cipherOffset[PS3_SECURITY_CIPHER_NUM_MAX]; - U8 iv[PS3_MAX_IV_NUM]; + unsigned char cipherNum; + unsigned int cipherLegth[PS3_SECURITY_CIPHER_NUM_MAX]; + unsigned int cipherOffset[PS3_SECURITY_CIPHER_NUM_MAX]; + unsigned char iv[PS3_MAX_IV_NUM]; }; -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h index 2b0fa7e8ed3a..a01f8e59651d 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_event.h @@ -1,76 +1,37 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_EVENT_H_ #define _PS3_HTP_EVENT_H_ #include "ps3_htp_def.h" #include "ps3_htp_dev.h" -#include "ps3_mgr_evt.h" +#include "ps3_htp_mgr_evt.h" #include "ps3_evtcode_trans.h" - -#define PS3_EVENT_DETAIL_BUF_MAX (20) +#define PS3_EVENT_DETAIL_BUF_MAX (20) enum PS3EventLevel { - PS3_EVENT_LEVEL_INFO, - PS3_EVENT_LEVEL_WARN, - PS3_EVENT_LEVEL_CRITICAL, -}; - -#if 0 - -MgrEvtType_e { - PS3_EVENT_TYPE_NONE = 0X00000000, - - PS3_EVENT_TYPE_PD_COUNT_CHANGE = 0X00000001, - - PS3_EVENT_TYPE_VD_COUNT_CHANGE = 0X00000002, - PS3_EVENT_TYPE_CTRL_INFO_CHANGE = 0X00000004, - PS3_EVENT_TYPE_PD_ATTR_CHANGE = 0X00000008, - PS3_EVENT_TYPE_VD_ATTR_CHANGE = 0X00000010, - PS3_EVENT_TYPE_OTHER = 0X00000020, - PS3_EVENT_TYPE_ALL = 0XFFFFFFFF, + PS3_EVENT_LEVEL_INFO, + PS3_EVENT_LEVEL_WARN, + PS3_EVENT_LEVEL_CRITICAL, }; -#endif struct PS3EventDetail { - U32 eventCode; - U32 timestamp; - MgrEvtType_e eventType; - union { - struct PS3DiskDevPos devicePos; - U8 EnclId; - }; + unsigned int eventCode; + unsigned int timestamp; + enum MgrEvtType eventType; + union { + struct PS3DiskDevPos devicePos; + unsigned char EnclId; + }; }; struct PS3EventInfo { - U32 eventTypeMap; - U32 eventCount; - - struct PS3EventDetail eventDetail[PS3_EVENT_DETAIL_BUF_MAX]; - U8 reserved[8]; -}; -#if 0 - -enum PS3EventCode { - PS3_EVENT_CODE_NONE = 0X00000000, - - PS3_EVENT_CODE_PD_ADD = 0X00000001, - PS3_EVENT_CODE_PD_DEL = 0X00000002, - PS3_EVENT_CODE_PD_CHANGE = 0X00000003, - PS3_EVENT_CODE_SES_ADD = 0X00000004, - PS3_EVENT_CODE_SES_DEL = 0X00000005, - PS3_EVENT_CODE_PD_COUNT_CHANGE = 0X00000006, - - PS3_EVENT_CODE_VD_ADD = 0X00000011, - PS3_EVENT_CODE_VD_DEL = 0X00000012, - PS3_EVENT_CODE_VD_COUNT_CHANGE = 0X00000013, - - PS3_EVENT_CODE_PD_ATTR_CHANGE = 0X00000021, + unsigned int eventTypeMap; + unsigned int eventCount; - PS3_EVENT_CODE_PD_INFO_CHANGE = 0X00000022, - PS3_EVENT_CODE_OTHER = 0X00000040, + struct PS3EventDetail eventDetail[PS3_EVENT_DETAIL_BUF_MAX]; + unsigned char reserved[8]; }; #endif -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h index 9e7824fecbdd..1b382e91eb09 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_ioctl.h @@ -1,114 +1,112 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_IOCTL_H_ #define _PS3_HTP_IOCTL_H_ #include "ps3_htp.h" #include "ps3_htp_reqframe.h" - - -#define PS3_MAX_IOCTL_SGE_NUM 16 -#define PS3_IOCTL_SENSE_SIZE 96 -#define PS3_IOCTL_MAX_FRAME_SIZE 128 +#define PS3_MAX_IOCTL_SGE_NUM 16 +#define PS3_IOCTL_SENSE_SIZE 96 +#define PS3_IOCTL_MAX_FRAME_SIZE 128 #ifndef PS3_SCSI_HOST_PROC_NAME -#define PS3_SCSI_HOST_PROC_NAME "ps3stor" +#define PS3_SCSI_HOST_PROC_NAME "ps3stor" #endif -#define PS3_PRODUCT_MODEL "ps3stor" +#define PS3_PRODUCT_MODEL "ps3stor" #ifndef PS3_SCSI_HOST_PROC_NAME_V100 -#define PS3_SCSI_HOST_PROC_NAME_V100 "ps3" +#define PS3_SCSI_HOST_PROC_NAME_V100 "ps3" #endif -#define PS3_PRODUCT_MODEL_V100 "ps3" +#define PS3_PRODUCT_MODEL_V100 "ps3" + +#define PS3_PSW_PRODUCT_MODEL "psw" -#define PS3_PSW_PRODUCT_MODEL "psw" struct PS3CmdIoctlHeader { - U8 cmdType; - U8 version; - U16 deviceId; - U16 cmdSubType; - U8 cmdResult; - U8 sglOffset; - U16 index; - U16 control; - U32 sgeCount; - U16 timeout; - U8 sglChainOffset; - U8 syncFlag; - U32 abortCmdFrameId; + unsigned char cmdType; + unsigned char version; + unsigned short deviceId; + unsigned short cmdSubType; + unsigned char cmdResult; + unsigned char sglOffset; + unsigned short index; + unsigned short control; + unsigned int sgeCount; + unsigned short timeout; + unsigned char sglChainOffset; + unsigned char syncFlag; + unsigned int abortCmdFrameId; }; - union PS3IoctlFrame { - U8 value[PS3_IOCTL_MAX_FRAME_SIZE]; - struct PS3CmdIoctlHeader header; + unsigned char value[PS3_IOCTL_MAX_FRAME_SIZE]; + struct PS3CmdIoctlHeader header; }; - #ifdef _WINDOWS #define PS3_IOCTL_SIG "ps3stor" #define PS3_IOCTL_FUNCTION 0x801 #define PS3_DEBUG_CLI_FUNCTION 0x802 -#define PS3_CTL_CODE CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_IOCTL_FUNCTION, \ - METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define PS3_DBG_CLI_CODE CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_DEBUG_CLI_FUNCTION, \ - METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define PS3_CTL_CODE \ + CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_IOCTL_FUNCTION, \ + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define PS3_DBG_CLI_CODE \ + CTL_CODE(FILE_DEVICE_MASS_STORAGE, PS3_DEBUG_CLI_FUNCTION, \ + METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) struct PS3IoctlSyncCmd { - U16 hostId; - U16 sglOffset; - U16 sgeCount; - U16 reserved; - U64 traceId; - struct PS3Sge Sgl[PS3_MAX_IOCTL_SGE_NUM]; - UCHAR data[0]; + unsigned short hostId; + unsigned short sglOffset; + unsigned short sgeCount; + unsigned short reserved; + unsigned long long traceId; + struct PS3Sge Sgl[PS3_MAX_IOCTL_SGE_NUM]; + unsigned char data[0]; }; -typedef struct _PS3_IO_CONTROL { - SRB_IO_CONTROL SrbHeader; - ULONG reserved; - struct PS3IoctlSyncCmd ps3Ioctl; -}PS3_IO_CONTRL, * PPS3_IO_CONTROL; +struct _PS3_IO_CONTROL { + SRB_IO_CONTROL SrbHeader; + unsigned long reserved; + struct PS3IoctlSyncCmd ps3Ioctl; +}; #else #define PS3_CMD_IOCTL_SYNC_CMD _IOWR('M', 1, struct PS3IoctlSyncCmd) #ifndef __WIN32__ -#define PS3_EVENT_NOTICE_SIG (SIGRTMIN+7) -enum{ - PS3_IOCTL_CMD_NORMAL = 0, - PS3_IOCTL_CMD_WEB_SUBSCRIBE, +#define PS3_EVENT_NOTICE_SIG (SIGRTMIN + 7) +enum { + PS3_IOCTL_CMD_NORMAL = 0, + PS3_IOCTL_CMD_WEB_SUBSCRIBE, }; struct PS3IoctlSyncCmd { - U16 hostId; - U16 sglOffset; - U16 sgeCount; - U16 reserved1; - U32 resultCode; - U8 reserved2[4]; - U8 sense[PS3_IOCTL_SENSE_SIZE]; - U64 traceId; - U8 reserved3[120]; - union PS3IoctlFrame msg; - struct PS3Sge sgl[PS3_MAX_IOCTL_SGE_NUM]; + unsigned short hostId; + unsigned short sglOffset; + unsigned short sgeCount; + unsigned short reserved1; + unsigned int resultCode; + unsigned char reserved2[4]; + unsigned char sense[PS3_IOCTL_SENSE_SIZE]; + unsigned long long traceId; + unsigned char reserved3[120]; + union PS3IoctlFrame msg; + struct PS3Sge sgl[PS3_MAX_IOCTL_SGE_NUM]; }; #endif struct PS3IoctlAsynCmd { - U16 hostId; - U16 reserved1; + unsigned short hostId; + unsigned short reserved1; - U32 seqNum; + unsigned int seqNum; - U16 eventLevel; + unsigned short eventLevel; - U16 eventType; - U8 reserved2[4]; + unsigned short eventType; + unsigned char reserved2[4]; }; #endif - -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h index 29ecf508cfa2..2020365ea9e5 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_pci.h @@ -1,53 +1,55 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_PCI_H_ #define _PS3_HTP_PCI_H_ -#define PCI_DEVICE_ID 0x02 +#define PCI_DEVICE_ID 0x02 enum { - PCI_VENDOR_ID_STARS = 0x1eb6, - PCI_VENDOR_ID_PS3_FPGA = 0x1eb6, - PCI_VENDOR_ID_PS3_SWITCH_FPGA = 0x1eb6, - PCI_VENDOR_ID_PS3_ASIC = 0x1666, - PCI_VENDOR_ID_PS3 = 0x1ff2, - PCI_DEVICE_ID_PS3_RAID = 0x0001, - PCI_DEVICE_ID_PS3_HBA = 0x0002, - PCI_DEVICE_ID_PS3_SWITCH = 0x0003, - PCI_DEVICE_ID_PS3_SWITCH_FPGA = 0x6004, - PCI_DEVICE_ID_PS3_RAID_FPGA = 0xabcd, - PCI_DEVICE_ID_STARS_HBA_2120_16i = 0x20a1, - PCI_DEVICE_ID_STARS_IOC_2020_18i = 0x20a2, - PCI_DEVICE_ID_STARS_IOC_2213_16i = 0x20a3, - PCI_DEVICE_ID_STARS_ROC_2020_10i = 0x30a2, - PCI_SUBVERDOR_PS3_SWITCH_FPGA = 0x1eb6, - PCI_SUBSYSTEM_PS3_SWITCH_FPGA = 0x6004, - PCI_CLASS_CODE_PS3_SWITCH_FPGA = 0x058000, + PCI_VENDOR_ID_STARS = 0x1eb6, + PCI_VENDOR_ID_PS3_FPGA = 0x1eb6, + PCI_VENDOR_ID_PS3_SWITCH_FPGA = 0x1eb6, + PCI_VENDOR_ID_PS3_ASIC = 0x1666, + PCI_VENDOR_ID_PS3 = 0x1ff2, + PCI_VENDOR_ID_TL = 0x206f, + PCI_DEVICE_ID_PS3_RAID = 0x0001, + PCI_DEVICE_ID_PS3_HBA = 0x0002, + PCI_DEVICE_ID_PS3_SWITCH = 0x0003, + PCI_DEVICE_ID_PS3_SWITCH_FPGA = 0x6004, + PCI_DEVICE_ID_PS3_RAID_FPGA = 0xabcd, + PCI_DEVICE_ID_STARS_HBA_2120_16i = 0x20a1, + PCI_DEVICE_ID_STARS_IOC_2020_18i = 0x20a2, + PCI_DEVICE_ID_STARS_IOC_2213_16i = 0x20a3, + PCI_DEVICE_ID_STARS_ROC_2020_10i = 0x30a2, + PCI_DEVICE_ID_TL_30A2 = 0x30a2, + PCI_SUBVERDOR_PS3_SWITCH_FPGA = 0x1eb6, + PCI_SUBSYSTEM_PS3_SWITCH_FPGA = 0x6004, + PCI_CLASS_CODE_PS3_SWITCH_FPGA = 0x058000, }; -static inline const S8 * namePciDevType(U16 e) +static inline const char *namePciDevType(unsigned short e) { - switch (e) { - case PCI_DEVICE_ID_PS3_RAID: - return "PCI_DEVICE_ID_PS3_RAID"; - case PCI_DEVICE_ID_PS3_RAID_FPGA: - return "PCI_DEVICE_ID_PS3_RAID_FPGA"; - case PCI_DEVICE_ID_PS3_HBA: - return "PCI_DEVICE_ID_PS3_HBA"; - case PCI_DEVICE_ID_PS3_SWITCH: - return "PCI_DEVICE_ID_PS3_SWITCH"; - case PCI_DEVICE_ID_PS3_SWITCH_FPGA: - return "PCI_DEVICE_ID_PS3_SWITCH_FPGA"; - case PCI_DEVICE_ID_STARS_HBA_2120_16i: - return "PCI_DEVICE_ID_STARS_HBA_2120_16i"; - case PCI_DEVICE_ID_STARS_IOC_2020_18i: - return "PCI_DEVICE_ID_STARS_IOC_2020_18i"; - case PCI_DEVICE_ID_STARS_ROC_2020_10i: - return "PCI_DEVICE_ID_STARS_ROC_2020_10i"; - case PCI_DEVICE_ID_STARS_IOC_2213_16i: - return "PCI_DEVICE_ID_STARS_IOC_2213_16i"; - default: - return "PCI_DEVICE_ID_INVALID"; - } + switch (e) { + case PCI_DEVICE_ID_PS3_RAID: + return "PCI_DEVICE_ID_PS3_RAID"; + case PCI_DEVICE_ID_PS3_RAID_FPGA: + return "PCI_DEVICE_ID_PS3_RAID_FPGA"; + case PCI_DEVICE_ID_PS3_HBA: + return "PCI_DEVICE_ID_PS3_HBA"; + case PCI_DEVICE_ID_PS3_SWITCH: + return "PCI_DEVICE_ID_PS3_SWITCH"; + case PCI_DEVICE_ID_PS3_SWITCH_FPGA: + return "PCI_DEVICE_ID_PS3_SWITCH_FPGA"; + case PCI_DEVICE_ID_STARS_HBA_2120_16i: + return "PCI_DEVICE_ID_STARS_HBA_2120_16i"; + case PCI_DEVICE_ID_STARS_IOC_2020_18i: + return "PCI_DEVICE_ID_STARS_IOC_2020_18i"; + case PCI_DEVICE_ID_STARS_ROC_2020_10i: + return "PCI_DEVICE_ID_STARS_ROC_2020_10i"; + case PCI_DEVICE_ID_STARS_IOC_2213_16i: + return "PCI_DEVICE_ID_STARS_IOC_2213_16i"; + default: + return "PCI_DEVICE_ID_INVALID"; + } } -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h index 196995c8312d..beb8b5311172 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_req_frame_hw.h @@ -1,98 +1,98 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_REQ_FRAME_HW_H_ #define _PS3_HTP_REQ_FRAME_HW_H_ #include "ps3_htp_def.h" -#define ENCODE_CCS_XFERLEN(x) (((U32)(x) >> 2)) -#define DECODE_CCS_XFERLEN(x) (((U32)(x) << 2)) +#define ENCODE_CCS_XFERLEN(x) (((unsigned int)(x) >> 2)) +#define DECODE_CCS_XFERLEN(x) (((unsigned int)(x) << 2)) #ifdef _WINDOWS #define __attribute__(x) #pragma pack(push, 1) #endif - struct PS3NvmeSglDesc { - U64 addr; - union { - struct { - U8 reserved[7]; - U8 subtype : 4; - U8 type : 4; - } generic; - - struct { - U32 length; - U8 reserved[3]; - U8 subtype : 4; - U8 type : 4; - } unkeyed; - - struct { - U64 length : 24; - U64 key : 32; - U64 subtype : 4; - U64 type : 4; - } keyed; - }; + unsigned long long addr; + union { + struct { + unsigned char reserved[7]; + unsigned char subtype : 4; + unsigned char type : 4; + } generic; + + struct { + unsigned int length; + unsigned char reserved[3]; + unsigned char subtype : 4; + unsigned char type : 4; + } unkeyed; + + struct { + unsigned long long length : 24; + unsigned long long key : 32; + unsigned long long subtype : 4; + unsigned long long type : 4; + } keyed; + }; }; struct PS3NvmeCmdDw0_9 { - U16 opcode : 8; - U16 fuse : 2; - U16 reserved1 : 4; - U16 psdt : 2; - U16 cID; + unsigned short opcode : 8; + unsigned short fuse : 2; + unsigned short reserved1 : 4; + unsigned short psdt : 2; + unsigned short cID; - U32 nsID; + unsigned int nsID; - U32 reserved2; - U32 reserved3; + unsigned int reserved2; + unsigned int reserved3; - U64 mPtr; + unsigned long long mPtr; - union { - struct { - U64 prp1; - U64 prp2; - } prp; - struct PS3NvmeSglDesc sgl1; + union { + struct { + unsigned long long prp1; + unsigned long long prp2; + } prp; + struct PS3NvmeSglDesc sgl1; - } dPtr; + } dPtr; }; -typedef struct PS3NvmeCommonCmd { - struct PS3NvmeCmdDw0_9 cDW0_9; +struct PS3NvmeCommonCmd { + struct PS3NvmeCmdDw0_9 cDW0_9; - U32 cDW10; - U32 cDW11; - U32 cDW12; - U32 cDW13; - U32 cDW14; - U32 cDW15; -} PS3NvmeCommonCmd_s; + unsigned int cDW10; + unsigned int cDW11; + unsigned int cDW12; + unsigned int cDW13; + unsigned int cDW14; + unsigned int cDW15; +}; -typedef struct PS3NvmeRWCmd { - struct PS3NvmeCmdDw0_9 cDW0_9; +struct PS3NvmeRWCmd { + struct PS3NvmeCmdDw0_9 cDW0_9; - U32 sLbaLo; - U32 sLbaHi; - U32 numLba; - U32 cDW13; - U32 cDW14; - U32 cDW15; -} PS3NvmeRWCmd_s; + unsigned int sLbaLo; + unsigned int sLbaHi; + unsigned int numLba; + unsigned int cDW13; + unsigned int cDW14; + unsigned int cDW15; +}; -typedef union PS3NvmeReqFrame { - PS3NvmeCommonCmd_s commonReqFrame; - PS3NvmeRWCmd_s rwReqFrame; -} PS3NvmeReqFrame_u; +union PS3NvmeReqFrame { + struct PS3NvmeCommonCmd commonReqFrame; + struct PS3NvmeRWCmd rwReqFrame; +}; #ifdef _WINDOWS #pragma pack(pop) #endif -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h index 75ec48040907..d315965c82a9 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_reqframe.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_HTP_REQFRAME_H_ #define _PS3_HTP_REQFRAME_H_ @@ -8,289 +8,290 @@ #include "ps3_htp_req_frame_hw.h" enum { - PS3_FRAME_SGE_BUFSIZE = 4096, - PS3_FRAME_SGE_SHIFT = 12, - PS3_FRAME_REQ_SGE_NUM_FE = 8, - PS3_FRAME_REQ_PRP_NUM_FE = 2, - PS3_FRAME_REQ_SGE_NUM_HW = 8, - PS3_FRAME_REQ_PRP_NUM_HW = 2, - PS3_FRAME_REQ_SGE_NUM_MGR = 11, - PS3_FRAME_REQ_EXT_SGE_MIN = 2, - PS3_FRAME_CDB_BUFLEN = 32, - PS3_FRAME_LUN_BUFLEN = 8, - PS3_DEBUG_MEM_ARRAY_MAX_NUM = 16, - PS3_MAX_DMA_MEM_SIZE = 4096, - PS3_MAX_DEBUG_MEM_SIZE_PARA = 65536, - PS3_DRV_NAME_MAX_LEN = 32, - PS3_DRV_VERSION_MAX_LEN = 24, + PS3_FRAME_SGE_BUFSIZE = 4096, + PS3_FRAME_SGE_SHIFT = 12, + PS3_FRAME_REQ_SGE_NUM_FE = 8, + PS3_FRAME_REQ_PRP_NUM_FE = 2, + PS3_FRAME_REQ_SGE_NUM_HW = 8, + PS3_FRAME_REQ_PRP_NUM_HW = 2, + PS3_FRAME_REQ_SGE_NUM_MGR = 11, + PS3_FRAME_REQ_EXT_SGE_MIN = 2, + PS3_FRAME_CDB_BUFLEN = 32, + PS3_FRAME_LUN_BUFLEN = 8, + PS3_DEBUG_MEM_ARRAY_MAX_NUM = 16, + PS3_MAX_DMA_MEM_SIZE = 4096, + PS3_MAX_DEBUG_MEM_SIZE_PARA = 65536, + PS3_DRV_NAME_MAX_LEN = 32, + PS3_DRV_VERSION_MAX_LEN = 24, }; enum { - PS3_DATA_DIRECTION_WRITE = 0, - PS3_DATA_DIRECTION_READ = 1, + PS3_DATA_DIRECTION_WRITE = 0, + PS3_DATA_DIRECTION_READ = 1, }; enum { - PS3_REQFRAME_FORMAT_FRONTEND = 0, - PS3_REQFRAME_FORMAT_SAS = 1, - PS3_REQFRAME_FORMAT_SATA = 2, - PS3_REQFRAME_FORMAT_NVME = 3, + PS3_REQFRAME_FORMAT_FRONTEND = 0, + PS3_REQFRAME_FORMAT_SAS = 1, + PS3_REQFRAME_FORMAT_SATA = 2, + PS3_REQFRAME_FORMAT_NVME = 3, }; enum { - PS3_LINUX_FRAME = 0, - PS3_WINDOWS_FRAME = 1, + PS3_LINUX_FRAME = 0, + PS3_WINDOWS_FRAME = 1, }; enum { - PS3_COMPAT_VER_DEFAULT = 0, - PS3_COMPAT_VER_1 = 1, - PS3_COMPAT_VER_MAX = 0xffff, + PS3_COMPAT_VER_DEFAULT = 0, + PS3_COMPAT_VER_1 = 1, + PS3_COMPAT_VER_MAX = 0xffff, +}; + +struct PS3Sge { + unsigned long long addr; + unsigned int length; + unsigned int reserved1 : 30; + unsigned int lastSge : 1; + unsigned int ext : 1; }; -typedef struct PS3Sge { - U64 addr; - U32 length; - U32 reserved1 : 30; - U32 lastSge : 1; - U32 ext : 1; -} PS3Sge_s; - -typedef struct PS3Prp { - U64 prp1; - U64 prp2; -} PS3Prp_s; - - - -typedef struct PS3SoftwareZone { - U64 virtDiskLba; - U32 numBlocks; - U8 opcode; - U8 sglOffset; - U8 sglFormat : 2; - U8 isResendCmd : 1; - U8 reserved1 : 5; - U8 reserved2; - U16 subOpcode; - U16 sgeCount : 9; - U16 reserved3 : 7; - U8 reserved4[4]; -} PS3SoftwareZone_s; - -typedef struct PS3ReqFrameHead -{ - U8 cmdType; - U8 cmdSubType; - U16 cmdFrameID; - union{ - struct { - U32 noReplyWord : 1; - U32 dataFormat : 1; - U32 reqFrameFormat : 2; - U32 mapBlockVer : 2; - U32 isWrite : 1; - U32 isStream1 : 1; - U32 reserved : 24; - }; - U32 control; - }; - PS3DiskDev_u devID; - U16 timeout; - U16 virtDiskSeq; - U16 reserved1[4]; - U64 traceID; -} PS3ReqFrameHead_s; - -typedef struct PS3HwReqFrame { - PS3ReqFrameHead_s reqHead; - PS3SoftwareZone_s softwareZone; - U8 reserved[8]; - union { - IODT_V1_s sasReqFrame; - PS3NvmeReqFrame_u nvmeReqFrame; - }; - PS3Sge_s sgl[PS3_FRAME_REQ_SGE_NUM_FE]; -} PS3HwReqFrame_s; - -typedef struct PS3VDAccAttr { - U64 firstPdStartLba; - U8 firstSpanNo; - U8 fisrtSeqInSpan; - U8 secondSeqInSapn; - U8 thirdSeqInSapn; - U8 clineCount; - U8 isAccActive : 1; - U8 isStream : 1; - U8 reserved1 : 6; - U16 ioOutStandingCnt; - U8 reserved2[16]; -} PS3VDAccAttr_s; - - -typedef struct PS3FrontEndReqFrame { - PS3ReqFrameHead_s reqHead; - U8 cdb[PS3_FRAME_CDB_BUFLEN]; - PS3VDAccAttr_s vdAccAttr; - U32 dataXferLen; - U8 reserved[25]; - U8 sgeOffset; - U16 sgeCount; - union { - PS3Sge_s sgl[PS3_FRAME_REQ_SGE_NUM_FE]; - PS3Prp_s prp; - }; -} PS3FrontEndReqFrame_s; +struct PS3Prp { + unsigned long long prp1; + unsigned long long prp2; +}; + + + +struct PS3SoftwareZone { + unsigned long long virtDiskLba; + unsigned int numBlocks; + unsigned char opcode; + unsigned char sglOffset; + unsigned char sglFormat : 2; + unsigned char isResendCmd : 1; + unsigned char reserved1 : 5; + unsigned char reserved2; + unsigned short subOpcode; + unsigned short sgeCount : 9; + unsigned short reserved3 : 7; + unsigned char reserved4[4]; +}; + +struct PS3ReqFrameHead { + unsigned char cmdType; + unsigned char cmdSubType; + unsigned short cmdFrameID; + union{ + struct { + unsigned int noReplyWord : 1; + unsigned int dataFormat : 1; + unsigned int reqFrameFormat : 2; + unsigned int mapBlockVer : 2; + unsigned int isWrite : 1; + unsigned int isStream1 : 1; + unsigned int reserved : 16; + unsigned int ncq_prio : 1; + unsigned int reserved2 : 7; + }; + unsigned int control; + }; + union PS3DiskDev devID; + unsigned short timeout; + unsigned short virtDiskSeq; + unsigned short reserved1[4]; + unsigned long long traceID; +}; + +struct PS3HwReqFrame { + struct PS3ReqFrameHead reqHead; + struct PS3SoftwareZone softwareZone; + unsigned char reserved[8]; + union { + struct IODT_V1 sasReqFrame; + union PS3NvmeReqFrame nvmeReqFrame; + }; + struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_FE]; +}; + +struct PS3VDAccAttr { + unsigned long long firstPdStartLba; + unsigned char firstSpanNo; + unsigned char fisrtSeqInSpan; + unsigned char secondSeqInSapn; + unsigned char thirdSeqInSapn; + unsigned char clineCount; + unsigned char isAccActive : 1; + unsigned char isStream : 1; + unsigned char reserved1 : 6; + unsigned short ioOutStandingCnt; + unsigned char reserved2[16]; +}; + + +struct PS3FrontEndReqFrame { + struct PS3ReqFrameHead reqHead; + unsigned char cdb[PS3_FRAME_CDB_BUFLEN]; + struct PS3VDAccAttr vdAccAttr; + unsigned int dataXferLen; + unsigned char reserved[25]; + unsigned char sgeOffset; + unsigned short sgeCount; + union { + struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_FE]; + struct PS3Prp prp; + }; +}; struct PS3MgrDev { - struct PS3DiskDevPos devID; - U16 num; - U8 devType; - U8 reserved[17]; + struct PS3DiskDevPos devID; + unsigned short num; + unsigned char devType; + unsigned char reserved[17]; }; struct PS3MgrEvent { - U32 eventTypeMap; - U32 eventTypeMapProcResult; - U32 eventLevel; - U8 reserved[20]; + unsigned int eventTypeMap; + unsigned int eventTypeMapProcResult; + unsigned int eventLevel; + unsigned char reserved[20]; }; struct PS3SasMgr { - U64 sasAddr; - U8 enclID; - U8 startPhyID; - U8 phyCount; - U8 reserved1; - U16 reqLen; - U8 reserved2[2]; + unsigned long long sasAddr; + unsigned char enclID; + unsigned char startPhyID; + unsigned char phyCount; + unsigned char reserved1; + unsigned short reqLen; + unsigned char reserved2[2]; }; struct PS3SasPhySet { - U64 sasAddr; - U8 phyID; - U8 minLinkRate; - U8 maxLinkRate; - U8 phyCtrl; - U8 reserved[3]; + unsigned long long sasAddr; + unsigned char phyID; + unsigned char minLinkRate; + unsigned char maxLinkRate; + unsigned char phyCtrl; + unsigned char reserved[3]; }; union PS3MgrReqDiffValue { - U8 word[32]; - U16 originalCmdFrameID; - U8 eventStart; - struct PS3MgrDev dev; - struct PS3MgrEvent event; - struct PS3SasMgr sasMgr; - struct PS3SasPhySet phySet; - U8 unLoadType; - BOOL isRetry; + unsigned char word[32]; + unsigned short originalCmdFrameID; + unsigned char eventStart; + struct PS3MgrDev dev; + struct PS3MgrEvent event; + struct PS3SasMgr sasMgr; + struct PS3SasPhySet phySet; + unsigned char unLoadType; + int isRetry; }; -typedef struct PS3MgrReqFrame { - PS3ReqFrameHead_s reqHead; - U16 sgeCount; - U8 sgeOffset; - U8 syncFlag; - U16 timeout; - U8 abortFlag; - U8 pendingFlag; - union PS3MgrReqDiffValue value; - U8 osType; - U8 suspend_type; - U8 reserved[6]; - struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_MGR]; -}PS3MgrReqFrame_s; +struct PS3MgrReqFrame { + struct PS3ReqFrameHead reqHead; + unsigned short sgeCount; + unsigned char sgeOffset; + unsigned char syncFlag; + unsigned short timeout; + unsigned char abortFlag; + unsigned char pendingFlag; + union PS3MgrReqDiffValue value; + unsigned char osType; + unsigned char suspend_type; + unsigned char reserved[6]; + struct PS3Sge sgl[PS3_FRAME_REQ_SGE_NUM_MGR]; +}; -typedef struct PS3MgrTaskReqFrame { - PS3ReqFrameHead_s reqHead; - U16 taskID; - U8 lun[PS3_FRAME_LUN_BUFLEN]; - U8 abortedCmdType; - U8 reserved[5]; -} PS3MgrTaskReqFrame_s; +struct PS3MgrTaskReqFrame { + struct PS3ReqFrameHead reqHead; + unsigned short taskID; + unsigned char lun[PS3_FRAME_LUN_BUFLEN]; + unsigned char abortedCmdType; + unsigned char reserved[5]; +}; union PS3ReqFrame { - PS3MgrTaskReqFrame_s taskReq; - PS3MgrReqFrame_s mgrReq; - PS3FrontEndReqFrame_s frontendReq; - PS3HwReqFrame_s hwReq; - U8 word[256]; + struct PS3MgrTaskReqFrame taskReq; + struct PS3MgrReqFrame mgrReq; + struct PS3FrontEndReqFrame frontendReq; + struct PS3HwReqFrame hwReq; + unsigned char word[256]; }; -typedef struct PS3DrvInfo { - char drvName[PS3_DRV_NAME_MAX_LEN]; - char drvVersion[PS3_DRV_VERSION_MAX_LEN]; - U64 bus; - U8 dev:5; - U8 func:3; - U8 domain_support:1; - U8 reserved:7; - U16 compatVer; - U32 domain; - U8 reserved1[56]; -} PS3DrvInfo_s; +struct PS3DrvInfo { + char drvName[PS3_DRV_NAME_MAX_LEN]; + char drvVersion[PS3_DRV_VERSION_MAX_LEN]; + unsigned long long bus; + unsigned char dev : 5; + unsigned char func : 3; + unsigned char domain_support : 1; + unsigned char reserved : 7; + unsigned short compatVer; + unsigned int domain; + unsigned char reserved1[56]; +}; enum { - PS3_MEM_TYPE_UNKNOWN = 0, - PS3_MEM_TYPE_SO = 1, - PS3_MEM_TYPE_RO = 2, + PS3_MEM_TYPE_UNKNOWN = 0, + PS3_MEM_TYPE_SO = 1, + PS3_MEM_TYPE_RO = 2, }; -typedef struct PS3HostMemInfo { - U64 startAddr; - U64 endAddr; - U8 type; - U8 reserved[7]; -} PS3HostMemInfo_s; +struct PS3HostMemInfo { + unsigned long long startAddr; + unsigned long long endAddr; + unsigned char type; + unsigned char reserved[7]; +}; struct PS3InitReqFrame { - PS3ReqFrameHead_s reqHead; - U8 ver; - U8 reserved0; - U16 length; - U8 operater; - U8 pageSize; - U8 pciIrqType; - U8 osType; - U8 reserved1[6]; - U16 msixVector; - U64 timeStamp; - U64 reqFrameBufBaseAddr; - U64 hostMemInfoBaseAddr; - U32 hostMemInfoNum; - U8 reserved2[20]; - - U64 replyFifoDescBaseAddr; - - U64 respFrameBaseAddr; - U32 eventTypeMap; - U16 reqFrameMaxNum; - U16 respFrameMaxNum; - U64 filterTableAddr; - U32 filterTableLen; - U16 bufSizePerRespFrame; - U8 hilMode; - U8 reserved3[33]; - U64 systemInfoBufAddr; - U64 debugMemArrayAddr; - U32 debugMemArrayNum; - U32 dumpDmaBufLen; - U64 dumpDmaBufAddr; - U32 dumpIsrSN; - U16 drvInfoBufLen; - U8 reserverd4[2]; - U64 drvInfoBufAddr; - U8 reserved5[36]; - U32 respStatus; + struct PS3ReqFrameHead reqHead; + unsigned char ver; + unsigned char reserved0; + unsigned short length; + unsigned char operater; + unsigned char pageSize; + unsigned char pciIrqType; + unsigned char osType; + unsigned char reserved1[6]; + unsigned short msixVector; + unsigned long long timeStamp; + unsigned long long reqFrameBufBaseAddr; + unsigned long long hostMemInfoBaseAddr; + unsigned int hostMemInfoNum; + unsigned char reserved2[20]; + + unsigned long long replyFifoDescBaseAddr; + + unsigned long long respFrameBaseAddr; + unsigned int eventTypeMap; + unsigned short reqFrameMaxNum; + unsigned short respFrameMaxNum; + unsigned long long filterTableAddr; + unsigned int filterTableLen; + unsigned short bufSizePerRespFrame; + unsigned char hilMode; + unsigned char reserved3[33]; + unsigned long long systemInfoBufAddr; + unsigned long long debugMemArrayAddr; + unsigned int debugMemArrayNum; + unsigned int dumpDmaBufLen; + unsigned long long dumpDmaBufAddr; + unsigned int dumpIsrSN; + unsigned short drvInfoBufLen; + unsigned char reserverd4[2]; + unsigned long long drvInfoBufAddr; + unsigned char reserved5[36]; + unsigned int respStatus; }; -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h index 06c976e5db92..82d19fc7b099 100644 --- a/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h +++ b/drivers/scsi/linkdata/ps3stor/include/htp_v200/ps3_htp_sas.h @@ -1,320 +1,319 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IODT_H_ #define _PS3_IODT_H_ #include "ps3_htp_def.h" - enum IodtProtocolType { - PROTOCOL_SMP = 0b000, - PROTOCOL_SSP = 0b001, - PROTOCOL_STP = 0b010, - PROTOCOL_DIRT = 0b111, + PROTOCOL_SMP = 0b000, + PROTOCOL_SSP = 0b001, + PROTOCOL_STP = 0b010, + PROTOCOL_DIRT = 0b111, }; enum IodtFrameType { - FRAMETYPE_SSP_CMD = 0b001, - FRAMETYPE_SSP_SMP = 0b001, - FRAMETYPE_SATA_NONDATA = 0b001, + FRAMETYPE_SSP_CMD = 0b001, + FRAMETYPE_SSP_SMP = 0b001, + FRAMETYPE_SATA_NONDATA = 0b001, - FRAMETYPE_SSP_TASK = 0b010, - FRAMETYPE_SATA_PIO = 0b010, + FRAMETYPE_SSP_TASK = 0b010, + FRAMETYPE_SATA_PIO = 0b010, - FRAMETYPE_SATA_DMA = 0b011, + FRAMETYPE_SATA_DMA = 0b011, - FRAMETYPE_SATA_FPDMA = 0b100, + FRAMETYPE_SATA_FPDMA = 0b100, - FRAMETYPE_SATA_ATAPI = 0b101, - FRAMETYPE_DIRECT = 0b111, + FRAMETYPE_SATA_ATAPI = 0b101, + FRAMETYPE_DIRECT = 0b111, }; - + enum IodtIuSrc { - IU_SRC_MEM = 0b00, - IU_SRC_IODT = 0b01, - IU_SRC_TUPLE = 0b10, - IU_SRC_SATA = 0b11, + IU_SRC_MEM = 0b00, + IU_SRC_IODT = 0b01, + IU_SRC_TUPLE = 0b10, + IU_SRC_SATA = 0b11, }; enum IodtSgeMode { - IODT_SGEMODE_DIRECT = 0x0, - IODT_SGEMODE_SGL = 0x1, + IODT_SGEMODE_DIRECT = 0x0, + IODT_SGEMODE_SGL = 0x1, }; enum IodtEedpMode { - EEDP_MODE_CHECK = 0x0, - EEDP_MODE_INSERT = 0x1, - EEDP_MODE_REPLACE = 0x2, - EEDP_MODE_RMV = 0x3, + EEDP_MODE_CHECK = 0x0, + EEDP_MODE_INSERT = 0x1, + EEDP_MODE_REPLACE = 0x2, + EEDP_MODE_RMV = 0x3, }; enum AbortCtrl { - ABT_SASSATA_TASK = 0b00, - ABT_SAS_TASKSET = 0b01, - ABT_LOCAL_BY_DISK = 0b10, - ABT_LOCAL_BY_PORT = 0b11, + ABT_SASSATA_TASK = 0b00, + ABT_SAS_TASKSET = 0b01, + ABT_LOCAL_BY_DISK = 0b10, + ABT_LOCAL_BY_PORT = 0b11, - ABT_MGT_IO = 0b00, - ABT_SOFTRESET = 0b01, - ABT_READ_NCQ_ERR_LOG = 0b10, - ABT_SMP = 0b11, + ABT_MGT_IO = 0b00, + ABT_SOFTRESET = 0b01, + ABT_READ_NCQ_ERR_LOG = 0b10, + ABT_SMP = 0b11, }; enum DirectFlag { - DIRECT_FLAG_NORMAL = 0b00, - DIRECT_FLAG_DIRECT = 0b10, + DIRECT_FLAG_NORMAL = 0b00, + DIRECT_FLAG_DIRECT = 0b10, }; enum CmdWordType { - CMD_WORD_TYPE_ABORT = 0b00, - CMD_WORD_TYPE_MGT = 0b01, - CMD_WORD_TYPE_READ = 0b10, - CMD_WORD_TYPE_WRITE = 0b11, + CMD_WORD_TYPE_ABORT = 0b00, + CMD_WORD_TYPE_MGT = 0b01, + CMD_WORD_TYPE_READ = 0b10, + CMD_WORD_TYPE_WRITE = 0b11, }; enum SmpFrameType { - SMP_REQ = 0x40, - SMP_RESP = 0x41, + SMP_REQ = 0x40, + SMP_RESP = 0x41, }; enum eedpMode { - EEDP_NONE = 0b0000, - EEDP_CHK = 0b0001, - EEDP_INST = 0b0010, - EEDP_REPL = 0b0100, - EEDP_RMV = 0b1000, + EEDP_NONE = 0b0000, + EEDP_CHK = 0b0001, + EEDP_INST = 0b0010, + EEDP_REPL = 0b0100, + EEDP_RMV = 0b1000, +}; + +union IoDmaCfg { + struct { + unsigned char eedpEn : 1; + unsigned char eedpSgMod : 1; + unsigned char twoSglMod : 1; + unsigned char sgMode : 1; + unsigned char eedpMode : 4; + }; + unsigned char byte; }; -typedef union IoDmaCfg { - struct { - U8 eedpEn : 1; - U8 eedpSgMod : 1; - U8 twoSglMod : 1; - U8 sgMode : 1; - U8 eedpMode : 4; - }; - U8 byte; -} IoDmaCfg_u; - - -typedef struct __attribute__((packed)) SspTaskFrameIu { - U64 LUN; - U16 reserved0; - U8 function; - U8 reserved1; - U16 manageTag; - U8 reserved2[14]; -} SspTaskFrameIu_s; - - -typedef union __attribute__((packed)) SmpFrameIu { - struct { - U8 frameType; - U8 reqestBytes[31]; - }; - U8 smpIURaw[32]; -} SmpFrameIu_s; - - -typedef struct __attribute__((packed)) DfifoWordCommon { - - union { - struct { - U16 type : 2; - U16 rsv1 : 2; - U16 direct : 2; - U16 rFifoID : 4; - U16 rsv2 : 6; - }; - U16 WD0; - }; - - - union{ - - struct { - union{ - - struct { - U16 darID : 13; - U16 rsv3 : 2; - - U16 function : 1; - }; - - struct{ - U16 manageIptt : 13; - }; - }; - }; - - struct { - union{ - - struct{ - U16 reqFrameID : 13; - }; - - - struct{ - U16 manageReqFrameID : 13; - }; - }; - }; - U16 WD1; - }; - - - union { - struct { - U16 phyDiskID : 12; - U16 rsv4 : 2; - U16 abortCtrl : 2; - }; - U16 WD2; - }; -}DfifoWordCommon_s; - -typedef struct __attribute__((packed)) IODT_V1 { - union { - - struct __attribute__((packed)) { - union { - struct { - union { - struct { - U8 protocolType : 3; - U8 frameType : 3; - U8 iuSrc : 2; - }; - U8 byte0; - }; - - IoDmaCfg_u dmaCfg; - }; - U16 config; - }; - - - - - U16 cmdLen : 9; - U16 rsv0 : 7; - - union { - struct { - U32 taskDarID : 13; - U32 : 19; - }; - struct { - U32 dataBufLenDWAlign : 24; - - U32 rsvd0 : 1; - U32 cmdDir : 1; - U32 refTagEn : 1; - U32 appTagEn : 1; - U32 guardTagEn : 1; - U32 refTagInc : 1; - U32 rsv1 : 1; - U32 aborted : 1; - }; - }; - }; - U64 QW0; - }; - - - union { - struct __attribute__((packed)) { - DfifoWordCommon_s commonWord; - U16 rsv2 : 1; - U16 sataCtl : 1; - U16 rsv3 : 2; - U16 sasCtl : 1; - U16 sataByteBlock0 : 1; - U16 sataByteBlock1 : 1; - U16 rsv4 : 9; - }; - U64 QW1; - }; - - - union { - U64 dataBaseAddr; - U64 QW2; - }; - - - union { - U64 eedpBaseAddr; - U64 QW3; - }; - - - union { - - struct { - U64 cmdIUAddr; - U64 rsv9; - - U64 refTag : 32; - U64 appTag : 16; - U64 rsv10 : 16; - - U64 rsv11; - } A; - - union { - U8 cdb[32]; - SspTaskFrameIu_s taskIU; - SmpFrameIu_s smpIU; - } B; - - - struct { - U64 opCode : 8; - U64 rsv12 : 56; - - U64 lba : 48; - U64 rsv13 : 16; - - U64 refTag : 32; - U64 appTag : 16; - U64 rsv14 : 16; - - U64 rsv15; - } C; - - struct { - U32 ataCmd : 8; - U32 ataDev : 8; - U32 ataCtl : 8; - U32 ataIcc : 8; - U32 ataSecCnt : 16; - U32 ataFeature : 16; - - union { - struct { - U64 ataLba : 48; - U64 rsv16 : 16; - }; - struct { - U8 lba0; - U8 lba1; - U8 lba2; - U8 lba3; - U8 lba4; - U8 lba5; - }; - U8 lba[6]; - }; - - U32 ataAuxiliary; - U32 rsv17; - - U64 rsv18; - } D; - }; -} IODT_V1_s; + +struct __packed SspTaskFrameIu { + unsigned long long LUN; + unsigned short reserved0; + unsigned char function; + unsigned char reserved1; + unsigned short manageTag; + unsigned char reserved2[14]; +}; + + +union __packed SmpFrameIu { + struct { + unsigned char frameType; + unsigned char reqestBytes[31]; + }; + unsigned char smpIURaw[32]; +}; + + +struct __packed DfifoWordCommon { + + union { + struct { + unsigned short type : 2; + unsigned short rsv1 : 2; + unsigned short direct : 2; + unsigned short rFifoID : 4; + unsigned short rsv2 : 6; + }; + unsigned short WD0; + }; + + + union { + + struct { + union { + + struct { + unsigned short darID : 13; + unsigned short rsv3 : 2; + + unsigned short function : 1; + }; + + struct { + unsigned short manageIptt : 13; + }; + }; + }; + + struct { + union { + + struct { + unsigned short reqFrameID : 13; + }; + + struct { + unsigned short manageReqFrameID : 13; + }; + }; + }; + unsigned short WD1; + }; + + union { + struct { + unsigned short phyDiskID : 12; + unsigned short rsv4 : 2; + unsigned short abortCtrl : 2; + }; + unsigned short WD2; + }; +}; + +struct __packed IODT_V1 { + union { + + struct __packed { + union { + struct { + union { + struct { + unsigned char + protocolType : 3; + unsigned char + frameType : 3; + unsigned char iuSrc : 2; + }; + unsigned char byte0; + }; + + union IoDmaCfg dmaCfg; + }; + unsigned short config; + }; + + + + unsigned short cmdLen : 9; + unsigned short rsv0 : 7; + + union { + struct { + unsigned int taskDarID : 13; + unsigned int resv0 : 19; + }; + struct { + unsigned int dataBufLenDWAlign : 24; + + unsigned int rsvd0 : 1; + unsigned int cmdDir : 1; + unsigned int refTagEn : 1; + unsigned int appTagEn : 1; + unsigned int guardTagEn : 1; + unsigned int refTagInc : 1; + unsigned int rsv1 : 1; + unsigned int aborted : 1; + }; + }; + }; + unsigned long long QW0; + }; + + + union { + struct __packed { + struct DfifoWordCommon commonWord; + unsigned short rsv2 : 1; + unsigned short sataCtl : 1; + unsigned short rsv3 : 2; + unsigned short sasCtl : 1; + unsigned short sataByteBlock0 : 1; + unsigned short sataByteBlock1 : 1; + unsigned short rsv4 : 9; + }; + unsigned long long QW1; + }; + + + union { + unsigned long long dataBaseAddr; + unsigned long long QW2; + }; + + + union { + unsigned long long eedpBaseAddr; + unsigned long long QW3; + }; + + + union { + + struct { + unsigned long long cmdIUAddr; + unsigned long long rsv9; + + unsigned long long refTag : 32; + unsigned long long appTag : 16; + unsigned long long rsv10 : 16; + + unsigned long long rsv11; + } A; + + union { + unsigned char cdb[32]; + struct SspTaskFrameIu taskIU; + union SmpFrameIu smpIU; + } B; + + + struct { + unsigned long long opCode : 8; + unsigned long long rsv12 : 56; + + unsigned long long lba : 48; + unsigned long long rsv13 : 16; + + unsigned long long refTag : 32; + unsigned long long appTag : 16; + unsigned long long rsv14 : 16; + + unsigned long long rsv15; + } C; + + struct { + unsigned int ataCmd : 8; + unsigned int ataDev : 8; + unsigned int ataCtl : 8; + unsigned int ataIcc : 8; + unsigned int ataSecCnt : 16; + unsigned int ataFeature : 16; + + union { + struct { + unsigned long long ataLba : 48; + unsigned long long rsv16 : 16; + }; + struct { + unsigned char lba0; + unsigned char lba1; + unsigned char lba2; + unsigned char lba3; + unsigned char lba4; + unsigned char lba5; + }; + unsigned char lba[6]; + }; + + unsigned int ataAuxiliary; + unsigned int rsv17; + + unsigned long long rsv18; + } D; + }; +}; enum { CMD_LEN_THR = 32, @@ -322,4 +321,4 @@ enum { CMD_LEN_L = 11, }; -#endif \ No newline at end of file +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h index 23e352b2c1c3..a9718732633b 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h @@ -1,8 +1,8 @@ -#ifndef __S1861_GLOBAL_BASEADDR_REG_H__ -#define __S1861_GLOBAL_BASEADDR_REG_H__ -#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL -#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL -#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL -#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL -#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL +#ifndef __S1861_GLOBAL_BASEADDR_REG_H__ +#define __S1861_GLOBAL_BASEADDR_REG_H__ +#define HIL_REG0_PS3_REGISTER_F_BASEADDR 0x24000000UL +#define HIL_REG0_PS3_REGISTER_F_SIZE 0x10000UL +#define HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR 0x24010000UL +#define HIL_REG0_PS3_REQUEST_QUEUE_SIZE 0x200UL +#define HIL_REG0_PS3_REGISTER_S_SIZE 0x1FE00UL #endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h index a7f4a47bcce6..3cc18353b858 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_f_reg.h @@ -1,1053 +1,1078 @@ -#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ -#define __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ +#define __S1861_HIL_REG0_PS3_REGISTER_F_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_MACRO__ -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) -#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) -#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) -#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) -#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) -#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) -#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) -#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) -#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) -#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) -#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) -#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) -#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) -#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) -#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) -#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) -#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) -#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) -#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x40) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x48) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x50) +#define HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x58) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x100) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x108) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x110) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x118) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x120) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x128) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x130) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x138) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x140) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x200) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x208) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x210) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x218) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x220) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x228) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x230) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x238) +#define HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_RST (0x0000000002FAF080) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x240) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x248) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_RST (0x0000000000000001) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x300) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x308) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_RST (0x0000000000001FFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x310) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_RST (0x0000000000000FFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x318) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x320) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x328) +#define HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_RST (0x0000000000000007) +#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x330) +#define HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x338) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_RST (0x000000000000007F) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x340) +#define HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x348) +#define HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_RST (0x0000000000000400) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x350) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_RST (0x0000000000001000) +#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x358) +#define HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_RST (0x0000000000000400) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x360) +#define HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x400) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x408) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x410) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x418) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x420) +#define HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x440) +#define HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x500) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x508) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x510) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x518) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x520) +#define HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x600) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x608) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x610) +#define HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x618) +#define HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x620) +#define HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x628) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x630) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x638) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x640) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x648) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x650) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x658) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x660) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x668) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x670) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x678) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x680) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x688) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x690) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x698) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6a8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6b8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6c8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d0) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x6d8) +#define HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x700) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_RST (0xFFFFFFFFFFFFFFFF) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x708) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR \ + (HIL_REG0_PS3_REGISTER_F_BASEADDR + 0x710) +#define HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_RST \ + (0x0000000000000000) #endif -#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_STRUCT__ -typedef union HilReg0Ps3RegisterFPs3Doorbell{ - - volatile U64 val; - struct{ - - U64 cmd : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3Doorbell_u; - -typedef union HilReg0Ps3RegisterFPs3DoorbellIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3DoorbellIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3DoorbellIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3DoorbellIrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3IrqControl{ - - volatile U64 val; - struct{ - - U64 global : 1; - U64 fwState : 1; - U64 tbd : 30; - U64 reserved3 : 32; - }reg; -}HilReg0Ps3RegisterFPs3IrqControl_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetKey{ - - volatile U64 val; - struct{ - - U64 ps3SoftresetKey : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetKey_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetState{ - - volatile U64 val; - struct{ - - U64 rpt : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetState_u; - -typedef union HilReg0Ps3RegisterFPs3Softreset{ - - volatile U64 val; - struct{ - - U64 cmd : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3Softreset_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetIrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow{ - - volatile U64 val; - struct{ - - U64 rpt : 64; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh{ - - volatile U64 val; - struct{ - - U64 rpt : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetTimeCnt{ - - volatile U64 val; - struct{ - - U64 rpt : 64; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetTimeCnt_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn{ - - volatile U64 val; - struct{ - - U64 rpt : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetTimeOutEn_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetKey{ - - volatile U64 val; - struct{ - - U64 ps3HardresetKey : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3HardresetKey_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetState{ - - volatile U64 val; - struct{ - - U64 rpt : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3HardresetState_u; - -typedef union HilReg0Ps3RegisterFPs3Hardreset{ - - volatile U64 val; - struct{ - - U64 config : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3Hardreset_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow{ - - volatile U64 val; - struct{ - - U64 rpt : 64; - }reg; -}HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh{ - - volatile U64 val; - struct{ - - U64 rpt : 8; - U64 reserved1 : 56; - }reg; -}HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetTimeCnt{ - - volatile U64 val; - struct{ - - U64 rpt : 64; - }reg; -}HilReg0Ps3RegisterFPs3HardresetTimeCnt_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetTimeOutEn{ - - volatile U64 val; - struct{ - - U64 rpt : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3HardresetTimeOutEn_u; - -typedef union HilReg0Ps3RegisterFPs3KeyGapCfg{ - - volatile U64 val; - struct{ - - U64 ps3KeyGapCfg : 64; - }reg; -}HilReg0Ps3RegisterFPs3KeyGapCfg_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3HardresetIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3HardresetIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3HardresetIrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3SocFwState{ - - volatile U64 val; - struct{ - - U64 ps3SocFwState : 8; - U64 ps3SocFwStartState : 8; - U64 ps3SocBootState : 8; - U64 tbd : 8; - U64 reserved4 : 32; - }reg; -}HilReg0Ps3RegisterFPs3SocFwState_u; - -typedef union HilReg0Ps3RegisterFPs3MaxFwCmd{ - - volatile U64 val; - struct{ - - U64 ps3MaxFwCmd : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3MaxFwCmd_u; - -typedef union HilReg0Ps3RegisterFPs3MaxChainSize{ - - volatile U64 val; - struct{ - - U64 ps3MaxChainSize : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3MaxChainSize_u; - -typedef union HilReg0Ps3RegisterFPs3MaxVdInfoSize{ - - volatile U64 val; - struct{ - - U64 ps3MaxVdInfoSize : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3MaxVdInfoSize_u; - -typedef union HilReg0Ps3RegisterFPs3MaxNvmePageSize{ - - volatile U64 val; - struct{ - - U64 ps3MaxNvmePageSize : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3MaxNvmePageSize_u; - -typedef union HilReg0Ps3RegisterFPs3FeatureSupport{ - - volatile U64 val; - struct{ - - U64 multiDevfnSupport : 1; - U64 dmaBit64Support : 1; - U64 debugOcmSupport : 1; - U64 tbd1 : 13; - U64 fwHaltSupport : 1; - U64 sglModeSupport : 1; - U64 dumpCrashSupport : 1; - U64 shallowSoftRecoverySupport : 1; - U64 deepSoftRecoverySupport : 1; - U64 hardRecoverySupport : 1; - U64 tbd2 : 42; - }reg; -}HilReg0Ps3RegisterFPs3FeatureSupport_u; - -typedef union HilReg0Ps3RegisterFPs3FirmwareVersion{ - - volatile U64 val; - struct{ - - U64 ps3FmVer : 8; - U64 tbd : 24; - U64 reserved2 : 32; - }reg; -}HilReg0Ps3RegisterFPs3FirmwareVersion_u; - -typedef union HilReg0Ps3RegisterFPs3MaxReplyque{ - - volatile U64 val; - struct{ - - U64 ps3MaxReplyque : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3MaxReplyque_u; - -typedef union HilReg0Ps3RegisterFPs3HardwareVersion{ - - volatile U64 val; - struct{ - - U64 chipId : 64; - }reg; -}HilReg0Ps3RegisterFPs3HardwareVersion_u; - -typedef union HilReg0Ps3RegisterFPs3MgrQueueDepth{ - - volatile U64 val; - struct{ - - U64 ps3MgrQueueDepth : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3MgrQueueDepth_u; - -typedef union HilReg0Ps3RegisterFPs3CmdQueueDepth{ - - volatile U64 val; - struct{ - - U64 ps3CmdQueueDepth : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3CmdQueueDepth_u; - -typedef union HilReg0Ps3RegisterFPs3TfifoDepth{ - - volatile U64 val; - struct{ - - U64 ps3TfifoDepth : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3TfifoDepth_u; - -typedef union HilReg0Ps3RegisterFPs3MaxSecR1xCmds{ - - volatile U64 val; - struct{ - - U64 ps3MaxSecR1xCmds : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u; - -typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3HilAdvice2directCnt0_u; - -typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3HilAdvice2directCnt1_u; - -typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3HilAdvice2directCnt2_u; - -typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3HilAdvice2directCnt3_u; - -typedef union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3HilAdvice2directCntAll_u; - -typedef union HilReg0Ps3RegisterFPs3IrqStatusRpt{ - - volatile U64 val; - struct{ - - U64 doorbell : 1; - U64 reserved1 : 3; - U64 softreset : 1; - U64 reserved3 : 3; - U64 dumpCtrl : 1; - U64 reserved5 : 3; - U64 debug0 : 1; - U64 reserved7 : 3; - U64 debug1 : 1; - U64 reserved9 : 3; - U64 debug2 : 1; - U64 reserved11 : 3; - U64 debug3 : 1; - U64 reserved13 : 3; - U64 debug4 : 1; - U64 reserved15 : 3; - U64 cmdTrigger : 1; - U64 reserved17 : 3; - U64 hardreset : 1; - U64 reserved19 : 3; - U64 sessioncmdAddr : 1; - U64 reserved21 : 23; - }reg; -}HilReg0Ps3RegisterFPs3IrqStatusRpt_u; - -typedef union HilReg0Ps3RegisterFPs3DumpCtrl{ - - volatile U64 val; - struct{ - - U64 cmd : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RegisterFPs3DumpCtrl_u; - -typedef union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3DumpCtrlIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3DumpCtrlIrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3DumpStatus{ - - volatile U64 val; - struct{ - - U64 dmaFinish : 1; - U64 hasCrashDump : 1; - U64 hasFwDump : 1; - U64 hasBarDump : 1; - U64 hasAutoDump : 2; - U64 tbd : 10; - U64 reserved6 : 48; - }reg; -}HilReg0Ps3RegisterFPs3DumpStatus_u; - -typedef union HilReg0Ps3RegisterFPs3DumpDataSize{ - - volatile U64 val; - struct{ - - U64 ps3DumpDataSize : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RegisterFPs3DumpDataSize_u; - -typedef union HilReg0Ps3RegisterFPs3CmdTrigger{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3CmdTrigger_u; - -typedef union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3CmdTriggerIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3CmdTriggerIrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3SoftresetCounter{ - - volatile U64 val; - struct{ - - U64 rpt : 32; - U64 tbd : 32; - }reg; -}HilReg0Ps3RegisterFPs3SoftresetCounter_u; - -typedef union HilReg0Ps3RegisterFPs3RegCmdState{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3RegCmdState_u; - -typedef union HilReg0Ps3RegisterFPs3Debug0{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug0_u; - -typedef union HilReg0Ps3RegisterFPs3Debug0IrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug0IrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3Debug0IrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug0IrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3Debug1{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug1_u; - -typedef union HilReg0Ps3RegisterFPs3Debug1IrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug1IrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3Debug1IrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug1IrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3Debug2{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug2_u; - -typedef union HilReg0Ps3RegisterFPs3Debug2IrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug2IrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3Debug2IrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug2IrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3Debug3{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug3_u; - -typedef union HilReg0Ps3RegisterFPs3Debug3IrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug3IrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3Debug3IrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug3IrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3Debug4{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug4_u; - -typedef union HilReg0Ps3RegisterFPs3Debug4IrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug4IrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3Debug4IrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3Debug4IrqMask_u; - -typedef union HilReg0Ps3RegisterFPs3Debug5{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug5_u; - -typedef union HilReg0Ps3RegisterFPs3Debug6{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug6_u; - -typedef union HilReg0Ps3RegisterFPs3Debug7{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug7_u; - -typedef union HilReg0Ps3RegisterFPs3Debug8{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug8_u; - -typedef union HilReg0Ps3RegisterFPs3Debug9{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug9_u; - -typedef union HilReg0Ps3RegisterFPs3Debug10{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug10_u; - -typedef union HilReg0Ps3RegisterFPs3Debug11{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug11_u; - -typedef union HilReg0Ps3RegisterFPs3Debug12{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3Debug12_u; - -typedef union HilReg0Ps3RegisterFPs3SessioncmdAddr{ - - volatile U64 val; - struct{ - - U64 cmd : 64; - }reg; -}HilReg0Ps3RegisterFPs3SessioncmdAddr_u; - -typedef union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear{ - - volatile U64 val; - struct{ - - U64 pulse : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear_u; - -typedef union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask{ - - volatile U64 val; - struct{ - - U64 level : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask_u; - -typedef struct HilReg0Ps3RegisterF{ - - U64 reserved0[8]; - HilReg0Ps3RegisterFPs3Doorbell_u ps3Doorbell; - HilReg0Ps3RegisterFPs3DoorbellIrqClear_u ps3DoorbellIrqClear; - HilReg0Ps3RegisterFPs3DoorbellIrqMask_u ps3DoorbellIrqMask; - HilReg0Ps3RegisterFPs3IrqControl_u ps3IrqControl; - U64 reserved1[20]; - HilReg0Ps3RegisterFPs3SoftresetKey_u ps3SoftresetKey; - HilReg0Ps3RegisterFPs3SoftresetState_u ps3SoftresetState; - HilReg0Ps3RegisterFPs3Softreset_u ps3Softreset; - HilReg0Ps3RegisterFPs3SoftresetIrqClear_u ps3SoftresetIrqClear; - HilReg0Ps3RegisterFPs3SoftresetIrqMask_u ps3SoftresetIrqMask; - HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow_u ps3SoftresetKeyShiftRegLow; - HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh_u ps3SoftresetKeyShiftRegHigh; - HilReg0Ps3RegisterFPs3SoftresetTimeCnt_u ps3SoftresetTimeCnt; - HilReg0Ps3RegisterFPs3SoftresetTimeOutEn_u ps3SoftresetTimeOutEn; - U64 reserved2[23]; - HilReg0Ps3RegisterFPs3HardresetKey_u ps3HardresetKey; - HilReg0Ps3RegisterFPs3HardresetState_u ps3HardresetState; - HilReg0Ps3RegisterFPs3Hardreset_u ps3Hardreset; - HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow_u ps3HardresetKeyShiftRegLow; - HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh_u ps3HardresetKeyShiftRegHigh; - HilReg0Ps3RegisterFPs3HardresetTimeCnt_u ps3HardresetTimeCnt; - HilReg0Ps3RegisterFPs3HardresetTimeOutEn_u ps3HardresetTimeOutEn; - HilReg0Ps3RegisterFPs3KeyGapCfg_u ps3KeyGapCfg; - HilReg0Ps3RegisterFPs3HardresetIrqClear_u ps3HardresetIrqClear; - HilReg0Ps3RegisterFPs3HardresetIrqMask_u ps3HardresetIrqMask; - U64 reserved3[22]; - HilReg0Ps3RegisterFPs3SocFwState_u ps3SocFwState; - HilReg0Ps3RegisterFPs3MaxFwCmd_u ps3MaxFwCmd; - HilReg0Ps3RegisterFPs3MaxChainSize_u ps3MaxChainSize; - HilReg0Ps3RegisterFPs3MaxVdInfoSize_u ps3MaxVdInfoSize; - HilReg0Ps3RegisterFPs3MaxNvmePageSize_u ps3MaxNvmePageSize; - HilReg0Ps3RegisterFPs3FeatureSupport_u ps3FeatureSupport; - HilReg0Ps3RegisterFPs3FirmwareVersion_u ps3FirmwareVersion; - HilReg0Ps3RegisterFPs3MaxReplyque_u ps3MaxReplyque; - HilReg0Ps3RegisterFPs3HardwareVersion_u ps3HardwareVersion; - HilReg0Ps3RegisterFPs3MgrQueueDepth_u ps3MgrQueueDepth; - HilReg0Ps3RegisterFPs3CmdQueueDepth_u ps3CmdQueueDepth; - HilReg0Ps3RegisterFPs3TfifoDepth_u ps3TfifoDepth; - HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u ps3MaxSecR1xCmds; - U64 reserved4[19]; - HilReg0Ps3RegisterFPs3HilAdvice2directCnt0_u ps3HilAdvice2directCnt0; - HilReg0Ps3RegisterFPs3HilAdvice2directCnt1_u ps3HilAdvice2directCnt1; - HilReg0Ps3RegisterFPs3HilAdvice2directCnt2_u ps3HilAdvice2directCnt2; - HilReg0Ps3RegisterFPs3HilAdvice2directCnt3_u ps3HilAdvice2directCnt3; - HilReg0Ps3RegisterFPs3HilAdvice2directCntAll_u ps3HilAdvice2directCntAll; - U64 reserved5[3]; - HilReg0Ps3RegisterFPs3IrqStatusRpt_u ps3IrqStatusRpt; - U64 reserved6[23]; - HilReg0Ps3RegisterFPs3DumpCtrl_u ps3DumpCtrl; - HilReg0Ps3RegisterFPs3DumpCtrlIrqClear_u ps3DumpCtrlIrqClear; - HilReg0Ps3RegisterFPs3DumpCtrlIrqMask_u ps3DumpCtrlIrqMask; - HilReg0Ps3RegisterFPs3DumpStatus_u ps3DumpStatus; - HilReg0Ps3RegisterFPs3DumpDataSize_u ps3DumpDataSize; - U64 reserved7[27]; - HilReg0Ps3RegisterFPs3CmdTrigger_u ps3CmdTrigger; - HilReg0Ps3RegisterFPs3CmdTriggerIrqClear_u ps3CmdTriggerIrqClear; - HilReg0Ps3RegisterFPs3CmdTriggerIrqMask_u ps3CmdTriggerIrqMask; - HilReg0Ps3RegisterFPs3SoftresetCounter_u ps3SoftresetCounter; - HilReg0Ps3RegisterFPs3RegCmdState_u ps3RegCmdState; - HilReg0Ps3RegisterFPs3Debug0_u ps3Debug0; - HilReg0Ps3RegisterFPs3Debug0IrqClear_u ps3Debug0IrqClear; - HilReg0Ps3RegisterFPs3Debug0IrqMask_u ps3Debug0IrqMask; - HilReg0Ps3RegisterFPs3Debug1_u ps3Debug1; - HilReg0Ps3RegisterFPs3Debug1IrqClear_u ps3Debug1IrqClear; - HilReg0Ps3RegisterFPs3Debug1IrqMask_u ps3Debug1IrqMask; - HilReg0Ps3RegisterFPs3Debug2_u ps3Debug2; - HilReg0Ps3RegisterFPs3Debug2IrqClear_u ps3Debug2IrqClear; - HilReg0Ps3RegisterFPs3Debug2IrqMask_u ps3Debug2IrqMask; - HilReg0Ps3RegisterFPs3Debug3_u ps3Debug3; - HilReg0Ps3RegisterFPs3Debug3IrqClear_u ps3Debug3IrqClear; - HilReg0Ps3RegisterFPs3Debug3IrqMask_u ps3Debug3IrqMask; - HilReg0Ps3RegisterFPs3Debug4_u ps3Debug4; - HilReg0Ps3RegisterFPs3Debug4IrqClear_u ps3Debug4IrqClear; - HilReg0Ps3RegisterFPs3Debug4IrqMask_u ps3Debug4IrqMask; - HilReg0Ps3RegisterFPs3Debug5_u ps3Debug5; - HilReg0Ps3RegisterFPs3Debug6_u ps3Debug6; - HilReg0Ps3RegisterFPs3Debug7_u ps3Debug7; - HilReg0Ps3RegisterFPs3Debug8_u ps3Debug8; - HilReg0Ps3RegisterFPs3Debug9_u ps3Debug9; - HilReg0Ps3RegisterFPs3Debug10_u ps3Debug10; - HilReg0Ps3RegisterFPs3Debug11_u ps3Debug11; - HilReg0Ps3RegisterFPs3Debug12_u ps3Debug12; - U64 reserved8[4]; - HilReg0Ps3RegisterFPs3SessioncmdAddr_u ps3SessioncmdAddr; - HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear_u ps3SessioncmdAddrIrqClear; - HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask_u ps3SessioncmdAddrIrqMask; -}HilReg0Ps3RegisterF_s; +#ifndef __S1861_HIL_REG0_PS3_REGISTER_F_REG_STRUCT__ +union HilReg0Ps3RegisterFPs3Doorbell { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DoorbellIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DoorbellIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3IrqControl { + volatile unsigned long long val; + struct { + + unsigned long long global : 1; + unsigned long long fwState : 1; + unsigned long long tbd : 30; + unsigned long long reserved3 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetKey { + volatile unsigned long long val; + struct { + + unsigned long long ps3SoftresetKey : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetState { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Softreset { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetTimeCnt { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetKey { + volatile unsigned long long val; + struct { + + unsigned long long ps3HardresetKey : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetState { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Hardreset { + volatile unsigned long long val; + struct { + + unsigned long long config : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 8; + unsigned long long reserved1 : 56; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetTimeCnt { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetTimeOutEn { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3KeyGapCfg { + volatile unsigned long long val; + struct { + + unsigned long long ps3KeyGapCfg : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardresetIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SocFwState { + volatile unsigned long long val; + struct { + + unsigned long long ps3SocFwState : 8; + unsigned long long ps3SocFwStartState : 8; + unsigned long long ps3SocBootState : 8; + unsigned long long tbd : 8; + unsigned long long reserved4 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxFwCmd { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxFwCmd : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxChainSize { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxChainSize : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxVdInfoSize { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxVdInfoSize : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxNvmePageSize { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxNvmePageSize : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3FeatureSupport { + volatile unsigned long long val; + struct { + + unsigned long long multiDevfnSupport : 1; + unsigned long long dmaBit64Support : 1; + unsigned long long debugOcmSupport : 1; + unsigned long long tbd1 : 13; + unsigned long long fwHaltSupport : 1; + unsigned long long sglModeSupport : 1; + unsigned long long dumpCrashSupport : 1; + unsigned long long shallowSoftRecoverySupport : 1; + unsigned long long deepSoftRecoverySupport : 1; + unsigned long long hardRecoverySupport : 1; + unsigned long long tbd2 : 42; + } reg; +}; + +union HilReg0Ps3RegisterFPs3FirmwareVersion { + volatile unsigned long long val; + struct { + + unsigned long long ps3FmVer : 8; + unsigned long long tbd : 24; + unsigned long long reserved2 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxReplyque { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxReplyque : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HardwareVersion { + volatile unsigned long long val; + struct { + + unsigned long long chipId : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MgrQueueDepth { + volatile unsigned long long val; + struct { + + unsigned long long ps3MgrQueueDepth : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3CmdQueueDepth { + volatile unsigned long long val; + struct { + + unsigned long long ps3CmdQueueDepth : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3TfifoDepth { + volatile unsigned long long val; + struct { + + unsigned long long ps3TfifoDepth : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3MaxSecR1xCmds { + volatile unsigned long long val; + struct { + + unsigned long long ps3MaxSecR1xCmds : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3IrqStatusRpt { + volatile unsigned long long val; + struct { + + unsigned long long doorbell : 1; + unsigned long long reserved1 : 3; + unsigned long long softreset : 1; + unsigned long long reserved3 : 3; + unsigned long long dumpCtrl : 1; + unsigned long long reserved5 : 3; + unsigned long long debug0 : 1; + unsigned long long reserved7 : 3; + unsigned long long debug1 : 1; + unsigned long long reserved9 : 3; + unsigned long long debug2 : 1; + unsigned long long reserved11 : 3; + unsigned long long debug3 : 1; + unsigned long long reserved13 : 3; + unsigned long long debug4 : 1; + unsigned long long reserved15 : 3; + unsigned long long cmdTrigger : 1; + unsigned long long reserved17 : 3; + unsigned long long hardreset : 1; + unsigned long long reserved19 : 3; + unsigned long long sessioncmdAddr : 1; + unsigned long long reserved21 : 23; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DumpCtrl { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DumpStatus { + volatile unsigned long long val; + struct { + + unsigned long long dmaFinish : 1; + unsigned long long hasCrashDump : 1; + unsigned long long hasFwDump : 1; + unsigned long long hasBarDump : 1; + unsigned long long hasAutoDump : 2; + unsigned long long tbd : 10; + unsigned long long reserved6 : 48; + } reg; +}; + +union HilReg0Ps3RegisterFPs3DumpDataSize { + volatile unsigned long long val; + struct { + + unsigned long long ps3DumpDataSize : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3CmdTrigger { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SoftresetCounter { + volatile unsigned long long val; + struct { + + unsigned long long rpt : 32; + unsigned long long tbd : 32; + } reg; +}; + +union HilReg0Ps3RegisterFPs3RegCmdState { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug0 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug0IrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug0IrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug1 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug1IrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug1IrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug2 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug2IrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug2IrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug3 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug3IrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug3IrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug4 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug4IrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug4IrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug5 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug6 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug7 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug8 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug9 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug10 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug11 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3Debug12 { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SessioncmdAddr { + volatile unsigned long long val; + struct { + + unsigned long long cmd : 64; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear { + volatile unsigned long long val; + struct { + + unsigned long long pulse : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask { + volatile unsigned long long val; + struct { + + unsigned long long level : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +struct HilReg0Ps3RegisterF { + + unsigned long long reserved0[8]; + union HilReg0Ps3RegisterFPs3Doorbell ps3Doorbell; + union HilReg0Ps3RegisterFPs3DoorbellIrqClear ps3DoorbellIrqClear; + union HilReg0Ps3RegisterFPs3DoorbellIrqMask ps3DoorbellIrqMask; + union HilReg0Ps3RegisterFPs3IrqControl ps3IrqControl; + unsigned long long reserved1[20]; + union HilReg0Ps3RegisterFPs3SoftresetKey ps3SoftresetKey; + union HilReg0Ps3RegisterFPs3SoftresetState ps3SoftresetState; + union HilReg0Ps3RegisterFPs3Softreset ps3Softreset; + union HilReg0Ps3RegisterFPs3SoftresetIrqClear ps3SoftresetIrqClear; + union HilReg0Ps3RegisterFPs3SoftresetIrqMask ps3SoftresetIrqMask; + + union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegLow + ps3SoftresetKeyShiftRegLow; + union HilReg0Ps3RegisterFPs3SoftresetKeyShiftRegHigh + ps3SoftresetKeyShiftRegHigh; + union HilReg0Ps3RegisterFPs3SoftresetTimeCnt ps3SoftresetTimeCnt; + union HilReg0Ps3RegisterFPs3SoftresetTimeOutEn ps3SoftresetTimeOutEn; + unsigned long long reserved2[23]; + union HilReg0Ps3RegisterFPs3HardresetKey ps3HardresetKey; + union HilReg0Ps3RegisterFPs3HardresetState ps3HardresetState; + union HilReg0Ps3RegisterFPs3Hardreset ps3Hardreset; + + union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegLow + ps3HardresetKeyShiftRegLow; + union HilReg0Ps3RegisterFPs3HardresetKeyShiftRegHigh + ps3HardresetKeyShiftRegHigh; + union HilReg0Ps3RegisterFPs3HardresetTimeCnt ps3HardresetTimeCnt; + union HilReg0Ps3RegisterFPs3HardresetTimeOutEn ps3HardresetTimeOutEn; + union HilReg0Ps3RegisterFPs3KeyGapCfg ps3KeyGapCfg; + union HilReg0Ps3RegisterFPs3HardresetIrqClear ps3HardresetIrqClear; + union HilReg0Ps3RegisterFPs3HardresetIrqMask ps3HardresetIrqMask; + unsigned long long reserved3[22]; + union HilReg0Ps3RegisterFPs3SocFwState ps3SocFwState; + union HilReg0Ps3RegisterFPs3MaxFwCmd ps3MaxFwCmd; + union HilReg0Ps3RegisterFPs3MaxChainSize ps3MaxChainSize; + union HilReg0Ps3RegisterFPs3MaxVdInfoSize ps3MaxVdInfoSize; + union HilReg0Ps3RegisterFPs3MaxNvmePageSize ps3MaxNvmePageSize; + union HilReg0Ps3RegisterFPs3FeatureSupport ps3FeatureSupport; + union HilReg0Ps3RegisterFPs3FirmwareVersion ps3FirmwareVersion; + union HilReg0Ps3RegisterFPs3MaxReplyque ps3MaxReplyque; + union HilReg0Ps3RegisterFPs3HardwareVersion ps3HardwareVersion; + union HilReg0Ps3RegisterFPs3MgrQueueDepth ps3MgrQueueDepth; + union HilReg0Ps3RegisterFPs3CmdQueueDepth ps3CmdQueueDepth; + union HilReg0Ps3RegisterFPs3TfifoDepth ps3TfifoDepth; + union HilReg0Ps3RegisterFPs3MaxSecR1xCmds ps3MaxSecR1xCmds; + unsigned long long reserved4[19]; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt0 ps3HilAdvice2directCnt0; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt1 ps3HilAdvice2directCnt1; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt2 ps3HilAdvice2directCnt2; + union HilReg0Ps3RegisterFPs3HilAdvice2directCnt3 ps3HilAdvice2directCnt3; + union HilReg0Ps3RegisterFPs3HilAdvice2directCntAll + ps3HilAdvice2directCntAll; + unsigned long long reserved5[3]; + union HilReg0Ps3RegisterFPs3IrqStatusRpt ps3IrqStatusRpt; + unsigned long long reserved6[23]; + union HilReg0Ps3RegisterFPs3DumpCtrl ps3DumpCtrl; + union HilReg0Ps3RegisterFPs3DumpCtrlIrqClear ps3DumpCtrlIrqClear; + union HilReg0Ps3RegisterFPs3DumpCtrlIrqMask ps3DumpCtrlIrqMask; + union HilReg0Ps3RegisterFPs3DumpStatus ps3DumpStatus; + union HilReg0Ps3RegisterFPs3DumpDataSize ps3DumpDataSize; + unsigned long long reserved7[27]; + union HilReg0Ps3RegisterFPs3CmdTrigger ps3CmdTrigger; + union HilReg0Ps3RegisterFPs3CmdTriggerIrqClear ps3CmdTriggerIrqClear; + union HilReg0Ps3RegisterFPs3CmdTriggerIrqMask ps3CmdTriggerIrqMask; + union HilReg0Ps3RegisterFPs3SoftresetCounter ps3SoftresetCounter; + union HilReg0Ps3RegisterFPs3RegCmdState ps3RegCmdState; + union HilReg0Ps3RegisterFPs3Debug0 ps3Debug0; + union HilReg0Ps3RegisterFPs3Debug0IrqClear ps3Debug0IrqClear; + union HilReg0Ps3RegisterFPs3Debug0IrqMask ps3Debug0IrqMask; + union HilReg0Ps3RegisterFPs3Debug1 ps3Debug1; + union HilReg0Ps3RegisterFPs3Debug1IrqClear ps3Debug1IrqClear; + union HilReg0Ps3RegisterFPs3Debug1IrqMask ps3Debug1IrqMask; + union HilReg0Ps3RegisterFPs3Debug2 ps3Debug2; + union HilReg0Ps3RegisterFPs3Debug2IrqClear ps3Debug2IrqClear; + union HilReg0Ps3RegisterFPs3Debug2IrqMask ps3Debug2IrqMask; + union HilReg0Ps3RegisterFPs3Debug3 ps3Debug3; + union HilReg0Ps3RegisterFPs3Debug3IrqClear ps3Debug3IrqClear; + union HilReg0Ps3RegisterFPs3Debug3IrqMask ps3Debug3IrqMask; + union HilReg0Ps3RegisterFPs3Debug4 ps3Debug4; + union HilReg0Ps3RegisterFPs3Debug4IrqClear ps3Debug4IrqClear; + union HilReg0Ps3RegisterFPs3Debug4IrqMask ps3Debug4IrqMask; + union HilReg0Ps3RegisterFPs3Debug5 ps3Debug5; + union HilReg0Ps3RegisterFPs3Debug6 ps3Debug6; + union HilReg0Ps3RegisterFPs3Debug7 ps3Debug7; + union HilReg0Ps3RegisterFPs3Debug8 ps3Debug8; + union HilReg0Ps3RegisterFPs3Debug9 ps3Debug9; + union HilReg0Ps3RegisterFPs3Debug10 ps3Debug10; + union HilReg0Ps3RegisterFPs3Debug11 ps3Debug11; + union HilReg0Ps3RegisterFPs3Debug12 ps3Debug12; + unsigned long long reserved8[4]; + union HilReg0Ps3RegisterFPs3SessioncmdAddr ps3SessioncmdAddr; + union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqClear + ps3SessioncmdAddrIrqClear; + union HilReg0Ps3RegisterFPs3SessioncmdAddrIrqMask + ps3SessioncmdAddrIrqMask; +}; +#endif #endif -#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h index e8593293b754..454f025bf85b 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h @@ -1,38 +1,39 @@ -#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ -#define __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ +#define __S1861_HIL_REG0_PS3_REGISTER_S_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_MACRO__ -#define HIL_REG0_PS3_REGISTER_S_PS3_FUCNTION_LOCK_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUCNTION_LOCK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) -#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_ADDR \ + (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x0) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_ADDR \ + (HIL_REG0_PS3_REGISTER_S_BASEADDR + 0x8) +#define HIL_REG0_PS3_REGISTER_S_PS3_FUNCTION_LOCK_OWNER_RST (0x0000000000000003) #endif -#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_STRUCT__ -typedef union HilReg0Ps3RegisterSPs3FucntionLock{ +#ifndef __S1861_HIL_REG0_PS3_REGISTER_S_REG_STRUCT__ +union HilReg0Ps3RegisterSPs3FucntionLock { + volatile unsigned long long val; + struct { - volatile U64 val; - struct{ + unsigned long long lock : 1; + unsigned long long reserved1 : 63; + } reg; +}; - U64 lock : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RegisterSPs3FucntionLock_u; +union HilReg0Ps3RegisterSPs3FunctionLockOwner { + volatile unsigned long long val; + struct { -typedef union HilReg0Ps3RegisterSPs3FunctionLockOwner{ + unsigned long long display : 2; + unsigned long long reserved1 : 62; + } reg; +}; - volatile U64 val; - struct{ +struct HilReg0Ps3RegisterS { - U64 display : 2; - U64 reserved1 : 62; - }reg; -}HilReg0Ps3RegisterSPs3FunctionLockOwner_u; - -typedef struct HilReg0Ps3RegisterS{ - - HilReg0Ps3RegisterSPs3FucntionLock_u ps3FucntionLock; - HilReg0Ps3RegisterSPs3FunctionLockOwner_u ps3FunctionLockOwner; -}HilReg0Ps3RegisterS_s; + union HilReg0Ps3RegisterSPs3FucntionLock ps3FucntionLock; + union HilReg0Ps3RegisterSPs3FunctionLockOwner ps3FunctionLockOwner; +}; +#endif #endif -#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h index 688575a7ec4e..3406bf9f6466 100644 --- a/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h +++ b/drivers/scsi/linkdata/ps3stor/include/hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h @@ -1,420 +1,424 @@ -#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ -#define __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ +#define __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_H__ #include "s1861_global_baseaddr.h" #ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_MACRO__ -#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) -#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n)*0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n)*0x8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST (0x000000000000003F) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) -#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x0) +#define HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_RST (0xFFFFFFFFFFFFFFFF) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOERRCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x10) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_RST (0x0000000C1FFF0000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x18) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELCONFIG_RST (0x0000000300000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x20) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFORST_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x28) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOIOCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x30) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOFLOWCNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x38) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_STATUS_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x40) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_SET_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x48) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_CLR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x50) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_INT_MASK_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x58) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_CNT_CLR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x60) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOORDERERROR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_ADDR(_n) \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x68 + (_n) * 0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODINSHIFT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_ADDR(_n) \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x88 + (_n) * 0x8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFODOUTSHIFT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xa8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_MAXLEVEL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_RST (0x0000000000000002) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xb8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_EN_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOINIT_MAX_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xc8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_CNT_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOSTATUS_ECC_ADDR_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xd8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_DECODER_OVERFLOW_RST \ + (0x000000000000003F) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFO_ECC_BAD_PROJECT_RST (0x0000000000000001) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xe8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOOVERFLOW_WORD_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf0) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCTL_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0xf8) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORCNTCLR_RST \ + (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x100) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORLOW_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x108) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORMID_RST (0x0000000000000000) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_ADDR \ + (HIL_REG0_PS3_REQUEST_QUEUE_BASEADDR + 0x110) +#define HIL_REG0_PS3_REQUEST_QUEUE_FIFOLEVELMONITORHIGH_RST (0x0000000000000000) #endif -#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_STRUCT__ -typedef union HilReg0Ps3RequestQueuePs3RequestQueue{ - - volatile U64 val; - struct{ - - U64 port : 64; - }reg; -}HilReg0Ps3RequestQueuePs3RequestQueue_u; - -typedef union HilReg0Ps3RequestQueueFifoErrCnt{ - - volatile U64 val; - struct{ - - U64 waddrerr : 32; - U64 reserved1 : 32; - }reg; -}HilReg0Ps3RequestQueueFifoErrCnt_u; - -typedef union HilReg0Ps3RequestQueueFifoStatus{ - - volatile U64 val; - struct{ - - U64 filled : 16; - U64 fifoDepth : 16; - U64 almostfull : 1; - U64 full : 1; - U64 almostempty : 1; - U64 empty : 1; - U64 reserved6 : 28; - }reg; -}HilReg0Ps3RequestQueueFifoStatus_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelConfig{ - - volatile U64 val; - struct{ - - U64 cfgAempty : 16; - U64 cfgAfull : 16; - U64 emptyProtect : 1; - U64 fullProtect : 1; - U64 reserved4 : 30; - }reg; -}HilReg0Ps3RequestQueueFifoLevelConfig_u; - -typedef union HilReg0Ps3RequestQueueFifoRst{ - - volatile U64 val; - struct{ - - U64 resetPls : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RequestQueueFifoRst_u; - -typedef union HilReg0Ps3RequestQueueFifoIOCnt{ - - volatile U64 val; - struct{ - - U64 wr : 32; - U64 rd : 32; - }reg; -}HilReg0Ps3RequestQueueFifoIOCnt_u; - -typedef union HilReg0Ps3RequestQueueFifoFlowCnt{ - - volatile U64 val; - struct{ - - U64 overflow : 32; - U64 underflow : 32; - }reg; -}HilReg0Ps3RequestQueueFifoFlowCnt_u; - -typedef union HilReg0Ps3RequestQueueFifoIntStatus{ - - volatile U64 val; - struct{ - - U64 overflowStatus : 1; - U64 underflowStatus : 1; - U64 nemptyStatus : 1; - U64 eccBadStatus : 1; - U64 reserved4 : 60; - }reg; -}HilReg0Ps3RequestQueueFifoIntStatus_u; - -typedef union HilReg0Ps3RequestQueueFifoIntSet{ - - volatile U64 val; - struct{ - - U64 overflowSet : 1; - U64 underflowSet : 1; - U64 nemptySet : 1; - U64 eccBadSet : 1; - U64 reserved4 : 60; - }reg; -}HilReg0Ps3RequestQueueFifoIntSet_u; - -typedef union HilReg0Ps3RequestQueueFifoIntClr{ - - volatile U64 val; - struct{ - - U64 overflowClr : 1; - U64 underflowClr : 1; - U64 nemptyClr : 1; - U64 eccBadClr : 1; - U64 reserved4 : 60; - }reg; -}HilReg0Ps3RequestQueueFifoIntClr_u; - -typedef union HilReg0Ps3RequestQueueFifoIntMask{ - - volatile U64 val; - struct{ - - U64 overflowMask : 1; - U64 underflowMask : 1; - U64 nemptyMask : 1; - U64 eccBadMask : 1; - U64 reserved4 : 60; - }reg; -}HilReg0Ps3RequestQueueFifoIntMask_u; - -typedef union HilReg0Ps3RequestQueueFifoCntClr{ - - volatile U64 val; - struct{ - - U64 fifowrcntClr : 1; - U64 fifordcntClr : 1; - U64 fifoerrcntClr : 1; - U64 fifoordererrwrcntClr : 1; - U64 fifoordererrrdcntClr : 1; - U64 fifobit1errcntClr : 1; - U64 fifobit2errcntClr : 1; - U64 reserved7 : 57; - }reg; -}HilReg0Ps3RequestQueueFifoCntClr_u; - -typedef union HilReg0Ps3RequestQueueFifoOrderError{ - - volatile U64 val; - struct{ - - U64 wrcnt : 32; - U64 rdcnt : 32; - }reg; -}HilReg0Ps3RequestQueueFifoOrderError_u; - -typedef union HilReg0Ps3RequestQueueFifoDinShift{ - - volatile U64 val; - struct{ - - U64 val : 64; - }reg; -}HilReg0Ps3RequestQueueFifoDinShift_u; - -typedef union HilReg0Ps3RequestQueueFifoDoutShift{ - - volatile U64 val; - struct{ - - U64 val : 64; - }reg; -}HilReg0Ps3RequestQueueFifoDoutShift_u; - -typedef union HilReg0Ps3RequestQueueFifostatusMaxlevel{ - - volatile U64 val; - struct{ - - U64 val : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RequestQueueFifostatusMaxlevel_u; - -typedef union HilReg0Ps3RequestQueueFifoInit{ - - volatile U64 val; - struct{ - - U64 stat : 2; - U64 reserved1 : 62; - }reg; -}HilReg0Ps3RequestQueueFifoInit_u; - -typedef union HilReg0Ps3RequestQueueFifoinitEn{ - - volatile U64 val; - struct{ - - U64 start : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RequestQueueFifoinitEn_u; - -typedef union HilReg0Ps3RequestQueueFifoinitMax{ - - volatile U64 val; - struct{ - - U64 num : 16; - U64 reserved1 : 48; - }reg; -}HilReg0Ps3RequestQueueFifoinitMax_u; - -typedef union HilReg0Ps3RequestQueueFifostatusEccCnt{ - - volatile U64 val; - struct{ - - U64 bit1Err : 32; - U64 bit2Err : 32; - }reg; -}HilReg0Ps3RequestQueueFifostatusEccCnt_u; - -typedef union HilReg0Ps3RequestQueueFifostatusEccAddr{ - - volatile U64 val; - struct{ - - U64 errPoint : 64; - }reg; -}HilReg0Ps3RequestQueueFifostatusEccAddr_u; - -typedef union HilReg0Ps3RequestQueueFifoDecoderOverflow{ - - volatile U64 val; - struct{ - - U64 rCmdwordEmpty : 1; - U64 rPortindexEmpty : 1; - U64 rCmdbackEmpty : 1; - U64 wCmdwordEmpty : 1; - U64 wPortindexEmpty : 1; - U64 wCmdbackEmpty : 1; - U64 rCmdwordFull : 1; - U64 rPortindexFull : 1; - U64 rCmdbackFull : 1; - U64 wCmdwordFull : 1; - U64 wPortindexFull : 1; - U64 wCmdbackFull : 1; - U64 reserved12 : 52; - }reg; -}HilReg0Ps3RequestQueueFifoDecoderOverflow_u; - -typedef union HilReg0Ps3RequestQueueFifoEccBadProject{ - - volatile U64 val; - struct{ - - U64 en : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RequestQueueFifoEccBadProject_u; - -typedef union HilReg0Ps3RequestQueueFifooverflowWord{ - - volatile U64 val; - struct{ - - U64 record : 64; - }reg; -}HilReg0Ps3RequestQueueFifooverflowWord_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelMonitorCtl{ - - volatile U64 val; - struct{ - - U64 low : 16; - U64 high : 16; - U64 en : 1; - U64 reserved3 : 31; - }reg; -}HilReg0Ps3RequestQueueFifoLevelMonitorCtl_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr{ - - volatile U64 val; - struct{ - - U64 en : 1; - U64 reserved1 : 63; - }reg; -}HilReg0Ps3RequestQueueFifoLevelMonitorCntClr_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelMonitorLow{ - - volatile U64 val; - struct{ - - U64 cnt : 64; - }reg; -}HilReg0Ps3RequestQueueFifoLevelMonitorLow_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelMonitorMid{ - - volatile U64 val; - struct{ - - U64 cnt : 64; - }reg; -}HilReg0Ps3RequestQueueFifoLevelMonitorMid_u; - -typedef union HilReg0Ps3RequestQueueFifoLevelMonitorHigh{ - - volatile U64 val; - struct{ - - U64 cnt : 64; - }reg; -}HilReg0Ps3RequestQueueFifoLevelMonitorHigh_u; - -typedef struct HilReg0Ps3RequestQueue{ - - HilReg0Ps3RequestQueuePs3RequestQueue_u ps3RequestQueue; - HilReg0Ps3RequestQueueFifoErrCnt_u fifoErrCnt; - HilReg0Ps3RequestQueueFifoStatus_u fifoStatus; - HilReg0Ps3RequestQueueFifoLevelConfig_u fifoLevelConfig; - HilReg0Ps3RequestQueueFifoRst_u fifoRst; - HilReg0Ps3RequestQueueFifoIOCnt_u fifoIOCnt; - HilReg0Ps3RequestQueueFifoFlowCnt_u fifoFlowCnt; - HilReg0Ps3RequestQueueFifoIntStatus_u fifoIntStatus; - HilReg0Ps3RequestQueueFifoIntSet_u fifoIntSet; - HilReg0Ps3RequestQueueFifoIntClr_u fifoIntClr; - HilReg0Ps3RequestQueueFifoIntMask_u fifoIntMask; - HilReg0Ps3RequestQueueFifoCntClr_u fifoCntClr; - HilReg0Ps3RequestQueueFifoOrderError_u fifoOrderError; - HilReg0Ps3RequestQueueFifoDinShift_u fifoDinShift[4]; - HilReg0Ps3RequestQueueFifoDoutShift_u fifoDoutShift[4]; - HilReg0Ps3RequestQueueFifostatusMaxlevel_u fifoStatusMaxLevel; - HilReg0Ps3RequestQueueFifoInit_u fifoInit; - HilReg0Ps3RequestQueueFifoinitEn_u fifoinitEn; - HilReg0Ps3RequestQueueFifoinitMax_u fifoinitMax; - HilReg0Ps3RequestQueueFifostatusEccCnt_u fifoStatusEccCnt; - HilReg0Ps3RequestQueueFifostatusEccAddr_u fifoStatusEccAddr; - HilReg0Ps3RequestQueueFifoDecoderOverflow_u fifoDecoderOverflow; - HilReg0Ps3RequestQueueFifoEccBadProject_u fifoEccBadProject; - HilReg0Ps3RequestQueueFifooverflowWord_u fifoOverFlowWord; - HilReg0Ps3RequestQueueFifoLevelMonitorCtl_u fifoLevelMonitorCtl; - HilReg0Ps3RequestQueueFifoLevelMonitorCntClr_u fifoLevelMonitorCntClr; - HilReg0Ps3RequestQueueFifoLevelMonitorLow_u fifoLevelMonitorLow; - HilReg0Ps3RequestQueueFifoLevelMonitorMid_u fifoLevelMonitorMid; - HilReg0Ps3RequestQueueFifoLevelMonitorHigh_u fifoLevelMonitorHigh; -}HilReg0Ps3RequestQueue_s; +#ifndef __S1861_HIL_REG0_PS3_REQUEST_QUEUE_REG_STRUCT__ +union HilReg0Ps3RequestQueuePs3RequestQueue { + volatile unsigned long long val; + struct { + + unsigned long long port : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoErrCnt { + volatile unsigned long long val; + struct { + + unsigned long long waddrerr : 32; + unsigned long long reserved1 : 32; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoStatus { + volatile unsigned long long val; + struct { + + unsigned long long filled : 16; + unsigned long long fifoDepth : 16; + unsigned long long almostfull : 1; + unsigned long long full : 1; + unsigned long long almostempty : 1; + unsigned long long empty : 1; + unsigned long long reserved6 : 28; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelConfig { + volatile unsigned long long val; + struct { + + unsigned long long cfgAempty : 16; + unsigned long long cfgAfull : 16; + unsigned long long emptyProtect : 1; + unsigned long long fullProtect : 1; + unsigned long long reserved4 : 30; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoRst { + volatile unsigned long long val; + struct { + + unsigned long long resetPls : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoIOCnt { + volatile unsigned long long val; + struct { + + unsigned long long wr : 32; + unsigned long long rd : 32; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoFlowCnt { + volatile unsigned long long val; + struct { + + unsigned long long overflow : 32; + unsigned long long underflow : 32; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoIntStatus { + volatile unsigned long long val; + struct { + + unsigned long long overflowStatus : 1; + unsigned long long underflowStatus : 1; + unsigned long long nemptyStatus : 1; + unsigned long long eccBadStatus : 1; + unsigned long long reserved4 : 60; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoIntSet { + volatile unsigned long long val; + struct { + + unsigned long long overflowSet : 1; + unsigned long long underflowSet : 1; + unsigned long long nemptySet : 1; + unsigned long long eccBadSet : 1; + unsigned long long reserved4 : 60; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoIntClr { + volatile unsigned long long val; + struct { + + unsigned long long overflowClr : 1; + unsigned long long underflowClr : 1; + unsigned long long nemptyClr : 1; + unsigned long long eccBadClr : 1; + unsigned long long reserved4 : 60; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoIntMask { + volatile unsigned long long val; + struct { + + unsigned long long overflowMask : 1; + unsigned long long underflowMask : 1; + unsigned long long nemptyMask : 1; + unsigned long long eccBadMask : 1; + unsigned long long reserved4 : 60; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoCntClr { + volatile unsigned long long val; + struct { + + unsigned long long fifowrcntClr : 1; + unsigned long long fifordcntClr : 1; + unsigned long long fifoerrcntClr : 1; + unsigned long long fifoordererrwrcntClr : 1; + unsigned long long fifoordererrrdcntClr : 1; + unsigned long long fifobit1errcntClr : 1; + unsigned long long fifobit2errcntClr : 1; + unsigned long long reserved7 : 57; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoOrderError { + volatile unsigned long long val; + struct { + + unsigned long long wrcnt : 32; + unsigned long long rdcnt : 32; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoDinShift { + volatile unsigned long long val; + struct { + + unsigned long long val : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoDoutShift { + volatile unsigned long long val; + struct { + + unsigned long long val : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifostatusMaxlevel { + volatile unsigned long long val; + struct { + + unsigned long long val : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoInit { + volatile unsigned long long val; + struct { + + unsigned long long stat : 2; + unsigned long long reserved1 : 62; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoinitEn { + volatile unsigned long long val; + struct { + + unsigned long long start : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoinitMax { + volatile unsigned long long val; + struct { + + unsigned long long num : 16; + unsigned long long reserved1 : 48; + } reg; +}; + +union HilReg0Ps3RequestQueueFifostatusEccCnt { + volatile unsigned long long val; + struct { + + unsigned long long bit1Err : 32; + unsigned long long bit2Err : 32; + } reg; +}; + +union HilReg0Ps3RequestQueueFifostatusEccAddr { + volatile unsigned long long val; + struct { + + unsigned long long errPoint : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoDecoderOverflow { + volatile unsigned long long val; + struct { + + unsigned long long rCmdwordEmpty : 1; + unsigned long long rPortindexEmpty : 1; + unsigned long long rCmdbackEmpty : 1; + unsigned long long wCmdwordEmpty : 1; + unsigned long long wPortindexEmpty : 1; + unsigned long long wCmdbackEmpty : 1; + unsigned long long rCmdwordFull : 1; + unsigned long long rPortindexFull : 1; + unsigned long long rCmdbackFull : 1; + unsigned long long wCmdwordFull : 1; + unsigned long long wPortindexFull : 1; + unsigned long long wCmdbackFull : 1; + unsigned long long reserved12 : 52; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoEccBadProject { + volatile unsigned long long val; + struct { + + unsigned long long en : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RequestQueueFifooverflowWord { + volatile unsigned long long val; + struct { + + unsigned long long record : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelMonitorCtl { + volatile unsigned long long val; + struct { + + unsigned long long low : 16; + unsigned long long high : 16; + unsigned long long en : 1; + unsigned long long reserved3 : 31; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr { + volatile unsigned long long val; + struct { + + unsigned long long en : 1; + unsigned long long reserved1 : 63; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelMonitorLow { + volatile unsigned long long val; + struct { + + unsigned long long cnt : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelMonitorMid { + volatile unsigned long long val; + struct { + + unsigned long long cnt : 64; + } reg; +}; + +union HilReg0Ps3RequestQueueFifoLevelMonitorHigh { + volatile unsigned long long val; + struct { + + unsigned long long cnt : 64; + } reg; +}; + +struct HilReg0Ps3RequestQueue { + + union HilReg0Ps3RequestQueuePs3RequestQueue ps3RequestQueue; + union HilReg0Ps3RequestQueueFifoErrCnt fifoErrCnt; + union HilReg0Ps3RequestQueueFifoStatus fifoStatus; + union HilReg0Ps3RequestQueueFifoLevelConfig fifoLevelConfig; + union HilReg0Ps3RequestQueueFifoRst fifoRst; + union HilReg0Ps3RequestQueueFifoIOCnt fifoIOCnt; + union HilReg0Ps3RequestQueueFifoFlowCnt fifoFlowCnt; + union HilReg0Ps3RequestQueueFifoIntStatus fifoIntStatus; + union HilReg0Ps3RequestQueueFifoIntSet fifoIntSet; + union HilReg0Ps3RequestQueueFifoIntClr fifoIntClr; + union HilReg0Ps3RequestQueueFifoIntMask fifoIntMask; + union HilReg0Ps3RequestQueueFifoCntClr fifoCntClr; + union HilReg0Ps3RequestQueueFifoOrderError fifoOrderError; + union HilReg0Ps3RequestQueueFifoDinShift fifoDinShift[4]; + union HilReg0Ps3RequestQueueFifoDoutShift fifoDoutShift[4]; + union HilReg0Ps3RequestQueueFifostatusMaxlevel fifoStatusMaxLevel; + union HilReg0Ps3RequestQueueFifoInit fifoInit; + union HilReg0Ps3RequestQueueFifoinitEn fifoinitEn; + union HilReg0Ps3RequestQueueFifoinitMax fifoinitMax; + union HilReg0Ps3RequestQueueFifostatusEccCnt fifoStatusEccCnt; + union HilReg0Ps3RequestQueueFifostatusEccAddr fifoStatusEccAddr; + union HilReg0Ps3RequestQueueFifoDecoderOverflow fifoDecoderOverflow; + union HilReg0Ps3RequestQueueFifoEccBadProject fifoEccBadProject; + union HilReg0Ps3RequestQueueFifooverflowWord fifoOverFlowWord; + union HilReg0Ps3RequestQueueFifoLevelMonitorCtl fifoLevelMonitorCtl; + union HilReg0Ps3RequestQueueFifoLevelMonitorCntClr + fifoLevelMonitorCntClr; + union HilReg0Ps3RequestQueueFifoLevelMonitorLow fifoLevelMonitorLow; + union HilReg0Ps3RequestQueueFifoLevelMonitorMid fifoLevelMonitorMid; + union HilReg0Ps3RequestQueueFifoLevelMonitorHigh fifoLevelMonitorHigh; +}; +#endif #endif -#endif \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_define.h b/drivers/scsi/linkdata/ps3stor/include/ps3_define.h deleted file mode 100644 index d53dfac46439..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_define.h +++ /dev/null @@ -1,244 +0,0 @@ - -#ifndef __PS3_DEFINE_H__ -#define __PS3_DEFINE_H__ - -#include "ps3_types.h" - -#define PS3_ASM __asm__ volatile - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef INVALID_U4 -#define INVALID_U4 0xF -#endif - -#ifndef INVALID_U8 -#define INVALID_U8 0xFF -#endif - -#ifndef INVALID_U16 -#define INVALID_U16 0xFFFF -#endif - -#ifndef INVALID_U16_1 -#define INVALID_U16_1 0xFFFE -#endif - -#ifndef INVALID_U16_2 -#define INVALID_U16_2 0xFFFD -#endif - -#ifndef INVALID_U32 -#define INVALID_U32 0xFFFFFFFF -#endif - -#ifndef INVALID_U64 -#define INVALID_U64 0xFFFFFFFFFFFFFFFF -#endif - -#ifdef __aarch64__ -#define __arm64__ -#endif - - -#ifndef INVALID_ULONG -#if defined (__arm64__) || defined (__x86_64__) -#define INVALID_ULONG 0xFFFFFFFFFFFFFFFF -#elif defined(__arm__) || defined (__i386__) -#define INVALID_ULONG 0xFFFFFFFF -#endif -#endif - -#ifndef INVALID_S8 -#define INVALID_S8 0xFF -#endif - -#ifndef INVALID_S16 -#define INVALID_S16 0xFFFF -#endif - -#ifndef INVALID_S32 -#define INVALID_S32 ((S32)(-1)) -#endif - -#ifndef INVALID_S64 -#define INVALID_S64 0xFFFFFFFFFFFFFFFF -#endif - -#ifndef INVALID_LONG -#if defined (__arm64__) || defined (__x86_64__) -#define INVALID_LONG 0xFFFFFFFFFFFFFFFF -#elif defined(__arm__) || defined (__i386__) -#define INVALID_LONG 0xFFFFFFFF -#endif -#endif - - -#ifndef MACRO_64_BIT -#if defined (__arm64__) || defined (__x86_64__) -#define MACRO_64_BIT -#endif -#endif - -#ifndef MACRO_32_BIT -#if defined (__arm__) || defined (__i386__) -#define MACRO_32_BIT -#endif -#endif - -#ifndef MACRO_ARM -#if defined (__arm64__) || defined (__arm__) -#define MACRO_ARM -#endif -#endif - -#ifndef MACRO_X86 -#if defined (__x86_64__) || defined (__i386__) -#define MACRO_X86 -#endif -#endif - -#ifndef LOCK_PREFIX -#define LOCK_PREFIX "lock ; " -#endif - -#ifndef BITS_PER_LONG -#ifdef MACRO_64_BIT -#define BITS_PER_LONG 64 -#else -#define BITS_PER_LONG 32 -#endif -#endif - -#ifdef MACRO_64_BIT -#define BITS_PER_LONG_SHIFT 6 -#else -#define BITS_PER_LONG_SHIFT 5 -#endif - -#ifndef BIT -#define BIT(nr) (1UL << (nr)) -#endif - -#ifndef BIT_MASK -#define BIT_MASK(nr) (1UL << ((nr) & ((BITS_PER_LONG) - 1))) -#endif -#ifndef BIT_WORD -#define BIT_WORD(nr) ((nr) >> (BITS_PER_LONG_SHIFT)) -#endif - -#define BIT_MASK_32(nr) (1UL << ((nr) & (32 - 1))) -#define BIT_WORD_32(nr) ((nr) >> 5) - -#ifndef BITS_PER_BYTE -#define BITS_PER_BYTE 8 -#endif - - -#ifndef PS3_BITIDX_INVALID -#define PS3_BITIDX_INVALID (-1) -#endif - - -#define SECTOR_SIZE_512 (512) -#define SECTOR_SIZE_4096 (4096) -#define SECTOR_SIZE_512_BYTES_SHIFT (9) -#define SECTOR_SIZE_4096_BYTES_SHIFT (12) -#define SECTOR_512_TO_BYTES(lba) ((lba) << SECTOR_SIZE_512_BYTES_SHIFT) -#define BYTES_TO_SECTOR_512(byte) ((byte) >> SECTOR_SIZE_512_BYTES_SHIFT) -#define SECTOR_512_TO_4K_SHIFT (3) -#define SECTOR4K_512COUNT (8) - -#define SECTOR4K_INDEX(offset) ((offset) >> SECTOR_512_TO_4K_SHIFT) -#define SECTOR4K_ALIGN(offset) ((offset) & ~(SECTOR4K_512COUNT - 1)) -#define SECTOR4K_MOD(offset) ((offset) & (SECTOR4K_512COUNT - 1)) - -#ifndef CACHE_ALIGNED -#define CACHE_ALIGNED __attribute__((__aligned__(64))) -#endif - -#ifndef ALIGNED -#define ALIGNED(a) __attribute__((__aligned__(a))) -#endif - - - -#ifndef RING_NAMESIZE -#define RING_NAMESIZE (32) -#endif - -#ifndef RING_F_SP_ENQ -#define RING_F_SP_ENQ 0x0001 -#endif -#ifndef RING_F_SC_DEQ -#define RING_F_SC_DEQ 0x0002 -#endif -#ifndef RING_F_EXACT_SZ -#define RING_F_EXACT_SZ 0x0004 -#endif -#ifndef RING_SZ_MASK -#define RING_SZ_MASK (0x7fffffffU) -#endif - - -#ifndef RING_F_MASK -#define RING_F_MASK (RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ) -#endif - -#ifndef RING_CACHE_LINE_SIZE -#define RING_CACHE_LINE_SIZE (64) -#endif -#ifndef RING_CACHE_LINE_MASK -#define RING_CACHE_LINE_MASK (RING_CACHE_LINE_SIZE - 1) -#endif - -#ifndef ALIGN_FLOOR -#define ALIGN_FLOOR(val, cacheLineSize) \ - val & (~(cacheLineSize - 1)) -#endif -#ifndef ALIGN -#define ALIGN(val, cacheLineSize) \ - ALIGN_FLOOR((val + cacheLineSize - 1), (cacheLineSize)) -#endif - -#if !defined(PCLINT) - - -#define PS3_SIZE_OF_TYPE_IS_ALIGN_OF(type, alignSize) \ -static inline char size_of_##type##_is_align_of_##alignSize() \ -{ \ - char __dummy1[0 - (sizeof(type) & (alignSize - 1))]; \ - return __dummy1[-1]; \ -} - - -#define PS3_SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) \ -static inline char size_of_##type##_not_larger_than_##size() \ -{ \ - char __dummy1[size - sizeof(type)]; \ - return __dummy1[-1]; \ -} - -#define PS3_SIZE_OF_TYPE_EQUAL_WITH(type, size) \ -static inline char size_of_##type##_equal_with_##size1() \ -{ \ - char __dummy1[size - sizeof(type)]; \ - return __dummy1[-1]; \ -} \ -static inline char size_of_##type##_equal_with_##size2() \ -{ \ - char __dummy2[sizeof(type) - size]; \ - return __dummy2[-1]; \ -} -#else - -#define PS3_SIZE_OF_TYPE_IS_ALIGN_OF(type, alignSize) -#define PS3_SIZE_OF_TYPE_NOT_LARGER_THAN(type, size) -#define PS3_SIZE_OF_TYPE_EQUAL_WITH(type, size) - -#endif - -#endif - diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_dev_type.h b/drivers/scsi/linkdata/ps3stor/include/ps3_dev_type.h deleted file mode 100644 index 6cee7d7d0c54..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_dev_type.h +++ /dev/null @@ -1,98 +0,0 @@ - -#ifndef __PS3_DEV_TYPE_H__ -#define __PS3_DEV_TYPE_H__ - -typedef enum DriverType { - DRIVER_TYPE_UNKNOWN = 0, - DRIVER_TYPE_SAS, - DRIVER_TYPE_SATA, - DRIVER_TYPE_SES, - DRIVER_TYPE_NVME, - DRIVER_TYPE_EXP_SAS, - DRIVER_TYPE_VEP, - DRIVER_TYPE_CHASSIS, - DRIVER_TYPE_BACKPLANE, - DRIVER_TYPE_MAX, -} DriverType_e; - -static inline const char *getDriverTypeName(DriverType_e driverType) -{ - static const char *driverTypeName[] = { - [DRIVER_TYPE_UNKNOWN] = "DRIVER_TYPE_UNKNOWN", - [DRIVER_TYPE_SAS] = "DRIVER_TYPE_SAS", - [DRIVER_TYPE_SATA] = "DRIVER_TYPE_SATA", - [DRIVER_TYPE_SES] = "DRIVER_TYPE_SES", - [DRIVER_TYPE_NVME] = "DRIVER_TYPE_NVME", - [DRIVER_TYPE_EXP_SAS] = "DRIVER_TYPE_EXP_SAS", - [DRIVER_TYPE_VEP] = "DRIVER_TYPE_VEP", - [DRIVER_TYPE_CHASSIS] = "DRIVER_TYPE_CHASSIS", - [DRIVER_TYPE_BACKPLANE] = "DRIVER_TYPE_BACKPLANE", - [DRIVER_TYPE_MAX] = "DRIVER_TYPE_MAX", - }; - - return driverTypeName[driverType]; -} - - -typedef enum MediumType { - DEVICE_TYPE_UNKNOWN = 0, - DEVICE_TYPE_HDD, - DEVICE_TYPE_SSD, - DEVICE_TYPE_ENCLOSURE, - DEVICE_TYPE_MAX, -} MediumType_e; - -static inline const char *getMediumTypeName(MediumType_e mediumType) -{ - static const char *mediumTypeName[] = { - [DEVICE_TYPE_UNKNOWN] = "DEVICE_TYPE_UNKNOWN", - [DEVICE_TYPE_HDD] = "DEVICE_TYPE_HDD", - [DEVICE_TYPE_SSD] = "DEVICE_TYPE_SSD", - [DEVICE_TYPE_ENCLOSURE] = "DEVICE_TYPE_ENCLOSURE", - [DEVICE_TYPE_MAX] = "DEVICE_TYPE_MAX", - }; - - return mediumTypeName[mediumType]; -} - - -typedef enum DiskSpinUpState { - DISK_SPIN_INVALID = 0, - DISK_SPIN_UP = 1, - DISK_SPIN_TRANS = 2, - DISK_SPIN_DOWN = 3, -} DiskSpinUpState_e; - - -typedef enum DeviceState { - DEVICE_STATE_FREE = 0x0, - DEVICE_STATE_INSERTING, - DEVICE_STATE_ONLINE, - DEVICE_STATE_WAIT, - DEVICE_STATE_RECOVER, - DEVICE_STATE_PREONLINE, - DEVICE_STATE_OUTING, - DEVICE_STATE_MAX, -} DeviceState_e; - -static inline const char *getDeviceStateName(DeviceState_e pdState) -{ - static const char *pdStateName[] = { - [DEVICE_STATE_FREE] = "DEVICE_STATE_FREE", - [DEVICE_STATE_INSERTING] = "DEVICE_STATE_INSERTING", - [DEVICE_STATE_ONLINE] = "DEVICE_STATE_ONLINE", - [DEVICE_STATE_WAIT] = "DEVICE_STATE_WAIT", - [DEVICE_STATE_RECOVER] = "DEVICE_STATE_RECOVER", - [DEVICE_STATE_PREONLINE] = "DEVICE_STATE_PREONLINE", - [DEVICE_STATE_OUTING] = "DEVICE_STATE_OUTING", - [DEVICE_STATE_MAX] = "DEVICE_STATE_MAX", - }; - - return pdStateName[pdState]; -} - -#define DEVICE_NOT_RUNNING(state) \ - ((state != DEVICE_STATE_ONLINE) && (state != DEVICE_STATE_WAIT) && \ - (state != DEVICE_STATE_RECOVER) && (state != DEVICE_STATE_PREONLINE)) - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h b/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h index 955541851967..dd35acb14fae 100644 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_evtcode_trans.h @@ -1,493 +1,508 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PS3_EVTCODE_TRANS_H__ #define __PS3_EVTCODE_TRANS_H__ -#include "ps3_types.h" #if !(defined(PS3_PRODUCT_EXPANDER) || defined(PS3_PRODUCT_SWITCH)) -#include "ps3_mgr_evt_raidhba.h" +#include "ps3_htp_mgr_evt_raidhba.h" -static inline S8 const *mgrEvtCodeTrans(U32 opCode) +#define PS3_EVT_EXT_NR (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) + +static inline char const *mgrEvtCodeTrans(unsigned int opCode) { - U32 typeIndex = 0; - U32 codeIndex = 0; - const S8* pEvtTransStr = NULL; - static S8 const *pEvtCodeInfo[PS3_EVT_MAX_TYPE_LOCAL][MGR_EVT_TYPE_OFFSET] = { - { - "MGR_EVT_SAS_START", - "MGR_EVT_SAS_EXPANDER_IN", - "MGR_EVT_SAS_EXPANDER_OUT", - "MGR_EVT_SAS_EXPANDER_UPDATE", - "MGR_EVT_SAS_EXPANDER_CHANGE", - "MGR_EVT_ENCL_TEMP_NORMAL", - "MGR_EVT_ENCL_TEMP_WARNING", - "MGR_EVT_ENCL_TEMP_CRITICAL", - "MGR_EVT_TOPO_LOOP", - "MGR_EVT_LOOP_RESOLUTION", - "MGR_EVT_CASCADED_SCAN_SMP_FAIL", - "MGR_EVT_ENCL_EXCEED", - "MGR_EVT_TRI_MODE_SWITCH", - "MGR_EVT_CHANGE_PHY_BY_USER", - "MGR_EVT_REV_HIBERNATE_CMD", - "MGR_EVT_PHY_CHANGE", - "MGR_EVT_INQUIRY_INFO", - "MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH", - "MGR_EVT_SAS_SATA_LN_EXCEPTION", - "MGR_EVT_SAS_SATA_DRIVER_INFO", - }, - { - "MGR_EVT_PD_COUNT_START", - "MGR_EVT_DEVM_DISK_IN", - "MGR_EVT_DEVM_DISK_OUT", - "MGR_EVT_MULITPILE_PD_IN", - "MGR_EVT_MULITPILE_PD_OUT", - "MGR_EVT_DEVM_JBOD", - "MGR_EVT_DEVM_READY", - "MGR_EVT_MULITPILE_JBOD", - "MGR_EVT_MULITPILE_READY", - "MGR_EVT_BACKPLANE_ON", - "MGR_EVT_BACKPLANE_OFF", - "MGR_EVT_MULITPILE_PD_STATE_CHANGE", - "MGR_EVT_DEVM_DISK_CHANGE", - "MGR_EVT_DEFAULT_UNUSED", - "MGR_EVT_PD_PRE_READY", - }, - { - "MGR_EVT_VD_COUNT_START", - "MGR_EVT_VD_OPTIMAL", - "MGR_EVT_VD_PARTIAL_DEGRADE", - "MGR_EVT_VD_DEGRADE", - "MGR_EVT_VD_CREATED", - "MGR_EVT_VD_DELETED", - "MGR_EVT_VD_HIDDEN_CHANGE", - "MGR_EVT_MULITPILE_VD_IN", - "MGR_EVT_MULITPILE_VD_OUT", - "MGR_EVT_VD_UNLOCK", - "MGR_EVT_VD_OFFLINE", - }, - { - "MGR_EVT_CTRL_INFO_START", - "MGR_EVT_CTRL_REBOOT", - "MGR_EVT_CTRL_SHUTDOWN", - "MGR_EVT_CTRL_TIME_CHANGE", - "MGR_EVT_CTRL_EVENT_LOG_CLEARED", - "MGR_EVT_CTRL_RBLD_RATE_CHANGED", - "MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED", - "MGR_EVT_CTRL_ENABLENCQ_CHANGED", - "MGR_EVT_CTRL_AUTO_REBUILD_CHANGED", - "MGR_EVT_CTRL_EGHS_READY_CHANGED", - "MGR_EVT_CTRL_EGHS_SPARE_CHANGED", - "MGR_EVT_CTRL_BGI_RATE_CHANGED", - "MGR_EVT_CTRL_MIGRATE_RATE_CHANGED", - "MGR_EVT_CTRL_CC_RATE_CHANGED", - "MGR_EVT_CTRL_DIRECT_CHANGE", - "MGR_EVT_CTRL_PR_START", - "MGR_EVT_CTRL_PR_PAUSE", - "MGR_EVT_CTRL_PR_REMINDER_PAUSE", - "MGR_EVT_CTRL_PR_RESUME", - "MGR_EVT_CTRL_PR_DONE", - "MGR_EVT_CTRL_PR_RATE_CHANGED", - "MGR_EVT_CTRL_PR_CANT_START", - "MGR_EVT_CTRL_PR_PROP_CHANGED", - "MGR_EVT_CTRL_PARAM_CHANGE", - "MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE", - "MGR_EVT_CTRL_RECOVERY_FACTORY", - "MGR_EVT_CTRL_PROFILEID_CHANGED", - "MGR_EVT_CTRL_SANPSHOT_CREATE", - "MGR_EVT_CTRL_SANPSHOT_DELETE", - "MGR_EVT_CTRL_ENABLEPDM_CHANGED", - "MGR_EVT_CTRL_PDMSUPPORTREADYPD", - "MGR_EVT_CTRL_PDMTIMERINTERVAL", - "MGR_EVT_CTRL_SECURITY_KEY_CHANGE", - "MGR_EVT_CTRL_SECURITY_KEY_CREATE", - "MGR_EVT_CTRL_SECURITY_KEY_DESTROY", - "MGR_EVT_CTRL_SECURITY_KEY_ESCROW", - "MGR_EVT_CTRL_SECURITY_KEY_FAILED", - "MGR_EVT_CTRL_SECURITY_KEY_INVALID", - "MGR_EVT_AUTOCONFIG", - "MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL", - "MGR_EVT_CTRL_FOREIGN_CLEAR", - "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL", - "MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL", - "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS", - "MGR_EVT_CTRL_FOREIGN_PD_DETECTED", - "MGR_EVT_PD_INSERT_TO_DG", - "MGR_EVT_PD_IMPORT_TO_DG", - "MGR_EVT_HARD_RESET", - "MGR_EVT_DPF_CFG_MODIFY", - "MGR_EVT_SPOR", - "MGR_EVT_ONF_ABNORMAL", - "MGR_EVT_CTRL_LOADED", - "MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE", - "MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE", - "MGR_EVT_MEDIUM_DATA_RECOVER", - "MGR_EVT_CACHE_PROTECTION_CMPT_READY", - "MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY", - "MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE", - "MGR_EVT_INIT_FAIL", - "MGR_EVT_CTRL_POWER_MODE_CHANGED", - }, - { - "MGR_EVT_PD_ATTR_START", - "MGR_EVT_PD_INFO_CHANGE", - "MGR_EVT_PD_STATE_CHANGE", - "MGR_EVT_PD_MARKED_JBOD", - "MGR_EVT_PD_MARKED_READY", - "MGR_EVT_PD_MARKED_ONLINE", - "MGR_EVT_PD_MARKED_OFFLINE", - "MGR_EVT_PD_MARKED_FAILED", - "MGR_EVT_PD_MARKED_MISSING", - "MGR_EVT_PD_MARKED_REBUILD", - "MGR_EVT_PD_MARKED_REPLACE", - "MGR_EVT_PD_MARKED_UNCONFIGUREDBAD", - "MGR_EVT_PD_MARKED_FOREIGN", - "MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED", - "MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED", - "MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED", - "MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED", - "MGR_EVT_PD_R_GLOBAL_SPARE_ADDED", - "MGR_EVT_PD_R_GLOBAL_SPARE_DELETED", - "MGR_EVT_PD_R_DEDICATED_SPARE_ADDED", - "MGR_EVT_PD_R_DEDICATED_SPARE_DELETED", - "MGR_EVT_PD_RBLD_ABORT_BY_USER", - "MGR_EVT_PD_RBLD_DONE_PD", - "MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE", - "MGR_EVT_PD_RBLD_FAILED_BAD_TARGET", - "MGR_EVT_PD_RBLD_PROGRESS", - "MGR_EVT_PD_RBLD_SUSPENDED_REMINDER", - "MGR_EVT_PD_RBLD_SUSPENDED", - "MGR_EVT_PD_RBLD_RESUME", - "MGR_EVT_PD_RBLD_START", - "MGR_EVT_PD_RBLD_START_AUTO", - "MGR_EVT_PD_RBLD_MEDIUM_ERROR", - "MGR_EVT_PD_EMERGENCY_SPARE", - "MGR_EVT_PD_RECOVER_MEDIUM_ERROR", - "MGR_EVT_PD_MOVEBACK_START", - "MGR_EVT_PD_MOVEBACK_ABORT", - "MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD", - "MGR_EVT_PD_MOVEBACK_DONE", - "MGR_EVT_PD_MOVEBACK_PROGRESS", - "MGR_EVT_PD_MOVEBACK_SUSPENDED", - "MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER", - "MGR_EVT_PD_MOVEBACK_RESUME", - "MGR_EVT_PD_MOVEBACK_START_AUTO", - "MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE", - "MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET", - "MGR_EVT_PD_MOVEBACK_ABORT_BY_USER", - "MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR", - "MGR_EVT_PD_FGI_START", - "MGR_EVT_PD_FGI_COMPLETE", - "MGR_EVT_PD_FGI_FAILED", - "MGR_EVT_PD_FGI_PROGRESS", - "MGR_EVT_PD_FGI_ABORT", - "MGR_EVT_PD_PR_ABORTED", - "MGR_EVT_PD_PR_CORRECTED", - "MGR_EVT_PD_PR_UNCORRECTABLE", - "MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR", - "MGR_EVT_PD_PR_PROGRESS", - "MGR_EVT_PD_SET_BOOT_DRIVE", - "MGR_EVT_PD_RESET_BOOT_DRIVE", - "MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT", - "MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN", - "MGR_EVT_PD_POWERSAVE_TO_ON", - "MGR_EVT_PD_POWERSAVE_TO_TRANSITION", - "MGR_EVT_PD_TRANSITION_TO_ON", - "MGR_EVT_PD_TRANSITION_TO_POWERSAVE", - "MGR_EVT_PD_ON_TO_POWERSAVE", - "MGR_EVT_PD_START_LOCATE", - "MGR_EVT_PD_STOP_LOCATE", - "MGR_EVT_PD_PFA_ERROR", - "MGR_EVT_PD_NOT_PRESENT", - "MGR_EVT_DEVM_DISK_FAULT", - "MGR_EVT_PHY_FLASHOFFLINE", - "MGR_EVT_PHY_FLASHONLINE", - "MGR_EVT_NFR_DONE", - "MGR_EVT_NFR_REPAIRED", - "MGR_EVT_NFR_REPORT", - "MGR_EVT_NFR_STOP", - "MGR_EVT_PD_DOWNLOAD_DONE", - "MGR_EVT_PD_DOWNLOAD_START", - "MGR_EVT_NVME_PHY_BAD", - }, - { - "MGR_EVT_VD_ATTR_START", - "MGR_EVT_MULITPILE_VD_STATE_CHANGE", - "MGR_EVT_VD_OFFLINE_OLD", - "MGR_EVT_VD_LOCK", - "MGR_EVT_VD_PASSWD_CHANGED", - "MGR_EVT_VD_SETTINGS_CHANGE", - "MGR_EVT_VD_PD_CHANGE", - "MGR_EVT_VD_STATE_CHANGE", - "MGR_EVT_PD_RBLD_DONE_LD", - "MGR_EVT_VD_FGI_START", - "MGR_EVT_VD_FGI_COMPLETE", - "MGR_EVT_VD_FGI_FAILED", - "MGR_EVT_VD_FGI_PROGRESS", - "MGR_EVT_VD_FGI_ABORT", - "MGR_EVT_VD_BGI_START", - "MGR_EVT_VD_BGI_COMPLETE", - "MGR_EVT_VD_BGI_FAILED", - "MGR_EVT_VD_BGI_PROGRESS", - "MGR_EVT_VD_BGI_ABORT", - "MGR_EVT_VD_BGI_PAUSE", - "MGR_EVT_VD_BGI_REMINDER_PAUSE", - "MGR_EVT_VD_BGI_RESUME", - "MGR_EVT_VD_BGI_CORRECTABLE_ERROR", - "MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR", - "MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION", - "MGR_EVT_VD_BBM_CLEARED", - "MGR_EVT_VD_BBM_PERCENT_FULL", - "MGR_EVT_VD_BBM_100_FULL", - "MGR_EVT_VD_BBM_LOG_FULL", - "MGR_EVT_VD_BBM_LOG_RCT", - "MGR_EVT_VD_BBM_LOG_WCT", - "MGR_EVT_VD_BBM_DEL_RCT", - "MGR_EVT_VD_CC_ABORTED", - "MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR", - "MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS", - "MGR_EVT_VD_CC_DONE", - "MGR_EVT_VD_CC_DONE_INCON", - "MGR_EVT_VD_CC_FAILED", - "MGR_EVT_VD_CC_FAILED_UNCOR", - "MGR_EVT_VD_CC_INCONSISTENT_PARITY", - "MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED", - "MGR_EVT_VD_CC_PROGRESS", - "MGR_EVT_VD_CC_START", - "MGR_EVT_VD_CC_PAUSE", - "MGR_EVT_VD_CC_REMINDER_PAUSE", - "MGR_EVT_VD_CC_RESUME", - "MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY", - "MGR_EVT_VD_SET_BOOT_DRIVE", - "MGR_EVT_VD_RESET_BOOT_DRIVE", - "MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT", - "MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN", - "MGR_EVT_ALL_CONFIGS_MISSING", - "MGR_EVT_PDS_MISSING", - "MGR_EVT_NVSRAM_RECOVER_FAIL", - "MGR_EVT_NVSRAM_UPDATE_FAIL", - "MGR_EVT_VD_ERASE_ABORT", - "MGR_EVT_VD_ERASE_COMPLETE", - "MGR_EVT_VD_ERASE_DISK_FAILED", - "MGR_EVT_VD_ERASE_FAILED", - "MGR_EVT_VD_ERASE_PROGRESS", - "MGR_EVT_VD_ERASE_START", - "MGR_EVT_VD_EXPAND_FINISH", - "MGR_EVT_VD_EXPAND_START", - "MGR_EVT_VD_FLUSH_CLEAR_FAILED", - "MGR_EVT_VD_FLUSH_RECORD_FAILED", - "MGR_EVT_VD_FLUSH_SET_INCONSIST", - "MGR_EVT_VDS_MISSING", - "MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED", - "MGR_EVT_VD_FLUSH_CACHE_PINNED", - "MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED", - "MGR_EVT_VD_FLUSH_CACHE_DISCARDED", - "MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL", - "MGR_EVT_VD_FLUSH_CACHE_DESTAGED", - "MGR_EVT_VD_CM_RECOVERY_CRC_FAIL", - "MGR_EVT_VD_BGI_COMPLETE_UNCOR", - }, - { - "MGR_EVT_DG_INFO_START", - "MGR_EVT_DG_CREATED", - "MGR_EVT_DG_DELETED", - "MGR_EVT_DG_SETTING_CHANGE", - "MGR_EVT_DG_MIGRATION_START", - "MGR_EVT_DG_MIGRATION_RECOVER", - "MGR_EVT_DG_MIGRATION_SUCCESS", - "MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED", - "MGR_EVT_DG_MIGRATION_FAILED", - "MGR_EVT_DG_MIGRATION_RECOVER_FAILED", - "MGR_EVT_DG_MIGRATION_PROGRESS", - "MGR_EVT_DG_MIGRATION_INTERNAL_WARNING", - "MGR_EVT_DG_PRSWITCH_CHANGE", - "MGR_EVT_DG_PR_ABORTED_WM_FAILED", - "MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED", - }, - { - "MGR_EVT_BBU_START", - "MGR_EVT_BBU_PRESENT", - "MGR_EVT_BBU_NOT_PRESENT", - "MGR_EVT_BBU_GOOD", - "MGR_EVT_BBU_BAD", - "MGR_EVT_BBU_CAP_BELOW_THRESHOLD", - "MGR_EVT_BBU_CAP_ABOVE_THRESHOLD", - "MGR_EVT_BBU_CHARGE_STATUS", - "MGR_EVT_BBU_CHARGE_COMPLETE", - "MGR_EVT_BBU_INSERT", - "MGR_EVT_BBU_ABSENT", - "MGR_EVT_BBU_TEMPERATURE_NORMAL", - "MGR_EVT_BBU_TEMPERATURE_HIGH", - "MGR_EVT_BBU_VOLTAGE_NORMAL", - "MGR_EVT_BBU_VOLTAGE_HIGH", - "MGR_EVT_BBU_CURRENT_NORMAL", - "MGR_EVT_BBU_CURRENT_HIGH", - "MGR_EVT_BBU_LOAD_NORMAL", - "MGR_EVT_BBU_VOLTAGE_LOW", - "MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD", - "MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD", - "MGR_EVT_BBU_LEARN_STAGE", - "MGR_EVT_BBU_LEARN_REQUESTED", - "MGR_EVT_BBU_LEARN_POSTPONED", - "MGR_EVT_BBU_LEARN_TIMEOUT", - "MGR_EVT_BBU_LEARN_MANUAL", - "MGR_EVT_BBU_LEARN_RESCHEDULED", - "MGR_EVT_BBU_PROPERTIES_CHANGED", - }, - { - "MGR_EVT_CONFIG_START", - "MGR_EVT_CONFIG_INFO", - "MGR_EVT_CONFIG_FLASH_READ_FAIL", - "MGR_EVT_CONFIG_FLASH_WRITE_FAIL", - "MGR_EVT_CONFIG_NVSRAM_READ_FAIL", - "MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL", - "MGR_EVT_CONFIG_VERSION_MISMATCH", - "MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL", - "MGR_EVT_CONFIG_ERASE_NVSRAM", - "MGR_EVT_PHY_LINKSPEED_CFG_CHANGE", - }, - { - "MGR_EVT_IO_START", - "MGR_EVT_IO_TEST", - "MGR_EVT_IO_SENSE_DATA", - "MGR_EVT_DEVICE_RESET", - "MGR_EVT_NVME_DEVICE_RESET", - "MGR_EVT_DEVICE_ABNORMAL", - "MGR_EVT_IO_SENSE", - }, - { - "MGR_EVT_UKEY_START", - "MGR_EVT_UKEY_INSERT", - "MGR_EVT_UKEY_DEGRADE", - "MGR_EVT_RAID_KEY_OVERCURRENT", - "MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER", - }, - { - "MGR_EVT_HWR_START", - "MGR_EVT_HWR_HAC_RESET_BEGIN", - "MGR_EVT_HWR_HAC_RESET_END", - "MGR_EVT_REPORT_HAC_ECC", - }, - { - "MGR_EVT_ALARM_START", - "MGR_EVT_ALARM_ENABLED", - "MGR_EVT_ALARM_DISABLED", - }, - { - "MGR_EVT_ECC_START", - "MGR_EVT_ECC_CNT_EXCEED", - "MGR_EVT_ECC_ERR_INTR", - "MGR_EVT_ECC_CNT_CLEAR", - "MGR_EVT_ECC_CLI_CHANGE", - "MGR_EVT_ECC_FACTORY_CHANGE", - }, - { - "MGR_EVT_UPGRADE_START", - "MGR_EVT_IMAGE_DOWNLOAD_ERROR", - "MGR_EVT_IMAGE_AUTHENTICATION_FAIL", - "MGR_EVT_IMAGE_VERSION_CHECK_FAIL", - "MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL", - "MGR_EVT_IMAGE_FROM_BACKUP", - "MGR_EVT_DEV_OPEN_ERROR", - "MGR_EVT_DEV_FLASH_ERROR", - "MGR_EVT_DEV_ERASE_ERROR", - "MGR_EVT_DEV_CLOSE_ERROR", - "MGR_EVT_FLASH_GENERAL_ERROR", - "MGR_EVT_FLASH_TIMEOUT", - "MGR_EVT_UPGRADE_SUCCESS", - "MGR_EVT_UPGRADE_SYNC_START", - "MGR_EVT_UPGRADE_SYNC_FAILED", - "MGR_EVT_UPGRADE_SYNC_SUCCESS", - }, - { - "MGR_EVT_TEMP_START", - "MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE", - "MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE", - "MGR_EVT_TEMP_WARNING", - "MGR_EVT_TEMP_CRITICAL", - }, - { - "MGR_EVT_PD_ATTR_EXTEND_START_START", - "MGR_EVT_PD_NVME_CMD_ERR", - "MGR_EVT_PD_NVME_CMD_TO", - "MGR_EVT_PD_NVME_INSERT_FAIL", - "MGR_EVT_PD_ERASE_ABORT", - "MGR_EVT_PD_ERASE_COMPLETE", - "MGR_EVT_PD_ERASE_FAILED", - "MGR_EVT_PD_ERASE_PROGRESS", - "MGR_EVT_PD_ERASE_START", - "MGR_EVT_PD_PDM_ABORT_BY_USER", - "MGR_EVT_PD_PDM_ABORT_FOR_REBUILD", - "MGR_EVT_PD_PDM_ABORT", - "MGR_EVT_PD_PDM_DONE", - "MGR_EVT_PD_PDM_FAILED_BAD_SOURCE", - "MGR_EVT_PD_PDM_FAILED_BAD_TARGET", - "MGR_EVT_PD_PDM_MEDIUM_ERROR", - "MGR_EVT_PD_PDM_PROGRESS", - "MGR_EVT_PD_PDM_REPLACED_SOURCE", - "MGR_EVT_PD_PDM_RESUME", - "MGR_EVT_PD_PDM_START_AUTO", - "MGR_EVT_PD_PDM_START", - "MGR_EVT_PD_PDM_SUSPENDED_REMINDER", - "MGR_EVT_PD_PDM_SUSPENDED", - "MGR_EVT_PD_PFA_ERROR_CLEAR", - "MGR_EVT_PD_SANITIZE_START", - "MGR_EVT_PD_FORMAT_START", - "MGR_EVT_PD_SANITIZE_PROGRESS", - "MGR_EVT_PD_SANITIZE_DONE", - "MGR_EVT_PD_FORMAT_DONE", - "MGR_EVT_PD_DPF_ERROR", - "MGR_EVT_PD_MARKED_SHIELD", - "MGR_EVT_PD_BBM_CORRECTED", - "MGR_EVT_PD_BBM_UNRECOVERABLE", - "MGR_EVT_PD_BBM_PUNCTURING", - "MGR_EVT_PD_BBM_REASSIGN_WR_ERROR", - "MGR_EVT_PD_UNABLE_ACCESS", - "MGR_EVT_MULITPILE_PD_UNABLE_ACCESS", - "MGR_EVT_PD_INSERT_FAIL", - "MGR_EVT_PHY_SATA_D2H_FAIL", - "MGR_EVT_PD_NOT_INSERTED", - "MGR_EVT_PD_NOT_SUPPORT", - "MGR_EVT_MULITPILE_PD_NOT_SUPPORT", - "MGR_EVT_NVDATA_INVAILD", - "MGR_EVT_PD_RBLD_NON_UNMAP_PD", - "MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD", - "MGR_EVT_PD_PDM_NON_UNMAP_PD", - "MGR_EVT_PD_RBLD_FAILED", - "MGR_EVT_PD_SANITIZE_FAILED", - "MGR_EVT_PD_SPIN_FAIL", - "MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT", - "MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT", - "MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT", - "MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT", - "MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT", - "MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT", - "MGR_EVT_NFR_FAILED", - "MGR_EVT_PD_RBLD_SMALL_SIZE", - "MGR_EVT_PD_MOVEBACK_SMALL_SIZE", - "MGR_EVT_NEGO_LOWER_LINK_SPEED", - "MGR_EVT_PCIE_LINK_NEGO_ABNORMAL", - "MGR_EVT_PD_ISOLATION", - "MGR_EVT_PD_REPAIR_FAILED", - "MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C", - "MGR_EVT_PD_PCIE_ENUMERATE_FAILED", - "MGR_EVT_PD_MISS_LIGHTING", - }, -}; + unsigned int typeIndex = 0; + unsigned int codeIndex = 0; + const char *pEvtTransStr = NULL; + static const char *pEvtCodeInfo[MGR_EVT_EXTEND_TYPE_START][MGR_EVT_TYPE_OFFSET] = { + { + "MGR_EVT_SAS_START", + "MGR_EVT_SAS_EXPANDER_IN", + "MGR_EVT_SAS_EXPANDER_OUT", + "MGR_EVT_SAS_EXPANDER_UPDATE", + "MGR_EVT_SAS_EXPANDER_CHANGE", + "MGR_EVT_ENCL_TEMP_NORMAL", + "MGR_EVT_ENCL_TEMP_WARNING", + "MGR_EVT_ENCL_TEMP_CRITICAL", + "MGR_EVT_TOPO_LOOP", + "MGR_EVT_LOOP_RESOLUTION", + "MGR_EVT_CASCADED_SCAN_SMP_FAIL", + "MGR_EVT_ENCL_EXCEED", + "MGR_EVT_TRI_MODE_SWITCH", + "MGR_EVT_CHANGE_PHY_BY_USER", + "MGR_EVT_REV_HIBERNATE_CMD", + "MGR_EVT_PHY_CHANGE", + "MGR_EVT_INQUIRY_INFO", + "MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH", + "MGR_EVT_SAS_SATA_LN_EXCEPTION", + "MGR_EVT_SAS_SATA_DRIVER_INFO", + }, + { + "MGR_EVT_PD_COUNT_START", + "MGR_EVT_DEVM_DISK_IN", + "MGR_EVT_DEVM_DISK_OUT", + "MGR_EVT_MULITPILE_PD_IN", + "MGR_EVT_MULITPILE_PD_OUT", + "MGR_EVT_DEVM_JBOD", + "MGR_EVT_DEVM_READY", + "MGR_EVT_MULITPILE_JBOD", + "MGR_EVT_MULITPILE_READY", + "MGR_EVT_BACKPLANE_ON", + "MGR_EVT_BACKPLANE_OFF", + "MGR_EVT_MULITPILE_PD_STATE_CHANGE", + "MGR_EVT_DEVM_DISK_CHANGE", + "MGR_EVT_DEFAULT_UNUSED", + "MGR_EVT_PD_PRE_READY", + }, + { + "MGR_EVT_VD_COUNT_START", + "MGR_EVT_VD_OPTIMAL", + "MGR_EVT_VD_PARTIAL_DEGRADE", + "MGR_EVT_VD_DEGRADE", + "MGR_EVT_VD_CREATED", + "MGR_EVT_VD_DELETED", + "MGR_EVT_VD_HIDDEN_CHANGE", + "MGR_EVT_MULITPILE_VD_IN", + "MGR_EVT_MULITPILE_VD_OUT", + "MGR_EVT_VD_UNLOCK", + "MGR_EVT_VD_OFFLINE", + "MGR_EVT_VD_CHANGE", + }, + { + "MGR_EVT_CTRL_INFO_START", + "MGR_EVT_CTRL_REBOOT", + "MGR_EVT_CTRL_SHUTDOWN", + "MGR_EVT_CTRL_TIME_CHANGE", + "MGR_EVT_CTRL_EVENT_LOG_CLEARED", + "MGR_EVT_CTRL_RBLD_RATE_CHANGED", + "MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED", + "MGR_EVT_CTRL_ENABLENCQ_CHANGED", + "MGR_EVT_CTRL_AUTO_REBUILD_CHANGED", + "MGR_EVT_CTRL_EGHS_READY_CHANGED", + "MGR_EVT_CTRL_EGHS_SPARE_CHANGED", + "MGR_EVT_CTRL_BGI_RATE_CHANGED", + "MGR_EVT_CTRL_MIGRATE_RATE_CHANGED", + "MGR_EVT_CTRL_CC_RATE_CHANGED", + "MGR_EVT_CTRL_DIRECT_CHANGE", + "MGR_EVT_CTRL_PR_START", + "MGR_EVT_CTRL_PR_PAUSE", + "MGR_EVT_CTRL_PR_REMINDER_PAUSE", + "MGR_EVT_CTRL_PR_RESUME", + "MGR_EVT_CTRL_PR_DONE", + "MGR_EVT_CTRL_PR_RATE_CHANGED", + "MGR_EVT_CTRL_PR_CANT_START", + "MGR_EVT_CTRL_PR_PROP_CHANGED", + "MGR_EVT_CTRL_PARAM_CHANGE", + "MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE", + "MGR_EVT_CTRL_RECOVERY_FACTORY", + "MGR_EVT_CTRL_PROFILEID_CHANGED", + "MGR_EVT_CTRL_SANPSHOT_CREATE", + "MGR_EVT_CTRL_SANPSHOT_DELETE", + "MGR_EVT_CTRL_ENABLEPDM_CHANGED", + "MGR_EVT_CTRL_PDMSUPPORTREADYPD", + "MGR_EVT_CTRL_PDMTIMERINTERVAL", + "MGR_EVT_CTRL_SECURITY_KEY_CHANGE", + "MGR_EVT_CTRL_SECURITY_KEY_CREATE", + "MGR_EVT_CTRL_SECURITY_KEY_DESTROY", + "MGR_EVT_CTRL_SECURITY_KEY_ESCROW", + "MGR_EVT_CTRL_SECURITY_KEY_FAILED", + "MGR_EVT_CTRL_SECURITY_KEY_INVALID", + "MGR_EVT_AUTOCONFIG", + "MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL", + "MGR_EVT_CTRL_FOREIGN_CLEAR", + "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL", + "MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL", + "MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS", + "MGR_EVT_CTRL_FOREIGN_PD_DETECTED", + "MGR_EVT_PD_INSERT_TO_DG", + "MGR_EVT_PD_IMPORT_TO_DG", + "MGR_EVT_HARD_RESET", + "MGR_EVT_DPF_CFG_MODIFY", + "MGR_EVT_SPOR", + "MGR_EVT_ONF_ABNORMAL", + "MGR_EVT_CTRL_LOADED", + "MGR_EVT_CACHE_PROTECTION_CMPT_READY", + "MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY", + "MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE", + "MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE", + "MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE", + "MGR_EVT_MEDIUM_DATA_RECOVER", + "MGR_EVT_INIT_FAIL", + "MGR_EVT_CTRL_POWER_MODE_CHANGED", + }, + { + "MGR_EVT_PD_ATTR_START", + "MGR_EVT_PD_INFO_CHANGE", + "MGR_EVT_PD_STATE_CHANGE", + "MGR_EVT_PD_MARKED_JBOD", + "MGR_EVT_PD_MARKED_READY", + "MGR_EVT_PD_MARKED_ONLINE", + "MGR_EVT_PD_MARKED_OFFLINE", + "MGR_EVT_PD_MARKED_FAILED", + "MGR_EVT_PD_MARKED_MISSING", + "MGR_EVT_PD_MARKED_REBUILD", + "MGR_EVT_PD_MARKED_REPLACE", + "MGR_EVT_PD_MARKED_UNCONFIGUREDBAD", + "MGR_EVT_PD_MARKED_FOREIGN", + "MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED", + "MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED", + "MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED", + "MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED", + "MGR_EVT_PD_R_GLOBAL_SPARE_ADDED", + "MGR_EVT_PD_R_GLOBAL_SPARE_DELETED", + "MGR_EVT_PD_R_DEDICATED_SPARE_ADDED", + "MGR_EVT_PD_R_DEDICATED_SPARE_DELETED", + "MGR_EVT_PD_RBLD_ABORT_BY_USER", + "MGR_EVT_PD_RBLD_DONE_PD", + "MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE", + "MGR_EVT_PD_RBLD_FAILED_BAD_TARGET", + "MGR_EVT_PD_RBLD_PROGRESS", + "MGR_EVT_PD_RBLD_SUSPENDED_REMINDER", + "MGR_EVT_PD_RBLD_SUSPENDED", + "MGR_EVT_PD_RBLD_RESUME", + "MGR_EVT_PD_RBLD_START", + "MGR_EVT_PD_RBLD_START_AUTO", + "MGR_EVT_PD_RBLD_MEDIUM_ERROR", + "MGR_EVT_PD_EMERGENCY_SPARE", + "MGR_EVT_PD_RECOVER_MEDIUM_ERROR", + "MGR_EVT_PD_MOVEBACK_START", + "MGR_EVT_PD_MOVEBACK_ABORT", + "MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD", + "MGR_EVT_PD_MOVEBACK_DONE", + "MGR_EVT_PD_MOVEBACK_PROGRESS", + "MGR_EVT_PD_MOVEBACK_SUSPENDED", + "MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER", + "MGR_EVT_PD_MOVEBACK_RESUME", + "MGR_EVT_PD_MOVEBACK_START_AUTO", + "MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE", + "MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET", + "MGR_EVT_PD_MOVEBACK_ABORT_BY_USER", + "MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR", + "MGR_EVT_PD_FGI_START", + "MGR_EVT_PD_FGI_COMPLETE", + "MGR_EVT_PD_FGI_FAILED", + "MGR_EVT_PD_FGI_PROGRESS", + "MGR_EVT_PD_FGI_ABORT", + "MGR_EVT_PD_PR_ABORTED", + "MGR_EVT_PD_PR_CORRECTED", + "MGR_EVT_PD_PR_UNCORRECTABLE", + "MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR", + "MGR_EVT_PD_PR_PROGRESS", + "MGR_EVT_PD_SET_BOOT_DRIVE", + "MGR_EVT_PD_RESET_BOOT_DRIVE", + "MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT", + "MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN", + "MGR_EVT_PD_POWERSAVE_TO_ON", + "MGR_EVT_PD_POWERSAVE_TO_TRANSITION", + "MGR_EVT_PD_TRANSITION_TO_ON", + "MGR_EVT_PD_TRANSITION_TO_POWERSAVE", + "MGR_EVT_PD_ON_TO_POWERSAVE", + "MGR_EVT_PD_START_LOCATE", + "MGR_EVT_PD_STOP_LOCATE", + "MGR_EVT_PD_PFA_ERROR", + "MGR_EVT_PD_NOT_PRESENT", + "MGR_EVT_DEVM_DISK_FAULT", + "MGR_EVT_PHY_FLASHOFFLINE", + "MGR_EVT_PHY_FLASHONLINE", + "MGR_EVT_NFR_DONE", + "MGR_EVT_NFR_REPAIRED", + "MGR_EVT_NFR_REPORT", + "MGR_EVT_NFR_STOP", + "MGR_EVT_PD_DOWNLOAD_DONE", + "MGR_EVT_PD_DOWNLOAD_START", + "MGR_EVT_NVME_PHY_BAD", + }, + { + "MGR_EVT_VD_ATTR_START", + "MGR_EVT_MULITPILE_VD_STATE_CHANGE", + "MGR_EVT_VD_OFFLINE_OLD", + "MGR_EVT_VD_LOCK", + "MGR_EVT_VD_PASSWD_CHANGED", + "MGR_EVT_VD_SETTINGS_CHANGE", + "MGR_EVT_VD_PD_CHANGE", + "MGR_EVT_VD_STATE_CHANGE", + "MGR_EVT_PD_RBLD_DONE_LD", + "MGR_EVT_VD_FGI_START", + "MGR_EVT_VD_FGI_COMPLETE", + "MGR_EVT_VD_FGI_FAILED", + "MGR_EVT_VD_FGI_PROGRESS", + "MGR_EVT_VD_FGI_ABORT", + "MGR_EVT_VD_BGI_START", + "MGR_EVT_VD_BGI_COMPLETE", + "MGR_EVT_VD_BGI_FAILED", + "MGR_EVT_VD_BGI_PROGRESS", + "MGR_EVT_VD_BGI_ABORT", + "MGR_EVT_VD_BGI_PAUSE", + "MGR_EVT_VD_BGI_REMINDER_PAUSE", + "MGR_EVT_VD_BGI_RESUME", + "MGR_EVT_VD_BGI_CORRECTABLE_ERROR", + "MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR", + "MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION", + "MGR_EVT_VD_BBM_CLEARED", + "MGR_EVT_VD_BBM_PERCENT_FULL", + "MGR_EVT_VD_BBM_100_FULL", + "MGR_EVT_VD_BBM_LOG_FULL", + "MGR_EVT_VD_BBM_LOG_RCT", + "MGR_EVT_VD_BBM_LOG_WCT", + "MGR_EVT_VD_BBM_DEL_RCT", + "MGR_EVT_VD_CC_ABORTED", + "MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR", + "MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS", + "MGR_EVT_VD_CC_DONE", + "MGR_EVT_VD_CC_DONE_INCON", + "MGR_EVT_VD_CC_FAILED", + "MGR_EVT_VD_CC_FAILED_UNCOR", + "MGR_EVT_VD_CC_INCONSISTENT_PARITY", + "MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED", + "MGR_EVT_VD_CC_PROGRESS", + "MGR_EVT_VD_CC_START", + "MGR_EVT_VD_CC_PAUSE", + "MGR_EVT_VD_CC_REMINDER_PAUSE", + "MGR_EVT_VD_CC_RESUME", + "MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY", + "MGR_EVT_VD_SET_BOOT_DRIVE", + "MGR_EVT_VD_RESET_BOOT_DRIVE", + "MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT", + "MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN", + "MGR_EVT_ALL_CONFIGS_MISSING", + "MGR_EVT_PDS_MISSING", + "MGR_EVT_NVSRAM_RECOVER_FAIL", + "MGR_EVT_NVSRAM_UPDATE_FAIL", + "MGR_EVT_VD_ERASE_ABORT", + "MGR_EVT_VD_ERASE_COMPLETE", + "MGR_EVT_VD_ERASE_DISK_FAILED", + "MGR_EVT_VD_ERASE_FAILED", + "MGR_EVT_VD_ERASE_PROGRESS", + "MGR_EVT_VD_ERASE_START", + "MGR_EVT_VD_EXPAND_FINISH", + "MGR_EVT_VD_EXPAND_START", + "MGR_EVT_VD_FLUSH_CLEAR_FAILED", + "MGR_EVT_VD_FLUSH_RECORD_FAILED", + "MGR_EVT_VD_FLUSH_SET_INCONSIST", + "MGR_EVT_VDS_MISSING", + "MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED", + "MGR_EVT_VD_FLUSH_CACHE_PINNED", + "MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED", + "MGR_EVT_VD_FLUSH_CACHE_DISCARDED", + "MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL", + "MGR_EVT_VD_FLUSH_CACHE_DESTAGED", + "MGR_EVT_VD_CM_RECOVERY_CRC_FAIL", + "MGR_EVT_VD_BGI_COMPLETE_UNCOR", + }, + { + "MGR_EVT_DG_INFO_START", + "MGR_EVT_DG_CREATED", + "MGR_EVT_DG_DELETED", + "MGR_EVT_DG_SETTING_CHANGE", + "MGR_EVT_DG_MIGRATION_START", + "MGR_EVT_DG_MIGRATION_RECOVER", + "MGR_EVT_DG_MIGRATION_SUCCESS", + "MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED", + "MGR_EVT_DG_MIGRATION_FAILED", + "MGR_EVT_DG_MIGRATION_RECOVER_FAILED", + "MGR_EVT_DG_MIGRATION_PROGRESS", + "MGR_EVT_DG_MIGRATION_INTERNAL_WARNING", + "MGR_EVT_DG_PRSWITCH_CHANGE", + "MGR_EVT_DG_PR_ABORTED_WM_FAILED", + "MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED", + }, + { + "MGR_EVT_BBU_START", + "MGR_EVT_BBU_PRESENT", + "MGR_EVT_BBU_NOT_PRESENT", + "MGR_EVT_BBU_GOOD", + "MGR_EVT_BBU_BAD", + "MGR_EVT_BBU_CAP_BELOW_THRESHOLD", + "MGR_EVT_BBU_CAP_ABOVE_THRESHOLD", + "MGR_EVT_BBU_CHARGE_STATUS", + "MGR_EVT_BBU_CHARGE_COMPLETE", + "MGR_EVT_BBU_INSERT", + "MGR_EVT_BBU_ABSENT", + "MGR_EVT_BBU_TEMPERATURE_NORMAL", + "MGR_EVT_BBU_TEMPERATURE_HIGH", + "MGR_EVT_BBU_VOLTAGE_NORMAL", + "MGR_EVT_BBU_VOLTAGE_HIGH", + "MGR_EVT_BBU_CURRENT_NORMAL", + "MGR_EVT_BBU_CURRENT_HIGH", + "MGR_EVT_BBU_LOAD_NORMAL", + "MGR_EVT_BBU_VOLTAGE_LOW", + "MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD", + "MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD", + "MGR_EVT_BBU_LEARN_STAGE", + "MGR_EVT_BBU_LEARN_REQUESTED", + "MGR_EVT_BBU_LEARN_POSTPONED", + "MGR_EVT_BBU_LEARN_TIMEOUT", + "MGR_EVT_BBU_LEARN_MANUAL", + "MGR_EVT_BBU_LEARN_RESCHEDULED", + "MGR_EVT_BBU_PROPERTIES_CHANGED", + }, + { + "MGR_EVT_CONFIG_START", + "MGR_EVT_CONFIG_INFO", + "MGR_EVT_CONFIG_FLASH_READ_FAIL", + "MGR_EVT_CONFIG_FLASH_WRITE_FAIL", + "MGR_EVT_CONFIG_NVSRAM_READ_FAIL", + "MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL", + "MGR_EVT_CONFIG_VERSION_MISMATCH", + "MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL", + "MGR_EVT_CONFIG_ERASE_NVSRAM", + "MGR_EVT_PHY_LINKSPEED_CFG_CHANGE", + }, + { + "MGR_EVT_IO_START", + "MGR_EVT_IO_TEST", + "MGR_EVT_IO_SENSE_DATA", + "MGR_EVT_DEVICE_RESET", + "MGR_EVT_NVME_DEVICE_RESET", + "MGR_EVT_DEVICE_ABNORMAL", + "MGR_EVT_IO_SENSE", + }, + { + "MGR_EVT_UKEY_START", + "MGR_EVT_UKEY_INSERT", + "MGR_EVT_UKEY_DEGRADE", + "MGR_EVT_RAID_KEY_OVERCURRENT", + "MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER", + }, + { + "MGR_EVT_HWR_START", + "MGR_EVT_HWR_HAC_RESET_BEGIN", + "MGR_EVT_HWR_HAC_RESET_END", + "MGR_EVT_REPORT_HAC_ECC", + }, + { + "MGR_EVT_ALARM_START", + "MGR_EVT_ALARM_ENABLED", + "MGR_EVT_ALARM_DISABLED", + }, + { + "MGR_EVT_ECC_START", + "MGR_EVT_ECC_CNT_EXCEED", + "MGR_EVT_ECC_ERR_INTR", + "MGR_EVT_ECC_CNT_CLEAR", + "MGR_EVT_ECC_CLI_CHANGE", + "MGR_EVT_ECC_FACTORY_CHANGE", + }, + { + "MGR_EVT_UPGRADE_START", + "MGR_EVT_IMAGE_DOWNLOAD_ERROR", + "MGR_EVT_IMAGE_AUTHENTICATION_FAIL", + "MGR_EVT_IMAGE_VERSION_CHECK_FAIL", + "MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL", + "MGR_EVT_IMAGE_FROM_BACKUP", + "MGR_EVT_DEV_OPEN_ERROR", + "MGR_EVT_DEV_FLASH_ERROR", + "MGR_EVT_DEV_ERASE_ERROR", + "MGR_EVT_DEV_CLOSE_ERROR", + "MGR_EVT_FLASH_GENERAL_ERROR", + "MGR_EVT_FLASH_TIMEOUT", + "MGR_EVT_UPGRADE_SUCCESS", + "MGR_EVT_UPGRADE_SYNC_START", + "MGR_EVT_UPGRADE_SYNC_FAILED", + "MGR_EVT_UPGRADE_SYNC_SUCCESS", + }, + { + "MGR_EVT_TEMP_START", + "MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE", + "MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE", + "MGR_EVT_TEMP_WARNING", + "MGR_EVT_TEMP_CRITICAL", + }, + }; - if (opCode >= ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET) + \ - (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) * MGR_EVT_TYPE_EXTEND_OFFSET) { - goto end; - }; - typeIndex = opCode / MGR_EVT_TYPE_OFFSET; - codeIndex = opCode % MGR_EVT_TYPE_OFFSET; - pEvtTransStr = pEvtCodeInfo[typeIndex][codeIndex]; + static const char *pEvtCodeExtInfo[PS3_EVT_EXT_NR][MGR_EVT_TYPE_EXTEND_OFFSET] = { + { + "MGR_EVT_PD_ATTR_EXTEND_START_START", + "MGR_EVT_PD_ERASE_ABORT", + "MGR_EVT_PD_ERASE_COMPLETE", + "MGR_EVT_PD_ERASE_FAILED", + "MGR_EVT_PD_ERASE_PROGRESS", + "MGR_EVT_PD_ERASE_START", + "MGR_EVT_PD_PDM_ABORT_BY_USER", + "MGR_EVT_PD_PDM_ABORT_FOR_REBUILD", + "MGR_EVT_PD_PDM_ABORT", + "MGR_EVT_PD_PDM_DONE", + "MGR_EVT_PD_PDM_FAILED_BAD_SOURCE", + "MGR_EVT_PD_PDM_FAILED_BAD_TARGET", + "MGR_EVT_PD_PDM_MEDIUM_ERROR", + "MGR_EVT_PD_PDM_PROGRESS", + "MGR_EVT_PD_PDM_REPLACED_SOURCE", + "MGR_EVT_PD_PDM_RESUME", + "MGR_EVT_PD_PDM_START_AUTO", + "MGR_EVT_PD_PDM_START", + "MGR_EVT_PD_PDM_SUSPENDED_REMINDER", + "MGR_EVT_PD_PDM_SUSPENDED", + "MGR_EVT_PD_PFA_ERROR_CLEAR", + "MGR_EVT_PD_SANITIZE_START", + "MGR_EVT_PD_FORMAT_START", + "MGR_EVT_PD_SANITIZE_PROGRESS", + "MGR_EVT_PD_SANITIZE_DONE", + "MGR_EVT_PD_FORMAT_DONE", + "MGR_EVT_PD_DPF_ERROR", + "MGR_EVT_PD_MARKED_SHIELD", + "MGR_EVT_PD_BBM_CORRECTED", + "MGR_EVT_PD_BBM_UNRECOVERABLE", + "MGR_EVT_PD_BBM_PUNCTURING", + "MGR_EVT_PD_BBM_REASSIGN_WR_ERROR", + "MGR_EVT_PD_UNABLE_ACCESS", + "MGR_EVT_MULITPILE_PD_UNABLE_ACCESS", + "MGR_EVT_PD_INSERT_FAIL", + "MGR_EVT_PHY_SATA_D2H_FAIL", + "MGR_EVT_PD_NOT_INSERTED", + "MGR_EVT_PD_NOT_SUPPORT", + "MGR_EVT_MULITPILE_PD_NOT_SUPPORT", + "MGR_EVT_NVDATA_INVALID", + "MGR_EVT_PD_RBLD_NON_UNMAP_PD", + "MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD", + "MGR_EVT_PD_PDM_NON_UNMAP_PD", + "MGR_EVT_PD_RBLD_FAILED", + "MGR_EVT_PD_SANITIZE_FAILED", + "MGR_EVT_PD_SPIN_FAIL", + "MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT", + "MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT", + "MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT", + "MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT", + "MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT", + "MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT", + "MGR_EVT_NFR_FAILED", + "MGR_EVT_PD_RBLD_SMALL_SIZE", + "MGR_EVT_PD_MOVEBACK_SMALL_SIZE", + "MGR_EVT_NEGO_LOWER_LINK_SPEED", + "MGR_EVT_PD_NVME_CMD_ERR", + "MGR_EVT_PD_NVME_CMD_TO", + "MGR_EVT_PD_NVME_INSERT_FAIL", + "MGR_EVT_PCIE_LINK_NEGO_ABNORMAL", + "MGR_EVT_PD_ISOLATION", + "MGR_EVT_PD_REPAIR_FAILED", + "MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C", + "MGR_EVT_PD_PCIE_ENUMERATE_FAILED", + "MGR_EVT_PD_MISS_LIGHTING", + }, + }; + + if (opCode >= ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET) + + (PS3_EVT_MAX_TYPE_LOCAL - MGR_EVT_EXTEND_TYPE_START) + * MGR_EVT_TYPE_EXTEND_OFFSET) { + goto end; + }; + if (opCode < ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) { + typeIndex = opCode / MGR_EVT_TYPE_OFFSET; + codeIndex = opCode % MGR_EVT_TYPE_OFFSET; + pEvtTransStr = pEvtCodeInfo[typeIndex][codeIndex]; + } else { + typeIndex = (opCode - ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) + / MGR_EVT_TYPE_EXTEND_OFFSET; + codeIndex = (opCode - ((MGR_EVT_EXTEND_TYPE_START - 1) * MGR_EVT_TYPE_OFFSET)) + % MGR_EVT_TYPE_EXTEND_OFFSET; + pEvtTransStr = pEvtCodeExtInfo[typeIndex][codeIndex]; +}; end: - return pEvtTransStr; + return pEvtTransStr; } #else -static inline S8 const *mgrEvtCodeTrans(U32 opCode) +static inline char const *mgrEvtCodeTrans(unsigned int opCode) { - const S8* pEvtTransStr = NULL; - return pEvtTransStr; + const char * const pEvtTransStr = NULL; + return pEvtTransStr; } #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h new file mode 100644 index 000000000000..92fabd5cdeb0 --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_dev_info.h @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PS3_HTP_DEV_INFO_H__ +#define __PS3_HTP_DEV_INFO_H__ + + +enum DriverType { + DRIVER_TYPE_UNKNOWN = 0, + DRIVER_TYPE_SAS, + DRIVER_TYPE_SATA, + DRIVER_TYPE_SES, + DRIVER_TYPE_NVME, + DRIVER_TYPE_EXP_SAS, + DRIVER_TYPE_VEP, + DRIVER_TYPE_CHASSIS, + DRIVER_TYPE_BACKPLANE, + DRIVER_TYPE_MAX, +}; + +static inline const char *getDriverTypeName(enum DriverType driverType) +{ + static const char * const driverTypeName[] = { + [DRIVER_TYPE_UNKNOWN] = "DRIVER_TYPE_UNKNOWN", + [DRIVER_TYPE_SAS] = "DRIVER_TYPE_SAS", + [DRIVER_TYPE_SATA] = "DRIVER_TYPE_SATA", + [DRIVER_TYPE_SES] = "DRIVER_TYPE_SES", + [DRIVER_TYPE_NVME] = "DRIVER_TYPE_NVME", + [DRIVER_TYPE_EXP_SAS] = "DRIVER_TYPE_EXP_SAS", + [DRIVER_TYPE_VEP] = "DRIVER_TYPE_VEP", + [DRIVER_TYPE_CHASSIS] = "DRIVER_TYPE_CHASSIS", + [DRIVER_TYPE_BACKPLANE] = "DRIVER_TYPE_BACKPLANE", + [DRIVER_TYPE_MAX] = "DRIVER_TYPE_MAX", + }; + + return driverTypeName[driverType]; +} + + +enum MediumType { + DEVICE_TYPE_UNKNOWN = 0, + DEVICE_TYPE_HDD, + DEVICE_TYPE_SSD, + DEVICE_TYPE_ENCLOSURE, + DEVICE_TYPE_MAX, +}; + +static inline const char *getMediumTypeName(enum MediumType mediumType) +{ + static const char * const mediumTypeName[] = { + [DEVICE_TYPE_UNKNOWN] = "DEVICE_TYPE_UNKNOWN", + [DEVICE_TYPE_HDD] = "DEVICE_TYPE_HDD", + [DEVICE_TYPE_SSD] = "DEVICE_TYPE_SSD", + [DEVICE_TYPE_ENCLOSURE] = "DEVICE_TYPE_ENCLOSURE", + [DEVICE_TYPE_MAX] = "DEVICE_TYPE_MAX", + }; + + return mediumTypeName[mediumType]; +} + + +enum DeviceState { + DEVICE_STATE_FREE = 0x0, + DEVICE_STATE_INSERTING, + DEVICE_STATE_ONLINE, + DEVICE_STATE_WAIT, + DEVICE_STATE_RECOVER, + DEVICE_STATE_PREONLINE, + DEVICE_STATE_OUTING, + DEVICE_STATE_MAX, +}; + +static inline const char *getDeviceStateName(enum DeviceState pdState) +{ + static const char * const pdStateName[] = { + [DEVICE_STATE_FREE] = "DEVICE_STATE_FREE", + [DEVICE_STATE_INSERTING] = "DEVICE_STATE_INSERTING", + [DEVICE_STATE_ONLINE] = "DEVICE_STATE_ONLINE", + [DEVICE_STATE_WAIT] = "DEVICE_STATE_WAIT", + [DEVICE_STATE_RECOVER] = "DEVICE_STATE_RECOVER", + [DEVICE_STATE_PREONLINE] = "DEVICE_STATE_PREONLINE", + [DEVICE_STATE_OUTING] = "DEVICE_STATE_OUTING", + [DEVICE_STATE_MAX] = "DEVICE_STATE_MAX", + }; + + return pdStateName[pdState]; +} + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h new file mode 100644 index 000000000000..416fa01d10f6 --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_meta.h @@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PS3_HTP_META_H__ +#define __PS3_HTP_META_H__ + +enum MicPdState { + MIC_PD_STATE_UNKNOWN = 0, + MIC_PD_STATE_READY = 1, + MIC_PD_STATE_UBAD = 2, + MIC_PD_STATE_DSPARE = 3, + MIC_PD_STATE_GSPARE = 4, + MIC_PD_STATE_OFFLINE = 5, + MIC_PD_STATE_ONLINE = 6, + MIC_PD_STATE_MISSING = 7, + MIC_PD_STATE_FAILED = 8, + MIC_PD_STATE_REBUILD = 9, + MIC_PD_STATE_REPLACE = 10, + MIC_PD_STATE_FOREIGN = 11, + MIC_PD_STATE_JBOD = 12, + MIC_PD_STATE_UNSUPPORT = 13, + MIC_PD_STATE_PDM = 14, + MIC_PD_STATE_CFSHLD = 15, + MIC_PD_STATE_HSPSHLD = 16, + MIC_PD_STATE_RUNSP = 17, + MIC_PD_STATE_UBUNSP = 18, + MIC_PD_STATE_MAX +}; + + +static inline const char *getPdStateName(enum MicPdState pdSate, + unsigned char isRaid) +{ + static const char * const raidPdName[] = { + [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", + [MIC_PD_STATE_READY] = "UGOOD", + [MIC_PD_STATE_UBAD] = "UBAD", + [MIC_PD_STATE_DSPARE] = "DSPARE", + [MIC_PD_STATE_GSPARE] = "GSPARE", + [MIC_PD_STATE_OFFLINE] = "OFFLINE", + [MIC_PD_STATE_ONLINE] = "ONLINE", + [MIC_PD_STATE_MISSING] = "MISSING", + [MIC_PD_STATE_FAILED] = "FAILED", + [MIC_PD_STATE_REBUILD] = "REBUILD", + [MIC_PD_STATE_REPLACE] = "REPLACE", + [MIC_PD_STATE_FOREIGN] = "FOREIGN", + [MIC_PD_STATE_JBOD] = "JBOD", + [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", + [MIC_PD_STATE_PDM] = "PDM", + [MIC_PD_STATE_CFSHLD] = "CFSHLD", + [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", + [MIC_PD_STATE_RUNSP] = "UGUNSP", + [MIC_PD_STATE_UBUNSP] = "UBUNSP", + }; + + static const char * const hbaPdName[] = { + [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", + [MIC_PD_STATE_READY] = "READY", + [MIC_PD_STATE_UBAD] = "UBAD", + [MIC_PD_STATE_DSPARE] = "DSPARE", + [MIC_PD_STATE_GSPARE] = "GSPARE", + [MIC_PD_STATE_OFFLINE] = "OFFLINE", + [MIC_PD_STATE_ONLINE] = "ONLINE", + [MIC_PD_STATE_MISSING] = "MISSING", + [MIC_PD_STATE_FAILED] = "FAILED", + [MIC_PD_STATE_REBUILD] = "REBUILD", + [MIC_PD_STATE_REPLACE] = "REPLACE", + [MIC_PD_STATE_FOREIGN] = "FOREIGN", + [MIC_PD_STATE_JBOD] = "JBOD", + [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", + [MIC_PD_STATE_PDM] = "PDM", + [MIC_PD_STATE_CFSHLD] = "CFSHLD", + [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", + [MIC_PD_STATE_RUNSP] = "RUNSP", + [MIC_PD_STATE_UBUNSP] = "UBUNSP", + }; + + if (isRaid) + return raidPdName[pdSate]; + else + return hbaPdName[pdSate]; +} + + +enum MicVdState { + MIC_VD_STATE_UNKNOWN = 0, + MIC_VD_STATE_OFFLINE, + MIC_VD_STATE_OPTIMAL, + MIC_VD_STATE_PARTIAL_DEGRADE, + MIC_VD_STATE_DEGRADE +}; + +static inline const char *getVdStateName(enum MicVdState vdSate) +{ + static const char * const vdStateName[] = { [MIC_VD_STATE_UNKNOWN] = "UNKNOWN", + [MIC_VD_STATE_OFFLINE] = "OFFLINE", + [MIC_VD_STATE_OPTIMAL] = "OPTIMAL", + [MIC_VD_STATE_PARTIAL_DEGRADE] = + "PARTIALLY DEGRADED", + [MIC_VD_STATE_DEGRADE] = + "DEGRADED" }; + + return vdStateName[vdSate]; +} + + +enum RaidLevel { + RAID0 = 0x00, + RAID1 = 0x01, + RAID5 = 0x05, + RAID6 = 0x06, + JBOD = 0x0A, + RAID10 = 0x10, + RAID1E = 0x11, + RAID00 = 0x20, + RAID50 = 0x50, + RAID60 = 0x60, + RAID_UNKNOWN = 0xFF +}; + +enum VDAccessPolicy { + VD_ACCESS_POLICY_READ_WRITE = 0, + VD_ACCESS_POLICY_READ_ONLY, + VD_ACCESS_POLICY_BLOCK, + VD_ACCESS_POLICY_REMOVE_ACCESS +}; +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h new file mode 100644 index 000000000000..86340a47217a --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PS3_HTP_MGR_EVT_H__ +#define __PS3_HTP_MGR_EVT_H__ + +#include "ps3_htp_mgr_evt_raidhba.h" + +struct PS3EventFilter { + unsigned char eventType; + unsigned char eventCodeCnt; + unsigned char reserved[6]; + unsigned short eventCodeTable[0]; +}; + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h new file mode 100644 index 000000000000..3084bc168567 --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_mgr_evt_raidhba.h @@ -0,0 +1,1869 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PS3_HTP_MGR_EVT_RAIDHBA_H__ +#define __PS3_HTP_MGR_EVT_RAIDHBA_H__ +#include "ps3_mgr_evt_common.h" + +enum MgrEvtType { + PS3_EVT_ILLEGAL_TYPE = 0, + PS3_EVT_SAS_INFO = 0x1, + PS3_EVT_PD_COUNT = 0x2, + PS3_EVT_VD_COUNT = 0x4, + PS3_EVT_CTRL_INFO = 0x8, + PS3_EVT_PD_ATTR = 0x10, + PS3_EVT_VD_ATTR = 0x20, + PS3_EVT_DG_INFO = 0x40, + PS3_EVT_BBU_INFO = 0x80, + PS3_EVT_CONFIG = 0x100, + PS3_EVT_IO_INFO = 0x200, + PS3_EVT_UKEY_INFO = 0x400, + PS3_EVT_HWR_INFO = 0x800, + PS3_EVT_ALARM_INFO = 0x1000, + PS3_EVT_ECC_INFO = 0x2000, + PS3_EVT_UPGRADE_INFO = 0x4000, + PS3_EVT_TEMP_INFO = 0x8000, + PS3_EVT_PD_ATTR_EXTEND = 0x10000, +}; + +static inline const char *nameMgrEvtType(unsigned int e) +{ + switch (e) { + case PS3_EVT_SAS_INFO: + return "PS3_EVT_SAS_INFO"; + case PS3_EVT_PD_COUNT: + return "PS3_EVT_PD_COUNT"; + case PS3_EVT_VD_COUNT: + return "PS3_EVT_VD_COUNT"; + case PS3_EVT_CTRL_INFO: + return "PS3_EVT_CTRL_INFO"; + case PS3_EVT_PD_ATTR: + return "PS3_EVT_PD_ATTR"; + case PS3_EVT_VD_ATTR: + return "PS3_EVT_VD_ATTR"; + case PS3_EVT_DG_INFO: + return "PS3_EVT_DG_INFO"; + case PS3_EVT_BBU_INFO: + return "PS3_EVT_BBU_INFO"; + case PS3_EVT_CONFIG: + return "PS3_EVT_CONFIG"; + case PS3_EVT_IO_INFO: + return "PS3_EVT_IO_INFO"; + case PS3_EVT_UKEY_INFO: + return "PS3_EVT_UKEY_INFO"; + case PS3_EVT_HWR_INFO: + return "PS3_EVT_HWR_INFO"; + case PS3_EVT_ALARM_INFO: + return "PS3_EVT_ALARM_INFO"; + case PS3_EVT_ECC_INFO: + return "PS3_EVT_ECC_INFO"; + case PS3_EVT_UPGRADE_INFO: + return "PS3_EVT_UPGRADE_INFO"; + case PS3_EVT_TEMP_INFO: + return "PS3_EVT_TEMP_INFO"; + case PS3_EVT_PD_ATTR_EXTEND: + return "PS3_EVT_PD_ATTR_EXTEND"; + default: + return "PS3_EVT_ILLEGAL_TYPE"; + } +} + +enum { + PS3_EVT_SAS_INFO_LOCAL = 1, + PS3_EVT_PD_COUNT_LOCAL = 2, + PS3_EVT_VD_COUNT_LOCAL = 3, + PS3_EVT_CTRL_INFO_LOCAL = 4, + PS3_EVT_PD_ATTR_LOCAL = 5, + PS3_EVT_VD_ATTR_LOCAL = 6, + PS3_EVT_DG_INFO_LOCAL = 7, + PS3_EVT_BBU_INFO_LOCAL = 8, + PS3_EVT_CONFIG_LOCAL = 9, + PS3_EVT_IO_INFO_LOCAL = 10, + PS3_EVT_UKEY_INFO_LOCAL = 11, + PS3_EVT_HWR_INFO_LOCAL = 12, + PS3_EVT_ALARM_INFO_LOCAL = 13, + PS3_EVT_ECC_INFO_LOCAL = 14, + PS3_EVT_UPGRADE_INFO_LOCAL = 15, + PS3_EVT_TEMP_INFO_LOCAL = 16, + PS3_EVT_PD_ATTR_EXTEND_LOCAL = 17, + PS3_EVT_DEFAULT_UNUSED_LOCAL, + PS3_EVT_MAX_TYPE_LOCAL, +}; + +static inline const char *nameMgrEvtLocalType(unsigned int e) +{ + switch (e) { + case PS3_EVT_SAS_INFO_LOCAL: + return "PS3_EVT_SAS_INFO_LOCAL"; + case PS3_EVT_PD_COUNT_LOCAL: + return "PS3_EVT_PD_COUNT_LOCAL"; + case PS3_EVT_VD_COUNT_LOCAL: + return "PS3_EVT_VD_COUNT_LOCAL"; + case PS3_EVT_CTRL_INFO_LOCAL: + return "PS3_EVT_CTRL_INFO_LOCAL"; + case PS3_EVT_PD_ATTR_LOCAL: + return "PS3_EVT_PD_ATTR_LOCAL"; + case PS3_EVT_VD_ATTR_LOCAL: + return "PS3_EVT_VD_ATTR_LOCAL"; + case PS3_EVT_DG_INFO_LOCAL: + return "PS3_EVT_DG_INFO_LOCAL"; + case PS3_EVT_BBU_INFO_LOCAL: + return "PS3_EVT_BBU_INFO_LOCAL"; + case PS3_EVT_CONFIG_LOCAL: + return "PS3_EVT_CONFIG_LOCAL"; + case PS3_EVT_IO_INFO_LOCAL: + return "PS3_EVT_IO_INFO_LOCAL"; + case PS3_EVT_UKEY_INFO_LOCAL: + return "PS3_EVT_UKEY_INFO_LOCAL"; + case PS3_EVT_HWR_INFO_LOCAL: + return "PS3_EVT_HWR_INFO_LOCAL"; + case PS3_EVT_ALARM_INFO_LOCAL: + return "PS3_EVT_ALARM_INFO_LOCAL"; + case PS3_EVT_ECC_INFO_LOCAL: + return "PS3_EVT_ECC_INFO_LOCAL"; + case PS3_EVT_UPGRADE_INFO_LOCAL: + return "PS3_EVT_UPGRADE_INFO_LOCAL"; + case PS3_EVT_TEMP_INFO_LOCAL: + return "PS3_EVT_TEMP_INFO_LOCAL"; + case PS3_EVT_PD_ATTR_EXTEND_LOCAL: + return "PS3_EVT_PD_ATTR_EXTEND_LOCAL"; + default: + return "PS3_EVT_ILLEGAL_TYPE"; + } +} + +enum MgrEvtSASInfoCode { + MGR_EVT_SAS_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_SAS_INFO_LOCAL), + MGR_EVT_SAS_EXPANDER_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x1), + MGR_EVT_SAS_EXPANDER_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0x2), + MGR_EVT_SAS_EXPANDER_UPDATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x3), + MGR_EVT_SAS_EXPANDER_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x4), + MGR_EVT_ENCL_TEMP_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x5), + MGR_EVT_ENCL_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0x6), + MGR_EVT_ENCL_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_SAS_START + 0x7), + MGR_EVT_TOPO_LOOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0x8), + MGR_EVT_LOOP_RESOLUTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x9), + MGR_EVT_CASCADED_SCAN_SMP_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_SAS_START + 0xa), + MGR_EVT_ENCL_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0xb), + MGR_EVT_TRI_MODE_SWITCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0xc), + MGR_EVT_CHANGE_PHY_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0xd), + MGR_EVT_REV_HIBERNATE_CMD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0xe), + MGR_EVT_PHY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0xf), + MGR_EVT_INQUIRY_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x10), + MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0x11), + MGR_EVT_SAS_SATA_LN_EXCEPTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_SAS_START + 0x12), + MGR_EVT_SAS_SATA_DRIVER_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_SAS_START + 0x13), + MGR_EVT_SAS_END = (MGR_EVT_SAS_START+0x14), +}; + +enum MgrEvtPdCountCode { + MGR_EVT_PD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_COUNT_LOCAL), + MGR_EVT_DEVM_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x1), + MGR_EVT_DEVM_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x2), + MGR_EVT_MULITPILE_PD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x3), + MGR_EVT_MULITPILE_PD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x4), + MGR_EVT_DEVM_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x5), + MGR_EVT_DEVM_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x6), + MGR_EVT_MULITPILE_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x7), + MGR_EVT_MULITPILE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x8), + MGR_EVT_BACKPLANE_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0x9), + MGR_EVT_BACKPLANE_OFF = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0xa), + MGR_EVT_MULITPILE_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0xb), + MGR_EVT_DEVM_DISK_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0xc), + MGR_EVT_DEFAULT_UNUSED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0xd), + MGR_EVT_PD_PRE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_COUNT_START + 0xe), + MGR_EVT_PD_COUNT_END = (MGR_EVT_PD_COUNT_START+0xf), +}; + +enum MgrEvtVdCountCode { + MGR_EVT_VD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_COUNT_LOCAL), + MGR_EVT_VD_OPTIMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x1), + MGR_EVT_VD_PARTIAL_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_COUNT_START + 0x2), + MGR_EVT_VD_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_COUNT_START + 0x3), + MGR_EVT_VD_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x4), + MGR_EVT_VD_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x5), + MGR_EVT_VD_HIDDEN_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x6), + MGR_EVT_MULITPILE_VD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x7), + MGR_EVT_MULITPILE_VD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x8), + MGR_EVT_VD_UNLOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0x9), + MGR_EVT_VD_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_COUNT_START + 0xa), + MGR_EVT_VD_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_COUNT_START + 0xb), + MGR_EVT_VD_COUNT_END = (MGR_EVT_VD_COUNT_START+0xc), +}; + +enum MgrEvtCtrlInfoCode { + MGR_EVT_CTRL_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CTRL_INFO_LOCAL), + MGR_EVT_CTRL_REBOOT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1), + MGR_EVT_CTRL_SHUTDOWN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2), + MGR_EVT_CTRL_TIME_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x3), + MGR_EVT_CTRL_EVENT_LOG_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x4), + MGR_EVT_CTRL_RBLD_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x5), + MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x6), + MGR_EVT_CTRL_ENABLENCQ_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x7), + MGR_EVT_CTRL_AUTO_REBUILD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x8), + MGR_EVT_CTRL_EGHS_READY_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x9), + MGR_EVT_CTRL_EGHS_SPARE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xa), + MGR_EVT_CTRL_BGI_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xb), + MGR_EVT_CTRL_MIGRATE_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xc), + MGR_EVT_CTRL_CC_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xd), + MGR_EVT_CTRL_DIRECT_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xe), + MGR_EVT_CTRL_PR_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0xf), + MGR_EVT_CTRL_PR_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x10), + MGR_EVT_CTRL_PR_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x11), + MGR_EVT_CTRL_PR_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x12), + MGR_EVT_CTRL_PR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x13), + MGR_EVT_CTRL_PR_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x14), + MGR_EVT_CTRL_PR_CANT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x15), + MGR_EVT_CTRL_PR_PROP_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x16), + MGR_EVT_CTRL_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x17), + MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x18), + MGR_EVT_CTRL_RECOVERY_FACTORY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x19), + MGR_EVT_CTRL_PROFILEID_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1a), + MGR_EVT_CTRL_SANPSHOT_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1b), + MGR_EVT_CTRL_SANPSHOT_DELETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1c), + MGR_EVT_CTRL_ENABLEPDM_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1d), + MGR_EVT_CTRL_PDMSUPPORTREADYPD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1e), + MGR_EVT_CTRL_PDMTIMERINTERVAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x1f), + MGR_EVT_CTRL_SECURITY_KEY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x20), + MGR_EVT_CTRL_SECURITY_KEY_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x21), + MGR_EVT_CTRL_SECURITY_KEY_DESTROY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x22), + MGR_EVT_CTRL_SECURITY_KEY_ESCROW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x23), + MGR_EVT_CTRL_SECURITY_KEY_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x24), + MGR_EVT_CTRL_SECURITY_KEY_INVALID = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x25), + MGR_EVT_AUTOCONFIG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x26), + MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x27), + MGR_EVT_CTRL_FOREIGN_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x28), + MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x29), + MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2a), + MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2b), + MGR_EVT_CTRL_FOREIGN_PD_DETECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2c), + MGR_EVT_PD_INSERT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2d), + MGR_EVT_PD_IMPORT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2e), + MGR_EVT_HARD_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x2f), + MGR_EVT_DPF_CFG_MODIFY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x30), + MGR_EVT_SPOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x31), + MGR_EVT_ONF_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_CTRL_INFO_START + 0x32), + MGR_EVT_CTRL_LOADED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x33), + MGR_EVT_CACHE_PROTECTION_CMPT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x34), + MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x35), + MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_CTRL_INFO_START + 0x36), + MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_CTRL_INFO_START + 0x37), + MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_CTRL_INFO_START + 0x38), + MGR_EVT_MEDIUM_DATA_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x39), + MGR_EVT_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x3a), + MGR_EVT_CTRL_POWER_MODE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CTRL_INFO_START + 0x3b), + MGR_EVT_CTRL_INFO_END = (MGR_EVT_CTRL_INFO_START+0x3c), +}; + +enum MgrEvtPdAttrCode { + MGR_EVT_PD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_LOCAL), + MGR_EVT_PD_INFO_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1), + MGR_EVT_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2), + MGR_EVT_PD_MARKED_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3), + MGR_EVT_PD_MARKED_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4), + MGR_EVT_PD_MARKED_ONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x5), + MGR_EVT_PD_MARKED_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x6), + MGR_EVT_PD_MARKED_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x7), + MGR_EVT_PD_MARKED_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x8), + MGR_EVT_PD_MARKED_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x9), + MGR_EVT_PD_MARKED_REPLACE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xa), + MGR_EVT_PD_MARKED_UNCONFIGUREDBAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xb), + MGR_EVT_PD_MARKED_FOREIGN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xc), + MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xd), + MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xe), + MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0xf), + MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x10), + MGR_EVT_PD_R_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x11), + MGR_EVT_PD_R_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x12), + MGR_EVT_PD_R_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x13), + MGR_EVT_PD_R_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x14), + MGR_EVT_PD_RBLD_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x15), + MGR_EVT_PD_RBLD_DONE_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x16), + MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x17), + MGR_EVT_PD_RBLD_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x18), + MGR_EVT_PD_RBLD_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_START + 0x19), + MGR_EVT_PD_RBLD_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1a), + MGR_EVT_PD_RBLD_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1b), + MGR_EVT_PD_RBLD_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1c), + MGR_EVT_PD_RBLD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1d), + MGR_EVT_PD_RBLD_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x1e), + MGR_EVT_PD_RBLD_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_START + 0x1f), + MGR_EVT_PD_EMERGENCY_SPARE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x20), + MGR_EVT_PD_RECOVER_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_START + 0x21), + MGR_EVT_PD_MOVEBACK_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x22), + MGR_EVT_PD_MOVEBACK_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x23), + MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x24), + MGR_EVT_PD_MOVEBACK_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x25), + MGR_EVT_PD_MOVEBACK_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_START + 0x26), + MGR_EVT_PD_MOVEBACK_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x27), + MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x28), + MGR_EVT_PD_MOVEBACK_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x29), + MGR_EVT_PD_MOVEBACK_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2a), + MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x2b), + MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2c), + MGR_EVT_PD_MOVEBACK_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2d), + MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_START + 0x2e), + MGR_EVT_PD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x2f), + MGR_EVT_PD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x30), + MGR_EVT_PD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x31), + MGR_EVT_PD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_START + 0x32), + MGR_EVT_PD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x33), + MGR_EVT_PD_PR_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x34), + MGR_EVT_PD_PR_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x35), + MGR_EVT_PD_PR_UNCORRECTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_START + 0x36), + MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x37), + MGR_EVT_PD_PR_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_START + 0x38), + MGR_EVT_PD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x39), + MGR_EVT_PD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3a), + MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3b), + MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3c), + MGR_EVT_PD_POWERSAVE_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3d), + MGR_EVT_PD_POWERSAVE_TO_TRANSITION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3e), + MGR_EVT_PD_TRANSITION_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x3f), + MGR_EVT_PD_TRANSITION_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x40), + MGR_EVT_PD_ON_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x41), + MGR_EVT_PD_START_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x42), + MGR_EVT_PD_STOP_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x43), + MGR_EVT_PD_PFA_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x44), + MGR_EVT_PD_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x45), + MGR_EVT_DEVM_DISK_FAULT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_START + 0x46), + MGR_EVT_PHY_FLASHOFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_START + 0x47), + MGR_EVT_PHY_FLASHONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x48), + MGR_EVT_NFR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x49), + MGR_EVT_NFR_REPAIRED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4a), + MGR_EVT_NFR_REPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4b), + MGR_EVT_NFR_STOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4c), + MGR_EVT_PD_DOWNLOAD_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4d), + MGR_EVT_PD_DOWNLOAD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4e), + MGR_EVT_NVME_PHY_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_START + 0x4f), + MGR_EVT_PD_ATTR_END = (MGR_EVT_PD_ATTR_START+0x50), +}; + +enum MgrEvtVdAttrCode { + MGR_EVT_VD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_ATTR_LOCAL), + MGR_EVT_MULITPILE_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x1), + MGR_EVT_VD_OFFLINE_OLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x2), + MGR_EVT_VD_LOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x3), + MGR_EVT_VD_PASSWD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x4), + MGR_EVT_VD_SETTINGS_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x5), + MGR_EVT_VD_PD_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x6), + MGR_EVT_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x7), + MGR_EVT_PD_RBLD_DONE_LD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x8), + MGR_EVT_VD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x9), + MGR_EVT_VD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0xa), + MGR_EVT_VD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_ATTR_START + 0xb), + MGR_EVT_VD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_VD_ATTR_START + 0xc), + MGR_EVT_VD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0xd), + MGR_EVT_VD_BGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0xe), + MGR_EVT_VD_BGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0xf), + MGR_EVT_VD_BGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_ATTR_START + 0x10), + MGR_EVT_VD_BGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_VD_ATTR_START + 0x11), + MGR_EVT_VD_BGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x12), + MGR_EVT_VD_BGI_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x13), + MGR_EVT_VD_BGI_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x14), + MGR_EVT_VD_BGI_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x15), + MGR_EVT_VD_BGI_CORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x16), + MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x17), + MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x18), + MGR_EVT_VD_BBM_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x19), + MGR_EVT_VD_BBM_PERCENT_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x1a), + MGR_EVT_VD_BBM_100_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x1b), + MGR_EVT_VD_BBM_LOG_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x1c), + MGR_EVT_VD_BBM_LOG_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x1d), + MGR_EVT_VD_BBM_LOG_WCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_ATTR_START + 0x1e), + MGR_EVT_VD_BBM_DEL_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x1f), + MGR_EVT_VD_CC_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x20), + MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x21), + MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x22), + MGR_EVT_VD_CC_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x23), + MGR_EVT_VD_CC_DONE_INCON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x24), + MGR_EVT_VD_CC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_ATTR_START + 0x25), + MGR_EVT_VD_CC_FAILED_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x26), + MGR_EVT_VD_CC_INCONSISTENT_PARITY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x27), + MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x28), + MGR_EVT_VD_CC_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_VD_ATTR_START + 0x29), + MGR_EVT_VD_CC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2a), + MGR_EVT_VD_CC_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2b), + MGR_EVT_VD_CC_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2c), + MGR_EVT_VD_CC_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2d), + MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2e), + MGR_EVT_VD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x2f), + MGR_EVT_VD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x30), + MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x31), + MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x32), + MGR_EVT_ALL_CONFIGS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x33), + MGR_EVT_PDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x34), + MGR_EVT_NVSRAM_RECOVER_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x35), + MGR_EVT_NVSRAM_UPDATE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x36), + MGR_EVT_VD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x37), + MGR_EVT_VD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x38), + MGR_EVT_VD_ERASE_DISK_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x39), + MGR_EVT_VD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_VD_ATTR_START + 0x3a), + MGR_EVT_VD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_VD_ATTR_START + 0x3b), + MGR_EVT_VD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x3c), + MGR_EVT_VD_EXPAND_FINISH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x3d), + MGR_EVT_VD_EXPAND_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x3e), + MGR_EVT_VD_FLUSH_CLEAR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x3f), + MGR_EVT_VD_FLUSH_RECORD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x40), + MGR_EVT_VD_FLUSH_SET_INCONSIST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x41), + MGR_EVT_VDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x42), + MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x43), + MGR_EVT_VD_FLUSH_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x44), + MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x45), + MGR_EVT_VD_FLUSH_CACHE_DISCARDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x46), + MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x47), + MGR_EVT_VD_FLUSH_CACHE_DESTAGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_VD_ATTR_START + 0x48), + MGR_EVT_VD_CM_RECOVERY_CRC_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_VD_ATTR_START + 0x49), + MGR_EVT_VD_BGI_COMPLETE_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_VD_ATTR_START + 0x4a), + MGR_EVT_VD_ATTR_END = (MGR_EVT_VD_ATTR_START+0x4b), +}; + +enum MgrEvtDgInfoCode { + MGR_EVT_DG_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_DG_INFO_LOCAL), + MGR_EVT_DG_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x1), + MGR_EVT_DG_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x2), + MGR_EVT_DG_SETTING_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x3), + MGR_EVT_DG_MIGRATION_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x4), + MGR_EVT_DG_MIGRATION_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x5), + MGR_EVT_DG_MIGRATION_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0x6), + MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_DG_INFO_START + 0x7), + MGR_EVT_DG_MIGRATION_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_DG_INFO_START + 0x8), + MGR_EVT_DG_MIGRATION_RECOVER_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_DG_INFO_START + 0x9), + MGR_EVT_DG_MIGRATION_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_DG_INFO_START + 0xa), + MGR_EVT_DG_MIGRATION_INTERNAL_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_DG_INFO_START + 0xb), + MGR_EVT_DG_PRSWITCH_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_DG_INFO_START + 0xc), + MGR_EVT_DG_PR_ABORTED_WM_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_DG_INFO_START + 0xd), + MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_DG_INFO_START + 0xe), + MGR_EVT_DG_INFO_END = (MGR_EVT_DG_INFO_START+0xf), +}; + +enum MgrEvtBbuInfoCode { + MGR_EVT_BBU_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_BBU_INFO_LOCAL), + MGR_EVT_BBU_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x1), + MGR_EVT_BBU_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x2), + MGR_EVT_BBU_GOOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x3), + MGR_EVT_BBU_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0x4), + MGR_EVT_BBU_CAP_BELOW_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x5), + MGR_EVT_BBU_CAP_ABOVE_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x6), + MGR_EVT_BBU_CHARGE_STATUS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x7), + MGR_EVT_BBU_CHARGE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x8), + MGR_EVT_BBU_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x9), + MGR_EVT_BBU_ABSENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0xa), + MGR_EVT_BBU_TEMPERATURE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0xb), + MGR_EVT_BBU_TEMPERATURE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_BBU_START + 0xc), + MGR_EVT_BBU_VOLTAGE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0xd), + MGR_EVT_BBU_VOLTAGE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0xe), + MGR_EVT_BBU_CURRENT_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0xf), + MGR_EVT_BBU_CURRENT_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0x10), + MGR_EVT_BBU_LOAD_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x11), + MGR_EVT_BBU_VOLTAGE_LOW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0x12), + MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x13), + MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_BBU_START + 0x14), + MGR_EVT_BBU_LEARN_STAGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x15), + MGR_EVT_BBU_LEARN_REQUESTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0x16), + MGR_EVT_BBU_LEARN_POSTPONED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x17), + MGR_EVT_BBU_LEARN_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_BBU_START + 0x18), + MGR_EVT_BBU_LEARN_MANUAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_BBU_START + 0x19), + MGR_EVT_BBU_LEARN_RESCHEDULED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x1a), + MGR_EVT_BBU_PROPERTIES_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_BBU_START + 0x1b), + MGR_EVT_BBU_END = (MGR_EVT_BBU_START+0x1c), +}; + +enum MgrEvtConfigCode { + MGR_EVT_CONFIG_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CONFIG_LOCAL), + MGR_EVT_CONFIG_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x1), + MGR_EVT_CONFIG_FLASH_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x2), + MGR_EVT_CONFIG_FLASH_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x3), + MGR_EVT_CONFIG_NVSRAM_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x4), + MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x5), + MGR_EVT_CONFIG_VERSION_MISMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x6), + MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x7), + MGR_EVT_CONFIG_ERASE_NVSRAM = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x8), + MGR_EVT_PHY_LINKSPEED_CFG_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_CONFIG_START + 0x9), + MGR_EVT_CONFIG_END = (MGR_EVT_CONFIG_START+0xa), +}; + +enum MgrEvtIoInfoCode { + MGR_EVT_IO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_IO_INFO_LOCAL), + MGR_EVT_IO_TEST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x1), + MGR_EVT_IO_SENSE_DATA = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x2), + MGR_EVT_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x3), + MGR_EVT_NVME_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x4), + MGR_EVT_DEVICE_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x5), + MGR_EVT_IO_SENSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_IO_START + 0x6), + MGR_EVT_IO_END = (MGR_EVT_IO_START+0x7), +}; + +enum MgrEvtUkeyInfoCode { + MGR_EVT_UKEY_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UKEY_INFO_LOCAL), + MGR_EVT_UKEY_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UKEY_START + 0x1), + MGR_EVT_UKEY_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UKEY_START + 0x2), + MGR_EVT_RAID_KEY_OVERCURRENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_UKEY_START + 0x3), + MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UKEY_START + 0x4), + MGR_EVT_UKEY_END = (MGR_EVT_UKEY_START+0x5), +}; + +enum MgrEvtHwRInfoCode { + MGR_EVT_HWR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_HWR_INFO_LOCAL), + MGR_EVT_HWR_HAC_RESET_BEGIN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_HWR_START + 0x1), + MGR_EVT_HWR_HAC_RESET_END = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_HWR_START + 0x2), + MGR_EVT_REPORT_HAC_ECC = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_HWR_START + 0x3), + MGR_EVT_HWR_END = (MGR_EVT_HWR_START+0x4), +}; + +enum MgrEvtAlarmInfoCode { + MGR_EVT_ALARM_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ALARM_INFO_LOCAL), + MGR_EVT_ALARM_ENABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_ALARM_START + 0x1), + MGR_EVT_ALARM_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_ALARM_START + 0x2), + MGR_EVT_ALARM_END = (MGR_EVT_ALARM_START+0x3), +}; + +enum MgrEvtEccInfoCode { + MGR_EVT_ECC_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ECC_INFO_LOCAL), + MGR_EVT_ECC_CNT_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_ECC_START + 0x1), + MGR_EVT_ECC_ERR_INTR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_ECC_START + 0x2), + MGR_EVT_ECC_CNT_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_ECC_START + 0x3), + MGR_EVT_ECC_CLI_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_ECC_START + 0x4), + MGR_EVT_ECC_FACTORY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_ECC_START + 0x5), + MGR_EVT_ECC_END = (MGR_EVT_ECC_START+0x6), +}; + +enum MgrEvtUpgradeInfoCode { + MGR_EVT_UPGRADE_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UPGRADE_INFO_LOCAL), + MGR_EVT_IMAGE_DOWNLOAD_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x1), + MGR_EVT_IMAGE_AUTHENTICATION_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x2), + MGR_EVT_IMAGE_VERSION_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x3), + MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x4), + MGR_EVT_IMAGE_FROM_BACKUP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_UPGRADE_START + 0x5), + MGR_EVT_DEV_OPEN_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x6), + MGR_EVT_DEV_FLASH_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x7), + MGR_EVT_DEV_ERASE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x8), + MGR_EVT_DEV_CLOSE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0x9), + MGR_EVT_FLASH_GENERAL_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0xa), + MGR_EVT_FLASH_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_UPGRADE_START + 0xb), + MGR_EVT_UPGRADE_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UPGRADE_START + 0xc), + MGR_EVT_UPGRADE_SYNC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UPGRADE_START + 0xd), + MGR_EVT_UPGRADE_SYNC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UPGRADE_START + 0xe), + MGR_EVT_UPGRADE_SYNC_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_UPGRADE_START + 0xf), + MGR_EVT_UPGRADE_END = (MGR_EVT_UPGRADE_START+0x10), +}; + +enum MgrEvtTempInfoCode { + MGR_EVT_TEMP_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_TEMP_INFO_LOCAL), + MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_TEMP_START + 0x1), + MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_TEMP_START + 0x2), + MGR_EVT_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_TEMP_START + 0x3), + MGR_EVT_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_TEMP_START + 0x4), + MGR_EVT_TEMP_END = (MGR_EVT_TEMP_START+0x5), +}; + +enum MgrEvtPdAttrExtendCode { + MGR_EVT_PD_ATTR_EXTEND_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_EXTEND_LOCAL), + MGR_EVT_PD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1), + MGR_EVT_PD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2), + MGR_EVT_PD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3), + MGR_EVT_PD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_EXTEND_START + 0x4), + MGR_EVT_PD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x5), + MGR_EVT_PD_PDM_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x6), + MGR_EVT_PD_PDM_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x7), + MGR_EVT_PD_PDM_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x8), + MGR_EVT_PD_PDM_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x9), + MGR_EVT_PD_PDM_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0xa), + MGR_EVT_PD_PDM_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0xb), + MGR_EVT_PD_PDM_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0xc), + MGR_EVT_PD_PDM_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_EXTEND_START + 0xd), + MGR_EVT_PD_PDM_REPLACED_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0xe), + MGR_EVT_PD_PDM_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0xf), + MGR_EVT_PD_PDM_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x10), + MGR_EVT_PD_PDM_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x11), + MGR_EVT_PD_PDM_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x12), + MGR_EVT_PD_PDM_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x13), + MGR_EVT_PD_PFA_ERROR_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x14), + MGR_EVT_PD_SANITIZE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x15), + MGR_EVT_PD_FORMAT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x16), + MGR_EVT_PD_SANITIZE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, + MGR_EVT_PD_ATTR_EXTEND_START + 0x17), + MGR_EVT_PD_SANITIZE_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x18), + MGR_EVT_PD_FORMAT_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x19), + MGR_EVT_PD_DPF_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1a), + MGR_EVT_PD_MARKED_SHIELD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1b), + MGR_EVT_PD_BBM_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1c), + MGR_EVT_PD_BBM_UNRECOVERABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1d), + MGR_EVT_PD_BBM_PUNCTURING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1e), + MGR_EVT_PD_BBM_REASSIGN_WR_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x1f), + MGR_EVT_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x20), + MGR_EVT_MULITPILE_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x21), + MGR_EVT_PD_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x22), + MGR_EVT_PHY_SATA_D2H_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x23), + MGR_EVT_PD_NOT_INSERTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x24), + MGR_EVT_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x25), + MGR_EVT_MULITPILE_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_TRUE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x26), + MGR_EVT_NVDATA_INVALID = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x27), + MGR_EVT_PD_RBLD_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x28), + MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x29), + MGR_EVT_PD_PDM_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2a), + MGR_EVT_PD_RBLD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2b), + MGR_EVT_PD_SANITIZE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2c), + MGR_EVT_PD_SPIN_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2d), + MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2e), + MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x2f), + MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x30), + MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x31), + MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x32), + MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x33), + MGR_EVT_NFR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x34), + MGR_EVT_PD_RBLD_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x35), + MGR_EVT_PD_MOVEBACK_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x36), + MGR_EVT_NEGO_LOWER_LINK_SPEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x37), + MGR_EVT_PD_NVME_CMD_ERR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x38), + MGR_EVT_PD_NVME_CMD_TO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x39), + MGR_EVT_PD_NVME_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3a), + MGR_EVT_PCIE_LINK_NEGO_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3b), + MGR_EVT_PD_ISOLATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3c), + MGR_EVT_PD_REPAIR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3d), + MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3e), + MGR_EVT_PD_PCIE_ENUMERATE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_EXTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, + MGR_EVT_PD_ATTR_EXTEND_START + 0x3f), + MGR_EVT_PD_MISS_LIGHTING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, + PS3_EVT_EXP_INTERNAL, PS3_EVT_IS_BATCH_FALSE, + PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, + MGR_EVT_PD_ATTR_EXTEND_START + 0x40), + MGR_EVT_PD_ATTR_EXTEND_END = (MGR_EVT_PD_ATTR_EXTEND_START+0x41), +}; + +static inline unsigned int ps3EvtCodeExtendToNormal(unsigned int evtcode) +{ + unsigned int event = 0; + + switch (evtcode) { + case PS3_EVT_PD_ATTR_EXTEND_LOCAL: + event = PS3_EVT_PD_ATTR_LOCAL; + break; + default: + event = evtcode; + break; + } + return event; +} + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h new file mode 100644 index 000000000000..b7a0c80e4234 --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_nvme_spec.h @@ -0,0 +1,190 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __PS3_HTP_NVME_SPEC_H__ +#define __PS3_HTP_NVME_SPEC_H__ + + +enum NvmeGenCmdSC { + NVME_SC_SUCCESS = 0x00, + NVME_SC_INVALID_OPCODE = 0x01, + NVME_SC_INVALID_FIELD = 0x02, + NVME_SC_COMMAND_ID_CONFLICT = 0x03, + NVME_SC_DATA_TRANSFER_ERROR = 0x04, + NVME_SC_ABORTED_POWER_LOSS = 0x05, + NVME_SC_INTERNAL_DEVICE_ERROR = 0x06, + NVME_SC_ABORTED_BY_REQUEST = 0x07, + NVME_SC_ABORTED_SQ_DELETION = 0x08, + NVME_SC_ABORTED_FAILED_FUSED = 0x09, + NVME_SC_ABORTED_MISSING_FUSED = 0x0a, + NVME_SC_INVALID_NAMESPACE_OR_FORMAT = 0x0b, + NVME_SC_COMMAND_SEQUENCE_ERROR = 0x0c, + NVME_SC_INVALID_SGL_SEG_DESCRIPTOR = 0x0d, + NVME_SC_INVALID_NUM_SGL_DESCIRPTORS = 0x0e, + NVME_SC_DATA_SGL_LENGTH_INVALID = 0x0f, + NVME_SC_METADATA_SGL_LENGTH_INVALID = 0x10, + NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID = 0x11, + NVME_SC_INVALID_CONTROLLER_MEM_BUF = 0x12, + NVME_SC_INVALID_PRP_OFFSET = 0x13, + NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED = 0x14, + NVME_SC_OPERATION_DENIED = 0x15, + NVME_SC_INVALID_SGL_OFFSET = 0x16, + + NVME_SC_HOSTID_INCONSISTENT_FORMAT = 0x18, + NVME_SC_KEEP_ALIVE_EXPIRED = 0x19, + NVME_SC_KEEP_ALIVE_INVALID = 0x1a, + NVME_SC_ABORTED_PREEMPT = 0x1b, + NVME_SC_SANITIZE_FAILED = 0x1c, + NVME_SC_SANITIZE_IN_PROGRESS = 0x1d, + NVME_SC_SGL_DATA_BLOCK_GRANULARITY_INVALID = 0x1e, + NVME_SC_COMMAND_INVALID_IN_CMB = 0x1f, + NVME_SC_NAMESPACE_IS_WRITE_PROTECTED = 0x20, + NVME_SC_COMMAND_INTERRUPTED = 0x21, + NVME_SC_TRANSIENT_TRANSPORT_ERROR = 0x22, + + NVME_SC_LBA_OUT_OF_RANGE = 0x80, + NVME_SC_CAPACITY_EXCEEDED = 0x81, + NVME_SC_NAMESPACE_NOT_READY = 0x82, + NVME_SC_RESERVATION_CONFLICT = 0x83, + NVME_SC_FORMAT_IN_PROGRESS = 0x84, +}; + + +enum NvmeCmdSpecSC { + NVME_CSC_COMPLETION_QUEUE_INVALID = 0x00, + NVME_CSC_INVALID_QUEUE_IDENTIFIER = 0x01, + NVME_CSC_MAXIMUM_QUEUE_SIZE_EXCEEDED = 0x02, + NVME_CSC_ABORT_COMMAND_LIMIT_EXCEEDED = 0x03, + + NVME_CSC_ASYNC_EVENT_REQUEST_LIMIT_EXCEEDED = 0x05, + NVME_CSC_INVALID_FIRMWARE_SLOT = 0x06, + NVME_CSC_INVALID_FIRMWARE_IMAGE = 0x07, + NVME_CSC_INVALID_INTERRUPT_VECTOR = 0x08, + NVME_CSC_INVALID_LOG_PAGE = 0x09, + NVME_CSC_INVALID_FORMAT = 0x0a, + NVME_CSC_FIRMWARE_REQ_CONVENTIONAL_RESET = 0x0b, + NVME_CSC_INVALID_QUEUE_DELETION = 0x0c, + NVME_CSC_FEATURE_ID_NOT_SAVEABLE = 0x0d, + NVME_CSC_FEATURE_NOT_CHANGEABLE = 0x0e, + NVME_CSC_FEATURE_NOT_NAMESPACE_SPECIFIC = 0x0f, + NVME_CSC_FIRMWARE_REQ_NVM_RESET = 0x10, + NVME_CSC_FIRMWARE_REQ_RESET = 0x11, + NVME_CSC_FIRMWARE_REQ_MAX_TIME_VIOLATION = 0x12, + NVME_CSC_FIRMWARE_ACTIVATION_PROHIBITED = 0x13, + NVME_CSC_OVERLAPPING_RANGE = 0x14, + NVME_CSC_NAMESPACE_INSUFFICIENT_CAPACITY = 0x15, + NVME_CSC_NAMESPACE_ID_UNAVAILABLE = 0x16, + + NVME_CSC_NAMESPACE_ALREADY_ATTACHED = 0x18, + NVME_CSC_NAMESPACE_IS_PRIVATE = 0x19, + NVME_CSC_NAMESPACE_NOT_ATTACHED = 0x1a, + NVME_CSC_THINPROVISIONING_NOT_SUPPORTED = 0x1b, + NVME_CSC_CONTROLLER_LIST_INVALID = 0x1c, + NVME_CSC_DEVICE_SELF_TEST_IN_PROGRESS = 0x1d, + NVME_CSC_BOOT_PARTITION_WRITE_PROHIBITED = 0x1e, + NVME_CSC_INVALID_CTRLR_ID = 0x1f, + NVME_CSC_INVALID_SECONDARY_CTRLR_STATE = 0x20, + NVME_CSC_INVALID_NUM_CTRLR_RESOURCES = 0x21, + NVME_CSC_INVALID_RESOURCE_ID = 0x22, + + NVME_CSC_CONFLICTING_ATTRIBUTES = 0x80, + NVME_CSC_INVALID_PROTECTION_INFO = 0x81, + NVME_CSC_ATTEMPTED_WRITE_TO_RO_RANGE = 0x82, +}; + + +enum NvmeMediaErrSC { + NVME_MSC_WRITE_FAULTS = 0x80, + NVME_MSC_UNRECOVERED_READ_ERROR = 0x81, + NVME_MSC_GUARD_CHECK_ERROR = 0x82, + NVME_MSC_APPLICATION_TAG_CHECK_ERROR = 0x83, + NVME_MSC_REFERENCE_TAG_CHECK_ERROR = 0x84, + NVME_MSC_COMPARE_FAILURE = 0x85, + NVME_MSC_ACCESS_DENIED = 0x86, + NVME_MSC_DEALLOCATED_OR_UNWRITTEN_BLOCK = 0x87, +}; + +enum NvmeStatusCodes { + NVME_SUCCESS = 0x0000, + NVME_INVALID_OPCODE = 0x0001, + NVME_INVALID_FIELD = 0x0002, + NVME_CID_CONFLICT = 0x0003, + NVME_DATA_TRAS_ERROR = 0x0004, + NVME_POWER_LOSS_ABORT = 0x0005, + NVME_INTERNAL_DEV_ERROR = 0x0006, + NVME_CMD_ABORT_REQ = 0x0007, + NVME_CMD_ABORT_SQ_DEL = 0x0008, + NVME_CMD_ABORT_FAILED_FUSE = 0x0009, + NVME_CMD_ABORT_MISSING_FUSE = 0x000a, + NVME_INVALID_NSID = 0x000b, + NVME_CMD_SEQ_ERROR = 0x000c, + NVME_INVALID_SGL_SEG_DESCR = 0x000d, + NVME_INVALID_NUM_SGL_DESCRS = 0x000e, + NVME_DATA_SGL_LEN_INVALID = 0x000f, + NVME_MD_SGL_LEN_INVALID = 0x0010, + NVME_SGL_DESCR_TYPE_INVALID = 0x0011, + NVME_INVALID_USE_OF_CMB = 0x0012, + NVME_INVALID_PRP_OFFSET = 0x0013, + NVME_CMD_SET_CMB_REJECTED = 0x002b, + NVME_INVALID_CMD_SET = 0x002c, + NVME_LBA_RANGE = 0x0080, + NVME_CAP_EXCEEDED = 0x0081, + NVME_NS_NOT_READY = 0x0082, + NVME_NS_RESV_CONFLICT = 0x0083, + NVME_FORMAT_IN_PROGRESS = 0x0084, + NVME_INVALID_CQID = 0x0100, + NVME_INVALID_QID = 0x0101, + NVME_MAX_QSIZE_EXCEEDED = 0x0102, + NVME_ACL_EXCEEDED = 0x0103, + NVME_RESERVED = 0x0104, + NVME_AER_LIMIT_EXCEEDED = 0x0105, + NVME_INVALID_FW_SLOT = 0x0106, + NVME_INVALID_FW_IMAGE = 0x0107, + NVME_INVALID_IRQ_VECTOR = 0x0108, + NVME_INVALID_LOG_ID = 0x0109, + NVME_INVALID_FORMAT = 0x010a, + NVME_FW_REQ_RESET = 0x010b, + NVME_INVALID_QUEUE_DEL = 0x010c, + NVME_FID_NOT_SAVEABLE = 0x010d, + NVME_FEAT_NOT_CHANGEABLE = 0x010e, + NVME_FEAT_NOT_NS_SPEC = 0x010f, + NVME_FW_REQ_SUSYSTEM_RESET = 0x0110, + NVME_NS_ALREADY_ATTACHED = 0x0118, + NVME_NS_PRIVATE = 0x0119, + NVME_NS_NOT_ATTACHED = 0x011A, + NVME_NS_CTRL_LIST_INVALID = 0x011C, + NVME_CONFLICTING_ATTRS = 0x0180, + NVME_INVALID_PROT_INFO = 0x0181, + NVME_WRITE_TO_RO = 0x0182, + NVME_CMD_SIZE_LIMIT = 0x0183, + NVME_ZONE_BOUNDARY_ERROR = 0x01b8, + NVME_ZONE_FULL = 0x01b9, + NVME_ZONE_READ_ONLY = 0x01ba, + NVME_ZONE_OFFLINE = 0x01bb, + NVME_ZONE_INVALID_WRITE = 0x01bc, + NVME_ZONE_TOO_MANY_ACTIVE = 0x01bd, + NVME_ZONE_TOO_MANY_OPEN = 0x01be, + NVME_ZONE_INVAL_TRANSITION = 0x01bf, + NVME_WRITE_FAULT = 0x0280, + NVME_UNRECOVERED_READ = 0x0281, + NVME_E2E_GUARD_ERROR = 0x0282, + NVME_E2E_APP_ERROR = 0x0283, + NVME_E2E_REF_ERROR = 0x0284, + NVME_CMP_FAILURE = 0x0285, + NVME_ACCESS_DENIED = 0x0286, + NVME_DULB = 0x0287, + NVME_MORE = 0x2000, + NVME_DNR = 0x4000, + NVME_NO_COMPLETE = 0xffff, +}; + + +enum NvmeStatusCodeType { + NVME_SCT_GENERIC = 0x0, + NVME_SCT_COMMAND_SPECIFIC = 0x1, + NVME_SCT_MEDIA_ERROR = 0x2, + NVME_SCT_PATH = 0x3, + + NVME_SCT_VENDOR_SPECIFIC = 0x7, +}; + +#endif + diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_register_fifo.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h similarity index 38% rename from drivers/scsi/linkdata/ps3stor/include/ps3_register_fifo.h rename to drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h index 3a1336af889a..0bd90bfe288e 100644 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_register_fifo.h +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_register_fifo.h @@ -1,6 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __PS3_REGISTER_FIFO_H__ -#define __PS3_REGISTER_FIFO_H__ +#ifndef __PS3_HTP_REGISTER_FIFO_H__ +#define __PS3_HTP_REGISTER_FIFO_H__ #include "hwapi/include_v200/s1861_regs/s1861_global_baseaddr.h" #include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_request_queue_reg.h" @@ -10,26 +11,27 @@ #ifdef __cplusplus extern "C" { #endif -typedef union ps3RequestFifo { - U8 reserved0[HIL_REG0_PS3_REQUEST_QUEUE_SIZE]; - HilReg0Ps3RequestQueue_s request_fifo; -} ps3RequestFifo_u; - -typedef union ps3RegShare{ - U8 reserved0[HIL_REG0_PS3_REGISTER_S_SIZE]; - HilReg0Ps3RegisterS_s share_reg; -} ps3RegShare_u; - -typedef union ps3RegExclusive{ - U8 reserved0[HIL_REG0_PS3_REGISTER_F_SIZE]; - HilReg0Ps3RegisterF_s Excl_reg; -} ps3RegExclusive_u; - -typedef struct Ps3Fifo{ - ps3RegExclusive_u reg_f; - ps3RequestFifo_u cmd_fifo; - ps3RegShare_u reg_s; -} Ps3Fifo_s; + +union ps3RequestFifo { + unsigned char reserved0[HIL_REG0_PS3_REQUEST_QUEUE_SIZE]; + struct HilReg0Ps3RequestQueue request_fifo; +}; + +union ps3RegShare { + unsigned char reserved0[HIL_REG0_PS3_REGISTER_S_SIZE]; + struct HilReg0Ps3RegisterS share_reg; +}; + +union ps3RegExclusive { + unsigned char reserved0[HIL_REG0_PS3_REGISTER_F_SIZE]; + struct HilReg0Ps3RegisterF Excl_reg; +}; + +struct Ps3Fifo { + union ps3RegExclusive reg_f; + union ps3RequestFifo cmd_fifo; + union ps3RegShare reg_s; +}; #ifdef __cplusplus } diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h new file mode 100644 index 000000000000..2520a93bc6b3 --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_htp_trace_id.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __PS3_HTP_TRACE_ID_H__ +#define __PS3_HTP_TRACE_ID_H__ + +#define TRACE_ID_CHIP_OUT_COUNT_MASK 0x000FFFFFFFFFFFFFLLU + +#define TRACE_ID_CHIP_OUT_CPUID_SHIFT 52 +#define TRACE_ID_CHIP_OUT_CPUID_MASK 0x7FFLLU + +static inline void traceIdCpuIdSet(unsigned long long *traceId, + unsigned short cpuId) +{ + *traceId &= ~(TRACE_ID_CHIP_OUT_CPUID_MASK + << TRACE_ID_CHIP_OUT_CPUID_SHIFT); + *traceId |= ((unsigned long long)cpuId & TRACE_ID_CHIP_OUT_CPUID_MASK) + << TRACE_ID_CHIP_OUT_CPUID_SHIFT; +} + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_meta.h b/drivers/scsi/linkdata/ps3stor/include/ps3_meta.h deleted file mode 100644 index d49d813ab3e4..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_meta.h +++ /dev/null @@ -1,166 +0,0 @@ - -#ifndef __PS3_META_H__ -#define __PS3_META_H__ - - -typedef enum MicPdState { - MIC_PD_STATE_UNKNOWN = 0, - MIC_PD_STATE_READY = 1, - MIC_PD_STATE_UBAD = 2, - MIC_PD_STATE_DSPARE = 3, - MIC_PD_STATE_GSPARE = 4, - MIC_PD_STATE_OFFLINE = 5, - MIC_PD_STATE_ONLINE = 6, - MIC_PD_STATE_MISSING = 7, - MIC_PD_STATE_FAILED = 8, - MIC_PD_STATE_REBUILD = 9, - MIC_PD_STATE_REPLACE = 10, - MIC_PD_STATE_FOREIGN = 11, - MIC_PD_STATE_JBOD = 12, - MIC_PD_STATE_UNSUPPORT = 13, - MIC_PD_STATE_PDM = 14, - MIC_PD_STATE_CFSHLD = 15, - MIC_PD_STATE_HSPSHLD = 16, - MIC_PD_STATE_RUNSP = 17, - MIC_PD_STATE_UBUNSP = 18, - MIC_PD_STATE_MAX -}MicPdState_e; - - -typedef enum PhyProtoType { - PHY_PROTO_SAS_SATA, - PHY_PROTO_PCIE, - PHY_PROTO_BOTTOM, -}PhyProtoType_e; - - -static inline const char *getPdStateName(MicPdState_e pdSate, unsigned char isRaid) -{ - static const char *raidPdName[] = { - [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_PD_STATE_READY] = "UGOOD", - [MIC_PD_STATE_UBAD] = "UBAD", - [MIC_PD_STATE_DSPARE] = "DSPARE", - [MIC_PD_STATE_GSPARE] = "GSPARE", - [MIC_PD_STATE_OFFLINE] = "OFFLINE", - [MIC_PD_STATE_ONLINE] = "ONLINE", - [MIC_PD_STATE_MISSING] = "MISSING", - [MIC_PD_STATE_FAILED] = "FAILED", - [MIC_PD_STATE_REBUILD] = "REBUILD", - [MIC_PD_STATE_REPLACE] = "REPLACE", - [MIC_PD_STATE_FOREIGN] = "FOREIGN", - [MIC_PD_STATE_JBOD] = "JBOD", - [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", - [MIC_PD_STATE_PDM] = "PDM", - [MIC_PD_STATE_CFSHLD] = "CFSHLD", - [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", - [MIC_PD_STATE_RUNSP] = "UGUNSP", - [MIC_PD_STATE_UBUNSP] = "UBUNSP", - }; - - static const char *hbaPdName[] = { - [MIC_PD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_PD_STATE_READY] = "READY", - [MIC_PD_STATE_UBAD] = "UBAD", - [MIC_PD_STATE_DSPARE] = "DSPARE", - [MIC_PD_STATE_GSPARE] = "GSPARE", - [MIC_PD_STATE_OFFLINE] = "OFFLINE", - [MIC_PD_STATE_ONLINE] = "ONLINE", - [MIC_PD_STATE_MISSING] = "MISSING", - [MIC_PD_STATE_FAILED] = "FAILED", - [MIC_PD_STATE_REBUILD] = "REBUILD", - [MIC_PD_STATE_REPLACE] = "REPLACE", - [MIC_PD_STATE_FOREIGN] = "FOREIGN", - [MIC_PD_STATE_JBOD] = "JBOD", - [MIC_PD_STATE_UNSUPPORT] = "UNSUPPORT", - [MIC_PD_STATE_PDM] = "PDM", - [MIC_PD_STATE_CFSHLD] = "CFSHLD", - [MIC_PD_STATE_HSPSHLD] = "HSPSHLD", - [MIC_PD_STATE_RUNSP] = "RUNSP", - [MIC_PD_STATE_UBUNSP] = "UBUNSP", - }; - - if (isRaid) { - return raidPdName[pdSate]; - } else { - return hbaPdName[pdSate]; - } -} - - -typedef enum MicVdState { - MIC_VD_STATE_UNKNOWN = 0, - MIC_VD_STATE_OFFLINE, - MIC_VD_STATE_OPTIMAL, - MIC_VD_STATE_PARTIAL_DEGRADE, - MIC_VD_STATE_DEGRADE -}MicVdState_e; - - -typedef enum InquiryFailReason { - INSERT_INQUIRY_ERR = 0, - INSERT_TUR_ERR = 1, -}InquiryFailReason_e; - - -typedef enum pdUnspReason { - PD_UNSP_EXCEED_MAX_SIZE = 0, - PD_UNSP_EXCEED_MAX_NUM = 1, - PD_UNSP_TUR_ERR, - PD_UNSP_SANITIZE, - PD_UNSP_INQUIRY_FAIL, - PD_UNSP_RESET_FAIL, -}pdUnspReason_e; - -static inline const char *getVdStateName(MicVdState_e vdSate) -{ - static const char *vdStateName[] = { - [MIC_VD_STATE_UNKNOWN] = "UNKNOWN", - [MIC_VD_STATE_OFFLINE] = "OFFLINE", - [MIC_VD_STATE_OPTIMAL] = "OPTIMAL", - [MIC_VD_STATE_PARTIAL_DEGRADE] = "PARTIALLY DEGRADED", - [MIC_VD_STATE_DEGRADE] = "DEGRADED" - }; - - return vdStateName[vdSate]; -} - -static inline const char *triModeNameGet(PhyProtoType_e protoType) -{ - static const char *protoTypeName[] = { - [PHY_PROTO_SAS_SATA] = "SAS/SATA", - [PHY_PROTO_PCIE] = "PCIe", - [PHY_PROTO_BOTTOM] = "DEFAULT", - }; - return protoTypeName[protoType]; -} - - -typedef enum RaidLevel { - RAID0 = 0x00, - RAID1 = 0x01, - RAID5 = 0x05, - RAID6 = 0x06, - JBOD = 0x0A, - RAID10 = 0x10, - RAID1E = 0x11, - RAID00 = 0x20, - RAID50 = 0x50, - RAID60 = 0x60, - RAID_UNKNOWN = 0xFF -}RaidLevel_e; - -typedef enum VDAccessPolicy { - VD_ACCESS_POLICY_READ_WRITE = 0, - VD_ACCESS_POLICY_READ_ONLY, - VD_ACCESS_POLICY_BLOCK, - VD_ACCESS_POLICY_REMOVE_ACCESS -} VDAccessPolicy_e; - - -typedef enum VDBgt { - VD_BGT_IDLE_READY = 0, - VD_BGT_FULL_INIT = 1, -} VDBgt_e; - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt.h b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt.h deleted file mode 100644 index 4bf433df4351..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef __PS3_MGR_EVT__ -#define __PS3_MGR_EVT__ - -#include "ps3_mgr_evt_raidhba.h" -#include "ps3_mgr_evt_swexp.h" -#include "ps3lib/ps3lib_event.h" - - -#pragma pack(1) - -#if (defined(PS3_PRODUCT_EXPANDER) || defined(PS3_PRODUCT_SWITCH)) -#define PS3_EVT_ATTR(evtcode) (PS3_EVT_ATTR_EXTEND(evtcode)) -#else -#define PS3_EVT_ATTR(evtcode) (ps3EvtCodeExtendToNormal(PS3_EVT_ATTR_EXTEND(evtcode))) -#endif - - -typedef Ps3LibPdAttrInfo_s MgrPdAttrInfo_s; - -typedef Ps3LibPdPreFailInfo_s MgrPdPreFailInfo_s; - -typedef Ps3LibSparePdInfo_s MgrSparePdInfo_s; - -typedef Ps3LibVdAttrInfo_s MgrVdAttrInfo_s; - -typedef Ps3LibDiskPFCfgModifyEvtInfo_s MgrDiskPFCfgModifyEvtInfo_s; - - -#define MAX_VD_NAME_BYTES (16) -typedef Ps3LibVdBaseSetting_s MgrVdBaseSetting_s; - -typedef Ps3LibVdPropertiesInfo_s MgrVdPropertiesInfo_s; - -typedef Ps3LibVdStateChangeInfo_s MgrVdStateChangeInfo_s; - -typedef Ps3LibVdCreateEvtInfo_s MgrVdCreateInfo_s; - -typedef Ps3LibDgAttrInfo_s MgrDgAttrInfo_s; - -typedef Ps3LibExpanderInfo_s MgrExpanderInfo_s; - -enum { - MGR_EVT_FUNCTION0 = 0, - MGR_EVT_FUNCTION1 = 1, - MGR_EVT_FUNCTION_COMMON = 250, -}; - -typedef Ps3LibCtrlAttrInfo_s MgrCtrlAttrInfo_s; - - -typedef Ps3LibCtrlRebootInfo_s MgrCtrlRebootInfo_s; - - -typedef Ps3LibPdBatchEvtInfo_s MgrPdBatchEvtInfo_s; - - -typedef Ps3LibVdBatchEvtInfo_s MgrVdBatchEvtInfo_s; - - -typedef Ps3LibVdBbmBatchEvtInfo_s MgrVdBbmBatchEvtInfo_s; - - -typedef Ps3LibCtrlBatchEvtInfo_s MgrCtrlBatchEvtInfo_s; - - -typedef Ps3LibCfgAttrInfo_s MgrCfgAttrInfo_s; -#define MGR_CTRL_AUTOCONFIG_EVTDATA_SIZE PS3LIB_CTRL_AUTOCONFIG_EVTDATA_SIZE -typedef Ps3LibCfgAutoConfig_s MgrCfgAutoConfig_s; - - -typedef Ps3LibBgtRebuildInfo_s MgrBgtRebuildInfo_s; - - -#define FGI_MODE_LEN PS3LIB_FGI_MODE_LEN -typedef Ps3LibBgtInitEvtInfo_s MgrBgtInitEvtInfo_s; - - -typedef Ps3LibBgtEraseEvtInfo_s MgrBgtEraseEvtInfo_s; - - -typedef Ps3LibPhyEvtInfo_s MgrPhyEvtInfo_s; - -#define BBM_ERRTBL_NAME_LEN PS3LIB_BBM_ERRTBL_NAME_LEN - -typedef Ps3LibVdBbmEvtInfo_s MgrVdBbmEvtInfo_s; - -typedef Ps3LibRwDdtEvtInfo_s MgrRwDdtEvtInfo_s; - -typedef Ps3LibFlushEvtInfo_s MgrFlushEvtInfo_s; - -typedef Ps3LibBgtCcEvtInfo_s MgrBgtCcEvtInfo_s; - -typedef Ps3LibBgtPrEvtInfo_s MgrBgtPrEvtInfo_s; - - -typedef Ps3LibBbuEvtInfo_s MgrBbuEvtInfo_s; - -typedef Ps3LibMigrationInfo_s MgrMigrationInfo_s; - - -typedef Ps3LibUkeyEvtInfo_s MgrUkeyEvtInfo_s; - - -typedef Ps3LibExpEvtInfo_s MgrExpEvtInfo_s; - - -typedef Ps3LibOemInfo_s MgrOemInfo_s; - - -typedef Ps3LibBplaneEvtInfo_s BplaneEvtInfo_s; - -typedef Ps3LibEccEvtInfo_s MgrEccEvtInfo_s; - - -typedef Ps3LibTempEvtInfo_s MgrTempEvtInfo_s; - -typedef Ps3LibIoCmdType_s IoCmdType_s; - - -typedef Ps3LibSenseDataEvtInfo_s MgrSenseDataEvtInfo_s; -typedef Ps3LibErrSenseEvtInfo_s MgrErrSenseEvtInfo_s; - -typedef Ps3LibPdDownloadInfo_s MgrPdDownloadInfo_s; - -typedef Ps3LibSanitizeEvtInfo_s MgrSanitizeEvtInfo_s; - -typedef Ps3LibFormatEvtInfo_s MgrFormatEvtInfo_s; - -typedef Ps3LibSnapshotEvtInfo_s MgrSnapshotEvtInfo_s; - -typedef Ps3LibReportEvtData_u MgrReportEvtData_u; - -typedef enum Ps3HardResetEvtMoudle -{ - HARD_RESET_BY_HOST = 0, - HARD_RESET_BY_BACKEND, - HARD_RESET_BY_FRONTEND, -} Ps3HardResetEvtMoudle_e; - -typedef enum SporStatus { - SPOR_DUMP_SUCCESS, - SPOR_DUMP_RUNNING, - SPOR_DUMP_NVSRAM_INIT_FAILED, - SPOR_DUMP_NVSRAM_WR_FAILED, - SPOR_DUMP_ONF_INIT_FAILED, - SPOR_DUMP_MM_INIT_FAILED, - SPOR_DUMP_CM_INIT_FAILED, - SPOR_DUMP_FAILED, - SPOR_LOAD_SUCCESS, - SPOR_LOAD_NVSRAM_INIT_FAILED, - SPOR_LOAD_NVSRAM_WR_FAILED, - SPOR_LOAD_ONF_INIT_FAILED, - SPOR_LOAD_MM_INIT_FAILED, - SPOR_LOAD_CM_INIT_FAILED, - SPOR_LOAD_FAILED, - SPOR_STATUS_NULL = 0xFF, -}SporStatus_e; - -#pragma pack() - - -typedef enum MgrEventModule -{ - PS3_EVT_HOST_DRV_X2 = 1, - PS3_EVT_HOST_DRV_X16, - PS3_EVT_HOST_DRV_VD_X2, - PS3_EVT_HOST_DRV_VD_X16, - PS3_EVT_METDATA, - PS3_EVT_DEV_MANAGE, - PS3_EVT_IOC_ALARM_PWM, - PS3_EVT_IOC_ALARM_LED, - PS3_EVT_IOC_ALARM, - PS3_EVT_IOC_MGR, - PS3_EVT_HOST_SIM, - PS3_EVT_HOST_SIM_X2, - PS3_EVT_HOST_SIM_X16, - PS3_EVT_MODULE_MAX, -}MgrEventModule_e; - -typedef struct PS3EventFilter -{ - U8 eventType; - U8 eventCodeCnt; - U8 reserved[6]; - U16 eventCodeTable[0]; -}PS3EventFilter_s; - -typedef void (* eventNoticeCb)(void *pCtxt); - -typedef S32 (* mgrEventNoticeFunc)(U32 eventCode, MgrReportEvtData_u *pEventDesc, - void *pCtxt, eventNoticeCb noticeCountOp); -typedef void (* eventPublishCb)(void *pPublishInfo); - -S32 mgrEvtCancleSubscribe(U8 moduleId); - -S32 mgrDrvEvtWebSubsCancel(U8 funcType); - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h index 088f73210a57..b2e151a956ac 100644 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h +++ b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_common.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PS3_MGR_EVT_COMMON_H__ #define __PS3_MGR_EVT_COMMON_H__ @@ -9,20 +10,22 @@ #define MGR_EVT_EXTEND_TYPE_START (17) -#define MGR_EVT_TYPE_BASE_LOCAL(sn) (sn < MGR_EVT_EXTEND_TYPE_START ? (sn - 1) * MGR_EVT_TYPE_OFFSET : \ - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) \ - + MGR_EVT_TYPE_EXTEND_OFFSET * (sn - MGR_EVT_EXTEND_TYPE_START)) +#define MGR_EVT_TYPE_BASE_LOCAL(sn) (sn < MGR_EVT_EXTEND_TYPE_START ? \ + (sn - 1) * MGR_EVT_TYPE_OFFSET : \ + MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) \ + + MGR_EVT_TYPE_EXTEND_OFFSET * (sn - MGR_EVT_EXTEND_TYPE_START)) -#define MGR_EVENT_CODE_2_TYPE(code) (code <= MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) ? \ - ((code) / MGR_EVT_TYPE_OFFSET + 1) : \ - (code - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1)) / MGR_EVT_TYPE_EXTEND_OFFSET \ - + MGR_EVT_EXTEND_TYPE_START) +#define MGR_EVENT_CODE_2_TYPE(code) \ + (code <= MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1) ? \ + ((code) / MGR_EVT_TYPE_OFFSET + 1) : \ + (code - MGR_EVT_TYPE_OFFSET * (MGR_EVT_EXTEND_TYPE_START - 1)) / \ + MGR_EVT_TYPE_EXTEND_OFFSET + MGR_EVT_EXTEND_TYPE_START) #else -#define MGR_EVT_TYPE_BASE_LOCAL(sn) ((sn - 1) * MGR_EVT_TYPE_OFFSET) -#define MGR_EVENT_CODE_2_TYPE(code) ((code) / MGR_EVT_TYPE_OFFSET + 1) +#define MGR_EVT_TYPE_BASE_LOCAL(sn) ((sn - 1) * MGR_EVT_TYPE_OFFSET) +#define MGR_EVENT_CODE_2_TYPE(code) ((code) / MGR_EVT_TYPE_OFFSET + 1) #endif #define PS3_EVT_TYPE_OFFSET (30) @@ -33,51 +36,50 @@ #define PS3_EVT_CODE_OFFSET (0) #define PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code) \ - ((((type)&0b11) << PS3_EVT_TYPE_OFFSET) | (((expose)&0b11) << PS3_EVT_EXPOSE_OFFSET) | \ - (((batch)&0b1) << PS3_EVT_BATCH_OFFSET) | (((attr)&0x3F) << PS3_EVT_ATTR_OFFSET) | \ - (((level)&0xF) << PS3_EVT_LEVEL_OFFSET) | ((code)&0xFFF) << PS3_EVT_CODE_OFFSET) + ((((type)&0b11) << PS3_EVT_TYPE_OFFSET) | \ + (((expose)&0b11) << PS3_EVT_EXPOSE_OFFSET) | \ + (((batch)&0b1) << PS3_EVT_BATCH_OFFSET) | \ + (((attr)&0x3F) << PS3_EVT_ATTR_OFFSET) | \ + (((level)&0xF) << PS3_EVT_LEVEL_OFFSET) | \ + ((code)&0xFFF) << PS3_EVT_CODE_OFFSET) #define PS3_MK_EVT(type, expose, batch, attr, level, code) \ - (PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code)) + (PS3_MAKE_EVT_CODE(type, expose, batch, attr, level, code)) -#define PS3_EVT_TYPE(evtcode) ((evtcode >> PS3_EVT_TYPE_OFFSET) & 0b11) +#define PS3_EVT_TYPE(evtcode) ((evtcode >> PS3_EVT_TYPE_OFFSET) & 0b11) #define PS3_EVT_EXPOSE(evtcode) ((evtcode >> PS3_EVT_EXPOSE_OFFSET) & 0b11) #define PS3_EVT_IS_BATCH(evtcode) ((evtcode >> PS3_EVT_BATCH_OFFSET) & 0b1) -#define PS3_EVT_ATTR_EXTEND(evtcode) ((U8)((evtcode >> PS3_EVT_ATTR_OFFSET) & 0x3F)) -#define PS3_EVT_LEVEL(evtcode) ((evtcode >> PS3_EVT_LEVEL_OFFSET) & 0xF) -#define PS3_EVT_CODE(evtcode) (((U32)evtcode >> PS3_EVT_CODE_OFFSET) & 0xFFF) - -typedef enum Ps3EventType -{ - PS3_EVT_TYPE_UNKNOWN = 0b0000, - PS3_EVT_TYPE_RAIDHBA = 0b0001, - PS3_EVT_TYPE_EXPANDER = 0b0010, - PS3_EVT_TYPE_PCIESWITCH = 0b0011, -}Ps3EventType_e; - -typedef enum Ps3EventExpose -{ - PS3_EVT_EXP_UNKNOWN = 0b0000, - PS3_EVT_EXP_EXTERNAL = 0b0001, - PS3_EVT_EXP_INTERNAL = 0b0010, - PS3_EVT_EXP_MAX = 0b0011, -}Ps3EventExpose_e; - -typedef enum MgrEventLevel -{ - PS3_EVT_CLASS_UNKNOWN = 0b0000, - PS3_EVT_CLASS_DEBUG = 0b0011, - PS3_EVT_CLASS_PROCESS = 0b0101, - PS3_EVT_CLASS_INFO = 0b0001, - PS3_EVT_CLASS_WARNING = 0b0010, - PS3_EVT_CLASS_CRITICAL = 0b0100, - PS3_EVT_CLASS_FATAL = 0b1000, - PS3_EVT_CLASS_MAX, -}MgrEventLevel_e; - -typedef enum MgrEventIsBatch -{ - PS3_EVT_IS_BATCH_FALSE = 0b0, - PS3_EVT_IS_BATCH_TRUE = 0b1, -}MgrEventIsBatch_e; +#define PS3_EVT_ATTR_EXTEND(evtcode) ((U8)((evtcode >> PS3_EVT_ATTR_OFFSET) & 0x3F)) +#define PS3_EVT_LEVEL(evtcode) ((evtcode >> PS3_EVT_LEVEL_OFFSET) & 0xF) +#define PS3_EVT_CODE(evtcode) (((unsigned int)evtcode >> PS3_EVT_CODE_OFFSET) & 0xFFF) + +enum Ps3EventType { + PS3_EVT_TYPE_UNKNOWN = 0b0000, + PS3_EVT_TYPE_RAIDHBA = 0b0001, + PS3_EVT_TYPE_EXPANDER = 0b0010, + PS3_EVT_TYPE_PCIESWITCH = 0b0011 +}; + +enum Ps3EventExpose { + PS3_EVT_EXP_UNKNOWN = 0b0000, + PS3_EVT_EXP_EXTERNAL = 0b0001, + PS3_EVT_EXP_INTERNAL = 0b0010, + PS3_EVT_EXP_MAX = 0b0011 +}; + +enum MgrEventLevel { + PS3_EVT_CLASS_UNKNOWN = 0b0000, + PS3_EVT_CLASS_DEBUG = 0b0011, + PS3_EVT_CLASS_PROCESS = 0b0101, + PS3_EVT_CLASS_INFO = 0b0001, + PS3_EVT_CLASS_WARNING = 0b0010, + PS3_EVT_CLASS_CRITICAL = 0b0100, + PS3_EVT_CLASS_FATAL = 0b1000, + PS3_EVT_CLASS_MAX +}; + +enum MgrEventIsBatch { + PS3_EVT_IS_BATCH_FALSE = 0b0, + PS3_EVT_IS_BATCH_TRUE = 0b1, +}; #endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_raidhba.h b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_raidhba.h deleted file mode 100644 index 9e6cdf658a6a..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_raidhba.h +++ /dev/null @@ -1,1509 +0,0 @@ -#ifndef __PS3_MGR_EVT_RAIDHBA_H__ -#define __PS3_MGR_EVT_RAIDHBA_H__ -#include "ps3_mgr_evt_common.h" - -typedef enum MgrEvtType -{ - PS3_EVT_ILLEGAL_TYPE = 0, - PS3_EVT_SAS_INFO = 0x1, - PS3_EVT_PD_COUNT = 0x2, - PS3_EVT_VD_COUNT = 0x4, - PS3_EVT_CTRL_INFO = 0x8, - PS3_EVT_PD_ATTR = 0x10, - PS3_EVT_VD_ATTR = 0x20, - PS3_EVT_DG_INFO = 0x40, - PS3_EVT_BBU_INFO = 0x80, - PS3_EVT_CONFIG = 0x100, - PS3_EVT_IO_INFO = 0x200, - PS3_EVT_UKEY_INFO = 0x400, - PS3_EVT_HWR_INFO = 0x800, - PS3_EVT_ALARM_INFO = 0x1000, - PS3_EVT_ECC_INFO = 0x2000, - PS3_EVT_UPGRADE_INFO = 0x4000, - PS3_EVT_TEMP_INFO = 0x8000, - PS3_EVT_PD_ATTR_EXTEND = 0x10000, -}MgrEvtType_e; - -static inline const S8 * nameMgrEvtType(U32 e) -{ - switch(e) { - case PS3_EVT_SAS_INFO: - return "PS3_EVT_SAS_INFO"; - break; - case PS3_EVT_PD_COUNT: - return "PS3_EVT_PD_COUNT"; - break; - case PS3_EVT_VD_COUNT: - return "PS3_EVT_VD_COUNT"; - break; - case PS3_EVT_CTRL_INFO: - return "PS3_EVT_CTRL_INFO"; - break; - case PS3_EVT_PD_ATTR: - return "PS3_EVT_PD_ATTR"; - break; - case PS3_EVT_VD_ATTR: - return "PS3_EVT_VD_ATTR"; - break; - case PS3_EVT_DG_INFO: - return "PS3_EVT_DG_INFO"; - break; - case PS3_EVT_BBU_INFO: - return "PS3_EVT_BBU_INFO"; - break; - case PS3_EVT_CONFIG: - return "PS3_EVT_CONFIG"; - break; - case PS3_EVT_IO_INFO: - return "PS3_EVT_IO_INFO"; - break; - case PS3_EVT_UKEY_INFO: - return "PS3_EVT_UKEY_INFO"; - break; - case PS3_EVT_HWR_INFO: - return "PS3_EVT_HWR_INFO"; - break; - case PS3_EVT_ALARM_INFO: - return "PS3_EVT_ALARM_INFO"; - break; - case PS3_EVT_ECC_INFO: - return "PS3_EVT_ECC_INFO"; - break; - case PS3_EVT_UPGRADE_INFO: - return "PS3_EVT_UPGRADE_INFO"; - break; - case PS3_EVT_TEMP_INFO: - return "PS3_EVT_TEMP_INFO"; - break; - case PS3_EVT_PD_ATTR_EXTEND: - return "PS3_EVT_PD_ATTR_EXTEND"; - break; - default : - return "PS3_EVT_ILLEGAL_TYPE"; - break; - } -} - -enum -{ - PS3_EVT_SAS_INFO_LOCAL = 1, - PS3_EVT_PD_COUNT_LOCAL = 2, - PS3_EVT_VD_COUNT_LOCAL = 3, - PS3_EVT_CTRL_INFO_LOCAL = 4, - PS3_EVT_PD_ATTR_LOCAL = 5, - PS3_EVT_VD_ATTR_LOCAL = 6, - PS3_EVT_DG_INFO_LOCAL = 7, - PS3_EVT_BBU_INFO_LOCAL = 8, - PS3_EVT_CONFIG_LOCAL = 9, - PS3_EVT_IO_INFO_LOCAL = 10, - PS3_EVT_UKEY_INFO_LOCAL = 11, - PS3_EVT_HWR_INFO_LOCAL = 12, - PS3_EVT_ALARM_INFO_LOCAL = 13, - PS3_EVT_ECC_INFO_LOCAL = 14, - PS3_EVT_UPGRADE_INFO_LOCAL = 15, - PS3_EVT_TEMP_INFO_LOCAL = 16, - PS3_EVT_PD_ATTR_EXTEND_LOCAL = 17, - PS3_EVT_DEFAULT_UNUSED_LOCAL, - PS3_EVT_MAX_TYPE_LOCAL, -}; - -static inline const S8 * nameMgrEvtLocalType(U32 e) -{ - switch(e) { - case PS3_EVT_SAS_INFO_LOCAL: - return "PS3_EVT_SAS_INFO_LOCAL"; - break; - case PS3_EVT_PD_COUNT_LOCAL: - return "PS3_EVT_PD_COUNT_LOCAL"; - break; - case PS3_EVT_VD_COUNT_LOCAL: - return "PS3_EVT_VD_COUNT_LOCAL"; - break; - case PS3_EVT_CTRL_INFO_LOCAL: - return "PS3_EVT_CTRL_INFO_LOCAL"; - break; - case PS3_EVT_PD_ATTR_LOCAL: - return "PS3_EVT_PD_ATTR_LOCAL"; - break; - case PS3_EVT_VD_ATTR_LOCAL: - return "PS3_EVT_VD_ATTR_LOCAL"; - break; - case PS3_EVT_DG_INFO_LOCAL: - return "PS3_EVT_DG_INFO_LOCAL"; - break; - case PS3_EVT_BBU_INFO_LOCAL: - return "PS3_EVT_BBU_INFO_LOCAL"; - break; - case PS3_EVT_CONFIG_LOCAL: - return "PS3_EVT_CONFIG_LOCAL"; - break; - case PS3_EVT_IO_INFO_LOCAL: - return "PS3_EVT_IO_INFO_LOCAL"; - break; - case PS3_EVT_UKEY_INFO_LOCAL: - return "PS3_EVT_UKEY_INFO_LOCAL"; - break; - case PS3_EVT_HWR_INFO_LOCAL: - return "PS3_EVT_HWR_INFO_LOCAL"; - break; - case PS3_EVT_ALARM_INFO_LOCAL: - return "PS3_EVT_ALARM_INFO_LOCAL"; - break; - case PS3_EVT_ECC_INFO_LOCAL: - return "PS3_EVT_ECC_INFO_LOCAL"; - break; - case PS3_EVT_UPGRADE_INFO_LOCAL: - return "PS3_EVT_UPGRADE_INFO_LOCAL"; - break; - case PS3_EVT_TEMP_INFO_LOCAL: - return "PS3_EVT_TEMP_INFO_LOCAL"; - break; - case PS3_EVT_PD_ATTR_EXTEND_LOCAL: - return "PS3_EVT_PD_ATTR_EXTEND_LOCAL"; - break; - default : - return "PS3_EVT_ILLEGAL_TYPE"; - break; - } -} - -enum MgrEvtSASInfoCode -{ - MGR_EVT_SAS_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_SAS_INFO_LOCAL), - MGR_EVT_SAS_EXPANDER_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x1), - MGR_EVT_SAS_EXPANDER_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x2), - MGR_EVT_SAS_EXPANDER_UPDATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x3), - MGR_EVT_SAS_EXPANDER_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x4), - MGR_EVT_ENCL_TEMP_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x5), - MGR_EVT_ENCL_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x6), - MGR_EVT_ENCL_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_SAS_START + 0x7), - MGR_EVT_TOPO_LOOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x8), - MGR_EVT_LOOP_RESOLUTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x9), - MGR_EVT_CASCADED_SCAN_SMP_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_SAS_START + 0xa), - MGR_EVT_ENCL_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xb), - MGR_EVT_TRI_MODE_SWITCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xc), - MGR_EVT_CHANGE_PHY_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xd), - MGR_EVT_REV_HIBERNATE_CMD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0xe), - MGR_EVT_PHY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0xf), - MGR_EVT_INQUIRY_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x10), - MGR_EVT_SAS_SATA_LINK_SPEED_NOMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x11), - MGR_EVT_SAS_SATA_LN_EXCEPTION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_SAS_START + 0x12), - MGR_EVT_SAS_SATA_DRIVER_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_SAS_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_SAS_START + 0x13), - MGR_EVT_SAS_END = (MGR_EVT_SAS_START+0x14), -}; - -enum MgrEvtPdCountCode -{ - MGR_EVT_PD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_COUNT_LOCAL), - MGR_EVT_DEVM_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x1), - MGR_EVT_DEVM_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x2), - MGR_EVT_MULITPILE_PD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x3), - MGR_EVT_MULITPILE_PD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x4), - MGR_EVT_DEVM_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x5), - MGR_EVT_DEVM_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x6), - MGR_EVT_MULITPILE_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x7), - MGR_EVT_MULITPILE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x8), - MGR_EVT_BACKPLANE_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0x9), - MGR_EVT_BACKPLANE_OFF = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xa), - MGR_EVT_MULITPILE_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xb), - MGR_EVT_DEVM_DISK_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xc), - MGR_EVT_DEFAULT_UNUSED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xd), - MGR_EVT_PD_PRE_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_INTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_COUNT_START + 0xe), - MGR_EVT_PD_COUNT_END = (MGR_EVT_PD_COUNT_START+0xf), -}; - -enum MgrEvtVdCountCode -{ - MGR_EVT_VD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_COUNT_LOCAL), - MGR_EVT_VD_OPTIMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x1), - MGR_EVT_VD_PARTIAL_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_COUNT_START + 0x2), - MGR_EVT_VD_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_COUNT_START + 0x3), - MGR_EVT_VD_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x4), - MGR_EVT_VD_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x5), - MGR_EVT_VD_HIDDEN_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x6), - MGR_EVT_MULITPILE_VD_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x7), - MGR_EVT_MULITPILE_VD_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x8), - MGR_EVT_VD_UNLOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_COUNT_START + 0x9), - MGR_EVT_VD_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_COUNT_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_COUNT_START + 0xa), - MGR_EVT_VD_COUNT_END = (MGR_EVT_VD_COUNT_START+0xb), -}; - -enum MgrEvtCtrlInfoCode -{ - MGR_EVT_CTRL_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CTRL_INFO_LOCAL), - MGR_EVT_CTRL_REBOOT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1), - MGR_EVT_CTRL_SHUTDOWN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2), - MGR_EVT_CTRL_TIME_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3), - MGR_EVT_CTRL_EVENT_LOG_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x4), - MGR_EVT_CTRL_RBLD_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x5), - MGR_EVT_CTRL_ENABLEMOVEBACK_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x6), - MGR_EVT_CTRL_ENABLENCQ_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x7), - MGR_EVT_CTRL_AUTO_REBUILD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x8), - MGR_EVT_CTRL_EGHS_READY_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x9), - MGR_EVT_CTRL_EGHS_SPARE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xa), - MGR_EVT_CTRL_BGI_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xb), - MGR_EVT_CTRL_MIGRATE_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xc), - MGR_EVT_CTRL_CC_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xd), - MGR_EVT_CTRL_DIRECT_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xe), - MGR_EVT_CTRL_PR_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0xf), - MGR_EVT_CTRL_PR_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x10), - MGR_EVT_CTRL_PR_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x11), - MGR_EVT_CTRL_PR_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x12), - MGR_EVT_CTRL_PR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x13), - MGR_EVT_CTRL_PR_RATE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x14), - MGR_EVT_CTRL_PR_CANT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x15), - MGR_EVT_CTRL_PR_PROP_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x16), - MGR_EVT_CTRL_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x17), - MGR_EVT_CTRL_AUTO_CC_PARAM_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x18), - MGR_EVT_CTRL_RECOVERY_FACTORY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x19), - MGR_EVT_CTRL_PROFILEID_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1a), - MGR_EVT_CTRL_SANPSHOT_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1b), - MGR_EVT_CTRL_SANPSHOT_DELETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1c), - MGR_EVT_CTRL_ENABLEPDM_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1d), - MGR_EVT_CTRL_PDMSUPPORTREADYPD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1e), - MGR_EVT_CTRL_PDMTIMERINTERVAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x1f), - MGR_EVT_CTRL_SECURITY_KEY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x20), - MGR_EVT_CTRL_SECURITY_KEY_CREATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x21), - MGR_EVT_CTRL_SECURITY_KEY_DESTROY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x22), - MGR_EVT_CTRL_SECURITY_KEY_ESCROW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x23), - MGR_EVT_CTRL_SECURITY_KEY_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x24), - MGR_EVT_CTRL_SECURITY_KEY_INVALID = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x25), - MGR_EVT_AUTOCONFIG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x26), - MGR_EVT_CTRL_FOREIGN_IMPORTED_ALL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x27), - MGR_EVT_CTRL_FOREIGN_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x28), - MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x29), - MGR_EVT_CTRL_FOREIGN_IMPORT_PART_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2a), - MGR_EVT_CTRL_FOREIGN_IMPORT_FAIL_PDS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2b), - MGR_EVT_CTRL_FOREIGN_PD_DETECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2c), - MGR_EVT_PD_INSERT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2d), - MGR_EVT_PD_IMPORT_TO_DG = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2e), - MGR_EVT_HARD_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x2f), - MGR_EVT_DPF_CFG_MODIFY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x30), - MGR_EVT_SPOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x31), - MGR_EVT_ONF_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_CTRL_INFO_START + 0x32), - MGR_EVT_CTRL_LOADED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x33), - MGR_EVT_MAIN_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_CTRL_INFO_START + 0x34), - MGR_EVT_BACKUP_MEDIUM_NOT_AVAILABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_CTRL_INFO_START + 0x35), - MGR_EVT_MEDIUM_DATA_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x36), - MGR_EVT_CACHE_PROTECTION_CMPT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x37), - MGR_EVT_CACHE_PROTECTION_CMPT_NOT_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x38), - MGR_EVT_CACHE_PROTECTION_CMPT_INSTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_CTRL_INFO_START + 0x39), - MGR_EVT_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3a), - MGR_EVT_CTRL_POWER_MODE_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CTRL_INFO_START + 0x3b), - MGR_EVT_CTRL_INFO_END = (MGR_EVT_CTRL_INFO_START+0x3c), -}; - -enum MgrEvtPdAttrCode -{ - MGR_EVT_PD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_LOCAL), - MGR_EVT_PD_INFO_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1), - MGR_EVT_PD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2), - MGR_EVT_PD_MARKED_JBOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3), - MGR_EVT_PD_MARKED_READY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4), - MGR_EVT_PD_MARKED_ONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x5), - MGR_EVT_PD_MARKED_OFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x6), - MGR_EVT_PD_MARKED_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x7), - MGR_EVT_PD_MARKED_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x8), - MGR_EVT_PD_MARKED_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x9), - MGR_EVT_PD_MARKED_REPLACE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xa), - MGR_EVT_PD_MARKED_UNCONFIGUREDBAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xb), - MGR_EVT_PD_MARKED_FOREIGN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xc), - MGR_EVT_PD_NR_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xd), - MGR_EVT_PD_NR_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xe), - MGR_EVT_PD_NR_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0xf), - MGR_EVT_PD_NR_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x10), - MGR_EVT_PD_R_GLOBAL_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x11), - MGR_EVT_PD_R_GLOBAL_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x12), - MGR_EVT_PD_R_DEDICATED_SPARE_ADDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x13), - MGR_EVT_PD_R_DEDICATED_SPARE_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x14), - MGR_EVT_PD_RBLD_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x15), - MGR_EVT_PD_RBLD_DONE_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x16), - MGR_EVT_PD_RBLD_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x17), - MGR_EVT_PD_RBLD_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x18), - MGR_EVT_PD_RBLD_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x19), - MGR_EVT_PD_RBLD_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1a), - MGR_EVT_PD_RBLD_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1b), - MGR_EVT_PD_RBLD_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1c), - MGR_EVT_PD_RBLD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1d), - MGR_EVT_PD_RBLD_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x1e), - MGR_EVT_PD_RBLD_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x1f), - MGR_EVT_PD_EMERGENCY_SPARE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x20), - MGR_EVT_PD_RECOVER_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x21), - MGR_EVT_PD_MOVEBACK_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x22), - MGR_EVT_PD_MOVEBACK_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x23), - MGR_EVT_PD_MOVEBACK_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x24), - MGR_EVT_PD_MOVEBACK_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x25), - MGR_EVT_PD_MOVEBACK_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x26), - MGR_EVT_PD_MOVEBACK_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x27), - MGR_EVT_PD_MOVEBACK_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x28), - MGR_EVT_PD_MOVEBACK_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x29), - MGR_EVT_PD_MOVEBACK_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2a), - MGR_EVT_PD_MOVEBACK_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x2b), - MGR_EVT_PD_MOVEBACK_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2c), - MGR_EVT_PD_MOVEBACK_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2d), - MGR_EVT_PD_MOVEBACK_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x2e), - MGR_EVT_PD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x2f), - MGR_EVT_PD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x30), - MGR_EVT_PD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x31), - MGR_EVT_PD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x32), - MGR_EVT_PD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x33), - MGR_EVT_PD_PR_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x34), - MGR_EVT_PD_PR_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x35), - MGR_EVT_PD_PR_UNCORRECTABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_START + 0x36), - MGR_EVT_PD_PR_FOUND_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x37), - MGR_EVT_PD_PR_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_START + 0x38), - MGR_EVT_PD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x39), - MGR_EVT_PD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3a), - MGR_EVT_PD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3b), - MGR_EVT_PD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3c), - MGR_EVT_PD_POWERSAVE_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3d), - MGR_EVT_PD_POWERSAVE_TO_TRANSITION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3e), - MGR_EVT_PD_TRANSITION_TO_ON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x3f), - MGR_EVT_PD_TRANSITION_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x40), - MGR_EVT_PD_ON_TO_POWERSAVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x41), - MGR_EVT_PD_START_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x42), - MGR_EVT_PD_STOP_LOCATE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x43), - MGR_EVT_PD_PFA_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x44), - MGR_EVT_PD_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x45), - MGR_EVT_DEVM_DISK_FAULT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_START + 0x46), - MGR_EVT_PHY_FLASHOFFLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_START + 0x47), - MGR_EVT_PHY_FLASHONLINE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x48), - MGR_EVT_NFR_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x49), - MGR_EVT_NFR_REPAIRED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4a), - MGR_EVT_NFR_REPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4b), - MGR_EVT_NFR_STOP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4c), - MGR_EVT_PD_DOWNLOAD_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4d), - MGR_EVT_PD_DOWNLOAD_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4e), - MGR_EVT_NVME_PHY_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_START + 0x4f), - MGR_EVT_PD_ATTR_END = (MGR_EVT_PD_ATTR_START+0x50), -}; - -enum MgrEvtVdAttrCode -{ - MGR_EVT_VD_ATTR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_VD_ATTR_LOCAL), - MGR_EVT_MULITPILE_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x1), - MGR_EVT_VD_OFFLINE_OLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x2), - MGR_EVT_VD_LOCK = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x3), - MGR_EVT_VD_PASSWD_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x4), - MGR_EVT_VD_SETTINGS_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x5), - MGR_EVT_VD_PD_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_INTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x6), - MGR_EVT_VD_STATE_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x7), - MGR_EVT_PD_RBLD_DONE_LD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x8), - MGR_EVT_VD_FGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x9), - MGR_EVT_VD_FGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xa), - MGR_EVT_VD_FGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0xb), - MGR_EVT_VD_FGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0xc), - MGR_EVT_VD_FGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xd), - MGR_EVT_VD_BGI_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xe), - MGR_EVT_VD_BGI_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0xf), - MGR_EVT_VD_BGI_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x10), - MGR_EVT_VD_BGI_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x11), - MGR_EVT_VD_BGI_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x12), - MGR_EVT_VD_BGI_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x13), - MGR_EVT_VD_BGI_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x14), - MGR_EVT_VD_BGI_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x15), - MGR_EVT_VD_BGI_CORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x16), - MGR_EVT_VD_BGI_UNCORRECTABLE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x17), - MGR_EVT_VD_ALTER_ATTR_BY_MIGRATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x18), - MGR_EVT_VD_BBM_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x19), - MGR_EVT_VD_BBM_PERCENT_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x1a), - MGR_EVT_VD_BBM_100_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x1b), - MGR_EVT_VD_BBM_LOG_FULL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x1c), - MGR_EVT_VD_BBM_LOG_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x1d), - MGR_EVT_VD_BBM_LOG_WCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x1e), - MGR_EVT_VD_BBM_DEL_RCT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x1f), - MGR_EVT_VD_CC_ABORTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x20), - MGR_EVT_VD_CC_CORRECTED_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x21), - MGR_EVT_VD_CC_DOUBLE_MEDIUM_ERRORS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x22), - MGR_EVT_VD_CC_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x23), - MGR_EVT_VD_CC_DONE_INCON = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x24), - MGR_EVT_VD_CC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x25), - MGR_EVT_VD_CC_FAILED_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x26), - MGR_EVT_VD_CC_INCONSISTENT_PARITY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x27), - MGR_EVT_VD_CC_INCONSISTENT_PARITY_LOGGING_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x28), - MGR_EVT_VD_CC_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x29), - MGR_EVT_VD_CC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2a), - MGR_EVT_VD_CC_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2b), - MGR_EVT_VD_CC_REMINDER_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2c), - MGR_EVT_VD_CC_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2d), - MGR_EVT_VD_RW_RAID1X_WRITE_CARDBUSY = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2e), - MGR_EVT_VD_SET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x2f), - MGR_EVT_VD_RESET_BOOT_DRIVE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x30), - MGR_EVT_VD_RESET_BOOT_DRIVE_WITH_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x31), - MGR_EVT_VD_SET_BOOT_DRIVE_WITH_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x32), - MGR_EVT_ALL_CONFIGS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x33), - MGR_EVT_PDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x34), - MGR_EVT_NVSRAM_RECOVER_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x35), - MGR_EVT_NVSRAM_UPDATE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x36), - MGR_EVT_VD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x37), - MGR_EVT_VD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x38), - MGR_EVT_VD_ERASE_DISK_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x39), - MGR_EVT_VD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_VD_ATTR_START + 0x3a), - MGR_EVT_VD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_VD_ATTR_START + 0x3b), - MGR_EVT_VD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3c), - MGR_EVT_VD_EXPAND_FINISH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3d), - MGR_EVT_VD_EXPAND_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3e), - MGR_EVT_VD_FLUSH_CLEAR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x3f), - MGR_EVT_VD_FLUSH_RECORD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x40), - MGR_EVT_VD_FLUSH_SET_INCONSIST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x41), - MGR_EVT_VDS_MISSING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x42), - MGR_EVT_VD_BBM_UNCORRECTABLE_LOGGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x43), - MGR_EVT_VD_FLUSH_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x44), - MGR_EVT_VD_FLUSH_OCR_CACHE_PINNED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x45), - MGR_EVT_VD_FLUSH_CACHE_DISCARDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x46), - MGR_EVT_VD_FLUSH_CACHE_DISCARDED_DEL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x47), - MGR_EVT_VD_FLUSH_CACHE_DESTAGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_VD_ATTR_START + 0x48), - MGR_EVT_VD_CM_RECOVERY_CRC_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_VD_ATTR_START + 0x49), - MGR_EVT_VD_BGI_COMPLETE_UNCOR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_VD_ATTR_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_VD_ATTR_START + 0x4a), - MGR_EVT_VD_ATTR_END = (MGR_EVT_VD_ATTR_START+0x4b), -}; - -enum MgrEvtDgInfoCode -{ - MGR_EVT_DG_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_DG_INFO_LOCAL), - MGR_EVT_DG_CREATED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x1), - MGR_EVT_DG_DELETED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x2), - MGR_EVT_DG_SETTING_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x3), - MGR_EVT_DG_MIGRATION_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x4), - MGR_EVT_DG_MIGRATION_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x5), - MGR_EVT_DG_MIGRATION_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0x6), - MGR_EVT_DG_MIGRATION_ALLOC_RESOURCE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0x7), - MGR_EVT_DG_MIGRATION_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_DG_INFO_START + 0x8), - MGR_EVT_DG_MIGRATION_RECOVER_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_DG_INFO_START + 0x9), - MGR_EVT_DG_MIGRATION_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_DG_INFO_START + 0xa), - MGR_EVT_DG_MIGRATION_INTERNAL_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xb), - MGR_EVT_DG_PRSWITCH_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_DG_INFO_START + 0xc), - MGR_EVT_DG_PR_ABORTED_WM_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xd), - MGR_EVT_DG_PR_ABORTED_SPINUP_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_DG_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_DG_INFO_START + 0xe), - MGR_EVT_DG_INFO_END = (MGR_EVT_DG_INFO_START+0xf), -}; - -enum MgrEvtBbuInfoCode -{ - MGR_EVT_BBU_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_BBU_INFO_LOCAL), - MGR_EVT_BBU_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1), - MGR_EVT_BBU_NOT_PRESENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x2), - MGR_EVT_BBU_GOOD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x3), - MGR_EVT_BBU_BAD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x4), - MGR_EVT_BBU_CAP_BELOW_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x5), - MGR_EVT_BBU_CAP_ABOVE_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x6), - MGR_EVT_BBU_CHARGE_STATUS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x7), - MGR_EVT_BBU_CHARGE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x8), - MGR_EVT_BBU_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x9), - MGR_EVT_BBU_ABSENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0xa), - MGR_EVT_BBU_TEMPERATURE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xb), - MGR_EVT_BBU_TEMPERATURE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0xc), - MGR_EVT_BBU_VOLTAGE_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xd), - MGR_EVT_BBU_VOLTAGE_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0xe), - MGR_EVT_BBU_CURRENT_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0xf), - MGR_EVT_BBU_CURRENT_HIGH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x10), - MGR_EVT_BBU_LOAD_NORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x11), - MGR_EVT_BBU_VOLTAGE_LOW = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x12), - MGR_EVT_BBU_BATTERY_CAP_ABOVE_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x13), - MGR_EVT_BBU_BATTERY_CAP_BELOW_SOH_THRESHOLD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0x14), - MGR_EVT_BBU_LEARN_STAGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x15), - MGR_EVT_BBU_LEARN_REQUESTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x16), - MGR_EVT_BBU_LEARN_POSTPONED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x17), - MGR_EVT_BBU_LEARN_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_BBU_START + 0x18), - MGR_EVT_BBU_LEARN_MANUAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_BBU_START + 0x19), - MGR_EVT_BBU_LEARN_RESCHEDULED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1a), - MGR_EVT_BBU_PROPERTIES_CHANGED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_BBU_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_BBU_START + 0x1b), - MGR_EVT_BBU_END = (MGR_EVT_BBU_START+0x1c), -}; - -enum MgrEvtConfigCode -{ - MGR_EVT_CONFIG_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_CONFIG_LOCAL), - MGR_EVT_CONFIG_INFO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x1), - MGR_EVT_CONFIG_FLASH_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x2), - MGR_EVT_CONFIG_FLASH_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x3), - MGR_EVT_CONFIG_NVSRAM_READ_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x4), - MGR_EVT_CONFIG_NVSRAM_WRITE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x5), - MGR_EVT_CONFIG_VERSION_MISMATCH = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x6), - MGR_EVT_CONFIG_MEDIA_VALUE_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x7), - MGR_EVT_CONFIG_ERASE_NVSRAM = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x8), - MGR_EVT_PHY_LINKSPEED_CFG_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_CONFIG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_CONFIG_START + 0x9), - MGR_EVT_CONFIG_END = (MGR_EVT_CONFIG_START+0xa), -}; - -enum MgrEvtIoInfoCode -{ - MGR_EVT_IO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_IO_INFO_LOCAL), - MGR_EVT_IO_TEST = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x1), - MGR_EVT_IO_SENSE_DATA = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x2), - MGR_EVT_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x3), - MGR_EVT_NVME_DEVICE_RESET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x4), - MGR_EVT_DEVICE_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x5), - MGR_EVT_IO_SENSE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_IO_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_IO_START + 0x6), - MGR_EVT_IO_END = (MGR_EVT_IO_START+0x7), -}; - -enum MgrEvtUkeyInfoCode -{ - MGR_EVT_UKEY_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UKEY_INFO_LOCAL), - MGR_EVT_UKEY_INSERT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x1), - MGR_EVT_UKEY_DEGRADE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x2), - MGR_EVT_RAID_KEY_OVERCURRENT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_UKEY_START + 0x3), - MGR_EVT_RAID_KEY_OVERCURRENT_RECOVER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UKEY_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UKEY_START + 0x4), - MGR_EVT_UKEY_END = (MGR_EVT_UKEY_START+0x5), -}; - -enum MgrEvtHwRInfoCode -{ - MGR_EVT_HWR_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_HWR_INFO_LOCAL), - MGR_EVT_HWR_HAC_RESET_BEGIN = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x1), - MGR_EVT_HWR_HAC_RESET_END = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x2), - MGR_EVT_REPORT_HAC_ECC = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_HWR_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_HWR_START + 0x3), - MGR_EVT_HWR_END = (MGR_EVT_HWR_START+0x4), -}; - -enum MgrEvtAlarmInfoCode -{ - MGR_EVT_ALARM_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ALARM_INFO_LOCAL), - MGR_EVT_ALARM_ENABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ALARM_START + 0x1), - MGR_EVT_ALARM_DISABLED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ALARM_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ALARM_START + 0x2), - MGR_EVT_ALARM_END = (MGR_EVT_ALARM_START+0x3), -}; - -enum MgrEvtEccInfoCode -{ - MGR_EVT_ECC_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_ECC_INFO_LOCAL), - MGR_EVT_ECC_CNT_EXCEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_ECC_START + 0x1), - MGR_EVT_ECC_ERR_INTR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_ECC_START + 0x2), - MGR_EVT_ECC_CNT_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x3), - MGR_EVT_ECC_CLI_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x4), - MGR_EVT_ECC_FACTORY_CHANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_INTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_ECC_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_ECC_START + 0x5), - MGR_EVT_ECC_END = (MGR_EVT_ECC_START+0x6), -}; - -enum MgrEvtUpgradeInfoCode -{ - MGR_EVT_UPGRADE_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_UPGRADE_INFO_LOCAL), - MGR_EVT_IMAGE_DOWNLOAD_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x1), - MGR_EVT_IMAGE_AUTHENTICATION_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x2), - MGR_EVT_IMAGE_VERSION_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x3), - MGR_EVT_IMAGE_CHECKSUM_CHECK_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x4), - MGR_EVT_IMAGE_FROM_BACKUP = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_UPGRADE_START + 0x5), - MGR_EVT_DEV_OPEN_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x6), - MGR_EVT_DEV_FLASH_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x7), - MGR_EVT_DEV_ERASE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x8), - MGR_EVT_DEV_CLOSE_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0x9), - MGR_EVT_FLASH_GENERAL_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0xa), - MGR_EVT_FLASH_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_UPGRADE_START + 0xb), - MGR_EVT_UPGRADE_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xc), - MGR_EVT_UPGRADE_SYNC_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xd), - MGR_EVT_UPGRADE_SYNC_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xe), - MGR_EVT_UPGRADE_SYNC_SUCCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_UPGRADE_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_UPGRADE_START + 0xf), - MGR_EVT_UPGRADE_END = (MGR_EVT_UPGRADE_START+0x10), -}; - -enum MgrEvtTempInfoCode -{ - MGR_EVT_TEMP_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_TEMP_INFO_LOCAL), - MGR_EVT_TEMP_WITHIN_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_TEMP_START + 0x1), - MGR_EVT_TEMP_ABOVE_OPTIMAL_RANGE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_TEMP_START + 0x2), - MGR_EVT_TEMP_WARNING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_TEMP_START + 0x3), - MGR_EVT_TEMP_CRITICAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_TEMP_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_TEMP_START + 0x4), - MGR_EVT_TEMP_END = (MGR_EVT_TEMP_START+0x5), -}; - -enum MgrEvtPdAttrExtendCode -{ - MGR_EVT_PD_ATTR_EXTEND_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_PD_ATTR_EXTEND_LOCAL), - MGR_EVT_PD_NVME_CMD_ERR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1), - MGR_EVT_PD_NVME_CMD_TO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2), - MGR_EVT_PD_NVME_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3), - MGR_EVT_PD_ERASE_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x4), - MGR_EVT_PD_ERASE_COMPLETE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x5), - MGR_EVT_PD_ERASE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x6), - MGR_EVT_PD_ERASE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0x7), - MGR_EVT_PD_ERASE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x8), - MGR_EVT_PD_PDM_ABORT_BY_USER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x9), - MGR_EVT_PD_PDM_ABORT_FOR_REBUILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0xa), - MGR_EVT_PD_PDM_ABORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xb), - MGR_EVT_PD_PDM_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xc), - MGR_EVT_PD_PDM_FAILED_BAD_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0xd), - MGR_EVT_PD_PDM_FAILED_BAD_TARGET = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0xe), - MGR_EVT_PD_PDM_MEDIUM_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0xf), - MGR_EVT_PD_PDM_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0x10), - MGR_EVT_PD_PDM_REPLACED_SOURCE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x11), - MGR_EVT_PD_PDM_RESUME = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x12), - MGR_EVT_PD_PDM_START_AUTO = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x13), - MGR_EVT_PD_PDM_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x14), - MGR_EVT_PD_PDM_SUSPENDED_REMINDER = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x15), - MGR_EVT_PD_PDM_SUSPENDED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x16), - MGR_EVT_PD_PFA_ERROR_CLEAR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x17), - MGR_EVT_PD_SANITIZE_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x18), - MGR_EVT_PD_FORMAT_START = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x19), - MGR_EVT_PD_SANITIZE_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_PROCESS, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1a), - MGR_EVT_PD_SANITIZE_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1b), - MGR_EVT_PD_FORMAT_DONE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1c), - MGR_EVT_PD_DPF_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1d), - MGR_EVT_PD_MARKED_SHIELD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1e), - MGR_EVT_PD_BBM_CORRECTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x1f), - MGR_EVT_PD_BBM_UNRECOVERABLE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x20), - MGR_EVT_PD_BBM_PUNCTURING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x21), - MGR_EVT_PD_BBM_REASSIGN_WR_ERROR = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x22), - MGR_EVT_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x23), - MGR_EVT_MULITPILE_PD_UNABLE_ACCESS = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x24), - MGR_EVT_PD_INSERT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x25), - MGR_EVT_PHY_SATA_D2H_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x26), - MGR_EVT_PD_NOT_INSERTED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x27), - MGR_EVT_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x28), - MGR_EVT_MULITPILE_PD_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_TRUE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x29), - MGR_EVT_NVDATA_INVAILD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2a), - MGR_EVT_PD_RBLD_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2b), - MGR_EVT_PD_MOVEBACK_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2c), - MGR_EVT_PD_PDM_NON_UNMAP_PD = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2d), - MGR_EVT_PD_RBLD_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2e), - MGR_EVT_PD_SANITIZE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_PD_ATTR_EXTEND_START + 0x2f), - MGR_EVT_PD_SPIN_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x30), - MGR_EVT_PD_RBLD_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x31), - MGR_EVT_PD_RBLD_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x32), - MGR_EVT_PD_PDM_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x33), - MGR_EVT_PD_PDM_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x34), - MGR_EVT_PD_MOVEBACK_MEDIA_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x35), - MGR_EVT_PD_MOVEBACK_DRIVE_MIX_NOT_SUPPORT = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x36), - MGR_EVT_NFR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x37), - MGR_EVT_PD_RBLD_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x38), - MGR_EVT_PD_MOVEBACK_SMALL_SIZE = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x39), - MGR_EVT_NEGO_LOWER_LINK_SPEED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3a), - MGR_EVT_PCIE_LINK_NEGO_ABNORMAL = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3b), - MGR_EVT_PD_ISOLATION = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3c), - MGR_EVT_PD_REPAIR_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3d), - MGR_EVT_PD_PCIE_LINK_UP_WITHOUT_I2C = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3e), - MGR_EVT_PD_PCIE_ENUMERATE_FAILED = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_PD_ATTR_EXTEND_START + 0x3f), - MGR_EVT_PD_MISS_LIGHTING = PS3_MK_EVT(PS3_EVT_TYPE_RAIDHBA, PS3_EVT_EXP_INTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_PD_ATTR_EXTEND_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_PD_ATTR_EXTEND_START + 0x40), - MGR_EVT_PD_ATTR_EXTEND_END = (MGR_EVT_PD_ATTR_EXTEND_START+0x41), -}; - -static inline U32 ps3EvtCodeExtendToNormal(U32 evtcode) -{ - U32 event = 0; - switch (evtcode){ - case PS3_EVT_PD_ATTR_EXTEND_LOCAL: - event = PS3_EVT_PD_ATTR_LOCAL; - break; - default: - event = evtcode; - } - return event; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_swexp.h b/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_swexp.h deleted file mode 100644 index f6fd2adf8c39..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_mgr_evt_swexp.h +++ /dev/null @@ -1,477 +0,0 @@ -#ifndef __PS3_MGR_EVT_SWEXP_H__ -#define __PS3_MGR_EVT_SWEXP_H__ -#include "ps3_mgr_evt_common.h" - -enum -{ - PS3_EVTLOG_LOCAL = 1, - PS3_EVTLOG_PD_COUNT_LOCAL = 2, - PS3_EVTLOG_CTRL_INFO_LOCAL = 3, - PS3_EVT_EXP_LOCAL = 4, - PS3_EVT_EXP_PHY_LOCAL = 5, - PS3_EVT_EXP_CONN_LOCAL = 6, - PS3_EVTLOG_SW_CTRL_INFO_LOCAL = 7, - PS3_EVTLOG_MAX_TYPE_LOCAL, -}; - -static inline const S8 * nameMgrEvtSwExpType(U32 e) -{ - switch(e) { - case PS3_EVTLOG_LOCAL: - return "PS3_EVTLOG_LOCAL"; - break; - case PS3_EVTLOG_PD_COUNT_LOCAL: - return "PS3_EVTLOG_PD_COUNT_LOCAL"; - break; - case PS3_EVTLOG_CTRL_INFO_LOCAL: - return "PS3_EVTLOG_CTRL_INFO_LOCAL"; - break; - case PS3_EVT_EXP_LOCAL: - return "PS3_EVT_EXP_LOCAL"; - break; - case PS3_EVT_EXP_PHY_LOCAL: - return "PS3_EVT_EXP_PHY_LOCAL"; - break; - case PS3_EVT_EXP_CONN_LOCAL: - return "PS3_EVT_EXP_CONN_LOCAL"; - break; - case PS3_EVTLOG_SW_CTRL_INFO_LOCAL: - return "PS3_EVTLOG_SW_CTRL_INFO_LOCAL"; - break; - default : - return "PS3_EVTLOG_MAX_TYPE_LOCAL"; - break; - } -} - -enum MgrEvtLogCode -{ - MGR_EVTLOG_EVTLOG_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVTLOG_LOCAL), - MGR_SWITCH_EVTLOG_READY = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x1), - MGR_SWITCH_EVTLOG_TEST = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x2), - MGR_SWITCH_EVTLOG_OEM = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x3), - MGR_SWITCH_EVTLOG_BPLANE = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x4), - MGR_SWITCH_EVTLOG_SES = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x5), - MGR_SWITCH_EVTLOG_SCSI = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_EVTLOG_START + 0x6), - MGR_EVTLOG_EVTLOG_END = (MGR_EVTLOG_EVTLOG_START+0x7), -}; - -enum MgrEvtLogPdCountCode -{ - MGR_EVTLOG_PD_COUNT_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVTLOG_PD_COUNT_LOCAL), - MGR_EVTLOG_PD_COUNT_END = (MGR_EVTLOG_PD_COUNT_START+0x1), -}; - -enum MgrEvtLogCtrlInfoCode -{ - MGR_EVTLOG_CTRL_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVTLOG_CTRL_INFO_LOCAL), - MGR_EVT_EXP_UNUSED1 = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_CTRL_INFO_START + 0x1), - MGR_EVT_EXP_UNUSED2 = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_CTRL_INFO_START + 0x2), - MGR_EVT_EXP_UNUSED3 = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_CTRL_INFO_START + 0x3), - MGR_EVT_EXP_REBOOT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVTLOG_CTRL_INFO_START + 0x4), - MGR_EVT_EXP_SHUTDOWN = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVTLOG_CTRL_INFO_START + 0x5), - MGR_EVT_EXP_EVENT_LOG_CLEARD = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_CTRL_INFO_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVTLOG_CTRL_INFO_START + 0x6), - MGR_EVTLOG_CTRL_INFO_END = (MGR_EVTLOG_CTRL_INFO_START+0x7), -}; - -enum MgrEvtLogExpInfoCode -{ - MGR_EVT_EXP_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_EXP_LOCAL), - MGR_EVT_EXP_CFG_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x1), - MGR_EVT_EXP_CLI_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x2), - MGR_EVT_EXP_SES_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x3), - MGR_EVT_EXP_SMPI_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x4), - MGR_EVT_EXP_SMPT_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x5), - MGR_EVT_EXP_SSPI_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x6), - MGR_EVT_EXP_SSPT_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x7), - MGR_EVT_EXP_SCE_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x8), - MGR_EVT_EXP_TEST_LOG = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x9), - MGR_EVT_EXP_TEST_WARN_LOG = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_WARNING, - MGR_EVT_EXP_START + 0xa), - MGR_EVT_EXP_TEST_CRIT_LOG = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0xb), - MGR_EVT_EXP_TEST_FATAL_LOG = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_EXP_START + 0xc), - MGR_EVT_EXP_CEVA_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0xd), - MGR_EVT_EXP_CEVA_QUEUE_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0xe), - MGR_EVT_EXP_CEVA_MUTEX_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0xf), - MGR_EVT_EXP_CEVA_FUNC_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x10), - MGR_EVT_EXP_CEVA_READY = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x11), - MGR_EVT_EXP_CEVA_NOT_READY = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x12), - MGR_EVT_EXP_CEVA_SMP_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x13), - MGR_EVT_EXP_CEVA_DMA_RX_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x14), - MGR_EVT_EXP_CEVA_DMA_TX_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x15), - MGR_EVT_EXP_SCE_ERR_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x16), - MGR_EVT_EXP_SCE_ERR_NO_MEM = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x17), - MGR_EVT_EXP_SCE_ERR_NO_SPC_EXP = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x18), - MGR_EVT_EXP_SCE_ERR_NO_SPC_PHY = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x19), - MGR_EVT_EXP_SCE_ERR_NO_SPC_PNED = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1a), - MGR_EVT_EXP_SCE_ERR_NO_SPC_REMOVE = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1b), - MGR_EVT_EXP_SCE_ERR_NO_SPC_DOWN = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1c), - MGR_EVT_EXP_SCE_ERR_BUSY = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1d), - MGR_EVT_EXP_SCE_ERR_LOOP = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1e), - MGR_EVT_EXP_SCE_ERR_T2T = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x1f), - MGR_EVT_EXP_SCE_ERR_S2S = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x20), - MGR_EVT_EXP_SCE_ERR_EXP_ON_DIRECT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x21), - MGR_EVT_EXP_SCE_ERR_MULTIPLE_SUB = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x22), - MGR_EVT_EXP_SCE_ERR_SMP_REQ = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x23), - MGR_EVT_EXP_SCE_ERR_SMP_RSP = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x24), - MGR_EVT_EXP_BPP_ERR_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x25), - MGR_EVT_EXP_BPP_ERR_STORM = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x26), - MGR_EVT_EXP_BPP_ERR_SOFT_SEND = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x27), - MGR_EVT_EXP_SMPI_ERR_INIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x28), - MGR_EVT_EXP_SMPI_ERR_TRANSMIT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x29), - MGR_EVT_EXP_SMPI_ERR_RECV_TIMEOUT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2a), - MGR_EVT_EXP_SMPI_ERR_RECV_DMA = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2b), - MGR_EVT_EXP_SMPI_ERR_DO_RESET = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2c), - MGR_EVT_EXP_SMPI_ERR_OTHER = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2d), - MGR_EVT_EXP_SSPT_I_TIMEOUT_HW = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2e), - MGR_EVT_EXP_SSPT_I_TIMEOUT_SW = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x2f), - MGR_EVT_EXP_SSPT_RX_DMA_IN_PROGRESS = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x30), - MGR_EVT_EXP_SSPT_START_RX_DMA_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x31), - MGR_EVT_EXP_SSPT_RX_CMD_LEN_ERR = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x32), - MGR_EVT_EXP_SSPT_IO_FULL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x33), - MGR_EVT_EXP_SSPT_IM_FULL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x34), - MGR_EVT_EXP_SSPT_RX_DATA_ERR = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x35), - MGR_EVT_EXP_SSPT_RX_TASK_ERR = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x36), - MGR_EVT_EXP_SSPT_NOT_SUPPORT_TASK_FUNCTION = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x37), - MGR_EVT_EXP_SSPT_NOT_SUPPORT_FRM_TYPE = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x38), - MGR_EVT_EXP_SSPT_TX_PAUSE = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x39), - MGR_EVT_EXP_SSPT_HARD_RESET = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x3a), - MGR_EVT_EXP_SSPT_SOFT_RESET = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x3b), - MGR_EVT_EXP_SSPT_INIT_FAIL = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVT_EXP_START + 0x3c), - MGR_EVT_EXP_SSPT_SET_TIME = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_START + 0x3d), - MGR_EVT_EXP_DOUBLE_BIT_ECC_ERR = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_LOCAL, PS3_EVT_CLASS_FATAL, - MGR_EVT_EXP_START + 0x3e), - MGR_EVT_EXP_END = (MGR_EVT_EXP_START+0x3f), -}; - -enum MgrEvtLogExpPhyInfoCode -{ - MGR_EVT_EXP_PHY_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_EXP_PHY_LOCAL), - MGR_EVT_EXP_DISCONNECT_RAID_HBA = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x1), - MGR_EVT_EXP_DISCONNECT_EXP = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x2), - MGR_EVT_EXP_DISK_OUT = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x3), - MGR_EVT_EXP_PHY_ENABLE = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x4), - MGR_EVT_EXP_PHY_DISABLE = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x5), - MGR_EVT_EXP_PHY_HARD_RESET = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x6), - MGR_EVT_EXP_PHY_LINK_RESET = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_PHY_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_PHY_START + 0x7), - MGR_EVT_EXP_PHY_END = (MGR_EVT_EXP_PHY_START+0x8), -}; - -enum MgrEvtLogExpConnInfoCode -{ - MGR_EVT_EXP_CONN_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVT_EXP_CONN_LOCAL), - MGR_EVT_EXP_CONNECT_RAID_HBA = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_CONN_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_CONN_START + 0x1), - MGR_EVT_EXP_CONNECT_EXP = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_CONN_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_CONN_START + 0x2), - MGR_EVT_EXP_DISK_IN = PS3_MK_EVT(PS3_EVT_TYPE_EXPANDER, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVT_EXP_CONN_LOCAL, PS3_EVT_CLASS_INFO, - MGR_EVT_EXP_CONN_START + 0x3), - MGR_EVT_EXP_CONN_END = (MGR_EVT_EXP_CONN_START+0x4), -}; - -enum MgrEvtLogSwCtrlInfoCode -{ - MGR_EVTLOG_SW_CTRL_INFO_START = MGR_EVT_TYPE_BASE_LOCAL(PS3_EVTLOG_SW_CTRL_INFO_LOCAL), - MGR_SWITCH_EVTLOG_CTRL_REBOOT = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_SW_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVTLOG_SW_CTRL_INFO_START + 0x1), - MGR_SWITCH_EVTLOG_CTRL_SHUTDOWN = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_SW_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVTLOG_SW_CTRL_INFO_START + 0x2), - MGR_SWITCH_EVTLOG_CTRL_EVENT_LOG_CLEARED = PS3_MK_EVT(PS3_EVT_TYPE_PCIESWITCH, PS3_EVT_EXP_EXTERNAL, - PS3_EVT_IS_BATCH_FALSE, PS3_EVTLOG_SW_CTRL_INFO_LOCAL, PS3_EVT_CLASS_CRITICAL, - MGR_EVTLOG_SW_CTRL_INFO_START + 0x3), - MGR_EVTLOG_SW_CTRL_INFO_END = (MGR_EVTLOG_SW_CTRL_INFO_START+0x4), -}; - -static inline S8 const *swexpEvtLogCodeTrans(U32 opCode) -{ - U32 typeIndex = 0; - U32 codeIndex = 0; - const S8* pEvtTransStr = NULL; - static S8 const *pEvtLogCodeInfo[PS3_EVTLOG_MAX_TYPE_LOCAL][MGR_EVT_TYPE_OFFSET] = { - { - "MGR_EVTLOG_EVTLOG_START", - "MGR_SWITCH_EVTLOG_READY", - "MGR_SWITCH_EVTLOG_TEST", - "MGR_SWITCH_EVTLOG_OEM", - "MGR_SWITCH_EVTLOG_BPLANE", - "MGR_SWITCH_EVTLOG_SES", - "MGR_SWITCH_EVTLOG_SCSI", - }, - { - "MGR_EVTLOG_PD_COUNT_START", - }, - { - "MGR_EVTLOG_CTRL_INFO_START", - "MGR_EVT_EXP_UNUSED1", - "MGR_EVT_EXP_UNUSED2", - "MGR_EVT_EXP_UNUSED3", - "MGR_EVT_EXP_REBOOT", - "MGR_EVT_EXP_SHUTDOWN", - "MGR_EVT_EXP_EVENT_LOG_CLEARD", - }, - { - "MGR_EVT_EXP_START", - "MGR_EVT_EXP_CFG_INIT", - "MGR_EVT_EXP_CLI_INIT", - "MGR_EVT_EXP_SES_INIT", - "MGR_EVT_EXP_SMPI_INIT", - "MGR_EVT_EXP_SMPT_INIT", - "MGR_EVT_EXP_SSPI_INIT", - "MGR_EVT_EXP_SSPT_INIT", - "MGR_EVT_EXP_SCE_INIT", - "MGR_EVT_EXP_TEST_LOG", - "MGR_EVT_EXP_TEST_WARN_LOG", - "MGR_EVT_EXP_TEST_CRIT_LOG", - "MGR_EVT_EXP_TEST_FATAL_LOG", - "MGR_EVT_EXP_CEVA_INIT_FAIL", - "MGR_EVT_EXP_CEVA_QUEUE_FAIL", - "MGR_EVT_EXP_CEVA_MUTEX_FAIL", - "MGR_EVT_EXP_CEVA_FUNC_FAIL", - "MGR_EVT_EXP_CEVA_READY", - "MGR_EVT_EXP_CEVA_NOT_READY", - "MGR_EVT_EXP_CEVA_SMP_FAIL", - "MGR_EVT_EXP_CEVA_DMA_RX_FAIL", - "MGR_EVT_EXP_CEVA_DMA_TX_FAIL", - "MGR_EVT_EXP_SCE_ERR_INIT", - "MGR_EVT_EXP_SCE_ERR_NO_MEM", - "MGR_EVT_EXP_SCE_ERR_NO_SPC_EXP", - "MGR_EVT_EXP_SCE_ERR_NO_SPC_PHY", - "MGR_EVT_EXP_SCE_ERR_NO_SPC_PNED", - "MGR_EVT_EXP_SCE_ERR_NO_SPC_REMOVE", - "MGR_EVT_EXP_SCE_ERR_NO_SPC_DOWN", - "MGR_EVT_EXP_SCE_ERR_BUSY", - "MGR_EVT_EXP_SCE_ERR_LOOP", - "MGR_EVT_EXP_SCE_ERR_T2T", - "MGR_EVT_EXP_SCE_ERR_S2S", - "MGR_EVT_EXP_SCE_ERR_EXP_ON_DIRECT", - "MGR_EVT_EXP_SCE_ERR_MULTIPLE_SUB", - "MGR_EVT_EXP_SCE_ERR_SMP_REQ", - "MGR_EVT_EXP_SCE_ERR_SMP_RSP", - "MGR_EVT_EXP_BPP_ERR_INIT", - "MGR_EVT_EXP_BPP_ERR_STORM", - "MGR_EVT_EXP_BPP_ERR_SOFT_SEND", - "MGR_EVT_EXP_SMPI_ERR_INIT", - "MGR_EVT_EXP_SMPI_ERR_TRANSMIT", - "MGR_EVT_EXP_SMPI_ERR_RECV_TIMEOUT", - "MGR_EVT_EXP_SMPI_ERR_RECV_DMA", - "MGR_EVT_EXP_SMPI_ERR_DO_RESET", - "MGR_EVT_EXP_SMPI_ERR_OTHER", - "MGR_EVT_EXP_SSPT_I_TIMEOUT_HW", - "MGR_EVT_EXP_SSPT_I_TIMEOUT_SW", - "MGR_EVT_EXP_SSPT_RX_DMA_IN_PROGRESS", - "MGR_EVT_EXP_SSPT_START_RX_DMA_FAIL", - "MGR_EVT_EXP_SSPT_RX_CMD_LEN_ERR", - "MGR_EVT_EXP_SSPT_IO_FULL", - "MGR_EVT_EXP_SSPT_IM_FULL", - "MGR_EVT_EXP_SSPT_RX_DATA_ERR", - "MGR_EVT_EXP_SSPT_RX_TASK_ERR", - "MGR_EVT_EXP_SSPT_NOT_SUPPORT_TASK_FUNCTION", - "MGR_EVT_EXP_SSPT_NOT_SUPPORT_FRM_TYPE", - "MGR_EVT_EXP_SSPT_TX_PAUSE", - "MGR_EVT_EXP_SSPT_HARD_RESET", - "MGR_EVT_EXP_SSPT_SOFT_RESET", - "MGR_EVT_EXP_SSPT_INIT_FAIL", - "MGR_EVT_EXP_SSPT_SET_TIME", - "MGR_EVT_EXP_DOUBLE_BIT_ECC_ERR", - }, - { - "MGR_EVT_EXP_PHY_START", - "MGR_EVT_EXP_DISCONNECT_RAID_HBA", - "MGR_EVT_EXP_DISCONNECT_EXP", - "MGR_EVT_EXP_DISK_OUT", - "MGR_EVT_EXP_PHY_ENABLE", - "MGR_EVT_EXP_PHY_DISABLE", - "MGR_EVT_EXP_PHY_HARD_RESET", - "MGR_EVT_EXP_PHY_LINK_RESET", - }, - { - "MGR_EVT_EXP_CONN_START", - "MGR_EVT_EXP_CONNECT_RAID_HBA", - "MGR_EVT_EXP_CONNECT_EXP", - "MGR_EVT_EXP_DISK_IN", - }, - { - "MGR_EVTLOG_SW_CTRL_INFO_START", - "MGR_SWITCH_EVTLOG_CTRL_REBOOT", - "MGR_SWITCH_EVTLOG_CTRL_SHUTDOWN", - "MGR_SWITCH_EVTLOG_CTRL_EVENT_LOG_CLEARED", - }, - }; - - if (opCode >= (PS3_EVTLOG_MAX_TYPE_LOCAL * MGR_EVT_TYPE_OFFSET)) { - goto end; - }; - - typeIndex = opCode / MGR_EVT_TYPE_OFFSET; - codeIndex = opCode % MGR_EVT_TYPE_OFFSET; - pEvtTransStr = pEvtLogCodeInfo[typeIndex][codeIndex]; -end: - return pEvtTransStr; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_nvme_spec.h b/drivers/scsi/linkdata/ps3stor/include/ps3_nvme_spec.h deleted file mode 100644 index 644ed582d347..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_nvme_spec.h +++ /dev/null @@ -1,2215 +0,0 @@ - -#ifndef _NVME_SPEC_H -#define _NVME_SPEC_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define NVME_REG32_ERR_VAL ((U32)(-1)) -#define NVME_REG64_ERR_VAL ((U64)(-1)) -#define NVME_MAX_IO_QUEUES (65536) -#define NVME_MAX_NUM_ADMIN_QD (4096) -#define NVME_MAX_NUM_IO_QD (65536) -#define NVME_MIN_NUM_ADMIN_QD (2) -#define NVME_MIN_NUM_IO_QD (MASK#define NVME_NSSR_VAL (0x4e564d65) -#define NVME_CMD_SET_SUPPORT BIT(0) -#define NVME_INVALID_CID (0xFFFF) -#define NVME_MAX_WRITE_ZEROES (0xFFFF) -#define NVME_NSID_MASK (0xFFFFFFFF) - -#define NVME_GET_SECTOR_SIZE(data) (1 << (data)->lbaf[(data)->flbas.format].lbads) - - -#define NVME_GET_SQ_DOOR_BELL_OFFSET(qid, strd) (0x1000 + 2 * (qid) * (4 << (strd))) - -#define NVME_GET_CQ_DOOR_BELL_OFFSET(qid, strd) (0x1000 + (2 * (qid) + 1) * (4 << (strd))) - -#define NVME_SANITIZE_MAX_PROG 0xFFFF - -#define NVME_CAP_CSS_NVM 1 - -#define NVME_MPS_TO_PAGESIZE(mpsMin) (1u << (12 + (mpsMin))) - -#define NVME_PAGESIZE_TO_MPS(pageSize) (nvmeU64Log2(pageSize) - 12) - - -typedef union NvmeCapReg { - U64 rawVal; - struct { - U32 mqes : 16; - U32 cqr : 1; - U32 ams : 2; - U32 rsvd : 5; - U32 timeout : 8; - U32 dbStride : 4; - - U32 nssrSupport : 1; - U32 cmdSetSupport : 8; - U32 bootPartSupport : 1; - U32 rsvd1 : 2; - U32 mpsMin : 4; - U32 mpsMax : 4; - U32 pmrSupport : 1; - U32 cmbSupport : 1; - U32 rsvd3 : 6; - }; -} NvmeCapReg_u; - - -typedef union NvmeVsReg { - U32 rawVal; - struct { - U8 vsTerity; - U8 vsMinorNum; - U16 vsMajorNum; - }; -} NvmeVsReg_u; - - - -#define NVME_VERSION(mjr, mnr, ter) \ - (((uint32_s)(mjr) << 16) | ((uint32_s)(mnr) << 8) | (uint32_s)(ter)) - - -#define NVME_IO_SQ_ENTRY_SIZE 6 - -#define NVME_IO_CQ_ENTRY_SIZE 4 - - -#define NVME_SHUT_DOWN_NO_EFFECT 0x0 - -#define NVME_SHUT_DOWN_NOTIFY 0x1 - -#define NVME_SHUT_DOWN_ABRUT_NOTIFY 0x2 - -#define NVME_CSS_NVM_CMD_SET 0x0 - -typedef union NvmeCCReg { - U32 rawVal; - struct { - - U32 en : 1; - U32 rsvd : 3; - U32 css : 3; - U32 mps : 4; - U32 ams : 3; - U32 shutdownNotify : 2; - - U32 ioSqEntrySz : 4; - U32 ioCqEntrySz : 4; - U32 rsvd1 : 8; - }; -} NvmeCCReg_u; - - -#define NVME_SHST_NORMAL 0x0 -#define NVME_SHST_OCCURRING 0x1 -#define NVME_SHST_COMPLETE 0x2 - -typedef union NvmeCstsReg { - U32 rawVal; - struct { - U32 rdy : 1; - U32 cfs : 1; - U32 shutdownStatus : 2; - U32 nssrOccur : 1; - U32 proccessPaused : 1; - U32 rsvd : 26; - }; -} NvmeCstsReg_u; - - -typedef union NvmeAqaReg { - U32 rawVal; - struct { - U32 adminSqSz : 12; - U32 rsvd : 4; - U32 adminCqSz : 12; - U32 rsvd1 : 4; - }; -} NvmeAqaReg_u; - - -typedef union NvmeCmbLocReg { - U32 rawVal; - struct { - U32 bir : 3; - U32 cmbQMixMemSupport : 1; - U32 cmbQPhyDiscontiSupport : 1; - U32 cmbDataPtrMixLocSupport : 1; - U32 cmbDataPtrCmdIndentLocSupport : 1; - U32 cmbDataMetaMemMixSupport : 1; - U32 cmbQDwordAlignSupport : 1; - U32 rsvd : 3; - U32 offset : 20; - }; -} NvmeCmbLocReg_u; - - -typedef union NvmeCmbSzReg { - U32 rawVal; - struct { - U32 sqSupport : 1; - U32 cqSupport : 1; - U32 prpListSupport : 1; - U32 readSupport : 1; - U32 writeSupport : 1; - U32 rsvd : 3; - U32 szUnit : 4; - U32 size : 20; - }; -} NvmeCmbSzReg_u; - - -typedef struct NvmeControllerReg { - NvmeCapReg_u cap; - NvmeVsReg_u vs; - U32 intmskSet; - U32 intmskClr; - NvmeCCReg_u cc; - U32 rsvd0; - NvmeCstsReg_u csts; - U32 nssrCtrl; - NvmeAqaReg_u aqa; - U64 asq; - U64 acq; - NvmeCmbLocReg_u cmbLoc; - NvmeCmbSzReg_u cmbSz; - - - -} NvmeControllerReg_s; - - -typedef struct DBEntry { - U32 sqT; - U32 cqH; -} DBEntry_s; - - -enum NvmeSglDescSubType { - NVME_SGL_SUBTYPE_ADDRESS = 0x0, - NVME_SGL_SUBTYPE_OFFSET = 0x1, - NVME_SGL_SUBTYPE_TRANSPORT = 0xa, -}; - -typedef struct GenericSglDesc{ - U32 rsvd; - U32 rsvd1 : 24; - U32 subType : 4; - U32 type : 4; -} GenericSglDesc_s; - - -typedef struct UnKeyedSglDesc{ - U32 len; - U32 rsvd : 24; - U32 subType : 4; - U32 type : 4; -} UnKeyedSglDesc_s; - - -typedef struct KeyedSglDesc{ - U64 len : 24; - U64 key : 32; - U64 subType : 4; - U64 type : 4; -} KeyedSglDesc_s; - - -typedef struct NvmeSglDesc { - U64 addr; - union { - GenericSglDesc_s genSgl; - UnKeyedSglDesc_s unkeyedSgl; - KeyedSglDesc_s keyedSgl; - }; -} NvmeSglDesc_s; - - - - -struct NvmeSanitize { - - U32 sanact : 3; - - U32 ause : 1; - - U32 owpass : 4; - - U32 oipbp : 1; - - U32 ndas : 1; - - U32 reserved : 22; -}; - - - -enum NvmeSanitizeAction { - - NVME_SANITIZE_EXIT_FAILURE_MODE = 0x1, - - NVME_SANITIZE_BLOCK_ERASE = 0x2, - - NVME_SANITIZE_OVERWRITE = 0x3, - - NVME_SANITIZE_CRYPTO_ERASE = 0x4, -}; - -typedef struct NvmeCommonCmdEntry { - - U16 opc : 8; - U16 fuse : 2; - U16 rsvd : 4; - U16 psdt : 2; - U16 cid; - - - U32 nsId; - - - U64 rsvd1; - - - U64 metaPtr; - - - union { - struct { - U64 prp1; - union { - U64 prp2; - struct { - U32 metaDataLen; - U32 dataLen; - }; - }; - }; - NvmeSglDesc_s sgl; - }; - - - union { - - struct { - U64 slba; - U32 nlba : 16; - U32 res1 : 8; - U32 stc : 1; - U32 res2 : 1; - U32 prinfo : 4; - U32 fua : 1; - U32 lr : 1; - }; - - struct { - struct NvmeSanitize sanitizeDw10; - U32 overwritePattern; - }; - struct { - U32 dw10; - U32 dw11; - U32 dw12; - U32 dw13; - U32 dw14; - U32 dw15; - }; - }; -} NvmeCommonCmdEntry_s; - -#ifndef _WINDOWS -typedef struct __attribute__((packed)) NvmeCmdStatus { -#else -#pragma pack(1) -typedef struct NvmeCmdStatus { -#endif - union { - struct { - U16 p : 1; - U16 sc : 8; - U16 sct : 3; - U16 crd : 2; - U16 m : 1; - U16 dnr : 1; - }; - U16 cmdStatus; - }; -} NvmeCmdStatus_s; - -#ifdef _WINDOWS -#pragma pack() -#endif - - -#define NVME_GET_IO_SQ_NUM(cmdSpec) (((cmdSpec) & 0xFFFF) + 1) - -#define NVME_GET_IO_CQ_NUM(cmdSpec) (((cmdSpec) >> 16) + 1) - - -#define NVME_GET_POWER_STATE(cmdSpec) (((cmdSpec) & 0X1F)) - -typedef struct NvmeCplEntry { - - U32 cmdSpec; - - U32 rsvd; - - U16 sqHead; - U16 sqId; - - U16 cid; - NvmeCmdStatus_s status; -} NvmeCplEntry_s; - - -enum NvmeAdminOpcode { - NVME_OPC_DELETE_IO_SQ = 0x00, - NVME_OPC_CREATE_IO_SQ = 0x01, - NVME_OPC_GET_LOG_PAGE = 0x02, - - NVME_OPC_DELETE_IO_CQ = 0x04, - NVME_OPC_CREATE_IO_CQ = 0x05, - NVME_OPC_IDENTIFY = 0x06, - - NVME_OPC_ABORT = 0x08, - NVME_OPC_SET_FEATURES = 0x09, - NVME_OPC_GET_FEATURES = 0x0a, - - NVME_OPC_ASYNC_EVENT_REQUEST = 0x0c, - NVME_OPC_NS_MANAGEMENT = 0x0d, - - NVME_OPC_FIRMWARE_COMMIT = 0x10, - NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD = 0x11, - NVME_OPC_DEVICE_SELF_TEST = 0x14, - NVME_OPC_NS_ATTACHMENT = 0x15, - NVME_OPC_KEEP_ALIVE = 0x18, - NVME_OPC_DIRECTIVE_SEND = 0x19, - NVME_OPC_DIRECTIVE_RECEIVE = 0x1a, - NVME_OPC_VIRTUALIZATION_MANAGEMENT = 0x1c, - NVME_OPC_NVME_MI_SEND = 0x1d, - NVME_OPC_NVME_MI_RECEIVE = 0x1e, - NVME_OPC_DOORBELL_BUFFER_CONFIG = 0x7c, - NVME_OPC_FORMAT_NVM = 0x80, - NVME_OPC_SECURITY_SEND = 0x81, - NVME_OPC_SECURITY_RECEIVE = 0x82, - NVME_OPC_SANITIZE = 0x84, -}; - - -enum NvmeIOOpcode { - NVME_OPC_FLUSH = 0x00, - NVME_OPC_WRITE = 0x01, - NVME_OPC_READ = 0x02, - - NVME_OPC_WRITE_UNCORRECTABLE = 0x04, - NVME_OPC_COMPARE = 0x05, - - NVME_OPC_WRITE_ZEROES = 0x08, - NVME_OPC_DATASET_MANAGEMENT = 0x09, - NVME_OPC_VERIFY = 0x0C, - - NVME_OPC_RESERVATION_REGISTER = 0x0d, - NVME_OPC_RESERVATION_REPORT = 0x0e, - - NVME_OPC_RESERVATION_ACQUIRE = 0x11, - NVME_OPC_RESERVATION_RELEASE = 0x15, -}; - - -enum NvmeStatusCodeType { - NVME_SCT_GENERIC = 0x0, - NVME_SCT_COMMAND_SPECIFIC = 0x1, - NVME_SCT_MEDIA_ERROR = 0x2, - NVME_SCT_PATH = 0x3, - - NVME_SCT_VENDOR_SPECIFIC = 0x7, -}; - - -enum NvmeGenCmdSC { - NVME_SC_SUCCESS = 0x00, - NVME_SC_INVALID_OPCODE = 0x01, - NVME_SC_INVALID_FIELD = 0x02, - NVME_SC_COMMAND_ID_CONFLICT = 0x03, - NVME_SC_DATA_TRANSFER_ERROR = 0x04, - NVME_SC_ABORTED_POWER_LOSS = 0x05, - NVME_SC_INTERNAL_DEVICE_ERROR = 0x06, - NVME_SC_ABORTED_BY_REQUEST = 0x07, - NVME_SC_ABORTED_SQ_DELETION = 0x08, - NVME_SC_ABORTED_FAILED_FUSED = 0x09, - NVME_SC_ABORTED_MISSING_FUSED = 0x0a, - NVME_SC_INVALID_NAMESPACE_OR_FORMAT = 0x0b, - NVME_SC_COMMAND_SEQUENCE_ERROR = 0x0c, - NVME_SC_INVALID_SGL_SEG_DESCRIPTOR = 0x0d, - NVME_SC_INVALID_NUM_SGL_DESCIRPTORS = 0x0e, - NVME_SC_DATA_SGL_LENGTH_INVALID = 0x0f, - NVME_SC_METADATA_SGL_LENGTH_INVALID = 0x10, - NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID = 0x11, - NVME_SC_INVALID_CONTROLLER_MEM_BUF = 0x12, - NVME_SC_INVALID_PRP_OFFSET = 0x13, - NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED = 0x14, - NVME_SC_OPERATION_DENIED = 0x15, - NVME_SC_INVALID_SGL_OFFSET = 0x16, - - NVME_SC_HOSTID_INCONSISTENT_FORMAT = 0x18, - NVME_SC_KEEP_ALIVE_EXPIRED = 0x19, - NVME_SC_KEEP_ALIVE_INVALID = 0x1a, - NVME_SC_ABORTED_PREEMPT = 0x1b, - NVME_SC_SANITIZE_FAILED = 0x1c, - NVME_SC_SANITIZE_IN_PROGRESS = 0x1d, - NVME_SC_SGL_DATA_BLOCK_GRANULARITY_INVALID = 0x1e, - NVME_SC_COMMAND_INVALID_IN_CMB = 0x1f, - NVME_SC_NAMESPACE_IS_WRITE_PROTECTED = 0x20, - NVME_SC_COMMAND_INTERRUPTED = 0x21, - NVME_SC_TRANSIENT_TRANSPORT_ERROR = 0x22, - - NVME_SC_LBA_OUT_OF_RANGE = 0x80, - NVME_SC_CAPACITY_EXCEEDED = 0x81, - NVME_SC_NAMESPACE_NOT_READY = 0x82, - NVME_SC_RESERVATION_CONFLICT = 0x83, - NVME_SC_FORMAT_IN_PROGRESS = 0x84, -}; - - -enum NvmeCmdSpecSC { - NVME_CSC_COMPLETION_QUEUE_INVALID = 0x00, - NVME_CSC_INVALID_QUEUE_IDENTIFIER = 0x01, - NVME_CSC_MAXIMUM_QUEUE_SIZE_EXCEEDED = 0x02, - NVME_CSC_ABORT_COMMAND_LIMIT_EXCEEDED = 0x03, - - NVME_CSC_ASYNC_EVENT_REQUEST_LIMIT_EXCEEDED = 0x05, - NVME_CSC_INVALID_FIRMWARE_SLOT = 0x06, - NVME_CSC_INVALID_FIRMWARE_IMAGE = 0x07, - NVME_CSC_INVALID_INTERRUPT_VECTOR = 0x08, - NVME_CSC_INVALID_LOG_PAGE = 0x09, - NVME_CSC_INVALID_FORMAT = 0x0a, - NVME_CSC_FIRMWARE_REQ_CONVENTIONAL_RESET = 0x0b, - NVME_CSC_INVALID_QUEUE_DELETION = 0x0c, - NVME_CSC_FEATURE_ID_NOT_SAVEABLE = 0x0d, - NVME_CSC_FEATURE_NOT_CHANGEABLE = 0x0e, - NVME_CSC_FEATURE_NOT_NAMESPACE_SPECIFIC = 0x0f, - NVME_CSC_FIRMWARE_REQ_NVM_RESET = 0x10, - NVME_CSC_FIRMWARE_REQ_RESET = 0x11, - NVME_CSC_FIRMWARE_REQ_MAX_TIME_VIOLATION = 0x12, - NVME_CSC_FIRMWARE_ACTIVATION_PROHIBITED = 0x13, - NVME_CSC_OVERLAPPING_RANGE = 0x14, - NVME_CSC_NAMESPACE_INSUFFICIENT_CAPACITY = 0x15, - NVME_CSC_NAMESPACE_ID_UNAVAILABLE = 0x16, - - NVME_CSC_NAMESPACE_ALREADY_ATTACHED = 0x18, - NVME_CSC_NAMESPACE_IS_PRIVATE = 0x19, - NVME_CSC_NAMESPACE_NOT_ATTACHED = 0x1a, - NVME_CSC_THINPROVISIONING_NOT_SUPPORTED = 0x1b, - NVME_CSC_CONTROLLER_LIST_INVALID = 0x1c, - NVME_CSC_DEVICE_SELF_TEST_IN_PROGRESS = 0x1d, - NVME_CSC_BOOT_PARTITION_WRITE_PROHIBITED = 0x1e, - NVME_CSC_INVALID_CTRLR_ID = 0x1f, - NVME_CSC_INVALID_SECONDARY_CTRLR_STATE = 0x20, - NVME_CSC_INVALID_NUM_CTRLR_RESOURCES = 0x21, - NVME_CSC_INVALID_RESOURCE_ID = 0x22, - - NVME_CSC_CONFLICTING_ATTRIBUTES = 0x80, - NVME_CSC_INVALID_PROTECTION_INFO = 0x81, - NVME_CSC_ATTEMPTED_WRITE_TO_RO_RANGE = 0x82, -}; - - -enum NvmeMediaErrSC { - NVME_MSC_WRITE_FAULTS = 0x80, - NVME_MSC_UNRECOVERED_READ_ERROR = 0x81, - NVME_MSC_GUARD_CHECK_ERROR = 0x82, - NVME_MSC_APPLICATION_TAG_CHECK_ERROR = 0x83, - NVME_MSC_REFERENCE_TAG_CHECK_ERROR = 0x84, - NVME_MSC_COMPARE_FAILURE = 0x85, - NVME_MSC_ACCESS_DENIED = 0x86, - NVME_MSC_DEALLOCATED_OR_UNWRITTEN_BLOCK = 0x87, -}; - -enum NvmeStatusCodes { - NVME_SUCCESS = 0x0000, - NVME_INVALID_OPCODE = 0x0001, - NVME_INVALID_FIELD = 0x0002, - NVME_CID_CONFLICT = 0x0003, - NVME_DATA_TRAS_ERROR = 0x0004, - NVME_POWER_LOSS_ABORT = 0x0005, - NVME_INTERNAL_DEV_ERROR = 0x0006, - NVME_CMD_ABORT_REQ = 0x0007, - NVME_CMD_ABORT_SQ_DEL = 0x0008, - NVME_CMD_ABORT_FAILED_FUSE = 0x0009, - NVME_CMD_ABORT_MISSING_FUSE = 0x000a, - NVME_INVALID_NSID = 0x000b, - NVME_CMD_SEQ_ERROR = 0x000c, - NVME_INVALID_SGL_SEG_DESCR = 0x000d, - NVME_INVALID_NUM_SGL_DESCRS = 0x000e, - NVME_DATA_SGL_LEN_INVALID = 0x000f, - NVME_MD_SGL_LEN_INVALID = 0x0010, - NVME_SGL_DESCR_TYPE_INVALID = 0x0011, - NVME_INVALID_USE_OF_CMB = 0x0012, - NVME_INVALID_PRP_OFFSET = 0x0013, - NVME_CMD_SET_CMB_REJECTED = 0x002b, - NVME_INVALID_CMD_SET = 0x002c, - NVME_LBA_RANGE = 0x0080, - NVME_CAP_EXCEEDED = 0x0081, - NVME_NS_NOT_READY = 0x0082, - NVME_NS_RESV_CONFLICT = 0x0083, - NVME_FORMAT_IN_PROGRESS = 0x0084, - NVME_INVALID_CQID = 0x0100, - NVME_INVALID_QID = 0x0101, - NVME_MAX_QSIZE_EXCEEDED = 0x0102, - NVME_ACL_EXCEEDED = 0x0103, - NVME_RESERVED = 0x0104, - NVME_AER_LIMIT_EXCEEDED = 0x0105, - NVME_INVALID_FW_SLOT = 0x0106, - NVME_INVALID_FW_IMAGE = 0x0107, - NVME_INVALID_IRQ_VECTOR = 0x0108, - NVME_INVALID_LOG_ID = 0x0109, - NVME_INVALID_FORMAT = 0x010a, - NVME_FW_REQ_RESET = 0x010b, - NVME_INVALID_QUEUE_DEL = 0x010c, - NVME_FID_NOT_SAVEABLE = 0x010d, - NVME_FEAT_NOT_CHANGEABLE = 0x010e, - NVME_FEAT_NOT_NS_SPEC = 0x010f, - NVME_FW_REQ_SUSYSTEM_RESET = 0x0110, - NVME_NS_ALREADY_ATTACHED = 0x0118, - NVME_NS_PRIVATE = 0x0119, - NVME_NS_NOT_ATTACHED = 0x011A, - NVME_NS_CTRL_LIST_INVALID = 0x011C, - NVME_CONFLICTING_ATTRS = 0x0180, - NVME_INVALID_PROT_INFO = 0x0181, - NVME_WRITE_TO_RO = 0x0182, - NVME_CMD_SIZE_LIMIT = 0x0183, - NVME_ZONE_BOUNDARY_ERROR = 0x01b8, - NVME_ZONE_FULL = 0x01b9, - NVME_ZONE_READ_ONLY = 0x01ba, - NVME_ZONE_OFFLINE = 0x01bb, - NVME_ZONE_INVALID_WRITE = 0x01bc, - NVME_ZONE_TOO_MANY_ACTIVE = 0x01bd, - NVME_ZONE_TOO_MANY_OPEN = 0x01be, - NVME_ZONE_INVAL_TRANSITION = 0x01bf, - NVME_WRITE_FAULT = 0x0280, - NVME_UNRECOVERED_READ = 0x0281, - NVME_E2E_GUARD_ERROR = 0x0282, - NVME_E2E_APP_ERROR = 0x0283, - NVME_E2E_REF_ERROR = 0x0284, - NVME_CMP_FAILURE = 0x0285, - NVME_ACCESS_DENIED = 0x0286, - NVME_DULB = 0x0287, - NVME_MORE = 0x2000, - NVME_DNR = 0x4000, - NVME_NO_COMPLETE = 0xffff, -}; - -enum NvmeQprio { - NVME_QPRIO_URGENT = 0x0, - NVME_QPRIO_HIGH = 0x1, - NVME_QPRIO_MEDIUM = 0x2, - NVME_QPRIO_LOW = 0x3 -}; - -enum NvmeDataTransfer { - - NVME_DATA_NONE = 0, - - NVME_DATA_HOST_TO_CONTROLLER = 1, - - NVME_DATA_CONTROLLER_TO_HOST = 2, - - NVME_DATA_BIDIRECTIONAL = 3 -}; - -static inline enum NvmeDataTransfer NvmeOpcGetDataTransfer(U8 opc) -{ - return (enum NvmeDataTransfer)(opc & 3); -} - -enum NvmeFeat { - - - - NVME_FEAT_ARBITRATION = 0x01, - - NVME_FEAT_POWER_MANAGEMENT = 0x02, - - NVME_FEAT_LBA_RANGE_TYPE = 0x03, - - NVME_FEAT_TEMPERATURE_THRESHOLD = 0x04, - - NVME_FEAT_ERROR_RECOVERY = 0x05, - - NVME_FEAT_VOLATILE_WRITE_CACHE = 0x06, - - NVME_FEAT_NUMBER_OF_QUEUES = 0x07, - - NVME_FEAT_INTERRUPT_COALESCING = 0x08, - - NVME_FEAT_INTERRUPT_VECTOR_CONFIGURATION = 0x09, - - NVME_FEAT_WRITE_ATOMICITY = 0x0A, - - NVME_FEAT_ASYNC_EVENT_CONFIGURATION = 0x0B, - - NVME_FEAT_AUTONOMOUS_POWER_STATE_TRANSITION = 0x0C, - - NVME_FEAT_HOST_MEM_BUFFER = 0x0D, - NVME_FEAT_TIMESTAMP = 0x0E, - - NVME_FEAT_KEEP_ALIVE_TIMER = 0x0F, - - NVME_FEAT_HOST_CONTROLLED_THERMAL_MANAGEMENT = 0x10, - - NVME_FEAT_NON_OPERATIONAL_POWER_STATE_CONFIG = 0x11, - - - - - - - NVME_FEAT_SOFTWARE_PROGRESS_MARKER = 0x80, - - - NVME_FEAT_HOST_IDENTIFIER = 0x81, - NVME_FEAT_HOST_RESERVE_MASK = 0x82, - NVME_FEAT_HOST_RESERVE_PERSIST = 0x83, - - - - -}; - - -enum NvmeGetFeatSel { - NVME_GET_FEA_SEL_CURRENT = 0x0, - NVME_GET_FEA_SEL_DEFAULT = 0x1, - NVME_GET_FEA_SEL_SAVED = 0x2, - NVME_GET_FEA_SEL_SUP_CAPABILITY = 0x3, -}; - - -enum NvmeDsmAttribute { - NVME_DSM_ATTR_INTEGRAL_READ = 0x1, - NVME_DSM_ATTR_INTEGRAL_WRITE = 0x2, - NVME_DSM_ATTR_DEALLOCATE = 0x4, -}; - -struct NvmePowerState { - U16 mp; - - U8 reserved1; - - U8 mps : 1; - U8 nops : 1; - U8 reserved2 : 6; - - U32 enlat; - U32 exlat; - - U8 rrt : 5; - U8 reserved3 : 3; - - U8 rrl : 5; - U8 reserved4 : 3; - - U8 rwt : 5; - U8 reserved5 : 3; - - U8 rwl : 5; - U8 reserved6 : 3; - - U8 reserved7[16]; -}; - - -typedef enum NvmeIdentifyCns { - - NVME_IDENTIFY_NS = 0x00, - - - NVME_IDENTIFY_CTRLR = 0x01, - - - NVME_IDENTIFY_ACTIVE_NS_LIST = 0x02, - - - NVME_IDENTIFY_NS_ID_DESCRIPTOR_LIST = 0x03, - - - NVME_IDENTIFY_ALLOCATED_NS_LIST = 0x10, - - - NVME_IDENTIFY_NS_ALLOCATED = 0x11, - - - - NVME_IDENTIFY_NS_ATTACHED_CTRLR_LIST = 0x12, - - - NVME_IDENTIFY_CTRLR_LIST = 0x13, - - - NVME_IDENTIFY_PRIMARY_CTRLR_CAP = 0x14, - - - NVME_IDENTIFY_SECONDARY_CTRLR_LIST = 0x15, - - - NVME_IDENTIFY_NS_GRANULARITY_LIST = 0x16, -} NvmeIdentifyCns_e; - - -enum NvmfCtrlrModel { - - NVMF_CTRLR_MODEL_DYNAMIC = 0, - - - NVMF_CTRLR_MODEL_STATIC = 1, -}; - -#define NVME_CTRLR_SN_LEN 20 -#define NVME_CTRLR_MN_LEN 40 -#define NVME_CTRLR_FR_LEN 8 - - -enum NvmeSglsSupported { - - NVME_SGLS_NOT_SUPPORTED = 0, - - - NVME_SGLS_SUPPORTED = 1, - - - NVME_SGLS_SUPPORTED_DWORD_PCIE_ALIGNED = 2, -}; - - -enum NvmeFlushBroadcast { - - NVME_FLUSH_BROADCAST_NOT_INDICATED = 0, - - - - - NVME_FLUSH_BROADCAST_NOT_SUPPORTED = 2, - - - NVME_FLUSH_BROADCAST_SUPPORTED = 3 -}; -#ifndef _WINDOWS -struct __attribute__((packed)) __attribute__((aligned)) NvmeCtrlrData { -#else -#pragma pack(1) -struct NvmeCtrlrData { -#endif - - - U16 vid; - - - U16 ssvid; - - - S8 sn[NVME_CTRLR_SN_LEN]; - - - S8 mn[NVME_CTRLR_MN_LEN]; - - - U8 fr[NVME_CTRLR_FR_LEN]; - - - U8 rab; - - - U8 ieee[3]; - - - - U8 cmic; - - - U8 mdts; - - - U16 cntlid; - - - union NvmeVsReg ver; - - - U32 rtd3r; - - - U32 rtd3e; - - - U32 oaes; - - - U32 ctratt; - - U8 reserved_100[12]; - - - U8 fguid[16]; - - U8 reserved_128[128]; - - - - - U16 oacs; - - - U8 acl; - - - U8 aerl; - - - U8 frmw; - - - U8 lpe; - - - U8 elpe; - - - U8 npss; - - - U8 avscc; - - - U8 apsta; - - - U16 wctemp; - - - U16 cctemp; - - - U16 mtfa; - - - U32 hmpre; - - - U32 hmmin; - - - U64 tnvmcap[2]; - - - U64 unvmcap[2]; - - - U32 rpmbs; - - - U16 edstt; - - - U8 dsto; - - U8 fwug; - - U16 kas; - - - U16 hctma; - - - U16 mntmt; - - - U16 mxtmt; - - - union { - U32 sanicap; - struct { - U32 ces:1; - U32 bes:1; - U32 ows:1; - U32 snicapRsvd1:26; - U32 ndi:1; - U32 nodmmas:2; - }; - }; - - U8 reserved3[180]; - - - - - U8 sqes; - - - U8 cqes; - - U16 maxcmd; - - - U32 nn; - - - U16 oncs; - - - U16 fuses; - - - U8 fna; - - - U8 vwc; - - - U16 awun; - - - U16 awupf; - - - U8 nvscc; - - U8 reserved531; - - - U16 acwu; - - U16 reserved534; - - - U32 sgls; - - U8 reserved4[228]; - - U8 subnqn[256]; - - U8 reserved5[768]; - - - struct { - - U32 ioccsz; - - - U32 iorcsz; - - - U16 icdoff; - - - U8 ctrattr; - - - U8 msdbd; - - U8 reserved[244]; - }; - - - struct NvmePowerState psd[32]; - - - U8 vs[1024]; -}; -#ifdef _WINDOWS -#pragma pack() -#endif - -#ifndef _WINDOWS -struct __attribute__((packed)) NvmePrimaryCtrlCapabilities { -#else -#pragma pack(1) -struct NvmePrimaryCtrlCapabilities { -#endif - - U16 cntlid; - - U16 portid; - - U8 crt; - U8 reserved[27]; - - U32 vqfrt; - - U32 vqrfa; - - U16 vqrfap; - - U16 vqprt; - - - U16 vqfrsm; - - U16 vqgran; - U8 reserved1[16]; - - - U32 vifrt; - - - U32 virfa; - - - U16 virfap; - - U16 viprt; - - - U16 vifrsm; - - U16 vigran; - U8 reserved2[4016]; -}; - - -#ifdef _WINDOWS -#pragma pack() -#endif -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeSecondaryCtrlEntry { -#else -#pragma pack(1) -struct NvmeSecondaryCtrlEntry { -#endif - - U16 scid; - - U16 pcid; - - U8 scs; - U8 reserved[3]; - - U16 vfn; - - - U16 nvq; - - - U16 nvi; - U8 reserved1[18]; -}; - -#ifdef _WINDOWS -#pragma pack() -#endif -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeSecondaryCtrlList { -#else -#pragma pack(1) -struct NvmeSecondaryCtrlList { -#endif - - U8 number; - U8 reserved[31]; - struct NvmeSecondaryCtrlEntry entries[127]; -}; - -#ifdef _WINDOWS -#pragma pack() -#endif -struct NvmeNsData { - - U64 nsze; - - - U64 ncap; - - - U64 nuse; - - - U8 nsfeat; - - - U8 nlbaf; - union { - struct { - U8 format : 4; - U8 extended : 1; - U8 reserved2 : 3; - } flbas; - U8 flbasRaw; - }; - - - U8 mc; - - - union { - struct { - U8 type1 : 1; - U8 type2 : 1; - U8 type3 : 1; - U8 piBeforeMeta : 1; - U8 piAfterMeta : 1; - U8 reserved2 : 3; - }; - U8 rawData; - } dpc; - - - union { - struct { - U8 type : 3; - U8 isPiBefore : 1; - U8 reserved2 : 4; - }; - U8 rawData; - } dps; - - - U8 nmic; - - - U8 nsrescap; - - U8 fpi; - - - U8 dlfeat; - - - U16 nawun; - - - U16 nawupf; - - - U16 nacwu; - - - U16 nabsn; - - - U16 nabo; - - - U16 nabspf; - - - U16 noiob; - - - U64 nvmcap[2]; - - U8 reserved64[40]; - - - U8 nguid[16]; - - - U64 eui64; - - struct { - U32 ms : 16; - U32 lbads : 8; - U32 rp : 2; - U32 reserved6 : 6; - } lbaf[16]; - - U8 reserved6[192]; - - U8 vendorSpecific[3712]; -}; - - - -enum NvmeDeallocLogicalBlockReadValue { - - NVME_DEALLOC_NOT_REPORTED = 0, - - - NVME_DEALLOC_READ_00 = 1, - - - NVME_DEALLOC_READ_FF = 2, -}; - - -enum NvmeReservationType { - - - - NVME_RESERVE_WRITE_EXCLUSIVE = 0x1, - - - NVME_RESERVE_EXCLUSIVE_ACCESS = 0x2, - - - NVME_RESERVE_WRITE_EXCLUSIVE_REG_ONLY = 0x3, - - - NVME_RESERVE_EXCLUSIVE_ACCESS_REG_ONLY = 0x4, - - - NVME_RESERVE_WRITE_EXCLUSIVE_ALL_REGS = 0x5, - - - NVME_RESERVE_EXCLUSIVE_ACCESS_ALL_REGS = 0x6, - - -}; - -struct NvmeReservationAcquireData { - - U64 crkey; - - U64 prkey; -}; - - - - -enum NvmeReservationAcquireAction { - NVME_RESERVE_ACQUIRE = 0x0, - NVME_RESERVE_PREEMPT = 0x1, - NVME_RESERVE_PREEMPT_ABORT = 0x2, -}; -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeReservationStatusData { -#else -#pragma pack(1) -struct NvmeReservationStatusData { -#endif - - U32 gen; - - U8 rtype; - - U16 regctl; - U16 reserved1; - - U8 ptpls; - U8 reserved[14]; -}; -#ifdef _WINDOWS -#pragma pack() -#endif - -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeReservationStatusExtendedData { -#else -#pragma pack(1) -struct NvmeReservationStatusExtendedData { -#endif - struct NvmeReservationStatusData data; - U8 reserved[40]; -}; - - -#ifdef _WINDOWS -#pragma pack() -#endif -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeRegisteredCtrlrData { -#else -#pragma pack(1) -struct NvmeRegisteredCtrlrData { -#endif - - U16 cntlid; - U8 rcsts; - U8 reserved2[5]; - - U64 hostid; - - U64 rkey; -}; - -#ifdef _WINDOWS -#pragma pack() -#endif -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeRegisteredCtrlrExtendedData { -#else -#pragma pack(1) -struct NvmeRegisteredCtrlrExtendedData { -#endif - - U16 cntlid; - - U8 rcsts; - U8 reserved2[5]; - - U64 rkey; - - U8 hostid[16]; - U8 reserved3[32]; -}; - - -#ifdef _WINDOWS -#pragma pack() -#endif - - -enum NvmeReservationRegisterCptpl { - NVME_RESERVE_PTPL_NO_CHANGES = 0x0, - NVME_RESERVE_PTPL_CLEAR_POWER_ON = 0x2, - NVME_RESERVE_PTPL_PERSIST_POWER_LOSS = 0x3, -}; - - -enum NvmeReservationRegisterAction { - NVME_RESERVE_REGISTER_KEY = 0x0, - NVME_RESERVE_UNREGISTER_KEY = 0x1, - NVME_RESERVE_REPLACE_KEY = 0x2, -}; - -struct NvmeReservationRegisterData { - - U64 crkey; - - U64 nrkey; -}; - - - -struct NvmeReservationKeyData { - - U64 crkey; -}; - - - -enum NvmeReservationReleaseAction { - NVME_RESERVE_RELEASE = 0x0, - NVME_RESERVE_CLEAR = 0x1, -}; - - -enum NvmeReservationNotificationLogPageType { - NVME_RESERVATION_LOG_PAGE_EMPTY = 0x0, - NVME_REGISTRATION_PREEMPTED = 0x1, - NVME_RESERVATION_RELEASED = 0x2, - NVME_RESERVATION_PREEMPTED = 0x3, -}; - - -struct NvmeReservationNotificationLog { - - U64 logPageCount; - - U8 type; - - U8 numAvailLogPages; - U8 reserved[2]; - U32 nsid; - U8 reserved1[48]; -}; - - - - -#define NVME_REGISTRATION_PREEMPTED_MASK (1U << 1) - -#define NVME_RESERVATION_RELEASED_MASK (1U << 2) - -#define NVME_RESERVATION_PREEMPTED_MASK (1U << 3) - - - - -#define NVME_LOG_PAGE_DW10_SPICE(dw10, lid, logLen) (dw10) = ((((logLen) >> 2) - 1) << 16) | (lid) -#define NVME_LOG_PAGE_RETAIN_BIT_SET(dw10) (dw10) |= 1UL << 15 - - -enum NvmeLogPage { - - - - NVME_LOG_ERROR = 0x01, - - - NVME_LOG_HEALTH_INFORMATION = 0x02, - - - NVME_LOG_FIRMWARE_SLOT = 0x03, - - - NVME_LOG_CHANGED_NS_LIST = 0x04, - - - NVME_LOG_COMMAND_EFFECTS_LOG = 0x05, - - - NVME_LOG_DEVICE_SELF_TEST = 0x06, - - - NVME_LOG_TELEMETRY_HOST_INITIATED = 0x07, - - - NVME_LOG_TELEMETRY_CTRLR_INITIATED = 0x08, - - - - - NVME_LOG_DISCOVERY = 0x70, - - - - - NVME_LOG_RESERVATION_NOTIFICATION = 0x80, - - - NVME_LOG_SANITIZE_STATUS = 0x81, - - - - -}; - -enum { - NVME_NO_LOG_LSP = 0x0, - NVME_NO_LOG_LPO = 0x0, - NVME_LOG_ANA_LSP_RGO = 0x1, - NVME_TELEM_LSP_CREATE = 0x1, -}; - - -struct NvmeErrorInformationEntry { - U64 errorCount; - U16 sqid; - U16 cid; - struct NvmeCmdStatus status; - U16 errorLocation; - U64 lba; - U32 nsid; - U8 vendorSpecific; - U8 trtype; - U8 reserved30[2]; - U64 commandSpecific; - U16 trtypeSpecific; - U8 reserved42[22]; -}; - - -union NvmeCriticalWarningState { - U8 raw; - - struct { - U8 availableSpare : 1, - temperature : 1, - deviceReliability : 1, - readOnly : 1, - volatileMemoryBackup : 1, - persistentMemRO : 1, - reserved : 2; - }; -}; - - - -#ifndef _WINDOWS -typedef struct __attribute__((packed)) __attribute__((aligned)) -NvmeHealthInformationPage { -#else -#pragma pack(1) -typedef struct NvmeHealthInformationPage { -#endif - union NvmeCriticalWarningState criticalWarning; - - U16 temperature; - U8 availableSpare; - U8 availableSpareThreshold; - U8 percentageUsed; - U8 enduGrpCritWarnSumry; - - U8 reserved[25]; - - - U64 dataUnitsRead[2]; - - U64 dataUnitsWritten[2]; - - U64 hostReadCommands[2]; - U64 hostWriteCommands[2]; - - U64 controllerBusyTime[2]; - U64 powerCycles[2]; - U64 powerOnHours[2]; - U64 unsafeShutdowns[2]; - U64 mediaErrors[2]; - U64 numErrorInfoLogEntries[2]; - - U32 warningTempTime; - U32 criticalTempTime; - U16 tempSensor[8]; - - U8 reserved2[296]; -}NvmeHealthInformationPage_s; - - -#ifdef _WINDOWS -#pragma pack() -#endif - -struct NvmeCmdsAndEffectEntry { - - U16 csupp : 1; - - - U16 lbcc : 1; - - - U16 ncc : 1; - - - U16 nic : 1; - - - U16 ccc : 1; - - U16 reserved1 : 11; - - U16 cse : 3; - - U16 reserved2 : 13; -}; - - -struct NvmeCmdsAndEffectLogPage { - - struct NvmeCmdsAndEffectEntry adminCmdsSupported[256]; - - - struct NvmeCmdsAndEffectEntry ioCmdsSupported[256]; - - U8 reserved0[2048]; -}; - - - -#ifndef _WINDOWS -struct __attribute__((packed)) NvmeSelfTestResEntry { -#else -#pragma pack(1) -struct NvmeSelfTestResEntry { -#endif - U8 operationRes : 4, - selfTestCode : 4; - U8 segmentNum; - U8 nsIdValid : 1, - flbaValid : 1, - sctValid : 1, - scValid : 1, - reserved1 : 4; - U8 reserved2; - U64 poh; - U32 nsId; - U64 failingLba; - U8 sct : 3, - reserved3 : 5; - U8 sc; - U16 vendorSpecific; -}; -#ifdef _WINDOWS -#pragma pack() -#endif -#ifndef _WINDOWS -typedef struct __attribute__((packed)) NvmeSelfTestLogPage { -#else -#pragma pack(1) -typedef struct NvmeSelfTestLogPage { -#endif - - U8 currtOpt : 4, - reserved1 : 4; - U8 currtComplt : 7, - reserved2 : 1; - U16 reserved3; - struct NvmeSelfTestResEntry newSelfTestRes[20]; -}NvmeSelfTestLogPage_s; -#ifdef _WINDOWS -#pragma pack() -#endif - - -struct NvmeTelemetryLogPageHdr { - - U8 lpi; - U8 rsvd[4]; - U8 ieeeOui[3]; - - U16 dalb1; - - U16 dalb2; - - U16 dalb3; - U8 rsvd1[368]; - - U8 ctrlrAvail; - - U8 ctrlrGen; - - U8 rsnident[128]; - U8 telemetryDatablock[0]; -}; - - - -enum NvmeSanitizeStatusType { - NVME_NEVER_BEEN_SANITIZED = 0x0, - NVME_RECENT_SANITIZE_SUCCESSFUL = 0x1, - NVME_SANITIZE_IN_PROGRESS = 0x2, - NVME_SANITIZE_FAILED = 0x3, -}; - - -struct NvmeSanitizeStatusSstat { - U16 status : 3; - U16 completePass : 5; - U16 globalDataErase : 1; - U16 reserved : 7; -}; - - -struct NvmeSanitizeStatusLogPage { - - U16 sprog; - - struct NvmeSanitizeStatusSstat sstat; - - U32 scdw10; - - U32 etOverwrite; - - U32 etBlockErase; - - U32 etCryptoErase; - U8 reserved[492]; -}; - - - - -enum NvmeAsyncEventType { - - NVME_ASYNC_EVENT_TYPE_ERROR = 0x0, - - NVME_ASYNC_EVENT_TYPE_SMART = 0x1, - - NVME_ASYNC_EVENT_TYPE_NOTICE = 0x2, - - - - NVME_ASYNC_EVENT_TYPE_IO = 0x6, - - NVME_ASYNC_EVENT_TYPE_VENDOR = 0x7, -}; - - -enum NvmeAsyncEventInfoError { - - NVME_ASYNC_EVENT_WRITE_INVALID_DB = 0x0, - - NVME_ASYNC_EVENT_INVALID_DB_WRITE = 0x1, - - NVME_ASYNC_EVENT_DIAGNOSTIC_FAILURE = 0x2, - - NVME_ASYNC_EVENT_PERSISTENT_INTERNAL = 0x3, - - NVME_ASYNC_EVENT_TRANSIENT_INTERNAL = 0x4, - - NVME_ASYNC_EVENT_FW_IMAGE_LOAD = 0x5, - - -}; - - -enum NvmeAsyncEventInfoSmart { - - NVME_ASYNC_EVENT_SUBSYSTEM_RELIABILITY = 0x0, - - NVME_ASYNC_EVENT_TEMPERATURE_THRESHOLD = 0x1, - - NVME_ASYNC_EVENT_SPARE_BELOW_THRESHOLD = 0x2, - - -}; - - -enum NvmeAsyncEventInfoNotice { - - NVME_ASYNC_EVENT_NS_ATTR_CHANGED = 0x0, - - NVME_ASYNC_EVENT_FW_ACTIVATION_START = 0x1, - - NVME_ASYNC_EVENT_TELEMETRY_LOG_CHANGED = 0x2, - - -}; - - -enum NvmeAsyncEventInfoNvmCommandSet { - - NVME_ASYNC_EVENT_RESERVATION_LOG_AVAIL = 0x0, - - NVME_ASYNC_EVENT_SANITIZE_COMPLETED = 0x1, - - -}; - - -union NvmeAsyncEventCompletion { - U32 raw; - struct { - U32 asyncEventType : 3; - U32 reserved1 : 5; - U32 asyncEventInfo : 8; - U32 logPageIdentifier : 8; - U32 reserved2 : 8; - }; -}; - - - -union NvmeFeatArbitration { - U32 raw; - struct { - - U32 ab : 3; - - U32 reserved : 5; - - - U32 lpw : 8; - - - U32 mpw : 8; - - - U32 hpw : 8; - }; -}; - - - -union NvmeFeatPowerManagement { - U32 raw; - struct { - - U32 ps : 5; - - - U32 wh : 3; - - U32 reserved : 24; - }; -}; - - - -union NvmeFeatLbaRangeType { - U32 raw; - struct { - - U32 num : 6; - - U32 reserved : 26; - }; -}; - - - -union NvmeFeatTemperatureThreshold { - U32 raw; - struct { - - U32 tmpth : 16; - - - U32 tmpsel : 4; - - - U32 thsel : 2; - - U32 reserved : 10; - }; -}; - - - - -union NvmeFeatErrorRecovery { - U32 raw; - struct { - - U32 tler : 16; - - - U32 dulbe : 1; - - U32 reserved : 15; - }; -}; - - - -union NvmeFeatVolatileWriteCache { - U32 raw; - struct { - - U32 wce : 1; - - U32 reserved : 31; - }; -}; - - - -union NvmeFeatNumberOfQueues { - U32 raw; - struct { - - U32 nsqr : 16; - - - U32 ncqr : 16; - }; -}; - - - -union NvmeFeatInterruptCoalescing { - U32 raw; - struct { - - U32 thr : 8; - - - U32 time : 8; - - U32 reserved : 16; - }; -}; - - - - -union NvmeFeatInterruptVectorConfiguration { - U32 raw; - struct { - - U32 iv : 16; - - - U32 cd : 1; - - U32 reserved : 15; - }; -}; - - - - -union NvmeFeatWriteAtomicity { - U32 raw; - struct { - - U32 dn : 1; - - U32 reserved : 31; - }; -}; - - - - -union NvmeFeatAsyncEventConfiguration { - U32 raw; - struct { - union NvmeCriticalWarningState critWarn; - U32 nsAttrNotice : 1; - U32 fwActivationNotice : 1; - U32 telemetryLogNotice : 1; - U32 reserved : 21; - }; -}; - - - -#define NvmeAsyncEventConfig NvmeFeatAsyncEventConfiguration - - - -union NvmeFeatAutonomousPowerStateTransition { - U32 raw; - struct { - - U32 apste : 1; - - U32 reserved : 31; - }; -}; - - - - -union NvmeFeatHostMemBuffer { - U32 raw; - struct { - - U32 ehm : 1; - - - U32 mr : 1; - - U32 reserved : 30; - }; -}; - - - -union NvmeFeatKeepAliveTimer { - - U32 kato; -}; - - - - -union NvmeFeatHostControlledThermalManagement { - U32 raw; - struct { - - U32 tmt2 : 16; - - - U32 tmt1 : 16; - }; -}; - - - - - -union NvmeFeatNonOperationalPowerStateConfig { - U32 raw; - struct { - - U32 noppme : 1; - - U32 reserved : 31; - }; -}; - - - - - -union NvmeFeatSoftwareProgressMarker { - U32 raw; - struct { - - U32 pbslc : 8; - U32 reserved : 24; - }; -}; - - - - -union NvmeFeatHostIdentifier { - U32 raw; - struct { - - U32 exhid : 1; - - U32 reserved : 31; - }; -}; - - - -struct NvmeFirmwarePage { - U8 afi; - - U8 reserved[7]; - U8 revision[7][8]; - U8 reserved2[448]; -}; - - - -enum NvmeNsAttachType { - - NVME_NS_CTRLR_ATTACH = 0x0, - - - NVME_NS_CTRLR_DETACH = 0x1, - - -}; - - -enum NvmeNsManagementType { - - NVME_NS_MANAGEMENT_CREATE = 0x0, - - - NVME_NS_MANAGEMENT_DELETE = 0x1, - - -}; - -struct NvmeNsList { - U32 nsList[1024]; -}; - - -enum NvmeNidt { - - NVME_NIDT_EUI64 = 0x01, - - - NVME_NIDT_NGUID = 0x02, - - - NVME_NIDT_UUID = 0x03, -}; - -struct NvmeNsIdDesc { - - U8 nidt; - - - U8 nidl; - - U8 reserved2; - U8 reserved3; - - - U8 nid[]; -}; - - -typedef struct NvmeCtrlrList { - U16 ctrlrCount; - U16 ctrlrList[2047]; -}NvmeCtrlrList_s; - - -enum NvmeSecureEraseSetting { - NVME_FMT_NVM_SES_NO_SECURE_ERASE = 0x0, - NVME_FMT_NVM_SES_USER_DATA_ERASE = 0x1, - NVME_FMT_NVM_SES_CRYPTO_ERASE = 0x2, -}; - -enum NvmePiLocation { - NVME_FMT_NVM_PROTECTION_AT_TAIL = 0x0, - NVME_FMT_NVM_PROTECTION_AT_HEAD = 0x1, -}; - -enum NvmePiType { - NVME_FMT_NVM_PROTECTION_DISABLE = 0x0, - NVME_FMT_NVM_PROTECTION_TYPE1 = 0x1, - NVME_FMT_NVM_PROTECTION_TYPE2 = 0x2, - NVME_FMT_NVM_PROTECTION_TYPE3 = 0x3, -}; - -enum NvmeMetadataSetting { - NVME_FMT_NVM_METADATA_TRANSFER_AS_BUFFER = 0x0, - NVME_FMT_NVM_METADATA_TRANSFER_AS_LBA = 0x1, -}; - -struct NvmeFormat { - U32 lbaf : 4; - U32 ms : 1; - U32 pi : 3; - U32 pil : 1; - U32 ses : 3; - U32 reserved : 20; -}; - - -struct NvmeProtectionInfo { - U16 guard; - U16 appTag; - U32 refTag; -}; - - - -enum NvmeFwCommitAction { - NVME_FW_COMMIT_REPLACE_IMG = 0x0, - NVME_FW_COMMIT_REPLACE_AND_ENABLE_IMG = 0x1, - NVME_FW_COMMIT_ENABLE_IMG = 0x2, - NVME_FW_COMMIT_RUN_IMG = 0x3, -}; - - -enum NvmeDeviceSelfTestCode { - NVME_SHORT_DEVICE_SELF_TEST_OPT = 0x1, - NVME_EXTENDED_DEVICE_SELF_TEST_OPT = 0x2, - NVME_ABORT_DEVICE_SELF_TEST_OPT = 0xF, -}; - - -struct NvmeFwCommit { - U32 fs : 3; - U32 ca : 3; - U32 reserved : 26; -}; - - -#define NVME_CPL_IS_SUCCESS(cpl) (!NVME_CMD_STATUS_NOT_SUCCESS(cpl)) - -#define NVME_CMD_STATUS_NOT_SUCCESS(cpl) \ - ((cpl)->status.sc != NVME_SC_SUCCESS || \ - (cpl)->status.sct != NVME_SCT_GENERIC) - -#define NVME_STATUS_CMD_ABORT_REQUEST(cpl) \ - ((cpl)->status.sc == NVME_SC_ABORTED_BY_REQUEST && \ - (cpl)->status.sct == NVME_SCT_GENERIC) - -#define NVME_CPL_PI_IS_ERROR(cpl) \ - ((cpl)->status.sct == NVME_SCT_MEDIA_ERROR && \ - ((cpl)->status.sc == NVME_SC_GUARD_CHECK_ERROR || \ - (cpl)->status.sc == NVME_SC_APPLICATION_TAG_CHECK_ERROR || \ - (cpl)->status.sc == NVME_SC_REFERENCE_TAG_CHECK_ERROR)) - - - -#define NVME_IO_FLAGS_PRCHK_REFTAG (1U << 26) - -#define NVME_IO_FLAGS_PRCHK_APPTAG (1U << 27) - -#define NVME_IO_FLAGS_PRCHK_GUARD (1U << 28) - -#define NVME_IO_FLAGS_PRACT (1U << 29) -#define NVME_IO_FLAGS_FORCE_UNIT_ACCESS (1U << 30) -#define NVME_IO_FLAGS_LIMITED_RETRY (1U << 31) - -#define NVME_FORMAT_SES_BIT_MASK 0x7UL -#define NVME_FORMAT_SES_BIT_SHIFT 9 -#define NVME_LBAF_MASK 0xFUL -#define NVME_FORMAT_SES_TYPE_NONE 0x0 -#define NVME_FORMAT_SES_TYPE_USER_DATA_ERASE 0x1 -#define NVME_FORMAT_SES_TYPE_CRYPTO_ERASE 0x2 -typedef union NvmeFormatCmdDw10 { - struct { - U32 lbaf:4; - U32 mset:1; - U32 pi:3; - U32 pil:1; - U32 ses:1; - U32 reseved:3; - }; - U32 rawVal; -} NvmeFormatCmdDw10_u; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_trace_id.h b/drivers/scsi/linkdata/ps3stor/include/ps3_trace_id.h deleted file mode 100644 index a442d81e62ff..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_trace_id.h +++ /dev/null @@ -1,40 +0,0 @@ - -#ifndef __PS3_TRACE_ID_H__ -#define __PS3_TRACE_ID_H__ - -#define TRACE_ID_CHIP_OUT_COUNT_MASK 0x000FFFFFFFFFFFFFLLU - -#define TRACE_ID_CHIP_OUT_CPUID_SHIFT 52 -#define TRACE_ID_CHIP_OUT_CPUID_MASK 0x7FFLLU - -static inline void traceIdCpuIdSet(unsigned long long *traceId, unsigned short cpuId) -{ - *traceId &= ~(TRACE_ID_CHIP_OUT_CPUID_MASK << TRACE_ID_CHIP_OUT_CPUID_SHIFT); - *traceId |= ((unsigned long long)cpuId & TRACE_ID_CHIP_OUT_CPUID_MASK) << \ - TRACE_ID_CHIP_OUT_CPUID_SHIFT; -} - -#define TRACE_ID_CLI_COUNT_MASK 0x00000000000000FFLLU -#define TRACE_ID_CLI_TID_MASK 0x0000000000FFFF00LLU -#define TRACE_ID_CLI_TIME_MASK 0x00FFFFFFFF000000LLU -#define TRACE_ID_CLI_FLAG 0xFF00000000000000LLU - -#define TRACE_ID_CLI_COUNT_SHIFT 0 -#define TRACE_ID_CLI_TID_SHIFT 8 -#define TRACE_ID_CLI_TIME_SHIFT 24 -#define TRACE_ID_CLI_FLAG_SHIFT 56 - -#define TRACE_ID_CHIP_IN_COUNT_MASK 0x00FFFFFFFFFFFFFFLLU -#define TRACE_ID_CHIP_IN_FLAG 0x8000000000000000LLU - -#define TRACE_ID_CHIP_IN_CONTEXTID_SHIFT 56 -#define TRACE_ID_CHIP_IN_CONTEXTID_MASK 0x7FLLU - -static inline void traceIdContextIdSet(unsigned long long *traceId, unsigned short contextId) -{ - *traceId &= ~(TRACE_ID_CHIP_IN_CONTEXTID_MASK << TRACE_ID_CHIP_IN_CONTEXTID_SHIFT); - *traceId |= ((unsigned long long)contextId & TRACE_ID_CHIP_IN_CONTEXTID_MASK) << \ - TRACE_ID_CHIP_IN_CONTEXTID_SHIFT; -} - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3_types.h b/drivers/scsi/linkdata/ps3stor/include/ps3_types.h deleted file mode 100644 index 4cae41978055..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3_types.h +++ /dev/null @@ -1,123 +0,0 @@ - -#ifndef __PS3_TYPES_H__ -#define __PS3_TYPES_H__ - -#ifdef __cplusplus -extern "C"{ -#endif - -#ifndef __KERNEL__ -#include -#endif - -typedef unsigned char U8; -typedef unsigned short U16; -typedef unsigned int U32; -typedef unsigned long ULong; -typedef unsigned long long U64; - -typedef char S8; -typedef short S16; -typedef int S32; -typedef long Long; -typedef long long S64; - -typedef U32 CtrlId_t; -typedef S32 Ps3Errno; -typedef U16 DgId_t; -typedef U16 VdId_t; -typedef U16 PdId_t; -typedef U8 EnclId_t; -typedef U16 SlotId_t; -typedef U8 PhyId_t; - -#define PS3_FALSE 0 -#define PS3_TRUE 1 -typedef int Ps3Bool_t; - -#ifndef BOOL -#define BOOL Ps3Bool_t -#endif - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#ifndef likely -#define likely(x) __builtin_expect(!!(x), 1) -#endif - -#ifndef unlikely -#define unlikely(x) __builtin_expect(!!(x), 0) -#endif - -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t)(&((TYPE *)0)->MEMBER)) -#endif - - -#ifndef PS3_MIN -#define PS3_MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - - -#ifndef PS3_MAX -#define PS3_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - - -#ifndef PS3_MIN_NON_ZERO -#define PS3_MIN_NON_ZERO(a, b) ((a) == 0 ? (b) : \ - ((b) == 0 ? (a) : (PS3_MIN(a, b)))) -#endif - -#ifndef TYPEOF -#ifdef __cplusplus -#define TYPEOF decltype -#else -#define TYPEOF typeof -#endif -#endif - -#ifndef container_of -#ifndef PCLINT -#define container_of(ptr, type, member) ({ \ - const TYPEOF( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#else -#define container_of(ptr, type, member) \ - ((type *)(void *)(char *)ptr) -#endif -#endif - -#ifndef PS3_DESC -#define PS3_DESC(a) 1 -#endif - - -#ifndef PS3_IN -#define PS3_IN -#endif - -#ifndef PS3_OUT -#define PS3_OUT -#endif - -typedef Ps3Bool_t (*RmCheckFunc)(void *pSubSchedTask); - -typedef union RmMiscInfo -{ - struct { - U8 idx; - U8 status; - U8 valid; - U8 hasInQueued; - }; - U32 val; -}RmMiscInfo_s; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/include/ps3lib/ps3lib_event.h b/drivers/scsi/linkdata/ps3stor/include/ps3lib/ps3lib_event.h deleted file mode 100644 index 624e4563b992..000000000000 --- a/drivers/scsi/linkdata/ps3stor/include/ps3lib/ps3lib_event.h +++ /dev/null @@ -1,789 +0,0 @@ - -#ifndef __PS3LIB_EVENT_H__ -#define __PS3LIB_EVENT_H__ - -#if defined(__cplusplus) -extern "C" { -#endif - -#define PS3LIB_MAX_VD_NAME_BYTES (16) -#define PS3LIB_CTRL_AUTOCONFIG_EVTDATA_SIZE (8) -#define PS3LIB_BBM_ERRTBL_NAME_LEN (6) -#define PS3LIB_EVT_DESC_MAX_LEN (4096) -#define PS3LIB_FGI_MODE_LEN (5) -#define PS3LIB_EVT_LOG_INFO_MAX_SIZE (116) -#define PS3LIB_EXP_EVENT_DATA_COLLECT_MAX_NUM (256) -#define PS3LIB_MAX_EVENT_REG_CNT (128) - -enum { - PS3LIB_EVT_LOG_OLDEST, - PS3LIB_EVT_LOG_LATEST, - PS3LIB_EVT_LOG_LAST_CLEAR, - PS3LIB_EVT_LOG_LAST_REBOOT, - PS3LIB_EVT_LOG_LAST_SHUTDOWN, - PS3LIB_EVT_LOG_FATAL_OLDEST, - PS3LIB_EVT_LOG_FATAL_LATEST, - PS3LIB_EVT_LOG_LAST_MAX, -}; - -typedef enum Ps3LibEpEventLevel -{ - PS3LIB_EVT_CLASS_UNKNOWN = 0b0000, - PS3LIB_EVT_CLASS_DEBUG = 0b0011, - PS3LIB_EVT_CLASS_PROCESS = 0b0101, - PS3LIB_EVT_CLASS_INFO = 0b0001, - PS3LIB_EVT_CLASS_WARNING = 0b0010, - PS3LIB_EVT_CLASS_CRITICAL = 0b0100, - PS3LIB_EVT_CLASS_FATAL = 0b1000, - PS3LIB_EVT_CLASS_MAX, -} Ps3LibEpEventLevel_e; - -enum -{ - PS3LIB_CTRL_EVT_SAS_INFO_LOCAL = 1, - PS3LIB_CTRL_EVT_PD_COUNT_LOCAL = 2, - PS3LIB_CTRL_EVT_VD_COUNT_LOCAL = 3, - PS3LIB_CTRL_EVT_CTRL_INFO_LOCAL = 4, - PS3LIB_CTRL_EVT_PD_ATTR_LOCAL = 5, - PS3LIB_CTRL_EVT_VD_ATTR_LOCAL = 6, - PS3LIB_CTRL_EVT_DG_INFO_LOCAL = 7, - PS3LIB_CTRL_EVT_BBU_INFO_LOCAL = 8, - PS3LIB_CTRL_EVT_CONFIG_LOCAL = 9, - PS3LIB_CTRL_EVT_IO_INFO_LOCAL = 10, - PS3LIB_CTRL_EVT_UKEY_INFO_LOCAL = 11, - PS3LIB_CTRL_EVT_HWR_INFO_LOCAL = 12, - PS3LIB_CTRL_EVT_ALARM_INFO_LOCAL = 13, - PS3LIB_CTRL_EVT_ECC_INFO_LOCAL = 14, - PS3LIB_CTRL_EVT_UPGRADE_INFO_LOCAL = 15, - PS3LIB_CTRL_EVT_TEMP_INFO_LOCAL = 16, - PS3LIB_CTRL_EVT_PD_ATTR_EXTEND_LOCAL = 17, - PS3LIB_CTRL_EVT_DEFAULT_UNUSED_LOCAL, - PS3LIB_CTRL_EVT_MAX_TYPE_LOCAL, -}; - -typedef struct Ps3LibEvtLogRdEntry { - U32 loopCnt; - U32 seqNum; - U32 offset; - U32 timeStampBySec; - U32 size; -} Ps3LibEvtLogRdEntry_s; - -typedef struct Ps3LibEvtLogRdInfo { - Ps3LibEvtLogRdEntry_s persistInfo[PS3LIB_EVT_LOG_LAST_MAX]; -} Ps3LibEvtLogRdInfo_s; - -typedef struct Ps3LibEvtPersistInfo { - U32 regionSz[2]; - Ps3LibEvtLogRdInfo_s persist; -} Ps3LibEvtPersistInfo_s; - -typedef struct Ps3LibEvtLogHeader { - U32 magic; - U32 seqNum; - U32 size : 8; - U32 funcType : 2; - U32 conFlag : 1; - U32 evtCode : 12; - U32 level : 4; - U32 type : 5; - U32 timeStampBySec; -} Ps3LibEvtLogHeader_s; - -#pragma pack(1) - -typedef struct Ps3LibPdAttrInfo { - U32 checkSum : 8; - U32 enclosureId : 8; - U32 phyId : 8; - U32 evtVersion : 8; - U16 phyDiskID; - U16 softChan : 4; - U16 devID : 12; - U16 slotId; - U16 oldState : 4; - U16 newState : 4; - U16 isEnclPd : 1; - U16 longFault : 1; - U16 reason : 6; - U16 arrayId : 8; - U16 rowId : 8; - U16 prevState : 8; - U16 curState : 8; - U64 sasAddr; -}Ps3LibPdAttrInfo_s; - -typedef struct Ps3LibSparePdInfo { - Ps3LibPdAttrInfo_s baseInfo; - U8 dedicatedDgCnt; - U8 reserved[3]; - U16 dedicatedDgId[8]; -}Ps3LibSparePdInfo_s; - -typedef struct Ps3LibVdAttrInfo { - U32 magicNum; - U16 virtDiskID; - U16 softChan : 4, - devID : 12; - U16 diskGrpId; - U16 locked : 1, - pad : 15; -}Ps3LibVdAttrInfo_s; - -typedef struct Ps3LibDiskPFCfgModifyEvtInfo { - U8 modifyCfgDataType; - U8 funcIsEnable:1; - U8 pad : 7; - U16 preFailPollTimeMin; -}Ps3LibDiskPFCfgModifyEvtInfo_s; - -typedef struct Ps3LibVdBaseSetting { - U32 accessPolicy :2, - hidden :1, - defaultWriteCachePolicy :2, - currentWriteCachePolicy :1, - defaultReadCachePolicy :1, - currentReadCachePolicy :1, - diskCachePolicy :2, - ioPolicy :1, - noBgi :1, - emulationType :2, - unmap :1, - cbSize :2, - cbMode :3, - encryption :1, - rebootNoVerify :1, - rsv :10; - U8 vdName[PS3LIB_MAX_VD_NAME_BYTES]; - U64 size; -}Ps3LibVdBaseSetting_s; - -typedef struct Ps3LibVdPropertiesInfo { - Ps3LibVdAttrInfo_s baseInfo; - Ps3LibVdBaseSetting_s oldSetting; - Ps3LibVdBaseSetting_s newSetting; -}Ps3LibVdPropertiesInfo_s; - -typedef struct Ps3LibVdStateChangeInfo { - Ps3LibVdAttrInfo_s baseInfo; - U8 oldVdState; - U8 newVdState; - U8 reserved[2]; -}Ps3LibVdStateChangeInfo_s; - -typedef struct Ps3LibVdCreateEvtInfo { - Ps3LibVdAttrInfo_s baseInfo; - Ps3LibVdBaseSetting_s setting; -}Ps3LibVdCreateEvtInfo_s; - -typedef struct Ps3LibCtrlAttrInfo { - U32 supportUnevenSpans : 1; - U32 supportJbodSecure : 1; - U32 supportCrashDump : 1; - U32 supportNvmePassthru : 1; - U32 supportDirectCmd : 1; - U32 supportAcceleration : 1; - U32 supportNcq : 1; - U32 reserved1 : 25; - U32 reserved2[1]; - U64 oldSysTime; - U64 newSysTIme; - U64 monoSysTime; - U32 newSysTimeYear; - U32 newSysTimeMon; - U32 newSysTimeDay; - U32 newSysTimeHour; - U32 newSysTimeMin; - U32 newSysTimeSec; - U64 cfgNum; - U8 *pValue; - U32 len; -}Ps3LibCtrlAttrInfo_s; - -typedef struct Ps3LibCtrlRebootInfo { - U16 ctrlBootMode; - U16 ctrlShutDownReason; - - - - - - U32 regBootValue; -}Ps3LibCtrlRebootInfo_s; - -typedef struct Ps3LibDgAttrInfo { - U16 dgId; - U16 reserved[3]; -}Ps3LibDgAttrInfo_s; - -typedef struct Ps3LibExpanderInfo { - U8 EnclId; - U8 port; - U8 reserved[6]; -}Ps3LibExpanderInfo_s; - -typedef struct Ps3LibCfgAttrInfo { - U16 profileId; - U8 reserved[2]; -}Ps3LibCfgAttrInfo_s; - -typedef struct Ps3LibCfgAutoConfig { - S8 cfgName[PS3LIB_CTRL_AUTOCONFIG_EVTDATA_SIZE]; -}Ps3LibCfgAutoConfig_s; - -typedef struct Ps3LibCtrlPowerMode { - U8 mode; - U8 rsv[3]; -}Ps3LibCtrlPowerMode_s; - -typedef struct Ps3LibBgtRebuildInfo { - U16 newPDFlatId; - U16 newEnclosureId; - U16 newSlotId; - U16 oldPDFlatId; - U16 oldEnclosureId; - U16 oldSlotId; - U16 virtDiskId; - U16 devId; - U32 remainSecs; - U64 errorPba; - U64 errorLba; - U8 progressPercent; - U8 rebuildRate; - U8 enableMoveback; - U8 autoRebuild; - U8 eghs; - U8 enablePdm; - U8 pdmSupportReadyPd; - U8 reserved[1]; - U32 pdmTimerInterval; -} Ps3LibBgtRebuildInfo_s; - -typedef struct Ps3LibBgtInitEvtInfo { - U32 aliveSec; - U32 progressRate; - U16 dgId; - U16 virtDiskId; - U16 pdFlatId; - U16 enclosureId; - U16 slotId; - U8 cpuRate; - S8 mode[PS3LIB_FGI_MODE_LEN]; - U64 mediumErrLba; - U64 mediumErrPba; - U16 MediumErrPdFlatId; - U16 softChan : 4; - U16 devID : 12; -} Ps3LibBgtInitEvtInfo_s; - -typedef struct Ps3LibBgtEraseEvtInfo { - U32 aliveSec; - U32 progressRate; - U16 dgId; - U16 virtDiskId; - U16 pdFlatId; - U16 enclosureId; - U16 slotId; - U16 devId; -} Ps3LibBgtEraseEvtInfo_s; - -typedef struct Ps3LibBgtCcEvtInfo { - U32 aliveSecs; - U8 progressPercent; - U8 ccRate; - U8 mode; - U8 resered; - U16 virtDiskID; - U16 diskGroupID; - U32 inconsistStrip; - U16 devId; - U16 faultDiskID; - U16 enclosureId; - U16 slotId; - U64 pdErrLba; - U64 vdErrLba; -}Ps3LibBgtCcEvtInfo_s; - -typedef struct Ps3LibBgtPrEvtInfo { - U32 aliveSecs; - U16 enclosureId; - U16 slotId; - U8 progressPercent; - U8 prRate; - U16 virtDiskID; - U16 pdFlatId; - U16 diskGroupID; - U16 dgStatus; - U8 reserved[2]; - U64 errLba; -}Ps3LibBgtPrEvtInfo_s; - -typedef struct Ps3LibPhyEvtInfo { - U32 enclosureId:8, - slotId:8, - phyId:8, - reason:8; -} Ps3LibPhyEvtInfo_s; - -typedef struct Ps3LibVdBbmEvtInfo { - U64 lba; - U64 pba; - U16 lbaLen; - U16 dgId; - U16 virtDiskId; - U16 percentErrTbl; - U16 devId; - S8 errTblName[PS3LIB_BBM_ERRTBL_NAME_LEN]; - U16 pdFlatId; - U16 enclosureId; - U16 slotId; - U16 reserved; -} Ps3LibVdBbmEvtInfo_s; - -typedef struct Ps3LibRwDdtEvtInfo { - U16 virtDiskID; - U16 diskGroupID; - U32 vdLen; - U64 vdLba; -} Ps3LibRwDdtEvtInfo_s; - -typedef struct Ps3LibFlushEvtInfo { - U16 opcode; - U16 dgId; - U16 virtDiskId; - U16 minVdId; - U16 devId; - U8 reserved[6]; - U64 vdIdMap[3]; -} Ps3LibFlushEvtInfo_s; - -typedef struct Ps3LibMigrationInfo { - U8 migrRate; - U8 resv; - U16 diskGroupID; - U32 percent; - U32 aliveSec; - U16 currVdId; - U8 reserved[2]; -} Ps3LibMigrationInfo_s; - -typedef struct Ps3LibVdBbmBatchEvtInfo -{ - U32 count; - Ps3LibVdBbmEvtInfo_s vdBbmEvtInfo[0]; -} Ps3LibVdBbmBatchEvtInfo_s; - -typedef struct Ps3LibVdBatchEvtInfo -{ - U32 count; - Ps3LibVdAttrInfo_s vdInfo[0]; -}Ps3LibVdBatchEvtInfo_s; - -typedef struct Ps3LibPdBatchEvtInfo -{ - U32 count; - Ps3LibPdAttrInfo_s pdInfo[0]; -}Ps3LibPdBatchEvtInfo_s; - -typedef struct Ps3LibCtrlBatchEvtInfo -{ - U32 count; - Ps3LibCtrlAttrInfo_s ctrlInfo[0]; -}Ps3LibCtrlBatchEvtInfo_s; - -typedef struct Ps3libBatchEvtInfoCommon -{ - U32 count; - S8 batchInfo[0]; -}Ps3libBatchEvtInfoCommon_s; - -typedef struct Ps3LibBbuEvtInfo { - U8 absent : 1; - U8 overTemp : 1; - U8 overVol : 1; - U8 overCur : 1; - U8 overLoad : 1; - U8 lifeisOver : 1; - U8 reserved : 2; - U8 status; - U8 chargeStatus; - U8 learnStage; - S16 batTemperature; - U16 batVoltage; - S16 batCurrent; - U8 reserved1[2]; -} Ps3LibBbuEvtInfo_s; - -typedef struct Ps3LibUkeyEvtInfo { - U8 ukeyStatus; - U8 reserved[3]; -} Ps3LibUkeyEvtInfo_s; - -typedef struct Ps3LibExpEvtInfo { - U64 expanderSasAddr; - U64 attachedSasAddr; - U8 phyId[8]; -} Ps3LibExpEvtInfo_s; - -typedef struct Ps3LibEccEvtInfo { - U32 eccErrObj; - U32 eccSingleBitCntInc; - U8 eccErrCntThreshold; - U8 pad[3]; - U16 eccClearPeriod; - U8 eccType; - U8 eccErrSubObj; - U64 eccMutilErrAddr; - U32 eccEvtVersion; -} Ps3LibEccEvtInfo_s; - -typedef struct Ps3LibTempEvtInfo { - U32 tempType; - S32 tempErrThreshold[4]; - S32 temperature; -} Ps3LibTempEvtInfo_s; - -typedef struct Ps3LibIoCmdType { - U8 cmdType; - U8 rsv[9]; -} Ps3LibIoCmdType_s; - -typedef struct Ps3LibDeviceResetEvtInfo { - U16 enclosureId; - U16 slotId; - U16 phyDiskID; - U16 resetType; - U64 sasAddress; -} Ps3LibDeviceResetEvtInfo_s; - -typedef struct Ps3LibSenseDataEvtInfo { - U16 enclosureId; - U16 slotId; - U16 phyDiskID; - union { - U8 cdb[10]; - Ps3LibIoCmdType_s ioCmdType; - }; - U8 ioFormat; - U8 palErr; - U8 dataPre; - U8 scsiStatus; - U8 skStatus; - U8 sk; - U8 asc; - U8 ascq; - U64 path; -} Ps3LibSenseDataEvtInfo_s; - -typedef struct Ps3LibErrSenseEvtInfo { - U16 enclosureId; - U16 slotId; - U16 phyDiskID; - U8 CDBLen; - U8 senseLen; - U8 cdb[32]; - U8 senseData[56]; - U8 sk; - U8 asc; - U8 ascq; - U8 resv; - U64 path; -} Ps3LibErrSenseEvtInfo_s; - -typedef struct Ps3LibPdDownloadInfo { - U32 downloadMode; - S32 isSuccess; - U16 phyDiskID; - U16 softChan : 4; - U16 devID : 12; - U16 enclosureId; - U16 slotId; -}Ps3LibPdDownloadInfo_s; - -typedef struct Ps3LibSanitizeEvtInfo { - Ps3LibPdAttrInfo_s baseInfo; - U32 aliveSecs; - U8 progressPercent; - U8 pad[3]; -}Ps3LibSanitizeEvtInfo_s; - -typedef struct Ps3LibFormatEvtInfo { - Ps3LibPdAttrInfo_s baseInfo; - U32 aliveSecs; - U8 progressPercent; - U8 pad[3]; -}Ps3LibFormatEvtInfo_s; - -typedef struct Ps3LibSnapshotEvtInfo { - U8 snapCount; - U8 pad[3]; -}Ps3LibSnapshotEvtInfo_s; - -typedef struct Ps3LibPdPreFailInfo { - U32 checkSum : 8; - U32 oldState : 4; - U32 newState : 4; - U32 diskType : 4; - U32 pad : 12; - U16 phyDiskID; - U16 softChan : 4; - U16 devID : 12; - U16 enclosureId; - U16 slotId; - U32 historyErrBitMap; - U32 errBitMap; - S8 vendor[8]; - S8 diskSerialNum[24]; -}Ps3LibPdPreFailInfo_s; - -typedef struct Ps3LibNvDataInvaildInfo { - U32 nvDataIDBitMap[16]; - U16 bitmapSize; - U16 invaildCount; -} Ps3LibNvDataInvaildInfo_s; - -typedef struct Ps3LibSpeedNegoInfo { - U16 enclosureId; - U16 slotId; - S8 isPcie; - S8 speed; - U8 width; - U8 type; -}Ps3LibSpeedNegoInfo_s; - -typedef struct Ps3LibInitFailInfo { - U64 errCode; - U8 initFailCnt; - U8 pad[3]; -} Ps3LibInitFailInfo_s; - -typedef struct Ps3LibOemInfo { - S8 oemData[PS3LIB_EVT_LOG_INFO_MAX_SIZE]; -} Ps3LibOemInfo_s; - -typedef struct Ps3LibBplaneEvtInfo { - S8 bplaneData[PS3LIB_EVT_LOG_INFO_MAX_SIZE]; -} Ps3LibBplaneEvtInfo_s; - -typedef struct Ps3LibTriModeInfo { - U8 connectorId; - U8 subConnectorId; - U8 curMode; - U8 rev; -} Ps3LibTriModeInfo_s; - -typedef struct Ps3LibPhyChgInfo { - U8 portId; - U8 phyId; - U8 reason; - U8 rev; -} Ps3LibPhyChgInfo_s; - -typedef struct Ps3LibPhyInquiryInfo { - U32 pdId; - U16 slotId; - U16 enclosureId; - S8 vendor[9]; - S8 diskModelNum[41]; - S8 diskSerialNum[25]; - U8 rev; - U16 sectorSize; - U16 res; - U64 physicalSize; -} Ps3LibPhyInquiryInfo_s; - -typedef struct Ps3LibSmpFailInfo { - U8 enclId; - U8 function; - U8 rev[2]; - U32 code; -} Ps3LibSmpFailInfo_s; - -typedef union Ps3LibNvmeEvtInfo { - struct { - U8 sqe[64]; - U64 path; - U16 enclosureId; - U16 slotId; - U16 phyDiskId; - U16 sf; - U32 cmdSpecfic; - U32 type:8; - U32 isAdminCmd:1; - U32 rsvd:23; - }; -} Ps3LibNvmeEvtInfo_u; - -typedef struct Ps3LibSasSataLinkSpeedMatchInfo { - U8 channelId; - U8 lPhyId; - U8 linkSpeed; - U8 pad1; - U32 pad2; -} Ps3LibSasSataLinkSpeedMatchInfo_s; - -typedef struct Ps3LibSasSataLNExceptionInfo { - U8 channelId; - U8 lPhyId; - U16 pad1; - U32 type; - U32 status; - U32 pad2; -} Ps3LibSasSataLNExceptionInfo_s; - -typedef struct Ps3LibSasSataDriverInfo { - U8 channelId; - U8 lPhyId; - U16 pad1; - U32 type; - U32 status; - U32 pad2; -} Ps3LibSasSataDriverInfo_s; - -typedef union Ps3LibReportEvtData -{ - Ps3LibPdAttrInfo_s pdInfo; - Ps3LibSparePdInfo_s sparePdInfo; - Ps3LibVdAttrInfo_s vdInfo; - Ps3LibVdPropertiesInfo_s vdChange; - Ps3LibVdStateChangeInfo_s vdStateChangeInfo; - Ps3LibVdCreateEvtInfo_s vdCreate; - Ps3LibCtrlAttrInfo_s ctrlInfo; - Ps3LibCtrlRebootInfo_s ctrlRebootInfo; - Ps3LibDgAttrInfo_s dgInfo; - Ps3LibExpanderInfo_s expanderInfo; - Ps3LibCfgAttrInfo_s cfgInfo; - Ps3LibCfgAutoConfig_s autoConfigInfo; - - Ps3LibBgtRebuildInfo_s bgtRebuildInfo; - Ps3LibBgtInitEvtInfo_s bgtInitEvtInfo; - Ps3LibBgtEraseEvtInfo_s bgtEraseEvtInfo; - Ps3LibBgtCcEvtInfo_s bgtCcInfo; - - Ps3LibBgtPrEvtInfo_s bgtPrInfo; - - Ps3LibPhyEvtInfo_s phyInfo; - - Ps3LibVdBbmEvtInfo_s vdBbmEvtInfo; - Ps3LibRwDdtEvtInfo_s dataVdInfo; - - Ps3LibFlushEvtInfo_s flushEvtInfo; - - Ps3LibMigrationInfo_s bgtMigrInfo; - - Ps3LibVdBatchEvtInfo_s batchVdInfo; - Ps3LibPdBatchEvtInfo_s batchPdInfo; - Ps3LibCtrlBatchEvtInfo_s batchCtrlInfo; - Ps3LibVdBbmBatchEvtInfo_s batchBbmInfo; - Ps3libBatchEvtInfoCommon_s *pBatchCommonInfo; - Ps3LibBbuEvtInfo_s bbuEvtInfo; - Ps3LibUkeyEvtInfo_s ukeyInfo; - - Ps3LibExpEvtInfo_s expEvtInfo; - Ps3LibOemInfo_s oemEvtInfo; - Ps3LibBplaneEvtInfo_s bplaneEvtInfo; - Ps3LibEccEvtInfo_s eccEvtInfo; - Ps3LibTempEvtInfo_s tempEvtInfo; - Ps3LibDeviceResetEvtInfo_s deviceResetEvtInfo; - Ps3LibSenseDataEvtInfo_s senseDataEvtInfo; - Ps3LibErrSenseEvtInfo_s errSenseEvtInfo; - Ps3LibPdDownloadInfo_s pdDldEvtInfo; - Ps3LibSanitizeEvtInfo_s sanitizeInfo; - Ps3LibFormatEvtInfo_s formatInfo; - Ps3LibSnapshotEvtInfo_s snapShotInfo; - Ps3LibPdPreFailInfo_s pdPrefailInfo; - Ps3LibDiskPFCfgModifyEvtInfo_s diskPFCfgModifyEvtInfo; - Ps3LibNvDataInvaildInfo_s nvDataInvaildInfo; - Ps3LibCtrlPowerMode_s powerMode; - Ps3LibSpeedNegoInfo_s speedNegoInfo; - Ps3LibInitFailInfo_s initFailInfo; - Ps3LibTriModeInfo_s triModeInfo; - Ps3LibPhyChgInfo_s phyChgInfo; - Ps3LibPhyInquiryInfo_s phyInquiryInfo; - Ps3LibSmpFailInfo_s smpFailInfo; - Ps3LibNvmeEvtInfo_u nvmeInfo; - Ps3LibSasSataLinkSpeedMatchInfo_s sasSataLinkSpeedNoMatchInfo; - Ps3LibSasSataLNExceptionInfo_s sasSataLNExceptionInfo; - Ps3LibSasSataDriverInfo_s sasSataDriverInfo; - - - U64 value; - - - U8 data[PS3LIB_EVT_LOG_INFO_MAX_SIZE]; -}Ps3LibReportEvtData_u; -#pragma pack() - -typedef struct Ps3LibEvtLogEntry { - U32 seqNum; - Ps3LibEvtLogHeader_s head; - Ps3LibReportEvtData_u evtInfo; - CtrlId_t ctrlId; - CtrlId_t regCtrlId; - U32 registerId; - U32 pad; -} Ps3LibEvtLogEntry_s; - -typedef struct Ps3LibEvtLogList { - U32 count; - Ps3LibEvtLogEntry_s evtEntry[0]; -} Ps3LibEvtLogList_s; - -typedef struct Ps3LibEvtErrDataEntry { - U32 beforeSeqNum; - U32 errDataLen; - U8 *errData; -} Ps3LibEvtErrDataEntry_s; - -typedef struct Ps3LibEvtLog { - Ps3LibEvtPersistInfo_s evtPerInfo; - U32 evtCount; - U32 errCount; - Ps3LibEvtLogEntry_s * evtEntryList; - Ps3LibEvtErrDataEntry_s *errDataList; -} Ps3LibEvtLog_s; - -typedef struct Ps3LibEventDataCollectionKV { - char key[PS3LIB_EXP_EVENT_DATA_COLLECT_MAX_NUM]; - char val[PS3LIB_EXP_EVENT_DATA_COLLECT_MAX_NUM]; -} Ps3LibEventDataCollectionKV_s; - -typedef struct Ps3LibEventDataCollection { - struct Ps3LibEventDataCollectionKV kv[PS3LIB_EXP_EVENT_DATA_COLLECT_MAX_NUM]; -} Ps3LibEventDataCollection_s; - -enum { - PS3LIB_EXPANDER_EVENT_TYPE = 0, - PS3LIB_SWITCH_EVENT_TYPE = 1, - PS3LIB_RAID_HBA_EVENT_TYPE = 0xff, -}; - -typedef struct Ps3LibEvtPrintFunc{ - S8 const *(*evtCode2Str)(U32 opCode); - S8 const *(*evtLoca2Str)(U8 locate); - const S8 *(*getEvtDesc)(Ps3LibEvtLogEntry_s *event, S32 len, S8 *buff, S32 buffLen); - S32(*getEvtData) - (Ps3LibEventDataCollection_s *eventDataCollection, Ps3LibEvtLogEntry_s *event, S32 len, S8 *buff, S32 buffLen); -}Ps3LibEvtPrintFunc_t; - -Ps3LibEvtPrintFunc_t *ps3libEventPrintFunc(CtrlId_t ctrlId, U8 eventType); - -Ps3Errno ps3libCtrlEvtlogPerGet(CtrlId_t ctrlId, Ps3LibEvtPersistInfo_s *evtlogRdInfo); - -Ps3Errno ps3libEventLogGet(CtrlId_t ctrlId, U32 sinceSeqNum, Ps3LibEvtLog_s **ppEvtLog); - -void ps3libEventLogDestroy(Ps3LibEvtLog_s *pEvtLog); - -S32 ps3libEvtLevelCompare(U8 levelA, U8 levelB); - -Ps3Errno ps3libCtrlEventLogsDelete(CtrlId_t ctrlId); - -U32 ps3libEventUinqueIdToCtrlId(U32 uniqueId); - - - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c index d58436082638..a04c684ba8fa 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_base.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -41,15 +42,15 @@ #include "ps3_err_inject.h" #include "ps3_r1x_write_lock.h" #include "ps3_watchdog.h" -#if defined PS3_HARDWARE_ASIC +#if defined PS3_HARDWARE_ASIC #include "ps3_pci.h" #endif #include "ps3_cli_debug.h" #include "ps3_recovery.h" - +#include "ps3_kernel_version.h" const char *const PS3_CHRDEV_NAME = "ps3stor-ioctl"; -#define PS3_PCI_DRIVER_NAME "ps3stor" -#define PS3_SCSI_HOST_NAME "ps3stor_scsi_host" +#define PS3_PCI_DRIVER_NAME "ps3stor" +#define PS3_SCSI_HOST_NAME "ps3stor_scsi_host" #define PS3_SCSI_DEFAULT_INIT_ID (-1) #define PS3_SCSI_DEFAULT_CMD_PER_LUN (256) @@ -59,37 +60,34 @@ const char *const PS3_CHRDEV_NAME = "ps3stor-ioctl"; #define PS3_BIOS_PARAM_MAX_SECTORS (63) #define PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G (0x200000) -#define IS_DMA64 (sizeof(dma_addr_t) == 8) +#define IS_DMA64 (sizeof(dma_addr_t) == 8) #define PS3_HOST_UUIID(_dev) (_dev->bus->number << 8 | _dev->devfn) -static const U8 DMA_MASK_BIT_44 = PCIE_DMA_HOST_ADDR_BIT_POS; -static const U8 DMA_MASK_BIT_52 = PCIE_DMA_HOST_ADDR_BIT_POS_VALID; -static const U8 DMA_MASK_BIT_32 = 32; -static const U32 PS3_REGISTER_BAR_INDEX = 0x02; +static const unsigned char DMA_MASK_BIT_44 = PCIE_DMA_HOST_ADDR_BIT_POS; +static const unsigned char DMA_MASK_BIT_52 = PCIE_DMA_HOST_ADDR_BIT_POS_VALID; +static const unsigned char DMA_MASK_BIT_32 = 32; +static const unsigned int PS3_REGISTER_BAR_INDEX = 0x02; static unsigned int ps3_mgmt_chrdev_major_no; #ifdef __KERNEL__ -#define PCI_DEVICE_SET(vend, dev, subven, subdev, cls, cls_mask) \ - .vendor = (vend), .device = (dev), \ - .subvendor = (subven), .subdevice = (subdev),\ - .class = (cls), .class_mask = (cls_mask) +#define PCI_DEVICE_SET(vend, dev, subven, subdev, cls, cls_mask) \ + .vendor = (vend), .device = (dev), .subvendor = (subven), \ + .subdevice = (subdev), .class = (cls), .class_mask = (cls_mask) #else -#define PCI_DEVICE_SET(vend, dev, subven, subdev, class, class_mask) \ - .vendor = (vend), .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID +#define PCI_DEVICE_SET(vend, dev, subven, subdev, class, class_mask) \ + .vendor = (vend), .device = (dev), .subvendor = PCI_ANY_ID, \ + .subdevice = PCI_ANY_ID #endif static struct pci_device_id ps3_pci_table[] = { - {PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_RAID_FPGA)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3_FPGA, PCI_DEVICE_ID_PS3_HBA)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_RAID_FPGA)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3_ASIC, PCI_DEVICE_ID_PS3_HBA)}, - {PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_IOC_2020_18i)}, - {PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2020_18i)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_ROC_2020_10i)}, - {PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2213_16i)}, - {0, 0, 0, 0}}; + { PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_IOC_2020_18i) }, + { PCI_DEVICE(PCI_VENDOR_ID_STARS, PCI_DEVICE_ID_STARS_ROC_2020_10i) }, + { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2020_18i) }, + { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_ROC_2020_10i) }, + { PCI_DEVICE(PCI_VENDOR_ID_PS3, PCI_DEVICE_ID_STARS_IOC_2213_16i) }, + { PCI_DEVICE(PCI_VENDOR_ID_TL, PCI_DEVICE_ID_TL_30A2) }, + { 0, 0, 0, 0 } +}; MODULE_DEVICE_TABLE(pci, ps3_pci_table); @@ -97,26 +95,25 @@ static int ps3_mgmt_open(struct inode *pinode, struct file *filep) { (void)pinode; (void)filep; - if (!capable(CAP_SYS_ADMIN)) { + if (!capable(CAP_SYS_ADMIN)) return -EACCES; - } return PS3_SUCCESS; } static int ps3_bios_param(struct scsi_device *sdev, struct block_device *bdev, - sector_t capacity, int params[]) + sector_t capacity, int params[]) { int heads = PS3_BIOS_PARAM_DEFAULT_HEADER; int sectors = PS3_BIOS_PARAM_DEFAULT_SECTORS; sector_t cylinders = capacity; - ULong dummy = heads * sectors; + unsigned long dummy = heads * sectors; (void)sdev; (void)bdev; sector_div(cylinders, dummy); - if ((ULong)capacity >= PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G) { + if ((unsigned long)capacity >= PS3_BIOS_PARAM_DEV_CAPCITY_THRESHOLD_1G) { heads = PS3_BIOS_PARAM_MAX_HEADER; sectors = PS3_BIOS_PARAM_MAX_SECTORS; dummy = heads * sectors; @@ -135,15 +132,14 @@ static int ps3_bios_param(struct scsi_device *sdev, struct block_device *bdev, static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) { struct ps3_instance *instance = NULL; - S32 qoff = 0; - S32 offset = 0; + int qoff = 0; + int offset = 0; struct blk_mq_queue_map *map = NULL; instance = (struct ps3_instance *)shost->hostdata; - if (shost->nr_hw_queues == 1) { + if (shost->nr_hw_queues == 1) goto l_out; - } offset = instance->irq_context.high_iops_msix_vectors; qoff = 0; @@ -151,11 +147,15 @@ static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) map = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; map->nr_queues = instance->irq_context.valid_msix_vector_count - offset; map->queue_offset = 0; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,12,0)) +#if defined(PS3_MAP_QUEUES_RET) (void)qoff; - MAP_QUEUES_RET_VAL(blk_mq_pci_map_queues(map, instance->pdev, offset)); + return MAP_QUEUES_RET_VAL(blk_mq_pci_map_queues(map, instance->pdev, offset)); +#else +#if defined(PS3_MAP_HW_QUEUES) + blk_mq_map_hw_queues(map, &instance->pdev->dev, offset); #else blk_mq_pci_map_queues(map, instance->pdev, offset); +#endif qoff += map->nr_queues; map = &shost->tag_set.map[HCTX_TYPE_POLL]; @@ -166,15 +166,16 @@ static MAP_QUEUES_RET_TYPE ps3_map_queues(struct Scsi_Host *shost) } #endif l_out: - MAP_QUEUES_RET_VAL(0); + return MAP_QUEUES_RET_VAL(0); } #endif static ssize_t page_size_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; + if (buf == NULL) { ret = 0; goto l_out; @@ -182,169 +183,184 @@ static ssize_t page_size_show(struct device *cdev, (void)cdev; (void)attr; - ret = snprintf(buf, PAGE_SIZE, "%ld\n", (ULong)PAGE_SIZE - 1); + ret = snprintf(buf, PAGE_SIZE, "%ld\n", (unsigned long)PAGE_SIZE - 1); l_out: return ret; } static inline ssize_t vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_vd_io_outstanding_show(cdev, attr, buf); } static inline ssize_t io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_io_outstanding_show(cdev, attr, buf); } static inline ssize_t is_load_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_is_load_show(cdev, attr, buf); } static inline ssize_t dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_dump_ioc_regs_show(cdev, attr, buf); } static inline ssize_t max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_max_scsi_cmds_show(cdev, attr, buf); } static inline ssize_t event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_event_subscribe_info_show(cdev, attr, buf); } static inline ssize_t ioc_state_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_ioc_state_show(cdev, attr, buf); } static ssize_t log_level_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { return ps3_log_level_store(cdev, attr, buf, count); } static inline ssize_t log_level_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_log_level_show(cdev, attr, buf); } static inline ssize_t io_trace_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_io_trace_switch_store(cdev, attr, buf, count); } static inline ssize_t io_trace_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_io_trace_switch_show(cdev, attr, buf); } static inline ssize_t dump_type_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_type_show(cdev, attr, buf); } static inline ssize_t dump_type_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_dump_type_store(cdev, attr, buf, count); } static inline ssize_t dump_dir_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_dir_show(cdev, attr, buf); } static inline ssize_t dump_state_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_dump_state_show(cdev, attr, buf); } static inline ssize_t dump_state_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_dump_state_store(cdev, attr, buf, count); } static inline ssize_t soc_dead_reset_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_soc_dead_reset_store(cdev, attr, buf, count); } static inline ssize_t halt_support_cli_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_halt_support_cli_show(cdev, attr, buf); } static inline ssize_t halt_support_cli_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_halt_support_cli_store(cdev, attr, buf, count); } static inline ssize_t qos_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { return ps3_qos_switch_show(cdev, attr, buf); } static ssize_t qos_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { return ps3_qos_switch_store(cdev, attr, buf, count); } static inline ssize_t product_model_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_product_model_show(cdev, attr, buf); } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else static inline ssize_t irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, + char *buf) { return ps3_irq_prk_support_show(cdev, attr, buf); } static inline ssize_t irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { return ps3_irq_prk_support_store(cdev, attr, buf, count); } #endif static inline ssize_t cli_ver_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { - ssize_t ret= 0; + ssize_t ret = 0; (void)cdev; (void)attr; - if (buf != NULL) { + if (buf != NULL) ret = snprintf(buf, PAGE_SIZE, "%d\n", PS3_IOCTL_VERSION); - } return ret; } @@ -368,14 +384,14 @@ static DEVICE_ATTR_RW(qos_switch); static DEVICE_ATTR_RO(product_model); static DEVICE_ATTR_RO(cli_ver); -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else static DEVICE_ATTR_RW(irq_prk_support); #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) +#if defined(PS3_HOST_ATTRS) static struct attribute *ps3_host_attrs[] = { &dev_attr_page_size.attr, &dev_attr_vd_io_outstanding.attr, @@ -395,18 +411,26 @@ static struct attribute *ps3_host_attrs[] = { &dev_attr_qos_switch.attr, &dev_attr_product_model.attr, &dev_attr_cli_ver.attr, -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else &dev_attr_irq_prk_support.attr, #endif NULL, }; +#if defined(PS3_UT) +static const struct attribute_group ps3_host_attr_group = { + .name = "ps3_host_attr_group", + .attrs = ps3_host_attrs, + .bin_attrs = NULL +}; +#else static const struct attribute_group ps3_host_attr_group = { .attrs = ps3_host_attrs }; +#endif const struct attribute_group *ps3_host_groups[] = { &ps3_host_attr_group, @@ -432,8 +456,8 @@ static struct device_attribute *ps3_host_attrs[] = { &dev_attr_qos_switch, &dev_attr_product_model, &dev_attr_cli_ver, -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else &dev_attr_irq_prk_support, @@ -441,15 +465,85 @@ static struct device_attribute *ps3_host_attrs[] = { NULL, }; #endif + +#ifdef PS3_NCQ_PRIO_SUPPORT +static ssize_t device_ncq_prio_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct ps3_scsi_priv_data *priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + + (void)attr; + return snprintf(buf, PAGE_SIZE, "%d\n", + priv_data->ncq_prio_enable); +} + +static ssize_t device_ncq_prio_enable_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct ps3_instance *instance = (struct ps3_instance *)shost_priv(sdev->host); + + (void)count; + + if (instance == NULL) + return -EINVAL; + + if (instance->ioc_adpter->ncq_prio_enable_stor == NULL) + return -EINVAL; + else + return instance->ioc_adpter->ncq_prio_enable_stor(dev, buf); +} + +#ifdef PS3_UT +DEVICE_ATTR(ncq_prio_enable, device_ncq_prio_enable_show, device_ncq_prio_enable_store); +#else +static DEVICE_ATTR(ncq_prio_enable, 0644, + device_ncq_prio_enable_show, + device_ncq_prio_enable_store); +#endif + +#ifdef PS3_KERNEL_START_WITH_516 +static struct attribute *ps3_dev_attrs[] = { + &dev_attr_ncq_prio_enable.attr, + NULL, +}; + +static const struct attribute_group ps3_dev_attr_group = { + .attrs = ps3_dev_attrs +}; + +const struct attribute_group *ps3_dev_groups[] = { + &ps3_dev_attr_group, + NULL +}; +#else +struct device_attribute *ps3_dev_attrs[] = { + &dev_attr_ncq_prio_enable, + NULL, +}; +#endif +#endif + static struct scsi_host_template ps3_scsi_host_template = { .module = THIS_MODULE, .name = PS3_SCSI_HOST_NAME, .proc_name = PS3_SCSI_HOST_PROC_NAME, .queuecommand = ps3_scsih_queue_command, .eh_abort_handler = ps3_err_scsi_task_mgr_abort, +#if defined(PS3_SDEV_CONFIG_SUPPORT) + .sdev_init = ps3_scsi_slave_alloc, + .sdev_destroy = ps3_scsi_slave_destroy, + .sdev_configure = ps3_scsi_slave_configure, +#else .slave_alloc = ps3_scsi_slave_alloc, - .slave_configure = ps3_scsi_slave_configure, .slave_destroy = ps3_scsi_slave_destroy, +#if defined(PS3_DEVICE_CONFIG_SUPPORT) + .device_configure = ps3_scsi_slave_configure, +#else + .slave_configure = ps3_scsi_slave_configure, +#endif +#endif .change_queue_depth = ps3_change_queue_depth, .eh_device_reset_handler = ps3_device_reset_handler, .eh_target_reset_handler = ps3_err_reset_target, @@ -460,28 +554,37 @@ static struct scsi_host_template ps3_scsi_host_template = { .map_queues = ps3_map_queues, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)) +#if defined(PS3_TRACK_QUEUE_DEPTH) .track_queue_depth = 1, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) +#if defined(PS3_HOST_ATTRS) .shost_groups = ps3_host_groups, +#ifdef PS3_NCQ_PRIO_SUPPORT + .sdev_groups = ps3_dev_groups, +#endif #else .shost_attrs = ps3_host_attrs, +#ifdef PS3_NCQ_PRIO_SUPPORT + .sdev_attrs = ps3_dev_attrs, +#endif +#ifdef PS3_UT + .sdev_attrs = NULL, +#endif #endif }; -static inline void ps3_set_product_model(struct ps3_instance * instance, const U16 id) +static inline void ps3_set_product_model(struct ps3_instance *instance, + const unsigned short id) { - if (PS3_DEVICE_IS_SWITCH(id)) { + if (PS3_DEVICE_IS_SWITCH(id)) instance->product_model = PS3_PSW_PRODUCT_MODEL; - } else { + else instance->product_model = PS3_PRODUCT_MODEL; - } - return; } -static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, const struct pci_device_id *id) +static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, + const struct pci_device_id *id) { struct Scsi_Host *host = NULL; struct ps3_instance *instance = NULL; @@ -492,7 +595,7 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, const stru } host = scsi_host_alloc(&ps3_scsi_host_template, - sizeof(struct ps3_instance)); + sizeof(struct ps3_instance)); if (!host) { LOG_ERROR("pci_id[%u] scsi_host_alloc failed!\n", pdev->dev.id); @@ -511,7 +614,7 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, const stru instance->state_machine.can_hostreset = PS3_FALSE; instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; instance->is_pcie_err_detected = PS3_FALSE; - mb(); + mb(); /* in order to force CPU ordering */ if (ps3_instance_add(instance) != PS3_SUCCESS) { scsi_remove_host(host); @@ -519,29 +622,27 @@ static struct ps3_instance *ps3_instance_create(struct pci_dev *pdev, const stru instance = NULL; } - LOG_INFO("hno:%u scsi_host_alloc [unique_id:%d]!\n", - PS3_HOST(instance), host->unique_id); + LOG_INFO("hno:%u scsi_host_alloc [unique_id:%d]!\n", PS3_HOST(instance), + host->unique_id); return instance; } static inline void ps3_instance_put(struct ps3_instance *instance) { - if (ps3_instance_remove(instance) != PS3_SUCCESS) { + if (ps3_instance_remove(instance) != PS3_SUCCESS) LOG_ERROR("ps3_instance remove NOK\n"); - } - return; } -S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) +int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) { resource_size_t base_addr = 0; - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ret = pci_enable_device_mem(pdev); - INJECT_START(PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_FORCE_PCI_EN_MEM_FAILED, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u pci id[%u] pci enable failed\n", - PS3_HOST(instance), pdev->dev.id); + PS3_HOST(instance), pdev->dev.id); goto l_pci_enable_device_mem_failed; } @@ -549,36 +650,32 @@ S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) instance->reg_bar = PS3_REGISTER_BAR_INDEX; ret = (pci_resource_flags(pdev, instance->reg_bar) & IORESOURCE_MEM); - INJECT_START(PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_FORCE_PCI_RES_FLAGS_FAILED, &ret); if (!ret) { LOG_ERROR("hno:%u Bar %lu isnot IORESOURCE_MEM\n", - PS3_HOST(instance), instance->reg_bar); + PS3_HOST(instance), instance->reg_bar); goto l_bar_check_failed; } - ret = pci_request_selected_regions(pdev, 1<reg_bar, - "PS3 pci regions"); - INJECT_START(PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, &ret) + ret = pci_request_selected_regions(pdev, 1 << instance->reg_bar, + "PS3 pci regions"); + INJECT_START(PS3_ERR_IJ_FORCE_PCI_REQ_REGION_FAILED, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u IO memory region busy\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u IO memory region busy\n", PS3_HOST(instance)); goto l_pci_request_selected_regions_failed; } -#if ((defined(RHEL_MAJOR) && \ - ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ - (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) +#if defined(PS3_SUPPORT_PCIE_REPORT) pci_enable_pcie_error_reporting(pdev); #endif if (instance->ioc_adpter->reg_set) { instance->reg_set = - (Ps3Fifo_s __iomem *)instance->ioc_adpter->reg_set(pdev, - instance->reg_bar); + (struct Ps3Fifo __iomem *)instance->ioc_adpter->reg_set( + pdev, instance->reg_bar); } else { - instance->reg_set = - (Ps3Fifo_s __iomem *)ioremap( - pci_resource_start(pdev, instance->reg_bar), - PS3_REGISTER_SET_SIZE); + instance->reg_set = (struct Ps3Fifo __iomem *)ioremap( + pci_resource_start(pdev, instance->reg_bar), + PS3_REGISTER_SET_SIZE); } - INJECT_START(PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, &instance->reg_set) + INJECT_START(PS3_ERR_IJ_FORCE_PCI_IOREMAP_FAILED, &instance->reg_set); if (instance->reg_set == NULL) { LOG_ERROR("hno:%u ioremap failed\n", PS3_HOST(instance)); goto l_ioremap_failed; @@ -587,15 +684,14 @@ S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance) } ps3_atomic_set(&instance->watchdog_reg_read_fail_count, 0); - LOG_INFO("reg_bar_idx = %lu, bar_base_paddr = 0x%llx, reg_set_vaddr = 0x%p\n", instance->reg_bar, - (U64)base_addr, instance->reg_set); + LOG_INFO( + "reg_bar_idx = %lu, bar_base_paddr = 0x%llx, reg_set_vaddr = 0x%p\n", + instance->reg_bar, (unsigned long long)base_addr, instance->reg_set); return PS3_SUCCESS; l_ioremap_failed: - pci_release_selected_regions(instance->pdev, 1<reg_bar); -#if ((defined(RHEL_MAJOR) && \ - ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ - (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) + pci_release_selected_regions(instance->pdev, 1 << instance->reg_bar); +#if defined(PS3_SUPPORT_PCIE_REPORT) pci_disable_pcie_error_reporting(pdev); #endif l_pci_request_selected_regions_failed: @@ -613,22 +709,20 @@ static void ps3_pci_exit(struct ps3_instance *instance) } if (pci_is_enabled(instance->pdev)) { - pci_release_selected_regions(instance->pdev, 1<reg_bar); -#if ((defined(RHEL_MAJOR) && \ - ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ - (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) + pci_release_selected_regions(instance->pdev, + 1 << instance->reg_bar); +#if defined(PS3_SUPPORT_PCIE_REPORT) pci_disable_pcie_error_reporting(instance->pdev); #endif pci_disable_device(instance->pdev); } - - return; } -static S32 ps3_scsi_init(struct ps3_instance *instance) +static int ps3_scsi_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct Scsi_Host *host = instance->host; + host->can_queue = instance->cmd_attr.cur_can_que; host->this_id = PS3_SCSI_DEFAULT_INIT_ID; host->sg_tablesize = instance->cmd_context.max_host_sge_count; @@ -638,7 +732,7 @@ static S32 ps3_scsi_init(struct ps3_instance *instance) host->max_id = instance->dev_context.max_dev_per_channel; host->max_lun = PS3_FRAME_LUN_BUFLEN; host->max_cmd_len = PS3_FRAME_CDB_BUFLEN; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#if defined(PS3_SUPPORT_BIO_MERGE) host->use_clustering = instance->use_clusting; #endif @@ -652,28 +746,27 @@ static S32 ps3_scsi_init(struct ps3_instance *instance) host->nr_hw_queues = 1; if ((instance->irq_context.valid_msix_vector_count > - instance->irq_context.high_iops_msix_vectors) && - ps3_tagset_enable_query() && - (instance->smp_affinity_enable)) { + instance->irq_context.high_iops_msix_vectors) && + ps3_tagset_enable_query() && (instance->smp_affinity_enable)) { host->host_tagset = 1; - host->nr_hw_queues = instance->irq_context.valid_msix_vector_count - + host->nr_hw_queues = + instance->irq_context.valid_msix_vector_count - instance->irq_context.high_iops_msix_vectors; } #endif -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +#if defined(PS3_CHANGE_QUEUE_DEPTH) ret = scsi_init_shared_tag_map(host, host->can_queue); if (ret) { LOG_ERROR("hno:%u Failed to shared tag from\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } #endif if (scsi_add_host(instance->host, &instance->pdev->dev)) { - LOG_ERROR("hno:%u Failed to add host\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u Failed to add host\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -684,91 +777,87 @@ static S32 ps3_scsi_init(struct ps3_instance *instance) return ret; } -static inline S32 __ps3_config_dma_mask32(struct ps3_instance *instance) +static inline int __ps3_config_dma_mask32(struct ps3_instance *instance) { if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(DMA_MASK_BIT_32)) || - dma_set_coherent_mask(&instance->pdev->dev, - DMA_BIT_MASK(DMA_MASK_BIT_32))) { + dma_set_coherent_mask(&instance->pdev->dev, + DMA_BIT_MASK(DMA_MASK_BIT_32))) { LOG_ERROR("hno:%u 32 dma mask set failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; - } else { - instance->dma_mask = DMA_MASK_BIT_32; - LOG_INFO("hno:%u 32 dma mask set\n", - PS3_HOST(instance)); } - + instance->dma_mask = DMA_MASK_BIT_32; + LOG_INFO("hno:%u 32 dma mask set\n", PS3_HOST(instance)); return PS3_SUCCESS; } -static inline U8 ps3_dma_mask_get(struct ps3_instance *instance) +static inline unsigned char ps3_dma_mask_get(struct ps3_instance *instance) { - return ((instance->dma_addr_bit_pos > DMA_MASK_BIT_52) ? DMA_MASK_BIT_52 : DMA_MASK_BIT_44); + return ((instance->dma_addr_bit_pos > DMA_MASK_BIT_52) ? + DMA_MASK_BIT_52 : + DMA_MASK_BIT_44); } -static inline S32 __ps3_config_dma_mask(struct ps3_instance *instance) +static inline int __ps3_config_dma_mask(struct ps3_instance *instance) { - U8 dma_mask = 0; + unsigned char dma_mask = 0; + dma_mask = ps3_dma_mask_get(instance); if (dma_set_mask(&instance->pdev->dev, DMA_BIT_MASK(dma_mask)) || - dma_set_coherent_mask(&instance->pdev->dev, - DMA_BIT_MASK(dma_mask))) { + dma_set_coherent_mask(&instance->pdev->dev, + DMA_BIT_MASK(dma_mask))) { LOG_ERROR("hno:%u 62 dma mask set failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return __ps3_config_dma_mask32(instance); - } else { - instance->dma_mask = dma_mask; - LOG_INFO("hno:%u dma mask set %u\n", - PS3_HOST(instance), instance->dma_mask); } + instance->dma_mask = dma_mask; + LOG_INFO("hno:%u dma mask set %u\n", PS3_HOST(instance), instance->dma_mask); return PS3_SUCCESS; } -static S32 ps3_config_dma_mask(struct ps3_instance *instance) +static int ps3_config_dma_mask(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - Bool is_dma64_support = PS3_FALSE; - if (!ps3_ioc_mgr_is_dma64_support(instance, &is_dma64_support)) { + int ret = -PS3_FAILED; + unsigned char is_dma64_support = PS3_FALSE; + + if (!ps3_ioc_mgr_is_dma64_support(instance, &is_dma64_support)) goto l_out; - } if (is_dma64_support) { if (IS_DMA64) { ret = __ps3_config_dma_mask(instance); } else { LOG_ERROR("hno:%u unsupport 32bit system\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } else { LOG_ERROR("hno:%u soc unsupport 64bit dma\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; } -static inline void ps3_device_busy_threshold_cfg(struct ps3_instance *instance) +static inline void ps3_device_busy_threshold_cfg(struct ps3_instance *instance) { - S32 device_busy = 0; + int device_busy = 0; device_busy = ps3_device_busy_threshold_query(); - if (device_busy <= 0 || - device_busy > instance->cmd_attr.cur_can_que) { + if (device_busy <= 0 || device_busy > instance->cmd_attr.cur_can_que) instance->device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; - } else { + else instance->device_busy_threshold = device_busy; - } } static void ps3_cmd_attr_context_init(struct ps3_instance *instance) { - U32 cmd_qdepth = ps3_throttle_qdepth_query(); + unsigned int cmd_qdepth = ps3_throttle_qdepth_query(); instance->cmd_attr.cur_can_que = instance->cmd_context.max_scsi_cmd_count - instance->cmd_context.max_r1x_cmd_count; if ((cmd_qdepth != 0) && - cmd_qdepth <= (U32)instance->cmd_attr.cur_can_que) { + cmd_qdepth <= (unsigned int)instance->cmd_attr.cur_can_que) { instance->cmd_attr.throttle_que_depth = cmd_qdepth; } else { instance->cmd_attr.throttle_que_depth = @@ -781,62 +870,50 @@ static void ps3_cmd_attr_context_init(struct ps3_instance *instance) ps3_device_busy_threshold_cfg(instance); } -static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) +static int ps3_init_ioc_prepare(struct ps3_instance *instance) { ps3_ioc_mgr_req_queue_lock_init(instance); instance->watchdog_context.is_stop = PS3_TRUE; ps3_atomic_set(&instance->watchdog_ref, 0); ps3_err_fault_context_init(instance); - if (!ps3_ioc_fw_version_get(instance)) { + if (!ps3_ioc_fw_version_get(instance)) goto l_get_reg_failed; - } - if (!ps3_feature_support_reg_get(instance)) { + if (!ps3_feature_support_reg_get(instance)) goto l_get_reg_failed; - } - if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) { + if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) goto l_ioc_init_failed; - } - if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) { + if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) goto l_ctrl_info_init_failed; - } - if (ps3_cmd_context_init(instance) != PS3_SUCCESS) { + if (ps3_cmd_context_init(instance) != PS3_SUCCESS) goto l_cmd_context_init_failed; - } ps3_cmd_attr_context_init(instance); - if (ps3_event_context_init(instance) != PS3_SUCCESS) { + if (ps3_event_context_init(instance) != PS3_SUCCESS) goto l_event_context_init_failed; - } - if (ps3_webSubscribe_context_init(instance) != PS3_SUCCESS) { - goto l_web_context_init_failed; - } + if (ps3_webSubscribe_context_init(instance) != PS3_SUCCESS) + goto l_web_context_init_failed; - if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) { + if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) goto l_cmd_stat_failed; - } - if (ps3_debug_mem_alloc(instance) != PS3_SUCCESS) { + if (ps3_debug_mem_alloc(instance) != PS3_SUCCESS) goto l_debug_mem_failed; - } - if (ps3_dump_init(instance) != PS3_SUCCESS) { + if (ps3_dump_init(instance) != PS3_SUCCESS) goto l_dump_init_failed; - } - if (ps3_drv_info_buf_alloc(instance) != PS3_SUCCESS) { + if (ps3_drv_info_buf_alloc(instance) != PS3_SUCCESS) goto l_drv_info_init_failed; - } - if (ps3_host_mem_info_buf_alloc(instance) != PS3_SUCCESS) { + if (ps3_host_mem_info_buf_alloc(instance) != PS3_SUCCESS) goto l_host_mem_init_failed; - } return PS3_SUCCESS; l_host_mem_init_failed: @@ -848,7 +925,7 @@ static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) l_debug_mem_failed: ps3_cmd_statistics_exit(instance); l_cmd_stat_failed: - ps3_webSubscribe_context_exit(instance); + ps3_webSubscribe_context_exit(instance); l_web_context_init_failed: ps3_event_context_exit(instance); l_event_context_init_failed: @@ -868,7 +945,7 @@ static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) (void)ps3_debug_mem_free(instance); ps3_cmd_statistics_exit(instance); ps3_event_context_exit(instance); - ps3_webSubscribe_context_exit(instance); + ps3_webSubscribe_context_exit(instance); ps3_ctrl_info_buf_free(instance); ps3_ioc_init_cmd_context_exit(instance); ps3_cmd_context_exit(instance); @@ -880,27 +957,23 @@ static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) ps3_host_mem_info_buf_free(instance); } -static S32 ps3_init_ioc_complete(struct ps3_instance *instance) +static int ps3_init_ioc_complete(struct ps3_instance *instance) { - if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) { + if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) goto l_mgr_cmd_init_failed; - } - if (ps3_device_mgr_init(instance) != PS3_SUCCESS) { + if (ps3_device_mgr_init(instance) != PS3_SUCCESS) goto l_device_mgr_init_failed; - } - if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) { + if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) goto l_sas_device_mgr_init_failed; - } - if (ps3_qos_init(instance) != PS3_SUCCESS) { + if (ps3_qos_init(instance) != PS3_SUCCESS) goto l_qos_init_failed; - } return PS3_SUCCESS; l_qos_init_failed: - ps3_sas_device_mgr_exit(instance); + ps3_sas_device_mgr_exit(instance); l_sas_device_mgr_init_failed: ps3_device_mgr_exit(instance); l_device_mgr_init_failed: @@ -916,27 +989,21 @@ static void ps3_init_ioc_complete_exit(struct ps3_instance *instance) ps3_mgr_cmd_exit(instance); ps3_qos_exit(instance); - - return ; } -S32 ps3_pci_init_complete(struct ps3_instance *instance) +int ps3_pci_init_complete(struct ps3_instance *instance) { - if (ps3_config_dma_mask(instance) != PS3_SUCCESS) { + if (ps3_config_dma_mask(instance) != PS3_SUCCESS) goto l_failed; - } - if (ps3_irq_context_init(instance) != PS3_SUCCESS) { + if (ps3_irq_context_init(instance) != PS3_SUCCESS) goto l_failed; - } if (instance->ioc_adpter->irq_init) { - if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) { + if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) goto l_irqs_init_failed; - } } else { - if (ps3_irqs_init(instance) != PS3_SUCCESS) { + if (ps3_irqs_init(instance) != PS3_SUCCESS) goto l_irqs_init_failed; - } } return PS3_SUCCESS; @@ -946,20 +1013,21 @@ S32 ps3_pci_init_complete(struct ps3_instance *instance) return -PS3_FAILED; } -static S32 ps3_wait_reg_access_done(struct ps3_instance *instance) +static int ps3_wait_reg_access_done(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 read_count = 0; - const U32 retry_max = 9000; + int ret = PS3_SUCCESS; + unsigned int read_count = 0; + const unsigned int retry_max = 9000; ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - while (ps3_atomic_read(&instance->reg_op_count) != 0){ + while (ps3_atomic_read(&instance->reg_op_count) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - if(read_count++ > retry_max){ + if (read_count++ > retry_max) { LOG_INFO("hno:%u wait reg op over:%d ms, failed\n", - PS3_HOST(instance), read_count*PS3_LOOP_TIME_INTERVAL_20MS); + PS3_HOST(instance), + read_count * PS3_LOOP_TIME_INTERVAL_20MS); ret = -PS3_FAILED; goto l_out; } @@ -974,26 +1042,27 @@ void ps3_pci_init_complete_exit(struct ps3_instance *instance) ps3_irqs_exit(instance); instance->is_pci_reset = PS3_TRUE; - mb(); + mb(); /* in order to force CPU ordering */ if (ps3_wait_reg_access_done(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u wait reg access done NOK\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u wait reg access done NOK\n", + PS3_HOST(instance)); return; } - ps3_pci_exit(instance); + ps3_pci_exit(instance); if (!ps3_pci_err_recovery_get(instance) && - !instance->state_machine.is_suspend) { + !instance->state_machine.is_suspend) { pci_set_drvdata(instance->pdev, NULL); } ps3_irq_context_exit(instance); } -static Bool ps3_bit_pos_set(struct ps3_instance *instance) +static unsigned char ps3_bit_pos_set(struct ps3_instance *instance) { - U8 bit_pos = 0; - Bool ret = PS3_TRUE; + unsigned char bit_pos = 0; + unsigned char ret = PS3_TRUE; if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) { ret = PS3_FALSE; @@ -1003,76 +1072,72 @@ static Bool ps3_bit_pos_set(struct ps3_instance *instance) instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; goto l_out; } - if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0) { + if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0) instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; - } else { + else instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; - } l_out: - mb(); - LOG_WARN("hno:%u set bit pos %u\n", - PS3_HOST(instance), instance->dma_addr_bit_pos); + mb(); /* in order to force CPU ordering */ + LOG_WARN("hno:%u set bit pos %u\n", PS3_HOST(instance), + instance->dma_addr_bit_pos); return ret; } -static S32 ps3_firmware_init(struct pci_dev *pdev, struct ps3_instance *instance) +static int ps3_firmware_init(struct pci_dev *pdev, + struct ps3_instance *instance) { - S32 ret; + int ret; - if (ps3_recovery_context_init(instance) != PS3_SUCCESS) { + if (ps3_recovery_context_init(instance) != PS3_SUCCESS) goto l_recovery_context_init_failed; - } - if (ps3_pci_init(pdev, instance) != PS3_SUCCESS) { + if (ps3_pci_init(pdev, instance) != PS3_SUCCESS) goto l_failed; - } - if (!ps3_ioc_recovery_count_get(instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get( + instance, + &instance->recovery_context->ioc_recovery_count)) { goto l_failed; } - INJECT_START(PS3_ERR_IJ_SET_IOC_IN_SECURITY, instance) + INJECT_START(PS3_ERR_IJ_SET_IOC_IN_SECURITY, instance); if (instance->ioc_adpter->ioc_security_check && - instance->ioc_adpter->ioc_security_check(instance)) { - LOG_WARN("hno:%u:ioc is in security state\n", PS3_HOST(instance)); + instance->ioc_adpter->ioc_security_check(instance)) { + LOG_WARN("hno:%u:ioc is in security state\n", + PS3_HOST(instance)); goto l_failed; } - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_READY, instance) - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_READY, instance); + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != + PS3_SUCCESS) { goto l_failed; } atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_READY, instance); - if (!ps3_bit_pos_set(instance)) { + if (!ps3_bit_pos_set(instance)) goto l_failed; - } - if (ps3_pci_init_complete(instance) != PS3_SUCCESS) { + if (ps3_pci_init_complete(instance) != PS3_SUCCESS) goto l_failed; - } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; pci_save_state(pdev); ret = ps3_init_ioc_prepare(instance); - INJECT_START(PS3_ERR_IJ_FIRMWARE_INIT_FAIL, &ret) - if (ret != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FIRMWARE_INIT_FAIL, &ret); + if (ret != PS3_SUCCESS) goto l_failed; - } - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_INIT, instance) - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_INIT, instance); + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) goto l_failed; - } - atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_CTRL_INFO, instance) + atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_PRE_OPERATIONAL); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_CTRL_INFO, instance); - if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) { + if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) goto l_failed; - } - if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) { + if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) goto l_failed; - } return PS3_SUCCESS; @@ -1089,7 +1154,6 @@ static void ps3_firmware_exit(struct ps3_instance *instance) ps3_pci_init_complete_exit(instance); ps3_init_ioc_complete_exit(instance); ps3_init_ioc_prepare_exit(instance); - return; } static void ps3_scsi_remove_host(struct ps3_instance *instance) @@ -1100,19 +1164,20 @@ static void ps3_scsi_remove_host(struct ps3_instance *instance) } else { scsi_remove_host(instance->host); } - return; } -static Bool ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) +static unsigned char ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) { - Bool ret = PS3_TRUE; - U32 i = 0; + unsigned char ret = PS3_TRUE; + unsigned int i = 0; for (i = 0; i < cmd_context->max_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_PROCESS) { + if (cmd_context->cmd_buf[i]->cmd_state.state == + PS3_CMD_STATE_PROCESS) { ret = PS3_FALSE; - INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, &ret) - INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, cmd_context) + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, &ret); + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, + cmd_context); break; } } @@ -1123,56 +1188,39 @@ static Bool ps3_cmd_context_empty(struct ps3_cmd_context *cmd_context) static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct ps3_instance *instance = NULL; - ULong flags = 0; - S32 ret; + unsigned long flags = 0; + int ret; #ifdef PS3_SUPPORT_INJECT - U32 times = 180000; -#endif -#ifdef PS3_HARDWARE_ASIC - U16 real_dev_id = 0; - U32 check_count = ps3_hba_check_time_query() * 10 + 1; + unsigned int times = 180000; #endif - LOG_INFO("device[%d] ps3_probe\n", pdev->dev.id); + LOG_INFO("device[%d] %s\n", pdev->dev.id, __func__); - if (ps3_avaliable_func_id_query() >= PS3_FUNC_UNLIMITED) { - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + if (ps3_available_func_id_query() >= PS3_FUNC_UNLIMITED) { + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); } else { - if ((U32)ps3_get_pci_function(pdev) != ps3_avaliable_func_id_query()) { - LOG2_WARN("Function %x not avaliable\n", ps3_get_pci_function(pdev)); + if ((unsigned int)ps3_get_pci_function(pdev) != + ps3_available_func_id_query()) { + LOG2_WARN("Function %x not available\n", + ps3_get_pci_function(pdev)); goto l_func_id_error; } else { - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe start.\n", + ps3_get_pci_domain(pdev), + ps3_get_pci_bus(pdev), ps3_get_pci_slot(pdev), + ps3_get_pci_function(pdev)); } } - INJECT_INIT() - INJECT_PROBE_ACTIVE() + INJECT_INIT(); + INJECT_PROBE_ACTIVE(); instance = ps3_instance_create(pdev, id); - if (instance == NULL) { + if (instance == NULL) goto l_ps3_instance_create_failed; - } -#ifdef PS3_HARDWARE_ASIC - while(id->device == PCI_DEVICE_ID_PS3_RAID_FPGA && - check_count > 0) { - pci_read_config_word(pdev, PCI_DEVICE_ID, &real_dev_id); - LOG_INFO("get real device id is[0x%x] \n", real_dev_id); - if (real_dev_id == PCI_DEVICE_ID_PS3_HBA || - real_dev_id == PCI_DEVICE_ID_STARS_IOC_2020_18i || - real_dev_id == PCI_DEVICE_ID_STARS_ROC_2020_10i) { - ((struct pci_device_id *)id)->device = real_dev_id; - break; - } else { - check_count--; - ps3_msleep(100); - } - - }; -#endif ps3_ioc_adp_init(instance, id); instance->ioc_adpter->ioc_resource_prepare(instance); ps3_debug_context_init(instance); @@ -1184,82 +1232,76 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) LOG_WARN("ps3_firmware_init fail:%d\n", ret); goto l_firmware_init_failed; } - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_OPER, instance) + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_OPERATIONAL); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_OPER, instance); instance->ioc_adpter->irq_enable(instance); ps3_dump_ctrl_set_int_ready(instance); ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); ps3_scsi_cmd_timeout_adjust(); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCSI_INIT, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCSI_INIT, instance); ret = ps3_scsi_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_scsi_init_failed; - } instance->state_machine.is_load = PS3_TRUE; - mb(); + mb(); /* in order to force CPU ordering */ INJECT_START(PS3_ERR_IJ_FORCE_F1_LOAD_START_HARD, instance); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_LOAD, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_LOAD, instance); ret = ps3_watchdog_start(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_watch_dog_start_failed; - } - INJECT_START(PS3_ERR_IJ_F1_PROBE_FORCE_IOC_FAULT, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_HOST_START_HARD, instance) + INJECT_START(PS3_ERR_IJ_F1_PROBE_FORCE_IOC_FAULT, instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_HOST_START_HARD, instance); ret = ps3_device_mgr_data_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_dev_info_get_failed; - } ret = ps3_sas_device_data_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_expander_get_failed; - } - INJECT_START(PS3_ERR_IJ_FORCE_F1_SCAN_START_HARD, instance) - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_SCAN, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_SCAN_START_HARD, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_B_SCAN, instance); instance->state_machine.can_hostreset = PS3_TRUE; - INJECT_START(PS3_ERR_IJ_FORCE_F0_WATCHDOG_START_HARD, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F0_WATCHDOG_START_HARD, instance); ps3_scsi_scan_host(instance); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_SCAN, instance) - INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_DELAY, ×) - INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_START_HARD, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_SCAN, instance); + INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_DELAY, ×); + INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_START_HARD, instance); INJECT_START(PS3_ERR_IJ_PROBE_HOST_RESET, instance); instance->is_scan_host_finish = PS3_TRUE; - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCAN_FINISH, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_FINISH_HARD, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_SCAN_FINISH, instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_A_SCAN_FINISH_HARD, instance); ret = ps3_event_subscribe(instance); if (ret == -PS3_FAILED) { goto l_event_subscribe_failed; } else if (ret == -PS3_RECOVERED) { - LOG_INFO("device[%d] skip event/vd info subscribe due to recovery during probe\n", + LOG_INFO( + "device[%d] skip event/vd info subscribe due to recovery during probe\n", pdev->dev.id); goto l_event_subscribe_recovered; } - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_EVENT, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_EVENT, instance); ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_RECOVERED) { LOG_INFO("device[%d] vd info subscribe failed, ret: %d\n", - pdev->dev.id, ret); + pdev->dev.id, ret); goto l_vd_info_subscribe_failed; } l_event_subscribe_recovered: - INJECT_START(PS3_ERR_IJ_WAIT_HARDRESET, instance) + INJECT_START(PS3_ERR_IJ_WAIT_HARDRESET, instance); instance->is_probe_finish = PS3_TRUE; - mb(); -#if 0 - if (ps3_watchdog_start(instance) != PS3_SUCCESS) { - goto l_watch_dog_start_failed; - } -#endif - LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + mb(); /* in order to force CPU ordering */ + LOG2_WARN("PCI Device %04x:%02x:%02x:%x probe end.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); return PS3_SUCCESS; @@ -1268,22 +1310,24 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) l_event_subscribe_failed: ps3_dev_mgr_vd_info_unsubscribe(instance); ps3_event_unsubscribe(instance); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - instance->event_context.abort_eventcmd = 0; - instance->dev_context.abort_vdpending_cmd = 0; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); ps3_sas_device_data_exit(instance); l_expander_get_failed: l_scsi_init_failed: instance->state_machine.is_load = PS3_FALSE; - mb(); + mb(); /* in order to force CPU ordering */ ps3_device_mgr_data_exit(instance); l_dev_info_get_failed: ps3_watchdog_stop(instance); l_watch_dog_start_failed: ps3_scsi_remove_host(instance); instance->state_machine.can_hostreset = PS3_FALSE; - mb(); + mb(); /* in order to force CPU ordering */ ps3_dump_work_stop(instance); ps3_recovery_context_exit(instance); instance->ioc_adpter->irq_disable(instance); @@ -1293,35 +1337,38 @@ static int ps3_probe(struct pci_dev *pdev, const struct pci_device_id *id) ps3_firmware_exit(instance); l_firmware_init_failed: instance->is_probe_failed = PS3_TRUE; - mb(); + mb(); /* in order to force CPU ordering */ ps3_instance_put(instance); scsi_host_put(instance->host); l_ps3_instance_create_failed: ps3_dma_dump_mapping(pdev); - l_func_id_error: - printk(KERN_WARNING "PCI Device %04x:%02x:%02x:%x probe failed.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); +l_func_id_error: + dev_warn(&pdev->dev, "PCI Device %04x:%02x:%02x:%x probe failed.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); return -ENODEV; } -static S32 ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) +static int ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 cur_state = 0; - U32 ioc_state = 0; + int ret = PS3_SUCCESS; + unsigned int cur_state = 0; + unsigned int ioc_state = 0; cur_state = ps3_atomic_read(&instance->state_machine.state); ioc_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_IOC_NOT_RUNNING, &ioc_state) - if((ioc_state != PS3_FW_STATE_RUNNING) || - (cur_state != PS3_INSTANCE_STATE_OPERATIONAL)){ - LOG_WARN("hno:%u goto half hard reset, cur_state:%s,IOC state is %s!\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state),ps3_ioc_state_print(ioc_state)); + INJECT_START(PS3_ERR_IJ_IOC_NOT_RUNNING, &ioc_state); + if ((ioc_state != PS3_FW_STATE_RUNNING) || + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL)) { + LOG_WARN( + "hno:%u goto half hard reset, cur_state:%s,IOC state is %s!\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + ps3_ioc_state_print(ioc_state)); ret = -PS3_FAILED; goto l_out; } - cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); + cancel_delayed_work_sync( + &instance->event_context.delay_work->event_work); l_out: return ret; @@ -1329,38 +1376,39 @@ static S32 ps3_cancel_event_wk_in_unload(struct ps3_instance *instance) static void ps3_shutdown(struct pci_dev *pdev) { - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { - LOG_ERROR("device[%d] ps3_shutdown fail\n", pdev->dev.id); + LOG_ERROR("device[%d] %s fail\n", pdev->dev.id, __func__); return; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown start.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); instance->state_machine.is_load = PS3_FALSE; - mb(); - INJECT_START(PS3_ERR_IJ_SHUTDOWN_HARDRESET, instance) + mb(); /* in order to force CPU ordering */ + INJECT_START(PS3_ERR_IJ_SHUTDOWN_HARDRESET, instance); ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { - while (!ps3_cmd_context_empty(&instance->cmd_context)) { + while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); - } } - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_HALF_RECOVERY_CHECK, instance) + if (instance->is_half_hard_reset) goto l_reset_to_ready; - } - ps3_r1x_conflict_queue_clean_all(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); + ps3_r1x_conflict_queue_clean_all( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), + PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); #ifdef PS3_SUPPORT_INJECT ps3_inject_clear(); #endif - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) goto l_reset_to_ready; - } if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); @@ -1372,25 +1420,27 @@ static void ps3_shutdown(struct pci_dev *pdev) goto l_reset_to_ready; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); - goto l_reset_to_ready; - } - } + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", + pdev->dev.id); + goto l_reset_to_ready; + } + } instance->is_host_added = PS3_FALSE; ps3_watchdog_stop(instance); ps3_dump_exit(instance); - INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance ->is_half_hard_reset) - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance->is_half_hard_reset); + if (instance->is_half_hard_reset) goto l_release_res; - } - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SHUTDOWN, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SHUTDOWN, + PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload failed.\n", pdev->dev.id); goto l_reset_to_ready; } @@ -1400,29 +1450,25 @@ static void ps3_shutdown(struct pci_dev *pdev) if (instance->is_host_added) { ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance ->is_half_hard_reset) { + if (instance->is_half_hard_reset) goto l_release_res; - } } - if (ps3_hard_reset_to_ready_with_doorbell(instance) != - PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK.\n", - PS3_HOST(instance)); - } + if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) + LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); l_release_res: - while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) ps3_msleep(3000); - } INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) - + if (instance->is_half_hard_reset) + cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); instance->state_machine.can_hostreset = PS3_FALSE; ps3_check_and_wait_host_reset(instance); - if (!instance ->is_half_hard_reset) { + if (!instance->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); } - ps3_recovery_destory(instance); + ps3_recovery_destroy(instance); ps3_instance_state_transfer_to_quit(instance); ps3_recovery_clean(instance); @@ -1431,75 +1477,91 @@ static void ps3_shutdown(struct pci_dev *pdev) ps3_firmware_exit(instance); ps3_instance_put(instance); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); - return; + LOG2_WARN("PCI Device %04x:%02x:%02x:%x shutdown end.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); } void ps3_remove(struct pci_dev *pdev) { - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { - LOG_ERROR("device[%d] ps3_remove fail\n", pdev->dev.id); + LOG_ERROR("device[%d] %s fail\n", pdev->dev.id, __func__); return; } instance->state_machine.is_load = PS3_FALSE; - LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove start\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); - mb(); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove start\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { ps3_dump_exit(instance); - while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) ps3_msleep(10); - } - while (!ps3_cmd_context_empty(&instance->cmd_context)) { + while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); - } ps3_all_reply_fifo_complete(instance); ps3_cmd_force_stop(instance); - cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); + cancel_delayed_work_sync( + &instance->event_context.delay_work->event_work); goto l_release_res; } - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_HALF_RECOVERY_CHECK, instance) + if (instance->is_half_hard_reset) goto l_reset_to_ready; - } - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_NOT_RUNNING, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, instance) - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_NOT_RUNNING, instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, + instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_CANCEL_EVENT_WORK_FAIL_RESUME, + instance); + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) goto l_reset_to_ready; - } - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_EVENT_FAIL, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_EVENT_FAIL_RESUME, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_EVENT_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_EVENT_FAIL, instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_EVENT_FAIL_RESUME, + instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_EVENT_FAIL_RESUME, + instance); if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; } - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_VDINFO_FAIL, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_VDINFO_FAIL_RESUME, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_VDINFO_FAIL_RESUME, instance) + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_VDINFO_FAIL, instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_VDINFO_FAIL_RESUME, + instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_VDINFO_FAIL_RESUME, + instance); if (ps3_dev_mgr_vd_info_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] vd unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; } - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_WEB_FAIL, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_WEB_FAIL_RESUME, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_WEB_FAIL_RESUME, instance) - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_WEB_FAIL, instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_WEB_FAIL_RESUME, + instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_WEB_FAIL_RESUME, + instance); + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); - goto l_reset_to_ready; - } - } + if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { + LOG_ERROR("device[%d] web unsubscribe NOK.\n", + pdev->dev.id); + goto l_reset_to_ready; + } + } - ps3_r1x_conflict_queue_clean_all(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); + ps3_r1x_conflict_queue_clean_all( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), + PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); #ifdef PS3_SUPPORT_INJECT @@ -1513,14 +1575,17 @@ void ps3_remove(struct pci_dev *pdev) ps3_watchdog_stop(instance); ps3_dump_exit(instance); - INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance ->is_half_hard_reset) - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_HALF_HARD_RESET, &instance->is_half_hard_reset); + if (instance->is_half_hard_reset) goto l_release_res; - } - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_UNLOAD_FAIL, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_UNLOAD_FAIL_RESUME, instance) - INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_UNLOAD_FAIL_RESUME, instance) - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_IOC_UNLOAD_FAIL, instance); + INJECT_START( + PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_REQ_IOC_UNLOAD_FAIL_RESUME, + instance); + INJECT_START(PS3_ERR_IJ_FORCE_F1_REMOVE_RECOVERY_IOC_UNLOAD_FAIL_RESUME, + instance); + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, + PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload failed.\n", pdev->dev.id); goto l_reset_to_ready; } @@ -1530,36 +1595,30 @@ void ps3_remove(struct pci_dev *pdev) if (instance->is_host_added) { ps3_watchdog_stop(instance); ps3_dump_exit(instance); - if (instance ->is_half_hard_reset) { + if (instance->is_half_hard_reset) goto l_release_res; - } - } - if (ps3_hard_reset_to_ready_with_doorbell(instance) != - PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK.\n", - PS3_HOST(instance)); } + if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) + LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); l_release_res: - while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) ps3_msleep(3000); - } instance->state_machine.can_hostreset = PS3_FALSE; ps3_check_and_wait_host_reset(instance); INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) + if (instance->is_half_hard_reset) + cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); + ps3_instance_state_transfer_to_quit(instance); + ps3_recovery_destroy(instance); - ps3_instance_state_transfer_to_quit(instance); - ps3_recovery_destory(instance); - - if (instance->is_host_added) { + if (instance->is_host_added) ps3_scsi_remove_host(instance); - } - while(ps3_atomic_read(&instance->host_reset_processing) > 0) { + while (ps3_atomic_read(&instance->host_reset_processing) > 0) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } ps3_recovery_clean(instance); - if (!instance ->is_half_hard_reset) { + if (!instance->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); } @@ -1570,56 +1629,56 @@ void ps3_remove(struct pci_dev *pdev) ps3_instance_put(instance); scsi_host_put(instance->host); ps3_dma_dump_mapping(pdev); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove end\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); - return; + LOG2_WARN("PCI Device %04x:%02x:%02x:%x remove end\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); } #ifdef CONFIG_PM static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) { - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - U8 suspend_type = PS3_SUSPEND_TYPE_SLEEP; + unsigned char suspend_type = PS3_SUSPEND_TYPE_SLEEP; - (void) state; + (void)state; INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); if (instance == NULL) { - LOG2_ERROR("device[%d] ps3_suspend NOK\n", pdev->dev.id); + LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); return PS3_SUCCESS; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x ps3_suspend start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_suspend = PS3_TRUE; - mb(); + mb(); /* in order to force CPU ordering */ instance->state_machine.is_suspend = PS3_TRUE; - mb(); - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, instance) + mb(); /* in order to force CPU ordering */ + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY_1, instance); ps3_recovery_cancel_work_sync(instance); if (instance->pci_err_handle_state == PS3_DEVICE_ERR_STATE_CLEAN) { - while (!ps3_cmd_context_empty(&instance->cmd_context)) { + while (!ps3_cmd_context_empty(&instance->cmd_context)) ps3_msleep(10000); - } } INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, instance) - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_HALF_RECOVERY_CHECK, instance) + if (instance->is_half_hard_reset) goto l_reset_to_ready; - } - ps3_r1x_conflict_queue_clean_all(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); + ps3_r1x_conflict_queue_clean_all( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), + PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); #ifdef PS3_SUPPORT_INJECT ps3_inject_clear(); #endif - if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) { + if (ps3_cancel_event_wk_in_unload(instance) != PS3_SUCCESS) goto l_reset_to_ready; - } - if (ps3_event_unsubscribe(instance) != PS3_SUCCESS) { LOG_ERROR("device[%d] event unsubscribe NOK.\n", pdev->dev.id); goto l_reset_to_ready; @@ -1630,11 +1689,13 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) goto l_reset_to_ready; } - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, instance) - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED, instance); + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ps3_wait_mgr_cmd_done(instance, PS3_TRUE); if (ps3_web_unsubscribe(instance) != PS3_SUCCESS) { - LOG_ERROR("device[%d] web unsubscribe NOK.\n", pdev->dev.id); + LOG_ERROR("device[%d] web unsubscribe NOK.\n", + pdev->dev.id); goto l_reset_to_ready; } } @@ -1647,32 +1708,29 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) ps3_watchdog_stop(instance); ps3_recovery_cancel_work_sync(instance); - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, instance) - if (instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_2, instance); + if (instance->is_half_hard_reset) goto l_release_res; - } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)) - flush_scheduled_work(); -#endif + scsi_block_requests(instance->host); - if (state.event == PM_EVENT_FREEZE) { + if (state.event == PM_EVENT_FREEZE) suspend_type = PS3_SUSPEND_TYPE_HIBERNATE; - } LOG_INFO("event[%d] suspend_type[%d].\n", state.event, suspend_type); - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SUSPEND, suspend_type) != PS3_SUCCESS) { + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_SUSPEND, + suspend_type) != PS3_SUCCESS) { LOG_ERROR("device[%d] unload NOK.\n", pdev->dev.id); if (ps3_hard_reset_to_ready_with_doorbell(instance) != - PS3_SUCCESS) { + PS3_SUCCESS) { LOG_ERROR("device[%d] hard reset NOK.\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } goto l_release_res; l_reset_to_ready: - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, instance) - if (!instance ->is_half_hard_reset) { + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET_1, instance); + if (!instance->is_half_hard_reset) { instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); @@ -1681,16 +1739,13 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) ps3_dump_work_stop(instance); ps3_watchdog_stop(instance); ps3_recovery_cancel_work_sync(instance); - if (instance ->is_half_hard_reset) { - goto l_release_res; - } + if (instance->is_half_hard_reset) + goto l_half_reset; - if (ps3_hard_reset_to_ready_with_doorbell(instance) != - PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK.\n", - PS3_HOST(instance)); - } + if (ps3_hard_reset_to_ready_with_doorbell(instance) != PS3_SUCCESS) + LOG_ERROR("device[%d] hard reset NOK.\n", PS3_HOST(instance)); +l_half_reset: if (instance->event_context.event_cmd != NULL) { cmd = instance->event_context.event_cmd; instance->event_context.event_cmd = NULL; @@ -1700,86 +1755,93 @@ static int ps3_suspend(struct pci_dev *pdev, pm_message_t state) instance->event_context.event_abort_cmd = NULL; ps3_task_cmd_free(instance, abort_cmd); } - instance->event_context.subwork = 0; + ps3_atomic_set(&instance->event_context.subwork, 0); } ps3_dev_mgr_vd_info_clear(instance); - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ps3_web_cmd_clear(instance); } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,6,0)) - flush_scheduled_work(); -#endif + INJECT_START(PS3_ERR_IJ_SUSPEND_END, instance); + scsi_block_requests(instance->host); l_release_res: - INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance) + INJECT_START(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, instance); pci_set_drvdata(instance->pdev, instance); pci_save_state(pdev); - instance ->is_half_hard_reset = PS3_FALSE; + instance->is_half_hard_reset = PS3_FALSE; ps3_base_free_resources(instance); ps3_instance_put(instance); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x ps3_suspend end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_suspend = PS3_FALSE; return PS3_SUCCESS; } static int ps3_resume(struct pci_dev *pdev) { - S32 ret = PS3_SUCCESS; - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + int ret = PS3_SUCCESS; + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); INJECT_START(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, &instance); if (instance == NULL) { - LOG2_ERROR("device[%d] ps3_resume NOK\n", pdev->dev.id); + LOG2_ERROR("device[%d] %s NOK\n", pdev->dev.id, __func__); return PS3_SUCCESS; } - LOG2_WARN("PCI Device %04x:%02x:%02x:%x ps3_resume start.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s start.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); instance->is_resume = PS3_TRUE; - mb(); + mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(instance); pci_restore_state(pdev); instance->pdev = pdev; - if (ps3_instance_add(instance) != PS3_SUCCESS) { + if (ps3_instance_add(instance) != PS3_SUCCESS) goto l_out; - } INJECT_START(PS3_ERR_IJ_WAIT_RESUME_FUNCID_INVALID, instance); - if (ps3_avaliable_func_id_query() < PS3_FUNC_UNLIMITED && - (U32)ps3_get_pci_function(pdev) != ps3_avaliable_func_id_query()) { - LOG2_WARN("Function %d not avaliable\n", ps3_get_pci_function(pdev)); + if (ps3_available_func_id_query() < PS3_FUNC_UNLIMITED && + (unsigned int)ps3_get_pci_function(pdev) != ps3_available_func_id_query()) { + LOG2_WARN("Function %d not available\n", + ps3_get_pci_function(pdev)); goto l_out; } ret = ps3_base_init_resources(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u base init resources NOK, ret: %d\n", PS3_HOST(instance), ret); + LOG_ERROR("hno:%u base init resources NOK, ret: %d\n", + PS3_HOST(instance), ret); goto l_out; } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != + PS3_SUCCESS) { goto l_out; } - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_READY); ps3_all_reply_fifo_init(instance); - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) goto l_out; - } - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_PRE_OPERATIONAL); instance->ioc_adpter->irq_enable(instance); - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_OPERATIONAL); instance->state_machine.is_load = PS3_TRUE; scsi_unblock_requests(instance->host); @@ -1788,16 +1850,17 @@ static int ps3_resume(struct pci_dev *pdev) INJECT_START(PS3_ERR_IJ_WAIT_RESUME_WAIT_RECOVERY, instance); ret = ps3_watchdog_start(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } - instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; + instance->event_req_info.eventTypeMapProcResult = + instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); if (ret == -PS3_FAILED) { goto l_out; } else if (ret == -PS3_RECOVERED) { - LOG_INFO("device[%d] skip event/vd info subscribe due to recovery during probe\n", + LOG_INFO( + "device[%d] skip event/vd info subscribe due to recovery during probe\n", pdev->dev.id); goto l_event_subscribe_recovered; } @@ -1805,23 +1868,24 @@ static int ps3_resume(struct pci_dev *pdev) ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS && ret != -PS3_RECOVERED) { LOG_INFO("device[%d] vd info subscribe NOK, ret: %d\n", - pdev->dev.id, ret); + pdev->dev.id, ret); goto l_out; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { + if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) goto l_out; - } } l_event_subscribe_recovered: instance->state_machine.is_suspend = PS3_FALSE; instance->is_probe_finish = PS3_TRUE; instance->is_resume = PS3_FALSE; - LOG2_WARN("PCI Device %04x:%02x:%02x:%x ps3_resume end.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s end.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); return PS3_SUCCESS; @@ -1832,16 +1896,18 @@ static int ps3_resume(struct pci_dev *pdev) ps3_instance_state_transfer_to_dead(instance); scsi_unblock_requests(instance->host); ps3_dma_dump_mapping(pdev); - LOG2_WARN("PCI Device %04x:%02x:%02x:%x ps3_resume NOK.\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG2_WARN("PCI Device %04x:%02x:%02x:%x %s NOK.\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), __func__); return -ENODEV; } -#endif +#endif static ssize_t version_show(struct device_driver *dd, char *buf) { (void)dd; - return snprintf(buf, strlen(PS3_DRV_VERSION) + 2, "%s\n", PS3_DRV_VERSION); + return snprintf(buf, strlen(PS3_DRV_VERSION) + 2, "%s\n", + PS3_DRV_VERSION); } static DRIVER_ATTR_RO(version); @@ -1853,16 +1919,15 @@ static ssize_t release_date_show(struct device_driver *dd, char *buf) } static DRIVER_ATTR_RO(release_date); -static const struct file_operations ps3_mgmt_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = ps3_ioctl_fops, - .open = ps3_mgmt_open, - .release = NULL, - .llseek = noop_llseek, - .read = NULL, - .write = NULL, - .fasync = ps3_fasync -}; +static const struct file_operations ps3_mgmt_fops = { .owner = THIS_MODULE, + .unlocked_ioctl = + ps3_ioctl_fops, + .open = ps3_mgmt_open, + .release = NULL, + .llseek = noop_llseek, + .read = NULL, + .write = NULL, + .fasync = ps3_fasync }; static struct pci_driver ps3_pci_driver; static void init_pci_driver(struct pci_driver *drv) @@ -1876,42 +1941,38 @@ static void init_pci_driver(struct pci_driver *drv) drv->resume = ps3_resume; #endif drv->shutdown = ps3_shutdown; - if (ps3_aer_handle_support_query()) { + if (ps3_aer_handle_support_query()) ps3_pci_err_handler_init(drv); - } else { + else LOG_INFO("aer handle not supported\n"); - } - - return; } static int __init ps3stor_init(void) { int ret = PS3_SUCCESS; - printk(KERN_WARNING "ps3stor driver init start, version[%s], commit_id[%s], " - "build_time[%s], toolchain_id[%s]\n", - PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, - PS3_DRV_BUILD_TIME, PS3_DRV_TOOLCHAIN_ID); + + pr_warn("ps3stor driver init start, version[%s], commit_id[%s], build_time[%s], toolchain_id[%s]\n", + PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, PS3_DRV_BUILD_TIME, + PS3_DRV_TOOLCHAIN_ID); ret = ps3_debug_init(); INJECT_START(PS3_ERR_IJ_FORCE_DEBUG_INIT_FAIL, &ret); if (ret < 0) { - printk(KERN_ERR "ps3stor log init fail\n"); + pr_err("ps3stor log init fail\n"); goto l_debug_init_failed; } ps3_host_info_get(); ps3cmd_init(); ps3_mgmt_info_init(); - LOG_FILE_WARN("ps3stor driver version[%s], commit_id[%s]," - "build_time[%s], toolchain_id[%s]\n", - PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, - PS3_DRV_BUILD_TIME, PS3_DRV_TOOLCHAIN_ID); + LOG_FILE_WARN("ps3stor driver ver[%s], commit_id[%s], build_time[%s], toolchain_id[%s]\n", + PS3_DRV_VERSION, PS3_DRV_COMMIT_ID, PS3_DRV_BUILD_TIME, + PS3_DRV_TOOLCHAIN_ID); ret = ps3_sas_attach_transport(); INJECT_START(PS3_ERR_IJ_FORCE_TRANSPORT_INIT_FAIL, &ret); if (ret != PS3_SUCCESS) { - printk(KERN_ERR "ps3stor transport fail\n"); + pr_err("ps3stor transport fail\n"); ret = -ENODEV; goto l_sas_transport_failed; } @@ -1928,21 +1989,19 @@ static int __init ps3stor_init(void) ret = pci_register_driver(&ps3_pci_driver); INJECT_START(PS3_ERR_IJ_FORCE_PCIDRV_INIT_FAIL, &ret); if (ret) { - LOG_ERROR("ps3stor: PCI hotplug registration failed \n"); + LOG_ERROR("ps3stor: PCI hotplug registration failed\n"); goto l_pci_register_driver_failed; } ret = driver_create_file(&ps3_pci_driver.driver, &driver_attr_version); INJECT_START(PS3_ERR_IJ_FORCE_VERFILE_INIT_FAIL, &ret); - if (ret) { + if (ret) goto l_attr_ver_failed; - } ret = driver_create_file(&ps3_pci_driver.driver, - &driver_attr_release_date); + &driver_attr_release_date); INJECT_START(PS3_ERR_IJ_FORCE_VERFILE2_INIT_FAIL, &ret); - if (ret) { + if (ret) goto l_attr_release_date_failed; - } ps3_trace_id_init(); ps3_version_verbose_fill(); @@ -1977,7 +2036,6 @@ static void __exit ps3stor_exit(void) ps3_debug_exit(); ps3cmd_exit(); ps3_mgmt_exit(); - return; } MODULE_INFO(private_version, PS3_PRIVATE_VERSION); diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c index 893dfd432f6d..b800496d1052 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.c @@ -1,7 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include -#include +#include #include #include #include @@ -13,43 +14,59 @@ #include #include "ps3_cli.h" #include "ps3_instance_manager.h" +#include "ps3_kernel_version.h" +#include "ps3_util.h" #define PS3_CLI_STATIC_MINOR 26 #define PS3_CLI_DYNAMIC_MINOR MISC_DYNAMIC_MINOR -#define PS3_CLI_HASH_LEN 256 +#define PS3_CLI_HASH_LEN 256 struct ps3_cli_cmd_s { - struct ps3_cli_cmd_s *next; - char cmd[PS3_CLI_CMD_MAXLEN]; - char help[PS3_CLI_HELP_LEN]; - ps3_cli_func_t func; + struct ps3_cli_cmd_s *next; + char cmd[PS3_CLI_CMD_MAXLEN]; + char help[PS3_CLI_HELP_LEN]; + void (*func)(int argc, char *argv[]); }; -static int misc_registered; -static ps3_atomic32 dev_opened; -static int cmd_ready; -static char ps3_cli_input[PS3_CLI_INPUT_LEN]; -static char ps3_cli_output[PS3_CLI_OUTLINE_LEN]; -static char __user *read_buf; -static int read_buf_len; -static int read_buf_ptr; +static int misc_registered; +static atomic_t dev_opened; +static int cmd_ready; +static char ps3_cli_input[PS3_CLI_INPUT_LEN]; +static char ps3_cli_output[PS3_CLI_OUTLINE_LEN]; +static char __user *read_buf; +static int read_buf_len; +static int read_buf_ptr; -static struct ps3_cli_cmd_s *ps3_cli_cmd_head[PS3_CLI_HASH_LEN]; -static struct mutex ps3_cli_mutex; +static struct ps3_cli_cmd_s *ps3_cli_cmd_head[PS3_CLI_HASH_LEN]; +static struct mutex ps3_cli_mutex; -#if 0 -#define __pl() printk("func = %s, line = %d\n", __FUNCTION__, __LINE__) -#else #define __pl() + +static inline int ps3_cli_minor_get(void) +{ + if (strstr(ps3_host_release_get(), "an8")) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 134)) + return PS3_CLI_DYNAMIC_MINOR; +#else + return PS3_CLI_STATIC_MINOR; +#endif + } else if (strstr(ps3_host_release_get(), "al8")) + return PS3_CLI_DYNAMIC_MINOR; + +#if defined(PS3_STATIC_MINOR) + return PS3_CLI_STATIC_MINOR; +#else + return PS3_CLI_DYNAMIC_MINOR; #endif +} static ssize_t ps3_cli_write(struct file *fp, const char __user *buffer, - size_t nbytes, loff_t *ppos) + size_t nbytes, loff_t *ppos) { __pl(); (void)fp; (void)ppos; - if (nbytes>PS3_CLI_INPUT_LEN-1) + if (nbytes > PS3_CLI_INPUT_LEN - 1) return -EINVAL; if (copy_from_user(ps3_cli_input, buffer, nbytes)) @@ -63,10 +80,10 @@ static ssize_t ps3_cli_write(struct file *fp, const char __user *buffer, static u32 str_hash(const char *name) { u32 hash, hash0 = 0x12a3fe2d, hash1 = 0x37abe8f9; - const signed char *scp = (const signed char*)name; + const signed char *scp = (const signed char *)name; while (*scp) { - hash = hash1 + (hash0 ^ (((int) *scp++) * 7152373)); + hash = hash1 + (hash0 ^ (((int)*scp++) * 7152373)); if (hash & 0x80000000) hash -= 0x7fffffff; @@ -78,10 +95,10 @@ static u32 str_hash(const char *name) static struct ps3_cli_cmd_s *ps3_cli_find_cmd(const char *cmd) { - u32 idx = str_hash(cmd) & (PS3_CLI_HASH_LEN-1); + u32 idx = str_hash(cmd) & (PS3_CLI_HASH_LEN - 1); struct ps3_cli_cmd_s *p; - for (p=ps3_cli_cmd_head[idx]; p; p=p->next) + for (p = ps3_cli_cmd_head[idx]; p; p = p->next) if (!strcmp(p->cmd, cmd)) return p; return NULL; @@ -98,16 +115,15 @@ int ps3stor_cli_printf(const char *fmt, ...) len = vsnprintf(ps3_cli_output, PS3_CLI_OUTLINE_LEN, fmt, args); va_end(args); - if (read_buf_ptr>=read_buf_len) { + if (read_buf_ptr >= read_buf_len) return read_buf_ptr; - } - n = read_buf_len-read_buf_ptr; - if (n>len) + n = read_buf_len - read_buf_ptr; + if (n > len) n = len; - ret = copy_to_user(read_buf+read_buf_ptr, ps3_cli_output, n); - if (ret<0) { + ret = copy_to_user(read_buf + read_buf_ptr, ps3_cli_output, n); + if (ret < 0) { pr_err("copy_to_user err=%d\n", ret); return -1; } @@ -120,17 +136,19 @@ int ps3stor_cli_printf(const char *fmt, ...) } EXPORT_SYMBOL(ps3stor_cli_printf); -int ps3stor_cli_register(ps3_cli_func_t func, const char *cmd_str, const char *help) +int ps3stor_cli_register(void (*func)(int argc, char *argv[]), const char *cmd_str, + const char *help) { - u32 idx = str_hash(cmd_str) & (PS3_CLI_HASH_LEN-1); + u32 idx = str_hash(cmd_str) & (PS3_CLI_HASH_LEN - 1); struct ps3_cli_cmd_s *cmd; int ret; __pl(); ret = mutex_lock_killable(&ps3_cli_mutex); - if (ret!=0) { - pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", ret); + if (ret != 0) { + pr_err("%s(): mutex_lock_killable return err = %d\n", + __func__, ret); return ret; } cmd = ps3_cli_find_cmd(cmd_str); @@ -140,17 +158,16 @@ int ps3stor_cli_register(ps3_cli_func_t func, const char *cmd_str, const char *h return -EEXIST; } - cmd = (struct ps3_cli_cmd_s *)kmalloc(sizeof(struct ps3_cli_cmd_s), GFP_KERNEL); - if (cmd==NULL) { - pr_err("out of memory\n"); + cmd = kmalloc(sizeof(struct ps3_cli_cmd_s), GFP_KERNEL); + if (cmd == NULL) { mutex_unlock(&ps3_cli_mutex); return -ENOMEM; } memset(cmd, 0, sizeof(struct ps3_cli_cmd_s)); - strncpy(cmd->cmd, cmd_str, PS3_CLI_CMD_MAXLEN - 1); - strncpy(cmd->help, help, PS3_CLI_HELP_LEN - 1); + PS3_STRCPY(cmd->cmd, cmd_str, PS3_CLI_CMD_MAXLEN - 1); + PS3_STRCPY(cmd->help, help, PS3_CLI_HELP_LEN - 1); cmd->func = func; @@ -166,10 +183,11 @@ EXPORT_SYMBOL(ps3stor_cli_register); static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) { char *p = cmdline; - int i=0, spc=1; - while(*p) { + int i = 0, spc = 1; + + while (*p) { if (spc) { - if (*p!=' ') { + if (*p != ' ') { spc = 0; argv[i] = p; i++; @@ -177,7 +195,7 @@ static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) *p = '\0'; } } else { - if (*p==' ') { + if (*p == ' ') { spc = 1; *p = '\0'; } else { @@ -188,8 +206,8 @@ static void ps3_parse_cmd(char *cmdline, int *argc, char *argv[]) *argc = i; } -static ssize_t ps3_cli_read(struct file *fp, char __user *buf, - size_t nbytes, loff_t *ppos) +static ssize_t ps3_cli_read(struct file *fp, char __user *buf, size_t nbytes, + loff_t *ppos) { struct ps3_cli_cmd_s *cmd; int argc; @@ -211,14 +229,14 @@ static ssize_t ps3_cli_read(struct file *fp, char __user *buf, ps3_parse_cmd(ps3_cli_input, &argc, argv); ret = mutex_lock_killable(&ps3_cli_mutex); - if (ret!=0) { - pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", ret); + if (ret != 0) { + pr_err("ps3stor_cli_register(): mutex_lock_killable return err = %d\n", + ret); return ret; } - cmd = ps3_cli_find_cmd((const char*)argv[0]); - if (cmd!=NULL) { + cmd = ps3_cli_find_cmd((const char *)argv[0]); + if (cmd != NULL) cmd->func(argc, argv); - } mutex_unlock(&ps3_cli_mutex); __pl(); @@ -229,7 +247,7 @@ static int ps3_cli_open(struct inode *ip, struct file *fp) { (void)ip; (void)fp; - if (!atomic_add_unless(&dev_opened, 1, 1)) { + if (atomic_cmpxchg(&dev_opened, 0, 1) == 1) { pr_err("/dev/ps3stor_cli has already been opened\n"); return -EBUSY; } @@ -245,21 +263,19 @@ static int ps3_cli_release(struct inode *ip, struct file *fp) return 0; } -static const struct file_operations ps3_cli_fops = { - .owner = NULL, - .unlocked_ioctl = NULL, - .open = ps3_cli_open, - .release = ps3_cli_release, - .llseek = NULL, - .read = ps3_cli_read, - .write = ps3_cli_write, - .fasync = NULL -}; +static const struct file_operations ps3_cli_fops = { .owner = NULL, + .unlocked_ioctl = NULL, + .open = ps3_cli_open, + .release = ps3_cli_release, + .llseek = NULL, + .read = ps3_cli_read, + .write = ps3_cli_write, + .fasync = NULL }; static struct miscdevice ps3_cli_device = { - .minor = PS3_CLI_STATIC_MINOR, - .name = "ps3stor_cli", - .fops = &ps3_cli_fops, + .minor = PS3_CLI_STATIC_MINOR, + .name = "ps3stor_cli", + .fops = &ps3_cli_fops, }; static void ps3_cli_help(int argc, char *argv[]) @@ -269,9 +285,10 @@ static void ps3_cli_help(int argc, char *argv[]) (void)argc; (void)argv; __pl(); - for (i=0; inext) { - ps3stor_cli_printf("%20s -- %s\n", cmd->cmd, (const char*)cmd->help); + for (i = 0; i < PS3_CLI_HASH_LEN; i++) { + for (cmd = ps3_cli_cmd_head[i]; cmd != NULL; cmd = cmd->next) { + ps3stor_cli_printf("%20s -- %s\n", cmd->cmd, + (const char *)cmd->help); } } __pl(); @@ -281,7 +298,8 @@ static void ps3_free_cmds(void) { int i; struct ps3_cli_cmd_s *cmd; - for (i=0; inext; @@ -300,14 +318,15 @@ int ps3cmd_init(void) ps3_atomic_set(&dev_opened, 0); mutex_init(&ps3_cli_mutex); - ps3_cli_device.minor = PS3_CLI_DYNAMIC_MINOR; + ps3_cli_device.minor = ps3_cli_minor_get(); err = misc_register(&ps3_cli_device); if (err) { pr_warn("Couldn't initialize miscdevice /dev/ps3stor_cli.\n"); return err; } misc_registered = 1; - ps3stor_cli_register(ps3_cli_help, "help", "show this help information"); + ps3stor_cli_register(ps3_cli_help, "help", + "show this help information"); return 0; } @@ -320,4 +339,3 @@ void ps3cmd_exit(void) misc_registered = 0; mutex_destroy(&ps3_cli_mutex); } - diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h index cb2a74725761..3531befc68fe 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli.h @@ -1,17 +1,16 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CLI_H_ #define _PS3_CLI_H_ -#define PS3_CLI_INPUT_LEN 2048 -#define PS3_CLI_OUTPUT_MAX (16*1024*1024) -#define PS3_CLI_OUTLINE_LEN 4096 -#define PS3_CLI_HELP_LEN 256 -#define PS3_CLI_CMD_MAXLEN 32 -#define PS3_MAX_ARGV 64 - -typedef void (*ps3_cli_func_t)(int argc, char *argv[]); +#define PS3_CLI_INPUT_LEN 2048 +#define PS3_CLI_OUTPUT_MAX (16 * 1024 * 1024) +#define PS3_CLI_OUTLINE_LEN 4096 +#define PS3_CLI_HELP_LEN 256 +#define PS3_CLI_CMD_MAXLEN 32 +#define PS3_MAX_ARGV 64 -int ps3stor_cli_register(ps3_cli_func_t func, const char *cmd_str, const char *help); +int ps3stor_cli_register(void (*func)(int argc, char *argv[]), const char *cmd_str, + const char *help); int ps3stor_cli_printf(const char *fmt, ...); @@ -20,5 +19,5 @@ int ps3cmd_init(void); void ps3cmd_exit(void); -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c index 4dce44cccfb1..8680dff8d9e9 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -41,7 +42,7 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]); static void ps3_cli_crashdump_set(int argc, char *argv[]); static void ps3_cli_force_to_stop(int argc, char *argv[]); static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]); -static void ps3_io_statis_clear_cli_cb(int argc, char *argv []); +static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]); static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]); static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]); static void ps3_scsi_device_lookup_cb(int argc, char *argv[]); @@ -59,14 +60,14 @@ static void ps3_cli_remove_host_force(int argc, char *argv[]); static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]); static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]); static void ps3_cli_ramfs_test_set(int argc, char *argv[]); -static void ps3_cli_err_inject_active(int argc, char *argv[]); -static void ps3_cli_err_inject_clear(int argc, char *argv[]); static void ps3_no_wait_cli_cmd(int argc, char *argv[]); static void ps3_cli_qos_info(int argc, char *argv[]); -static void ps3_cli_special_log(int argc, char *argv[]); +static void ps3_cli_special_log(int argc, char *argv[]); -static Bool ps3_cli_wait_flag = PS3_FALSE; +static unsigned char ps3_cli_wait_flag = PS3_FALSE; #ifdef PS3_SUPPORT_INJECT +static void ps3_cli_err_inject_active(int argc, char *argv[]); +static void ps3_cli_err_inject_clear(int argc, char *argv[]); static void ps3_show_inject_scsi_rw(int argc, char *argv[]); static void ps3_show_inject_scsi_task(int argc, char *argv[]); static void ps3_show_inject_mgr(int argc, char *argv[]); @@ -83,215 +84,238 @@ static void ps3_show_all_inject(int argc, char *argv[]); static void ps3_clear_hit_cmd(int argc, char *argv[]); #endif struct ps3_cli_debug_cmd { - ps3_cli_func_t func; - const char *func_name; - const char *help; + void (*func)(int argc, char *argv[]); + const char *func_name; + const char *help; }; static struct ps3_cli_debug_cmd g_ps3_cli_debug_cmd_table[] = { - {ps3_cli_host_and_instance_ls, "ls", "ls option[host][instance][all]"}, - {ps3_cli_register_rw, "register_rw", - "register_rw host_no xxx(host number) name/offset xxx(reg name/offset) read/write xxx(reg value)"}, - {ps3_cli_register_dump, "register_dump", - "register_dump host_no xxx(host number)"}, - {ps3_cli_init_frame_dump, "init_frame_dump", - "init_frame_dump host_no xxx(host number)"}, - {ps3_cli_event_subscirbe_info_dump, - "event_subscribe_dump", - "event_subscribe_dump host_no xxx(host number)"}, - {ps3_cli_event_delay_set, - "event_delay_set", - "event_delay_set host_no xxx(host number) delay xxx(seconds)"}, - {ps3_cli_crashdump_set, - "crashdump", - "crashdump host_no xxx(host number) wait xxx(seconds)"}, - {ps3_cli_dev_mgr_cli_base_dump, "dmbi", - "device manager base infomation: dmbi option[vd][pd][all]"}, - {ps3_cli_dev_mgr_cli_detail_dump, "dmdi", - "device manager detail infomation: dmdi "}, - {ps3_cli_reply_fifo_dump, "reply_fifo_dump", - "reply_fifo_dump host_no xxx(host number) isr_sn xxx(isr SN) \ - option[start_idx xxx default: last_reply_idx][count xxx default: 100]"}, - {ps3_cli_cmd_dump, "cmd_dump", - "cmd_dump host_no xxx(host number) cmd_frame_id xxx(cmd_frame_id)"}, - {ps3_io_statis_dump_cli_cb, "show", - "show io statis (detail|summary)"}, - {ps3_io_statis_clear_cli_cb, "clear", - "clear io statis "}, - {ps3_cli_force_to_stop, "force_to_stop", "force_to_stop"}, - {ps3_debug_mem_para_cli_cb, "debug_mem_para_dump", - "debug_mem_para_dump host_no xxx(host no)"}, - {ps3_debug_mem_rw_cli_cb, "debug_mem", - "debug_mem host_no (host no) entry_index(0--max entry count) dir(0 read/1 write) length(Bytes)"}, - {ps3_scsi_device_lookup_cb, - "scsi_device_dump", "scsi_device_dump host_no xxx(host number)"}, - {ps3_hard_reset_cb, - "hard_reset", "hard_reset host_no xxx(host number)"}, - {ps3_soc_halt_cb, - "soc_halt", "soc_halt host_no xxx(host number)"}, - {ps3_cmd_stat_switch_store_cb, "cmd_stat_switch_store", - "cmd_stat_switch_store host_no xxx(host number) value xxx mask xxx" - "[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN," - " bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]"}, - {ps3_cmd_stat_switch_show_cb, - "cmd_stat_switch_show", "cmd_stat_switch_show host_no xxx"}, - {ps3_stat_total_show_cb, "cmd_stat_dump", "cmd_stat_dump host_no xxx"}, - {ps3_stat_inc_show_cb, "inc_stat_dump", "inc_stat_dump host_no xxx"}, - {ps3_stat_buf_clr_cb, "cmd_stat_clear", "cmd_stat_clear host_no xxx"}, - {ps3_stat_interval_show_cb, "cmd_stat_interval_show", - "cmd_stat_interval_show host_no xxx"}, - {ps3_stat_interval_store_cb, "cmd_stat_interval_store", - "cmd_stat_interval_store host_no xxx interval xxx(ms)"}, - {ps3_reply_fifo_reset_cb, "ps3_all_reply_fifo_reset", - "ps3_all_reply_fifo_reset host_no xxx"}, - {ps3_cli_remove_host_force, "remove_host", - "remove one host and free resource: (host number)"}, - {ps3_hardreset_cnt_clear_cli_cb, "hardreset_cnt_clear", - "hardreset_cnt_clear host_no xxx(host number)"}, - {ps3_hardreset_cnt_show_cli_cb, "hardreset_cnt_show", - "hardreset_cnt_show host_no xxx(host number)"}, - {ps3_cli_ramfs_test_set, "ramfs_test_set", - "set or clear filesystem type to ramfs: (0: clear, 1: set)"}, - {ps3_cli_err_inject_active, "err_inject", - "err_inject err_type count"}, - {ps3_cli_err_inject_clear, "cli_err_clear", - ""}, - {ps3_no_wait_cli_cmd, "ps3_no_wait_cli_cmd", - "clean_wait_cli_cmd flag xxx"}, - {ps3_cli_qos_info, "qos_dump", - "qos_dump host_no xxx(host number) pd/vd xxx(id) | all"}, - {ps3_cli_special_log, "spe_log", - "spe_log host_no xxx(host number) set xxx(0/1)"}, + { ps3_cli_host_and_instance_ls, "ls", + "ls option[host][instance][all]" }, + { ps3_cli_register_rw, "register_rw", + "register_rw host_no xxx(host num) name/offset xxx(name/offset) read/write xxx(value)" }, + { ps3_cli_register_dump, "register_dump", + "register_dump host_no xxx(host number)" }, + { ps3_cli_init_frame_dump, "init_frame_dump", + "init_frame_dump host_no xxx(host number)" }, + { ps3_cli_event_subscirbe_info_dump, "event_subscribe_dump", + "event_subscribe_dump host_no xxx(host number)" }, + { ps3_cli_event_delay_set, "event_delay_set", + "event_delay_set host_no xxx(host number) delay xxx(seconds)" }, + { ps3_cli_crashdump_set, "crashdump", + "crashdump host_no xxx(host number) wait xxx(seconds)" }, + { ps3_cli_dev_mgr_cli_base_dump, "dmbi", + "device manager base information: dmbi option[vd][pd][all]" }, + { ps3_cli_dev_mgr_cli_detail_dump, "dmdi", + "device manager detail information: dmdi " }, + { ps3_cli_reply_fifo_dump, "reply_fifo_dump", + "reply_fifo_dump host_no xxx(host number) isr_sn xxx(isr SN)\n" + "\t\toption[start_idx xxx default: last_reply_idx][count xxx default: 100]" }, + { ps3_cli_cmd_dump, "cmd_dump", + "cmd_dump host_no xxx(host number) cmd_frame_id xxx(cmd_frame_id)" }, + { ps3_io_statis_dump_cli_cb, "show", + "show io statis (detail|summary)" }, + { ps3_io_statis_clear_cli_cb, "clear", + "clear io statis " }, + { ps3_cli_force_to_stop, "force_to_stop", "force_to_stop" }, + { ps3_debug_mem_para_cli_cb, "debug_mem_para_dump", + "debug_mem_para_dump host_no xxx(host no)" }, + { ps3_debug_mem_rw_cli_cb, "debug_mem", + "debug_mem host_no (host no) entry_index(0--max entry cnt) dir(0/1 r/w) length(Bytes)" }, + { ps3_scsi_device_lookup_cb, "scsi_device_dump", + "scsi_device_dump host_no xxx(host number)" }, + { ps3_hard_reset_cb, "hard_reset", + "hard_reset host_no xxx(host number)" }, + { ps3_soc_halt_cb, "soc_halt", "soc_halt host_no xxx(host number)" }, + { ps3_cmd_stat_switch_store_cb, "cmd_stat_switch_store", + "cmd_stat_switch_store host_no xxx(host number) value xxx mask xxx\n" + "\t\t[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN,\n" + "\t\tbit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]" }, + { ps3_cmd_stat_switch_show_cb, "cmd_stat_switch_show", + "cmd_stat_switch_show host_no xxx" }, + { ps3_stat_total_show_cb, "cmd_stat_dump", + "cmd_stat_dump host_no xxx" }, + { ps3_stat_inc_show_cb, "inc_stat_dump", "inc_stat_dump host_no xxx" }, + { ps3_stat_buf_clr_cb, "cmd_stat_clear", "cmd_stat_clear host_no xxx" }, + { ps3_stat_interval_show_cb, "cmd_stat_interval_show", + "cmd_stat_interval_show host_no xxx" }, + { ps3_stat_interval_store_cb, "cmd_stat_interval_store", + "cmd_stat_interval_store host_no xxx interval xxx(ms)" }, + { ps3_reply_fifo_reset_cb, "ps3_all_reply_fifo_reset", + "ps3_all_reply_fifo_reset host_no xxx" }, + { ps3_cli_remove_host_force, "remove_host", + "remove one host and free resource: (host number)" }, + { ps3_hardreset_cnt_clear_cli_cb, "hardreset_cnt_clear", + "hardreset_cnt_clear host_no xxx(host number)" }, + { ps3_hardreset_cnt_show_cli_cb, "hardreset_cnt_show", + "hardreset_cnt_show host_no xxx(host number)" }, + { ps3_cli_ramfs_test_set, "ramfs_test_set", + "set or clear filesystem type to ramfs: (0: clear, 1: set)" }, + { ps3_no_wait_cli_cmd, "ps3_no_wait_cli_cmd", + "clean_wait_cli_cmd flag xxx" }, + { ps3_cli_qos_info, "qos_dump", + "qos_dump host_no xxx(host number) pd/vd xxx(id) | all" }, + { ps3_cli_special_log, "spe_log", + "spe_log host_no xxx(host number) set xxx(0/1)" }, #ifdef PS3_SUPPORT_INJECT - {ps3_inject_scsi_rw, "inject_rw", - "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx(1 timeout_force_reply/2 error_reply)\ -result xxx(scsi->result) sense xxx(resp_code-key-asc-ascq) times xxx"}, - {ps3_show_inject_scsi_rw, "show_inject_rw", - "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx"}, - {ps3_clear_inject_scsi_rw, "clear_inject_rw", - "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx"}, - {ps3_inject_scsi_task, "inject_scsi_task", - "host_no xxx(host number) dev xxx xxx(channel id) abort/reset (3 timeout/4 error_reply) times xxx"}, - {ps3_inject_mgr, "inject_mgr", - "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx xxx (7 timeout/8 error_reply xxx (errType)) times xxx"}, - {ps3_show_inject_scsi_task, "show_inject_scsi_task", - "host_no xxx(host number) dev xxx xxx(channel id)"}, - {ps3_show_inject_mgr, "show_inject_mgr", - "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx"}, - {ps3_clear_inject_scsi_task, "clear_inject_scsi_task", - "host_no xxx(host number) dev xxx xxx(channel id)"}, - {ps3_clear_inject_mgr, "clear_inject_mgr", - "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx"}, - {ps3_clear_all_inject, "clear_inject_all", - "clear_inject_all"}, - {ps3_show_all_inject, "show_inject_all", - "show_inject_all"}, - {ps3_clear_hit_cmd, "ps3_clear_hit_cmd", - "ps3_clear_hit_cmd"}, + { ps3_cli_err_inject_active, "err_inject", + "err_inject err_type count" }, + { ps3_cli_err_inject_clear, "cli_err_clear", "" }, + { ps3_inject_scsi_rw, "inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx\n" + "\t\t(1 timeout_force_reply/2 error_reply)\n" + "\t\tresult xxx(scsi->result) sense xxx(resp_code-key-asc-ascq) times xxx" }, + { ps3_show_inject_scsi_rw, "show_inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx" }, + { ps3_clear_inject_scsi_rw, "clear_inject_rw", + "host_no xxx(host number) dev xxx xxx(channel id) lba xxx len xxx xxx" }, + { ps3_inject_scsi_task, "inject_scsi_task", + "host_no xxx dev xxx xxx(chan id) abort/reset (3 timeout/4 error_reply) times xxx" }, + { ps3_inject_mgr, "inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx xxx\n" + "\t\t(7 timeout/8 error_reply xxx (errType)) times xxx" }, + { ps3_show_inject_scsi_task, "show_inject_scsi_task", + "host_no xxx(host number) dev xxx xxx(channel id)" }, + { ps3_show_inject_mgr, "show_inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx" }, + { ps3_clear_inject_scsi_task, "clear_inject_scsi_task", + "host_no xxx(host number) dev xxx xxx(channel id)" }, + { ps3_clear_inject_mgr, "clear_inject_mgr", + "host_no xxx(host number) cmd_type xxx cmd_sub_type xxx" }, + { ps3_clear_all_inject, "clear_inject_all", "clear_inject_all" }, + { ps3_show_all_inject, "show_inject_all", "show_inject_all" }, + { ps3_clear_hit_cmd, "ps3_clear_hit_cmd", "ps3_clear_hit_cmd" }, #endif }; -#define DRIVER_REGISTER_DEBUG_SIMULATOR -#define REG_OFFSET(member) (offsetof(Ps3Fifo_s, member)) +#define DRIVER_REGISTER_DEBUG_SIMULATOR +#define REG_OFFSET(member) (offsetof(struct Ps3Fifo, member)) struct ps3_reg_dump_desc { - const char *reg_name; - U32 reg_offset; - U32 reg_cnt; - Bool is_readable; + const char *reg_name; + unsigned int reg_offset; + unsigned int reg_cnt; + unsigned char is_readable; }; static struct ps3_reg_dump_desc g_reg_table[] = { - {"ps3RequestQueue", PS3_REG_OFFSET_REQUEST_QUE, 1, PS3_TRUE}, - {"ps3Doorbell", PS3_REG_OFFSET_DOORBELL, 1, PS3_FALSE}, - {"ps3DoorbellIrqClear", PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3DoorbellIrqMask", PS3_REG_OFFSET_DOORBELL_IRQ_MASK, 1, PS3_TRUE}, - {"ps3IrqControl", PS3_REG_OFFSET_IRQ_CONTROL, 1, PS3_TRUE}, - {"ps3SoftresetKey", PS3_REG_OFFSET_SOFTRESET_KEY, 1, PS3_TRUE}, - {"ps3SoftresetState", PS3_REG_OFFSET_SOFTRESET_STATE, 1, PS3_TRUE}, - {"ps3Softreset", PS3_REG_OFFSET_SOFTRESET, 1, PS3_TRUE}, - {"ps3SoftresetIrqClear", PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3SoftresetIrqMask", PS3_REG_OFFSET_SOFTRESET_IRQ_MASK, 1, PS3_TRUE}, - {"ps3SoftresetKeyShiftRegLow", PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE}, - {"ps3SoftresetKeyShiftRegHigh", PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE}, - {"ps3SoftresetTimeCnt", PS3_REG_OFFSET_SOFTRESET_TIME_CNT, 1, PS3_TRUE}, - {"ps3SoftresetTimeOutEn", PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT, 1, PS3_TRUE}, - {"ps3HardresetKey", PS3_REG_OFFSET_HARDRESET_KEY, 1, PS3_TRUE}, - {"ps3HardresetState", PS3_REG_OFFSET_HARDRESET_STATE, 1, PS3_TRUE}, - {"ps3Hardreset", PS3_REG_OFFSET_HARDRESET, 1, PS3_TRUE}, - {"ps3HardresetKeyShiftRegLow", PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE}, - {"ps3HardresetKeyShiftRegHigh", PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE}, - {"ps3HardresetTimeCnt", PS3_REG_OFFSET_HARDRESET_TIME_CNT, 1, PS3_TRUE}, - {"ps3HardresetTimeOutEn", PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT, 1, PS3_TRUE}, - {"ps3KeyGapCfg", PS3_REG_OFFSET_KEY_GAP_CFG, 1, PS3_TRUE}, - {"ps3HardresetIrqClear", PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3HardresetIrqMask", PS3_REG_OFFSET_HARDRESET_IRQ_MASK, 1, PS3_TRUE}, - {"ps3SocFwState", PS3_REG_OFFSET_SOC_FW_STATE, 1, PS3_TRUE}, - {"ps3MaxFwCmd", PS3_REG_OFFSET_MAX_FW_CMD, 1, PS3_TRUE}, - {"ps3MaxChainSize", PS3_REG_OFFSET_MAX_CHAIN_SIZE, 1, PS3_TRUE}, - {"ps3MaxVdInfoSize", PS3_REG_OFFSET_MAX_VD_INFO_SIZE, 1, PS3_TRUE}, - {"ps3MaxNvmePageSize", PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE, 1, PS3_TRUE}, - {"ps3FeatureSupport", PS3_REG_OFFSET_FEATURE_SUPPORT, 1, PS3_TRUE}, - {"ps3FirmwareVersion", PS3_REG_OFFSET_FIRMWARE_VERSION, 1, PS3_TRUE}, - {"ps3MaxReplyque", PS3_REG_OFFSET_REPLY_QUE, 1, PS3_TRUE}, - {"ps3HardwareVersion", PS3_REG_OFFSET_HARDWARE_VERSION, 1, PS3_TRUE}, - {"ps3MgrQueueDepth", PS3_REG_OFFSET_MGR_QUEUE_DEPTH, 1, PS3_TRUE}, - {"ps3CmdQueueDepth", PS3_REG_OFFSET_CMD_QUEUE_DEPTH, 1, PS3_TRUE}, - {"ps3TfifoDepth", PS3_REG_OFFSET_TFIFO_DEPTH, 1, PS3_TRUE}, - {"ps3MaxSecR1xCmds", PS3_REG_OFFSET_MAX_SEC_R1X_CMDS, 1, PS3_TRUE}, - {"ps3HilAdvice2directCnt0", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0, 1, PS3_TRUE}, - {"ps3HilAdvice2directCnt1", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1, 1, PS3_TRUE}, - {"ps3HilAdvice2directCnt2", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2, 1, PS3_TRUE}, - {"ps3HilAdvice2directCnt3", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3, 1, PS3_TRUE}, - {"ps3HilAdvice2directCntAll", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL, 1, PS3_TRUE}, - {"ps3IrqStatusRpt", PS3_REG_OFFSET_IRQ_STATUS_RPT, 1, PS3_TRUE}, - {"ps3DumpCtrl", PS3_REG_OFFSET_DUMP_CTRL, 1, PS3_FALSE}, - {"ps3DumpCtrlIrqClear", PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3DumpCtrlIrqMask", PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK, 1, PS3_TRUE}, - {"ps3DumpStatus", PS3_REG_OFFSET_DUMP_STATUS, 1, PS3_TRUE}, - {"ps3DumpDataSize", PS3_REG_OFFSET_DUMP_DATA_SIZE, 1, PS3_TRUE}, - {"ps3CmdTrigger", PS3_REG_OFFSET_CMD_TRIGGER, 1, PS3_TRUE}, - {"ps3CmdTriggerIrqClear", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3CmdTriggerIrqMask", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK, 1, PS3_TRUE}, - {"ps3RegCmdState", PS3_REG_OFFSET_REG_CMD_STATE, 1, PS3_TRUE}, - {"ps3SoftresetCounter", PS3_REG_OFFSET_SOFTRESET_COUNTER, 1, PS3_TRUE}, - {"ps3Debug0", PS3_REG_OFFSET_DEBUG0, 1, PS3_TRUE}, - {"ps3Debug0IrqClear", PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3Debug0IrqMask", PS3_REG_OFFSET_DEBUG0_IRQ_MASK, 1, PS3_TRUE}, - {"ps3Debug1", PS3_REG_OFFSET_DEBUG1, 1, PS3_TRUE}, - {"ps3Debug1IrqClear", PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3Debug1IrqMask", PS3_REG_OFFSET_DEBUG1_IRQ_MASK, 1, PS3_TRUE}, - {"ps3Debug2", PS3_REG_OFFSET_DEBUG2, 1, PS3_TRUE}, - {"ps3Debug2IrqClear", PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3Debug2IrqMask", PS3_REG_OFFSET_DEBUG2_IRQ_MASK, 1, PS3_TRUE}, - {"ps3Debug3", PS3_REG_OFFSET_DEBUG3, 1, PS3_TRUE}, - {"ps3Debug3IrqClear", PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3Debug3IrqMask", PS3_REG_OFFSET_DEBUG3_IRQ_MASK, 1, PS3_TRUE}, - {"ps3Debug4", PS3_REG_OFFSET_DEBUG4, 1, PS3_TRUE}, - {"ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_MASK, 1, PS3_TRUE}, - {"ps3Debug5", PS3_REG_OFFSET_DEBUG5, 1, PS3_TRUE}, - {"ps3Debug6", PS3_REG_OFFSET_DEBUG6, 1, PS3_TRUE}, - {"ps3Debug7", PS3_REG_OFFSET_DEBUG7, 1, PS3_TRUE}, - {"ps3Debug8", PS3_REG_OFFSET_DEBUG8, 1, PS3_TRUE}, - {"ps3Debug9", PS3_REG_OFFSET_DEBUG9, 1, PS3_TRUE}, - {"ps3Debug10", PS3_REG_OFFSET_DEBUG10, 1, PS3_TRUE}, - {"ps3Debug11", PS3_REG_OFFSET_DEBUG11, 1, PS3_TRUE}, - {"ps3Debug12", PS3_REG_OFFSET_DEBUG12, 1, PS3_TRUE}, - {"ps3SessioncmdAddr", PS3_REG_SESSION_ADDR, 1, PS3_TRUE}, - {"ps3SessioncmdAddrIrqClear", PS3_REG_SESSION_ADDR_IRQ_CLEAR, 1, PS3_TRUE}, - {"ps3SessioncmdAddrIrqMask", PS3_REG_SESSION_ADDR_IRQ_MASK, 1, PS3_TRUE}, + { "ps3RequestQueue", PS3_REG_OFFSET_REQUEST_QUE, 1, PS3_TRUE }, + { "ps3Doorbell", PS3_REG_OFFSET_DOORBELL, 1, PS3_FALSE }, + { "ps3DoorbellIrqClear", PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3DoorbellIrqMask", PS3_REG_OFFSET_DOORBELL_IRQ_MASK, 1, PS3_TRUE }, + { "ps3IrqControl", PS3_REG_OFFSET_IRQ_CONTROL, 1, PS3_TRUE }, + { "ps3SoftresetKey", PS3_REG_OFFSET_SOFTRESET_KEY, 1, PS3_TRUE }, + { "ps3SoftresetState", PS3_REG_OFFSET_SOFTRESET_STATE, 1, PS3_TRUE }, + { "ps3Softreset", PS3_REG_OFFSET_SOFTRESET, 1, PS3_TRUE }, + { "ps3SoftresetIrqClear", PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3SoftresetIrqMask", PS3_REG_OFFSET_SOFTRESET_IRQ_MASK, 1, + PS3_TRUE }, + { "ps3SoftresetKeyShiftRegLow", + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE }, + { "ps3SoftresetKeyShiftRegHigh", + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE }, + { "ps3SoftresetTimeCnt", PS3_REG_OFFSET_SOFTRESET_TIME_CNT, 1, + PS3_TRUE }, + { "ps3SoftresetTimeOutEn", PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT, 1, + PS3_TRUE }, + { "ps3HardresetKey", PS3_REG_OFFSET_HARDRESET_KEY, 1, PS3_TRUE }, + { "ps3HardresetState", PS3_REG_OFFSET_HARDRESET_STATE, 1, PS3_TRUE }, + { "ps3Hardreset", PS3_REG_OFFSET_HARDRESET, 1, PS3_TRUE }, + { "ps3HardresetKeyShiftRegLow", + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW, 1, PS3_TRUE }, + { "ps3HardresetKeyShiftRegHigh", + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH, 1, PS3_TRUE }, + { "ps3HardresetTimeCnt", PS3_REG_OFFSET_HARDRESET_TIME_CNT, 1, + PS3_TRUE }, + { "ps3HardresetTimeOutEn", PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT, 1, + PS3_TRUE }, + { "ps3KeyGapCfg", PS3_REG_OFFSET_KEY_GAP_CFG, 1, PS3_TRUE }, + { "ps3HardresetIrqClear", PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3HardresetIrqMask", PS3_REG_OFFSET_HARDRESET_IRQ_MASK, 1, + PS3_TRUE }, + { "ps3SocFwState", PS3_REG_OFFSET_SOC_FW_STATE, 1, PS3_TRUE }, + { "ps3MaxFwCmd", PS3_REG_OFFSET_MAX_FW_CMD, 1, PS3_TRUE }, + { "ps3MaxChainSize", PS3_REG_OFFSET_MAX_CHAIN_SIZE, 1, PS3_TRUE }, + { "ps3MaxVdInfoSize", PS3_REG_OFFSET_MAX_VD_INFO_SIZE, 1, PS3_TRUE }, + { "ps3MaxNvmePageSize", PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE, 1, + PS3_TRUE }, + { "ps3FeatureSupport", PS3_REG_OFFSET_FEATURE_SUPPORT, 1, PS3_TRUE }, + { "ps3FirmwareVersion", PS3_REG_OFFSET_FIRMWARE_VERSION, 1, PS3_TRUE }, + { "ps3MaxReplyque", PS3_REG_OFFSET_REPLY_QUE, 1, PS3_TRUE }, + { "ps3HardwareVersion", PS3_REG_OFFSET_HARDWARE_VERSION, 1, PS3_TRUE }, + { "ps3MgrQueueDepth", PS3_REG_OFFSET_MGR_QUEUE_DEPTH, 1, PS3_TRUE }, + { "ps3CmdQueueDepth", PS3_REG_OFFSET_CMD_QUEUE_DEPTH, 1, PS3_TRUE }, + { "ps3TfifoDepth", PS3_REG_OFFSET_TFIFO_DEPTH, 1, PS3_TRUE }, + { "ps3MaxSecR1xCmds", PS3_REG_OFFSET_MAX_SEC_R1X_CMDS, 1, PS3_TRUE }, + { "ps3HilAdvice2directCnt0", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0, 1, + PS3_TRUE }, + { "ps3HilAdvice2directCnt1", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1, 1, + PS3_TRUE }, + { "ps3HilAdvice2directCnt2", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2, 1, + PS3_TRUE }, + { "ps3HilAdvice2directCnt3", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3, 1, + PS3_TRUE }, + { "ps3HilAdvice2directCntAll", PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL, + 1, PS3_TRUE }, + { "ps3IrqStatusRpt", PS3_REG_OFFSET_IRQ_STATUS_RPT, 1, PS3_TRUE }, + { "ps3DumpCtrl", PS3_REG_OFFSET_DUMP_CTRL, 1, PS3_FALSE }, + { "ps3DumpCtrlIrqClear", PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3DumpCtrlIrqMask", PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK, 1, + PS3_TRUE }, + { "ps3DumpStatus", PS3_REG_OFFSET_DUMP_STATUS, 1, PS3_TRUE }, + { "ps3DumpDataSize", PS3_REG_OFFSET_DUMP_DATA_SIZE, 1, PS3_TRUE }, + { "ps3CmdTrigger", PS3_REG_OFFSET_CMD_TRIGGER, 1, PS3_TRUE }, + { "ps3CmdTriggerIrqClear", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3CmdTriggerIrqMask", PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK, 1, + PS3_TRUE }, + { "ps3RegCmdState", PS3_REG_OFFSET_REG_CMD_STATE, 1, PS3_TRUE }, + { "ps3SoftresetCounter", PS3_REG_OFFSET_SOFTRESET_COUNTER, 1, + PS3_TRUE }, + { "ps3Debug0", PS3_REG_OFFSET_DEBUG0, 1, PS3_TRUE }, + { "ps3Debug0IrqClear", PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR, 1, PS3_TRUE }, + { "ps3Debug0IrqMask", PS3_REG_OFFSET_DEBUG0_IRQ_MASK, 1, PS3_TRUE }, + { "ps3Debug1", PS3_REG_OFFSET_DEBUG1, 1, PS3_TRUE }, + { "ps3Debug1IrqClear", PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR, 1, PS3_TRUE }, + { "ps3Debug1IrqMask", PS3_REG_OFFSET_DEBUG1_IRQ_MASK, 1, PS3_TRUE }, + { "ps3Debug2", PS3_REG_OFFSET_DEBUG2, 1, PS3_TRUE }, + { "ps3Debug2IrqClear", PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR, 1, PS3_TRUE }, + { "ps3Debug2IrqMask", PS3_REG_OFFSET_DEBUG2_IRQ_MASK, 1, PS3_TRUE }, + { "ps3Debug3", PS3_REG_OFFSET_DEBUG3, 1, PS3_TRUE }, + { "ps3Debug3IrqClear", PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR, 1, PS3_TRUE }, + { "ps3Debug3IrqMask", PS3_REG_OFFSET_DEBUG3_IRQ_MASK, 1, PS3_TRUE }, + { "ps3Debug4", PS3_REG_OFFSET_DEBUG4, 1, PS3_TRUE }, + { "ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR, 1, PS3_TRUE }, + { "ps3Debug4IrqMask", PS3_REG_OFFSET_DEBUG4_IRQ_MASK, 1, PS3_TRUE }, + { "ps3Debug5", PS3_REG_OFFSET_DEBUG5, 1, PS3_TRUE }, + { "ps3Debug6", PS3_REG_OFFSET_DEBUG6, 1, PS3_TRUE }, + { "ps3Debug7", PS3_REG_OFFSET_DEBUG7, 1, PS3_TRUE }, + { "ps3Debug8", PS3_REG_OFFSET_DEBUG8, 1, PS3_TRUE }, + { "ps3Debug9", PS3_REG_OFFSET_DEBUG9, 1, PS3_TRUE }, + { "ps3Debug10", PS3_REG_OFFSET_DEBUG10, 1, PS3_TRUE }, + { "ps3Debug11", PS3_REG_OFFSET_DEBUG11, 1, PS3_TRUE }, + { "ps3Debug12", PS3_REG_OFFSET_DEBUG12, 1, PS3_TRUE }, + { "ps3SessioncmdAddr", PS3_REG_SESSION_ADDR, 1, PS3_TRUE }, + { "ps3SessioncmdAddrIrqClear", PS3_REG_SESSION_ADDR_IRQ_CLEAR, 1, + PS3_TRUE }, + { "ps3SessioncmdAddrIrqMask", PS3_REG_SESSION_ADDR_IRQ_MASK, 1, + PS3_TRUE }, }; static void ps3_cli_register_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { - ps3stor_cli_printf("malloc buf failed for register dump cli!\n"); + ps3stor_cli_printf( + "malloc buf failed for register dump cli!\n"); goto l_malloc_failed; } @@ -307,14 +331,15 @@ static void ps3_cli_register_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", - host_no); + ps3stor_cli_printf( + "Invalid host_no %d for register dump cmd!\n", host_no); goto l_out; } @@ -338,11 +363,12 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) struct ps3_instance *instance = NULL; struct ps3_cmd_context *cmd_context = NULL; struct PS3InitReqFrame *init_frame_msg = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 3) { - ps3stor_cli_printf("Too few args for init_frame_dump cli cmd!\n"); + ps3stor_cli_printf( + "Too few args for init_frame_dump cli cmd!\n"); goto l_out; } @@ -353,13 +379,15 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for init_frame_dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for init_frame_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for init_frame_dump cmd!\n", + ps3stor_cli_printf( + "Invalid host_no %d for init_frame_dump cmd!\n", host_no); goto l_out; } @@ -374,7 +402,7 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ps3stor_cli_printf("init frame:\n"); ps3stor_cli_printf("reqHead.cmdType:\t%u\n", - init_frame_msg->reqHead.cmdType); + init_frame_msg->reqHead.cmdType); ps3stor_cli_printf("length:\t%u\n", init_frame_msg->length); ps3stor_cli_printf("operater:\t%u\n", init_frame_msg->operater); ps3stor_cli_printf("pageSize:\t%u\n", init_frame_msg->pageSize); @@ -382,25 +410,30 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) ps3stor_cli_printf("msixVector:\t%u\n", init_frame_msg->msixVector); ps3stor_cli_printf("timeStamp:\t%llu\n", init_frame_msg->timeStamp); ps3stor_cli_printf("reqFrameBufBaseAddr:\t0x%llx\n", - init_frame_msg->reqFrameBufBaseAddr); + init_frame_msg->reqFrameBufBaseAddr); ps3stor_cli_printf("replyFifoDescBaseAddr:\t0x%llx\n", - init_frame_msg->replyFifoDescBaseAddr); + init_frame_msg->replyFifoDescBaseAddr); ps3stor_cli_printf("respFrameBaseAddr:\t0x%llx\n", - init_frame_msg->respFrameBaseAddr); - ps3stor_cli_printf("eventTypeMap:\t0x%08x\n", init_frame_msg->eventTypeMap); - ps3stor_cli_printf("reqFrameMaxNum:\t%u\n", init_frame_msg->reqFrameMaxNum); + init_frame_msg->respFrameBaseAddr); + ps3stor_cli_printf("eventTypeMap:\t0x%08x\n", + init_frame_msg->eventTypeMap); + ps3stor_cli_printf("reqFrameMaxNum:\t%u\n", + init_frame_msg->reqFrameMaxNum); ps3stor_cli_printf("respFrameMaxNum:\t%u\n", - init_frame_msg->respFrameMaxNum); + init_frame_msg->respFrameMaxNum); ps3stor_cli_printf("bufSizePerRespFrame:\t%u\n", - init_frame_msg->bufSizePerRespFrame); - ps3stor_cli_printf("hilMode:\t%u\n", - init_frame_msg->hilMode); + init_frame_msg->bufSizePerRespFrame); + ps3stor_cli_printf("hilMode:\t%u\n", init_frame_msg->hilMode); ps3stor_cli_printf("systemInfoBufAddr:\t0x%llx\n", - init_frame_msg->systemInfoBufAddr); - ps3stor_cli_printf("debugMemAddr:\t0x%llx\n", init_frame_msg->debugMemArrayAddr); - ps3stor_cli_printf("debugMemSize:\t%u\n", init_frame_msg->debugMemArrayNum); - ps3stor_cli_printf("filterTableAddr:\t0x%llx\n", init_frame_msg->filterTableAddr); - ps3stor_cli_printf("filterTableLen:\t%u\n", init_frame_msg->filterTableLen); + init_frame_msg->systemInfoBufAddr); + ps3stor_cli_printf("debugMemAddr:\t0x%llx\n", + init_frame_msg->debugMemArrayAddr); + ps3stor_cli_printf("debugMemSize:\t%u\n", + init_frame_msg->debugMemArrayNum); + ps3stor_cli_printf("filterTableAddr:\t0x%llx\n", + init_frame_msg->filterTableAddr); + ps3stor_cli_printf("filterTableLen:\t%u\n", + init_frame_msg->filterTableLen); ps3stor_cli_printf("respStatus:\t0x%08x\n", init_frame_msg->respStatus); @@ -408,10 +441,10 @@ static void ps3_cli_init_frame_dump(int argc, char *argv[]) return; } -static S32 ps3_register_offset_lookup(const char *reg_name_string, - U32 *reg_offset) +static int ps3_register_offset_lookup(const char *reg_name_string, + unsigned int *reg_offset) { - U32 idx = 0; + unsigned int idx = 0; struct ps3_reg_dump_desc *reg_desc = NULL; for (idx = 0; idx < ARRAY_SIZE(g_reg_table); idx++) { @@ -419,7 +452,7 @@ static S32 ps3_register_offset_lookup(const char *reg_name_string, if (reg_desc->reg_cnt != 1) { LOG_DEBUG("Reg %s is not a single register!\n", - reg_desc->reg_name); + reg_desc->reg_name); continue; } @@ -432,49 +465,51 @@ static S32 ps3_register_offset_lookup(const char *reg_name_string, return -PS3_FAILED; } -static void ps3_register_read_write(struct ps3_instance *instance, - int argc, char *argv[]) +static void ps3_register_read_write(struct ps3_instance *instance, int argc, + char *argv[]) { const char *reg_name_offset_string = argv[3]; const char *reg_loc_string = argv[4]; const char *state_ops_string = argv[5]; - U32 reg_value = 0; - U32 reg_offset = 0; - S32 ret = 0; - U64 value; + unsigned int reg_value = 0; + unsigned int reg_offset = 0; + int ret = 0; + unsigned long long value; - if (strcmp(reg_name_offset_string, "offset") == 0) { + if (strcmp(reg_name_offset_string, "offset") == 0) ret = kstrtouint(reg_loc_string, 0, ®_offset); - } else { + else ret = ps3_register_offset_lookup(reg_loc_string, ®_offset); - } if (ret != PS3_SUCCESS) { ps3stor_cli_printf("Reg %s not supported to read and write!\n", - reg_loc_string); + reg_loc_string); goto l_out; } if (strcmp(state_ops_string, "read") == 0) { - PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_offset, value); + PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_offset, + value); ps3stor_cli_printf("0x%llx\n", value); } else if (strcmp(state_ops_string, "write") == 0) { if (argc < 7) { ps3stor_cli_printf("No reg value for %s write cmd!\n", - reg_loc_string); + reg_loc_string); goto l_out; } ret = kstrtouint(argv[6], 0, ®_value); if (ret != 0) { - ps3stor_cli_printf("Invalid reg value for %s write cmd!\n", + ps3stor_cli_printf( + "Invalid reg value for %s write cmd!\n", reg_loc_string); goto l_out; } - PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, reg_offset, (U64)reg_value); + PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, reg_offset, + (unsigned long long)reg_value); ps3stor_cli_printf("Write 0x%x to %s!\n", reg_value, - reg_loc_string); + reg_loc_string); } else { ps3stor_cli_printf("Invalid ops for %s cmd!\n", reg_loc_string); } @@ -486,8 +521,8 @@ static void ps3_register_read_write(struct ps3_instance *instance, static void ps3_cli_register_rw(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 6) { ps3stor_cli_printf("Too few args for register cli cmd!\n"); @@ -501,14 +536,15 @@ static void ps3_cli_register_rw(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for register cli cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for register cli cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for register cli cmd!\n", - host_no); + host_no); goto l_out; } @@ -521,98 +557,112 @@ ssize_t ps3_ioc_reg_dump(struct ps3_instance *instance, char *buf) { ssize_t len = 0; ssize_t total_len = PAGE_SIZE; - U32 idx = 0; - U64 value = 0; + unsigned int idx = 0; + unsigned long long value = 0; struct ps3_reg_dump_desc *reg_desc = NULL; for (idx = 0; idx < ARRAY_SIZE(g_reg_table); idx++) { reg_desc = &g_reg_table[idx]; #ifndef DRIVER_REGISTER_DEBUG_SIMULATOR - if (!reg_desc->is_readable) { + if (!reg_desc->is_readable) continue; - } #endif - if (reg_desc->reg_cnt > 1) { + if (reg_desc->reg_cnt > 1) continue; - } - PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, reg_desc->reg_offset, value); + PS3_IOC_REG_READ_OFFSET_WITCH_CHECK( + instance, reg_desc->reg_offset, value); len += snprintf(buf + len, total_len - len, "%s:\t0x%08llx\n", - reg_desc->reg_name, value); + reg_desc->reg_name, value); } return len; } -static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, Bool is_detail) +static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, unsigned char is_detail) { - U8 i = 0; - U8 j = 0; - ps3stor_cli_printf("vd channel, id, virtDiskId: [%u:%u:%u], magicNum:%#x\n", + unsigned char i = 0; + unsigned char j = 0; + + ps3stor_cli_printf( + "vd channel, id, virtDiskId: [%u:%u:%u], magicNum:%#x\n", PS3_CHANNEL(&p_entry->diskPos), PS3_TARGET(&p_entry->diskPos), PS3_VDID(&p_entry->diskPos), p_entry->diskPos.diskMagicNum); ps3stor_cli_printf("vd dev_type: PS3_DEV_TYPE_VD\n"); ps3stor_cli_printf("vd isHidden: %s\n", - (p_entry->isHidden) ? "true" : "false"); + (p_entry->isHidden) ? "true" : "false"); ps3stor_cli_printf("vd accessPolicy: %s\n", - ps3_get_vd_access_plolicy_str((VDAccessPolicy_e)p_entry->accessPolicy)); + ps3_get_vd_access_plolicy_str( + (enum VDAccessPolicy)p_entry->accessPolicy)); ps3stor_cli_printf("vd diskGrpId: %u\n", p_entry->diskGrpId); - if (!is_detail) { + if (!is_detail) return; - } ps3stor_cli_printf("vd sectorSize: %u\n", p_entry->sectorSize); - ps3stor_cli_printf("vd stripeDataSize: %u\n", p_entry->stripeDataSize); + ps3stor_cli_printf("vd stripeDataSize: %u\n", + p_entry->stripeDataSize); ps3stor_cli_printf("vd physDrvCnt: %u\n", p_entry->physDrvCnt); ps3stor_cli_printf("vd stripSize: %u\n", p_entry->stripSize); ps3stor_cli_printf("vd isDirectEnable: %s\n", - (p_entry->isDirectEnable) ? "true" : "false"); + (p_entry->isDirectEnable) ? "true" : "false"); ps3stor_cli_printf("vd isNvme: %s\n", - (p_entry->isNvme) ? "true" : "false"); + (p_entry->isNvme) ? "true" : "false"); ps3stor_cli_printf("vd isSsd: %s\n", - (p_entry->isSsd) ? "true" : "false"); + (p_entry->isSsd) ? "true" : "false"); ps3stor_cli_printf("vd isWriteDirectEnable: %s\n", - (p_entry->isWriteDirectEnable) ? "true" : "false"); + (p_entry->isWriteDirectEnable) ? "true" : "false"); ps3stor_cli_printf("vd raidLevel: %u\n", p_entry->raidLevel); ps3stor_cli_printf("vd spanCount: %u\n", p_entry->spanCount); ps3stor_cli_printf("vd diskState: %u\n", p_entry->diskState); ps3stor_cli_printf("vd startLBA: %llu\n", p_entry->startLBA); ps3stor_cli_printf("vd extentSize: %llu\n", p_entry->extentSize); - ps3stor_cli_printf("vd isTaskMgmtEnable: %u\n", p_entry->isTaskMgmtEnable); - ps3stor_cli_printf("vd taskAbortTimeout: %u\n", p_entry->taskAbortTimeout); - ps3stor_cli_printf("vd taskResetTimeout: %u\n", p_entry->taskResetTimeout); + ps3stor_cli_printf("vd isTaskMgmtEnable: %u\n", + p_entry->isTaskMgmtEnable); + ps3stor_cli_printf("vd taskAbortTimeout: %u\n", + p_entry->taskAbortTimeout); + ps3stor_cli_printf("vd taskResetTimeout: %u\n", + p_entry->taskResetTimeout); ps3stor_cli_printf("vd mapBlock: %llu\n", p_entry->mapBlock); ps3stor_cli_printf("vd mapBlockVer: %u\n", p_entry->mapBlockVer); ps3stor_cli_printf("vd maxIOSize: %u\n", p_entry->maxIOSize); ps3stor_cli_printf("vd devQueDepth: %u\n", p_entry->devQueDepth); - ps3stor_cli_printf("vd dmaAddrAlignShift: %u\n", p_entry->dmaAddrAlignShift); - ps3stor_cli_printf("vd dmaLenAlignShift: %u\n", p_entry->dmaLenAlignShift); + ps3stor_cli_printf("vd dmaAddrAlignShift: %u\n", + p_entry->dmaAddrAlignShift); + ps3stor_cli_printf("vd dmaLenAlignShift: %u\n", + p_entry->dmaLenAlignShift); ps3stor_cli_printf("vd capacity(sector): %llu\n", p_entry->capacity); ps3stor_cli_printf("vd bdev_bdi_cap: %u\n", p_entry->bdev_bdi_cap); ps3stor_cli_printf("vd umapBlkDescCnt: %u\n", p_entry->umapBlkDescCnt); ps3stor_cli_printf("vd umapNumblk: %u\n", p_entry->umapNumblk); ps3stor_cli_printf("vd virtDiskSeq: %llu\n", p_entry->virtDiskSeq); ps3stor_cli_printf("vd normalQuota:%u directQuota:%u\n", - p_entry->normalQuota, p_entry->directQuota); + p_entry->normalQuota, p_entry->directQuota); ps3stor_cli_printf("vd dev_busy_scale: %u\n", p_entry->dev_busy_scale); for (i = 0; i < p_entry->spanCount; i++) { ps3stor_cli_printf(" span[%u].spanStripeDataSize: %u\n", i, - p_entry->span[i].spanStripeDataSize); + p_entry->span[i].spanStripeDataSize); ps3stor_cli_printf(" span[%u].spanState: %u\n", i, - p_entry->span[i].spanState); + p_entry->span[i].spanState); ps3stor_cli_printf(" span[%u].spanPdNum: %u\n", i, - p_entry->span[i].spanPdNum); + p_entry->span[i].spanPdNum); for (j = 0; j < p_entry->span[i].spanPdNum; j++) { ps3stor_cli_printf( " span[%u].extent[%u] - member pd:[%u:%u:%u]\n", i, j, - p_entry->span[i].extent[j].phyDiskID.ps3Dev.softChan, - p_entry->span[i].extent[j].phyDiskID.ps3Dev.devID, - p_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID); - ps3stor_cli_printf(" span[%u].extent[%u].state: %u\n", i, j, + p_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.softChan, + p_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.devID, + p_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.phyDiskID); + ps3stor_cli_printf( + " span[%u].extent[%u].state: %u\n", i, j, p_entry->span[i].extent[j].state); } } @@ -620,90 +670,101 @@ static void ps3_dev_mgr_print_vd(struct PS3VDEntry *p_entry, Bool is_detail) static void ps3_dev_mgr_show_base_vd(struct ps3_instance *instance) { - U16 i = 0; - U16 j = 0; - U8 chan_id = 0; + unsigned short i = 0; + unsigned short j = 0; + unsigned char chan_id = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_channel *vd_chan = p_dev_ctx->channel_vd; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_entries = p_dev_ctx->vd_entries_array[vd_table_idx]; - U16 vd_idx = PS3_INVALID_DEV_ID; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short vd_idx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; - ps3stor_cli_printf("\n===========start print VD base infomation=========\n"); + ps3stor_cli_printf( + "\n===========start print VD base information=========\n"); for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { chan_id = vd_chan[i].channel; for (j = 0; j < vd_chan[i].max_dev_num; j++) { vd_idx = p_table->vd_idxs[chan_id][j]; - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), vd_idx); + virtDiskIdx = get_offset_of_vdid( + PS3_VDID_OFFSET(instance), vd_idx); if (vd_idx != PS3_INVALID_DEV_ID) { - ps3_dev_mgr_print_vd(&p_entries[virtDiskIdx], PS3_FALSE); + ps3_dev_mgr_print_vd(&p_entries[virtDiskIdx], + PS3_FALSE); } } } - ps3stor_cli_printf("\n============end print VD base infomation==========\n"); + ps3stor_cli_printf( + "\n============end print VD base information==========\n"); } -static void ps3_dev_mgr_print_pd(struct ps3_pd_entry *p_entry, Bool is_detail, Bool is_raid) +static void ps3_dev_mgr_print_pd(struct ps3_pd_entry *p_entry, unsigned char is_detail, + unsigned char is_raid) { - ps3stor_cli_printf("pd channel, id, pdFlatId: [%u:%u:%u], magicNum: %#x\n", + ps3stor_cli_printf( + "pd channel, id, pdFlatId: [%u:%u:%u], magicNum: %#x\n", PS3_CHANNEL(&p_entry->disk_pos), PS3_TARGET(&p_entry->disk_pos), PS3_PDID(&p_entry->disk_pos), p_entry->disk_pos.diskMagicNum); ps3stor_cli_printf("pd state: %s\n", - getDeviceStateName((DeviceState_e)p_entry->state)); + getDeviceStateName((enum DeviceState)p_entry->state)); ps3stor_cli_printf("pd dev_type: %s\n", - namePS3DevType((enum PS3DevType)p_entry->dev_type)); + namePS3DevType((enum PS3DevType)p_entry->dev_type)); ps3stor_cli_printf("pd config_flag: %s\n", - getPdStateName((MicPdState_e)p_entry->config_flag, is_raid)); - ps3stor_cli_printf("pd pd_flags: 0x%02x\n", p_entry->pd_flags); - ps3stor_cli_printf("pd support_ncq: %d\n", p_entry->support_ncq); + getPdStateName((enum MicPdState)p_entry->config_flag, + is_raid)); + ps3stor_cli_printf("pd pd_flags: 0x%02x\n", + p_entry->pd_flags); + ps3stor_cli_printf("pd support_ncq: %d\n", + p_entry->support_ncq); if (is_detail) { ps3stor_cli_printf("pd RWCT: %u\n", - p_entry->RWCT); + p_entry->RWCT); ps3stor_cli_printf("pd scsi_interface_type: %u\n", - p_entry->scsi_interface_type); + p_entry->scsi_interface_type); ps3stor_cli_printf("pd task_abort_timeout: %u\n", - p_entry->task_abort_timeout); + p_entry->task_abort_timeout); ps3stor_cli_printf("pd task_reset_timeout: %u\n", - p_entry->task_reset_timeout); + p_entry->task_reset_timeout); ps3stor_cli_printf("pd max_io_size: %u\n", - p_entry->max_io_size); + p_entry->max_io_size); ps3stor_cli_printf("pd is_direct_disable: %s\n", - (p_entry->is_direct_disable) ? "true" : "false"); + (p_entry->is_direct_disable) ? "true" : + "false"); ps3stor_cli_printf("pd dev_queue_depth: %u\n", - p_entry->dev_queue_depth); + p_entry->dev_queue_depth); ps3stor_cli_printf("pd sector_size: %u\n", - p_entry->sector_size); + p_entry->sector_size); ps3stor_cli_printf("pd encl_id: %u\n", - p_entry->encl_id); + p_entry->encl_id); ps3stor_cli_printf("pd phy_id: %u\n", - p_entry->phy_id); + p_entry->phy_id); ps3stor_cli_printf("pd dma_addr_alignment: %u\n", - p_entry->dma_addr_alignment); + p_entry->dma_addr_alignment); ps3stor_cli_printf("pd dma_len_alignment: %u\n", - p_entry->dma_len_alignment); + p_entry->dma_len_alignment); ps3stor_cli_printf("pd protect: %u\n", - p_entry->protect); + p_entry->protect); ps3stor_cli_printf("qos pd quota:normal[%u] direct[%u]\n", - p_entry->normal_quota, p_entry->direct_quota); + p_entry->normal_quota, + p_entry->direct_quota); } } static void ps3_dev_mgr_show_base_pd(struct ps3_instance *instance) { - U16 i = 0; - U16 j = 0; - U8 chan_id = 0; + unsigned short i = 0; + unsigned short j = 0; + unsigned char chan_id = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_channel *pd_chan = p_dev_ctx->channel_pd; struct ps3_pd_table *p_table = &p_dev_ctx->pd_table; - U16 pd_idx = PS3_INVALID_DEV_ID; + unsigned short pd_idx = PS3_INVALID_DEV_ID; - ps3stor_cli_printf("\n===========start print PD base infomation=========\n"); + ps3stor_cli_printf( + "\n===========start print PD base information=========\n"); for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { @@ -715,13 +776,14 @@ static void ps3_dev_mgr_show_base_pd(struct ps3_instance *instance) } } } - ps3stor_cli_printf("\n============end print PD base infomation==========\n"); + ps3stor_cli_printf( + "\n============end print PD base information==========\n"); } static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) { - S32 ret = 0; - U16 host_no = 0; + int ret = 0; + unsigned short host_no = 0; struct ps3_instance *instance = NULL; if (argc < 3) { @@ -731,7 +793,8 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) ret = kstrtou16(argv[1], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no \"%s\" for dmbi cmd!\n", + ps3stor_cli_printf( + "Can not parse host_no \"%s\" for dmbi cmd!\n", argv[1]); goto l_out; } @@ -739,7 +802,7 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for dmbi cmd!\n", - host_no); + host_no); goto l_out; } @@ -755,72 +818,78 @@ static void ps3_cli_dev_mgr_cli_base_dump(int argc, char *argv[]) goto l_out; } else { ps3stor_cli_printf("Invalid subtype \"%s\" for dmbi cmd!\n", - argv[2]); + argv[2]); } l_out: return; } static void ps3_dev_mgr_show_detail_info(struct ps3_instance *instance, - U16 channel, U16 id) + unsigned short channel, unsigned short id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_table *p_pd_table = &p_dev_ctx->pd_table; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_vd_table = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_vd_table = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - U16 disk_idx = 0; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short disk_idx = 0; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; if (PS3_IS_VD_CHANNEL(instance, channel)) { if (p_vd_table->vd_idxs[channel] == NULL) { - ps3stor_cli_printf("==error==invalid channel parameter: %d\n", + ps3stor_cli_printf( + "==error==invalid channel parameter: %d\n", channel); goto l_out; } if (id >= p_dev_ctx->max_dev_in_channel[channel]) { - ps3stor_cli_printf("==error==invalid id parameter: %d\n", - id); + ps3stor_cli_printf( + "==error==invalid id parameter: %d\n", id); goto l_out; } disk_idx = p_vd_table->vd_idxs[channel][id]; - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_idx); + virtDiskIdx = + get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_idx); if (virtDiskIdx == PS3_INVALID_DEV_ID) { ps3stor_cli_printf("==warn==vd is not exist: [%u:%u]\n", - channel, id); + channel, id); goto l_out; } - ps3stor_cli_printf("\n===========start print VD detail infomation=========\n"); + ps3stor_cli_printf( + "\n===========start print VD detail information=========\n"); ps3_dev_mgr_print_vd(&p_vd_array[virtDiskIdx], PS3_DRV_TRUE); - ps3stor_cli_printf("\n============end print VD detail infomation==========\n"); + ps3stor_cli_printf( + "\n============end print VD detail information==========\n"); } else { if (p_pd_table->pd_idxs[channel] == NULL) { - ps3stor_cli_printf("==error==invalid channel parameter: %d\n", + ps3stor_cli_printf( + "==error==invalid channel parameter: %d\n", channel); goto l_out; } if (id >= p_dev_ctx->max_dev_in_channel[channel]) { - ps3stor_cli_printf("==error==invalid id parameter: %d\n", - id); + ps3stor_cli_printf( + "==error==invalid id parameter: %d\n", id); goto l_out; } disk_idx = p_pd_table->pd_idxs[channel][id]; if (disk_idx == PS3_INVALID_DEV_ID) { ps3stor_cli_printf("==warn==pd is not exist: [%u:%u]\n", - channel, id); + channel, id); goto l_out; } - ps3stor_cli_printf("\n===========start print PD detail infomation=========\n"); + ps3stor_cli_printf( + "\n===========start print PD detail information=========\n"); ps3_dev_mgr_print_pd(&p_dev_ctx->pd_entries_array[disk_idx], - PS3_DRV_TRUE, instance->is_raid); - ps3stor_cli_printf("\n============end print PD detail infomation==========\n"); + PS3_DRV_TRUE, instance->is_raid); + ps3stor_cli_printf( + "\n============end print PD detail information==========\n"); } l_out: return; @@ -828,10 +897,10 @@ static void ps3_dev_mgr_show_detail_info(struct ps3_instance *instance, static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) { - S32 ret = 0; - U16 host_no = 0; - U16 channel = 0; - U16 id = 0; + int ret = 0; + unsigned short host_no = 0; + unsigned short channel = 0; + unsigned short id = 0; struct ps3_instance *instance = NULL; if (argc < 4) { @@ -841,7 +910,8 @@ static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) ret = kstrtou16(argv[1], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no \"%s\" for dmdi cmd!\n", + ps3stor_cli_printf( + "Can not parse host_no \"%s\" for dmdi cmd!\n", argv[1]); goto l_out; } @@ -849,20 +919,21 @@ static void ps3_cli_dev_mgr_cli_detail_dump(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { ps3stor_cli_printf("Invalid host_no %d for dmdi cmd!\n", - host_no); + host_no); goto l_out; } ret = kstrtou16(argv[2], 0, &channel); if (ret != 0) { - ps3stor_cli_printf("Can not parse chanel \"%s\" for dmdi cmd!\n", - argv[2]); + ps3stor_cli_printf( + "Can not parse chanel \"%s\" for dmdi cmd!\n", argv[2]); goto l_out; } ret = kstrtou16(argv[3], 0, &id); if (ret != 0) { - ps3stor_cli_printf("Can not parse targetId \"%s\" for dmdi cmd!\n", + ps3stor_cli_printf( + "Can not parse targetId \"%s\" for dmdi cmd!\n", argv[3]); goto l_out; } @@ -876,17 +947,19 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { - ps3stor_cli_printf("malloc buf failed for event subscribe info cli!\n"); + ps3stor_cli_printf( + "malloc buf failed for event subscribe info cli!\n"); goto l_malloc_failed; } if (argc < 3) { - ps3stor_cli_printf("Too few args for event_subscribe_dump cli cmd!\n"); + ps3stor_cli_printf( + "Too few args for event_subscribe_dump cli cmd!\n"); goto l_out; } @@ -897,13 +970,15 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf( + "Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -920,12 +995,13 @@ static void ps3_cli_event_subscirbe_info_dump(int argc, char *argv[]) static void ps3_cli_event_delay_set(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - U32 delay_seconds = 0; - S32 ret = 0; + unsigned short host_no = 0; + unsigned int delay_seconds = 0; + int ret = 0; if (argc < 3) { - ps3stor_cli_printf("Too few args for event_subscribe_dump cli cmd!\n"); + ps3stor_cli_printf( + "Too few args for event_subscribe_dump cli cmd!\n"); goto l_out; } @@ -936,13 +1012,15 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf( + "Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -950,15 +1028,18 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) if (strcmp(argv[3], "delay") == 0) { ret = kstrtouint(argv[4], 0, &delay_seconds); if (ret != 0) { - ps3stor_cli_printf("Can not parse delay seconds for event delay cmd!\n"); + ps3stor_cli_printf( + "Can not parse delay seconds for event delay cmd!\n"); goto l_out; } ret = ps3_event_delay_set(instance, delay_seconds); if (ret != 0) { - ps3stor_cli_printf("Unable to config event delay ret %d\n", ret); + ps3stor_cli_printf( + "Unable to config event delay ret %d\n", ret); goto l_out; } else { - ps3stor_cli_printf("Config event delay %d success\n", delay_seconds); + ps3stor_cli_printf("Config event delay %d success\n", + delay_seconds); } } @@ -969,9 +1050,9 @@ static void ps3_cli_event_delay_set(int argc, char *argv[]) static void ps3_cli_crashdump_set(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - U32 delay_seconds = 0; - S32 ret = 0; + unsigned short host_no = 0; + unsigned int delay_seconds = 0; + int ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args for crashdump cli cmd!\n"); @@ -985,13 +1066,15 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for event_subscribe_dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for event_subscribe_dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for event_subscribe_dump cmd!\n", + ps3stor_cli_printf( + "Invalid host_no %d for event_subscribe_dump cmd!\n", host_no); goto l_out; } @@ -999,7 +1082,8 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) if (strcmp(argv[3], "wait") == 0) { ret = kstrtouint(argv[4], 0, &delay_seconds); if (ret != 0) { - ps3stor_cli_printf("Can not parse delay seconds for event delay cmd!\n"); + ps3stor_cli_printf( + "Can not parse delay seconds for event delay cmd!\n"); goto l_out; } @@ -1012,42 +1096,65 @@ static void ps3_cli_crashdump_set(int argc, char *argv[]) } instance->dump_context.dump_dma_wait_times = delay_seconds; - ps3stor_cli_printf("set crashdump dma wait times %d success\n", delay_seconds); + ps3stor_cli_printf("set crashdump dma wait times %d success\n", + delay_seconds); } l_out: return; } -S32 ps3_dump_context_show(const char *prefix, struct ps3_instance *instance) +static int ps3_dump_context_show(const char *prefix, struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; - ps3stor_cli_printf("%sdump_type : %d \n", prefix, ctxt->dump_type); - ps3stor_cli_printf("%sdump_state : %d \n", prefix,ctxt->dump_state); - ps3stor_cli_printf("%sdump_work_status : %d \n", prefix,ctxt->dump_work_status); - ps3stor_cli_printf("%sdump_env : %d \n", prefix,ctxt->dump_env); - ps3stor_cli_printf("%sdump_dma_vaddr : %p \n", prefix, ctxt->dump_dma_buf); - ps3stor_cli_printf("%sdump_dma_paddr : %llx \n", prefix, ctxt->dump_dma_addr); - ps3stor_cli_printf("%sdump_dma_buff_size : %#x \n", prefix, PS3_DUMP_DMA_BUF_SIZE); - ps3stor_cli_printf("%sdump_dma_wait_times : %#x \n", prefix, ctxt->dump_dma_wait_times); - ps3stor_cli_printf("%sdump_data_size : %llu \n", prefix,ctxt->dump_data_size); - ps3stor_cli_printf("%sdump_data_size_copyed: %llu \n", prefix, ctxt->copyed_data_size); - ps3stor_cli_printf("%sdump_dir : %s \n", prefix,ctxt->dump_dir); - ps3stor_cli_printf("%sdump_file : %s \n", prefix,ctxt->dump_out_file.filename); - ps3stor_cli_printf("%sdump_file_type : %d \n", prefix,ctxt->dump_out_file.type); - ps3stor_cli_printf("%sdump_file_size : %llu\n", prefix,ctxt->dump_out_file.file_size); - ps3stor_cli_printf("%sdump_file_write_cnt : %llu\n", prefix,ctxt->dump_out_file.file_w_cnt); - ps3stor_cli_printf("%sdump_file_status : %d\n", prefix,ctxt->dump_out_file.file_status); - ps3stor_cli_printf("%sdump_file_fp : %p\n", prefix,ctxt->dump_out_file.fp); + ps3stor_cli_printf("%sdump_type : %d\n", prefix, + ctxt->dump_type); + ps3stor_cli_printf("%sdump_state : %d\n", prefix, + ctxt->dump_state); + ps3stor_cli_printf("%sdump_work_status : %d\n", prefix, + ctxt->dump_work_status); + ps3stor_cli_printf("%sdump_env : %d\n", prefix, + ctxt->dump_env); + ps3stor_cli_printf("%sdump_dma_vaddr : %p\n", prefix, + ctxt->dump_dma_buf); + ps3stor_cli_printf("%sdump_dma_paddr : %llx\n", prefix, + ctxt->dump_dma_addr); + ps3stor_cli_printf("%sdump_dma_buff_size : %#x\n", prefix, + PS3_DUMP_DMA_BUF_SIZE); + ps3stor_cli_printf("%sdump_dma_wait_times : %#x\n", prefix, + ctxt->dump_dma_wait_times); + ps3stor_cli_printf("%sdump_data_size : %llu\n", prefix, + ctxt->dump_data_size); + ps3stor_cli_printf("%sdump_data_size_copyed: %llu\n", prefix, + ctxt->copyed_data_size); + ps3stor_cli_printf("%sdump_dir : %s\n", prefix, + ctxt->dump_dir); + ps3stor_cli_printf("%sdump_file : %s\n", prefix, + ctxt->dump_out_file.filename); + ps3stor_cli_printf("%sdump_file_type : %d\n", prefix, + ctxt->dump_out_file.type); + ps3stor_cli_printf("%sdump_file_size : %llu\n", prefix, + ctxt->dump_out_file.file_size); + ps3stor_cli_printf("%sdump_file_write_cnt : %llu\n", prefix, + ctxt->dump_out_file.file_w_cnt); + ps3stor_cli_printf("%sdump_file_status : %d\n", prefix, + ctxt->dump_out_file.file_status); + ps3stor_cli_printf("%sdump_file_fp : %p\n", prefix, + ctxt->dump_out_file.fp); if (ctxt->dump_pending_cmd) { - ps3stor_cli_printf("%sdump_pending_cmd : [trace_id:0x%llx][CFID:%d]\n", prefix, - ctxt->dump_pending_cmd->trace_id, ctxt->dump_pending_cmd->cmd_word.cmdFrameID); - } - ps3stor_cli_printf("%sdump_notify_reg_times: %d\n", prefix,ctxt->dump_pending_send_times); - ps3stor_cli_printf("%sdump_type_times : %d\n", prefix,ctxt->dump_type_times); - ps3stor_cli_printf("%sdump_state_times : %d\n", prefix,ctxt->dump_state_times); + ps3stor_cli_printf( + "%sdump_pending_cmd : [trace_id:0x%llx][CFID:%d]\n", + prefix, ctxt->dump_pending_cmd->trace_id, + ctxt->dump_pending_cmd->cmd_word.cmdFrameID); + } + ps3stor_cli_printf("%sdump_notify_reg_times: %d\n", prefix, + ctxt->dump_pending_send_times); + ps3stor_cli_printf("%sdump_type_times : %d\n", prefix, + ctxt->dump_type_times); + ps3stor_cli_printf("%sdump_state_times : %d\n", prefix, + ctxt->dump_state_times); return ret; } @@ -1057,12 +1164,15 @@ static void ps3_host_info_detail_dump(void) struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; struct Scsi_Host *phost = NULL; + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); phost = instance->host; - ps3stor_cli_printf("host_no:%d scsi_host detail info\n", phost->host_no); + ps3stor_cli_printf("host_no:%d scsi_host detail info\n", + phost->host_no); ps3stor_cli_printf(" host_failed %d\n", phost->host_failed); - ps3stor_cli_printf(" host_eh_scheduled %d\n", phost->host_eh_scheduled); + ps3stor_cli_printf(" host_eh_scheduled %d\n", + phost->host_eh_scheduled); ps3stor_cli_printf(" host_no %d\n", phost->host_no); ps3stor_cli_printf(" eh_deadline %d\n", phost->eh_deadline); ps3stor_cli_printf(" last_reset %ul\n", phost->last_reset); @@ -1073,13 +1183,15 @@ static void ps3_host_info_detail_dump(void) ps3stor_cli_printf(" max_cmd_len %d\n", phost->max_cmd_len); ps3stor_cli_printf(" can_queue %d\n", phost->can_queue); ps3stor_cli_printf(" cmd_per_lun %d\n", phost->cmd_per_lun); - ps3stor_cli_printf(" sg_tablesize %d\n", phost->sg_tablesize); - ps3stor_cli_printf(" sg_prot_tablesize %d\n", phost->sg_prot_tablesize); + ps3stor_cli_printf(" sg_tablesize %d\n", + phost->sg_tablesize); + ps3stor_cli_printf(" sg_prot_tablesize %d\n", + phost->sg_prot_tablesize); ps3stor_cli_printf(" max_sectors %d\n", phost->max_sectors); - ps3stor_cli_printf(" dma_boundary 0x%x\n", phost->dma_boundary); + ps3stor_cli_printf(" dma_boundary 0x%x\n", + phost->dma_boundary); - switch (phost->shost_state) - { + switch (phost->shost_state) { case SHOST_CREATED: ps3stor_cli_printf(" shost_state SHOST_CREATED\n"); break; @@ -1096,10 +1208,12 @@ static void ps3_host_info_detail_dump(void) ps3stor_cli_printf(" shost_state SHOST_RECOVERY\n"); break; case SHOST_CANCEL_RECOVERY: - ps3stor_cli_printf(" shost_state SHOST_CANCEL_RECOVERY\n"); + ps3stor_cli_printf( + " shost_state SHOST_CANCEL_RECOVERY\n"); break; case SHOST_DEL_RECOVERY: - ps3stor_cli_printf(" shost_state SHOST_DEL_RECOVERY\n"); + ps3stor_cli_printf( + " shost_state SHOST_DEL_RECOVERY\n"); break; default: break; @@ -1109,109 +1223,115 @@ static void ps3_host_info_detail_dump(void) } static void ps3_cmd_context_detail_dump(const char *format_space, - struct ps3_cmd_context *cmd_context) + struct ps3_cmd_context *cmd_context) { - U32 i = 0; - ps3stor_cli_printf("%smax_cmd_count:%d\n", - format_space, cmd_context->max_cmd_count); - ps3stor_cli_printf("%smax_scsi_cmd_count:%d\n", - format_space, cmd_context->max_scsi_cmd_count); - ps3stor_cli_printf("%smax_mgr_cmd_count:%d\n", - format_space, cmd_context->max_mgr_cmd_count); - ps3stor_cli_printf("%sreq_frame_buf_phys:0x%llx\n", - format_space, cmd_context->req_frame_buf_phys); - ps3stor_cli_printf("%sresponse_frame_buf_phys:0x%llx\n", - format_space, cmd_context->response_frame_buf_phys); - ps3stor_cli_printf("%sinit_frame_buf_phys:0x%llx\n", - format_space, cmd_context->init_frame_buf_phys); - ps3stor_cli_printf("%sinit_frame_sys_info_phys:0x%llx\n", - format_space, cmd_context->init_frame_sys_info_phys); - ps3stor_cli_printf("%s sgl_mode_support: %u\n", - format_space, cmd_context->sgl_mode_support); - - if (cmd_context->cmd_buf == NULL) { + unsigned int i = 0; + + ps3stor_cli_printf("%smax_cmd_count:%d\n", format_space, + cmd_context->max_cmd_count); + ps3stor_cli_printf("%smax_scsi_cmd_count:%d\n", format_space, + cmd_context->max_scsi_cmd_count); + ps3stor_cli_printf("%smax_mgr_cmd_count:%d\n", format_space, + cmd_context->max_mgr_cmd_count); + ps3stor_cli_printf("%sreq_frame_buf_phys:0x%llx\n", format_space, + cmd_context->req_frame_buf_phys); + ps3stor_cli_printf("%sresponse_frame_buf_phys:0x%llx\n", format_space, + cmd_context->response_frame_buf_phys); + ps3stor_cli_printf("%sinit_frame_buf_phys:0x%llx\n", format_space, + cmd_context->init_frame_buf_phys); + ps3stor_cli_printf("%sinit_frame_sys_info_phys:0x%llx\n", format_space, + cmd_context->init_frame_sys_info_phys); + ps3stor_cli_printf("%s sgl_mode_support: %u\n", format_space, + cmd_context->sgl_mode_support); + + if (cmd_context->cmd_buf == NULL) goto l_out; - } for (i = cmd_context->max_scsi_cmd_count; - i < cmd_context->max_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_INIT) { + i < cmd_context->max_cmd_count; i++) { + if (cmd_context->cmd_buf[i]->cmd_state.state == + PS3_CMD_STATE_INIT) { continue; } - ps3stor_cli_printf("%s pending cmd mgr : [trace_id:0x%llx][CFID:%d][type:%d]" - "[isrSN:%d][%s]\n", - format_space, - cmd_context->cmd_buf[i]->trace_id, + ps3stor_cli_printf( + "%s pending cmd mgr : [trace_id:0x%llx][CFID:%d][type:%d][isrSN:%d][%s]\n", + format_space, cmd_context->cmd_buf[i]->trace_id, cmd_context->cmd_buf[i]->cmd_word.cmdFrameID, cmd_context->cmd_buf[i]->cmd_word.type, cmd_context->cmd_buf[i]->cmd_word.isrSN, - namePS3CmdState(cmd_context->cmd_buf[i]->cmd_state.state)); + namePS3CmdState( + cmd_context->cmd_buf[i]->cmd_state.state)); } for (i = 0; i < cmd_context->max_scsi_cmd_count; i++) { - if (cmd_context->cmd_buf[i]->cmd_state.state == PS3_CMD_STATE_INIT) { + if (cmd_context->cmd_buf[i]->cmd_state.state == + PS3_CMD_STATE_INIT) { continue; } - ps3stor_cli_printf("%s pending cmd scsi: [trace_id:0x%llx][CFID:%d][type:%d]" - "[isrSN:%d][%s]\n", - format_space, - cmd_context->cmd_buf[i]->trace_id, + ps3stor_cli_printf( + "%s pending cmd scsi: [trace_id:0x%llx][CFID:%d][type:%d][isrSN:%d][%s]\n", + format_space, cmd_context->cmd_buf[i]->trace_id, cmd_context->cmd_buf[i]->cmd_word.cmdFrameID, cmd_context->cmd_buf[i]->cmd_word.type, cmd_context->cmd_buf[i]->cmd_word.isrSN, - namePS3CmdState(cmd_context->cmd_buf[i]->cmd_state.state)); + namePS3CmdState( + cmd_context->cmd_buf[i]->cmd_state.state)); } l_out: ps3stor_cli_printf("\n"); } static void ps3_irq_context_detail_dump(const char *format_space, - struct ps3_irq_context *irq_context) + struct ps3_irq_context *irq_context) { - U32 i = 0; - - ps3stor_cli_printf("%sreply_fifo_depth:%d\n", - format_space, irq_context->reply_fifo_depth); - ps3stor_cli_printf("%svalid_msix_vector_count:%d\n", - format_space, irq_context->valid_msix_vector_count); - ps3stor_cli_printf("%shigh_iops_msix_vectors:%d\n", - format_space, irq_context->high_iops_msix_vectors); - ps3stor_cli_printf("%sreply_fifo_desc_buf_phys:0x%llx\n", - format_space, irq_context->reply_fifo_desc_buf_phys); + unsigned int i = 0; + + ps3stor_cli_printf("%sreply_fifo_depth:%d\n", format_space, + irq_context->reply_fifo_depth); + ps3stor_cli_printf("%svalid_msix_vector_count:%d\n", format_space, + irq_context->valid_msix_vector_count); + ps3stor_cli_printf("%shigh_iops_msix_vectors:%d\n", format_space, + irq_context->high_iops_msix_vectors); + ps3stor_cli_printf("%sreply_fifo_desc_buf_phys:0x%llx\n", format_space, + irq_context->reply_fifo_desc_buf_phys); for (i = 0; i < irq_context->valid_msix_vector_count; i++) { - ps3stor_cli_printf("%sreply_fifo_phys_base_addr_buf[%d]:0x%llx\n", + ps3stor_cli_printf( + "%sreply_fifo_phys_base_addr_buf[%d]:0x%llx\n", format_space, i, irq_context->reply_fifo_phys_base_addr_buf[i]); } - for (i = 0; (S32)i < irq_context->cpu_msix_table_sz - 1; i++) { - if (irq_context->cpu_msix_table == NULL) { + for (i = 0; (int)i < irq_context->cpu_msix_table_sz - 1; i++) { + if (irq_context->cpu_msix_table == NULL) break; - } ps3stor_cli_printf("%scpu_msix_table[%d]:0x%llx\n", - format_space, i, irq_context->cpu_msix_table[i]); - } - - ps3stor_cli_printf("%shigh_iops_io_count:%d\n", - format_space, irq_context->high_iops_io_count.counter); - ps3stor_cli_printf("%sis_enable_interrupts:%s\n", - format_space, - irq_context->is_enable_interrupts ? "PS3_TRUE" : "PS3_FALSE"); - ps3stor_cli_printf("%sis_support_balance:%s\n", - format_space, - irq_context->is_support_balance ? "PS3_TRUE" : "PS3_FALSE"); - ps3stor_cli_printf("%sis_balance_current_perf_mode:%s\n", - format_space, - irq_context->is_balance_current_perf_mode ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, i, + irq_context->cpu_msix_table[i]); + } + + ps3stor_cli_printf("%shigh_iops_io_count:%d\n", format_space, + irq_context->high_iops_io_count.counter); + ps3stor_cli_printf("%sis_enable_interrupts:%s\n", format_space, + irq_context->is_enable_interrupts ? "PS3_TRUE" : + "PS3_FALSE"); + ps3stor_cli_printf("%sis_support_balance:%s\n", format_space, + irq_context->is_support_balance ? "PS3_TRUE" : + "PS3_FALSE"); + ps3stor_cli_printf("%sis_balance_current_perf_mode:%s\n", format_space, + irq_context->is_balance_current_perf_mode ? + "PS3_TRUE" : + "PS3_FALSE"); switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_LEGACY\n", format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_LEGACY\n", + format_space); + break; case PS3_PCI_IRQ_MSI: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSI\n", format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSI\n", + format_space); + break; case PS3_PCI_IRQ_MSIX: - ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSIX\n", format_space); - break; + ps3stor_cli_printf("%spci_irq_type:PS3_PCI_IRQ_MSIX\n", + format_space); + break; default: break; } @@ -1219,135 +1339,147 @@ static void ps3_irq_context_detail_dump(const char *format_space, } static void ps3_dev_context_detail_dump(const char *format_space, - struct ps3_dev_context *dev_context) + struct ps3_dev_context *dev_context) { - ps3stor_cli_printf("%svd_table_idx:%d\n", format_space, dev_context->vd_table_idx); - ps3stor_cli_printf("%spd_channel_count:%d\n", - format_space, dev_context->pd_channel_count); - ps3stor_cli_printf("%svd_channel_count:%d\n", - format_space, dev_context->vd_channel_count); - ps3stor_cli_printf("%stotal_vd_count:%d\n", - format_space, dev_context->total_vd_count); - ps3stor_cli_printf("%stotal_pd_count:%d\n", - format_space, dev_context->total_pd_count); - ps3stor_cli_printf("%smax_dev_per_channel:%d\n", - format_space, dev_context->max_dev_per_channel); - ps3stor_cli_printf("%spd_list_buf_phys:0x%llx\n", - format_space, dev_context->pd_list_buf_phys); - ps3stor_cli_printf("%svd_list_buf_phys:0x%llx\n", - format_space, dev_context->vd_list_buf_phys); - ps3stor_cli_printf("%spd_info_buf_phys:0x%llx\n", - format_space, dev_context->pd_info_buf_phys); - ps3stor_cli_printf("%svd_info_buf_phys_sync:0x%llx\n", - format_space, dev_context->vd_info_buf_phys_sync); - ps3stor_cli_printf("%svd_info_buf_phys_async:0x%llx\n", - format_space, dev_context->vd_info_buf_phys_async); + ps3stor_cli_printf("%svd_table_idx:%d\n", format_space, + dev_context->vd_table_idx); + ps3stor_cli_printf("%spd_channel_count:%d\n", format_space, + dev_context->pd_channel_count); + ps3stor_cli_printf("%svd_channel_count:%d\n", format_space, + dev_context->vd_channel_count); + ps3stor_cli_printf("%stotal_vd_count:%d\n", format_space, + dev_context->total_vd_count); + ps3stor_cli_printf("%stotal_pd_count:%d\n", format_space, + dev_context->total_pd_count); + ps3stor_cli_printf("%smax_dev_per_channel:%d\n", format_space, + dev_context->max_dev_per_channel); + ps3stor_cli_printf("%spd_list_buf_phys:0x%llx\n", format_space, + dev_context->pd_list_buf_phys); + ps3stor_cli_printf("%svd_list_buf_phys:0x%llx\n", format_space, + dev_context->vd_list_buf_phys); + ps3stor_cli_printf("%spd_info_buf_phys:0x%llx\n", format_space, + dev_context->pd_info_buf_phys); + ps3stor_cli_printf("%svd_info_buf_phys_sync:0x%llx\n", format_space, + dev_context->vd_info_buf_phys_sync); + ps3stor_cli_printf("%svd_info_buf_phys_async:0x%llx\n", format_space, + dev_context->vd_info_buf_phys_async); ps3stor_cli_printf("\n"); } -static void ps3_event_context_detail_dump(const char *format_space, - struct ps3_event_context *event_context) +static void +ps3_event_context_detail_dump(const char *format_space, + struct ps3_event_context *event_context) { if (event_context->delay_work) { - ps3stor_cli_printf("%sevent_delay:%d\n", - format_space, event_context->delay_work->event_delay); + ps3stor_cli_printf("%sevent_delay:%d\n", format_space, + event_context->delay_work->event_delay); } ps3stor_cli_printf("\n"); } -static void ps3_fault_context_detail_dump(const char *format_space, - struct ps3_fault_context *fault_context) +static void +ps3_fault_context_detail_dump(const char *format_space, + struct ps3_fault_context *fault_context) { - ps3stor_cli_printf("%sioc_busy:%d\n", - format_space, fault_context->ioc_busy); - ps3stor_cli_printf("%slast_time:%d\n", - format_space, fault_context->last_time); + ps3stor_cli_printf("%sioc_busy:%d\n", format_space, + fault_context->ioc_busy); + ps3stor_cli_printf("%slast_time:%d\n", format_space, + fault_context->last_time); ps3stor_cli_printf("\n"); } static void ps3_ioc_ctrl_info_detail_dump(const char *format_space, - struct PS3IocCtrlInfo *ctrl_info) + struct PS3IocCtrlInfo *ctrl_info) { size_t i = 0; - ps3stor_cli_printf("%smaxVdCount:%d\n", - format_space, ctrl_info->maxVdCount); - ps3stor_cli_printf("%smaxPdCount:%d\n", - format_space, ctrl_info->maxPdCount); - ps3stor_cli_printf("%smaxSectors:%d\n", - format_space, ctrl_info->maxSectors); - ps3stor_cli_printf("%sPS3IocCtrlProp.enableSnapshot:%s\n", - format_space, - ctrl_info->properties.enableSnapshot ? "PS3_TRUE" : "PS3_FALSE"); + + ps3stor_cli_printf("%smaxVdCount:%d\n", format_space, + ctrl_info->maxVdCount); + ps3stor_cli_printf("%smaxPdCount:%d\n", format_space, + ctrl_info->maxPdCount); + ps3stor_cli_printf("%smaxSectors:%d\n", format_space, + ctrl_info->maxSectors); + ps3stor_cli_printf("%sPS3IocCtrlProp.enableSnapshot:%s\n", format_space, + ctrl_info->properties.enableSnapshot ? "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlProp.enableSoftReset:%s\n", - format_space, - ctrl_info->properties.enableSoftReset ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->properties.enableSoftReset ? "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportUnevenSpans:%s\n", - format_space, - ctrl_info->capabilities.supportUnevenSpans ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportUnevenSpans ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportJbodSecure:%s\n", - format_space, - ctrl_info->capabilities.supportJbodSecure ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportJbodSecure ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportNvmePassthru:%s\n", - format_space, - ctrl_info->capabilities.supportNvmePassthru ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportNvmePassthru ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportDirectCmd:%s\n", - format_space, - ctrl_info->capabilities.supportDirectCmd ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportDirectCmd ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportSataDirectCmd:%s\n", - format_space, - ctrl_info->capabilities.supportSataDirectCmd ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportSataDirectCmd ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportSataNcq:%s\n", - format_space, - ctrl_info->capabilities.supportSataNcq ? - "PS3_TRUE" : "PS3_FALSE"); + format_space, + ctrl_info->capabilities.supportSataNcq ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf("%sPS3IocCtrlCapable.supportAcceleration:%s\n", - format_space, - ctrl_info->capabilities.supportAcceleration ? - "PS3_TRUE" : "PS3_FALSE"); - ps3stor_cli_printf("%sscsiTaskAbortTimeout:%d\n", - format_space, ctrl_info->scsiTaskAbortTimeout); - ps3stor_cli_printf("%sscsiTaskResetTimeout:%d\n", - format_space, ctrl_info->scsiTaskResetTimeout); - ps3stor_cli_printf("%siocPerfMode:%d\n", - format_space, ctrl_info->iocPerfMode); - ps3stor_cli_printf("%svdQueueNum:%d\n", - format_space, ctrl_info->vdQueueNum); - ps3stor_cli_printf("%scancelTimeOut:%d\n", - format_space, ctrl_info->cancelTimeOut); - ps3stor_cli_printf("%schannelInfo channelNum:%d\n", - format_space, ctrl_info->channelInfo.channelNum); + format_space, + ctrl_info->capabilities.supportAcceleration ? + "PS3_TRUE" : + "PS3_FALSE"); + ps3stor_cli_printf("%sscsiTaskAbortTimeout:%d\n", format_space, + ctrl_info->scsiTaskAbortTimeout); + ps3stor_cli_printf("%sscsiTaskResetTimeout:%d\n", format_space, + ctrl_info->scsiTaskResetTimeout); + ps3stor_cli_printf("%siocPerfMode:%d\n", format_space, + ctrl_info->iocPerfMode); + ps3stor_cli_printf("%svdQueueNum:%d\n", format_space, + ctrl_info->vdQueueNum); + ps3stor_cli_printf("%scancelTimeOut:%d\n", format_space, + ctrl_info->cancelTimeOut); + ps3stor_cli_printf("%schannelInfo channelNum:%d\n", format_space, + ctrl_info->channelInfo.channelNum); for (i = 0; i < ctrl_info->channelInfo.channelNum; i++) { - ps3stor_cli_printf("%s channels[%d].channelType:%d\n", - format_space, i, + ps3stor_cli_printf( + "%s channels[%d].channelType:%d\n", format_space, i, ctrl_info->channelInfo.channels[i].channelType); - ps3stor_cli_printf("%s channels[%d].maxDevNum:%d\n", - format_space, i, + ps3stor_cli_printf( + "%s channels[%d].maxDevNum:%d\n", format_space, i, ctrl_info->channelInfo.channels[i].maxDevNum); } ps3stor_cli_printf("\n"); } -static void ps3_cmd_attr_context_detail_dump(const char *format_space, - struct ps3_cmd_attr_context *cmd_attr) +static void +ps3_cmd_attr_context_detail_dump(const char *format_space, + struct ps3_cmd_attr_context *cmd_attr) { - ps3stor_cli_printf("%sthrottle_que_depth:%d\n", - format_space, cmd_attr->throttle_que_depth); - ps3stor_cli_printf("%scur_can_que:%d\n", - format_space, cmd_attr->cur_can_que); - ps3stor_cli_printf("%svd_io_threshold:%d\n", - format_space, cmd_attr->vd_io_threshold); - ps3stor_cli_printf("%sis_support_direct_cmd:%s\n", - format_space, cmd_attr->is_support_direct_cmd ? - "PS3_TRUE" : "PS3_FALSE"); - ps3stor_cli_printf("%snvme_page_size:%d\n", - format_space, cmd_attr->nvme_page_size); + ps3stor_cli_printf("%sthrottle_que_depth:%d\n", format_space, + cmd_attr->throttle_que_depth); + ps3stor_cli_printf("%scur_can_que:%d\n", format_space, + cmd_attr->cur_can_que); + ps3stor_cli_printf("%svd_io_threshold:%d\n", format_space, + cmd_attr->vd_io_threshold); + ps3stor_cli_printf("%sis_support_direct_cmd:%s\n", format_space, + cmd_attr->is_support_direct_cmd ? "PS3_TRUE" : + "PS3_FALSE"); + ps3stor_cli_printf("%snvme_page_size:%d\n", format_space, + cmd_attr->nvme_page_size); ps3stor_cli_printf("\n"); } @@ -1357,18 +1489,25 @@ static void ps3_instance_info_detail_dump(void) struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; struct Scsi_Host *phost = NULL; - S32 instance_state = 0; + int instance_state = 0; + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); phost = instance->host; instance_state = atomic_read(&instance->state_machine.state); - ps3stor_cli_printf("host_no:%d instance detail info\n", phost->host_no); - ps3stor_cli_printf(" %s\n", namePS3InstanceState(instance_state)); + ps3stor_cli_printf("host_no:%d instance detail info\n", + phost->host_no); + ps3stor_cli_printf(" %s\n", + namePS3InstanceState(instance_state)); ps3stor_cli_printf(" reg_bar:0x%x\n", instance->reg_bar); ps3stor_cli_printf(" is_load:%s\n", - instance->state_machine.is_load ? "PS3_TRUE" : "PS3_FALSE"); + instance->state_machine.is_load ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf(" is_support_sync_cache:%s\n", - instance->is_support_sync_cache ? "PS3_TRUE" : "PS3_FALSE"); + instance->is_support_sync_cache ? + "PS3_TRUE" : + "PS3_FALSE"); ps3stor_cli_printf(" ps3_cmd_context detail info dump\n"); ps3_cmd_context_detail_dump(" ", &instance->cmd_context); @@ -1380,18 +1519,20 @@ static void ps3_instance_info_detail_dump(void) ps3_dev_context_detail_dump(" ", &instance->dev_context); ps3stor_cli_printf(" ps3_event_context detail info dump\n"); - ps3_event_context_detail_dump(" ", &instance->event_context); + ps3_event_context_detail_dump(" ", + &instance->event_context); ps3stor_cli_printf(" ps3_fault_context detail info dump\n"); - ps3_fault_context_detail_dump(" ", &instance->fault_context); + ps3_fault_context_detail_dump(" ", + &instance->fault_context); ps3stor_cli_printf(" PS3IocCtrlInfo detail info dump\n"); - ps3_ioc_ctrl_info_detail_dump(" ", - &instance->ctrl_info); + ps3_ioc_ctrl_info_detail_dump(" ", &instance->ctrl_info); - ps3stor_cli_printf(" ps3_cmd_attr_context detail info dump\n"); + ps3stor_cli_printf( + " ps3_cmd_attr_context detail info dump\n"); ps3_cmd_attr_context_detail_dump(" ", - &instance->cmd_attr); + &instance->cmd_attr); ps3stor_cli_printf(" ps3_dump_context detail info dump\n"); ps3_dump_context_show(" ", instance); @@ -1402,7 +1543,7 @@ static void ps3_cli_host_and_instance_ls(int argc, char *argv[]) { if (argc < 2) { ps3stor_cli_printf("ls host/instance/all\n"); - return ; + return; } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); @@ -1424,76 +1565,74 @@ static void ps3_cli_host_and_instance_ls(int argc, char *argv[]) l_out: ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - return ; } -static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, U16 isr_sn, - char *buf, ssize_t total_len, U16 index, U16 count) +static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, unsigned short isr_sn, + char *buf, ssize_t total_len, unsigned short index, + unsigned short count) { ssize_t len = 0; struct PS3ReplyWord *fifo = NULL; - U32 i = 0; + unsigned int i = 0; struct ps3_irq *irq = NULL; - U16 start_idx = 0; - U16 once_print_cnt = 0; - U16 cnt = 0; + unsigned short start_idx = 0; + unsigned short once_print_cnt = 0; + unsigned short cnt = 0; if (isr_sn >= instance->irq_context.valid_msix_vector_count) { - ps3stor_cli_printf("invalid isr_sn %d (max:%d)\n", isr_sn, + ps3stor_cli_printf( + "invalid isr_sn %d (max:%d)\n", isr_sn, instance->irq_context.valid_msix_vector_count - 1); return PS3_FAILED; } irq = instance->irq_context.irqs + isr_sn; - if (irq == NULL) { + if (irq == NULL) goto l_out; - } len += snprintf(buf + len, total_len - len, "irq_name: %s\n", - irq->name); + irq->name); len += snprintf(buf + len, total_len - len, "irqNo: %d\n", - irq->irqNo); + irq->irqNo); len += snprintf(buf + len, total_len - len, "isrSN: %d\n", - irq->isrSN); + irq->isrSN); len += snprintf(buf + len, total_len - len, "last_reply_idx: %d\n", - irq->last_reply_idx); + irq->last_reply_idx); len += snprintf(buf + len, total_len - len, "irq_poll_th: %d\n", - irq->irq_poll_sched_threshold); + irq->irq_poll_sched_threshold); len += snprintf(buf + len, total_len - len, "is_sched_irq_poll: %d\n", - irq->is_sched_irq_poll); + irq->is_sched_irq_poll); len += snprintf(buf + len, total_len - len, "is_enable_irq: %d\n", - irq->is_enable_irq); + irq->is_enable_irq); - if(index == 0) { + if (index == 0) start_idx = irq->last_reply_idx; - } else { + else start_idx = index; - } - if(count == 0){ + if (count == 0) once_print_cnt = 100; - } else { + else once_print_cnt = count; - } - while(cnt < once_print_cnt) { - if(i == instance->irq_context.reply_fifo_depth) { + while (cnt < once_print_cnt) { + if (i == instance->irq_context.reply_fifo_depth) i = 0; - } else { + else i = start_idx; - } - for ( ; i < instance->irq_context.reply_fifo_depth; ++i, ++cnt) { + for (; i < instance->irq_context.reply_fifo_depth; ++i, ++cnt) { if (total_len - len < 100) { ps3stor_cli_printf(buf); memset(buf, 0, total_len); len = 0; } fifo = irq->reply_fifo_virt_base_addr + i; - len += snprintf(buf + len, total_len - len, + len += snprintf( + buf + len, total_len - len, "reply_word:index[%u], replyFlags[0x%x], CFID[0x%x], mode[%d], retType[%d] diskType[%d]\n", - i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, fifo->retType, fifo->diskType); - if(cnt >= once_print_cnt) { + i, fifo->retStatus, fifo->cmdFrameID, + fifo->mode, fifo->retType, fifo->diskType); + if (cnt >= once_print_cnt) break; - } } } ps3stor_cli_printf(buf); @@ -1502,8 +1641,10 @@ static ssize_t ps3_reply_fifo_dump(struct ps3_instance *instance, U16 isr_sn, LOG_DEBUG("reply fifo[%d]", irq->isrSN); while (i < instance->irq_context.reply_fifo_depth) { fifo = irq->reply_fifo_virt_base_addr + i; - LOG_DEBUG("reply_word:index[%u], replyFlags[0x%x], CFID[0x%x] mode[%d] retType[%d] diskType[%d]\n", - i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, fifo->retType, fifo->diskType); + LOG_DEBUG( + "reply_word:index[%u], replyFlags[0x%x], CFID[0x%x] mode[%d] retType[%d] diskType[%d]\n", + i, fifo->retStatus, fifo->cmdFrameID, fifo->mode, + fifo->retType, fifo->diskType); ++i; } @@ -1515,13 +1656,13 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - U16 isr_sn = 0; - S32 ret = 0; - U16 start_idx = 0; - U16 count = 0; + unsigned short host_no = 0; + unsigned short isr_sn = 0; + int ret = 0; + unsigned short start_idx = 0; + unsigned short count = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -1556,7 +1697,7 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) if (isr_sn >= PS3_MAX_REPLY_QUE_COUNT) { ps3stor_cli_printf("Invalid isr_sn %d, max isr_sn %d!\n", - isr_sn, PS3_MAX_REPLY_QUE_COUNT); + isr_sn, PS3_MAX_REPLY_QUE_COUNT); goto l_out; } @@ -1566,11 +1707,12 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) goto l_out; } - if(argc == 7) { + if (argc == 7) { if (strcmp(argv[5], "start_idx") == 0) { ret = kstrtou16(argv[6], 0, &start_idx); if (ret != 0) { - ps3stor_cli_printf("Can not parse start_idx!\n"); + ps3stor_cli_printf( + "Can not parse start_idx!\n"); goto l_out; } } else if (strcmp(argv[5], "count") == 0) { @@ -1584,7 +1726,8 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) if (strcmp(argv[5], "start_idx") == 0) { ret = kstrtou16(argv[6], 0, &start_idx); if (ret != 0) { - ps3stor_cli_printf("Can not parse start_idx!\n"); + ps3stor_cli_printf( + "Can not parse start_idx!\n"); goto l_out; } } @@ -1597,7 +1740,8 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) } } - (void)ps3_reply_fifo_dump(instance, isr_sn, buf, PAGE_SIZE, start_idx, count); + (void)ps3_reply_fifo_dump(instance, isr_sn, buf, PAGE_SIZE, start_idx, + count); l_out: kfree(buf); @@ -1605,172 +1749,176 @@ static void ps3_cli_reply_fifo_dump(int argc, char *argv[]) return; } -static ssize_t ps3_req_head_dump(struct PS3ReqFrameHead *head, - char *buf, ssize_t total_len, size_t len) +static ssize_t ps3_req_head_dump(struct PS3ReqFrameHead *head, char *buf, + ssize_t total_len, size_t len) { + len += snprintf(buf + len, total_len - len, "cmdType: %d\n", + head->cmdType); + len += snprintf(buf + len, total_len - len, "cmdSubType: %d\n", + head->cmdSubType); + len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", + head->cmdFrameID); + len += snprintf(buf + len, total_len - len, "control: 0x%x\n", + head->control); len += snprintf(buf + len, total_len - len, - "cmdType: %d\n", head->cmdType); - len += snprintf(buf + len, total_len - len, - "cmdSubType: %d\n", head->cmdSubType); - len += snprintf(buf + len, total_len - len, - "cmdFrameID: %d\n", head->cmdFrameID); - len += snprintf(buf + len, total_len - len, - "control: 0x%x\n", head->control); - len += snprintf(buf + len, total_len - len, - "noReplyWord: 0x%x\n", head->noReplyWord); + "noReplyWord: 0x%x\n", head->noReplyWord); + len += snprintf(buf + len, total_len - len, "dataFormat: 0x%x\n", + head->dataFormat); len += snprintf(buf + len, total_len - len, - "dataFormat: 0x%x\n", head->dataFormat); + "reqFrameFormat: 0x%x\n", head->reqFrameFormat); len += snprintf(buf + len, total_len - len, - "reqFrameFormat: 0x%x\n", head->reqFrameFormat); - len += snprintf(buf + len, total_len - len, - "mapBlockVer: 0x%x\n", head->mapBlockVer); - len += snprintf(buf + len, total_len - len, - "isWrite: 0x%x\n", head->isWrite); - len += snprintf(buf + len, total_len - len, - "devID: 0x%x\n", head->devID.diskID); - len += snprintf(buf + len, total_len - len, - "traceID: %lld\n", head->traceID); + "mapBlockVer: 0x%x\n", head->mapBlockVer); + len += snprintf(buf + len, total_len - len, "isWrite: 0x%x\n", + head->isWrite); + len += snprintf(buf + len, total_len - len, "devID: 0x%x\n", + head->devID.diskID); + len += snprintf(buf + len, total_len - len, "traceID: %lld\n", + head->traceID); return len; } -static ssize_t ps3_mgr_req_frame_dump(struct ps3_cmd *cmd, - char *buf, ssize_t total_len, size_t len) +static ssize_t ps3_mgr_req_frame_dump(struct ps3_cmd *cmd, char *buf, + ssize_t total_len, size_t len) { - PS3MgrReqFrame_s *mgr_req = (PS3MgrReqFrame_s*)cmd->req_frame; + struct PS3MgrReqFrame *mgr_req = (struct PS3MgrReqFrame *)cmd->req_frame; + if (mgr_req->reqHead.cmdType == PS3_CMD_MANAGEMENT || - mgr_req->reqHead.cmdType == PS3_CMD_IOCTL) { - len = ps3_req_head_dump(&mgr_req->reqHead, buf, - total_len, len); + mgr_req->reqHead.cmdType == PS3_CMD_IOCTL) { + len = ps3_req_head_dump(&mgr_req->reqHead, buf, total_len, len); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", mgr_req->sgeCount); + "sgeCount: %d\n", mgr_req->sgeCount); len += snprintf(buf + len, total_len - len, - "sgeOffset: %d\n", mgr_req->sgeOffset); + "sgeOffset: %d\n", mgr_req->sgeOffset); len += snprintf(buf + len, total_len - len, - "syncFlag: %d\n", mgr_req->syncFlag); + "syncFlag: %d\n", mgr_req->syncFlag); len += snprintf(buf + len, total_len - len, - "timeout: %d\n", mgr_req->timeout); + "timeout: %d\n", mgr_req->timeout); len += snprintf(buf + len, total_len - len, - "abortFlag: %d\n", mgr_req->abortFlag); + "abortFlag: %d\n", mgr_req->abortFlag); len += snprintf(buf + len, total_len - len, - "pendingFlag: %d\n", mgr_req->pendingFlag); - } else if (mgr_req->reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT){ - PS3MgrTaskReqFrame_s *task_req = - (PS3MgrTaskReqFrame_s*)cmd->req_frame; - len = ps3_req_head_dump(&task_req->reqHead, buf, - total_len, len); + "pendingFlag: %d\n", mgr_req->pendingFlag); + } else if (mgr_req->reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT) { + struct PS3MgrTaskReqFrame *task_req = + (struct PS3MgrTaskReqFrame *)cmd->req_frame; + len = ps3_req_head_dump(&task_req->reqHead, buf, total_len, + len); len += snprintf(buf + len, total_len - len, - "taskID: %d\n", task_req->taskID); + "taskID: %d\n", task_req->taskID); len += snprintf(buf + len, total_len - len, - "abortedCmdType: %d\n", task_req->abortedCmdType); + "abortedCmdType: %d\n", + task_req->abortedCmdType); } else { - PS3FrontEndReqFrame_s *fe_req = - (PS3FrontEndReqFrame_s*)cmd->req_frame; - len = ps3_req_head_dump(&fe_req->reqHead, buf, - total_len, len); + struct PS3FrontEndReqFrame *fe_req = + (struct PS3FrontEndReqFrame *)cmd->req_frame; + len = ps3_req_head_dump(&fe_req->reqHead, buf, total_len, len); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", fe_req->sgeCount); + "sgeCount: %d\n", fe_req->sgeCount); } return len; } -static ssize_t ps3_req_frame_dump(struct ps3_cmd *cmd, - char *buf, ssize_t total_len, size_t len) +static ssize_t ps3_req_frame_dump(struct ps3_cmd *cmd, char *buf, + ssize_t total_len, size_t len) { if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { - if (cmd->req_frame->mgrReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND) { - PS3FrontEndReqFrame_s *fe_req = - (PS3FrontEndReqFrame_s*)cmd->req_frame; + if (cmd->req_frame->mgrReq.reqHead.reqFrameFormat == + PS3_REQFRAME_FORMAT_FRONTEND) { + struct PS3FrontEndReqFrame *fe_req = + (struct PS3FrontEndReqFrame *)cmd->req_frame; len = ps3_req_head_dump(&fe_req->reqHead, buf, - total_len, len); + total_len, len); len += snprintf(buf + len, total_len - len, - "dataXferLen: %d\n", fe_req->dataXferLen); + "dataXferLen: %d\n", + fe_req->dataXferLen); len += snprintf(buf + len, total_len - len, - "sgeCount: %d\n", fe_req->sgeCount); + "sgeCount: %d\n", + fe_req->sgeCount); } else { - PS3HwReqFrame_s *hw_req = - (PS3HwReqFrame_s*)cmd->req_frame; + struct PS3HwReqFrame *hw_req = + (struct PS3HwReqFrame *)cmd->req_frame; len += snprintf(buf + len, total_len - len, - "traceID: %llu\n", hw_req->reqHead.traceID); + "traceID: %llu\n", + hw_req->reqHead.traceID); len += snprintf(buf + len, total_len - len, - "vlba: 0x%llx\n", - hw_req->softwareZone.virtDiskLba); + "vlba: 0x%llx\n", + hw_req->softwareZone.virtDiskLba); len += snprintf(buf + len, total_len - len, - "numBlocks: 0x%u\n", - hw_req->softwareZone.numBlocks); + "numBlocks: %u\n", + hw_req->softwareZone.numBlocks); len += snprintf(buf + len, total_len - len, - "opcode: 0x%u\n", - hw_req->softwareZone.opcode); + "opcode: %u\n", + hw_req->softwareZone.opcode); len += snprintf(buf + len, total_len - len, - "sglOffset: 0x%u\n", - hw_req->softwareZone.sglOffset); + "sglOffset: %u\n", + hw_req->softwareZone.sglOffset); len += snprintf(buf + len, total_len - len, - "sglFormat: 0x%u\n", - hw_req->softwareZone.sglFormat); + "sglFormat: %u\n", + hw_req->softwareZone.sglFormat); len += snprintf(buf + len, total_len - len, - "isResendCmd: 0x%u\n", - hw_req->softwareZone.isResendCmd); + "isResendCmd: %u\n", + hw_req->softwareZone.isResendCmd); len += snprintf(buf + len, total_len - len, - "subOpcode: 0x%u\n", - hw_req->softwareZone.subOpcode); + "subOpcode: %u\n", + hw_req->softwareZone.subOpcode); len += snprintf(buf + len, total_len - len, - "sgeCount: 0x%u\n", - hw_req->softwareZone.sgeCount); + "sgeCount: %u\n", + hw_req->softwareZone.sgeCount); } - } else if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR){ - len = ps3_mgr_req_frame_dump(cmd, buf, total_len, len); + } else if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { + len = ps3_mgr_req_frame_dump(cmd, buf, total_len, len); } else { len += snprintf(buf + len, total_len - len, - "req frame is null\n"); + "req frame is null\n"); } return len; } -static ssize_t ps3_cmd_dump(struct ps3_instance *instance, U16 CFID, - char *buf, ssize_t total_len) +static ssize_t ps3_cmd_dump(struct ps3_instance *instance, unsigned short CFID, char *buf, + ssize_t total_len) { ssize_t len = 0; struct ps3_cmd *cmd = NULL; - cmd = (struct ps3_cmd*)instance->cmd_context.cmd_buf[CFID]; - if (cmd == NULL) { + cmd = (struct ps3_cmd *)instance->cmd_context.cmd_buf[CFID]; + if (cmd == NULL) goto l_out; - } len += snprintf(buf + len, total_len - len, "----dump ps3_cmd----\n"); len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", - CFID); + CFID); len += snprintf(buf + len, total_len - len, "trace_id: %lld\n", - cmd->trace_id); + cmd->trace_id); len += snprintf(buf + len, total_len - len, "no_reply_word: %d\n", - cmd->no_reply_word); + cmd->no_reply_word); len += snprintf(buf + len, total_len - len, "is_retry_cmd: %d\n", - cmd->io_attr.is_retry_cmd); + cmd->io_attr.is_retry_cmd); len += snprintf(buf + len, total_len - len, "direct_flag: %d\n", - cmd->io_attr.direct_flag); + cmd->io_attr.direct_flag); len += snprintf(buf + len, total_len - len, "dev_type: %s\n", - namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); + namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); len += snprintf(buf + len, total_len - len, "rw_flag: %d\n", - cmd->io_attr.rw_flag); + cmd->io_attr.rw_flag); len += snprintf(buf + len, total_len - len, "------cmd_word------\n"); len += snprintf(buf + len, total_len - len, "type: %d\n", - cmd->cmd_word.type); + cmd->cmd_word.type); len += snprintf(buf + len, total_len - len, "direct: %d\n", - cmd->cmd_word.direct); + cmd->cmd_word.direct); len += snprintf(buf + len, total_len - len, "isrSN: %d\n", - cmd->cmd_word.isrSN); + cmd->cmd_word.isrSN); len += snprintf(buf + len, total_len - len, "phyDiskID: %d\n", - cmd->cmd_word.phyDiskID); + cmd->cmd_word.phyDiskID); len += snprintf(buf + len, total_len - len, "queID: %d\n", - cmd->cmd_word.qMask); + cmd->cmd_word.qMask); len += snprintf(buf + len, total_len - len, "cmdFrameID: %d\n", - cmd->cmd_word.cmdFrameID); + cmd->cmd_word.cmdFrameID); len += snprintf(buf + len, total_len - len, "virtDiskID: %d\n", - cmd->cmd_word.virtDiskID); + cmd->cmd_word.virtDiskID); len += snprintf(buf + len, total_len - len, "------req_frame------\n"); if (cmd->cmd_word.cmdFrameID == 0) { - len += snprintf(buf + len, total_len - len, "--cmd is null--\n"); + len += snprintf(buf + len, total_len - len, + "--cmd is null--\n"); goto l_out; } @@ -1784,11 +1932,11 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - U16 cmdFrameID = 0; - S32 ret = 0; + unsigned short host_no = 0; + unsigned short cmdFrameID = 0; + int ret = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -1829,7 +1977,8 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) if (cmdFrameID >= instance->cmd_context.max_cmd_count) { ps3stor_cli_printf("Invalid cmd_frame_id %d, max id %d!\n", - cmdFrameID, instance->cmd_context.max_cmd_count); + cmdFrameID, + instance->cmd_context.max_cmd_count); goto l_out; } @@ -1843,11 +1992,11 @@ static void ps3_cli_cmd_dump(int argc, char *argv[]) } static ssize_t ps3_io_statis_to_str(struct ps3_dev_io_statis *disk_io_statis, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; - const U32 temp_array_len = 256; - char temp[256] = {0}; + const unsigned int temp_array_len = 256; + char temp[256] = { 0 }; ssize_t temp_len = 0; (void)disk_io_statis; @@ -1855,129 +2004,139 @@ static ssize_t ps3_io_statis_to_str(struct ps3_dev_io_statis *disk_io_statis, memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendCnt", - (U64)atomic64_read(&disk_io_statis->read_send_cnt)); - if ((len + temp_len) > total_len) { + (unsigned long long)atomic64_read(&disk_io_statis->read_send_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readSendCnt", - (U64)atomic64_read(&disk_io_statis->read_send_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "readSendCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_send_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendOkCnt", - (U64)atomic64_read(&disk_io_statis->read_send_ok_cnt)); - if ((len + temp_len) > total_len) { + temp_len = + snprintf(temp, temp_array_len, "%-20s:%llu\n", "readSendOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_send_ok_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readSendOkCnt", - (U64)atomic64_read(&disk_io_statis->read_send_ok_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "readSendOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_send_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readOutStandCnt", - (U64)atomic64_read(&disk_io_statis->read_send_wait_cnt)); - if ((len + temp_len) > total_len) { + temp_len = snprintf( + temp, temp_array_len, "%-20s:%llu\n", "readOutStandCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_send_wait_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readOutStandCnt", - (U64)atomic64_read(&disk_io_statis->read_send_wait_cnt)); + + len += snprintf( + buf + len, total_len - len, "%-20s:%llu\n", "readOutStandCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_send_wait_cnt)); memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvCnt", - (U64)atomic64_read(&disk_io_statis->read_recv_cnt)); - if ((len + temp_len) > total_len) { + (unsigned long long)atomic64_read(&disk_io_statis->read_recv_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readRecvCnt", - (U64)atomic64_read(&disk_io_statis->read_recv_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "readRecvCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_recv_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvOkCnt", - (U64)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); - if ((len + temp_len) > total_len) { + temp_len = + snprintf(temp, temp_array_len, "%-20s:%llu\n", "readRecvOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readRecvOkCnt", - (U64)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "readRecvOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->read_recv_ok_cnt)); memset(temp, 0, temp_array_len); temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "readOkBytes", - (U64)atomic64_read(&disk_io_statis->read_ok_bytes)); - if ((len + temp_len) > total_len) { + (unsigned long long)atomic64_read(&disk_io_statis->read_ok_bytes)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "readOkBytes", - (U64)atomic64_read(&disk_io_statis->read_ok_bytes)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "readOkBytes", + (unsigned long long)atomic64_read(&disk_io_statis->read_ok_bytes)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendCnt", - (U64)atomic64_read(&disk_io_statis->write_send_cnt)); - if ((len + temp_len) > total_len) { + temp_len = + snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeSendCnt", - (U64)atomic64_read(&disk_io_statis->write_send_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "writeSendCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeSendOkCnt", - (U64)atomic64_read(&disk_io_statis->write_send_ok_cnt)); - if ((len + temp_len) > total_len) { + temp_len = snprintf( + temp, temp_array_len, "%-20s:%llu\n", "writeSendOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_ok_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeSendOkCnt", - (U64)atomic64_read(&disk_io_statis->write_send_ok_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "writeSendOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeOutStandCnt", - (U64)atomic64_read(&disk_io_statis->write_send_wait_cnt)); - if ((len + temp_len) > total_len) { + temp_len = snprintf( + temp, temp_array_len, "%-20s:%llu\n", "writeOutStandCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_wait_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeOutStandCnt", - (U64)atomic64_read(&disk_io_statis->write_send_wait_cnt)); + len += snprintf( + buf + len, total_len - len, "%-20s:%llu\n", "writeOutStandCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_send_wait_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvCnt", - (U64)atomic64_read(&disk_io_statis->write_recv_cnt)); - if ((len + temp_len) > total_len) { + temp_len = + snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_recv_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeRecvCnt", - (U64)atomic64_read(&disk_io_statis->write_recv_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "writeRecvCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_recv_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n", "writeRecvOkCnt", - (U64)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); - if ((len + temp_len) > total_len) { + temp_len = snprintf( + temp, temp_array_len, "%-20s:%llu\n", "writeRecvOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", "writeRecvOkCnt", - (U64)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n", + "writeRecvOkCnt", + (unsigned long long)atomic64_read(&disk_io_statis->write_recv_ok_cnt)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%llu\n\n", "writeOkBytes", - (U64)atomic64_read(&disk_io_statis->write_ok_bytes)); - if ((len + temp_len) > total_len) { + temp_len = + snprintf(temp, temp_array_len, "%-20s:%llu\n\n", "writeOkBytes", + (unsigned long long)atomic64_read(&disk_io_statis->write_ok_bytes)); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%llu\n\n", "writeOkBytes", - (U64)atomic64_read(&disk_io_statis->write_ok_bytes)); + len += snprintf(buf + len, total_len - len, "%-20s:%llu\n\n", + "writeOkBytes", + (unsigned long long)atomic64_read(&disk_io_statis->write_ok_bytes)); l_out: return len; } static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; struct ps3_dev_io_statis disk_io_statis; - U32 i = 0; - const U32 temp_array_len = 256; - char temp[256] = {0}; + unsigned int i = 0; + const unsigned int temp_array_len = 256; + char temp[256] = { 0 }; ssize_t temp_len = 0; - U8 dev_type = 0; + unsigned char dev_type = 0; if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); @@ -1985,18 +2144,19 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%s\n", "disk io statistics detail:"); - if ((len + temp_len) > total_len) { + temp_len = snprintf(temp, temp_array_len, "%s\n", + "disk io statistics detail:"); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%s\n", "disk io statistics detail:"); + len += snprintf(buf + len, total_len - len, "%s\n", + "disk io statistics detail:"); list_for_each_entry(sdev, &instance->host->__devices, siblings) { if (scsi_device_get(sdev)) continue; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; + scsi_priv = (struct ps3_scsi_priv_data *)sdev->hostdata; if (scsi_priv == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); scsi_device_put(sdev); @@ -2004,43 +2164,49 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); - memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &scsi_priv->statis, + sizeof(struct ps3_dev_io_statis)); dev_type = scsi_priv->dev_type; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "index", i); + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "index", + i); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "index", i); + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", + "index", i); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:[%d,%d]\n", "diskId", - sdev->channel, sdev->id); + temp_len = snprintf(temp, temp_array_len, "%-20s:[%d,%d]\n", + "diskId", sdev->channel, sdev->id); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:[%d,%d]\n", "diskId", - sdev->channel, sdev->id); + len += snprintf(buf + len, total_len - len, "%-20s:[%d,%d]\n", + "diskId", sdev->channel, sdev->id); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%s\n", "diskType", - (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + temp_len = + snprintf(temp, temp_array_len, "%-20s:%s\n", "diskType", + (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); if ((len + temp_len) > total_len) { scsi_device_put(sdev); goto l_out; } - len += snprintf(buf + len, total_len - len, "%-20s:%s\n", "diskType", - (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); + len += snprintf(buf + len, total_len - len, "%-20s:%s\n", + "diskType", + (dev_type == PS3_DEV_TYPE_VD ? "VD" : "PD")); if (len >= total_len) { scsi_device_put(sdev); break; } - len += ps3_io_statis_to_str(&disk_io_statis, buf + len, total_len - len); + len += ps3_io_statis_to_str(&disk_io_statis, buf + len, + total_len - len); scsi_device_put(sdev); i++; @@ -2051,38 +2217,37 @@ static ssize_t ps3_io_statis_detail_dump(struct ps3_instance *instance, } static void ps3_io_statis_clear_by_target(struct ps3_instance *instance, - U32 channel, U32 target) + unsigned int channel, unsigned int target) { struct scsi_device *sdev = NULL; if (!instance) { ps3stor_cli_printf("invalid parameters"); - return ; + return; } sdev = scsi_device_lookup(instance->host, channel, target, 0); - if (sdev){ - if (sdev->channel == channel && sdev->id == target) { + if (sdev) { + if (sdev->channel == channel && sdev->id == target) ps3_io_statis_clear(sdev); - } scsi_device_put(sdev); } } static ssize_t ps3_io_statis_summary_dump(struct ps3_instance *instance, - char *buf, ssize_t total_len) + char *buf, ssize_t total_len) { ssize_t len = 0; struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; struct ps3_dev_io_statis disk_io_statis; struct ps3_dev_io_statis disk_io_statis_total; - U32 pd_cnt = 0, vd_cnt = 0; - const U32 temp_array_len = 256; - char temp[256] = {0}; + unsigned int pd_cnt = 0, vd_cnt = 0; + const unsigned int temp_array_len = 256; + char temp[256] = { 0 }; ssize_t temp_len = 0; - U8 dev_type = 0; + unsigned char dev_type = 0; if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); @@ -2095,109 +2260,134 @@ static ssize_t ps3_io_statis_summary_dump(struct ps3_instance *instance, continue; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - scsi_priv = (struct ps3_scsi_priv_data*)sdev->hostdata; + scsi_priv = (struct ps3_scsi_priv_data *)sdev->hostdata; if (scsi_priv == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); scsi_device_put(sdev); continue; } memset(&disk_io_statis, 0, sizeof(struct ps3_dev_io_statis)); - memcpy(&disk_io_statis, &scsi_priv->statis, sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &scsi_priv->statis, + sizeof(struct ps3_dev_io_statis)); dev_type = scsi_priv->dev_type; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - atomic64_add(atomic64_read(&disk_io_statis.read_send_cnt), &disk_io_statis_total.read_send_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_send_ok_cnt), &disk_io_statis_total.read_send_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_send_err_cnt), &disk_io_statis_total.read_send_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_send_wait_cnt), &disk_io_statis_total.read_send_wait_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_cnt), &disk_io_statis_total.read_recv_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_err_cnt), &disk_io_statis_total.read_recv_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_recv_ok_cnt), &disk_io_statis_total.read_recv_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.read_ok_bytes), &disk_io_statis_total.read_ok_bytes); - - atomic64_add(atomic64_read(&disk_io_statis.write_send_cnt), &disk_io_statis_total.write_send_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_send_ok_cnt), &disk_io_statis_total.write_send_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_send_err_cnt), &disk_io_statis_total.write_send_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_send_wait_cnt), &disk_io_statis_total.write_send_wait_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_recv_cnt), &disk_io_statis_total.write_recv_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_recv_err_cnt), &disk_io_statis_total.write_recv_err_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_recv_ok_cnt), &disk_io_statis_total.write_recv_ok_cnt); - atomic64_add(atomic64_read(&disk_io_statis.write_ok_bytes), &disk_io_statis_total.write_ok_bytes); - - if (dev_type == PS3_DEV_TYPE_VD) { + atomic64_add(atomic64_read(&disk_io_statis.read_send_cnt), + &disk_io_statis_total.read_send_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_ok_cnt), + &disk_io_statis_total.read_send_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_err_cnt), + &disk_io_statis_total.read_send_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_send_wait_cnt), + &disk_io_statis_total.read_send_wait_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_cnt), + &disk_io_statis_total.read_recv_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_err_cnt), + &disk_io_statis_total.read_recv_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_recv_ok_cnt), + &disk_io_statis_total.read_recv_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.read_ok_bytes), + &disk_io_statis_total.read_ok_bytes); + + atomic64_add(atomic64_read(&disk_io_statis.write_send_cnt), + &disk_io_statis_total.write_send_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_send_ok_cnt), + &disk_io_statis_total.write_send_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_send_err_cnt), + &disk_io_statis_total.write_send_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_send_wait_cnt), + &disk_io_statis_total.write_send_wait_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_recv_cnt), + &disk_io_statis_total.write_recv_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_recv_err_cnt), + &disk_io_statis_total.write_recv_err_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_recv_ok_cnt), + &disk_io_statis_total.write_recv_ok_cnt); + atomic64_add(atomic64_read(&disk_io_statis.write_ok_bytes), + &disk_io_statis_total.write_ok_bytes); + + if (dev_type == PS3_DEV_TYPE_VD) vd_cnt++; - } else { + else pd_cnt++; - } scsi_device_put(sdev); } - memcpy(&disk_io_statis, &disk_io_statis_total, sizeof(struct ps3_dev_io_statis)); + memcpy(&disk_io_statis, &disk_io_statis_total, + sizeof(struct ps3_dev_io_statis)); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%s\n", "disk io statistics summary:"); - if ((len + temp_len) > total_len) { + temp_len = snprintf(temp, temp_array_len, "%s\n", + "disk io statistics summary:"); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%s\n", "disk io statistics summary:"); + len += snprintf(buf + len, total_len - len, "%s\n", + "disk io statistics summary:"); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "VD count", vd_cnt); - if ((len + temp_len) > total_len) { + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "VD count", + vd_cnt); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "VD count", vd_cnt); + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "VD count", + vd_cnt); memset(temp, 0, temp_array_len); - temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "PD count", pd_cnt); - if ((len + temp_len) > total_len) { + temp_len = snprintf(temp, temp_array_len, "%-20s:%d\n", "PD count", + pd_cnt); + if ((len + temp_len) > total_len) goto l_out; - } - len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "PD count", pd_cnt); + len += snprintf(buf + len, total_len - len, "%-20s:%d\n", "PD count", + pd_cnt); - if (len >= total_len) { + if (len >= total_len) goto l_out; - } len += ps3_io_statis_to_str(&disk_io_statis, buf, total_len - len); l_out: return len; } -void ps3_io_statis_dump_cli_cb_test(U8 detail) +void ps3_io_statis_dump_cli_cb_test(unsigned char detail) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; char *buf = NULL; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; } if (detail) { - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, list_item); + list_for_each(pitem, + &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, + list_item); if (instance) { - (void)ps3_io_statis_detail_dump(instance, buf, PAGE_SIZE); + (void)ps3_io_statis_detail_dump(instance, buf, + PAGE_SIZE); break; } } } else { - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, list_item); + list_for_each(pitem, + &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, + list_item); if (instance) { - (void)ps3_io_statis_summary_dump(instance, buf, PAGE_SIZE); + (void)ps3_io_statis_summary_dump(instance, buf, + PAGE_SIZE); break; } } } ps3stor_cli_printf(buf); - LOG_DEBUG("buf = %s\n",buf); + LOG_DEBUG("buf = %s\n", buf); kfree(buf); buf = NULL; @@ -2212,7 +2402,7 @@ static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]) struct list_head *pitem = NULL; char *buf = NULL; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2239,25 +2429,31 @@ static void ps3_io_statis_dump_cli_cb(int argc, char *argv[]) } if (strcmp(argv[3], "detail") == 0) { - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, list_item); + list_for_each(pitem, + &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, + list_item); if (instance) { - (void)ps3_io_statis_detail_dump(instance, buf, PAGE_SIZE); + (void)ps3_io_statis_detail_dump(instance, buf, + PAGE_SIZE); break; } } } else { - list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { - instance = list_entry(pitem, struct ps3_instance, list_item); + list_for_each(pitem, + &ps3_mgmt_info_get()->instance_list_head) { + instance = list_entry(pitem, struct ps3_instance, + list_item); if (instance) { - (void)ps3_io_statis_summary_dump(instance, buf, PAGE_SIZE); + (void)ps3_io_statis_summary_dump(instance, buf, + PAGE_SIZE); break; } } } ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2271,8 +2467,8 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; - U32 channel = 0, target = 0; - S32 ret = 0; + unsigned int channel = 0, target = 0; + int ret = 0; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 5 args!\n"); @@ -2308,8 +2504,10 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); if (instance) { - ps3_io_statis_clear_by_target(instance, channel, target); - ps3stor_cli_printf("clear host %d channel %d target %d io statistics\n", + ps3_io_statis_clear_by_target(instance, channel, + target); + ps3stor_cli_printf( + "clear host %d channel %d target %d io statistics\n", instance->host->host_no, channel, target); break; } @@ -2318,8 +2516,8 @@ static void ps3_io_statis_clear_cli_cb(int argc, char *argv[]) l_out: return; } -static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, - char *buf, ssize_t total_len) +static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, char *buf, + ssize_t total_len) { ssize_t len = 0; @@ -2329,24 +2527,25 @@ static ssize_t ps3_hardreset_cnt_show(struct ps3_instance *instance, } len += snprintf(buf + len, total_len - len, "%s:%u\n", "hard reset cnt", - instance->recovery_context->hardreset_count); + instance->recovery_context->hardreset_count); l_out: return len; } -static ssize_t ps3_hardreset_cnt_clear(struct ps3_instance *instance, - char *buf, ssize_t total_len) +static ssize_t ps3_hardreset_cnt_clear(struct ps3_instance *instance, char *buf, + ssize_t total_len) { ssize_t len = 0; + if (!instance || !buf || total_len <= 0) { ps3stor_cli_printf("invalid parameters"); goto l_out; } instance->recovery_context->hardreset_count = 0; - len += snprintf(buf + len, total_len - len, "%s:%u\n", - "hard reset cnt",instance->recovery_context->hardreset_count); + len += snprintf(buf + len, total_len - len, "%s:%u\n", "hard reset cnt", + instance->recovery_context->hardreset_count); l_out: return len; } @@ -2355,10 +2554,10 @@ static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2376,20 +2575,21 @@ static void ps3_hardreset_cnt_show_cli_cb(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", - host_no); + ps3stor_cli_printf( + "Invalid host_no %d for register dump cmd!\n", host_no); goto l_out; } (void)ps3_hardreset_cnt_show(instance, buf, PAGE_SIZE); ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2403,9 +2603,10 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; char *buf = NULL; - U16 host_no = 0; - S32 ret = 0; - buf = (char*)kzalloc(PAGE_SIZE, GFP_KERNEL); + unsigned short host_no = 0; + int ret = 0; + + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_malloc_failed; @@ -2423,19 +2624,20 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &host_no); if (ret != 0) { - ps3stor_cli_printf("Can not parse host_no for register dump cmd!\n"); + ps3stor_cli_printf( + "Can not parse host_no for register dump cmd!\n"); goto l_out; } instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d for register dump cmd!\n", - host_no); + ps3stor_cli_printf( + "Invalid host_no %d for register dump cmd!\n", host_no); goto l_out; } (void)ps3_hardreset_cnt_clear(instance, buf, PAGE_SIZE); ps3stor_cli_printf(buf); - LOG_INFO("buf: %s\n", buf); + LOG_INFO("buf: %s\n", buf); l_out: kfree(buf); @@ -2443,7 +2645,6 @@ static void ps3_hardreset_cnt_clear_cli_cb(int argc, char *argv[]) l_malloc_failed: return; - } static void ps3_cli_stop_all_instance(void) @@ -2453,35 +2654,42 @@ static void ps3_cli_stop_all_instance(void) struct ps3_cmd *cmd = NULL; struct scsi_cmnd *s_cmd = NULL; struct ps3_scsi_priv_data *data = NULL; - U32 index = 0; + unsigned int index = 0; + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); - if (instance == NULL) { + if (instance == NULL) continue; - } ps3_instance_state_transfer_to_dead(instance); instance->ioc_adpter->irq_disable(instance); ps3_irqs_sync(instance); - ps3_r1x_conflict_queue_clean_all(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); + ps3_r1x_conflict_queue_clean_all( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), + PS3_TRUE); #ifdef PS3_SUPPORT_INJECT ps3_inject_clear(); #endif - for (index = 0; index < instance->cmd_context.max_scsi_cmd_count; index++) { + for (index = 0; + index < instance->cmd_context.max_scsi_cmd_count; + index++) { cmd = instance->cmd_context.cmd_buf[index]; if (cmd->scmd != NULL) { PS3_IO_OUTSTAND_DEC(instance, cmd->scmd); - PS3_VD_OUTSTAND_DEC(instance, cmd->scmd); + PS3_VD_OUTSTAND_DEC(instance, cmd); PS3_IO_BACK_ERR_INC(instance, cmd->scmd); PS3_DEV_BUSY_DEC(cmd->scmd); - cmd->scmd->result = ((S32)PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); + cmd->scmd->result = + ((int)PS3_SCSI_RESULT_HOST_STATUS( + DID_NO_CONNECT)); s_cmd = cmd->scmd; ps3_scsi_dma_unmap(cmd); - data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; - if(likely(data != NULL)){ - ps3_r1x_write_unlock(&data->lock_mgr, cmd); + data = (struct ps3_scsi_priv_data *) + cmd->scmd->device->hostdata; + if (likely(data != NULL)) { + ps3_r1x_write_unlock(&data->lock_mgr, + cmd); } ps3_scsi_cmd_free(cmd); SCMD_IO_DONE(s_cmd); @@ -2489,23 +2697,29 @@ static void ps3_cli_stop_all_instance(void) } for (index = instance->cmd_context.max_scsi_cmd_count; - index < instance->cmd_context.max_cmd_count; index++) { + index < instance->cmd_context.max_cmd_count; index++) { cmd = instance->cmd_context.cmd_buf[index]; - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD) { - cmd->resp_frame->normalRespFrame.respStatus = PS3_STATUS_DEVICE_NOT_FOUND; + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NO_REPLY_WORD) { + cmd->resp_frame->normalRespFrame.respStatus = + PS3_STATUS_DEVICE_NOT_FOUND; } else if (cmd->cmd_receive_cb != NULL) { - cmd->resp_frame->normalRespFrame.respStatus = PS3_STATUS_DEVICE_NOT_FOUND; - cmd->cmd_receive_cb(cmd, PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = + PS3_STATUS_DEVICE_NOT_FOUND; + cmd->cmd_receive_cb(cmd, + PS3_REPLY_WORD_FLAG_FAIL); } } - cancel_delayed_work_sync(&instance->event_context.delay_work->event_work); + cancel_delayed_work_sync( + &instance->event_context.delay_work->event_work); ps3_watchdog_stop(instance); instance->ioc_adpter->irq_enable(instance); ps3_irqpolls_enable(instance); - ps3stor_cli_printf("host_no:%d instance stopped!\n", instance->host->host_no); + ps3stor_cli_printf("host_no:%d instance stopped!\n", + instance->host->host_no); } } @@ -2522,58 +2736,66 @@ static void ps3_cli_force_to_stop(int argc, char *argv[]) ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); } -static void ps3_debug_mem_dump(struct ps3_instance *ins, U16 entry, U32 len) +static void ps3_debug_mem_dump(struct ps3_instance *ins, unsigned short entry, unsigned int len) { - U32 i = 0; - const U32 once_dump_len = 1024; - char buf[256] = { 0 }; - - for (; i < ins->debug_context.debug_mem_vaddr[entry].debugMemSize; ++i) { - if (ins->debug_context.debug_mem_vaddr[entry].debugMemAddr == 0 || len == 0) { + unsigned int i = 0; + const unsigned int once_dump_len = 1024; + char buf[256] = { 0 }; + + for (; i < ins->debug_context.debug_mem_vaddr[entry].debugMemSize; + ++i) { + if (ins->debug_context.debug_mem_vaddr[entry].debugMemAddr == + 0 || + len == 0) { break; } memset(buf, '\0', sizeof(buf)); if (len <= once_dump_len) { - (void)snprintf(buf, sizeof(buf),"base addr[0x%llx] len[%u]\n", - ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + - i * once_dump_len, len); - DATA_DUMP(((U8*)(ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i * once_dump_len)), - len, buf); + (void)snprintf(buf, sizeof(buf), + "base addr[0x%llx] len[%u]\n", + ins->debug_context.debug_mem_vaddr[entry] + .debugMemAddr + + i * once_dump_len, + len); + DATA_DUMP(((unsigned char *)(ins->debug_context + .debug_mem_vaddr[entry] + .debugMemAddr + + i * once_dump_len)), + len, buf); break; - } else { - len -= once_dump_len; - (void)snprintf(buf, sizeof(buf),"base addr[0x%llx] len[%u]\n", - ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + - i * once_dump_len, once_dump_len); - DATA_DUMP(((U8*)(ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i * once_dump_len)), - once_dump_len, buf); } + len -= once_dump_len; + (void)snprintf(buf, sizeof(buf), + "base addr[0x%llx] len[%u]\n", + ins->debug_context.debug_mem_vaddr[entry] + .debugMemAddr + i * once_dump_len, once_dump_len); + DATA_DUMP(((unsigned char *)(ins->debug_context.debug_mem_vaddr[entry] + .debugMemAddr + i * once_dump_len)), once_dump_len, buf); } - return; } -static void ps3_debug_mem_write(struct ps3_instance *ins, U16 entry, U32 len) +static void ps3_debug_mem_write(struct ps3_instance *ins, unsigned short entry, unsigned int len) { - const U8 l_value = 0x55; - const U8 h_value = 0xaa; - U32 i = 0; + const unsigned char l_value = 0x55; + const unsigned char h_value = 0xaa; + unsigned int i = 0; + struct Ps3DebugMemEntry *debug_mem_entry = NULL; - for (i = 0; i < len; i+=2) { - *((U8*)ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i) = l_value; - *((U8*)ins->debug_context.debug_mem_vaddr[entry].debugMemAddr + i + 1) = h_value; + debug_mem_entry = &ins->debug_context.debug_mem_vaddr[entry]; + for (i = 0; i < len; i += 2) { + *((unsigned char *)(uintptr_t)debug_mem_entry->debugMemAddr + i) = l_value; + *((unsigned char *)(uintptr_t)debug_mem_entry->debugMemAddr + i + 1) = h_value; } - - return; } static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - U16 entry = 0; - U16 dir = 0; - U32 len = 0; - S32 ret = 0; + unsigned short host_no = 0; + unsigned short entry = 0; + unsigned short dir = 0; + unsigned int len = 0; + int ret = 0; if (argc < 9) { ps3stor_cli_printf("Too few args, must input 9 args!\n"); @@ -2607,7 +2829,8 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) } if (instance->debug_context.debug_mem_array_num == 0) { - ps3stor_cli_printf("host_no %d not support debug mem!\n", host_no); + ps3stor_cli_printf("host_no %d not support debug mem!\n", + host_no); goto l_out; } @@ -2639,17 +2862,20 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) ps3stor_cli_printf("Can not parse entry!\n"); goto l_out; } - if (len > (instance->debug_context.debug_mem_vaddr[entry].debugMemSize * 1024)) { + if (len > (instance->debug_context.debug_mem_vaddr[entry].debugMemSize * + 1024)) { ps3stor_cli_printf("len over mem [%u], max[%u]!\n", len, - instance->debug_context.debug_mem_vaddr[entry].debugMemSize * 1024); + instance->debug_context + .debug_mem_vaddr[entry] + .debugMemSize * + 1024); goto l_out; } - if (dir == 1) { - ps3_debug_mem_write(instance, entry, len); - } else { + if (dir == 1) + ps3_debug_mem_write(instance, entry, len); + else ps3_debug_mem_dump(instance, entry, len); - } l_out: return; @@ -2658,14 +2884,16 @@ static void ps3_debug_mem_rw_cli_cb(int argc, char *argv[]) static void ps3_debug_mem_para_dump(struct ps3_instance *instance) { struct ps3_debug_context *cxt = &instance->debug_context; - U32 i = 0; - ps3stor_cli_printf("debug mem array num %u\n", cxt->debug_mem_array_num); - if (cxt->debug_mem_array_num == 0) { + unsigned int i = 0; + + ps3stor_cli_printf("debug mem array num %u\n", + cxt->debug_mem_array_num); + if (cxt->debug_mem_array_num == 0) goto l_out; - } for (; i < cxt->debug_mem_array_num; ++i) { - ps3stor_cli_printf("entry[%u] vaddr[0x%llx] dma[0x%llx] max_size[%u]KB\n", + ps3stor_cli_printf( + "entry[%u] vaddr[0x%llx] dma[0x%llx] max_size[%u]KB\n", i, cxt->debug_mem_vaddr[i].debugMemAddr, cxt->debug_mem_buf[i].debugMemAddr, cxt->debug_mem_buf[i].debugMemSize); @@ -2677,8 +2905,8 @@ static void ps3_debug_mem_para_dump(struct ps3_instance *instance) static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2702,7 +2930,8 @@ static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) } if (instance->debug_context.debug_mem_array_num == 0) { - ps3stor_cli_printf("host_no %d not support debug mem!\n", host_no); + ps3stor_cli_printf("host_no %d not support debug mem!\n", + host_no); goto l_out; } @@ -2715,19 +2944,18 @@ static void ps3_debug_mem_para_cli_cb(int argc, char *argv[]) static void ps3_scsi_device_loop_dump(struct ps3_instance *instance) { struct scsi_device *sdev = NULL; - ULong flags = 0; + unsigned long flags = 0; struct Scsi_Host *shost = instance->host; - if (instance->host == NULL) { + if (instance->host == NULL) goto l_out; - } spin_lock_irqsave(shost->host_lock, flags); list_for_each_entry(sdev, &shost->__devices, siblings) { - if (sdev == NULL) { + if (sdev == NULL) continue; - } - ps3stor_cli_printf("channel[%u], id[%u], lun[%llu], state[%d]!\n", + ps3stor_cli_printf( + "channel[%u], id[%u], lun[%llu], state[%d]!\n", sdev->channel, sdev->id, sdev->lun, sdev->sdev_state); } spin_unlock_irqrestore(shost->host_lock, flags); @@ -2739,8 +2967,8 @@ static void ps3_scsi_device_loop_dump(struct ps3_instance *instance) static void ps3_scsi_device_lookup_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2772,8 +3000,8 @@ static void ps3_scsi_device_lookup_cb(int argc, char *argv[]) static void ps3_hard_reset_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2797,26 +3025,24 @@ static void ps3_hard_reset_cb(int argc, char *argv[]) } ps3stor_cli_printf("hno:%u entry hard reset !\n", host_no); - LOG_INFO("hno:%u entry hard reset!\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u entry hard reset!\n", PS3_HOST(instance)); - LOG_WARN("hno:%u cli call recovery request!\n", - PS3_HOST(instance)); - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) - || (!ps3_hard_reset_enable_query())) { - LOG_WARN("hno:%u soc feature unsupport Hard reset! need to be offline!\n", + LOG_WARN("hno:%u cli call recovery request!\n", PS3_HOST(instance)); + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || + (!ps3_hard_reset_enable_query())) { + LOG_WARN( + "hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); goto l_out; } if (ps3_need_block_hard_reset_request(instance)) { LOG_WARN("hno:%u can not start hard reset\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ps3_hard_recovery_request_with_retry(instance); - LOG_WARN("hno:%u cli call recovery request!\n", - PS3_HOST(instance)); + ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); + LOG_WARN("hno:%u cli call recovery request!\n", PS3_HOST(instance)); l_out: return; @@ -2825,8 +3051,8 @@ static void ps3_hard_reset_cb(int argc, char *argv[]) static void ps3_soc_halt_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = 0; + unsigned short host_no = 0; + int ret = 0; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2851,11 +3077,11 @@ static void ps3_soc_halt_cb(int argc, char *argv[]) if (PS3_IOC_STATE_HALT_SUPPORT(instance)) { LOG_WARN("hno:%u cli call trans to halt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_instance_state_transfer_to_dead(instance); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_WARN("hno:%u cli call trans to halt end!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { ps3stor_cli_printf("host does not support HALT!\n", host_no); } @@ -2864,12 +3090,12 @@ static void ps3_soc_halt_cb(int argc, char *argv[]) return; } -static void ps3_cmd_stat_switch_store(U16 host_no, - U16 switch_flag, U16 mask) +static void ps3_cmd_stat_switch_store + (unsigned short host_no, unsigned short switch_flag, unsigned short mask) { struct ps3_instance *instance = ps3_instance_lookup(host_no); struct ps3_cmd_stat_wrokq_context *ctx = NULL; - Bool is_inc_switch_open = PS3_FALSE; + unsigned char is_inc_switch_open = PS3_FALSE; if (instance == NULL) { ps3stor_cli_printf("invalid host_no %u\n", host_no); @@ -2877,37 +3103,39 @@ static void ps3_cmd_stat_switch_store(U16 host_no, } if ((instance->cmd_statistics.cmd_stat_switch & mask) == - (switch_flag & mask)) { + (switch_flag & mask)) { ps3stor_cli_printf("switch_flag no change 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); goto l_out; } is_inc_switch_open = ps3_stat_inc_switch_is_open(instance); - instance->cmd_statistics.cmd_stat_switch &= (~mask) ; - instance->cmd_statistics.cmd_stat_switch |= (switch_flag & mask) ; + instance->cmd_statistics.cmd_stat_switch &= (~mask); + instance->cmd_statistics.cmd_stat_switch |= (switch_flag & mask); ctx = &instance->cmd_statistics.stat_workq; if ((ctx->stat_queue != NULL) && (!ctx->is_stop) && - ps3_stat_inc_switch_is_open(instance) && !is_inc_switch_open) { + ps3_stat_inc_switch_is_open(instance) && !is_inc_switch_open) { ps3stor_cli_printf("schedule delay work\n"); - queue_delayed_work(ctx->stat_queue, &ctx->stat_work, - msecs_to_jiffies(instance->cmd_statistics.stat_interval)); + queue_delayed_work( + ctx->stat_queue, &ctx->stat_work, + msecs_to_jiffies( + instance->cmd_statistics.stat_interval)); } ps3stor_cli_printf("stat switch value is 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); l_out: return; } static void ps3_cmd_stat_switch_store_cb(int argc, char *argv[]) { - U16 host_no = 0; - U16 switch_flag = 0; - U16 mask = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + unsigned short switch_flag = 0; + unsigned short mask = 0; + int ret = PS3_SUCCESS; if (argc < 7) { ps3stor_cli_printf("Too few args, must input 7 args!\n"); @@ -2953,18 +3181,19 @@ static void ps3_cmd_stat_switch_store_cb(int argc, char *argv[]) return; } -static inline void ps3_cmd_stat_switch_show(U16 host_no) +static inline void ps3_cmd_stat_switch_show(unsigned short host_no) { struct ps3_instance *instance = ps3_instance_lookup(host_no); + if (instance == NULL) { ps3stor_cli_printf("invalid host_no %u\n", host_no); goto l_out; } - ps3stor_cli_printf("[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN," - "bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]\n"); + ps3stor_cli_printf("[bit0:OUTSTAND_SWITCH_OPEN, bit1:INC_SWITCH_OPEN\n" + "bit2:LOG_SWITCH_OPEN, bit3:DEV_SWITCH_OPEN]\n"); ps3stor_cli_printf("stat switch value is 0x%x\n", - instance->cmd_statistics.cmd_stat_switch); + instance->cmd_statistics.cmd_stat_switch); l_out: return; @@ -2972,8 +3201,8 @@ static inline void ps3_cmd_stat_switch_show(U16 host_no) static void ps3_cmd_stat_switch_show_cb(int argc, char *argv[]) { - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -2996,34 +3225,36 @@ static void ps3_cmd_stat_switch_show_cb(int argc, char *argv[]) return; } -static void ps3_stat_total_dump(struct ps3_instance *instance, - char *buf, S32 total_len) +static void ps3_stat_total_dump(struct ps3_instance *instance, char *buf, + int total_len) { - S32 len = 0; - const U32 temp_array_len = total_len; - S8 *tmp_buf = NULL; - S32 temp_len = 0; + int len = 0; + const unsigned int temp_array_len = total_len; + char *tmp_buf = NULL; + int temp_len = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - U16 i = 0; + unsigned short i = 0; len += snprintf(buf + len, total_len - len, - "----host[%u] total cmd statistics show begin----\n", PS3_HOST(instance)); - len += snprintf(buf + len, total_len - len, - "----cmd_outstandin:%u----\n", + "----host[%u] total cmd statistics show begin----\n", + PS3_HOST(instance)); + len += snprintf( + buf + len, total_len - len, "----cmd_outstandin:%u----\n", ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); - len += snprintf(buf + len, total_len - len, + len += snprintf( + buf + len, total_len - len, "%-25s %-15s %-15s %-15s %-15s %-20s %-20s %-20s\n", - " ", "start", "back_good", "back_err", "not_back", "avg(us)", "max(us)", "min(us)"); + " ", "start", "back_good", "back_err", "not_back", "avg(us)", + "max(us)", "min(us)"); - tmp_buf = (S8 *)kzalloc(temp_array_len, GFP_KERNEL); - if (tmp_buf == NULL) { + tmp_buf = kzalloc(temp_array_len, GFP_KERNEL); + if (tmp_buf == NULL) goto l_out; - } for (; i < PS3_QOS_PD_PRO; ++i) { - temp_len = snprintf(tmp_buf, temp_array_len, - "%-25s %-15llu %-15llu %-15llu %-15llu " - "%-20llu %-20llu %-20llu\n", + temp_len = snprintf( + tmp_buf, temp_array_len, + "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].start, ctx->total_stat.stat[i].back_good, @@ -3039,9 +3270,9 @@ static void ps3_stat_total_dump(struct ps3_instance *instance, memset(tmp_buf, 0, temp_array_len); - len += snprintf(buf + len, total_len - len, - "%-25s %-15llu %-15llu %-15llu %-15llu " - "%-20llu %-20llu %-20llu\n", + len += snprintf( + buf + len, total_len - len, + "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].start, ctx->total_stat.stat[i].back_good, @@ -3053,28 +3284,29 @@ static void ps3_stat_total_dump(struct ps3_instance *instance, } temp_len = snprintf(tmp_buf, temp_array_len, - "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", + PS3_HOST(instance)); if ((len + temp_len) > total_len) { ps3stor_cli_printf("print over!\n"); goto l_out; } len += snprintf(buf + len, total_len - len, - "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", + PS3_HOST(instance)); l_out: if (tmp_buf != NULL) { - kfree((void*)tmp_buf); + kfree((void *)tmp_buf); tmp_buf = NULL; } - return; } static void ps3_stat_total_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - S8 *buf = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + char *buf = NULL; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3098,7 +3330,7 @@ static void ps3_stat_total_show_cb(int argc, char *argv[]) goto l_out; } - buf = (S8 *)kzalloc(PAGE_SIZE * 2, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE * 2, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3112,34 +3344,35 @@ static void ps3_stat_total_show_cb(int argc, char *argv[]) kfree(buf); buf = NULL; } - return; } -static void ps3_stat_inc_dump(struct ps3_instance *instance, - char *buf, S32 total_len) +static void ps3_stat_inc_dump(struct ps3_instance *instance, char *buf, + int total_len) { - S32 len = 0; - const U32 temp_array_len = PAGE_SIZE; - S8 *tmp_buf = NULL; - S32 temp_len = 0; + int len = 0; + const unsigned int temp_array_len = PAGE_SIZE; + char *tmp_buf = NULL; + int temp_len = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - U16 i = 0; + unsigned short i = 0; len += snprintf(buf + len, total_len - len, - "----host[%u] inc cmd statistics show begin----\n", PS3_HOST(instance)); - len += snprintf(buf + len, total_len - len, + "----host[%u] inc cmd statistics show begin----\n", + PS3_HOST(instance)); + len += snprintf( + buf + len, total_len - len, "%-25s %-15s %-15s %-15s %-15s %-20s %-20s %-20s\n", - " ", "start", "back_good", "back_err", "not_back", "avg(us)", "max(us)", "min(us)"); + " ", "start", "back_good", "back_err", "not_back", "avg(us)", + "max(us)", "min(us)"); - tmp_buf = (S8 *)kzalloc(temp_array_len, GFP_KERNEL); - if (tmp_buf == NULL) { + tmp_buf = kzalloc(temp_array_len, GFP_KERNEL); + if (tmp_buf == NULL) goto l_out; - } for (; i < PS3_QOS_PD_PRO; ++i) { - temp_len = snprintf(tmp_buf, temp_array_len, - "%-25s %-15llu %-15llu %-15llu %-15llu " - "%-20llu %-20llu %-20llu\n", + temp_len = snprintf( + tmp_buf, temp_array_len, + "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->inc_stat.stat[i].start, ctx->inc_stat.stat[i].back_good, @@ -3155,9 +3388,9 @@ static void ps3_stat_inc_dump(struct ps3_instance *instance, memset(tmp_buf, 0, temp_array_len); - len += snprintf(buf + len, total_len - len, - "%-25s %-15llu %-15llu %-15llu %-15llu " - "%-20llu %-20llu %-20llu\n", + len += snprintf( + buf + len, total_len - len, + "%-25s %-15llu %-15llu %-15llu %-15llu %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->inc_stat.stat[i].start, ctx->inc_stat.stat[i].back_good, @@ -3169,28 +3402,29 @@ static void ps3_stat_inc_dump(struct ps3_instance *instance, } temp_len = snprintf(tmp_buf, temp_array_len, - "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", + PS3_HOST(instance)); if ((len + temp_len) > total_len) { ps3stor_cli_printf("print over!\n"); goto l_out; } len += snprintf(buf + len, total_len - len, - "----host[%u] cmd statistics show end----\n", PS3_HOST(instance)); + "----host[%u] cmd statistics show end----\n", + PS3_HOST(instance)); l_out: if (tmp_buf != NULL) { - kfree((void*)tmp_buf); + kfree((void *)tmp_buf); tmp_buf = NULL; } - return; } static void ps3_stat_inc_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - S8 *buf = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + char *buf = NULL; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3214,7 +3448,7 @@ static void ps3_stat_inc_show_cb(int argc, char *argv[]) goto l_out; } - buf = (S8 *)kzalloc(PAGE_SIZE, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3228,14 +3462,13 @@ static void ps3_stat_inc_show_cb(int argc, char *argv[]) kfree(buf); buf = NULL; } - return; } static void ps3_stat_buf_clr_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3269,8 +3502,8 @@ static void ps3_stat_buf_clr_cb(int argc, char *argv[]) static void ps3_stat_interval_show_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3295,7 +3528,7 @@ static void ps3_stat_interval_show_cb(int argc, char *argv[]) } ps3stor_cli_printf("cmd stat interval is %u ms\n", - instance->cmd_statistics.stat_interval); + instance->cmd_statistics.stat_interval); l_out: return; @@ -3304,9 +3537,9 @@ static void ps3_stat_interval_show_cb(int argc, char *argv[]) static void ps3_stat_interval_store_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - U32 interval = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + unsigned int interval = 0; + int ret = PS3_SUCCESS; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3349,7 +3582,7 @@ static void ps3_stat_interval_store_cb(int argc, char *argv[]) instance->cmd_statistics.stat_interval = interval; ps3stor_cli_printf("cmd stat interval is %u ms\n", - instance->cmd_statistics.stat_interval); + instance->cmd_statistics.stat_interval); l_out: return; @@ -3358,8 +3591,8 @@ static void ps3_stat_interval_store_cb(int argc, char *argv[]) static void ps3_reply_fifo_reset_cb(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3394,8 +3627,8 @@ static void ps3_reply_fifo_reset_cb(int argc, char *argv[]) static void ps3_cli_remove_host_force(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - S32 ret = PS3_SUCCESS; + unsigned short host_no = 0; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3428,8 +3661,8 @@ static void ps3_cli_remove_host_force(int argc, char *argv[]) static void ps3_cli_ramfs_test_set(int argc, char *argv[]) { - U16 ramfs_enable = 0; - S32 ret = PS3_SUCCESS; + unsigned short ramfs_enable = 0; + int ret = PS3_SUCCESS; if (argc < 2) { ps3stor_cli_printf("Too few args, must input 2 args!\n"); @@ -3442,60 +3675,22 @@ static void ps3_cli_ramfs_test_set(int argc, char *argv[]) goto l_out; } - ps3_ramfs_test_store((S32)ramfs_enable); + ps3_ramfs_test_store((int)ramfs_enable); ps3stor_cli_printf("set ramfs test enable to %d\n", ramfs_enable); l_out: return; } -static void ps3_cli_err_inject_active(int argc, char *argv[]) -{ - U32 err_inject_type = 0; - U32 count; - S32 ret = PS3_SUCCESS; - - if (argc < 3) { - ps3stor_cli_printf("Too few args, must input 3 args!\n"); - goto l_out; - } - - ret = kstrtouint(argv[1], 0, &err_inject_type); - if (ret != 0) { - ps3stor_cli_printf("Can not parse err_inject_type!\n"); - goto l_out; - } - - ret = kstrtouint(argv[2], 0, &count); - if (ret != 0) { - ps3stor_cli_printf("Can not parse count!\n"); - goto l_out; - } - - if ((err_inject_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && - (err_inject_type < PS3_ERR_IJ_MAX_COUNT)) { - INJECT_ACTIVE(err_inject_type, count) - ps3stor_cli_printf("active %u count %u\n", err_inject_type, count); - } -l_out: - return; -} -static void ps3_cli_err_inject_clear(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - INJECT_EXIT() -} - -Bool ps3_get_wait_cli_flag(void) +unsigned char ps3_get_wait_cli_flag(void) { return ps3_cli_wait_flag; } static void ps3_no_wait_cli_cmd(int argc, char *argv[]) { - U16 wait_cli_flag = PS3_FALSE; - S32 ret = PS3_SUCCESS; + unsigned short wait_cli_flag = PS3_FALSE; + int ret = PS3_SUCCESS; if (argc < 3) { ps3stor_cli_printf("Too few args, must input 3 args!\n"); @@ -3509,40 +3704,42 @@ static void ps3_no_wait_cli_cmd(int argc, char *argv[]) ret = kstrtou16(argv[2], 0, &wait_cli_flag); if (ret != 0) { - ps3stor_cli_printf("Can not parse wait_cli_flag!\n", - argv[3]); + ps3stor_cli_printf("Can not parse wait_cli_flag!\n", argv[3]); goto l_out; } - if (wait_cli_flag) { + if (wait_cli_flag) ps3_cli_wait_flag = PS3_TRUE; - } else { + else ps3_cli_wait_flag = PS3_FALSE; - } ps3stor_cli_printf("ps3 no wait cli flag %d\n", ps3_cli_wait_flag); l_out: return; } -static void ps3_qos_show_pd(struct ps3_instance *instance, U16 disk_id) +static void ps3_qos_show_pd(struct ps3_instance *instance, unsigned short disk_id) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - U16 i = 0; - if (disk_id > 0 && - disk_id <= instance->qos_context.max_pd_count) { + unsigned short i = 0; + + if (disk_id > 0 && disk_id <= instance->qos_context.max_pd_count) { ps3stor_cli_printf("qos pd[%u] info\n", disk_id); qos_pd_mgr = &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; - ps3stor_cli_printf("-----valid[%u] vid[%u] used_quota[%u] quota[%u] total_waited_cmd[%u]\n", + ps3stor_cli_printf( + "-----valid[%u] vid[%u] used_quota[%u] quota[%u]" + "total_waited_cmd[%u] awake_cnt[%u]\n", ps3_atomic_read(&qos_pd_mgr->valid), qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->pd_used_quota), - qos_pd_mgr->pd_quota, qos_pd_mgr->total_wait_cmd_cnt); + qos_pd_mgr->pd_quota, qos_pd_mgr->total_wait_cmd_cnt, + qos_pd_mgr->wdt_awake); if (qos_pd_mgr->total_wait_cmd_cnt > 0) { for (i = 1; i < qos_pd_mgr->waitq_cnt; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - ps3stor_cli_printf(" vid[%u] waitq_cnt[%u]\n", + ps3stor_cli_printf( + " vid[%u] waitq_cnt[%u]\n", waitq->id, waitq->count); } } @@ -3550,9 +3747,10 @@ static void ps3_qos_show_pd(struct ps3_instance *instance, U16 disk_id) if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { waitq = &qos_pd_mgr->waitqs[0]; - ps3stor_cli_printf(" direct_used_quota[%u] direct_quota[%u] waitq_cnt[%u]\n", - ps3_atomic_read(&qos_pd_mgr->direct_used_quota), - qos_pd_mgr->direct_quota, waitq->count); + ps3stor_cli_printf( + " direct_used_quota[%u] direct_quota[%u] waitq_cnt[%u]\n", + ps3_atomic_read(&qos_pd_mgr->direct_used_quota), + qos_pd_mgr->direct_quota, waitq->count); } } else { @@ -3560,26 +3758,33 @@ static void ps3_qos_show_pd(struct ps3_instance *instance, U16 disk_id) } } -static void ps3_qos_show_vd(struct ps3_instance *instance, U16 disk_id) +static void ps3_qos_show_vd(struct ps3_instance *instance, unsigned short disk_id) { - U8 i = 0; + unsigned char i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; + if (disk_id > 0 && disk_id <= instance->qos_context.max_vd_count) { ps3stor_cli_printf("qos vd[%u] info\n", disk_id); if (instance->qos_context.vd_ctx.qos_vd_mgrs) { - qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[disk_id]; - ps3stor_cli_printf("-----valid[%u] quota[%u] quota_waitq[%u] exclusive[%u]\n", - qos_vd_mgr->valid, ps3_atomic_read(&qos_vd_mgr->vd_quota), - qos_vd_mgr->vd_quota_wait_q.count, ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt)); + qos_vd_mgr = &instance->qos_context.vd_ctx + .qos_vd_mgrs[disk_id]; + ps3stor_cli_printf( + "-----valid[%u] quota[%u] quota_waitq[%u] exclusive[%u]\n", + qos_vd_mgr->valid, + ps3_atomic_read(&qos_vd_mgr->vd_quota), + qos_vd_mgr->vd_quota_wait_q.count, + ps3_atomic_read( + &qos_vd_mgr->exclusive_cmd_cnt)); } if (qos_cq_ctx->cmdqs) { for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - ps3stor_cli_printf("-----cmdq[%u] waitq_cnt[%u]\n", - i, qos_softq_mgr->waitqs[disk_id].count); + ps3stor_cli_printf( + "-----cmdq[%u] waitq_cnt[%u]\n", i, + qos_softq_mgr->waitqs[disk_id].count); } } } else { @@ -3587,113 +3792,122 @@ static void ps3_qos_show_vd(struct ps3_instance *instance, U16 disk_id) } } -static void ps3_qos_stat_dump(struct ps3_instance *instance, - char *buf, S32 total_len) +static void ps3_qos_stat_dump(struct ps3_instance *instance, char *buf, + int total_len) { - S32 len = 0; - struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; - struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; - struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; + int len = 0; + struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; + struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - struct qos_wait_queue *cmd_waitq = NULL; - U16 i = 0; + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct qos_wait_queue *cmd_waitq = NULL; + unsigned short i = 0; - len += snprintf(buf + len, total_len - len, - "----host[%u] qos cmd statistics show begin switch[%u] " - "total_qos_cmd[%llu]\n", - PS3_HOST(instance), instance->qos_context.qos_switch, + len += snprintf( + buf + len, total_len - len, + "----host[%u] qos cmd statistics show begin switch[%u] total_qos_cmd[%llu]\n", + PS3_HOST(instance), instance->qos_context.qos_switch, ps3_atomic64_read(&instance->cmd_statistics.cmd_qos_total)); if (qos_tg_ctx->vd_cmd_waitqs) { len += snprintf(buf + len, total_len - len, - "tag: share[%u] mgr[%u]\n", ps3_atomic_read(&qos_tg_ctx->share_free_cnt), - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt)); - - if (qos_tg_ctx ->mgr_cmd_wait_q.count > 0) { - len += snprintf(buf + len, total_len - len, - "mgr cmd waitq count[%u]\n", - qos_tg_ctx->mgr_cmd_wait_q.count); - if (len >= total_len) { - goto l_out; - } - } + "tag: share[%u] mgr[%u]\n", + ps3_atomic_read(&qos_tg_ctx->share_free_cnt), + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt)); + + if (qos_tg_ctx->mgr_cmd_wait_q.count > 0) { + len += snprintf(buf + len, total_len - len, + "mgr cmd waitq count[%u]\n", + qos_tg_ctx->mgr_cmd_wait_q.count); + if (len >= total_len) + goto l_out; + } for (i = 1; i <= instance->qos_context.max_vd_count; i++) { - cmd_waitq = &qos_tg_ctx ->vd_cmd_waitqs[i]; - if (cmd_waitq->count) { - len += snprintf(buf + len, total_len - len, - "vd[%u] cmd waitq_count[%u]\n", i, cmd_waitq->count); - if (len >= total_len) { - goto l_out; - } - } - } + cmd_waitq = &qos_tg_ctx->vd_cmd_waitqs[i]; + if (cmd_waitq->count) { + len += snprintf(buf + len, total_len - len, + "vd[%u] cmd waitq_count[%u]\n", + i, cmd_waitq->count); + if (len >= total_len) + goto l_out; + } + } } if (qos_cq_ctx->cmdqs) { qos_softq_mgr = &qos_cq_ctx->mgrq; len += snprintf(buf + len, total_len - len, - "mgrq: free[%u] waitq_count[%u]\n", ps3_atomic_read(&qos_softq_mgr->free_cnt), - qos_softq_mgr->total_wait_cmd_cnt); - if (len >= total_len) { - goto l_out; - } + "mgrq: free[%u] waitq_count[%u]\n", + ps3_atomic_read(&qos_softq_mgr->free_cnt), + qos_softq_mgr->total_wait_cmd_cnt); + if (len >= total_len) + goto l_out; for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - len += snprintf(buf + len, total_len - len, - "cmdq[%u]: free[%u] waitq_count[%u]\n", i, ps3_atomic_read(&qos_softq_mgr->free_cnt), + len += snprintf( + buf + len, total_len - len, + "cmdq[%u]: free[%u] waitq_count[%u]\n", i, + ps3_atomic_read(&qos_softq_mgr->free_cnt), qos_softq_mgr->total_wait_cmd_cnt); - if (len >= total_len) { - goto l_out; - } + if (len >= total_len) + goto l_out; } } if (qos_pd_ctx->qos_pd_mgrs) { - for (i = 1; i <= instance->qos_context.max_pd_count; i++) { - qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; - if (qos_pd_mgr->total_wait_cmd_cnt) { - len += snprintf(buf + len, total_len - len, - "pid[%u] vid[%u] valid[%u] used_quota[%u] waitq_count[%u]\n", - qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->valid), - ps3_atomic_read(&qos_pd_mgr->pd_used_quota),qos_pd_mgr->total_wait_cmd_cnt); - if (len >= total_len) { - goto l_out; - } - } + for (i = 1; i <= instance->qos_context.max_pd_count; i++) { + qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; + if (qos_pd_mgr->total_wait_cmd_cnt) { + len += snprintf( + buf + len, total_len - len, + "pid[%u] vid[%u] valid[%u] used_quota[%u] waitq_count[%u]\n", + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, + ps3_atomic_read(&qos_pd_mgr->valid), + ps3_atomic_read( + &qos_pd_mgr->pd_used_quota), + qos_pd_mgr->total_wait_cmd_cnt); + if (len >= total_len) + goto l_out; + } if (qos_pd_mgr->total_waited_direct_cmd) { - len += snprintf(buf + len, total_len - len, - "pid[%u] valid[%u] direct_used_quota[%u] waitq_count[%u]\n", - qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, ps3_atomic_read(&qos_pd_mgr->direct_used_quota), + len += snprintf( + buf + len, total_len - len, + "pid[%u] valid[%u] direct_used_quota[%u] waitq_count[%u]\n", + qos_pd_mgr->disk_id, qos_pd_mgr->vd_id, + ps3_atomic_read( + &qos_pd_mgr->direct_used_quota), qos_pd_mgr->total_waited_direct_cmd); - if (len >= total_len) { - goto l_out; - } + if (len >= total_len) + goto l_out; } - } + } } if (qos_vd_ctx->qos_vd_mgrs) { - for (i = 1; i <= instance->qos_context.max_vd_count; i++) { - qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; - if (qos_vd_mgr->vd_quota_wait_q.count) { - len += snprintf(buf + len, total_len - len, - "vid[%u] quota[%u] waitq_count[%u]\n", - i, ps3_atomic_read(&qos_vd_mgr->vd_quota),qos_vd_mgr->vd_quota_wait_q.count); - if (len >= total_len) { - goto l_out; - } - } - } - } - - len += snprintf(buf + len, total_len - len, - "----host[%u] qos cmd statistics show end----\n", PS3_HOST(instance)); + for (i = 1; i <= instance->qos_context.max_vd_count; i++) { + qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; + if (qos_vd_mgr->vd_quota_wait_q.count) { + len += snprintf( + buf + len, total_len - len, + "vid[%u] quota[%u] waitq_count[%u]\n", + i, + ps3_atomic_read(&qos_vd_mgr->vd_quota), + qos_vd_mgr->vd_quota_wait_q.count); + if (len >= total_len) + goto l_out; + } + } + } + + len += snprintf(buf + len, total_len - len, + "----host[%u] qos cmd statistics show end----\n", + PS3_HOST(instance)); l_out: return; } @@ -3701,30 +3915,32 @@ static void ps3_qos_stat_dump(struct ps3_instance *instance, static void ps3_qos_show_delay(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - U16 i = 0; + unsigned short i = 0; - ps3stor_cli_printf("----host[%u] qos delay show begin----\n", PS3_HOST(instance)); - ps3stor_cli_printf("%-25s %-20s %-20s %-20s\n", - " ", "avg(us)", "max(us)", "min(us)"); + ps3stor_cli_printf("----host[%u] qos delay show begin----\n", + PS3_HOST(instance)); + ps3stor_cli_printf("%-25s %-20s %-20s %-20s\n", " ", "avg(us)", + "max(us)", "min(us)"); for (i = PS3_QOS_PD_PRO; i < PS3_CMD_STAT_COUNT; i++) { - ps3stor_cli_printf("%-25s %-20llu %-20llu %-20llu\n", + ps3stor_cli_printf( + "%-25s %-20llu %-20llu %-20llu\n", ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), ctx->total_stat.stat[i].lagency.avg, ctx->total_stat.stat[i].lagency.max_lagency, ctx->total_stat.stat[i].lagency.min_lagency); } - ps3stor_cli_printf("----host[%u] qos delay show end----\n", PS3_HOST(instance)); - return; + ps3stor_cli_printf("----host[%u] qos delay show end----\n", + PS3_HOST(instance)); } static void ps3_cli_qos_info(int argc, char *argv[]) { - struct ps3_instance *instance = NULL; - U16 host_no = 0; - U16 disk_id = 0; - S8 *buf = NULL; - S32 ret = 0; + struct ps3_instance *instance = NULL; + unsigned short host_no = 0; + unsigned short disk_id = 0; + char *buf = NULL; + int ret = 0; if (argc < 4) { ps3stor_cli_printf("Too few args, must input 4 args!\n"); @@ -3748,10 +3964,10 @@ static void ps3_cli_qos_info(int argc, char *argv[]) goto l_out; } - if (!instance->qos_context.inited) { - ps3stor_cli_printf("qos not support host_no %u !\n", host_no); + if (!instance->qos_context.inited) { + ps3stor_cli_printf("qos not support host_no %u !\n", host_no); goto l_out; - } + } if (strcmp(argv[3], "pd") == 0) { if (argc < 5) { @@ -3780,7 +3996,7 @@ static void ps3_cli_qos_info(int argc, char *argv[]) ps3_qos_show_vd(instance, disk_id); goto l_out; } else if (strcmp(argv[3], "all") == 0) { - buf = (S8 *)kzalloc(PAGE_SIZE * 2, GFP_KERNEL); + buf = kzalloc(PAGE_SIZE * 2, GFP_KERNEL); if (buf == NULL) { ps3stor_cli_printf("malloc buf failed!\n"); goto l_out; @@ -3792,20 +4008,18 @@ static void ps3_cli_qos_info(int argc, char *argv[]) ps3_qos_show_delay(instance); } l_out: - if (buf != NULL) { + if (buf != NULL) { kfree(buf); buf = NULL; } - - return; } -static void ps3_cli_special_log(int argc, char *argv[]) +static void ps3_cli_special_log(int argc, char *argv[]) { struct ps3_instance *instance = NULL; - U16 host_no = 0; - U16 print_switch = 0; - S32 ret = 0; + unsigned short host_no = 0; + unsigned short print_switch = 0; + int ret = 0; if (argc < 5) { ps3stor_cli_printf("Too few args, must input 5 args!\n"); @@ -3838,36 +4052,86 @@ static void ps3_cli_special_log(int argc, char *argv[]) instance->is_print_special_log = (print_switch > 0 ? 1 : 0); ps3stor_cli_printf("set print_special_log=%u\n", - instance->is_print_special_log); + instance->is_print_special_log); } l_out: return; } #ifdef PS3_SUPPORT_INJECT -struct inject_cmds_t * ps3_inject_scsi_rw_exist(struct inject_cmds_t *this_pitem) +static void ps3_cli_err_inject_active(int argc, char *argv[]) +{ + unsigned int err_inject_type = 0; + unsigned int count; + int ret = PS3_SUCCESS; + + if (argc < 3) { + ps3stor_cli_printf("Too few args, must input 3 args!\n"); + goto l_out; + } + + ret = kstrtouint(argv[1], 0, &err_inject_type); + if (ret != 0) { + ps3stor_cli_printf("Can not parse err_inject_type!\n"); + goto l_out; + } + + ret = kstrtouint(argv[2], 0, &count); + if (ret != 0) { + ps3stor_cli_printf("Can not parse count!\n"); + goto l_out; + } + + if ((err_inject_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && + (err_inject_type < PS3_ERR_IJ_MAX_COUNT)) { + INJECT_ACTIVE(err_inject_type, count); + ps3stor_cli_printf("active %u count %u\n", err_inject_type, + count); + } +l_out: + return; +} +static void ps3_cli_err_inject_clear(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + INJECT_EXIT(); +} + +static struct inject_cmds_t *ps3_inject_scsi_rw_exist(struct inject_cmds_t *this_pitem) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); - Bool is_find = PS3_FALSE; + struct PS3Inject *p_inject_list = get_inject(); + unsigned char is_find = PS3_FALSE; ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->scsi_rw_list)) { + if (list_empty(&p_inject_list->scsi_rw_list)) goto l_out; - } list_for_each_entry(pitem, &p_inject_list->scsi_rw_list, list) { - if ((this_pitem->item.scsi_cmd.host_no == pitem->item.scsi_cmd.host_no) && - (this_pitem->item.scsi_cmd.channel == pitem->item.scsi_cmd.channel) && - (this_pitem->item.scsi_cmd.id == pitem->item.scsi_cmd.id)) { - if (((this_pitem->item.scsi_cmd.lba >= pitem->item.scsi_cmd.lba) && - (this_pitem->item.scsi_cmd.lba <= pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len)) || - ((this_pitem->item.scsi_cmd.lba + this_pitem->item.scsi_cmd.len >= pitem->item.scsi_cmd.lba) && - (this_pitem->item.scsi_cmd.lba + this_pitem->item.scsi_cmd.len <= - pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len))) { - ps3stor_cli_printf("inject [%u:%u:%u] lba[0x%llx], len[0x%x], is exist!\n", - pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, - pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, + if ((this_pitem->item.scsi_cmd.host_no == + pitem->item.scsi_cmd.host_no) && + (this_pitem->item.scsi_cmd.channel == + pitem->item.scsi_cmd.channel) && + (this_pitem->item.scsi_cmd.id == pitem->item.scsi_cmd.id)) { + if (((this_pitem->item.scsi_cmd.lba >= + pitem->item.scsi_cmd.lba) && + (this_pitem->item.scsi_cmd.lba <= + pitem->item.scsi_cmd.lba + + pitem->item.scsi_cmd.len)) || + ((this_pitem->item.scsi_cmd.lba + + this_pitem->item.scsi_cmd.len >= + pitem->item.scsi_cmd.lba) && + (this_pitem->item.scsi_cmd.lba + + this_pitem->item.scsi_cmd.len <= + pitem->item.scsi_cmd.lba + + pitem->item.scsi_cmd.len))) { + ps3stor_cli_printf( + "inject [%u:%u:%u] lba[0x%llx], len[0x%x], is exist!\n", + pitem->item.scsi_cmd.host_no, + pitem->item.scsi_cmd.channel, + pitem->item.scsi_cmd.id, + pitem->item.scsi_cmd.lba, pitem->item.scsi_cmd.len); is_find = PS3_TRUE; break; @@ -3875,72 +4139,76 @@ struct inject_cmds_t * ps3_inject_scsi_rw_exist(struct inject_cmds_t *this_pitem } } l_out: - if(!is_find) { + if (!is_find) pitem = NULL; - } ps3_mutex_unlock(&p_inject_list->lock); return pitem; } -struct inject_cmds_t * ps3_inject_scsi_task_exist(struct inject_cmds_t *this_pitem) +static struct inject_cmds_t * +ps3_inject_scsi_task_exist(struct inject_cmds_t *this_pitem) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); - Bool is_find = PS3_FALSE; + struct PS3Inject *p_inject_list = get_inject(); + unsigned char is_find = PS3_FALSE; ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->scsi_task_list)) { + if (list_empty(&p_inject_list->scsi_task_list)) goto l_out; - } list_for_each_entry(pitem, &p_inject_list->scsi_task_list, list) { - if ((this_pitem->item.scsi_task_cmd.host_no == pitem->item.scsi_task_cmd.host_no) && - (this_pitem->item.scsi_task_cmd.channel == pitem->item.scsi_task_cmd.channel) && - (this_pitem->item.scsi_task_cmd.id == pitem->item.scsi_task_cmd.id)) { - if (this_pitem->item.scsi_task_cmd.cmd_type == pitem->item.scsi_task_cmd.cmd_type && - this_pitem->item.scsi_task_cmd.cmd_sub_type == pitem->item.scsi_task_cmd.cmd_sub_type) { + if ((this_pitem->item.scsi_task_cmd.host_no == + pitem->item.scsi_task_cmd.host_no) && + (this_pitem->item.scsi_task_cmd.channel == + pitem->item.scsi_task_cmd.channel) && + (this_pitem->item.scsi_task_cmd.id == + pitem->item.scsi_task_cmd.id)) { + if (this_pitem->item.scsi_task_cmd.cmd_type == + pitem->item.scsi_task_cmd.cmd_type && + this_pitem->item.scsi_task_cmd.cmd_sub_type == + pitem->item.scsi_task_cmd.cmd_sub_type) { is_find = PS3_TRUE; break; } } } l_out: - if(!is_find) { + if (!is_find) pitem = NULL; - } ps3_mutex_unlock(&p_inject_list->lock); return pitem; } -struct inject_cmds_t * ps3_inject_mgr_exist(struct inject_cmds_t *this_pitem) +static struct inject_cmds_t *ps3_inject_mgr_exist(struct inject_cmds_t *this_pitem) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); - Bool is_find = PS3_FALSE; + struct PS3Inject *p_inject_list = get_inject(); + unsigned char is_find = PS3_FALSE; ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->mgr_list)) { + if (list_empty(&p_inject_list->mgr_list)) goto l_out; - } list_for_each_entry(pitem, &p_inject_list->mgr_list, list) { - if ((this_pitem->item.mgr_cmd.host_no == pitem->item.mgr_cmd.host_no) && - (this_pitem->item.mgr_cmd.cmd_type == pitem->item.mgr_cmd.cmd_type) && - (this_pitem->item.mgr_cmd.cmd_sub_type == pitem->item.mgr_cmd.cmd_sub_type)) { - is_find = PS3_TRUE; + if ((this_pitem->item.mgr_cmd.host_no == + pitem->item.mgr_cmd.host_no) && + (this_pitem->item.mgr_cmd.cmd_type == + pitem->item.mgr_cmd.cmd_type) && + (this_pitem->item.mgr_cmd.cmd_sub_type == + pitem->item.mgr_cmd.cmd_sub_type)) { + is_find = PS3_TRUE; } } l_out: - if(!is_find) { + if (!is_find) pitem = NULL; - } ps3_mutex_unlock(&p_inject_list->lock); return pitem; } -void ps3_show_inject_scsi_rw_item(struct inject_cmds_t *pitem) +static void ps3_show_inject_scsi_rw_item(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1 = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_inject_list->scsi_rw_list)) { @@ -3950,11 +4218,13 @@ void ps3_show_inject_scsi_rw_item(struct inject_cmds_t *pitem) } ps3_mutex_unlock(&p_inject_list->lock); - if ((pitem1 = ps3_inject_scsi_rw_exist(pitem)) == NULL){ + pitem1 = ps3_inject_scsi_rw_exist(pitem); + if (pitem1 == NULL) { ps3stor_cli_printf("rw inject type is noexist!\n"); goto l_out; } - ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + ps3stor_cli_printf( + "inject_rw host_no %u channel %u id %u lba 0x%llx len %u type %u, time %u!\n", pitem1->item.scsi_cmd.host_no, pitem1->item.scsi_cmd.channel, pitem1->item.scsi_cmd.id, pitem1->item.scsi_cmd.lba, pitem1->item.scsi_cmd.len, pitem1->item.scsi_cmd.dealType, @@ -3964,10 +4234,10 @@ void ps3_show_inject_scsi_rw_item(struct inject_cmds_t *pitem) return; } -void ps3_show_inject_all_scsi_rw(int argc, char *argv[]) +static void ps3_show_inject_all_scsi_rw(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); (void)argc; (void)argv; @@ -3978,20 +4248,20 @@ void ps3_show_inject_all_scsi_rw(int argc, char *argv[]) } list_for_each_entry(pitem, &p_inject_list->scsi_rw_list, list) { - ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u!\n", - pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, - pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, - pitem->item.scsi_cmd.len); + ps3stor_cli_printf( + "inject_rw host_no %u channel %u id %u lba 0x%llx len %u!\n", + pitem->item.scsi_cmd.host_no, + pitem->item.scsi_cmd.channel, pitem->item.scsi_cmd.id, + pitem->item.scsi_cmd.lba, pitem->item.scsi_cmd.len); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_show_inject_scsi_task_item(struct inject_cmds_t *pitem) +static void ps3_show_inject_scsi_task_item(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_inject_list->scsi_task_list)) { @@ -4000,25 +4270,28 @@ void ps3_show_inject_scsi_task_item(struct inject_cmds_t *pitem) goto l_out; } ps3_mutex_unlock(&p_inject_list->lock); + pitem1 = ps3_inject_scsi_task_exist(pitem); - if ((pitem1 = ps3_inject_scsi_task_exist(pitem)) == NULL){ + if (pitem1 == NULL) { ps3stor_cli_printf("task inject type is noexist!\n"); goto l_out; } - ps3stor_cli_printf("inject_rw host_no %u channel %u id %u cmdtype" - " 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", - pitem1->item.scsi_task_cmd.host_no, pitem1->item.scsi_task_cmd.channel, - pitem1->item.scsi_task_cmd.id, pitem1->item.scsi_task_cmd.cmd_type, - pitem1->item.scsi_task_cmd.cmd_sub_type, pitem1->item.scsi_task_cmd.dealType, - pitem1->item.scsi_task_cmd.inject_count); + ps3stor_cli_printf("inj_rw hno %u ch %u id %u ctype %u cSubtype %u dType %u times %u!\n", + pitem1->item.scsi_task_cmd.host_no, + pitem1->item.scsi_task_cmd.channel, + pitem1->item.scsi_task_cmd.id, + pitem1->item.scsi_task_cmd.cmd_type, + pitem1->item.scsi_task_cmd.cmd_sub_type, + pitem1->item.scsi_task_cmd.dealType, + pitem1->item.scsi_task_cmd.inject_count); l_out: return; } -void ps3_show_inject_mgr_item(struct inject_cmds_t *pitem) +static void ps3_show_inject_mgr_item(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_inject_list->mgr_list)) { @@ -4026,24 +4299,27 @@ void ps3_show_inject_mgr_item(struct inject_cmds_t *pitem) goto l_out; } ps3_mutex_unlock(&p_inject_list->lock); + pitem1 = ps3_inject_mgr_exist(pitem); - if ((pitem1 = ps3_inject_mgr_exist(pitem)) == NULL){ + if (pitem1 == NULL) { ps3stor_cli_printf("mgr type is noexist!\n"); goto l_out; } - ps3stor_cli_printf("inject_mgr host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + ps3stor_cli_printf( + "inject_mgr host_no %u cmdtype %u cmdSubtype %u dealType %u times %u!\n", pitem1->item.mgr_cmd.host_no, pitem1->item.mgr_cmd.cmd_type, - pitem1->item.mgr_cmd.cmd_sub_type, pitem1->item.mgr_cmd.dealType, + pitem1->item.mgr_cmd.cmd_sub_type, + pitem1->item.mgr_cmd.dealType, pitem1->item.mgr_cmd.inject_count); l_out: return; } -void ps3_show_inject_all_scsi_task(int argc, char *argv[]) +static void ps3_show_inject_all_scsi_task(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); (void)argc; (void)argv; @@ -4054,118 +4330,118 @@ void ps3_show_inject_all_scsi_task(int argc, char *argv[]) } list_for_each_entry(pitem, &p_inject_list->scsi_task_list, list) { - ps3stor_cli_printf("inject_task host_no %u channel %u id %u" - " cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", - pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, - pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, - pitem->item.scsi_task_cmd.cmd_sub_type,pitem->item.scsi_task_cmd.dealType, + ps3stor_cli_printf( + "inj_task hno %u chani %u id %u ctype %u cSubtype %u dType %u times %u!\n", + pitem->item.scsi_task_cmd.host_no, + pitem->item.scsi_task_cmd.channel, + pitem->item.scsi_task_cmd.id, + pitem->item.scsi_task_cmd.cmd_type, + pitem->item.scsi_task_cmd.cmd_sub_type, + pitem->item.scsi_task_cmd.dealType, pitem->item.scsi_task_cmd.inject_count); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_show_inject_all_mgr(int argc, char *argv[]) +static void ps3_show_inject_all_mgr(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); (void)argc; (void)argv; ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->mgr_list)) { + if (list_empty(&p_inject_list->mgr_list)) goto l_out; - } list_for_each_entry(pitem, &p_inject_list->mgr_list, list) { - ps3stor_cli_printf("inject_task host_no %u cmdtype 0x%u " - "cmdSubtype 0x%u dealType 0x%u times %u!\n", - pitem->item.mgr_cmd.host_no, pitem->item.mgr_cmd.cmd_type, - pitem->item.mgr_cmd.cmd_sub_type,pitem->item.mgr_cmd.dealType, - pitem->item.mgr_cmd.inject_count); + ps3stor_cli_printf("inj_task hno %u ctype %u cSubtype %u dType %u times %u!\n", + pitem->item.mgr_cmd.host_no, + pitem->item.mgr_cmd.cmd_type, + pitem->item.mgr_cmd.cmd_sub_type, + pitem->item.mgr_cmd.dealType, + pitem->item.mgr_cmd.inject_count); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_clear_all_inject_scsi_rw(void) +static void ps3_clear_all_inject_scsi_rw(void) { struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); struct inject_cmds_t *pitem_next = NULL; ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->scsi_rw_list)) { + if (list_empty(&p_inject_list->scsi_rw_list)) goto l_out; - } - list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->scsi_rw_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &p_inject_list->scsi_rw_list, list) { list_del(&pitem->list); kfree(pitem); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_clear_all_inject_scsi_task(void) +static void ps3_clear_all_inject_scsi_task(void) { struct inject_cmds_t *pitem = NULL; struct inject_cmds_t *pitem_next = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->scsi_task_list)) { + if (list_empty(&p_inject_list->scsi_task_list)) goto l_out; - } - list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->scsi_task_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &p_inject_list->scsi_task_list, list) { list_del(&pitem->list); kfree(pitem); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_clear_all_inject_mgr(void) +static void ps3_clear_all_inject_mgr(void) { struct inject_cmds_t *pitem = NULL; struct inject_cmds_t *pitem_next = NULL; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); ps3_mutex_lock(&p_inject_list->lock); - if (list_empty(&p_inject_list->mgr_list)) { + if (list_empty(&p_inject_list->mgr_list)) goto l_out; - } - list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->mgr_list, list) { + list_for_each_entry_safe(pitem, pitem_next, &p_inject_list->mgr_list, + list) { list_del(&pitem->list); kfree(pitem); } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return; } -void ps3_del_inject_scsi_rw(struct inject_cmds_t *pitem) +static void ps3_del_inject_scsi_rw(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); - if ((pitem1 = ps3_inject_scsi_rw_exist(pitem)) == NULL){ + pitem1 = ps3_inject_scsi_rw_exist(pitem); + if (pitem1 == NULL) { ps3stor_cli_printf("rw inject type is noexist!\n"); goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("del inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + ps3stor_cli_printf( + "del inject_rw host_no %u channel %u id %u lba 0x%llx len %u type %u, time %u!\n", pitem1->item.scsi_cmd.host_no, pitem1->item.scsi_cmd.channel, pitem1->item.scsi_cmd.id, pitem1->item.scsi_cmd.lba, pitem1->item.scsi_cmd.len, pitem1->item.scsi_cmd.dealType, @@ -4176,23 +4452,26 @@ void ps3_del_inject_scsi_rw(struct inject_cmds_t *pitem) l_err: kfree(pitem); - return; } -void ps3_del_inject_scsi_task(struct inject_cmds_t *pitem) +static void ps3_del_inject_scsi_task(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); - if ((pitem1 = ps3_inject_scsi_task_exist(pitem)) == NULL){ + pitem1 = ps3_inject_scsi_task_exist(pitem); + if (pitem1 == NULL) { ps3stor_cli_printf("task inject type is noexist!\n"); goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("del inject_task host_no %u channel %u id %u" - " cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", - pitem1->item.scsi_task_cmd.host_no, pitem1->item.scsi_task_cmd.channel, - pitem1->item.scsi_task_cmd.id, pitem1->item.scsi_task_cmd.cmd_type, - pitem1->item.scsi_task_cmd.cmd_sub_type, pitem1->item.scsi_task_cmd.dealType, + ps3stor_cli_printf( + "del inj_task hno %u chan %u id %u ctype %u cSubtype %u dType %u times %u!\n", + pitem1->item.scsi_task_cmd.host_no, + pitem1->item.scsi_task_cmd.channel, + pitem1->item.scsi_task_cmd.id, + pitem1->item.scsi_task_cmd.cmd_type, + pitem1->item.scsi_task_cmd.cmd_sub_type, + pitem1->item.scsi_task_cmd.dealType, pitem1->item.scsi_task_cmd.inject_count); list_del(&pitem1->list); ps3_mutex_unlock(&p_inject_list->lock); @@ -4200,21 +4479,24 @@ void ps3_del_inject_scsi_task(struct inject_cmds_t *pitem) l_err: kfree(pitem); - return; } -void ps3_del_inject_mgr(struct inject_cmds_t *pitem) +static void ps3_del_inject_mgr(struct inject_cmds_t *pitem) { struct inject_cmds_t *pitem1; - PS3Inject_s *p_inject_list = get_inject(); + struct PS3Inject *p_inject_list = get_inject(); + + pitem1 = ps3_inject_mgr_exist(pitem); - if ((pitem1 = ps3_inject_mgr_exist(pitem)) == NULL){ + if (pitem1 == NULL) { ps3stor_cli_printf("mgr inject type is noexist!\n"); goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("del inject_mgr host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + ps3stor_cli_printf( + "del inject_mgr host_no %u cmdtype %u cmdSubtype %u dealType %u times %u!\n", pitem1->item.mgr_cmd.host_no, pitem1->item.mgr_cmd.cmd_type, - pitem1->item.mgr_cmd.cmd_sub_type,pitem1->item.mgr_cmd.dealType, + pitem1->item.mgr_cmd.cmd_sub_type, + pitem1->item.mgr_cmd.dealType, pitem1->item.mgr_cmd.inject_count); list_del(&pitem1->list); ps3_mutex_unlock(&p_inject_list->lock); @@ -4222,21 +4504,21 @@ void ps3_del_inject_mgr(struct inject_cmds_t *pitem) l_err: kfree(pitem); - return; } -S32 ps3_add_inject_scsi_rw(struct inject_cmds_t *pitem) +static int ps3_add_inject_scsi_rw(struct inject_cmds_t *pitem) { - S32 iRet = PS3_SUCCESS; - PS3Inject_s *p_inject_list = get_inject(); + int iRet = PS3_SUCCESS; + struct PS3Inject *p_inject_list = get_inject(); - if (ps3_inject_scsi_rw_exist(pitem) != NULL){ + if (ps3_inject_scsi_rw_exist(pitem) != NULL) { ps3stor_cli_printf("rw inject type is exist!\n"); iRet = -PS3_FAILED; goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", + ps3stor_cli_printf( + "inject_rw host_no %u channel %u id %u lba 0x%llx len %u type %u, time %u!\n", pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, pitem->item.scsi_cmd.len, pitem->item.scsi_cmd.dealType, @@ -4250,22 +4532,24 @@ S32 ps3_add_inject_scsi_rw(struct inject_cmds_t *pitem) l_out: return iRet; } -S32 ps3_add_inject_scsi_task(struct inject_cmds_t *pitem) +static int ps3_add_inject_scsi_task(struct inject_cmds_t *pitem) { - S32 iRet = PS3_SUCCESS; - PS3Inject_s *p_inject_list = get_inject(); + int iRet = PS3_SUCCESS; + struct PS3Inject *p_inject_list = get_inject(); - if (ps3_inject_scsi_task_exist(pitem) != NULL){ + if (ps3_inject_scsi_task_exist(pitem) != NULL) { ps3stor_cli_printf("task inject type is exist!\n"); iRet = -PS3_FAILED; goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("inject_task host_no %u channel %u id %u " - "cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", - pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, - pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, - pitem->item.scsi_task_cmd.cmd_sub_type, pitem->item.scsi_task_cmd.dealType, + ps3stor_cli_printf( + "inj_task hno %u chan %u id %u ctype %u cSubtype %u dType %u times %u!\n", + pitem->item.scsi_task_cmd.host_no, + pitem->item.scsi_task_cmd.channel, pitem->item.scsi_task_cmd.id, + pitem->item.scsi_task_cmd.cmd_type, + pitem->item.scsi_task_cmd.cmd_sub_type, + pitem->item.scsi_task_cmd.dealType, pitem->item.scsi_task_cmd.inject_count); list_add_tail(&pitem->list, &p_inject_list->scsi_task_list); ps3_mutex_unlock(&p_inject_list->lock); @@ -4276,18 +4560,19 @@ S32 ps3_add_inject_scsi_task(struct inject_cmds_t *pitem) l_out: return iRet; } -S32 ps3_add_inject_mgr(struct inject_cmds_t *pitem) +static int ps3_add_inject_mgr(struct inject_cmds_t *pitem) { - S32 iRet = PS3_SUCCESS; - PS3Inject_s *p_inject_list = get_inject(); + int iRet = PS3_SUCCESS; + struct PS3Inject *p_inject_list = get_inject(); - if (ps3_inject_mgr_exist(pitem) != NULL){ + if (ps3_inject_mgr_exist(pitem) != NULL) { ps3stor_cli_printf("mgr inject type is exist!\n"); iRet = -PS3_FAILED; goto l_err; } ps3_mutex_lock(&p_inject_list->lock); - ps3stor_cli_printf("inject_task host_no %u cmdtype 0x%u cmdSubtype 0x%u dealType 0x%u times %u!\n", + ps3stor_cli_printf( + "inject_task host_no %u cmdtype %u cmdSubtype %u dealType %u times %u!\n", pitem->item.mgr_cmd.host_no, pitem->item.mgr_cmd.cmd_type, pitem->item.mgr_cmd.cmd_sub_type, pitem->item.mgr_cmd.dealType, pitem->item.mgr_cmd.inject_count); @@ -4304,17 +4589,17 @@ S32 ps3_add_inject_mgr(struct inject_cmds_t *pitem) static void ps3_inject_scsi_rw(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - U64 lba; - U32 len; - S32 ret; - U32 result; - U32 sense_info; + unsigned int host_no; + unsigned int id; + unsigned int channel; + unsigned long long lba; + unsigned int len; + int ret; + unsigned int result; + unsigned int sense_info; struct scsi_device *sdev; - U32 times; - U32 dealType; + unsigned int times; + unsigned int dealType; struct ps3_instance *instance; if (argc < 13) { @@ -4322,10 +4607,9 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4340,8 +4624,7 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_cmd.host_no = host_no; @@ -4365,7 +4648,7 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_cmd.channel = channel; @@ -4400,15 +4683,14 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) ps3stor_cli_printf("Can not parse dealType!\n"); goto l_err; } - if (dealType != PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY - && dealType != PS3_SCSI_CMD_ERROR) { + if (dealType != PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY && + dealType != PS3_SCSI_CMD_ERROR) { ps3stor_cli_printf("err type is invalid!\n"); goto l_err; } pitem->item.scsi_cmd.dealType = dealType; - switch (pitem->item.scsi_cmd.dealType) - { + switch (pitem->item.scsi_cmd.dealType) { case PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY: if (strcmp(argv[11], "times") != 0) { ps3stor_cli_printf("times is needed!\n"); @@ -4445,10 +4727,14 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) ps3stor_cli_printf("Can not parse sense!\n"); goto l_err; } - pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.resp_code = sense_info & 0xf; - pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.sense_key = sense_info >> 8 & 0xf; - pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.asc = sense_info >> 16 & 0xf; - pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.ascq = sense_info >> 24 & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.resp_code = + sense_info & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.sense_key = + sense_info >> 8 & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.asc = + sense_info >> 16 & 0xf; + pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.ascq = + sense_info >> 24 & 0xf; if (strcmp(argv[15], "times") != 0) { ps3stor_cli_printf("times is needed!\n"); @@ -4464,8 +4750,7 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) break; default: ps3stor_cli_printf("handle type is invalid!\n"); - goto l_err; - break; + goto l_err; } ps3_add_inject_scsi_rw(pitem); goto l_out; @@ -4478,13 +4763,13 @@ static void ps3_inject_scsi_rw(int argc, char *argv[]) static void ps3_inject_scsi_task(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - S32 ret; + unsigned int host_no; + unsigned int id; + unsigned int channel; + int ret; struct scsi_device *sdev; - U32 times; - U32 dealType; + unsigned int times; + unsigned int dealType; struct ps3_instance *instance; if (argc < 10) { @@ -4492,10 +4777,9 @@ static void ps3_inject_scsi_task(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4510,8 +4794,7 @@ static void ps3_inject_scsi_task(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_task_cmd.host_no = host_no; @@ -4535,18 +4818,22 @@ static void ps3_inject_scsi_task(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_task_cmd.channel = channel; pitem->item.scsi_task_cmd.id = id; if (strcmp(argv[6], "abort") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_ABORT; } else if (strcmp(argv[6], "reset") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_RESET; } else { ps3stor_cli_printf("type is invalid!\n"); goto l_err; @@ -4557,8 +4844,9 @@ static void ps3_inject_scsi_task(int argc, char *argv[]) ps3stor_cli_printf("Can not parse dealType!\n"); goto l_err; } - if (dealType != PS3_SCSI_TASK_CMD_TIMEOUT && dealType != PS3_SCSI_TASK_CMD_ERROE && - dealType != PS3_SCSI_TASK_CMD_NORMAL) { + if (dealType != PS3_SCSI_TASK_CMD_TIMEOUT && + dealType != PS3_SCSI_TASK_CMD_ERROE && + dealType != PS3_SCSI_TASK_CMD_NORMAL) { ps3stor_cli_printf("deal type is invalid!\n"); goto l_err; } @@ -4587,13 +4875,13 @@ static void ps3_inject_scsi_task(int argc, char *argv[]) static void ps3_inject_mgr(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U8 cmd_type; - U8 cmd_sub_type; - S32 ret; - U32 times; - U32 dealType; - U32 errType; + unsigned int host_no; + unsigned char cmd_type; + unsigned char cmd_sub_type; + int ret; + unsigned int times; + unsigned int dealType; + unsigned int errType; struct ps3_instance *instance; if (argc < 10) { @@ -4601,10 +4889,9 @@ static void ps3_inject_mgr(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4619,15 +4906,14 @@ static void ps3_inject_mgr(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_task_cmd.host_no = host_no; if (strcmp(argv[3], "cmd_type") != 0) { ps3stor_cli_printf("cmd_type is needed!\n"); - goto l_err; + goto l_err; } ret = kstrtou8(argv[4], 0, &cmd_type); @@ -4704,12 +4990,12 @@ static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - U64 lba; - U32 len; - S32 ret; + unsigned int host_no; + unsigned int id; + unsigned int channel; + unsigned long long lba; + unsigned int len; + int ret; struct scsi_device *sdev; struct ps3_instance *instance; @@ -4718,10 +5004,9 @@ static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4736,8 +5021,7 @@ static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_cmd.host_no = host_no; @@ -4761,7 +5045,7 @@ static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_cmd.channel = channel; @@ -4796,16 +5080,15 @@ static void ps3_clear_inject_scsi_rw(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_clear_inject_scsi_task(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - S32 ret; + unsigned int host_no; + unsigned int id; + unsigned int channel; + int ret; struct scsi_device *sdev; struct ps3_instance *instance; @@ -4814,10 +5097,9 @@ static void ps3_clear_inject_scsi_task(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4832,8 +5114,7 @@ static void ps3_clear_inject_scsi_task(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_task_cmd.host_no = host_no; @@ -4857,18 +5138,22 @@ static void ps3_clear_inject_scsi_task(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_task_cmd.channel = channel; pitem->item.scsi_task_cmd.id = id; if (strcmp(argv[6], "abort") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_ABORT; } else if (strcmp(argv[6], "reset") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_RESET; } else { ps3stor_cli_printf("type is invalid!\n"); goto l_err; @@ -4878,16 +5163,15 @@ static void ps3_clear_inject_scsi_task(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_clear_inject_mgr(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 cmd_type; - U32 cmd_sub_type; - S32 ret; + unsigned int host_no; + unsigned int cmd_type; + unsigned int cmd_sub_type; + int ret; struct ps3_instance *instance; if (argc < 7) { @@ -4895,10 +5179,9 @@ static void ps3_clear_inject_mgr(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4913,13 +5196,12 @@ static void ps3_clear_inject_mgr(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.mgr_cmd.host_no = host_no; - if (strcmp(argv[3], "cmd_type") != 0){ + if (strcmp(argv[3], "cmd_type") != 0) { ps3stor_cli_printf("cmd_type is invalid!\n"); goto l_err; } @@ -4931,7 +5213,7 @@ static void ps3_clear_inject_mgr(int argc, char *argv[]) } pitem->item.mgr_cmd.cmd_type = cmd_type; - if (strcmp(argv[5], "cmd_sub_type") != 0){ + if (strcmp(argv[5], "cmd_sub_type") != 0) { ps3stor_cli_printf("cmd_sub_type is invalid!\n"); goto l_err; } @@ -4948,7 +5230,6 @@ static void ps3_clear_inject_mgr(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_clear_all_inject(int argc, char *argv[]) @@ -4964,12 +5245,12 @@ static void ps3_show_inject_scsi_rw(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - U64 lba; - U32 len; - S32 ret; + unsigned int host_no; + unsigned int id; + unsigned int channel; + unsigned long long lba; + unsigned int len; + int ret; struct scsi_device *sdev; struct ps3_instance *instance; @@ -4978,10 +5259,9 @@ static void ps3_show_inject_scsi_rw(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t*)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -4996,8 +5276,7 @@ static void ps3_show_inject_scsi_rw(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_cmd.host_no = host_no; @@ -5021,7 +5300,7 @@ static void ps3_show_inject_scsi_rw(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_cmd.channel = channel; @@ -5054,16 +5333,15 @@ static void ps3_show_inject_scsi_rw(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_show_inject_scsi_task(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 id; - U32 channel; - S32 ret; + unsigned int host_no; + unsigned int id; + unsigned int channel; + int ret; struct scsi_device *sdev; struct ps3_instance *instance; @@ -5072,10 +5350,9 @@ static void ps3_show_inject_scsi_task(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -5090,8 +5367,7 @@ static void ps3_show_inject_scsi_task(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_task_cmd.host_no = host_no; @@ -5115,18 +5391,22 @@ static void ps3_show_inject_scsi_task(int argc, char *argv[]) sdev = ps3_scsi_device_lookup(instance, channel, id, 0); if (sdev == NULL) { ps3stor_cli_printf("Invalid sdev [%d:%d:%d] invalid !\n", - host_no, channel, id); + host_no, channel, id); goto l_err; } pitem->item.scsi_task_cmd.channel = channel; pitem->item.scsi_task_cmd.id = id; if (strcmp(argv[6], "abort") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_ABORT; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_ABORT; } else if (strcmp(argv[6], "reset") == 0) { - pitem->item.scsi_task_cmd.cmd_type = PS3_CMD_SCSI_TASK_MANAGEMENT; - pitem->item.scsi_task_cmd.cmd_sub_type = PS3_TASK_CMD_SCSI_TASK_RESET; + pitem->item.scsi_task_cmd.cmd_type = + PS3_CMD_SCSI_TASK_MANAGEMENT; + pitem->item.scsi_task_cmd.cmd_sub_type = + PS3_TASK_CMD_SCSI_TASK_RESET; } else { ps3stor_cli_printf("type is invalid!\n"); goto l_err; @@ -5136,16 +5416,15 @@ static void ps3_show_inject_scsi_task(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_show_inject_mgr(int argc, char *argv[]) { struct inject_cmds_t *pitem = NULL; - U32 host_no; - U32 cmd_type; - U32 cmd_sub_type; - S32 ret; + unsigned int host_no; + unsigned int cmd_type; + unsigned int cmd_sub_type; + int ret; struct ps3_instance *instance; if (argc < 7) { @@ -5153,10 +5432,9 @@ static void ps3_show_inject_mgr(int argc, char *argv[]) return; } - pitem = (struct inject_cmds_t *)kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); - if (pitem == NULL) { + pitem = kmalloc(sizeof(struct inject_cmds_t), GFP_KERNEL); + if (pitem == NULL) return; - } if (strcmp(argv[1], "host_no") != 0) { ps3stor_cli_printf("host_no is needed!\n"); @@ -5171,8 +5449,7 @@ static void ps3_show_inject_mgr(int argc, char *argv[]) instance = ps3_instance_lookup(host_no); if (instance == NULL) { - ps3stor_cli_printf("Invalid host_no %d invalid !\n", - host_no); + ps3stor_cli_printf("Invalid host_no %d invalid !\n", host_no); goto l_err; } pitem->item.scsi_task_cmd.host_no = host_no; @@ -5205,23 +5482,21 @@ static void ps3_show_inject_mgr(int argc, char *argv[]) l_err: kfree(pitem); - return; } static void ps3_show_all_inject(int argc, char *argv[]) { ps3_show_inject_all_scsi_rw(argc, argv); ps3_show_inject_all_scsi_task(argc, argv); ps3_show_inject_all_mgr(argc, argv); - return; } -void ps3_scsi_task_cmd_clear_all(void) +static void ps3_scsi_task_cmd_clear_all(void) { struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); - PS3HitCmd_s * p_hit_inject = get_hit_inject(); + struct PS3Inject *p_inject_list = get_inject(); + struct PS3HitCmd *p_hit_inject = get_hit_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_hit_inject->scsi_task_list)) { @@ -5229,27 +5504,26 @@ void ps3_scsi_task_cmd_clear_all(void) goto l_out; } - list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->scsi_task_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &p_hit_inject->scsi_task_list, list) { list_del(&p_cmd->list); kfree(p_cmd); } - if(pitem->item.scsi_task_cmd.inject_count == 0) { + if (pitem->item.scsi_task_cmd.inject_count == 0) ps3_delete_scsi_task_inject(pitem); - } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return ; } -void ps3_mgr_cmd_clear_all(void) +static void ps3_mgr_cmd_clear_all(void) { struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; struct inject_cmds_t *pitem = NULL; - PS3Inject_s *p_inject_list = get_inject(); - PS3HitCmd_s * p_hit_inject = get_hit_inject(); + struct PS3Inject *p_inject_list = get_inject(); + struct PS3HitCmd *p_hit_inject = get_hit_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_hit_inject->mgr_list)) { @@ -5257,25 +5531,24 @@ void ps3_mgr_cmd_clear_all(void) goto l_out; } - list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->mgr_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->mgr_list, + list) { list_del(&p_cmd->list); kfree(p_cmd); } - if(pitem->item.mgr_cmd.inject_count == 0) { + if (pitem->item.mgr_cmd.inject_count == 0) ps3_delete_mgr_inject(pitem); - } l_out: ps3_mutex_unlock(&p_inject_list->lock); - return ; } -void ps3_scsi_rw_cmd_clear_all(void) +static void ps3_scsi_rw_cmd_clear_all(void) { struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; - PS3Inject_s *p_inject_list = get_inject(); - PS3HitCmd_s * p_hit_inject = get_hit_inject(); + struct PS3Inject *p_inject_list = get_inject(); + struct PS3HitCmd *p_hit_inject = get_hit_inject(); ps3_mutex_lock(&p_inject_list->lock); if (list_empty(&p_hit_inject->scsi_rw_list)) { @@ -5283,7 +5556,8 @@ void ps3_scsi_rw_cmd_clear_all(void) goto l_out; } - list_for_each_entry_safe(p_cmd, p_cmd_next, &p_hit_inject->scsi_rw_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &p_hit_inject->scsi_rw_list, list) { list_del(&p_cmd->list); ps3_scsi_dma_unmap(p_cmd->cmd); ps3_scsi_cmd_free(p_cmd->cmd); @@ -5292,7 +5566,6 @@ void ps3_scsi_rw_cmd_clear_all(void) l_out: ps3_mutex_unlock(&p_inject_list->lock); - return ; } static void ps3_clear_hit_cmd(int argc, char *argv[]) @@ -5319,14 +5592,15 @@ void ps3_cli_debug_init(void) { int ret = 0; struct ps3_cli_debug_cmd *cmd = NULL; - U32 table_index = 0; - U32 table_size = ARRAY_SIZE(g_ps3_cli_debug_cmd_table); + unsigned int table_index = 0; + unsigned int table_size = ARRAY_SIZE(g_ps3_cli_debug_cmd_table); + for (table_index = 0; table_index < table_size; table_index++) { cmd = &g_ps3_cli_debug_cmd_table[table_index]; - ret = ps3stor_cli_register(cmd->func, cmd->func_name, cmd->help); - if (ret) { - printk("cli register failed:%s:%d\n", cmd->func_name, ret); - } + ret = ps3stor_cli_register(cmd->func, cmd->func_name, + cmd->help); + if (ret) + pr_err("cli register failed:%s:%d\n", cmd->func_name, ret); } - INJECT_INIT() + INJECT_INIT(); } diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h index 63b362c25d38..e0f28638eac9 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_cli_debug.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CLI_DEBUG_H_ #define _PS3_CLI_DEBUG_H_ #include "ps3_instance_manager.h" @@ -7,12 +7,11 @@ ssize_t ps3_ioc_reg_dump(struct ps3_instance *instance, char *buf); void ps3_cli_debug_init(void); -void ps3_io_statis_dump_cli_cb_test(U8 detail); +void ps3_io_statis_dump_cli_cb_test(unsigned char detail); -Bool ps3_get_wait_cli_flag(void); +unsigned char ps3_get_wait_cli_flag(void); #ifdef PS3_SUPPORT_INJECT void ps3_inject_clear(void); #endif #endif - diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c index d15aa32ec9ca..44d5b4046363 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -21,7 +22,8 @@ #include "ps3_driver_log.h" #include "ps3_module_para.h" -S32 g_ramfs_test_enable = 0; +#include "ps3_kernel_version.h" +#include "ps3_util.h" #if defined DRIVER_DEBUG && defined __KERNEL__ @@ -32,101 +34,101 @@ S32 g_ramfs_test_enable = 0; #define DRV_LOG_FILE_SIZE_MIN_MB 10 #define DRV_LOG_FILE_SIZE_MAX_MB 200 -ps3_debug_t g_ps3_debug; -char g_log_path_str[LOG_PATH_LEN] = {0}; -char g_log_path_bin[LOG_PATH_LEN] = {0}; +struct ps3_debug g_ps3_debug; +char g_log_path_str[LOG_PATH_LEN] = { 0 }; +char g_log_path_bin[LOG_PATH_LEN] = { 0 }; static inline int time_for_log(char *buff, int buf_len) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#if defined(PS3_DUMP_TIME_32) struct timeval tv; struct tm td; do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); return snprintf(buff, buf_len, "[%04ld-%02d-%02d;%02d:%02d:%02d.%ld]", - td.tm_year + 1900, - td.tm_mon + 1, td.tm_mday, td.tm_hour, - td.tm_min, td.tm_sec, tv.tv_usec); + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec, tv.tv_usec); #else struct timespec64 tv; struct tm td; + ktime_get_real_ts64(&tv); - time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); + time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); return snprintf(buff, buf_len, "[%04ld-%02d-%02d;%02d:%02d:%02d.%ld]", - td.tm_year + 1900, - td.tm_mon + 1, td.tm_mday, td.tm_hour, - td.tm_min, td.tm_sec, tv.tv_nsec*1000); + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec, tv.tv_nsec * 1000); #endif } static inline int time_for_file_name(char *buff, int buf_len) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#if defined(PS3_DUMP_TIME_32) struct timeval tv; struct tm td; do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); #else struct timespec64 tv; struct tm td; + ktime_get_real_ts64(&tv); - time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest*60, &td); + time64_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); #endif return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec); + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec); } static inline char *ps3_stack_top(void) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) - ULong *ptr = (ULong*)(current->thread_info + 1); +#if defined(PS3_THREAD_INFO) + unsigned long *ptr = (unsigned long *)(current->thread_info + 1); #else - ULong *ptr = (ULong*)(task_thread_info(current) + 1 ); + unsigned long *ptr = (unsigned long *)(task_thread_info(current) + 1); #endif - return (char*)(ptr + 1); + return (char *)(ptr + 1); } -static inline ps3_thread_local_t *ps3_thread_local_get(ps3_thread_key_t * key) +static inline struct ps3_thread_local *ps3_thread_local_get(struct ps3_thread_key *key) { - return (ps3_thread_local_t*)(ps3_stack_top() + key->offset); + return (struct ps3_thread_local *)(ps3_stack_top() + key->offset); } -void ps3_thread_key_create(int size, ps3_thread_key_t *key) +void ps3_thread_key_create(int size, struct ps3_thread_key *key) { key->offset = g_ps3_debug.key_offset; - g_ps3_debug.key_offset += sizeof(ps3_thread_local_t) + size; + g_ps3_debug.key_offset += sizeof(struct ps3_thread_local) + size; } -void *ps3_thread_get_specific(ps3_thread_key_t *key) +void *ps3_thread_get_specific(struct ps3_thread_key *key) { - ps3_thread_local_t *local = ps3_thread_local_get(key); + struct ps3_thread_local *local = ps3_thread_local_get(key); + if (local->magic != DEBUG_TRACE_MAGIC) - { return NULL; - } - return (void*)local->data; + return (void *)local->data; } -void ps3_thread_clear_specific(ps3_thread_key_t *key) +void ps3_thread_clear_specific(struct ps3_thread_key *key) { - ps3_thread_local_t *local = ps3_thread_local_get(key); + struct ps3_thread_local *local = ps3_thread_local_get(key); + local->magic = 0; } int ps3_filter_file_add(char *name) { - debug_file_t *file = NULL; + struct debug_file *file = NULL; - file = (debug_file_t*)kmalloc(sizeof(debug_file_t), GFP_ATOMIC); - if (!file){ - ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); + file = kmalloc(sizeof(struct debug_file), GFP_ATOMIC); + if (!file) { + ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", PAGE_SIZE); return -ENOMEM; } - strncpy(file->name, name, sizeof(file->name)); + PS3_STRCPY(file->name, name, sizeof(file->name)); INIT_LIST_HEAD(&file->list); list_add_rcu(&file->list, &g_ps3_debug.filter_file); @@ -135,26 +137,26 @@ int ps3_filter_file_add(char *name) void ps3_filter_file_del(char *filename) { - debug_file_t *file = NULL; + struct debug_file *file = NULL; - list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list){ - if(!strcmp(file->name, filename)){ + list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list) { + if (!strcmp(file->name, filename)) { list_del_rcu(&file->list); synchronize_rcu(); kfree(file); return; } } - return; } #ifndef PS3_CFG_RELEASE static inline int ps3_filter_file_print(const char *filename) { - debug_file_t *file; + struct debug_file *file; + rcu_read_lock(); - list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list){ - if(!strcmp(file->name, filename)){ + list_for_each_entry_rcu(file, &g_ps3_debug.filter_file, list) { + if (!strcmp(file->name, filename)) { rcu_read_unlock(); return 1; } @@ -166,33 +168,29 @@ static inline int ps3_filter_file_print(const char *filename) #endif void ps3_filter_file_clear(void) { - debug_file_t *file = NULL; - - do{ - file = list_first_or_null_rcu( - &g_ps3_debug.filter_file, - debug_file_t, - list); - if (file){ + struct debug_file *file = NULL; + + do { + file = list_first_or_null_rcu(&g_ps3_debug.filter_file, + struct debug_file, list); + if (file) { list_del_rcu(&file->list); synchronize_rcu(); kfree(file); } - }while(file); - - return; + } while (file); } int ps3_filter_func_add(char *name) { - debug_func_t *func = NULL; + struct debug_func *func = NULL; - func = (debug_func_t *)kmalloc(sizeof(debug_func_t), GFP_ATOMIC); - if (!func){ - ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); + func = kmalloc(sizeof(struct debug_func), GFP_ATOMIC); + if (!func) { + ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", PAGE_SIZE); return -ENOMEM; } - strncpy(func->name, name, sizeof(func->name)); + PS3_STRCPY(func->name, name, sizeof(func->name)); INIT_LIST_HEAD(&func->list); list_add_rcu(&func->list, &g_ps3_debug.filter_func); @@ -201,36 +199,31 @@ int ps3_filter_func_add(char *name) void ps3_filter_func_del(char *name) { - debug_func_t *func = NULL; + struct debug_func *func = NULL; - list_for_each_entry_rcu(func, &g_ps3_debug.filter_func, list){ - if(!strcmp(func->name, name)){ + list_for_each_entry_rcu(func, &g_ps3_debug.filter_func, list) { + if (!strcmp(func->name, name)) { list_del_rcu(&func->list); synchronize_rcu(); kfree(func); return; } } - return; } void ps3_filter_func_clear(void) { - debug_func_t *func = NULL; - - do{ - func = list_first_or_null_rcu( - &g_ps3_debug.filter_func, - debug_func_t, - list); - if (func){ + struct debug_func *func = NULL; + + do { + func = list_first_or_null_rcu(&g_ps3_debug.filter_func, + struct debug_func, list); + if (func) { list_del_rcu(&func->list); synchronize_rcu(); kfree(func); } - }while(func); - - return; + } while (func); } void ps3_level_set(int level) @@ -238,14 +231,14 @@ void ps3_level_set(int level) g_ps3_debug.level = level; } -S32 ps3_level_get(void) +int ps3_level_get(void) { - return (S32)g_ps3_debug.level; + return (int)g_ps3_debug.level; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) static void ps3_file_close(struct file **file) { @@ -253,10 +246,10 @@ static void ps3_file_close(struct file **file) *file = NULL; } -static int ps3_file_open(ps3_log_t *log, struct file **pp_file) +static int ps3_file_open(struct ps3_log *log, struct file **pp_file) { struct file *file; - int flags_new = O_CREAT | O_RDWR | O_APPEND | O_LARGEFILE; + int flags_new = O_CREAT | O_RDWR | O_APPEND | O_LARGEFILE; int flags_rewrite = O_CREAT | O_RDWR | O_LARGEFILE | O_TRUNC; int err = 0; int len = 0; @@ -268,17 +261,18 @@ static int ps3_file_open(ps3_log_t *log, struct file **pp_file) if (log->file_num == 0) { time_for_file_name(filename + len, FILE_NAME_SIZE - len); } else { - snprintf(filename + len, FILE_NAME_SIZE - len, "%04d", log->index++); + snprintf(filename + len, FILE_NAME_SIZE - len, "%04d", + log->index++); log->index = log->index % log->file_num; } - if(log->file_num == 1 && log->file != NULL) { + if (log->file_num == 1 && log->file != NULL) { ps3_file_close(&log->file); log->file_pos = 0; } #else memset(filename, 0, FILE_NAME_SIZE); - strncpy(filename, path, FILE_NAME_SIZE); + PS3_STRCPY(filename, path, FILE_NAME_SIZE); #endif if (log->file_num == 0) { file = filp_open(filename, flags_new, 0666); @@ -286,36 +280,38 @@ static int ps3_file_open(ps3_log_t *log, struct file **pp_file) file = filp_open(filename, flags_rewrite, 0666); if (IS_ERR(file)) { err = (int)PTR_ERR(file); - if (err == -ENOENT) { + if (err == -ENOENT) file = filp_open(filename, flags_new, 0666); - } } } if (IS_ERR(file)) { err = (int)PTR_ERR(file); if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(KERN_INFO,"open file:%s failed[errno:%d]\n", filename, err); + ps3_print(PRINT_INFO, "open file:%s failed[errno:%d]\n", + filename, err); } goto l_out; } - if (!ps3_fs_requires_dev(file)) { -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + if (!ps3_fs_requires_dev(file)) { +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(KERN_INFO, "unexpected filesystem, superblock flags: 0x%x\n", - file->f_inode->i_sb->s_type->fs_flags); + ps3_print( + PRINT_INFO, + "unexpected filesystem, superblock flags: 0x%x\n", + file->f_inode->i_sb->s_type->fs_flags); } #endif - ps3_file_close(&file); - err = -EINVAL; - goto l_out; - } + ps3_file_close(&file); + err = -EINVAL; + goto l_out; + } mapping_set_gfp_mask(file->f_path.dentry->d_inode->i_mapping, GFP_NOFS); - ps3_print(KERN_INFO,"redirect file %s\n", filename); + ps3_print(PRINT_INFO, "redirect file %s\n", filename); *pp_file = file; @@ -326,35 +322,32 @@ static int ps3_file_open(ps3_log_t *log, struct file **pp_file) static void ps3_file_sync(struct file *file) { struct address_space *mapping; - void *journal; + void *journal; int ret = 0; int err; (void)ret; (void)err; - if( !file || !file->f_op || !file->f_op->fsync ){ + if (!file || !file->f_op || !file->f_op->fsync) goto l_end; - } - journal = current->journal_info; + journal = current->journal_info; current->journal_info = NULL; mapping = file->f_mapping; ret = filemap_fdatawrite(mapping); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) +#if defined(PS3_FILEMAP_WAIT) mutex_lock(&mapping->host->i_mutex); err = file->f_op->fsync(file, file->f_path.dentry, 1); - if( !ret ){ + if (!ret) ret = err; - } mutex_unlock(&mapping->host->i_mutex); err = filemap_fdatawait(mapping); - if( !ret ){ + if (!ret) ret = err; - } #else err = file->f_op->fsync(file, 0, file->f_mapping->host->i_size, 1); @@ -371,17 +364,17 @@ static int ps3_file_write(struct file *file, char *buf, int len) int ret = 0; void *journal; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) +#if defined(PS3_SUPPORT_FS) mm_segment_t old_fs; #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) +#if defined(PS3_KERNEL_WRITE_GET_DS) old_fs = get_fs(); set_fs(get_ds()); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#elif defined(PS3_KERNEL_WRITE) old_fs = get_fs(); set_fs(KERNEL_DS); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#elif defined(PS3_VFS_WRITE) #else old_fs = force_uaccess_begin(); #endif @@ -389,34 +382,33 @@ static int ps3_file_write(struct file *file, char *buf, int len) journal = current->journal_info; current->journal_info = NULL; - if (!file){ + if (!file) { return 0; } - do{ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) + do { +#if defined(PS3_KERNEL_WRITE_FILE_OP) ret = file->f_op->write(file, buf, len, &file->f_pos); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) +#elif defined(PS3_KERNEL_WRITE_FILE_VFS) ret = vfs_write(file, buf, len, &file->f_pos); #else ret = kernel_write(file, buf, len, &file->f_pos); #endif - }while( ret == -EINTR ); + } while (ret == -EINTR); if (ret >= 0) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,0) +#if defined(PS3_FSNOTIFY_FILE) fsnotify_modify(file); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) - if ( file->f_path.dentry) { +#elif defined(PS3_FSNOTIFY_FILE_PATH) + if (file->f_path.dentry) fsnotify_modify(file->f_path.dentry); - } #endif } current->journal_info = journal; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#if defined(PS3_SET_FS) set_fs(old_fs); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#elif defined(PS3_FORCE_UACCESS) #else force_uaccess_end(old_fs); #endif @@ -424,38 +416,38 @@ static int ps3_file_write(struct file *file, char *buf, int len) return ret; } -static void ps3_klog_in(ps3_log_t *log, char *buf, const int len) +static void ps3_klog_in(struct ps3_log *log, char *buf, const int len) { int begin = 0; - int end = 0; + int end = 0; int free_size; - ULong flags; + unsigned long flags; static unsigned long j; spin_lock_irqsave(&log->lock, flags); if (log->head > log->tail) { if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(KERN_INFO,"FAILURE: log head exceeds log tail\n"); + ps3_print(PRINT_INFO, + "FAILURE: log head exceeds log tail\n"); PS3_BUG_NO_SYNC(); } } free_size = log->buf_size - (log->tail - log->head); - if (free_size <= len){ + if (free_size <= len) { log->is_drop = 1; spin_unlock_irqrestore(&log->lock, flags); return; } begin = log->tail % log->buf_size; - end = (log->tail + len) % log->buf_size; + end = (log->tail + len) % log->buf_size; - if (begin < end){ + if (begin < end) { memcpy(log->buf + begin, buf, len); - } - else{ + } else { memcpy(log->buf + begin, buf, log->buf_size - begin); memcpy(log->buf, buf + log->buf_size - begin, end); } @@ -463,11 +455,9 @@ static void ps3_klog_in(ps3_log_t *log, char *buf, const int len) log->tail = log->tail + len; spin_unlock_irqrestore(&log->lock, flags); - - return; } -static void ps3_klog_out(ps3_log_t *log) +static void ps3_klog_out(struct ps3_log *log) { int len = 0; int rc = 0; @@ -484,69 +474,61 @@ static void ps3_klog_out(ps3_log_t *log) if (log->file == NULL) { rc = ps3_file_open(log, &log->file); - if (log->file != NULL) { + if (log->file != NULL) log->file_pos = 0; - } else { + else return; - } } do { - tail = log->tail; + tail = log->tail; begin = log->head % log->buf_size; - end = tail % log->buf_size; + end = tail % log->buf_size; len = 0; rc = 0; schedule_count_th++; - if ((schedule_count_th >= max_loop)) { + if (schedule_count_th >= max_loop) { schedule_count_th = 0; schedule_timeout_interruptible(PS3_KLOG_OUT_WAIT); } if (log->is_drop) { - rc = ps3_file_write( - log->file, - DEBUG_DROP_LOG_STRING, - strlen(DEBUG_DROP_LOG_STRING)); - if (rc < 0) { + rc = ps3_file_write(log->file, DEBUG_DROP_LOG_STRING, + strlen(DEBUG_DROP_LOG_STRING)); + if (rc < 0) break; - } log->is_drop = 0; } if (begin < end) { - rc = ps3_file_write( - log->file, - log->buf + begin, - end - begin); - if (rc > 0) { + rc = ps3_file_write(log->file, log->buf + begin, + end - begin); + if (rc > 0) len += rc; - } - } else if(begin > end) { - rc = ps3_file_write( - log->file, - log->buf + begin, - log->buf_size - begin); + } else if (begin > end) { + rc = ps3_file_write(log->file, log->buf + begin, + log->buf_size - begin); if (rc > 0) { len += rc; rc = ps3_file_write(log->file, log->buf, end); - if (rc > 0) { + if (rc > 0) len += rc; - } } } log->head += len; log->file_pos += len; - LOG_BUG_ON(log->head > log->tail, "FAILURE: log head exceeds log tail\n"); - }while (log->head != log->tail && rc > 0); + LOG_BUG_ON(log->head > log->tail, + "FAILURE: log head exceeds log tail\n"); + } while (log->head != log->tail && rc > 0); if (rc < 0) { if (printk_timed_ratelimit(&j, PS3_LOG_LIMIT_INTERVAL_MSEC)) { - ps3_print(KERN_INFO,"write file %s error %d\n", log->file_path, rc); + ps3_print(PRINT_INFO, "write file %s error %d\n", + log->file_path, rc); } - return ; + return; } #ifdef DRIVER_SWITCH_FILE @@ -559,37 +541,31 @@ static void ps3_klog_out(ps3_log_t *log) } } #endif - return ; } static int ps3_klog_flush(void *arg) { int i; - while (!kthread_should_stop()){ + while (!kthread_should_stop()) { schedule_timeout_interruptible(PS3_KLOG_OUT_WAIT); - for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++){ + for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) ps3_klog_out(&g_ps3_debug.log[i]); - } } return 0; } -static int ps3_klog_init( - ps3_log_t *log, - long long buf_size, - char *file_path, - long long file_size, - U32 file_num) +static int ps3_klog_init(struct ps3_log *log, long long buf_size, char *file_path, + long long file_size, unsigned int file_num) { int rc = 0; memset(log, 0, sizeof(*log)); spin_lock_init(&log->lock); - log->buf = (char*)vmalloc(buf_size+PAGE_SIZE); - if (!log->buf){ + log->buf = vmalloc(buf_size + PAGE_SIZE); + if (!log->buf) { rc = -ENOMEM; goto l_end; } @@ -597,146 +573,125 @@ static int ps3_klog_init( log->file = NULL; log->head = 0; log->tail = 0; - log->buf_size = buf_size; + log->buf_size = buf_size; log->file_path = file_path; - log->file_pos = 0; + log->file_pos = 0; log->file_size = file_size; - log->file_num = file_num; - log->index = 0; + log->file_num = file_num; + log->index = 0; l_end: return rc; } -static void ps3_klog_exit(ps3_log_t *log) +static void ps3_klog_exit(struct ps3_log *log) { - if (log->buf) { + if (log->buf) vfree(log->buf); - } - if (log->file) { + if (log->file) ps3_file_close(&log->file); - } } static inline char *ps3_file_name_locale(char *file) { char *p_slash = strrchr(file, '/'); - return (p_slash == NULL)?file:(p_slash+1); + + return (p_slash == NULL) ? file : (p_slash + 1); } -void ps3_log_string( - debug_level_e level, - const char *file, - int line, - const char *fmt,...) +void ps3_log_string(enum debug_level level, const char *file, int line, + const char *fmt, ...) { - ps3_ctxt_t *ctxt = NULL; + struct ps3_ctxt *ctxt = NULL; char *buf = NULL; int len = 0; - ULong flags = 0; + unsigned long flags = 0; va_list args; - if (level > g_ps3_debug.level){ + if (level > g_ps3_debug.level) { #ifndef PS3_CFG_RELEASE - if (!ps3_filter_file_print(file)){ + if (!ps3_filter_file_print(file)) return; - } #else return; #endif } - if (!in_interrupt()){ + if (!in_interrupt()) local_irq_save(flags); - } ctxt = per_cpu_ptr(g_ps3_debug.ctxt, get_cpu()); put_cpu(); - buf = ctxt->buff; + buf = ctxt->buff; - len = snprintf(buf, PAGE_SIZE, "%s", ps3_debug_level_name(level)); - len += time_for_log(buf+len, PAGE_SIZE - len); - len += snprintf(buf+len, PAGE_SIZE - len, "[%d][%d]%s:%4d:", - raw_smp_processor_id(), current->pid, - ps3_file_name_locale((char*)file), line); + len = snprintf(buf, PAGE_SIZE, "%s", ps3_debug_level_name(level)); + len += time_for_log(buf + len, PAGE_SIZE - len); + len += snprintf(buf + len, PAGE_SIZE - len, + "[%d][%d]%s:%4d:", raw_smp_processor_id(), current->pid, + ps3_file_name_locale((char *)file), line); va_start(args, fmt); - len += vsnprintf( - buf + len, - PAGE_SIZE - len, - fmt, - args); + len += vsnprintf(buf + len, PAGE_SIZE - len, fmt, args); va_end(args); - - if (!in_interrupt()){ + if (!in_interrupt()) local_irq_restore(flags); - } if (ps3_log_tty_query()) { if (buf[0] == 'I' || buf[0] == 'W') { - printk_ratelimited(KERN_WARNING"%s", buf + LOG_INFO_PREFIX_LEN); + pr_warn_ratelimited("%s", + buf + LOG_INFO_PREFIX_LEN); } else if (buf[0] == 'E') { - printk_ratelimited(KERN_WARNING"%s", buf + LOG_ERROR_PREFIX_LEN); + pr_warn_ratelimited("%s", + buf + LOG_ERROR_PREFIX_LEN); } } ps3_klog_in(&g_ps3_debug.log[DEBUG_TYPE_STRING], buf, len); wake_up_process(g_ps3_debug.task); - - return; } -void ps3_log_binary( - const char *file, - int line, - char *ptr, - int size, - char *str) +void ps3_log_binary(const char *file, int line, char *ptr, int size, char *str) { -#define LINE_TOTAL 16 - ps3_ctxt_t *ctxt = NULL; +#define LINE_TOTAL 16 + struct ps3_ctxt *ctxt = NULL; char *buf = NULL; int len = 0; int i; - ULong flags = 0; + unsigned long flags = 0; - if (!in_interrupt()){ + if (!in_interrupt()) local_irq_save(flags); - } ctxt = per_cpu_ptr(g_ps3_debug.ctxt, get_cpu()); put_cpu(); - buf = ctxt->buff; + buf = ctxt->buff; - len += time_for_log(buf+len, PAGE_SIZE - len); - len += snprintf(buf+len, PAGE_SIZE - len, "[%d]%s:%d, size:%d, ", - current->pid, ps3_file_name_locale((char*)file), - line, size); + len += time_for_log(buf + len, PAGE_SIZE - len); + len += snprintf(buf + len, PAGE_SIZE - len, "[%d]%s:%d, size:%d, ", + current->pid, ps3_file_name_locale((char *)file), line, + size); - len+=snprintf(buf + len, PAGE_SIZE - len, "%s",str); + len += snprintf(buf + len, PAGE_SIZE - len, "%s", str); - for(i = 0; i < size; i++){ - if (i % LINE_TOTAL == 0){ + for (i = 0; i < size; i++) { + if (i % LINE_TOTAL == 0) len += snprintf(buf + len, PAGE_SIZE - len, "%08x ", i); - } len += snprintf(buf + len, PAGE_SIZE - len, "%02hhx", ptr[i]); - if ((i % LINE_TOTAL) == (LINE_TOTAL - 1) || i == (size - 1)){ + if ((i % LINE_TOTAL) == (LINE_TOTAL - 1) || i == (size - 1)) len += snprintf(buf + len, PAGE_SIZE - len, "\n"); - } else if ((i % LINE_TOTAL) == (LINE_TOTAL/2 - 1)){ + else if ((i % LINE_TOTAL) == (LINE_TOTAL / 2 - 1)) len += snprintf(buf + len, PAGE_SIZE - len, " "); - } else{ + else len += snprintf(buf + len, PAGE_SIZE - len, " "); - } } - if (!in_interrupt()){ + if (!in_interrupt()) local_irq_restore(flags); - } ps3_klog_in(&g_ps3_debug.log[DEBUG_TYPE_BINARY], buf, len); @@ -752,27 +707,27 @@ void ps3_log_sync(void) int ps3_debug_init(void) { struct task_struct *task = NULL; - ps3_ctxt_t *ctxt = NULL; + struct ps3_ctxt *ctxt = NULL; int rc = 0; int i; int nid; - U32 file_num = 0; - U32 log_path_len = 0; - U32 input_log_space = ps3_log_space_size_query(); - U32 input_log_file_size = ps3_log_file_size_query(); - unsigned int log_file_size = 0; - char *log_path_p = NULL; - ps3_log_t *log_bin = &g_ps3_debug.log[DEBUG_TYPE_BINARY]; - ps3_log_t *log_str = &g_ps3_debug.log[DEBUG_TYPE_STRING]; + unsigned int file_num = 0; + unsigned int log_path_len = 0; + unsigned int input_log_space = ps3_log_space_size_query(); + unsigned int input_log_file_size = ps3_log_file_size_query(); + unsigned int log_file_size = 0; + char *log_path_p = NULL; + struct ps3_log *log_bin = &g_ps3_debug.log[DEBUG_TYPE_BINARY]; + struct ps3_log *log_str = &g_ps3_debug.log[DEBUG_TYPE_STRING]; INIT_LIST_HEAD(&g_ps3_debug.filter_file); INIT_LIST_HEAD(&g_ps3_debug.filter_func); g_ps3_debug.level = ps3_log_level_query(); - g_ps3_debug.ctxt = alloc_percpu(ps3_ctxt_t); + g_ps3_debug.ctxt = alloc_percpu(struct ps3_ctxt); if (!g_ps3_debug.ctxt) { rc = -ENOMEM; - ps3_print(KERN_ERR,"alloc percpu failed\n"); + ps3_print(PRINT_ERR, "alloc percpu failed\n"); goto l_end; } @@ -783,33 +738,38 @@ int ps3_debug_init(void) for_each_possible_cpu(i) { ctxt = per_cpu_ptr(g_ps3_debug.ctxt, i); - nid = cpu_to_node(i); + nid = cpu_to_node(i); ctxt->page = alloc_pages_node(nid, GFP_ATOMIC, 0); if (!ctxt->page) { rc = -ENOMEM; - ps3_print(KERN_ERR,"kmalloc size %lu failed\n", PAGE_SIZE); + ps3_print(PRINT_ERR, "kmalloc size %lu failed\n", + PAGE_SIZE); goto l_free_cpu_buff; } - ctxt->buff = kmap(ctxt->page); + ctxt->buff = PS3_KMAP(ctxt->page); } log_path_p = ps3_log_path_query(); log_path_len = strlen(log_path_p); if (log_path_p != NULL && log_path_p[0] == '/') { if (log_path_p[log_path_len - 1] == '/') { - snprintf(g_log_path_str, LOG_PATH_LEN, "%s%s.", log_path_p, LOG_FILE_PREFIX); - snprintf(g_log_path_bin, LOG_PATH_LEN, "%s%s.", log_path_p, BINARY_FILE_PREFIX); + snprintf(g_log_path_str, LOG_PATH_LEN, "%s%s.", + log_path_p, LOG_FILE_PREFIX); + snprintf(g_log_path_bin, LOG_PATH_LEN, "%s%s.", + log_path_p, BINARY_FILE_PREFIX); } else { - snprintf(g_log_path_str, LOG_PATH_LEN, "%s/%s.", log_path_p, LOG_FILE_PREFIX); - snprintf(g_log_path_bin, LOG_PATH_LEN, "%s/%s.", log_path_p, BINARY_FILE_PREFIX); + snprintf(g_log_path_str, LOG_PATH_LEN, "%s/%s.", + log_path_p, LOG_FILE_PREFIX); + snprintf(g_log_path_bin, LOG_PATH_LEN, "%s/%s.", + log_path_p, BINARY_FILE_PREFIX); } } else { snprintf(g_log_path_str, LOG_PATH_LEN, "%s.", LOG_FILE_PATH); snprintf(g_log_path_bin, LOG_PATH_LEN, "%s.", BINARY_FILE_PATH); } if (input_log_file_size < DRV_LOG_FILE_SIZE_MIN_MB || - input_log_file_size > DRV_LOG_FILE_SIZE_MAX_MB) { + input_log_file_size > DRV_LOG_FILE_SIZE_MAX_MB) { ps3_log_file_size_modify(LOG_FILE_SIZE >> MEGABYTE); input_log_file_size = LOG_FILE_SIZE >> MEGABYTE; } @@ -822,44 +782,36 @@ int ps3_debug_init(void) if (input_log_space) { file_num = input_log_space / input_log_file_size; if (file_num == 0) { - ps3_print(KERN_ERR,"filenum shouldnot be 0\n"); + ps3_print(PRINT_ERR, "filenum shouldnot be 0\n"); PS3_BUG(); } } else { file_num = 0; } - rc = ps3_klog_init( - log_str, - LOG_BUF_SIZE, - g_log_path_str, - log_file_size, - file_num); - if (rc < 0) { + rc = ps3_klog_init(log_str, LOG_BUF_SIZE, g_log_path_str, log_file_size, + file_num); + if (rc < 0) goto l_free_cpu_buff; - } - rc = ps3_klog_init( - log_bin, - BIN_BUF_SIZE, - g_log_path_bin, - BINARY_FILE_SIZE, - 0); - if (rc < 0) { + rc = ps3_klog_init(log_bin, BIN_BUF_SIZE, g_log_path_bin, + BINARY_FILE_SIZE, 0); + if (rc < 0) goto l_free_string; - } task = kthread_create(ps3_klog_flush, NULL, "ps3_klog_flush"); if (IS_ERR(task)) { rc = (int)PTR_ERR(task); - ps3_print(KERN_ERR,"Create kernel thread, err: %d\n", rc); + ps3_print(PRINT_ERR, "Create kernel thread, err: %d\n", rc); goto l_free_binary; } wake_up_process(task); g_ps3_debug.task = task; rc = 0; - ps3_print(KERN_INFO,"PS3 debug init logpath[%s] strlogsize[%dM] filenum[%d]\n", - g_log_path_str, (log_file_size >> MEGABYTE), log_str->file_num); + ps3_print(PRINT_INFO, + "PS3 debug init logpath[%s] strlogsize[%dM] filenum[%d]\n", + g_log_path_str, (log_file_size >> MEGABYTE), + log_str->file_num); l_end: return rc; @@ -873,7 +825,7 @@ int ps3_debug_init(void) for_each_possible_cpu(i) { ctxt = per_cpu_ptr(g_ps3_debug.ctxt, i); if (ctxt && ctxt->page) { - kunmap(ctxt->page); + PS3_KUNMAP(ctxt->page, ctxt->buff); __free_page(ctxt->page); } } @@ -884,23 +836,21 @@ int ps3_debug_init(void) void ps3_debug_exit(void) { int i = 0; - ps3_ctxt_t *ctxt; + struct ps3_ctxt *ctxt; - if (g_ps3_debug.task == NULL) { + if (g_ps3_debug.task == NULL) return; - } kthread_stop(g_ps3_debug.task); - for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) { + for (i = 0; i < ARRAY_SIZE(g_ps3_debug.log); i++) ps3_klog_exit(&g_ps3_debug.log[i]); - } if (g_ps3_debug.ctxt) { for_each_possible_cpu(i) { ctxt = per_cpu_ptr(g_ps3_debug.ctxt, i); if (ctxt && ctxt->page) { - kunmap(ctxt->page); + PS3_KUNMAP(ctxt->page, ctxt->buff); __free_page(ctxt->page); } } @@ -927,105 +877,47 @@ void ps3_debug_exit(void) #endif -#if 0 - -struct task_struct *g_ps3_task[8]; -static int ps3_log_test(void *arg) -{ - int i = 0; - int dump[16] = {}; - while(!kthread_should_stop()){ - for(i = 0; i < 1024; i++) { - LOG_WARN("hello world,%d\n",i); - DATA_DUMP(dump, sizeof(dump), "123\n"); - } - schedule_timeout_interruptible(8*HZ); - } - return 0; -} - -static int __init ps3_init(void) -{ - int rc = 0; - int i = 0; - int dump[16] = {}; - rc = ps3_debug_init(); - if (rc < 0){ - return rc; - } - - for (i = 0; i < 8; i++){ - LOG_WARN("hello world,%d\n",i); - DATA_DUMP(dump, sizeof(dump), "123\n"); - } - - for (i = 0; i < 8; i++){ - g_ps3_task[i] = kthread_create(ps3_log_test, NULL, "ps3_log_test"); - wake_up_process(g_ps3_task[i]); - } - return 0; -} - -static void __exit ps3_exit(void) -{ - int i; - for (i = 0; i < 8; i++){ - kthread_stop(g_ps3_task[i]); - } - ps3_debug_exit(); -} - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("ps3@starsmicrosystem.com"); -MODULE_DESCRIPTION("Stars PS3 Driver"); - -module_init(ps3_init); -module_exit(ps3_exit); - -#endif - -#else +#else -S32 g_ps3_log_level = LEVEL_INFO; +int g_ps3_log_level = LEVEL_INFO; -void ps3_thread_key_create(int size, ps3_thread_key_t *key) +void ps3_thread_key_create(int size, struct ps3_thread_key *key) { - size = size; - key = key; + (void)size; + (void)key; } -void *ps3_thread_get_specific(ps3_thread_key_t *key) +void *ps3_thread_get_specific(struct ps3_thread_key *key) { - key = key; return key; } -void ps3_thread_clear_specific(ps3_thread_key_t *key) +void ps3_thread_clear_specific(struct ps3_thread_key *key) { - key = key; + (void)key; } -int ps3_filter_file_add(char *name) +int ps3_filter_file_add(char *name) { - name = name; + (void)name; return 0; } void ps3_filter_file_del(char *name) { - name = name; + (void)name; } void ps3_filter_file_clear(void) { } -int ps3_filter_func_add(char *name) +int ps3_filter_func_add(char *name) { - name = name; + (void)name; return 0; } void ps3_filter_func_del(char *name) { - name = name; + (void)name; } void ps3_filter_func_clear(void) { @@ -1035,7 +927,7 @@ void ps3_level_set(int level) g_ps3_log_level = level; } -S32 ps3_level_get(void) +int ps3_level_get(void) { return g_ps3_log_level; } @@ -1054,5 +946,15 @@ void ps3_debug_exit(void) { } -#endif +#endif +static int g_ramfs_test_enable; +int ps3_ramfs_test_query(void) +{ + return g_ramfs_test_enable; +} + +void ps3_ramfs_test_store(int val) +{ + g_ramfs_test_enable = val; +} diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h index c84ae2859750..5dd1b2405dc6 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_driver_log.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_DRIVER_LOG_H_ #define _PS3_DRIVER_LOG_H_ @@ -7,144 +8,183 @@ #include #include "ps3_htp_def.h" +#include "ps3_platform_utils.h" #ifdef __cplusplus -extern "C"{ +extern "C" { #endif -#define PS3_HOST(ins) (ins)->host->host_no +#define PS3_HOST(ins) ((ins)->host->host_no) #define DRIVER_DEBUG -#define LOG_INFO_PREFIX_LEN 32 -#define LOG_ERROR_PREFIX_LEN 33 -#define MEGABYTE 20 +#define LOG_INFO_PREFIX_LEN 32 +#define LOG_ERROR_PREFIX_LEN 33 +#define MEGABYTE 20 -typedef enum { +enum debug_level { LEVEL_ERROR, LEVEL_WARN, LEVEL_INFO, LEVEL_DEBUG, -}debug_level_e; +}; -static inline const S8 *ps3_debug_level_name(debug_level_e lv) +static inline const char *ps3_debug_level_name(enum debug_level lv) { - static const S8 *level[] = { + static const char * const level[] = { [LEVEL_ERROR] = "ERROR", - [LEVEL_WARN] = "WARN", - [LEVEL_INFO] = "INFO", + [LEVEL_WARN] = "WARN", + [LEVEL_INFO] = "INFO", [LEVEL_DEBUG] = "DBG", }; return level[lv]; } -S32 ps3_level_get(void); +int ps3_level_get(void); #define PS3_LOG_LIMIT_INTERVAL_MSEC (24 * 60 * 60 * 1000) #ifdef __KERNEL__ -#define PRINT_DEBUG KERN_DEBUG -#define PRINT_INFO KERN_INFO -#define PRINT_WARN KERN_WARNING -#define PRINT_ERR KERN_ERR - -#define ps3_print(level,fmt,...) \ - printk(level"[PS3STOR]%s():%d;" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__) - -#define ps3_printk(level,fmt,...) do { \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_DEBUG) { \ - printk(KERN_DEBUG "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_INFO) { \ - printk(KERN_INFO "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - printk(KERN_WARNING "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - }else if (level == LEVEL_ERROR) { \ - printk(KERN_ERR "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } \ - } \ -} while(0) - -#define ps3_printk_ratelimited(level,fmt,...) do { \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_INFO) { \ - pr_info_ratelimited(KERN_INFO "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - printk_ratelimited(KERN_WARNING "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - }else if (level == LEVEL_ERROR) { \ - printk_ratelimited(KERN_ERR "[PS3STOR][%u]%d;" fmt, \ - current->pid, __LINE__, ##__VA_ARGS__); \ - } \ - } \ -} while(0) +#define PRINT_DEBUG LEVEL_DEBUG +#define PRINT_INFO LEVEL_INFO +#define PRINT_WARN LEVEL_WARN +#define PRINT_ERR LEVEL_ERROR + +#define ps3_print(level, fmt, ...) \ + do { \ + if (level == LEVEL_DEBUG) { \ + pr_debug("[PS3STOR]%s():%d;" fmt, \ + __func__, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_INFO) { \ + pr_info("[PS3STOR]%s():%d;" fmt, \ + __func__, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + pr_warn("[PS3STOR]%s():%d;" fmt, \ + __func__, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_ERROR) { \ + pr_err("[PS3STOR]%s():%d;" fmt, \ + __func__, __LINE__, ##__VA_ARGS__); \ + } \ + } while (0) + +#define ps3_printk(level, fmt, ...) \ + do { \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_DEBUG) { \ + pr_debug("[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_INFO) { \ + pr_info("[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + pr_warn("[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } else if (level == LEVEL_ERROR) { \ + pr_err("[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, ##__VA_ARGS__); \ + } \ + } \ + } while (0) + +#define ps3_printk_ratelimited(level, fmt, ...) \ + do { \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_INFO) { \ + pr_info_ratelimited( \ + "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, \ + ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + pr_warn_ratelimited( \ + "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, \ + ##__VA_ARGS__); \ + } else if (level == LEVEL_ERROR) { \ + pr_err_ratelimited( \ + "[PS3STOR][%u]%d;" fmt, \ + current->pid, __LINE__, \ + ##__VA_ARGS__); \ + } \ + } \ + } while (0) #else -#define PRINT_DEBUG LEVEL_DEBUG -#define PRINT_INFO LEVEL_INFO -#define PRINT_WARN LEVEL_WARN -#define PRINT_ERR LEVEL_ERROR +#define PRINT_DEBUG LEVEL_DEBUG +#define PRINT_INFO LEVEL_INFO +#define PRINT_WARN LEVEL_WARN +#define PRINT_ERR LEVEL_ERROR #include #include #include #define __percpu -static inline U64 get_now_ms() { +static inline unsigned long long get_now_ms(void) +{ struct timeval tv; - U64 timestamp = 0; + unsigned long long timestamp = 0; + gettimeofday(&tv, NULL); - timestamp = tv.tv_sec * 1000 + tv.tv_usec/1000; + timestamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; return timestamp; } -#define filename_printf(x) strrchr((x),'/')?strrchr((x),'/')+1:(x) - -#define ps3_print(lock_chk,level,fmt,...) do { \ - if (level != LEVEL_DEBUG && lock_chk) { \ - EXPECT_EQ(ps3_get_irq_spin_lock_count(), 0); \ - } \ - if (level <= ps3_level_get()) { \ - if (level == LEVEL_DEBUG) { \ - printf("DEBUG:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ - __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ - } else if (level == LEVEL_INFO) { \ - printf("INFO:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ - __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ - } else if (level == LEVEL_WARN) { \ - printf("WARN:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ - __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ - }else if (level == LEVEL_ERROR) { \ - printf("ERROR:%llu:%s:%s():%d:[%lu];" fmt, get_now_ms(), filename_printf(__FILE__), \ - __FUNCTION__, __LINE__, pthread_self(), ##__VA_ARGS__); \ - } \ - } \ -} while(0) +#define filename_printf(x) (strrchr((x), '/') ? strrchr((x), '/') + 1 : (x)) + +#define ps3_print(lock_chk, level, fmt, ...) \ + do { \ + if (level != LEVEL_DEBUG && lock_chk) { \ + EXPECT_EQ(ps3_get_irq_spin_lock_count(), 0); \ + } \ + if (level <= ps3_level_get()) { \ + if (level == LEVEL_DEBUG) { \ + printf("DEBUG:%llu:%s:%s():%d:[%lu];" fmt, \ + get_now_ms(), \ + filename_printf(__FILE__), \ + __func__, __LINE__, pthread_self(), \ + ##__VA_ARGS__); \ + } else if (level == LEVEL_INFO) { \ + printf("INFO:%llu:%s:%s():%d:[%lu];" fmt, \ + get_now_ms(), \ + filename_printf(__FILE__), \ + __func__, __LINE__, pthread_self(), \ + ##__VA_ARGS__); \ + } else if (level == LEVEL_WARN) { \ + printf("WARN:%llu:%s:%s():%d:[%lu];" fmt, \ + get_now_ms(), \ + filename_printf(__FILE__), \ + __func__, __LINE__, pthread_self(), \ + ##__VA_ARGS__); \ + } else if (level == LEVEL_ERROR) { \ + printf("ERROR:%llu:%s:%s():%d:[%lu];" fmt, \ + get_now_ms(), \ + filename_printf(__FILE__), \ + __func__, __LINE__, pthread_self(), \ + ##__VA_ARGS__); \ + } \ + } \ + } while (0) #endif -#define LOG_BUG_ON(cond, fmt, ...) do { \ - if((cond)) { \ - LOG_ERROR(fmt, ##__VA_ARGS__); \ - LOG_SYNC(); \ - BUG(); \ - } \ -}while(0) +#define LOG_BUG_ON(cond, fmt, ...) \ + do { \ + if ((cond)) { \ + LOG_ERROR(fmt, ##__VA_ARGS__); \ + LOG_SYNC(); \ + BUG(); \ + } \ + } while (0) #define DEBUG_TRACE_MAGIC 0x456789 -#define LOG_BUF_SIZE (1024LL << 11) -#define BIN_BUF_SIZE (1024LL << 10) +#define LOG_BUF_SIZE (1024LL << 11) +#define BIN_BUF_SIZE (1024LL << 10) -#define LOG_FILE_SIZE (200LL << 20) -#define LOG_FILE_PATH "/var/log/ps3sas_drv.log" -#define LOG_FILE_PREFIX "ps3sas_drv.log" +#define LOG_FILE_SIZE (200LL << 20) +#define LOG_FILE_PATH "/var/log/ps3sas_drv.log" +#define LOG_FILE_PREFIX "ps3sas_drv.log" #define BINARY_FILE_PREFIX "ps3sas_drv.bin" -#define BINARY_FILE_SIZE (200LL << 20) +#define BINARY_FILE_SIZE (200LL << 20) #define BINARY_FILE_PATH "/var/log/ps3sas_drv.bin" #define DEBUG_DROP_LOG_STRING "\nwarnning:drop some logs\n\n" @@ -155,198 +195,213 @@ enum { DEBUG_TYPE_NR, }; -typedef struct { +struct debug_func { struct list_head list; char name[64]; -} debug_func_t; +}; -typedef struct { +struct debug_file { struct list_head list; char name[64]; -} debug_file_t; +}; -typedef struct { +struct ps3_log { struct { - char *buf; - int buf_size; - long long head; - long long tail; + char *buf; + int buf_size; + long long head; + long long tail; spinlock_t lock; - unsigned char is_drop; + unsigned char is_drop; }; struct { - char *file_path; - struct file *file; - long long file_pos; - long long file_size; - U32 file_num; - U32 index; + char *file_path; + struct file *file; + long long file_pos; + long long file_size; + unsigned int file_num; + unsigned int index; }; -} ps3_log_t; +}; -typedef struct { - S32 magic; +struct ps3_thread_local { + int magic; char data[0]; -} ps3_thread_local_t; +}; -typedef struct { +struct ps3_ctxt { struct page *page; - void *buff; -} ps3_ctxt_t; - -typedef struct { - S32 offset; -} ps3_thread_key_t; - -typedef struct { - debug_level_e level; - U16 key_offset; - ps3_ctxt_t __percpu *ctxt; - struct list_head filter_func; - struct list_head filter_file; - struct task_struct *task; - ps3_log_t log[DEBUG_TYPE_NR]; -} ps3_debug_t; - -void ps3_thread_key_create(int size, ps3_thread_key_t *key); -void *ps3_thread_get_specific(ps3_thread_key_t *key); -void ps3_thread_clear_specific(ps3_thread_key_t *key); - -int ps3_filter_file_add(char *name); + void *buff; +}; + +struct ps3_thread_key { + int offset; +}; + +struct ps3_debug { + enum debug_level level; + unsigned short key_offset; + struct ps3_ctxt __percpu *ctxt; + struct list_head filter_func; + struct list_head filter_file; + struct task_struct *task; + struct ps3_log log[DEBUG_TYPE_NR]; +}; + +void ps3_thread_key_create(int size, struct ps3_thread_key *key); +void *ps3_thread_get_specific(struct ps3_thread_key *key); +void ps3_thread_clear_specific(struct ps3_thread_key *key); + +int ps3_filter_file_add(char *name); void ps3_filter_file_del(char *name); void ps3_filter_file_clear(void); -int ps3_filter_func_add(char *name); +int ps3_filter_func_add(char *name); void ps3_filter_func_del(char *name); void ps3_filter_func_clear(void); void ps3_level_set(int level); -S32 ps3_level_get(void); +int ps3_level_get(void); -int ps3_debug_init(void); +int ps3_debug_init(void); void ps3_debug_exit(void); -void ps3_log_string(debug_level_e level, const char *file, - int line, const char *fmt, ...); +void ps3_log_string(enum debug_level level, const char *file, int line, + const char *fmt, ...); -void ps3_log_binary(const char *file, int line, char *ptr, - S32 size, char *str); +void ps3_log_binary(const char *file, int line, char *ptr, int size, char *str); void ps3_log_sync(void); -extern S32 g_ramfs_test_enable; -static inline S32 ps3_ramfs_test_query(void) -{ - return g_ramfs_test_enable; -} - -static inline void ps3_ramfs_test_store(S32 val) -{ - g_ramfs_test_enable = val; -} +int ps3_ramfs_test_query(void); +void ps3_ramfs_test_store(int val); #if defined DRIVER_DEBUG && defined __KERNEL__ -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -#define WRITE_LOG(level, fmt, ...) \ +#define WRITE_LOG(level, fmt, ...) \ ps3_log_string(level, __FILE__, __LINE__, fmt, ##__VA_ARGS__) #define LOG_DEBUG(fmt, ...) WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG2_DEBUG(fmt, ...) WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG2_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG2_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) +#define LOG2_DEBUG(fmt, ...) \ + do { \ + WRITE_LOG(LEVEL_DEBUG, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG2_INFO(fmt, ...) \ + do { \ + WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG2_WARN(fmt, ...) \ + do { \ + WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG2_ERROR(fmt, ...) \ + do { \ + WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__); \ + } while (0) #define LOG_LEVEL(log_lvl, fmt, ...) WRITE_LOG(log_lvl, fmt, ##__VA_ARGS__) -#define LOG_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ -}while(0) - -#define LOG2_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } while (0) + +#define LOG2_INFO_LIM(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) #define LOG2_ERROR_LIM(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_FILE_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_FILE_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_FILE_ERROR(fmt, ...)WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) +#define LOG_FILE_INFO(fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_FILE_WARN(fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_FILE_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) #define LOG_SPC_ERROR(fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) -#define LOG_INFO_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_SYNC() ps3_log_sync() -#define DATA_DUMP(ptr, size, str) \ - ps3_log_binary(__FILE__, __LINE__, (char*)ptr, size, str) +#define LOG_INFO_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_IN_IRQ(ins, fmt, ...) WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ + WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + WRITE_LOG(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + WRITE_LOG(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + WRITE_LOG(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_SYNC() ps3_log_sync() +#define DATA_DUMP(ptr, size, str) \ + ps3_log_binary(__FILE__, __LINE__, (char *)ptr, size, str) #else -#define LOG_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__); -#define LOG_INFO(fmt, ...) ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); -#define LOG_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); -#define LOG_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); - -#define LOG2_DEBUG(fmt, ...) ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__); -#define LOG2_INFO(fmt, ...) ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__); -#define LOG2_WARN(fmt, ...) ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__); -#define LOG2_ERROR(fmt, ...) ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__); - -#define LOG_INFO_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_INFO, fmt, ##__VA_ARGS__); -#define LOG_WARN_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_WARN, fmt, ##__VA_ARGS__); -#define LOG_ERROR_LIM(fmt, ...) ps3_printk_ratelimited(LEVEL_ERROR, fmt, ##__VA_ARGS__); - -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } \ -}while(0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } \ -}while(0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - if (printk_timed_ratelimit(caller_jiffies, time)) { \ - ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } \ -}while(0) - -#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) -#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) - -#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) +#define LOG_DEBUG(fmt, ...) ps3_printk(LEVEL_DEBUG, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR(fmt, ...) ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG2_DEBUG(fmt, ...) ps3_print(PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG2_INFO(fmt, ...) ps3_print(PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN(fmt, ...) ps3_print(PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG2_ERROR(fmt, ...) ps3_print(PRINT_ERR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_LIM(fmt, ...) \ + ps3_printk_ratelimited(LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM(fmt, ...) \ + ps3_printk_ratelimited(LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_LIM(fmt, ...) \ + ps3_printk_ratelimited(LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } \ + } while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } \ + } while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + if (printk_timed_ratelimit(caller_jiffies, time)) { \ + ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) +#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) +#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) #define LOG_FILE_INFO(fmt, ...) #define LOG_FILE_WARN(fmt, ...) @@ -354,141 +409,158 @@ static inline void ps3_ramfs_test_store(S32 val) #define LOG_LEVEL(log_lvl, fmt, ...) ps3_printk(log_lvl, fmt, ##__VA_ARGS__) -#define LOG_INFO_IN_IRQ(ins, fmt, ...) do { \ - if((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ - } \ -}while(0) - -#define LOG_WARN_IN_IRQ(ins, fmt, ...) do { \ - if((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ - } \ -}while(0) - -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) do { \ - if((ins)->is_irq_prk_support) { \ - ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ - } \ -}while(0) - -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - if (need_prk_err) { \ - LOG_INFO_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_INFO_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ -} while(0) - -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - if (need_prk_err) { \ - LOG_WARN_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_WARN_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ -} while(0) - -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - if (need_prk_err) { \ - LOG_ERROR_LIM(fmt, ##__VA_ARGS__); \ - } else { \ - LOG_ERROR_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ - } \ -} while(0) +#define LOG_INFO_IN_IRQ(ins, fmt, ...) \ + do { \ + if ((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define LOG_WARN_IN_IRQ(ins, fmt, ...) \ + do { \ + if ((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ + do { \ + if ((ins)->is_irq_prk_support) { \ + ps3_printk(LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } \ + } while (0) +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + if (need_prk_err) { \ + LOG_INFO_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_INFO_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + if (need_prk_err) { \ + LOG_WARN_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_WARN_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + if (need_prk_err) { \ + LOG_ERROR_LIM(fmt, ##__VA_ARGS__); \ + } else { \ + LOG_ERROR_IN_IRQ((ins), fmt, ##__VA_ARGS__); \ + } \ + } while (0) #define LOG_SYNC() #define DATA_DUMP(ptr, size, str) #endif -static inline Bool ps3_fs_requires_dev(struct file *fp) +static inline unsigned char ps3_fs_requires_dev(struct file *fp) { - if (ps3_ramfs_test_query()) { + if (ps3_ramfs_test_query()) return PS3_FALSE; - } return (fp->f_inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV); } -#else - -#define LOG_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) - -#define LOG2_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) -#define LOG2_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) -#define LOG2_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) -#define LOG2_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) - -#define LOG_LEVEL(log_lvl, fmt, ...) ps3_print(PS3_TRUE, log_lvl, fmt, ##__VA_ARGS__) - -#define LOG_INFO_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__) -#define LOG_WARN_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__) -#define LOG_ERROR_LIM(fmt, ...) ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__) - -#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) do { \ - (void)caller_jiffies; \ - (void)time; \ - ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ -}while(0) - -#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) -#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) -#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) +#else + +#define LOG_DEBUG(fmt, ...) ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) + +#define LOG2_DEBUG(fmt, ...) \ + ps3_print(PS3_TRUE, PRINT_DEBUG, fmt, ##__VA_ARGS__) +#define LOG2_INFO(fmt, ...) ps3_print(PS3_TRUE, PRINT_INFO, fmt, ##__VA_ARGS__) +#define LOG2_WARN(fmt, ...) ps3_print(PS3_TRUE, PRINT_WARN, fmt, ##__VA_ARGS__) +#define LOG2_ERROR(fmt, ...) ps3_print(PS3_TRUE, PRINT_ERR, fmt, ##__VA_ARGS__) + +#define LOG_LEVEL(log_lvl, fmt, ...) \ + ps3_print(PS3_TRUE, log_lvl, fmt, ##__VA_ARGS__) + +#define LOG_INFO_LIM(fmt, ...) \ + ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__) +#define LOG_WARN_LIM(fmt, ...) \ + ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__) +#define LOG_ERROR_LIM(fmt, ...) \ + ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__) + +#define LOG_INFO_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_WARN_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_ERROR_TIME_LIM(caller_jiffies, time, fmt, ...) \ + do { \ + (void)caller_jiffies; \ + (void)time; \ + ps3_print(PS3_TRUE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } while (0) + +#define LOG2_INFO_LIM(fmt, ...) LOG_INFO_LIM(fmt, ##__VA_ARGS__) +#define LOG2_WARN_LIM(fmt, ...) LOG_WARN_LIM(fmt, ##__VA_ARGS__) +#define LOG2_ERROR_LIM(fmt, ...) LOG_ERROR_LIM(fmt, ##__VA_ARGS__) #define LOG_FILE_INFO(fmt, ...) #define LOG_FILE_WARN(fmt, ...) #define LOG_FILE_ERROR(fmt, ...) -#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) - -#define LOG_INFO_IN_IRQ(ins, fmt, ...) do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_WARN_IN_IRQ(ins, fmt, ...) do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ -}while(0) -#define LOG_ERROR_IN_IRQ(ins, fmt, ...) do { \ - (void)ins; \ - ps3_print(PS3_FALSE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ -}while(0) - -#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_INFO, fmt, ##__VA_ARGS__); \ -} while(0) - -#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_WARN, fmt, ##__VA_ARGS__); \ -} while(0) - -#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) do { \ - (void)ins; \ - ps3_print((need_prk_err), LEVEL_ERROR, fmt, ##__VA_ARGS__); \ -} while(0) +#define LOG_SPC_ERROR(fmt, ...) LOG_INFO(fmt, ##__VA_ARGS__) + +#define LOG_INFO_IN_IRQ(ins, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_WARN_IN_IRQ(ins, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_ERROR_IN_IRQ(ins, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print(PS3_FALSE, LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } while (0) +#define LOG_INFO_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_INFO, fmt, ##__VA_ARGS__); \ + } while (0) + +#define LOG_WARN_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_WARN, fmt, ##__VA_ARGS__); \ + } while (0) + +#define LOG_ERROR_LIM_WITH_CHECK(ins, need_prk_err, fmt, ...) \ + do { \ + (void)ins; \ + ps3_print((need_prk_err), LEVEL_ERROR, fmt, ##__VA_ARGS__); \ + } while (0) #define LOG_SYNC() #define DATA_DUMP(ptr, size, str) -static inline Bool ps3_fs_requires_dev(struct file *fp) +static inline unsigned char ps3_fs_requires_dev(struct file *fp) { (void)fp; return PS3_TRUE; } -#endif +#endif #ifdef PS3_CFG_RELEASE @@ -497,69 +569,87 @@ static inline Bool ps3_fs_requires_dev(struct file *fp) #if defined(PS3_CFG_OCM_DBGBUG) || defined(PS3_CFG_OCM_RELEASE) -#define PS3_BUG_ON(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ - } \ -}while(0) - -#define PS3_BUG_ON_NO_SYNC(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ - } \ -}while(0) +#define PS3_BUG_ON(cond) \ + do { \ + if ((cond)) { \ + pr_err("BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + LOG_ERROR( \ + "BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + } \ + } while (0) + +#define PS3_BUG_ON_NO_SYNC(cond) \ + do { \ + if ((cond)) { \ + pr_err("BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + LOG_ERROR( \ + "BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + } \ + } while (0) #else -#define PS3_BUG_ON(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - } \ - }while(0) - -#define PS3_BUG_ON_NO_SYNC(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - } \ - }while(0) +#define PS3_BUG_ON(cond) \ + do { \ + if ((cond)) { \ + pr_err("BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + } \ + } while (0) + +#define PS3_BUG_ON_NO_SYNC(cond) \ + do { \ + if ((cond)) { \ + pr_err("BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + } \ + } while (0) #endif #else -#define PS3_BUG_ON(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ - LOG_SYNC(); \ - } \ - BUG_ON(cond); \ -}while(0) - -#define PS3_BUG(void) do { \ - LOG_SYNC(); \ - BUG(void); \ -}while(0) - -#define PS3_BUG_ON_NO_SYNC(cond) do { \ - if((cond)) { \ - printk(KERN_ERR "BUG_ON's condition(%s) has been triggered\n", #cond); \ - LOG_ERROR("BUG_ON's condition(%s) has been triggered\n", #cond); \ - } \ - BUG_ON(cond); \ -}while(0) - -#define PS3_BUG_NO_SYNC(void) do { \ - BUG(void); \ -}while(0) +#define PS3_BUG_ON(cond) \ + do { \ + if ((cond)) { \ + pr_err("BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + LOG_ERROR( \ + "BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + LOG_SYNC(); \ + } \ + BUG_ON(cond); \ + } while (0) + +#define PS3_BUG(void) \ + do { \ + LOG_SYNC(); \ + BUG(void); \ + } while (0) + +#define PS3_BUG_ON_NO_SYNC(cond) \ + do { \ + if ((cond)) { \ + pr_err( \ + "BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + LOG_ERROR( \ + "BUG_ON's condition(%s) has been triggered\n", \ + #cond); \ + } \ + BUG_ON(cond); \ + } while (0) + +#define PS3_BUG_NO_SYNC(void) BUG(void) #endif -#define PS3_WARN_ON(cond) do { \ - WARN_ON(cond); \ -}while(0) +#define PS3_WARN_ON(cond) WARN_ON(cond) #ifdef __cplusplus } #endif -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c index d6cda7b3f897..e8690443b799 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_dump.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -6,7 +7,9 @@ #include #include #include +#ifdef PS3_UT #include +#endif #include "ps3_dump.h" #include "ps3_mgr_cmd.h" @@ -18,25 +21,26 @@ #include "ps3_cli.h" #include "ps3_module_para.h" #include "ps3_err_inject.h" +#include "ps3_kernel_version.h" static inline void ps3_dump_status_set(struct ps3_instance *instance, - U64 value); + unsigned long long value); -S32 ps3_dump_local_time(struct rtc_time *tm) +static int ps3_dump_local_time(struct rtc_time *tm) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#if defined(PS3_DUMP_TIME_32) struct timeval time; - U64 local_time; + unsigned long long local_time; do_gettimeofday(&time); - local_time = (U64)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + local_time = (unsigned long long)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time_to_tm(local_time, tm); #else struct timespec64 time; - U64 local_time; + unsigned long long local_time; ktime_get_real_ts64(&time); - local_time = (U64)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); + local_time = (unsigned long long)(time.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time64_to_tm(local_time, tm); #endif tm->tm_mon += 1; @@ -44,36 +48,40 @@ S32 ps3_dump_local_time(struct rtc_time *tm) return 0; } -S32 ps3_dump_filename_build(struct ps3_instance *instance, - char *filename, U32 len, U8 *prefix) +static int ps3_dump_filename_build(struct ps3_instance *instance, char *filename, + unsigned int len, unsigned char *prefix) { struct ps3_dump_context *ctxt = &instance->dump_context; struct rtc_time tm; char *p_str = filename; - if (filename == NULL || prefix == NULL) { + if (filename == NULL || prefix == NULL) return -1; - } ps3_dump_local_time(&tm); - p_str += snprintf(p_str, len - (p_str - filename), "%s", ctxt->dump_dir); - p_str += snprintf(p_str, len - (p_str - filename), (const char*)prefix); - p_str += snprintf(p_str, len - (p_str - filename), "host%d-", instance->host->host_no); - p_str += snprintf(p_str, len - (p_str - filename), "%04d%02d%02d-%02d%02d%02d-", - tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); - p_str += snprintf(p_str, len - (p_str - filename), "%llu", instance->ioc_fw_version); + p_str += + snprintf(p_str, len - (p_str - filename), "%s", ctxt->dump_dir); + p_str += + snprintf(p_str, len - (p_str - filename), (const char *)prefix); + p_str += snprintf(p_str, len - (p_str - filename), "host%d-", + instance->host->host_no); + p_str += snprintf(p_str, len - (p_str - filename), + "%04d%02d%02d-%02d%02d%02d-", tm.tm_year, tm.tm_mon, + tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); + p_str += snprintf(p_str, len - (p_str - filename), "%llu", + instance->ioc_fw_version); return 0; } -S32 ps3_dump_file_open(struct ps3_dump_context *ctxt, U32 dump_type) +static int ps3_dump_file_open(struct ps3_dump_context *ctxt, unsigned int dump_type) { struct ps3_dump_file_info *file_info = &ctxt->dump_out_file; - U8 filename[PS3_DUMP_FILE_NAME_LEN] = {0}; - U8 *p_prefix = NULL; - S32 ret = PS3_SUCCESS; + unsigned char filename[PS3_DUMP_FILE_NAME_LEN] = { 0 }; + unsigned char *p_prefix = NULL; + int ret = PS3_SUCCESS; struct file *fp = NULL; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) +#if defined(PS3_SUPPORT_FS) mm_segment_t old_fs; #endif @@ -85,15 +93,15 @@ S32 ps3_dump_file_open(struct ps3_dump_context *ctxt, U32 dump_type) memset(file_info, 0, sizeof(struct ps3_dump_file_info)); - switch (dump_type){ + switch (dump_type) { case PS3_DUMP_TYPE_FW_LOG: - p_prefix = (U8*)PS3_DUMP_FILE_FWLOG_PREFIX; + p_prefix = (unsigned char *)PS3_DUMP_FILE_FWLOG_PREFIX; break; case PS3_DUMP_TYPE_BAR_DATA: - p_prefix = (U8*)PS3_DUMP_FILE_BAR_PREFIX; + p_prefix = (unsigned char *)PS3_DUMP_FILE_BAR_PREFIX; break; case PS3_DUMP_TYPE_CRASH: - p_prefix = (U8*)PS3_DUMP_FILE_CORE_PREFIX; + p_prefix = (unsigned char *)PS3_DUMP_FILE_CORE_PREFIX; break; default: LOG_INFO("dump file create: unknown dump type %d\n", dump_type); @@ -101,34 +109,37 @@ S32 ps3_dump_file_open(struct ps3_dump_context *ctxt, U32 dump_type) goto l_out; } - if (ps3_dump_filename_build(ctxt->instance, (char*)filename, - PS3_DUMP_FILE_NAME_LEN, p_prefix) != 0) { + if (ps3_dump_filename_build(ctxt->instance, (char *)filename, + PS3_DUMP_FILE_NAME_LEN, p_prefix) != 0) { LOG_INFO("dump file create: filename build NOK\n"); ret = -PS3_FAILED; goto l_out; } - fp = (struct file*)filp_open((char*)filename, O_CREAT |O_RDWR | O_TRUNC | O_LARGEFILE, 0); + fp = (struct file *)filp_open( + (char *)filename, O_CREAT | O_RDWR | O_TRUNC | O_LARGEFILE, 0); if (IS_ERR(fp)) { - LOG_INFO("dump file create: filp_open error filename %s errno %d\n", filename, (int)PTR_ERR(fp)); + LOG_INFO( + "dump file create: filp_open error filename %s errno %d\n", + filename, (int)PTR_ERR(fp)); ret = -PS3_FAILED; goto l_out; } if (!ps3_fs_requires_dev(fp)) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) +#if defined(PS3_KERNEL_WRITE_GET_DS) old_fs = get_fs(); - set_fs(get_ds() ); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) + set_fs(get_ds()); +#elif defined(PS3_KERNEL_WRITE) old_fs = get_fs(); - set_fs( KERNEL_DS ); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) + set_fs(KERNEL_DS); +#elif defined(PS3_VFS_WRITE) #else old_fs = force_uaccess_begin(); #endif filp_close(fp, NULL); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#if defined(PS3_SET_FS) set_fs(old_fs); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#elif defined(PS3_FORCE_UACCESS) #else force_uaccess_end(old_fs); #endif @@ -146,69 +157,69 @@ S32 ps3_dump_file_open(struct ps3_dump_context *ctxt, U32 dump_type) return ret; } -S32 ps3_dump_file_write(struct ps3_dump_file_info *file_info, U8 *buf, U32 len) +static int ps3_dump_file_write(struct ps3_dump_file_info *file_info, + unsigned char *buf, unsigned int len) { struct file *fp = NULL; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) +#if defined(PS3_SUPPORT_FS) mm_segment_t old_fs; #endif - S32 ret = 0; + int ret = 0; if (file_info && file_info->fp) { fp = file_info->fp; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) +#if defined(PS3_KERNEL_WRITE_GET_DS) old_fs = get_fs(); - set_fs(get_ds() ); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) + set_fs(get_ds()); +#elif defined(PS3_KERNEL_WRITE) old_fs = get_fs(); - set_fs( KERNEL_DS ); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) + set_fs(KERNEL_DS); +#elif defined(PS3_VFS_WRITE) #else old_fs = force_uaccess_begin(); #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) - ret = kernel_write(fp, (char*)buf, len, &fp->f_pos); +#if defined(PS3_KERNEL_WRITE_FILE) + ret = kernel_write(fp, (char *)buf, len, &fp->f_pos); #else - ret = vfs_write(fp, (char*)buf, len, &fp->f_pos); + ret = vfs_write(fp, (char *)buf, len, &fp->f_pos); #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#if defined(PS3_SET_FS) set_fs(old_fs); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#elif defined(PS3_FORCE_UACCESS) #else force_uaccess_end(old_fs); #endif - if (ret > 0) { + if (ret > 0) file_info->file_size += len; - } file_info->file_w_cnt++; } return ret; } -S32 ps3_dump_file_close(struct ps3_dump_file_info *file_info) +static int ps3_dump_file_close(struct ps3_dump_file_info *file_info) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) +#if defined(PS3_SUPPORT_FS) mm_segment_t old_fs; #endif if (file_info && file_info->fp) { PS3_BUG_ON(IS_ERR(file_info->fp)); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) +#if defined(PS3_KERNEL_WRITE_GET_DS) old_fs = get_fs(); set_fs(get_ds()); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#elif defined(PS3_KERNEL_WRITE) old_fs = get_fs(); - set_fs( KERNEL_DS ); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) + set_fs(KERNEL_DS); +#elif defined(PS3_VFS_WRITE) #else old_fs = force_uaccess_begin(); #endif filp_close(file_info->fp, NULL); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) +#if defined(PS3_SET_FS) set_fs(old_fs); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#elif defined(PS3_FORCE_UACCESS) #else force_uaccess_end(old_fs); #endif @@ -219,22 +230,25 @@ S32 ps3_dump_file_close(struct ps3_dump_file_info *file_info) return 0; } -struct ps3_dump_context * dev_to_dump_context(struct device *cdev) +struct ps3_dump_context *dev_to_dump_context(struct device *cdev) { struct Scsi_Host *shost = class_to_shost(cdev); - struct ps3_instance *instance = - (struct ps3_instance *) shost->hostdata; + struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; + return &instance->dump_context; } -static inline Bool ps3_dump_ctrl_get(struct ps3_instance *instance, U64 *dump_ctrl) +static inline unsigned char ps3_dump_ctrl_get(struct ps3_instance *instance, + unsigned long long *dump_ctrl) { - Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, *dump_ctrl); + unsigned char ret = PS3_TRUE; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpCtrl, + *dump_ctrl); INJECT_START(PS3_ERR_IJ_DUMP_CTRL_ERR, dump_ctrl); if (*dump_ctrl == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } @@ -244,20 +258,19 @@ static inline Bool ps3_dump_ctrl_get(struct ps3_instance *instance, U64 *dump_ct return ret; } -static inline void ps3_dump_ctrl_set(struct ps3_instance *instance, - U64 value) +static inline void ps3_dump_ctrl_set(struct ps3_instance *instance, unsigned long long value) { PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, value); } static inline void ps3_dump_abort(struct ps3_instance *instance) { - struct ps3_dump_context * ctxt = &instance->dump_context; - U64 dump_ctrl; - Bool ret = PS3_TRUE; + struct ps3_dump_context *ctxt = &instance->dump_context; + unsigned long long dump_ctrl; + unsigned char ret = PS3_TRUE; if (ctxt->dump_state == PS3_DUMP_STATE_ABORTED || - ctxt->dump_state == PS3_DUMP_STATE_INVALID ) { + ctxt->dump_state == PS3_DUMP_STATE_INVALID) { goto l_ret; } @@ -265,12 +278,12 @@ static inline void ps3_dump_abort(struct ps3_instance *instance) INJECT_START(PS3_ERR_IJ_DUMP_ABORT_GET_CTRL_FAIL, &ret); if (ret) { if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + LOG_WARN("dump ctrl is not cleared 0x%llx\n", + dump_ctrl); } ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_ABORT); } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); } ctxt->dump_state = PS3_DUMP_STATE_ABORTED; l_ret: @@ -279,31 +292,28 @@ static inline void ps3_dump_abort(struct ps3_instance *instance) static inline void ps3_dump_end(struct ps3_instance *instance) { - U64 dump_ctrl; - Bool ret = PS3_TRUE; + unsigned long long dump_ctrl; + unsigned char ret = PS3_TRUE; ret = ps3_dump_ctrl_get(instance, &dump_ctrl); INJECT_START(PS3_ERR_IJ_DUMP_END_GET_CTRL_FAIL, &ret); if (ret) { if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + LOG_WARN("dump ctrl is not cleared 0x%llx\n", + dump_ctrl); } ps3_dump_ctrl_set(instance, PS3_DUMP_CTRL_DUMP_END); } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); } - - return; } -static inline S32 ps3_dump_trigger(struct ps3_instance *instance, - S32 dump_type) +static inline int ps3_dump_trigger(struct ps3_instance *instance, int dump_type) { - U64 dump_ctrl; - U64 ctrl_val = 0; - S32 ret = PS3_SUCCESS; - Bool reg_ret = PS3_TRUE; + unsigned long long dump_ctrl; + unsigned long long ctrl_val = 0; + int ret = PS3_SUCCESS; + unsigned char reg_ret = PS3_TRUE; switch (dump_type) { case PS3_DUMP_TYPE_CRASH: @@ -324,30 +334,31 @@ static inline S32 ps3_dump_trigger(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_GET_CTRL_FAIL, ®_ret); if (reg_ret) { if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + LOG_WARN("dump ctrl is not cleared 0x%llx\n", + dump_ctrl); ret = -PS3_FAILED; } else { ps3_dump_ctrl_set(instance, ctrl_val); } } else { - LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", PS3_HOST(instance)); ret = -PS3_FAILED; } l_ret: return ret; } -static inline Bool ps3_dump_status_get(struct ps3_instance *instance, - U64 *dump_status) +static inline unsigned char ps3_dump_status_get(struct ps3_instance *instance, + unsigned long long *dump_status) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpStatus, *dump_status); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpStatus, + *dump_status); INJECT_START(PS3_ERR_IJ_DUMP_STATUS_ERR, dump_status); if (*dump_status == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpStatus NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *dump_status = 0; ret = PS3_FALSE; goto l_out; @@ -359,35 +370,36 @@ static inline Bool ps3_dump_status_get(struct ps3_instance *instance, return ret; } -static inline void ps3_dump_status_set(struct ps3_instance *instance, - U64 value) +static inline void ps3_dump_status_set(struct ps3_instance *instance, unsigned long long value) { PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpStatus, value); } -static inline Bool ps3_dump_data_size_get_clear(struct ps3_instance *instance, - U64 *data_size) +static inline unsigned char ps3_dump_data_size_get_clear(struct ps3_instance *instance, + unsigned long long *data_size) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, *data_size); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, + *data_size); INJECT_START(PS3_ERR_IJ_DUMP_DATA_SIZE_FAIL, data_size); if (*data_size == U64_MAX) { LOG_INFO("hno:%u read reg ps3DumpDataSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *data_size = 0; ret = PS3_FALSE; } - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, 0); + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3DumpDataSize, + 0); return ret; } -static Bool ps3_dump_status_check(U64 status, U8 dump_type) +static unsigned char ps3_dump_status_check(unsigned long long status, unsigned char dump_type) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; - switch(dump_type){ + switch (dump_type) { case PS3_DUMP_TYPE_FW_LOG: ret = PS3_REG_TEST(status, PS3_DUMP_STATUS_REG_FW_DUMP_MASK); break; @@ -403,20 +415,19 @@ static Bool ps3_dump_status_check(U64 status, U8 dump_type) goto l_out; } - if (ret == PS3_TRUE) { + if (ret == PS3_TRUE) ret = PS3_REG_TEST(status, PS3_DUMP_STATUS_REG_DMA_FINISH_MASK); - } l_out: return ret; } -static S32 ps3_dump_dma_data_copy(struct ps3_dump_context * ctxt, U64 status) +static int ps3_dump_dma_data_copy(struct ps3_dump_context *ctxt, unsigned long long status) { - U64 dma_size = 0; - U64 dump_ctrl; - S32 ret = PS3_SUCCESS; - Bool reg_ret = PS3_TRUE; + unsigned long long dma_size = 0; + unsigned long long dump_ctrl; + int ret = PS3_SUCCESS; + unsigned char reg_ret = PS3_TRUE; if (!ps3_dump_data_size_get_clear(ctxt->instance, &dma_size)) { ret = -PS3_FAILED; @@ -430,10 +441,12 @@ static S32 ps3_dump_dma_data_copy(struct ps3_dump_context * ctxt, U64 status) } ctxt->dump_data_size += dma_size; - ret = ps3_dump_file_write(&ctxt->dump_out_file, ctxt->dump_dma_buf, dma_size); + ret = ps3_dump_file_write(&ctxt->dump_out_file, ctxt->dump_dma_buf, + dma_size); INJECT_START(PS3_ERR_IJ_DUMP_WRITE_FAIL, &ret); - if (ret < 0 || ret != (S32)dma_size) { - LOG_WARN("error: write data failure ret %d, dma_size %llu\n", ret, dma_size); + if (ret < 0 || ret != (int)dma_size) { + LOG_WARN("error: write data failure ret %d, dma_size %llu\n", + ret, dma_size); ret = -PS3_FAILED; goto l_out; } @@ -446,13 +459,14 @@ static S32 ps3_dump_dma_data_copy(struct ps3_dump_context * ctxt, U64 status) INJECT_START(PS3_ERR_IJ_DUMP_DATA_COPY_GET_CTRL_FAIL, ®_ret); if (reg_ret) { if (dump_ctrl) { - LOG_WARN("dump ctrl is not cleared 0x%llx\n", dump_ctrl); + LOG_WARN("dump ctrl is not cleared 0x%llx\n", + dump_ctrl); } ps3_dump_ctrl_set(ctxt->instance, PS3_DUMP_CTRL_COPY_FINISH); ret = PS3_SUCCESS; } else { LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(ctxt->instance)); + PS3_HOST(ctxt->instance)); ret = -PS3_FAILED; } @@ -460,7 +474,8 @@ static S32 ps3_dump_dma_data_copy(struct ps3_dump_context * ctxt, U64 status) return ret; } -static inline void ps3_dump_work_done(struct ps3_dump_context * ctxt, S32 cur_state) +static inline void ps3_dump_work_done(struct ps3_dump_context *ctxt, + int cur_state) { ctxt->dump_work_status = PS3_DUMP_WORK_STOP; ps3_dump_file_close(&ctxt->dump_out_file); @@ -472,14 +487,14 @@ static inline void ps3_dump_work_done(struct ps3_dump_context * ctxt, S32 cur_st } } -static void ps3_dump_work(struct work_struct *work) +static void ps3_dump_work(struct work_struct *work) { - static U32 work_wait_times = 0; - struct ps3_dump_context * ctxt = + unsigned int work_wait_times = 0; + struct ps3_dump_context *ctxt = ps3_container_of(work, struct ps3_dump_context, dump_work.work); - U64 status = 0, delay_ms = 0; - S32 cur_state = 0; - Bool ret = PS3_TRUE; + unsigned long long status = 0, delay_ms = 0; + int cur_state = 0; + unsigned char ret = PS3_TRUE; ctxt->dump_work_status = PS3_DUMP_WORK_RUNNING; ret = ps3_dump_status_get(ctxt->instance, &status); @@ -487,39 +502,47 @@ static void ps3_dump_work(struct work_struct *work) if (!ret) { delay_ms = PS3_REG_READ_INTERVAL_MS; LOG_INFO("ps3_dump_status_get error, delay %llums try again\n", - delay_ms); + delay_ms); queue_delayed_work(ctxt->dump_work_queue, &ctxt->dump_work, - msecs_to_jiffies(delay_ms)); + msecs_to_jiffies(delay_ms)); goto l_out; } INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); - while(delay_ms == 0) { + while (delay_ms == 0) { if (ctxt->is_hard_recovered) { LOG_WARN("dump in hard recovery, ready to abort\n"); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; } - switch(ctxt->dump_state) { + switch (ctxt->dump_state) { case PS3_DUMP_STATE_START: - INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, &status); - if ((status & PS3_DUMP_STATUS_REG_INVALID_BITS_MASK) == 0 || - (status & PS3_DUMP_STATUS_REG_ABORT_MASK) != 0) { - LOG_INFO("abort dump in START STATE, status: 0x%llx\n", status); + INJECT_START(PS3_ERR_IJ_DUMP_DUMP_STATE_INVALID, + &status); + if ((status & PS3_DUMP_STATUS_REG_INVALID_BITS_MASK) == + 0 || + (status & PS3_DUMP_STATUS_REG_ABORT_MASK) != 0) { + LOG_INFO( + "abort dump in START STATE, status: 0x%llx\n", + status); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; } if ((status & PS3_DUMP_STATUS_REG_MASK) == 0 || - ps3_dump_status_check(status, ctxt->dump_type) == PS3_FALSE) { + ps3_dump_status_check(status, ctxt->dump_type) == + PS3_FALSE) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; } - if (ctxt->dump_out_file.file_status != PS3_DUMP_FILE_OPEN) { - if (ps3_dump_file_open(ctxt, (U32)ctxt->dump_type) != PS3_SUCCESS) { + if (ctxt->dump_out_file.file_status != + PS3_DUMP_FILE_OPEN) { + if (ps3_dump_file_open(ctxt, + (unsigned int)ctxt->dump_type) != + PS3_SUCCESS) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; @@ -527,7 +550,8 @@ static void ps3_dump_work(struct work_struct *work) } work_wait_times = 0; ctxt->dump_state = PS3_DUMP_STATE_COPYING; - INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID_2, ctxt->instance); + INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID_2, + ctxt->instance); break; case PS3_DUMP_STATE_COPYING: if (status & PS3_DUMP_STATUS_REG_ABORT_MASK) { @@ -541,12 +565,14 @@ static void ps3_dump_work(struct work_struct *work) ctxt->dump_work_status = PS3_DUMP_WORK_DONE; break; } - if (ps3_dump_status_check(status, ctxt->dump_type) == PS3_FALSE) { + if (ps3_dump_status_check(status, ctxt->dump_type) == + PS3_FALSE) { delay_ms = WAIT_DUMP_COLLECT; work_wait_times++; break; } - if (ps3_dump_dma_data_copy(ctxt, status) != PS3_SUCCESS) { + if (ps3_dump_dma_data_copy(ctxt, status) != + PS3_SUCCESS) { LOG_INFO("abort dump in COPYING STATE\n"); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; @@ -557,35 +583,40 @@ static void ps3_dump_work(struct work_struct *work) break; case PS3_DUMP_STATE_PRE_ABORT: ps3_dump_abort(ctxt->instance); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) +#if defined(PS3_FALLTHROUGH) ps3_dump_work_done(ctxt, cur_state); work_wait_times = 0; goto l_out; #endif + /* fallthrough */ case PS3_DUMP_STATE_ABORTED: case PS3_DUMP_STATE_COPY_DONE: ps3_dump_work_done(ctxt, cur_state); work_wait_times = 0; goto l_out; default: - LOG_INFO("warn: dump work state %d\n", ctxt->dump_state); + LOG_INFO("warn: dump work state %d\n", + ctxt->dump_state); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; continue; } if (delay_ms) { if (work_wait_times >= - max((U32)WAIT_DUMP_TIMES_MIN, (U32)ctxt->dump_dma_wait_times)) { - LOG_INFO("error: wait too many times %d for dump %s, abort it\n", - work_wait_times,ps3_dump_type_to_name(ctxt->dump_type)); + max_t(unsigned int, WAIT_DUMP_TIMES_MIN, ctxt->dump_dma_wait_times)) { + LOG_INFO( + "error: wait too many times %d for dump %s, abort it\n", + work_wait_times, + ps3_dump_type_to_name(ctxt->dump_type)); ctxt->dump_state = PS3_DUMP_STATE_PRE_ABORT; work_wait_times = 0; delay_ms = 0; continue; } - queue_delayed_work(ctxt->dump_work_queue, &ctxt->dump_work, - msecs_to_jiffies(delay_ms)); - break; + queue_delayed_work(ctxt->dump_work_queue, + &ctxt->dump_work, + msecs_to_jiffies(delay_ms)); + break; } } @@ -593,18 +624,17 @@ static void ps3_dump_work(struct work_struct *work) return; } -S32 ps3_dump_dma_buf_alloc(struct ps3_instance *instance) +int ps3_dump_dma_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; - ctxt->dump_dma_buf = (U8*) ps3_dma_alloc_coherent( - instance, - PS3_DUMP_DMA_BUF_SIZE, - &ctxt->dump_dma_addr); - INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_DMA_BUF_FAILED, &ctxt->dump_dma_buf) + ctxt->dump_dma_buf = (unsigned char *)ps3_dma_alloc_coherent( + instance, PS3_DUMP_DMA_BUF_SIZE, (unsigned long long *)&ctxt->dump_dma_addr); + INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_DMA_BUF_FAILED, &ctxt->dump_dma_buf); if (ctxt->dump_dma_buf == NULL) { - LOG_ERROR("host_no[%d], dump dma alloc NOK!\n", PS3_HOST(instance)); + LOG_ERROR("host_no[%d], dump dma alloc NOK!\n", + PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -616,9 +646,8 @@ void ps3_dump_dma_buf_free(struct ps3_instance *instance) struct ps3_dump_context *ctxt = &instance->dump_context; if (ctxt->dump_dma_buf != NULL) { - ps3_dma_free_coherent(instance, - PS3_DUMP_DMA_BUF_SIZE, ctxt->dump_dma_buf, - ctxt->dump_dma_addr); + ps3_dma_free_coherent(instance, PS3_DUMP_DMA_BUF_SIZE, + ctxt->dump_dma_buf, ctxt->dump_dma_addr); ctxt->dump_dma_buf = NULL; } } @@ -632,14 +661,15 @@ static void ps3_dump_reset(struct ps3_dump_context *ctxt) memset(&ctxt->dump_out_file, 0, sizeof(ctxt->dump_out_file)); } -S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env) +int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, unsigned int env) { - S32 ret = PS3_SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int ret = PS3_SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; + LOG_INFO("dump type set: type %d\n", type); - + INJECT_START(PS3_ERR_IJ_DUMP_TYPE_ILLEGAL, &type); - if ( (type < PS3_DUMP_TYPE_CRASH)|| (type > PS3_DUMP_TYPE_BAR_DATA)) { + if ((type < PS3_DUMP_TYPE_CRASH) || (type > PS3_DUMP_TYPE_BAR_DATA)) { ret = -PS3_FAILED; goto l_ret; } @@ -654,7 +684,9 @@ S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env) ps3_mutex_lock(&ctxt->dump_lock); INJECT_START(PS3_ERR_IJ_DUMP_STATE_ILLEGAL, &ctxt->dump_state); if (ctxt->dump_state != PS3_DUMP_STATE_INVALID) { - LOG_FILE_ERROR("dump type set: work is busy, current state: %d, type %d\n", ctxt->dump_state, type); + LOG_FILE_ERROR( + "dump type set: work is busy, current state: %d, type %d\n", + ctxt->dump_state, type); ret = -PS3_FAILED; goto l_unlock; } @@ -676,19 +708,20 @@ S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env) cur_state = ps3_atomic_read(&ctxt->instance->state_machine.state); if (!ps3_state_is_normal(cur_state)) { LOG_WARN("h_no[%u], instance state is unnormal[%s]\n", - PS3_HOST(ctxt->instance), namePS3InstanceState(cur_state)); + PS3_HOST(ctxt->instance), + namePS3InstanceState(cur_state)); ret = -PS3_FAILED; goto l_unlock; } ctxt->dump_state = PS3_DUMP_STATE_START; - ctxt->dump_type = type; + ctxt->dump_type = type; ctxt->dump_env = env; ctxt->dump_type_times++; INJECT_AT_TIMES(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, ctxt->instance); - ret = ps3_dump_trigger (ctxt->instance, type); + ret = ps3_dump_trigger(ctxt->instance, type); INJECT_START(PS3_ERR_IJ_DUMP_TRIGGER_FAIL, &ret); if (ret != PS3_SUCCESS) { ps3_dump_reset(ctxt); @@ -702,10 +735,10 @@ S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env) return ret; } -S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state) +int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state) { - S32 ret = PS3_SUCCESS; - S32 cur_state; + int ret = PS3_SUCCESS; + int cur_state; LOG_INFO("dump state set: state %d\n", state); @@ -716,26 +749,24 @@ S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state) ps3_mutex_lock(&ctxt->dump_lock); cur_state = ctxt->dump_state; - if (cur_state == PS3_DUMP_STATE_INVALID) { + if (cur_state == PS3_DUMP_STATE_INVALID) goto l_unlock; - } cancel_delayed_work_sync(&ctxt->dump_work); ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; ctxt->dump_state_times++; if (cur_state == PS3_DUMP_STATE_PRE_ABORT || - cur_state == PS3_DUMP_STATE_START || - cur_state == PS3_DUMP_STATE_COPYING) { + cur_state == PS3_DUMP_STATE_START || + cur_state == PS3_DUMP_STATE_COPYING) { ps3_dump_abort(ctxt->instance); } ps3_dump_file_close(&ctxt->dump_out_file); ps3_dump_reset(ctxt); - if (cur_state == PS3_DUMP_STATE_COPY_DONE) { + if (cur_state == PS3_DUMP_STATE_COPY_DONE) ps3_dump_end(ctxt->instance); - } l_unlock: ps3_mutex_unlock(&ctxt->dump_lock); l_ret: @@ -745,45 +776,41 @@ S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state) void ps3_dump_detect(struct ps3_instance *instance) { struct ps3_dump_context *p_dump_ctx = &instance->dump_context; - S32 ret = PS3_SUCCESS; - S32 dump_type = 0; - U64 status = 0; - HilReg0Ps3RegisterFPs3DumpStatus_u dump_status = {0}; - U8 is_trigger_log; + int ret = PS3_SUCCESS; + int dump_type = 0; + unsigned long long status = 0; + union HilReg0Ps3RegisterFPs3DumpStatus dump_status = { 0 }; + unsigned char is_trigger_log; - if (!ps3_dump_status_get(instance, &status)) { + if (!ps3_dump_status_get(instance, &status)) goto l_out; - } dump_status.val = status; dump_type = dump_status.reg.hasAutoDump; INJECT_START(PS3_ERR_IJ_DUMP_TYPE_INVALID, &dump_type); - if (dump_type == 0) { + if (dump_type == 0) goto l_out; - } ps3_ioc_dump_support_get(instance); - if (!PS3_IOC_DUMP_SUPPORT(instance)) { + if (!PS3_IOC_DUMP_SUPPORT(instance)) goto l_out; - } LOG_DEBUG("hno:%u detect dump log file type[%d], status[%llx]\n", - PS3_HOST(instance), dump_type, status); + PS3_HOST(instance), dump_type, status); is_trigger_log = ps3_dump_is_trigger_log(instance); - INJECT_START(PS3_ERR_IJ_DETECT_NO_TRIGGER_LOG, &is_trigger_log) - if(!is_trigger_log) { + INJECT_START(PS3_ERR_IJ_DETECT_NO_TRIGGER_LOG, &is_trigger_log); + if (!is_trigger_log) { LOG_DEBUG("cannot dump type set!\n"); goto l_out; } ret = ps3_dump_type_set(p_dump_ctx, dump_type, PS3_DUMP_ENV_NOTIFY); LOG_DEBUG("hno:%u type[%d] autodump set trigger ret %d\n", - PS3_HOST(instance), dump_type, ret); - if (ret == PS3_SUCCESS) { + PS3_HOST(instance), dump_type, ret); + if (ret == PS3_SUCCESS) goto l_out; - } l_out: return; @@ -791,70 +818,70 @@ void ps3_dump_detect(struct ps3_instance *instance) static void ps3_dump_irq_handler_work(struct work_struct *work) { - struct ps3_dump_context * ctxt = - ps3_container_of(work, struct ps3_dump_context, dump_irq_handler_work); - - ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_RUNNING; - ps3_dump_detect(ctxt->instance); - ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_DONE; - - return; + struct ps3_dump_context *ctxt = ps3_container_of( + work, struct ps3_dump_context, dump_irq_handler_work); + ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_RUNNING; + ps3_dump_detect(ctxt->instance); + ctxt->dump_irq_handler_work_status = PS3_DUMP_IRQ_HANDLER_WORK_DONE; } -irqreturn_t ps3_dump_irq_handler(S32 virq, void *dev_id) +irqreturn_t ps3_dump_irq_handler(int virq, void *dev_id) { - struct ps3_instance *pInstance = (struct ps3_instance *)dev_id; - struct ps3_dump_context *p_dump_ctx = &pInstance->dump_context; - ULong flags = 0; + struct ps3_instance *pInstance = (struct ps3_instance *)dev_id; + struct ps3_dump_context *p_dump_ctx = &pInstance->dump_context; + unsigned long flags = 0; spin_lock_irqsave(&p_dump_ctx->dump_irq_handler_lock, flags); if (p_dump_ctx->dump_enabled) { - LOG_DEBUG("hno:%u dump irq recieved, virq: %d, dev_id: 0x%llx\n", - PS3_HOST(pInstance), virq, (U64)dev_id); + LOG_DEBUG( + "hno:%u dump irq received, virq: %d, dev_id: 0x%llx\n", + PS3_HOST(pInstance), virq, (unsigned long long)(uintptr_t)dev_id); if (!work_busy(&p_dump_ctx->dump_irq_handler_work)) { - queue_work(p_dump_ctx->dump_irq_handler_work_queue, &p_dump_ctx->dump_irq_handler_work); + queue_work(p_dump_ctx->dump_irq_handler_work_queue, + &p_dump_ctx->dump_irq_handler_work); } } spin_unlock_irqrestore(&p_dump_ctx->dump_irq_handler_lock, flags); - return IRQ_HANDLED; + return IRQ_HANDLED; } static void ps3_dump_dir_init(char *dump_dir) { - char *log_path_p; - U32 log_path_len = 0; + char *log_path_p; + unsigned int log_path_len = 0; log_path_p = ps3_log_path_query(); - if (log_path_p != NULL) { + if (log_path_p != NULL) log_path_len = strlen(log_path_p); - } if (log_path_p != NULL && log_path_p[0] == '/') { if (log_path_p[log_path_len - 1] == '/') { - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s", log_path_p); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s", + log_path_p); } else { - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", log_path_p); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", + log_path_p); } } else { - LOG_INFO("provided log dump dir not valid, using default\n"); - snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", PS3_DUMP_FILE_DIR); + LOG_INFO("provided log dump dir not valid, using default\n"); + snprintf(dump_dir, PS3_DUMP_FILE_DIR_LEN, "%s/", + PS3_DUMP_FILE_DIR); } - - return; } -S32 ps3_dump_init(struct ps3_instance *instance) +int ps3_dump_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dump_context *ctxt = &instance->dump_context; if (reset_devices) { - LOG_INFO("resetting device in progress, Do not initialize dump\n"); + LOG_INFO( + "resetting device in progress, Do not initialize dump\n"); goto l_ret; } @@ -862,11 +889,10 @@ S32 ps3_dump_init(struct ps3_instance *instance) LOG_INFO("hno:%u init already\n", PS3_HOST(instance)); goto l_ret; } - memset((void*)ctxt, 0, sizeof(struct ps3_dump_context )); + memset((void *)ctxt, 0, sizeof(struct ps3_dump_context)); - if (!ps3_ioc_dump_support_get(instance)) { + if (!ps3_ioc_dump_support_get(instance)) goto l_ret; - } ps3_dump_dir_init((char *)ctxt->dump_dir); @@ -880,7 +906,8 @@ S32 ps3_dump_init(struct ps3_instance *instance) } INIT_DELAYED_WORK(&ctxt->dump_work, ps3_dump_work); - ctxt->dump_work_queue = create_singlethread_workqueue((char*)"ps3_dump_work_queue"); + ctxt->dump_work_queue = + create_singlethread_workqueue((char *)"ps3_dump_work_q"); INJECT_START(PS3_ERR_IJ_DUMP_WORK_FAILED, &ctxt->dump_work_queue); if (ctxt->dump_work_queue == NULL) { LOG_ERROR("dump work queue create NOK\n"); @@ -890,8 +917,9 @@ S32 ps3_dump_init(struct ps3_instance *instance) INIT_WORK(&ctxt->dump_irq_handler_work, ps3_dump_irq_handler_work); ctxt->dump_irq_handler_work_queue = create_singlethread_workqueue( - (char*)"ps3_dump_irq_handler_work_queue"); - INJECT_START(PS3_ERR_DUMP_ALLOC_FAILED, &ctxt->dump_irq_handler_work_queue); + (char *)"ps3_dump_irq_wq"); + INJECT_START(PS3_ERR_DUMP_ALLOC_FAILED, + &ctxt->dump_irq_handler_work_queue); if (ctxt->dump_irq_handler_work_queue == NULL) { LOG_ERROR("dump irq handler work queue create NOK\n"); ret = -PS3_FAILED; @@ -911,18 +939,17 @@ S32 ps3_dump_init(struct ps3_instance *instance) void ps3_dump_exit(struct ps3_instance *instance) { struct ps3_dump_context *ctxt = &instance->dump_context; - ULong flags = 0; + unsigned long flags = 0; - if (ctxt->dump_dma_buf == NULL) { + if (ctxt->dump_dma_buf == NULL) return; - } spin_lock_irqsave(&ctxt->dump_irq_handler_lock, flags); ctxt->dump_enabled = 0; spin_unlock_irqrestore(&ctxt->dump_irq_handler_lock, flags); if (ctxt->dump_irq_handler_work_queue != NULL) { - if (!cancel_work_sync(&ctxt->dump_irq_handler_work)) { + if (!ps3_cancel_work_sync(&ctxt->dump_irq_handler_work)) { flush_workqueue(ctxt->dump_irq_handler_work_queue); } else { ctxt->dump_irq_handler_work_status = @@ -933,11 +960,10 @@ void ps3_dump_exit(struct ps3_instance *instance) } if (ctxt->dump_work_queue != NULL) { - if (!cancel_delayed_work_sync(&ctxt->dump_work)) { + if (!cancel_delayed_work_sync(&ctxt->dump_work)) flush_workqueue(ctxt->dump_work_queue); - } else { + else ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; - } destroy_workqueue(ctxt->dump_work_queue); ctxt->dump_work_queue = NULL; } @@ -946,14 +972,14 @@ void ps3_dump_exit(struct ps3_instance *instance) ps3_dump_file_close(&ctxt->dump_out_file); ps3_mutex_destroy(&ctxt->dump_lock); - LOG_INFO("hno:%u dump destory work and stop service\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u dump destroy work and stop service\n", + PS3_HOST(instance)); } void ps3_dump_work_stop(struct ps3_instance *instance) { struct ps3_dump_context *ctxt = &instance->dump_context; - ULong flags = 0; + unsigned long flags = 0; spin_lock_irqsave(&ctxt->dump_irq_handler_lock, flags); if (ctxt->dump_enabled == 0) { @@ -963,7 +989,7 @@ void ps3_dump_work_stop(struct ps3_instance *instance) spin_unlock_irqrestore(&ctxt->dump_irq_handler_lock, flags); if (ctxt->dump_irq_handler_work_queue != NULL) { - if (!cancel_work_sync(&ctxt->dump_irq_handler_work)) { + if (!ps3_cancel_work_sync(&ctxt->dump_irq_handler_work)) { flush_workqueue(ctxt->dump_irq_handler_work_queue); } else { ctxt->dump_irq_handler_work_status = @@ -973,35 +999,37 @@ void ps3_dump_work_stop(struct ps3_instance *instance) if (ctxt->dump_work_queue != NULL) { ps3_dump_state_set(ctxt, PS3_DUMP_STATE_INVALID); - if (!cancel_delayed_work_sync(&ctxt->dump_work)) { + if (!cancel_delayed_work_sync(&ctxt->dump_work)) flush_workqueue(ctxt->dump_work_queue); - } else { + else ctxt->dump_work_status = PS3_DUMP_WORK_CANCEL; - } } } void ps3_dump_ctrl_set_int_ready(struct ps3_instance *instance) { if (reset_devices) { - LOG_INFO("resetting device in progress, unable to confiure ps3DumpCtrl\n"); + LOG_INFO( + "resetting device in progress, unable to confiure ps3DumpCtrl\n"); return; } - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, PS3_DUMP_CTRL_DUMP_INT_READY); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3DumpCtrl, + PS3_DUMP_CTRL_DUMP_INT_READY); } -Bool ps3_dump_is_trigger_log(struct ps3_instance *instance) +unsigned char ps3_dump_is_trigger_log(struct ps3_instance *instance) { - Bool is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); - U64 dump_ctrl; - Bool is_trigger_log = PS3_FALSE; - S32 cur_state = ps3_atomic_read(&instance->state_machine.state); - Bool is_halt = (is_support_halt && (cur_state == PS3_INSTANCE_STATE_DEAD)); - Bool ret = PS3_TRUE; + unsigned char is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); + unsigned long long dump_ctrl; + unsigned char is_trigger_log = PS3_FALSE; + int cur_state = ps3_atomic_read(&instance->state_machine.state); + unsigned char is_halt = + (is_support_halt && (cur_state == PS3_INSTANCE_STATE_DEAD)); + unsigned char ret = PS3_TRUE; INJECT_START(PS3_ERR_IJ_DUMP_PCIE_ERR, instance); INJECT_START(PS3_ERR_IJ_DUMP_RECOVERY_ERR, instance); - if (likely(is_halt || - (cur_state == PS3_INSTANCE_STATE_OPERATIONAL && !ps3_pci_err_recovery_get(instance)))) { + if (likely(is_halt || (cur_state == PS3_INSTANCE_STATE_OPERATIONAL && + !ps3_pci_err_recovery_get(instance)))) { is_trigger_log = PS3_TRUE; } @@ -1009,16 +1037,14 @@ Bool ps3_dump_is_trigger_log(struct ps3_instance *instance) ret = ps3_dump_ctrl_get(instance, &dump_ctrl); INJECT_START(PS3_ERR_IJ_DUMP_IS_TRIGGER_GET_CTRL_FAIL, &ret); if (ret) { - if(dump_ctrl != 0) { + if (dump_ctrl != 0) is_trigger_log = PS3_FALSE; - } } else { LOG_INFO("hno:%u read ps3DumpCtrl NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_trigger_log = PS3_FALSE; } } return is_trigger_log; } - diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c index 3d65426a04cd..edf1d641bdbe 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include @@ -6,28 +7,24 @@ #include "ps3_recovery.h" #include "ps3_ioc_state.h" #include "ps3_module_para.h" +#include "ps3_kernel_version.h" static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, - pci_channel_state_t state); + pci_channel_state_t state); static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev); static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev); static void ps3_pci_resume(struct pci_dev *pdev); -extern S32 ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance); -extern S32 ps3_pci_init_complete(struct ps3_instance *instance); -extern void ps3_pci_init_complete_exit(struct ps3_instance *instance); - static struct pci_error_handlers ps3_err_handlers = { - .error_detected = ps3_pci_err_detected, - .mmio_enabled = ps3_pci_mmio_enabled, - .slot_reset = ps3_pci_slot_reset, - .resume = ps3_pci_resume + .error_detected = ps3_pci_err_detected, + .mmio_enabled = ps3_pci_mmio_enabled, + .slot_reset = ps3_pci_slot_reset, + .resume = ps3_pci_resume }; void ps3_pci_err_handler_init(struct pci_driver *drv) { drv->err_handler = &ps3_err_handlers; - return; } int ps3_base_init_resources(struct ps3_instance *instance) @@ -36,18 +33,20 @@ int ps3_base_init_resources(struct ps3_instance *instance) struct pci_dev *pdev = instance->pdev; ret = ps3_pci_init(pdev, instance); - INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_FAILED, &ret); if (ret) { - LOG_ERROR("hno:%u pci init failed, ret: %d\n", PS3_HOST(instance), ret); + LOG_ERROR("hno:%u pci init failed, ret: %d\n", + PS3_HOST(instance), ret); goto l_out; } instance->is_pci_reset = PS3_FALSE; ret = ps3_pci_init_complete(instance); - INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_COMP_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_PCI_INIT_COMP_FAILED, &ret); if (ret) { - LOG_ERROR("hno:%u pci init complete failed, ret: %d\n", PS3_HOST(instance), ret); + LOG_ERROR("hno:%u pci init complete failed, ret: %d\n", + PS3_HOST(instance), ret); goto l_out; } @@ -68,21 +67,25 @@ void ps3_base_free_resources(struct ps3_instance *instance) ps3_pci_init_complete_exit(instance); } -static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t state) +static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, + pci_channel_state_t state) { pci_ers_result_t ret = PCI_ERS_RESULT_NEED_RESET; - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); if (instance == NULL) { LOG_INFO("get instance failed\n"); - dev_info(&pdev->dev, "[PS3]%s():%d; get instance failed\n", __FUNCTION__, __LINE__); + dev_info(&pdev->dev, "[PS3]%s():%d; get instance failed\n", + __func__, __LINE__); ret = PCI_ERS_RESULT_DISCONNECT; goto l_out; } - LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detected state:%u\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state); + LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detected state:%u\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state); dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detected state:%u\n", - __FUNCTION__, __LINE__, state); + __func__, __LINE__, state); instance->is_pcie_err_detected = PS3_TRUE; switch (state) { case pci_channel_io_normal: @@ -93,7 +96,8 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, pci_channel_s scsi_block_requests(instance->host); ps3_watchdog_stop(instance); if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); + LOG_ERROR("hno:%u work sync failed, state: %u\n", + PS3_HOST(instance), state); } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_CLEAN; ps3_base_free_resources(instance); @@ -103,7 +107,8 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, pci_channel_s ps3_pci_err_recovery_set(instance, PS3_TRUE); ps3_watchdog_stop(instance); if (ps3_recovery_cancel_work_sync(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u work sync failed, state: %u\n", PS3_HOST(instance), state); + LOG_ERROR("hno:%u work sync failed, state: %u\n", + PS3_HOST(instance), state); } ps3_cmd_force_stop(instance); ps3_pci_err_recovery_set(instance, PS3_FALSE); @@ -117,10 +122,12 @@ static pci_ers_result_t ps3_pci_err_detected(struct pci_dev *pdev, pci_channel_s instance->is_pcie_err_detected = PS3_FALSE; l_out: - LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detect state:%u ret:%u\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state, ret); + LOG_INFO("[%04x:%02x:%02x:%x]:PCIe err detect state:%u ret:%u\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev), state, + ret); dev_info(&pdev->dev, "[PS3]%s():%d;PCIe err detect state:%u ret:%u\n", - __FUNCTION__, __LINE__, state, ret); + __func__, __LINE__, state, ret); return ret; } @@ -128,10 +135,11 @@ static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev) { pci_ers_result_t ret = PCI_ERS_RESULT_RECOVERED; - LOG_INFO("[%04x:%02x:%02x:%x]: PCIe err mmio enabled\n", ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), \ - ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); + LOG_INFO("[%04x:%02x:%02x:%x]: PCIe err mmio enabled\n", + ps3_get_pci_domain(pdev), ps3_get_pci_bus(pdev), + ps3_get_pci_slot(pdev), ps3_get_pci_function(pdev)); dev_info(&pdev->dev, "[PS3]%s():%d; PCIe err mmio enabled\n", - __FUNCTION__, __LINE__); + __func__, __LINE__); return ret; } @@ -139,11 +147,12 @@ static pci_ers_result_t ps3_pci_mmio_enabled(struct pci_dev *pdev) static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) { int ret; - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); LOG_INFO("hno:%u PCIe err slot reset begin.\n", PS3_HOST(instance)); dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset begin.\n", - __FUNCTION__, __LINE__, PS3_HOST(instance)); + __func__, __LINE__, PS3_HOST(instance)); instance->pdev = pdev; pci_restore_state(pdev); @@ -152,21 +161,24 @@ static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) ret = ps3_base_init_resources(instance); if (ret) { - LOG_ERROR("hno:%u base init resources failed, ret: %d\n", PS3_HOST(instance), ret); - dev_info(&pdev->dev, "[PS3]hno:%u init resources failed, ret: %d\n", PS3_HOST(instance), ret); + LOG_ERROR("hno:%u base init resources failed, ret: %d\n", + PS3_HOST(instance), ret); + dev_info(&pdev->dev, + "[PS3]hno:%u init resources failed, ret: %d\n", + PS3_HOST(instance), ret); goto l_out; } LOG_INFO("hno:%u PCIe err slot reset succeed.\n", PS3_HOST(instance)); - dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err slot reset succeed.\n", - __FUNCTION__, __LINE__, PS3_HOST(instance)); + dev_info(&pdev->dev, + "[PS3]%s():%d;hno:%u PCIe err slot reset succeed.\n", + __func__, __LINE__, PS3_HOST(instance)); ps3_pci_err_recovery_set(instance, PS3_FALSE); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; return PCI_ERS_RESULT_RECOVERED; l_out: - if (instance) { + if (instance) ps3_instance_state_transfer_to_dead(instance); - } ps3_pci_err_recovery_set(instance, PS3_FALSE); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_INIT; @@ -175,62 +187,60 @@ static pci_ers_result_t ps3_pci_slot_reset(struct pci_dev *pdev) static void ps3_pci_resume(struct pci_dev *pdev) { - S32 ret = PS3_SUCCESS; - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - struct ps3_instance *instance = (struct ps3_instance *)pci_get_drvdata(pdev); + int ret = PS3_SUCCESS; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + struct ps3_instance *instance = + (struct ps3_instance *)pci_get_drvdata(pdev); LOG_INFO("hno:%u PCIe err resume\n", PS3_HOST(instance)); dev_info(&pdev->dev, "[PS3]%s():%d;hno:%u PCIe err resume\n", - __FUNCTION__, __LINE__, PS3_HOST(instance)); + __func__, __LINE__, PS3_HOST(instance)); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_IOC_RUNNING_INIT_FAILED, &fw_cur_state) + INJECT_START(PS3_ERR_IJ_FORCE_PCIE_ERR_IOC_RUNNING_INIT_FAILED, + &fw_cur_state); if (fw_cur_state == PS3_FW_STATE_RUNNING) { - LOG_INFO("hno:%u not need repeat recovery\n", PS3_HOST(instance)); - dev_info(&pdev->dev, "[PS3]hno:%u not need repeat recovery\n", PS3_HOST(instance)); + LOG_INFO("hno:%u not need repeat recovery\n", + PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]hno:%u not need repeat recovery\n", + PS3_HOST(instance)); goto l_norecovery; } - INJECT_START(PS3_ERR_IJ_PCI_FORCE_HARD_RECOVERY_REQ_FAILED, instance) - ret = ps3_hard_recovery_request_with_retry(instance); + INJECT_START(PS3_ERR_IJ_PCI_FORCE_HARD_RECOVERY_REQ_FAILED, instance); + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); - dev_info(&pdev->dev, "[PS3]hno:%u hard reset NOK, ret: %d\n", PS3_HOST(instance), ret); + LOG_ERROR("hno:%u hard reset NOK, ret: %d\n", + PS3_HOST(instance), ret); + dev_info(&pdev->dev, "[PS3]hno:%u hard reset NOK, ret: %d\n", + PS3_HOST(instance), ret); goto l_failed; } ret = ps3_instance_wait_for_operational(instance, PS3_TRUE); - INJECT_START(PS3_ERR_IJ_PCI_FORCE_WAIT_OPERARIONAL_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_PCI_FORCE_WAIT_OPERARIONAL_FAILED, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u wait for opt NOK.\n", PS3_HOST(instance)); - dev_info(&pdev->dev, "[PS3]hno:%u wait for opt NOK.\n", PS3_HOST(instance)); + dev_info(&pdev->dev, "[PS3]hno:%u wait for opt NOK.\n", + PS3_HOST(instance)); goto l_failed; } l_norecovery: -#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 3)) \ - || (defined(CONFIG_SUSE_KERNEL) && ((CONFIG_SUSE_VERSION == 15) \ - && (CONFIG_SUSE_PATCHLEVEL >= 2)))) - pci_aer_clear_nonfatal_status(pdev); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) - pci_cleanup_aer_uncorrect_error_status(pdev); +#if defined(PS3_AER_CLEAR_STATUS) + pci_aer_clear_nonfatal_status(pdev); +#elif defined(PS3_AER_CLEAR_STATUS_LOW_KERNER) + pci_cleanup_aer_uncorrect_error_status(pdev); #endif ps3_watchdog_start(instance); scsi_unblock_requests(instance->host); instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; return; l_failed: -#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 3)) \ - || (defined(CONFIG_SUSE_KERNEL) && ((CONFIG_SUSE_VERSION == 15) \ - && (CONFIG_SUSE_PATCHLEVEL >= 2)))) - pci_aer_clear_nonfatal_status(pdev); -#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) - pci_cleanup_aer_uncorrect_error_status(pdev); +#if defined(PS3_AER_CLEAR_STATUS) + pci_aer_clear_nonfatal_status(pdev); +#elif defined(PS3_AER_CLEAR_STATUS_LOW_KERNER) + pci_cleanup_aer_uncorrect_error_status(pdev); #endif - if (instance) { + if (instance) ps3_instance_state_transfer_to_dead(instance); - } instance->pci_err_handle_state = PS3_DEVICE_ERR_STATE_NORMAL; - return; } - diff --git a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h index 81f1361789ad..05b8d06644fa 100644 --- a/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h +++ b/drivers/scsi/linkdata/ps3stor/linux/ps3_pcie_err_handle.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_PCIE_ERR_HANDLE_H_ #define _PS3_PCIE_ERR_HANDLE_H_ @@ -7,7 +7,7 @@ #include "ps3_instance_manager.h" #ifdef __cplusplus -extern "C"{ +extern "C" { #endif void ps3_pci_err_handler_init(struct pci_driver *drv); @@ -16,6 +16,10 @@ int ps3_base_init_resources(struct ps3_instance *instance); void ps3_base_free_resources(struct ps3_instance *instance); +int ps3_pci_init(struct pci_dev *pdev, struct ps3_instance *instance); +int ps3_pci_init_complete(struct ps3_instance *instance); +void ps3_pci_init_complete_exit(struct ps3_instance *instance); + #ifdef __cplusplus } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c index ce5eb6e1d26e..c11ab59f815e 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.c @@ -1,5 +1,5 @@ - -#ifndef _WINDOWS +// SPDX-License-Identifier: GPL-2.0 +#ifndef _WINDOWS #include #include #include @@ -27,64 +27,79 @@ #include "ps3_ioc_state.h" #include "ps3_mgr_cmd.h" -static S32 ps3_req_frame_alloc(struct ps3_instance *instance); +static int ps3_req_frame_alloc(struct ps3_instance *instance); static void ps3_req_frame_free(struct ps3_instance *instance); -static S32 ps3_cmd_resp_frame_alloc(struct ps3_instance *instance); +static int ps3_cmd_resp_frame_alloc(struct ps3_instance *instance); static void ps3_cmd_resp_frame_free(struct ps3_instance *instance); -static S32 ps3_cmd_buf_alloc(struct ps3_instance *instance); +static int ps3_cmd_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_buf_free(struct ps3_instance *instance); -static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance); +static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_ext_buf_free(struct ps3_instance *instance); -static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance); +static int ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance); static void ps3_cmd_r1xlock_buff_free(struct ps3_instance *instance); -static S32 ps3_cmd_init(struct ps3_instance *instance); +static int ps3_cmd_init(struct ps3_instance *instance); static void ps3_cmd_content_init(struct ps3_cmd *cmd); -static inline Bool is_mgr_cmd(struct ps3_instance *instance, U32 index); -static inline Bool is_task_cmd(struct ps3_instance *instance, U32 index); -static void cmd_pool_free(ps3_list_head *pool_list, - ps3_spinlock *pool_lock, struct ps3_cmd *cmd); -static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, - ps3_spinlock *pool_lock); - -#define PS3_RESP_FRAME_LENGH (PS3_SENSE_BUFFER_SIZE + 32) - -static inline Bool is_mgr_cmd(struct ps3_instance *instance, U32 index) +static inline unsigned char is_mgr_cmd(struct ps3_instance *instance, + unsigned int index); +static inline unsigned char is_task_cmd(struct ps3_instance *instance, + unsigned int index); +static void cmd_pool_free(struct list_head *pool_list, spinlock_t *pool_lock, + struct ps3_cmd *cmd); +static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, + spinlock_t *pool_lock); +#define PS3_RESP_FRAME_LENGTH (PS3_SENSE_BUFFER_SIZE + 32) + +static inline unsigned char is_mgr_cmd(struct ps3_instance *instance, + unsigned int index) { index -= instance->cmd_context.max_scsi_cmd_count; - return index < instance->max_mgr_cmd_count ? PS3_DRV_TRUE : PS3_DRV_FALSE; + return index < instance->max_mgr_cmd_count ? PS3_DRV_TRUE : + PS3_DRV_FALSE; } -static inline Bool is_task_cmd(struct ps3_instance *instance, U32 index) +static inline unsigned char is_task_cmd(struct ps3_instance *instance, + unsigned int index) { - index -= (instance->cmd_context.max_scsi_cmd_count + instance->max_mgr_cmd_count); - return index < instance->max_task_cmd_count ? PS3_DRV_TRUE : PS3_DRV_FALSE; + index -= (instance->cmd_context.max_scsi_cmd_count + + instance->max_mgr_cmd_count); + return index < instance->max_task_cmd_count ? PS3_DRV_TRUE : + PS3_DRV_FALSE; } -static inline Bool is_r1x_peer_cmd(struct ps3_instance *instance, U32 index) +static inline unsigned char is_r1x_peer_cmd(struct ps3_instance *instance, + unsigned int index) { struct ps3_cmd_context *cmd_ctx = &instance->cmd_context; - return ((cmd_ctx->max_scsi_cmd_count - cmd_ctx->max_r1x_cmd_count) <= index && + + return ((cmd_ctx->max_scsi_cmd_count - cmd_ctx->max_r1x_cmd_count) <= + index && index < cmd_ctx->max_scsi_cmd_count) ? - PS3_DRV_TRUE : PS3_DRV_FALSE; + PS3_DRV_TRUE : + PS3_DRV_FALSE; } -struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, U32 index) +struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, + unsigned int index) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - U32 offset = context->max_scsi_cmd_count - context->max_r1x_cmd_count; + unsigned int offset = + context->max_scsi_cmd_count - context->max_r1x_cmd_count; + if (instance->r1x_mode == PS3_R1X_MODE_PERF) { cmd = context->cmd_buf[index + offset]; cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_trace_id_alloc(&cmd->trace_id); init_completion(&cmd->sync_done); } else { - cmd = cmd_pool_alloc(&context->r1x_scsi_cmd_pool, &context->r1x_scsi_pool_lock); + cmd = cmd_pool_alloc(&context->r1x_scsi_cmd_pool, + &context->r1x_scsi_pool_lock); if (cmd != NULL && cmd->is_aborting == 1) { cmd->cmd_state.state = PS3_CMD_STATE_INIT; cmd->trace_id = 0; INJECT_START(PS3_ERR_IJ_SET_CMD_TID_FLAG, cmd); - cmd_pool_free(&context->r1x_scsi_cmd_pool, &context->r1x_scsi_pool_lock, cmd); + cmd_pool_free(&context->r1x_scsi_cmd_pool, + &context->r1x_scsi_pool_lock, cmd); cmd = NULL; } INJECT_START(PS3_ERR_IJ_SET_CMD_TID_FLAG, cmd); @@ -95,13 +110,14 @@ struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, U32 index) struct ps3_cmd *ps3_mgr_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; + return cmd_pool_alloc(&context->mgr_cmd_pool, &context->mgr_pool_lock); } -S32 ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - ULong flags = 0; + int ret = PS3_SUCCESS; + unsigned long flags = 0; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); ret = ps3_mgr_cmd_free_nolock(instance, cmd); @@ -117,16 +133,15 @@ struct ps3_cmd *ps3_task_cmd_alloc(struct ps3_instance *instance) context = &instance->cmd_context; cmd = cmd_pool_alloc(&context->task_cmd_pool, &context->task_pool_lock); - if (cmd == NULL) { + if (cmd == NULL) cmd = ps3_mgr_cmd_alloc(instance); - } return cmd; } -S32 ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; (void)instance; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -136,25 +151,26 @@ S32 ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -static S32 ps3_req_frame_alloc(struct ps3_instance *instance) +static int ps3_req_frame_alloc(struct ps3_instance *instance) { - U32 size = 0; + unsigned int size = 0; struct ps3_cmd_context *context = &instance->cmd_context; size = PS3_DEFAULT_REQ_FRAME_SIZE * context->max_cmd_count; - context->req_frame_dma_pool = (struct dma_pool *) ps3_dma_pool_create( - "PS3 req frame pool",&instance->pdev->dev, size, + context->req_frame_dma_pool = (struct dma_pool *)ps3_dma_pool_create( + "PS3 req frame pool", &instance->pdev->dev, size, DMA_ALIGN_BYTES_256, 0); - INJECT_START(PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, &context->req_frame_dma_pool); + INJECT_START(PS3_ERR_IJ_PS3_REQ_FRAME_BUF_ALLOC, + &context->req_frame_dma_pool); if (!context->req_frame_dma_pool) { LOG_ERROR("Failed to setup frame pool\n"); goto l_create_dma_pool_failed; } - context->req_frame_buf = (U8*)ps3_dma_pool_alloc(instance, - context->req_frame_dma_pool, - GFP_KERNEL, &context->req_frame_buf_phys); + context->req_frame_buf = (unsigned char *)ps3_dma_pool_alloc( + instance, context->req_frame_dma_pool, GFP_KERNEL, + &context->req_frame_buf_phys); if (!context->req_frame_buf) { LOG_ERROR("Failed to alloc frame dma memory\n"); goto l_free_mem; @@ -177,8 +193,8 @@ static void ps3_req_frame_free(struct ps3_instance *instance) #ifndef _WINDOWS if (context->req_frame_buf) { ps3_dma_pool_free(context->req_frame_dma_pool, - context->req_frame_buf, - context->req_frame_buf_phys); + context->req_frame_buf, + context->req_frame_buf_phys); context->req_frame_buf = NULL; } if (context->req_frame_dma_pool) { @@ -187,39 +203,43 @@ static void ps3_req_frame_free(struct ps3_instance *instance) } #else if (context->req_frame_buf != NULL) { - ps3_dma_free_coherent(instance, - context->req_frame_buf_size, - context->req_frame_buf, - context->req_frame_buf_phys); + ps3_dma_free_coherent(instance, context->req_frame_buf_size, + context->req_frame_buf, + context->req_frame_buf_phys); context->req_frame_buf = NULL; context->req_frame_buf_size = 0; } #endif } -static S32 ps3_cmd_resp_frame_alloc(struct ps3_instance *instance) +static int ps3_cmd_resp_frame_alloc(struct ps3_instance *instance) { - U32 sense_size = 0; + unsigned int sense_size = 0; struct ps3_cmd_context *context = &instance->cmd_context; - sense_size = PS3_RESP_FRAME_LENGH * context->max_cmd_count; + sense_size = PS3_RESP_FRAME_LENGTH * context->max_cmd_count; - context->response_frame_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 respSense pool", - &instance->pdev->dev, sense_size, - DMA_ALIGN_BYTES_4K, 0); + context->response_frame_dma_pool = + (struct dma_pool *)ps3_dma_pool_create("PS3 respSense pool", + &instance->pdev->dev, + sense_size, + DMA_ALIGN_BYTES_4K, 0); if (!context->response_frame_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); goto l_failed_alloc; } - context->response_frame_buf = (U8*)ps3_dma_pool_alloc(instance, context->response_frame_dma_pool, - GFP_KERNEL, &context->response_frame_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, &context->response_frame_buf); + context->response_frame_buf = (unsigned char *)ps3_dma_pool_alloc( + instance, context->response_frame_dma_pool, GFP_KERNEL, + &context->response_frame_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_RESP_FRAME_BUF_ALLOC, + &context->response_frame_buf); if (!context->response_frame_buf) { LOG_ERROR("Failed to alloc sense dma memory\n"); goto l_free_mem; } - ps3_get_so_addr_ranger(instance, context->response_frame_buf_phys, sense_size); + ps3_get_so_addr_ranger(instance, context->response_frame_buf_phys, + sense_size); return PS3_SUCCESS; l_free_mem: @@ -238,7 +258,8 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) #ifndef _WINDOWS if (context->response_frame_buf) { ps3_dma_pool_free(context->response_frame_dma_pool, - context->response_frame_buf, context->response_frame_buf_phys); + context->response_frame_buf, + context->response_frame_buf_phys); context->response_frame_buf = NULL; } if (context->response_frame_dma_pool) { @@ -248,9 +269,9 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) #else if (context->response_frame_buf != NULL) { ps3_dma_free_coherent(instance, - context->response_frame_buf_size, - context->response_frame_buf, - context->response_frame_buf_phys); + context->response_frame_buf_size, + context->response_frame_buf, + context->response_frame_buf_phys); context->response_frame_buf = NULL; context->response_frame_buf_size = 0; } @@ -259,17 +280,18 @@ static void ps3_cmd_resp_frame_free(struct ps3_instance *instance) static void ps3_cmd_mgr_trans_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) { + if (context->cmd_buf == NULL) return; - } for (i = 0; i < instance->max_mgr_cmd_count; i++) { if (context->cmd_buf) { - cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + i]; + cmd = context->cmd_buf[instance->cmd_context + .max_scsi_cmd_count + + i]; if (cmd && cmd->transient) { ps3_kfree(instance, cmd->transient); cmd->transient = NULL; @@ -278,18 +300,20 @@ static void ps3_cmd_mgr_trans_free(struct ps3_instance *instance) } } -static S32 ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) +static int ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd; struct ps3_cmd_context *context = &instance->cmd_context; for (i = 0; i < instance->max_mgr_cmd_count; i++) { - cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + i]; + cmd = context->cmd_buf[instance->cmd_context.max_scsi_cmd_count + + i]; - cmd->transient = (struct ps3_ioctl_transient *) - ps3_kzalloc(instance, sizeof(struct ps3_ioctl_transient)); - INJECT_START(PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, &cmd->transient); + cmd->transient = (struct ps3_ioctl_transient *)ps3_kzalloc( + instance, sizeof(struct ps3_ioctl_transient)); + INJECT_START(PS3_ERR_IJ_PS3_IOCTL_TRANSIENT_ALLOC, + &cmd->transient); if (cmd->transient == NULL) { LOG_ERROR("Failed to alloc sge dma memory\n"); goto l_free; @@ -299,21 +323,21 @@ static S32 ps3_cmd_mgr_trans_alloc(struct ps3_instance *instance) l_free: ps3_cmd_mgr_trans_free(instance); return -PS3_FAILED; - } -static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) +static int ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) { - U32 i = 0; - U32 sge_frame_size = 0; + unsigned int i = 0; + unsigned int sge_frame_size = 0; struct ps3_cmd *cmd; struct ps3_cmd_context *context = &instance->cmd_context; sge_frame_size = sizeof(struct PS3Sge) * context->ext_sge_frame_count; - context->ext_buf_size = PS3_MAX(sge_frame_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE); + context->ext_buf_size = + PS3_MAX(sge_frame_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE); #ifndef _WINDOWS - context->ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 ext buf pool", - &instance->pdev->dev, context->ext_buf_size, + context->ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create( + "PS3 ext buf pool", &instance->pdev->dev, context->ext_buf_size, PS3_CMD_EXT_BUF_DEFAULT_SIZE, 0); if (!context->ext_buf_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); @@ -322,8 +346,10 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->ext_buf_dma_pool, - GFP_KERNEL, &cmd->ext_buf_phys); + cmd->ext_buf = + ps3_dma_pool_zalloc(instance, context->ext_buf_dma_pool, + GFP_KERNEL, + (dma_addr_t *)&cmd->ext_buf_phys); INJECT_START(PS3_ERR_IJ_PS3_EXT_BUF_ALLOC, &cmd->ext_buf); if (!cmd->ext_buf) { LOG_ERROR("Failed to alloc scsi ext buf memory\n"); @@ -332,9 +358,9 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) } context->mgr_ext_buf_size = PS3_CMD_EXT_BUF_SIZE_MGR; - context->mgr_ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create("PS3 mgr ext buf pool", - &instance->pdev->dev, context->ext_buf_size, - PS3_CMD_EXT_BUF_SIZE_MGR, 0); + context->mgr_ext_buf_dma_pool = (struct dma_pool *)ps3_dma_pool_create( + "PS3 mgr ext buf pool", &instance->pdev->dev, + context->ext_buf_size, PS3_CMD_EXT_BUF_SIZE_MGR, 0); if (!context->mgr_ext_buf_dma_pool) { LOG_ERROR("Failed to setup sense pool\n"); goto l_failed_alloc; @@ -342,8 +368,9 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_pool_zalloc(instance, context->mgr_ext_buf_dma_pool, - GFP_KERNEL, &cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_pool_zalloc( + instance, context->mgr_ext_buf_dma_pool, GFP_KERNEL, + (dma_addr_t *)&cmd->ext_buf_phys); INJECT_START(PS3_ERR_IJ_PS3_MGR_EXT_BUF_ALLOC, &cmd->ext_buf); if (!cmd->ext_buf) { LOG_ERROR("Failed to alloc mgr ext buf memory\n"); @@ -355,12 +382,13 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) l_free_sge: ps3_cmd_ext_buf_free(instance); l_failed_alloc: - return -PS3_FAILED; + return -PS3_FAILED; #else for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_alloc_coherent(instance, context->ext_buf_size, - &cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_alloc_coherent( + instance, context->ext_buf_size, + (unsigned long long *)&cmd->ext_buf_phys); if (cmd->ext_buf == NULL) { LOG_ERROR("Failed to alloc scsi ext buf memory\n"); goto l_failed; @@ -370,8 +398,9 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) context->mgr_ext_buf_size = PS3_CMD_EXT_BUF_SIZE_MGR; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - cmd->ext_buf = ps3_dma_alloc_coherent(instance, context->mgr_ext_buf_size, - &cmd->ext_buf_phys); + cmd->ext_buf = ps3_dma_alloc_coherent( + instance, context->mgr_ext_buf_size, + (unsigned long long *)&cmd->ext_buf_phys); if (cmd->ext_buf == NULL) { LOG_ERROR("Failed to alloc mgr ext buf memory\n"); goto l_failed; @@ -389,20 +418,18 @@ static S32 ps3_cmd_ext_buf_alloc(struct ps3_instance *instance) static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) { + if (context->cmd_buf == NULL) return; - } #ifndef _WINDOWS for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_pool_free(context->ext_buf_dma_pool, - cmd->ext_buf, - cmd->ext_buf_phys); + cmd->ext_buf, cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -416,8 +443,7 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_pool_free(context->mgr_ext_buf_dma_pool, - cmd->ext_buf, - cmd->ext_buf_phys); + cmd->ext_buf, cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -431,8 +457,7 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { ps3_dma_free_coherent(instance, context->ext_buf_size, - cmd->ext_buf, - cmd->ext_buf_phys); + cmd->ext_buf, cmd->ext_buf_phys); cmd->ext_buf = NULL; } } @@ -440,21 +465,21 @@ static void ps3_cmd_ext_buf_free(struct ps3_instance *instance) for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; if ((cmd != NULL) && (cmd->ext_buf != NULL)) { - ps3_dma_free_coherent(instance, context->mgr_ext_buf_size, - cmd->ext_buf, - cmd->ext_buf_phys); + ps3_dma_free_coherent(instance, + context->mgr_ext_buf_size, + cmd->ext_buf, cmd->ext_buf_phys); cmd->ext_buf = NULL; } } #endif } -static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) +static int ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_context *context = &instance->cmd_context; struct ps3_cmd *cmd = NULL; - U32 node_buff_size = ps3_r1x_get_node_Buff_size(); + unsigned int node_buff_size = ps3_r1x_get_node_Buff_size(); for (i = 0; i < context->max_scsi_cmd_count; i++) { cmd = context->cmd_buf[i]; @@ -462,7 +487,8 @@ static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) cmd->node_buff = ps3_kzalloc(instance, node_buff_size); INJECT_START(PS3_ERR_IJ_PS3_R1XLOCK_BUF_ALLOC, &cmd->node_buff); if (!cmd->node_buff) { - LOG_ERROR("Failed to alloc r1x write lock range node buf memory\n"); + LOG_ERROR( + "Failed to alloc r1x write lock range node buf memory\n"); goto l_free_node; } } @@ -476,46 +502,44 @@ static S32 ps3_cmd_r1xlock_buff_alloc(struct ps3_instance *instance) static void ps3_cmd_r1xlock_buff_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - struct ps3_cmd* cmd = NULL; + struct ps3_cmd *cmd = NULL; - if (context->cmd_buf == NULL) { + if (context->cmd_buf == NULL) return; - } for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; - if(cmd != NULL) { + if (cmd != NULL) { cmd->szblock_cnt = 0; - if(cmd->node_buff != NULL){ + if (cmd->node_buff != NULL) { ps3_kfree(instance, cmd->node_buff); cmd->node_buff = NULL; } } } - - return; } -static S32 ps3_cmd_buf_alloc(struct ps3_instance *instance) +static int ps3_cmd_buf_alloc(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - context->cmd_buf = (struct ps3_cmd**)ps3_kcalloc(instance, context->max_cmd_count, - sizeof(struct ps3_cmd*)); + context->cmd_buf = (struct ps3_cmd **)ps3_kcalloc( + instance, context->max_cmd_count, sizeof(struct ps3_cmd *)); INJECT_START(PS3_ERR_IJ_PS3_CMD_BUF_ALLOC, &context->cmd_buf); if (context->cmd_buf == NULL) { LOG_ERROR("Failed to kcalloc memory for cmd_buf\n"); goto l_failed; } memset(context->cmd_buf, 0, - sizeof(struct ps3_cmd*) * context->max_cmd_count); + sizeof(struct ps3_cmd *) * context->max_cmd_count); for (i = 0; i < context->max_cmd_count; i++) { - context->cmd_buf[i] = (struct ps3_cmd*)ps3_kzalloc(instance, - sizeof(struct ps3_cmd)); - INJECT_START(PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, &context->cmd_buf[i]); + context->cmd_buf[i] = (struct ps3_cmd *)ps3_kzalloc( + instance, sizeof(struct ps3_cmd)); + INJECT_START(PS3_ERR_IJ_PS3_PS3_CMD_ALLOC, + &context->cmd_buf[i]); if (context->cmd_buf[i] == NULL) { LOG_ERROR("Failed to malloc memory for ps3_cmd\n"); goto l_failed; @@ -537,14 +561,13 @@ static S32 ps3_cmd_buf_alloc(struct ps3_instance *instance) static void ps3_cmd_buf_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) { + if (context->cmd_buf == NULL) goto l_out; - } - while(i < context->max_cmd_count && context->cmd_buf[i]) { + while (i < context->max_cmd_count && context->cmd_buf[i]) { ps3_kfree(instance, context->cmd_buf[i]); context->cmd_buf[i] = NULL; i++; @@ -562,11 +585,11 @@ static void ps3_cmd_buf_free(struct ps3_instance *instance) return; } -static S32 ps3_cmd_init(struct ps3_instance *instance) +static int ps3_cmd_init(struct ps3_instance *instance) { - U16 i = 0; - S32 ret = PS3_SUCCESS; - U32 offset = 0; + unsigned short i = 0; + int ret = PS3_SUCCESS; + unsigned int offset = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; @@ -574,43 +597,44 @@ static S32 ps3_cmd_init(struct ps3_instance *instance) for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; if (!cmd) { - LOG_ERROR("Failed ps3_cmd_init \n"); + LOG_ERROR("Failed %s\n", __func__); ret = -PS3_FAILED; goto l_out; } cmd->instance = instance; - offset = i * PS3_RESP_FRAME_LENGH; - cmd->resp_frame = (PS3RespFrame_u *) - (context->response_frame_buf + offset); - cmd->resp_frame_phys = context->response_frame_buf_phys + offset; + offset = i * PS3_RESP_FRAME_LENGTH; + cmd->resp_frame = + (union PS3RespFrame *)(context->response_frame_buf + + offset); + cmd->resp_frame_phys = + context->response_frame_buf_phys + offset; cmd->index = i; cmd->is_aborting = 0; #ifndef _WINDOWS cmd->scmd = NULL; #endif offset = i * PS3_DEFAULT_REQ_FRAME_SIZE; - cmd->req_frame = (union PS3ReqFrame *) - (context->req_frame_buf + offset); + cmd->req_frame = + (union PS3ReqFrame *)(context->req_frame_buf + offset); cmd->req_frame_phys = context->req_frame_buf_phys + offset; ps3_spin_lock_init(&cmd->cmd_state.lock); ps3_cmd_content_init(cmd); if (is_r1x_peer_cmd(instance, i)) { if (instance->r1x_mode == PS3_R1X_MODE_NORMAL) { list_add_tail(&cmd->cmd_list, - &context->r1x_scsi_cmd_pool); + &context->r1x_scsi_cmd_pool); } - } else if (is_task_cmd(instance,i)) { + } else if (is_task_cmd(instance, i)) { list_add_tail(&cmd->cmd_list, &context->task_cmd_pool); init_completion(&cmd->sync_done); - } else if (is_mgr_cmd(instance,i)) { + } else if (is_mgr_cmd(instance, i)) { list_add_tail(&cmd->cmd_list, &context->mgr_cmd_pool); init_completion(&cmd->sync_done); } #ifdef _WINDOWS - else { + else list_add_tail(&cmd->cmd_list, &context->scsi_cmd_pool); - } #endif } @@ -618,126 +642,185 @@ static S32 ps3_cmd_init(struct ps3_instance *instance) return ret; } -static inline void ps3_host_max_sge_count(struct ps3_cmd_context *context) +int ps3_ext_sge_cnt_calc_hba(struct ps3_instance *instance) +{ + int ret = PS3_SUCCESS; + int sge_cnt_cfg = ps3_max_sge_cnt_query(); + unsigned int max_chain_size = 0; + + if (ps3_ioc_mgr_debug10_get(instance, &max_chain_size) && + (max_chain_size >= PS3_CMD_EXT_BUF_DEFAULT_SIZE)) + goto l_set_sge_cnt; + + if (!ps3_ioc_mgr_max_chain_size_get(instance, &max_chain_size)) { + ret = -PS3_FAILED; + goto l_out; + } + +l_set_sge_cnt: + instance->cmd_context.ext_sge_frame_count = max_chain_size / sizeof(struct PS3Sge); + + if (sge_cnt_cfg >= PS3_MAX_SGE_CNT) + instance->cmd_context.ext_sge_frame_count = + PS3_MIN(PS3_MAX_SGE_CNT, instance->cmd_context.ext_sge_frame_count); + else + instance->cmd_context.ext_sge_frame_count = PS3_DEFAULT_EXT_SGE_CNT; + +l_out: + return ret; +} + +int ps3_ext_sge_cnt_calc_raid(struct ps3_instance *instance) +{ + int ret = PS3_SUCCESS; + if (!ps3_ioc_mgr_max_chain_size_get(instance, + &instance->cmd_context.ext_sge_frame_count)) { + ret = -PS3_FAILED; + } else + instance->cmd_context.ext_sge_frame_count /= sizeof(struct PS3Sge); + + return ret; +} + +void ps3_max_sge_cfg_hba(struct ps3_instance *instance) +{ + int sge_cnt_cfg = ps3_max_sge_cnt_query(); + + if (sge_cnt_cfg == PS3_DEFAULT_SGE_CNT) + goto l_out; + + if (sge_cnt_cfg < PS3_DEFAULT_EXT_SGE_CNT) + sge_cnt_cfg = PS3_MIN_SGE_CNT; + else if(sge_cnt_cfg < PS3_MAX_SGE_CNT) + sge_cnt_cfg = PS3_DEFAULT_EXT_SGE_CNT; + else + sge_cnt_cfg = PS3_MAX_SGE_CNT; + + if (sge_cnt_cfg < instance->cmd_context.max_host_sge_count) + instance->cmd_context.max_host_sge_count = sge_cnt_cfg; +l_out: + return; +} + +static inline void ps3_host_max_sge_count(struct ps3_instance *instance) { + struct ps3_cmd_context *context = &instance->cmd_context; context->max_host_sge_count = PS3_FRAME_REQ_SGE_NUM_HW; if (context->sgl_mode_support) { if (context->ext_sge_frame_count > PS3_FRAME_REQ_EXT_SGE_MIN) { - context->max_host_sge_count += (U16)context->ext_sge_frame_count - PS3_FRAME_REQ_EXT_SGE_MIN; + context->max_host_sge_count += + (unsigned short)context->ext_sge_frame_count - + PS3_FRAME_REQ_EXT_SGE_MIN; } } else if (context->ext_sge_frame_count > 1) { - context->max_host_sge_count = PS3_MAX((U16)(context->ext_sge_frame_count - 1), + context->max_host_sge_count = PS3_MAX( + (unsigned short)(context->ext_sge_frame_count - 1), context->max_host_sge_count); } + + if (instance->ioc_adpter->max_sge_config != NULL) + instance->ioc_adpter->max_sge_config(instance); } static inline void ps3_r1x_mode_set(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; - if (context->max_r1x_cmd_count >= context->max_scsi_cmd_count / 2) { + + if (context->max_r1x_cmd_count >= context->max_scsi_cmd_count / 2) instance->r1x_mode = PS3_R1X_MODE_PERF; - } - LOG_INFO("host_no:%u r1x_mode:%u\n", PS3_HOST(instance), instance->r1x_mode); + LOG_INFO("host_no:%u r1x_mode:%u\n", PS3_HOST(instance), + instance->r1x_mode); } -S32 ps3_cmd_context_init(struct ps3_instance *instance) +int ps3_cmd_context_init(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_cmd_context *context = &instance->cmd_context; int cpu = 0; - S64 *scsi_cmd_deliver = NULL; + long long *scsi_cmd_deliver = NULL; - if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &context->max_cmd_count)) { + if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &context->max_cmd_count)) goto l_failed; - } #ifdef PS3_HARDWARE_SIM context->max_r1x_cmd_count = 16; #else if (!ps3_get_max_r1x_cmds_with_check(instance, - &context->max_r1x_cmd_count)) { + &context->max_r1x_cmd_count)) { goto l_failed; } #endif - LOG_DEBUG("host_no:%u max_r1x_cmd_count:%u\n", - PS3_HOST(instance), context->max_r1x_cmd_count); + LOG_DEBUG("host_no:%u max_r1x_cmd_count:%u\n", PS3_HOST(instance), + context->max_r1x_cmd_count); context->max_mgr_cmd_count = instance->max_mgr_cmd_total_count; - context->max_scsi_cmd_count = context->max_cmd_count - - instance->max_mgr_cmd_total_count; + context->max_scsi_cmd_count = + context->max_cmd_count - instance->max_mgr_cmd_total_count; - if (context->max_r1x_cmd_count > (context->max_scsi_cmd_count / 2 )) { + if (context->max_r1x_cmd_count > (context->max_scsi_cmd_count / 2)) context->max_r1x_cmd_count = (context->max_scsi_cmd_count / 2); - } ps3_r1x_mode_set(instance); - LOG_DEBUG("host_no:%u max_r1x_cmd_final count:%u\n", - PS3_HOST(instance), context->max_r1x_cmd_count); + LOG_DEBUG("host_no:%u max_r1x_cmd_final count:%u\n", PS3_HOST(instance), + context->max_r1x_cmd_count); - if (!ps3_ioc_mgr_max_chain_size_get(instance, - &context->ext_sge_frame_count)) { - goto l_failed; + if (instance->ioc_adpter->ext_sge_cnt_calc != NULL) { + if (instance->ioc_adpter->ext_sge_cnt_calc(instance) != PS3_SUCCESS) + goto l_failed; } - context->ext_sge_frame_count /= sizeof(struct PS3Sge); - if (!ps3_ioc_mgr_max_nvme_page_size_get(instance, - &instance->cmd_attr.nvme_page_size)) { + if (!ps3_ioc_mgr_max_nvme_page_size_get( + instance, &instance->cmd_attr.nvme_page_size)) { goto l_failed; } - context->max_prp_count = PS3_FRAME_REQ_PRP_NUM_FE + - (instance->cmd_attr.nvme_page_size / sizeof(U64)); + context->max_prp_count = + PS3_FRAME_REQ_PRP_NUM_FE + (instance->cmd_attr.nvme_page_size / + sizeof(unsigned long long)); - ps3_host_max_sge_count(context); + ps3_host_max_sge_count(instance); if (context->max_cmd_count <= instance->max_mgr_cmd_total_count) { - LOG_ERROR("max_cmd_count %d too few\n", - context->max_cmd_count); + LOG_ERROR("max_cmd_count %d too few\n", context->max_cmd_count); goto l_failed; } ret = ps3_cmd_buf_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_req_frame_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_cmd_resp_frame_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_cmd_ext_buf_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_cmd_r1xlock_buff_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_cmd_mgr_trans_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } ret = ps3_cmd_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_failed; - } - instance->scsi_cmd_deliver = alloc_percpu(S64); + instance->scsi_cmd_deliver = alloc_percpu(long long); INJECT_START(PS3_ERR_IJ_PS3_PERCPU_ALLOC, &instance->scsi_cmd_deliver); if (!instance->scsi_cmd_deliver) { LOG_ERROR("alloc per_cpu scsi_cmd_deliver failed. hno:%u\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } else { for_each_possible_cpu(cpu) { - scsi_cmd_deliver = per_cpu_ptr(instance->scsi_cmd_deliver, cpu); + scsi_cmd_deliver = + per_cpu_ptr(instance->scsi_cmd_deliver, cpu); *scsi_cmd_deliver = 0; } } @@ -798,21 +881,23 @@ static void ps3_cmd_content_init(struct ps3_cmd *cmd) cmd->r1x_read_pd = 0; memset(&cmd->io_attr, 0, sizeof(struct ps3_scsi_io_attr)); - memset((void*)&cmd->sync_done, 0, sizeof(cmd->sync_done)); - if (cmd->transient == NULL || cmd->transient->sge_num == 0) { - memset((void*)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); - } + cmd->io_attr.target_pd_state = 0xff; + memset((void *)&cmd->sync_done, 0, sizeof(cmd->sync_done)); + if (cmd->transient == NULL || cmd->transient->sge_num == 0) + memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); - memset((void*)cmd->resp_frame, 0xff, sizeof(PS3RespFrame_u)); + memset((void *)cmd->resp_frame, 0xff, sizeof(union PS3RespFrame)); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); INIT_LIST_HEAD(&cmd->qos_list); - memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); + memset(&cmd->target_pd, 0, + sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); cmd->target_pd_count = 0; cmd->first_over_quota_pd_idx = 0; cmd->qos_waitq_flag = 0; - memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); + memset(&cmd->cmdq_info, 0, + sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); cmd->cmdq_count = 0; } @@ -848,42 +933,48 @@ static void ps3_scsi_cmd_content_init(struct ps3_cmd *cmd) cmd->is_r1x_scsi_complete = PS3_FALSE; cmd->flighting = PS3_FALSE; cmd->r1x_read_pd = 0; + cmd->vd_rd_outstand_flag = PS3_FALSE; + cmd->vd_wr_outstand_flag = PS3_FALSE; - if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length != 0) { - memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); + if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length != + 0) { + memset(cmd->ext_buf, 0, + cmd->instance->cmd_context.ext_buf_size); } if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) && - (cmd->transient == NULL || cmd->transient->sge_num == 0)) { - memset((void*)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + (cmd->transient == NULL || cmd->transient->sge_num == 0)) { + memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); } - if (cmd->resp_frame->normalRespFrame.respStatus != 0xFF) { + if (cmd->resp_frame->normalRespFrame.respStatus != 0xFF) cmd->resp_frame->normalRespFrame.respStatus = 0xFF; - } - if (cmd->resp_frame->sasRespFrame.status != 0xFF) { + if (cmd->resp_frame->sasRespFrame.status != 0xFF) cmd->resp_frame->sasRespFrame.status = 0xFF; - } - memset((void*)&cmd->sync_done, 0, sizeof(cmd->sync_done)); + memset((void *)&cmd->sync_done, 0, sizeof(cmd->sync_done)); memset(&cmd->io_attr, 0, sizeof(struct ps3_scsi_io_attr)); + cmd->io_attr.target_pd_state = 0xff; INIT_LIST_HEAD(&cmd->qos_list); - memset(&cmd->target_pd, 0, sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); + memset(&cmd->target_pd, 0, + sizeof(struct ps3_qos_member_pd_info) * PS3_QOS_MAX_PD_IN_VD); cmd->target_pd_count = 0; cmd->first_over_quota_pd_idx = 0; cmd->qos_waitq_flag = 0; - memset(&cmd->cmdq_info, 0, sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); + memset(&cmd->cmdq_info, 0, + sizeof(struct ps3_qos_cmdq_info) * PS3_QOS_MAX_CMDQ_ONE_CMD); cmd->cmdq_count = 0; } #ifndef _WINDOWS -struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag) +struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, + unsigned int tag) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - if (tag < (U32)instance->cmd_attr.cur_can_que) { + if (tag < (unsigned int)instance->cmd_attr.cur_can_que) { cmd = context->cmd_buf[tag]; cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_trace_id_alloc(&cmd->trace_id); @@ -892,11 +983,11 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag) return cmd; } -S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd) +int ps3_scsi_cmd_free(struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; - if (cmd->index < (U32)cmd->instance->cmd_attr.cur_can_que) { + if (cmd->index < (unsigned int)cmd->instance->cmd_attr.cur_can_que) { ps3_scsi_cmd_content_init(cmd); ret = PS3_SUCCESS; } @@ -907,11 +998,12 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - ULong flags = 0; + unsigned long flags = 0; ps3_spin_lock_irqsave(&context->scsi_pool_lock, &flags); if (!list_empty(&context->scsi_cmd_pool)) { - cmd = list_entry(list_remove_head(&context->scsi_cmd_pool), struct ps3_cmd, cmd_list); + cmd = list_entry(list_remove_head(&context->scsi_cmd_pool), + struct ps3_cmd, cmd_list); } ps3_spin_unlock_irqrestore(&context->scsi_pool_lock, flags); @@ -922,16 +1014,15 @@ struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance) return cmd; } -S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd) +int ps3_scsi_cmd_free(struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; - U32 max_count = 0; - ULong flags = 0; + int ret = -PS3_FAILED; + unsigned int max_count = 0; + unsigned long flags = 0; struct ps3_cmd_context *context = &cmd->instance->cmd_context; - if (unlikely(cmd == NULL)) { + if (unlikely(cmd == NULL)) goto l_out; - } max_count = context->max_scsi_cmd_count; if (cmd->index < max_count) { @@ -947,20 +1038,21 @@ S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd) } #endif -static void cmd_pool_free(ps3_list_head *pool_list, - ps3_spinlock *pool_lock, struct ps3_cmd *cmd) +static void cmd_pool_free(struct list_head *pool_list, spinlock_t *pool_lock, + struct ps3_cmd *cmd) { - ULong flags = 0; + unsigned long flags = 0; + ps3_spin_lock_irqsave(pool_lock, &flags); list_add_tail(&cmd->cmd_list, pool_list); ps3_spin_unlock_irqrestore(pool_lock, flags); } -static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, - ps3_spinlock *pool_lock) +static struct ps3_cmd *cmd_pool_alloc(struct list_head *pool_list, + spinlock_t *pool_lock) { struct ps3_cmd *cmd = NULL; - ULong flags = 0; + unsigned long flags = 0; #ifdef _WINDOWS struct ps3_cmd_context *context = NULL; #endif @@ -975,7 +1067,7 @@ static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, } ps3_spin_unlock_irqrestore(pool_lock, flags); - if(cmd != NULL) { + if (cmd != NULL) { #ifndef _WINDOWS ps3_trace_id_alloc(&cmd->trace_id); #else @@ -989,9 +1081,9 @@ static struct ps3_cmd *cmd_pool_alloc(ps3_list_head *pool_list, return cmd; } -Bool ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) +unsigned char ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; struct ps3_cmd_context *context = NULL; struct ps3_instance *instance = cmd->instance; @@ -1001,22 +1093,21 @@ Bool ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd) goto l_out; } - if(cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) goto l_out; - } ps3_scsi_cmd_content_init(cmd); if (instance->r1x_mode == PS3_R1X_MODE_NORMAL) { cmd_pool_free(&context->r1x_scsi_cmd_pool, - &context->r1x_scsi_pool_lock, cmd); + &context->r1x_scsi_pool_lock, cmd); } l_out: return ret; } -S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd_context *context = NULL; context = &instance->cmd_context; @@ -1025,21 +1116,20 @@ S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) goto l_out; } - if(cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) goto l_out; - } ps3_cmd_content_init(cmd); INJECT_START(PS3_ERR_FORCE_SET_CMD_INDEX_NOT_MGR, &cmd->index); if (is_task_cmd(instance, cmd->index)) { - cmd_pool_free(&context->task_cmd_pool, - &context->task_pool_lock, cmd); + cmd_pool_free(&context->task_cmd_pool, &context->task_pool_lock, + cmd); } else if (is_mgr_cmd(instance, cmd->index)) { - cmd_pool_free(&context->mgr_cmd_pool, - &context->mgr_pool_lock, cmd); + cmd_pool_free(&context->mgr_cmd_pool, &context->mgr_pool_lock, + cmd); } else { LOG_INFO_IN_IRQ(instance, "host_no:%u CFID:%u not mgr cmd!\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); PS3_BUG(); ret = -PS3_FAILED; } @@ -1047,30 +1137,40 @@ S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int ret = PS3_SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - mb(); + mb(); /* in order to force CPU ordering */ ret = ps3_cmd_send_pre_check(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) + goto l_out; + if (instance->is_suspend) { + LOG_FILE_INFO("host_no:%u instance state state is suspending\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; goto l_out; } cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cmd == instance->event_context.event_cmd) { - INJECT_START(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, &cur_state) - } +#ifdef PS3_SUPPORT_INJECT + if (cmd == instance->event_context.event_cmd) + INJECT_START(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, &cur_state); +#endif if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { if (instance->is_probe_finish && !instance->is_resume) { - LOG_FILE_ERROR("host_no:%u cannot send async cmd due to %s, return fail\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_FILE_ERROR( + "host_no:%u cannot send async cmd due to %s, return fail\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } else { - LOG_FILE_WARN("host_no:%u cannot send async cmd due to %s, return recovered\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_FILE_WARN( + "host_no:%u cannot send async cmd due to %s, return recovered\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); ret = -PS3_RECOVERED; } goto l_out; @@ -1084,13 +1184,11 @@ S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) #ifndef _WINDOWS static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, - struct ps3_cmd *peer_cmd) + struct ps3_cmd *peer_cmd) { - memcpy(peer_cmd->req_frame, cmd->req_frame, - sizeof(union PS3ReqFrame)); - memcpy((void*)&peer_cmd->io_attr, (void*)&cmd->io_attr, - sizeof(struct ps3_scsi_io_attr)); - memcpy(peer_cmd->ext_buf, cmd->ext_buf, cmd->instance->cmd_context.ext_buf_size); + memcpy(peer_cmd->req_frame, cmd->req_frame, sizeof(union PS3ReqFrame)); + memcpy((void *)&peer_cmd->io_attr, (void *)&cmd->io_attr, + sizeof(struct ps3_scsi_io_attr)); peer_cmd->scmd = cmd->scmd; peer_cmd->is_got_r1x = cmd->is_got_r1x; @@ -1098,11 +1196,13 @@ static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, peer_cmd->os_sge_map_count = cmd->os_sge_map_count; peer_cmd->cmd_receive_cb = cmd->cmd_receive_cb; peer_cmd->io_attr.pd_entry = cmd->io_attr.peer_pd_entry; - peer_cmd->io_attr.disk_id = PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); + peer_cmd->io_attr.disk_id = + PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); peer_cmd->io_attr.plba = cmd->io_attr.plba_back; peer_cmd->cmd_word_value = cmd->cmd_word_value; - peer_cmd->cmd_word.phyDiskID = PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); + peer_cmd->cmd_word.phyDiskID = + PS3_PDID(&peer_cmd->io_attr.pd_entry->disk_pos); peer_cmd->cmd_word.cmdFrameID = peer_cmd->index; peer_cmd->req_frame->hwReq.reqHead.cmdFrameID = peer_cmd->index; @@ -1117,19 +1217,20 @@ static void ps3_r1x_peer_cmd_build(struct ps3_cmd *cmd, cmd->is_r1x_scsi_complete = PS3_FALSE; peer_cmd->is_r1x_scsi_complete = PS3_FALSE; - LOG_DEBUG("host_no:%u r1x direct write cmd:%d, peer cmd:%d build:" - " tid:0x%llx pid:%u plba:0x%llx\n", - PS3_HOST(cmd->instance), cmd->index, peer_cmd->index, - peer_cmd->trace_id, peer_cmd->cmd_word.phyDiskID, - peer_cmd->io_attr.plba); + LOG_DEBUG( + "hno:%u r1x direct write cmd:%d, peer cmd:%d build: tid:0x%llx pid:%u plba:0x%llx\n", + PS3_HOST(cmd->instance), cmd->index, peer_cmd->index, + peer_cmd->trace_id, peer_cmd->cmd_word.phyDiskID, + peer_cmd->io_attr.plba); } -static struct ps3_cmd* ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static struct ps3_cmd *ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, + struct ps3_cmd *cmd) { struct ps3_cmd *peer_cmd = NULL; + if (cmd->io_attr.direct_flag != PS3_CMDWORD_DIRECT_ADVICE || - cmd->io_attr.peer_pd_entry == NULL) { + cmd->io_attr.peer_pd_entry == NULL) { goto _lout; } @@ -1137,7 +1238,8 @@ static struct ps3_cmd* ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, if (peer_cmd != NULL) { ps3_r1x_peer_cmd_build(cmd, peer_cmd); } else { - LOG_DEBUG("host_no:%u cmd:%d can not alloc r1x peer cmd any more\n", + LOG_DEBUG( + "host_no:%u cmd:%d can not alloc r1x peer cmd any more\n", PS3_HOST(instance), cmd->index); instance->ioc_adpter->io_cmd_rebuild(cmd); } @@ -1145,27 +1247,33 @@ static struct ps3_cmd* ps3_r1x_scsi_peer_prepare(struct ps3_instance *instance, return peer_cmd; } -void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, Bool time_out) +void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, + unsigned char time_out) { int cpu = 0; - S64 result = 0; - U16 try_cnt = 0; + long long result = 0; + unsigned short try_cnt = 0; if (instance->scsi_cmd_deliver) { do { result = 0; for_each_possible_cpu(cpu) { - result += *per_cpu_ptr(instance->scsi_cmd_deliver, cpu); + result += *per_cpu_ptr( + instance->scsi_cmd_deliver, cpu); } if (result > 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); if (time_out) { try_cnt++; - if (try_cnt > PS3_WAIT_SCSI_CMD_DONE_COUNT) { - LOG_WARN("hno:%u wait scsi cmd done NOK\n", + if (try_cnt > + PS3_WAIT_SCSI_CMD_DONE_COUNT) { + LOG_WARN( + "hno:%u wait scsi cmd done NOK\n", PS3_HOST(instance)); - INJECT_START(PS3_ERR_IJ_WAIT_SCSI_CMD_DONE_FAIL, instance); + INJECT_START( + PS3_ERR_IJ_WAIT_SCSI_CMD_DONE_FAIL, + instance); break; } } @@ -1174,12 +1282,13 @@ void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, Bool time_out) } LOG_INFO("wait scsi cmd done end. hno:%u try_cnt[%u]\n", - PS3_HOST(instance), try_cnt); + PS3_HOST(instance), try_cnt); } void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance) { - S64 *cmd_deliver = NULL; + long long *cmd_deliver = NULL; + cmd_deliver = get_cpu_ptr(instance->scsi_cmd_deliver); (*cmd_deliver)++; put_cpu_ptr(cmd_deliver); @@ -1187,49 +1296,53 @@ void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance) void ps3_scsi_cmd_deliver_put(struct ps3_instance *instance) { - S64 *cmd_deliver = NULL; + long long *cmd_deliver = NULL; + cmd_deliver = get_cpu_ptr(instance->scsi_cmd_deliver); (*cmd_deliver)--; put_cpu_ptr(cmd_deliver); } -void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out) +void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, + unsigned char time_out) { - U16 try_cnt = 0; + unsigned short try_cnt = 0; while (ps3_atomic_read(&instance->cmd_statistics.cmd_delivering) != 0) { - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, instance); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_2, + instance); ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); if (time_out) { try_cnt++; if (try_cnt > PS3_WAIT_SCSI_CMD_DONE_COUNT) { LOG_WARN("hno:%u wait mgr cmd done NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); break; } } } LOG_INFO("wait mgr cmd done end. hno:%u try_cnt[%u]\n", - PS3_HOST(instance), try_cnt); + PS3_HOST(instance), try_cnt); } -S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err) +int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned char need_prk_err) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *peer_cmd = NULL; ret = ps3_cmd_send_pre_check(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SCSI_DELIVER_DELAY); INJECT_START(PS3_ERR_IJ_WAIT_TASK_MGR_BUSY, instance); INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance); if (unlikely(instance->task_manager_host_busy)) { INJECT_START(PS3_ERR_IJ_SEND_CMD_TASK_MGR_BUSY, instance); - LOG_INFO_LIM_WITH_CHECK(instance, need_prk_err, + LOG_INFO_LIM_WITH_CHECK( + instance, need_prk_err, "host_no:%u cannot send block cmd due to task_manager_host_busy\n", PS3_HOST(instance)); @@ -1237,10 +1350,12 @@ S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool n goto l_out; } - INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_INS_UNLOAD, instance) + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_INS_UNLOAD, instance); if (!instance->state_machine.is_load) { - LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, - "host_no:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_WARN_LIM_WITH_CHECK( + instance, need_prk_err, + "host_no:%u instance state not is_load\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1261,7 +1376,7 @@ S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool n PS3_DEV_IO_OUTSTAND_INC(instance, cmd); PS3_IO_DRV2IOC_START_INC(instance, cmd); cmd->flighting = PS3_FALSE; - wmb(); + wmb(); /* in order to force CPU ordering */ INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); ps3_ioc_scsi_cmd_send(instance, &cmd->cmd_word); @@ -1276,19 +1391,23 @@ S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool n } #endif -struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id) +struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, + unsigned short cmd_frame_id) { struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; + if (cmd_frame_id >= context->max_cmd_count) { LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d invalid\n", - PS3_HOST(instance), cmd_frame_id); + PS3_HOST(instance), cmd_frame_id); goto l_failed; } cmd = context->cmd_buf[cmd_frame_id]; if (cmd->index != cmd_frame_id) { - LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d incorrect, expect CFID:%d\n", + LOG_ERROR_IN_IRQ( + instance, + "host_no:%u CFID:%d incorrect, expect CFID:%d\n", PS3_HOST(instance), cmd_frame_id, cmd->index); cmd = NULL; goto l_failed; @@ -1298,54 +1417,61 @@ struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id) return cmd; } -S32 ps3_cmd_dispatch(struct ps3_instance *instance, U16 cmd_frame_id, struct PS3ReplyWord *reply_word) +int ps3_cmd_dispatch(struct ps3_instance *instance, unsigned short cmd_frame_id, + struct PS3ReplyWord *reply_word) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; - U16 reply_flags = 0xff; + unsigned short reply_flags = 0xff; if (reply_word->retType == PS3_HARD_RET && - reply_word->retStatus == PS3_REPLY_WORD_FLAG_REPEAT_REPLY) { - LOG_ERROR_IN_IRQ(instance, "hno:%u repeated response CFID:%u reply_word:0x%llx\n", - PS3_HOST(instance), cmd_frame_id, *(U64 *)reply_word); + reply_word->retStatus == PS3_REPLY_WORD_FLAG_REPEAT_REPLY) { + LOG_ERROR_IN_IRQ( + instance, + "hno:%u repeated response CFID:%u reply_word:0x%llx\n", + PS3_HOST(instance), cmd_frame_id, + *(unsigned long long *)reply_word); goto l_out; } cmd = ps3_cmd_find(instance, cmd_frame_id); - if (cmd == NULL) { + if (cmd == NULL) goto l_out; - } memcpy(&(cmd->reply_word), reply_word, sizeof(struct PS3ReplyWord)); reply_flags = reply_word->retStatus; if (cmd->cmd_receive_cb) { ret = cmd->cmd_receive_cb(cmd, reply_flags); } else { - LOG_ERROR_IN_IRQ(instance, "warn ps3 cmd index %d has no cmd_receive_cb\n", + LOG_ERROR_IN_IRQ( + instance, + "warn ps3 cmd index %d has no cmd_receive_cb\n", cmd->index); } l_out: return ret; } -Bool ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) +unsigned char +ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + unsigned char ret = PS3_TRUE; + int cur_state = PS3_INSTANCE_STATE_INIT; cur_state = ps3_atomic_read(&instance->state_machine.state); - INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &cur_state) - INJECT_START(PS3_ERR_IJ_INS_STATE_DEAD, &cur_state) + INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &cur_state); + INJECT_START(PS3_ERR_IJ_INS_STATE_DEAD, &cur_state); INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_STATE_UNNORMAL, instance); INJECT_START(PS3_ERR_IJ_V2_FORCE_INS_DEAD, instance); if (cur_state == PS3_INSTANCE_STATE_DEAD && - (PS3_IOC_STATE_HALT_SUPPORT(instance) == PS3_TRUE) && - PS3_HALT_CLI_SUPPORT(instance)){ + (PS3_IOC_STATE_HALT_SUPPORT(instance) == PS3_TRUE) && + PS3_HALT_CLI_SUPPORT(instance)) { goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { - LOG_FILE_INFO("host_no:%u cannot handle cmd, driver state: %s\n", + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + LOG_FILE_INFO( + "host_no:%u cannot handle cmd, driver state: %s\n", PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = PS3_FALSE; } @@ -1354,18 +1480,20 @@ Bool ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance) return ret; } -S32 ps3_cmd_send_pre_check(struct ps3_instance *instance) +int ps3_cmd_send_pre_check(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (instance->is_probe_finish && !instance->state_machine.is_load) { LOG_FILE_INFO("host_no:%u instance state state is unloading\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_PCI_ERR, instance) + INJECT_START(PS3_ERR_IJ_CMD_SEND_FORCE_PCI_ERR, instance); if (ps3_pci_err_recovery_get(instance)) { - LOG_FILE_WARN("host_no:%u cannot send block cmd due to pci err recovery\n", + LOG_FILE_WARN( + "host_no:%u cannot send block cmd due to pci err recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -1374,13 +1502,15 @@ S32 ps3_cmd_send_pre_check(struct ps3_instance *instance) return ret; } -S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check) +int ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, + unsigned char no_check) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); if (!no_check && !instance->state_machine.is_load) { LOG_WARN_LIM("hno[%u] instance state not is_load\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_IN_UNLOAD; goto l_out; } @@ -1392,7 +1522,7 @@ S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check) INJECT_START(PS3_ERR_IJ_V2_PCIE_ERR, instance); if (ps3_pci_err_recovery_get(instance)) { LOG_WARN_LIM("hno[%u] host in pci err recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } @@ -1400,14 +1530,14 @@ S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check) return ret; } -S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + int ret = PS3_SUCCESS; + int cur_state = ps3_atomic_read(&instance->state_machine.state); INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE, instance); if (!instance->state_machine.is_load) { - if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { ret = -PS3_IN_UNLOAD; goto l_failed; } @@ -1417,12 +1547,14 @@ S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_RECOVERED; if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - cur_state = ps3_atomic_read(&instance->state_machine.state); + cur_state = + ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { + cur_state == PS3_INSTANCE_STATE_DEAD) { goto l_failed; } - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_BUSY; ret = -PS3_RESP_ERR; } goto l_failed; @@ -1435,15 +1567,18 @@ S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd) goto l_out; l_failed: - LOG_WARN_LIM("hno:%u, tid:0x%llx CFID:%u type:%d state:%d send check ret:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, PS3_MGR_CMD_TYPE(cmd), cur_state, ret); + LOG_WARN_LIM( + "hno:%u, tid:0x%llx CFID:%u type:%d state:%d send check ret:%d\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + PS3_MGR_CMD_TYPE(cmd), cur_state, ret); l_out: return ret; } -void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos) +void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, + unsigned char bit_pos) { - U32 i = 0; + unsigned int i = 0; struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct ps3_debug_context *debug_context = &instance->debug_context; @@ -1452,162 +1587,220 @@ void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos) struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; struct ps3_cmd *cmd = NULL; - irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, - irq_context->reply_fifo_desc_buf_phys); - irq_context->reply_fifo_desc_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + irq_context->reply_fifo_desc_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, irq_context->reply_fifo_desc_buf_phys); for (; i < irq_context->valid_msix_vector_count; i++) { irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); - irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, - irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); - irq_context->reply_fifo_phys_base_addr_buf[i] = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, irq_context->reply_fifo_desc_buf[i] + .ReplyFifoBaseAddr); + irq_context->reply_fifo_desc_buf[i] + .ReplyFifoBaseAddr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + irq_context->reply_fifo_desc_buf[i].ReplyFifoBaseAddr); + irq_context->reply_fifo_phys_base_addr_buf[i] = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, irq_context->reply_fifo_phys_base_addr_buf[i]); - irq_context->reply_fifo_phys_base_addr_buf[i] = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + irq_context->reply_fifo_phys_base_addr_buf[i] = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, irq_context->reply_fifo_phys_base_addr_buf[i]); } - cmd_context->init_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_buf_phys); - cmd_context->init_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->init_frame_buf_phys); + cmd_context->init_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd_context->init_frame_buf_phys); + cmd_context->init_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, cmd_context->init_frame_buf_phys); cmd_context->init_filter_table_phy_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_filter_table_phy_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd_context->init_filter_table_phy_addr); cmd_context->init_filter_table_phy_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->init_filter_table_phy_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + cmd_context->init_filter_table_phy_addr); if (cmd_context->init_frame_sys_info_buf != NULL) { cmd_context->init_frame_sys_info_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->init_frame_sys_info_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd_context->init_frame_sys_info_phys); cmd_context->init_frame_sys_info_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->init_frame_sys_info_phys); - } - instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->ctrl_info_buf_h); - instance->ctrl_info_buf_h = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->ctrl_info_buf_h); - cmd_context->req_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->req_frame_buf_phys); - cmd_context->req_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->req_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + cmd_context->init_frame_sys_info_phys); + } + instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, instance->ctrl_info_buf_h); + instance->ctrl_info_buf_h = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, instance->ctrl_info_buf_h); + cmd_context->req_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd_context->req_frame_buf_phys); + cmd_context->req_frame_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, cmd_context->req_frame_buf_phys); cmd_context->response_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd_context->response_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd_context->response_frame_buf_phys); cmd_context->response_frame_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd_context->response_frame_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + cmd_context->response_frame_buf_phys); for (i = 0; i < cmd_context->max_cmd_count; i++) { cmd = cmd_context->cmd_buf[i]; if (cmd->ext_buf != NULL) { - cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, cmd->ext_buf_phys); - cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, cmd->ext_buf_phys); + cmd->ext_buf_phys = + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, cmd->ext_buf_phys); + cmd->ext_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, cmd->ext_buf_phys); } } if (debug_context->debug_mem_buf != NULL) { debug_context->debug_mem_buf_phy = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, debug_context->debug_mem_buf_phy); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, debug_context->debug_mem_buf_phy); debug_context->debug_mem_buf_phy = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, debug_context->debug_mem_buf_phy); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + debug_context->debug_mem_buf_phy); for (i = 0; i < debug_context->debug_mem_array_num; i++) { - debug_context->debug_mem_buf[i].debugMemAddr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, - debug_context->debug_mem_buf[i].debugMemAddr); debug_context->debug_mem_buf[i].debugMemAddr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, - debug_context->debug_mem_buf[i].debugMemAddr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, debug_context->debug_mem_buf[i] + .debugMemAddr); + debug_context->debug_mem_buf[i].debugMemAddr = + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + debug_context->debug_mem_buf[i] + .debugMemAddr); } } if (dump_context->dump_dma_buf != NULL) { dump_context->dump_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dump_context->dump_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dump_context->dump_dma_addr); dump_context->dump_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dump_context->dump_dma_addr); - } - instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->drv_info_buf_phys); - instance->drv_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->drv_info_buf_phys); - instance->host_mem_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->host_mem_info_buf_phys); - instance->host_mem_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->host_mem_info_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dump_context->dump_dma_addr); + } + instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, instance->drv_info_buf_phys); + instance->drv_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, instance->drv_info_buf_phys); + instance->host_mem_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, instance->host_mem_info_buf_phys); + instance->host_mem_info_buf_phys = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, instance->host_mem_info_buf_phys); if (dev_context->pd_list_buf != NULL) { dev_context->pd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dev_context->pd_list_buf_phys); dev_context->pd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->pd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dev_context->pd_list_buf_phys); } if (dev_context->pd_info_buf != NULL) { dev_context->pd_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->pd_info_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dev_context->pd_info_buf_phys); dev_context->pd_info_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->pd_info_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dev_context->pd_info_buf_phys); } if (dev_context->vd_list_buf != NULL) { dev_context->vd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dev_context->vd_list_buf_phys); dev_context->vd_list_buf_phys = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_list_buf_phys); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dev_context->vd_list_buf_phys); } if (dev_context->vd_info_buf_sync != NULL) { dev_context->vd_info_buf_phys_sync = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_sync); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dev_context->vd_info_buf_phys_sync); dev_context->vd_info_buf_phys_sync = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_info_buf_phys_sync); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dev_context->vd_info_buf_phys_sync); } if (dev_context->vd_info_buf_async != NULL) { dev_context->vd_info_buf_phys_async = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dev_context->vd_info_buf_phys_async); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, dev_context->vd_info_buf_phys_async); dev_context->vd_info_buf_phys_async = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, dev_context->vd_info_buf_phys_async); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + dev_context->vd_info_buf_phys_async); } if (ps3_sas_ctx->ps3_sas_buff != NULL) { ps3_sas_ctx->ps3_sas_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); ps3_sas_ctx->ps3_sas_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ps3_sas_ctx->ps3_sas_buff_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + ps3_sas_ctx->ps3_sas_buff_dma_addr); } if (ps3_sas_ctx->ps3_sas_phy_buff != NULL) { ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, + ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ps3_sas_ctx->ps3_sas_phy_buff_dma_addr = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); - } - instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_start_addr); - instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->so_start_addr); - instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, instance->so_end_addr); - instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, instance->so_end_addr); + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, + ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + } + instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, instance->so_start_addr); + instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, instance->so_start_addr); + instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, instance->so_end_addr); + instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, instance->so_end_addr); } -Bool ps3_bit_pos_update(struct ps3_instance *instance) +unsigned char ps3_bit_pos_update(struct ps3_instance *instance) { - U8 old_bit_pos = instance->dma_addr_bit_pos; - U8 bit_pos = 0; - Bool ret = PS3_FALSE; + unsigned char old_bit_pos = instance->dma_addr_bit_pos; + unsigned char bit_pos = 0; + unsigned char ret = PS3_FALSE; - if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) { + if (!ps3_ioc_atu_support_retry_read(instance, &bit_pos)) goto l_out; - } - switch(bit_pos) { - case PS3_BIT_POS_DEFAULT: - case PS3_BIT_POS_44: - instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; - break; - case PS3_BIT_POS_53: - instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; - break; - case PS3_BIT_POS_54: - instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; - break; - default: - LOG_WARN("hno:%u bit pos value is unexpect %u\n", + switch (bit_pos) { + case PS3_BIT_POS_DEFAULT: + case PS3_BIT_POS_44: + instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; + break; + case PS3_BIT_POS_53: + instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; + break; + case PS3_BIT_POS_54: + instance->dma_addr_bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; + break; + default: + LOG_WARN("hno:%u bit pos value is unexpect %u\n", PS3_HOST(instance), bit_pos); - goto l_out; + goto l_out; } - mb(); + mb(); /* in order to force CPU ordering */ if (instance->dma_addr_bit_pos == old_bit_pos) { ret = PS3_TRUE; goto l_out; } ps3_dma_addr_bit_pos_update(instance, old_bit_pos); - LOG_WARN("hno:%u bit pos %u change to %u\n", - PS3_HOST(instance), old_bit_pos, instance->dma_addr_bit_pos); + LOG_WARN("hno:%u bit pos %u change to %u\n", PS3_HOST(instance), + old_bit_pos, instance->dma_addr_bit_pos); ret = PS3_TRUE; l_out: return ret; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h index 5d579a29ecb9..7a063f03f64b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_channel.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CMD_CHANNEL_H_ #define _PS3_CMD_CHANNEL_H_ @@ -14,37 +14,38 @@ #include "ps3_inner_data.h" #include "ps3_driver_log.h" #include "ps3_htp_ioctl.h" +#include "ps3_kernel_version.h" #define PS3_DEFAULT_REQ_FRAME_SIZE (256) #define PS3_WAIT_SCSI_CMD_DONE_COUNT (1200) enum { - DMA_ALIGN_BYTES_4K = 4096, - DMA_ALIGN_BYTES_2K = 2048, - DMA_ALIGN_BYTES_1K = 1024, - DMA_ALIGN_BYTES_512 = 512, - DMA_ALIGN_BYTES_256 = 256, - DMA_ALIGN_BYTES_128 = 128, - DMA_ALIGN_BYTES_64 = 64, - DMA_ALIGN_BYTES_16 = 16, - DMA_ALIGN_BYTES_4 = 4, + DMA_ALIGN_BYTES_4K = 4096, + DMA_ALIGN_BYTES_2K = 2048, + DMA_ALIGN_BYTES_1K = 1024, + DMA_ALIGN_BYTES_512 = 512, + DMA_ALIGN_BYTES_256 = 256, + DMA_ALIGN_BYTES_128 = 128, + DMA_ALIGN_BYTES_64 = 64, + DMA_ALIGN_BYTES_16 = 16, + DMA_ALIGN_BYTES_4 = 4, }; enum { - PS3_CMD_STATE_INIT = 0, - PS3_CMD_STATE_PROCESS = 1, - PS3_CMD_STATE_COMPLETE = 2, - PS3_CMD_STATE_DEAD = 3, + PS3_CMD_STATE_INIT = 0, + PS3_CMD_STATE_PROCESS = 1, + PS3_CMD_STATE_COMPLETE = 2, + PS3_CMD_STATE_DEAD = 3, }; enum { - PS3_CMD_FLAG_SOFTRESET = 1, - PS3_CMD_FLAG_HARDRESET = 2, + PS3_CMD_FLAG_SOFTRESET = 1, + PS3_CMD_FLAG_HARDRESET = 2, }; enum { - PS3_R1X_MODE_NORMAL = 0, - PS3_R1X_MODE_PERF = 1, + PS3_R1X_MODE_NORMAL = 0, + PS3_R1X_MODE_PERF = 1, }; #define PS3_CMD_EXT_BUF_DEFAULT_SIZE (4096) @@ -52,201 +53,207 @@ enum { #define PS3_MIN_SCSI_CMD_COUNT (4096) -static inline const S8 *namePS3CmdState(U32 s) +static inline const char *namePS3CmdState(unsigned int s) { - static const S8 *myNames[] = { - [PS3_CMD_STATE_INIT] = "PS3_CMD_STATE_INIT", - [PS3_CMD_STATE_PROCESS] = "PS3_CMD_STATE_PROCESS", - [PS3_CMD_STATE_COMPLETE] = "PS3_CMD_STATE_COMPLETE", - [PS3_CMD_STATE_DEAD] = "PS3_CMD_STATE_DEAD" + static const char * const myNames[] = { + [PS3_CMD_STATE_INIT] = "PS3_CMD_STATE_INIT", + [PS3_CMD_STATE_PROCESS] = "PS3_CMD_STATE_PROCESS", + [PS3_CMD_STATE_COMPLETE] = "PS3_CMD_STATE_COMPLETE", + [PS3_CMD_STATE_DEAD] = "PS3_CMD_STATE_DEAD" }; - if (s > PS3_CMD_STATE_DEAD) { + if (s > PS3_CMD_STATE_DEAD) return "PS3_CMD_STATE_INVALID"; - } return myNames[s]; } struct ps3_cmd_state_t { - U8 state; - U8 reset_flag; - U8 reserived[6]; - ps3_spinlock lock; + unsigned char state; + unsigned char reset_flag; + unsigned char reserived[6]; + spinlock_t lock; }; -typedef union ps3_scsi_cdb_option { - struct { - U8 non_ncq : 1; - U8 reserved0 : 1; - U8 reserved1 : 1; - U8 fua : 1; - U8 dpo : 1; - U8 protect : 3; - }; - U8 option; -} ps3_scsi_cdb_opts_u; - -struct ps3_scsi_io_attr -{ - Bool is_retry_cmd; - U8 direct_flag; - U8 seq_flag; - U8 dev_type; - union - { - struct{ - U8 rw_flag : 7; - U8 is_confilct_check : 1; +union ps3_scsi_cdb_option { + struct { + unsigned char non_ncq : 1; + unsigned char reserved0 : 1; + unsigned char reserved1 : 1; + unsigned char fua : 1; + unsigned char dpo : 1; + unsigned char protect : 3; + }; + unsigned char option; +}; + +struct ps3_scsi_io_attr { + unsigned char is_retry_cmd; + unsigned char direct_flag; + unsigned char seq_flag; + unsigned char dev_type; + union { + struct { + unsigned char rw_flag : 7; + unsigned char is_confilct_check : 1; }; - U8 rw_type; + unsigned char rw_type; }; - U32 num_blocks; - U32 lba_lo; - U32 lba_hi; + unsigned int num_blocks; + unsigned int lba_lo; + unsigned int lba_hi; const struct ps3_pd_entry *pd_entry; const struct ps3_pd_entry *peer_pd_entry; const struct PS3VDEntry *vd_entry; - U64 plba; - U64 plba_back; - U8 span_idx; - U8 span_pd_idx; - U16 disk_id; - Bool is_use_frontend_prp; - U8 span_pd_idx_p; - U8 span_pd_idx_q; - U8 is_force_normal:1; - U8 reserved:7; - ps3_scsi_cdb_opts_u cdb_opts; - U8 cdb[PS3_FRAME_CDB_BUFLEN]; - U32 sgl_buf_len; - U32 reserved1; + unsigned long long plba; + unsigned long long plba_back; + unsigned char span_idx; + unsigned char span_pd_idx; + unsigned short disk_id; + unsigned char is_use_frontend_prp; + unsigned char span_pd_idx_p; + unsigned char span_pd_idx_q; + unsigned char is_force_normal : 1; +#ifdef PS3_NCQ_PRIO_SUPPORT + unsigned char is_ncq_prio_enable:1; + unsigned char reserved:6; +#else + unsigned char reserved:7; +#endif + union ps3_scsi_cdb_option cdb_opts; + unsigned char cdb[PS3_FRAME_CDB_BUFLEN]; + unsigned int sgl_buf_len; + unsigned char target_pd_state; + unsigned int reserved1; }; struct ps3_ioctl_transient { - U16 sge_num; - U8 reserved[6]; + unsigned short sge_num; + unsigned char reserved[6]; void *transient_buff[PS3_MAX_IOCTL_SGE_NUM]; }; #define PS3_QOS_MAX_PD_IN_VD (17) struct ps3_qos_member_pd_info { - U16 flat_disk_id; - U16 strip_count; - Bool get_quota; + unsigned short flat_disk_id; + unsigned short strip_count; + unsigned char get_quota; }; #define PS3_QOS_MAX_CMDQ_ONE_CMD 2 struct ps3_qos_cmdq_info { - U8 que_id; - Bool get_rc; + unsigned char que_id; + unsigned char get_rc; }; struct ps3_cmd { union PS3ReqFrame *req_frame; - U64 req_frame_phys; + unsigned long long req_frame_phys; void *ext_buf; - U64 ext_buf_phys; - PS3RespFrame_u *resp_frame; - U64 resp_frame_phys; + unsigned long long ext_buf_phys; + union PS3RespFrame *resp_frame; + unsigned long long resp_frame_phys; struct ps3_instance *instance; union { - struct PS3CmdWord cmd_word; - struct PS3InitCmdWord init_cmd_word; - U64 cmd_word_value; + struct PS3CmdWord cmd_word; + struct PS3InitCmdWord init_cmd_word; + unsigned long long cmd_word_value; }; - struct scsi_cmnd *scmd; + struct scsi_cmnd *scmd; #ifndef _WINDOWS struct list_head cmd_list; #else - SCSI_REQUEST_BLOCK *srb; - ps3_list_head cmd_list; + SCSI_REQUEST_BLOCK * srb; + struct list_head cmd_list; #endif - U64 trace_id; - U16 index; - U8 no_reply_word; - U8 is_force_polling; - U8 is_got_r1x; - U8 is_inserted_c_q; - U8 is_r1x_aborting; - Bool is_r1x_scsi_complete; - U16 r1x_read_pd; + unsigned long long trace_id; + unsigned short index; + unsigned char no_reply_word; + unsigned char is_force_polling; + unsigned char is_got_r1x; + unsigned char is_inserted_c_q; + unsigned char is_r1x_aborting; + unsigned char is_r1x_scsi_complete; + unsigned short r1x_read_pd; struct ps3_cmd *r1x_peer_cmd; - U8 is_aborting; - U8 r1x_reply_flag; - U8 qos_processing; - U32 os_sge_map_count; + unsigned char is_aborting; + unsigned char r1x_reply_flag; + unsigned char qos_processing; + unsigned int os_sge_map_count; struct ps3_cmd_state_t cmd_state; - U16 time_out; - Bool is_interrupt; - U8 szblock_cnt; - U32 retry_cnt; - void* node_buff; + unsigned short time_out; + unsigned char is_interrupt; + unsigned char szblock_cnt; + unsigned int retry_cnt; + void *node_buff; #ifdef _WINDOWS KEVENT sync_done; #else - struct completion sync_done; + struct completion sync_done; #endif - S32 (*cmd_send_cb)(struct ps3_instance *, struct ps3_cmd *, U16 ); - S32 (*cmd_receive_cb)(struct ps3_cmd *, U16); + int (*cmd_send_cb)(struct ps3_instance *, struct ps3_cmd *, + unsigned short); + int (*cmd_receive_cb)(struct ps3_cmd *cmd, unsigned short reply_flags); struct ps3_ioctl_transient *transient; struct ps3_scsi_io_attr io_attr; #ifdef _WINDOWS - struct scsi_cmnd scmd_imp; + struct scsi_cmnd scmd_imp; #endif - struct PS3ReplyWord reply_word; + struct PS3ReplyWord reply_word; struct list_head qos_list; struct ps3_qos_member_pd_info target_pd[PS3_QOS_MAX_PD_IN_VD]; struct ps3_qos_cmdq_info cmdq_info[PS3_QOS_MAX_CMDQ_ONE_CMD]; - U16 target_pd_count; - U16 first_over_quota_pd_idx; - U8 qos_waitq_flag; - U8 cmdq_count; - Bool flighting; + unsigned short target_pd_count; + unsigned short first_over_quota_pd_idx; + unsigned char qos_waitq_flag; + unsigned char cmdq_count; + unsigned char flighting; + unsigned char vd_rd_outstand_flag; + unsigned char vd_wr_outstand_flag; }; -struct ps3_cmd_context { - U32 max_cmd_count; - U32 max_scsi_cmd_count; - U32 max_mgr_cmd_count; - U32 max_prp_count; +struct ps3_cmd_context { + unsigned int max_cmd_count; + unsigned int max_scsi_cmd_count; + unsigned int max_mgr_cmd_count; + unsigned int max_prp_count; struct ps3_cmd **cmd_buf; - dma_addr_t init_frame_buf_phys; - U8 *init_frame_buf; - dma_addr_t init_filter_table_phy_addr; - U8 *init_filter_table_buff; + dma_addr_t init_frame_buf_phys; + unsigned char *init_frame_buf; + dma_addr_t init_filter_table_phy_addr; + unsigned char *init_filter_table_buff; #ifndef _WINDOWS - struct dma_pool* req_frame_dma_pool; + struct dma_pool *req_frame_dma_pool; #endif - U32 req_frame_buf_size; - dma_addr_t req_frame_buf_phys; - U8 *req_frame_buf; + unsigned int req_frame_buf_size; + dma_addr_t req_frame_buf_phys; + unsigned char *req_frame_buf; #ifndef _WINDOWS - struct dma_pool* response_frame_dma_pool; + struct dma_pool *response_frame_dma_pool; #endif - U32 response_frame_buf_size; - dma_addr_t response_frame_buf_phys; - U8 *response_frame_buf; + unsigned int response_frame_buf_size; + dma_addr_t response_frame_buf_phys; + unsigned char *response_frame_buf; #ifndef _WINDOWS - struct dma_pool* ext_buf_dma_pool; + struct dma_pool *ext_buf_dma_pool; #endif - U32 ext_buf_size; - U32 ext_sge_frame_count; + unsigned int ext_buf_size; + unsigned int ext_sge_frame_count; #ifndef _WINDOWS - struct dma_pool* mgr_ext_buf_dma_pool; + struct dma_pool *mgr_ext_buf_dma_pool; #endif - U32 mgr_ext_buf_size; + unsigned int mgr_ext_buf_size; - dma_addr_t init_frame_sys_info_phys; - U8 *init_frame_sys_info_buf; - U8 sgl_mode_support; - U8 reserved0[1]; - U16 max_host_sge_count; + dma_addr_t init_frame_sys_info_phys; + unsigned char *init_frame_sys_info_buf; + unsigned char sgl_mode_support; + unsigned char reserved0[1]; + unsigned short max_host_sge_count; #ifndef _WINDOWS struct list_head mgr_cmd_pool; @@ -256,89 +263,106 @@ struct ps3_cmd_context { spinlock_t task_pool_lock; spinlock_t r1x_scsi_pool_lock; #else - ps3_list_head mgr_cmd_pool; - ps3_list_head task_cmd_pool; - ps3_list_head scsi_cmd_pool; - ps3_spinlock mgr_pool_lock; - ps3_spinlock task_pool_lock; - ps3_spinlock scsi_pool_lock; - - ps3_atomic64 trace_id; + struct list_head mgr_cmd_pool; + struct list_head task_cmd_pool; + struct list_head scsi_cmd_pool; + spinlock_t mgr_pool_lock; + spinlock_t task_pool_lock; + spinlock_t scsi_pool_lock; + + atomic64_t trace_id; #endif - U16 max_r1x_cmd_count; - U8 reserved1[6]; + unsigned short max_r1x_cmd_count; + unsigned char reserved1[6]; }; -S32 ps3_cmd_context_init(struct ps3_instance *instance); +int ps3_cmd_context_init(struct ps3_instance *instance); void ps3_cmd_context_exit(struct ps3_instance *instance); #ifndef _WINDOWS -struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, U32 tag); +struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance, + unsigned int tag); #else struct ps3_cmd *ps3_scsi_cmd_alloc(struct ps3_instance *instance); #endif -S32 ps3_scsi_cmd_free(struct ps3_cmd *cmd); +int ps3_scsi_cmd_free(struct ps3_cmd *cmd); struct ps3_cmd *ps3_mgr_cmd_alloc(struct ps3_instance *instance); -S32 ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd); -S32 ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_mgr_cmd_free_nolock(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_mgr_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); struct ps3_cmd *ps3_task_cmd_alloc(struct ps3_instance *instance); -S32 ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_task_cmd_free(struct ps3_instance *instance, struct ps3_cmd *cmd); -S32 ps3_reply_cmd_dispatcher(struct ps3_instance *instance, U16 cmd_frame_id); +int ps3_reply_cmd_dispatcher(struct ps3_instance *instance, + unsigned short cmd_frame_id); -S32 ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_async_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd); #ifndef _WINDOWS -S32 ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, Bool need_prk_err); +int ps3_scsi_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned char need_prk_err); #endif -struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, U16 cmd_frame_id); +struct ps3_cmd *ps3_cmd_find(struct ps3_instance *instance, + unsigned short cmd_frame_id); -S32 ps3_cmd_dispatch(struct ps3_instance *instance, U16 cmd_frame_id, - struct PS3ReplyWord *reply_word); +int ps3_cmd_dispatch(struct ps3_instance *instance, unsigned short cmd_frame_id, + struct PS3ReplyWord *reply_word); -struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, U32 index); +struct ps3_cmd *ps3_r1x_peer_cmd_alloc(struct ps3_instance *instance, + unsigned int index); -Bool ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd); +unsigned char ps3_r1x_peer_cmd_free_nolock(struct ps3_cmd *cmd); -static inline U16 ps3_cmd_frame_id(struct ps3_cmd *cmd) +static inline unsigned short ps3_cmd_frame_id(struct ps3_cmd *cmd) { return cmd->index; } -static inline U64 ps3_cmd_trace_id(struct ps3_cmd *cmd) +static inline unsigned long long ps3_cmd_trace_id(struct ps3_cmd *cmd) { return cmd->trace_id; } -static inline void ps3_cmd_trace_id_replace(struct ps3_cmd *cmd, U64 trace_id) +static inline void ps3_cmd_trace_id_replace(struct ps3_cmd *cmd, + unsigned long long trace_id) { cmd->trace_id = trace_id; } -Bool ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance); +unsigned char +ps3_is_instance_state_allow_cmd_execute(struct ps3_instance *instance); -S32 ps3_cmd_send_pre_check(struct ps3_instance *instance); +int ps3_cmd_send_pre_check(struct ps3_instance *instance); -void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, Bool time_out); +void ps3_wait_scsi_cmd_done(struct ps3_instance *instance, + unsigned char time_out); void ps3_scsi_cmd_deliver_get(struct ps3_instance *instance); void ps3_scsi_cmd_deliver_put(struct ps3_instance *instance); -void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, U8 bit_pos); +void ps3_dma_addr_bit_pos_update(struct ps3_instance *instance, + unsigned char bit_pos); + +unsigned char ps3_bit_pos_update(struct ps3_instance *instance); + +void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, + unsigned char time_out); + +int ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, + unsigned char no_check); -Bool ps3_bit_pos_update(struct ps3_instance *instance); +int ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd); -void ps3_wait_mgr_cmd_done(struct ps3_instance *instance, Bool time_out); +int ps3_ext_sge_cnt_calc_hba(struct ps3_instance *instance); -S32 ps3_mgr_cmd_send_pre_check(struct ps3_instance *instance, Bool no_check); +int ps3_ext_sge_cnt_calc_raid(struct ps3_instance *instance); -S32 ps3_mgr_cmd_send_check(struct ps3_instance *instance, struct ps3_cmd *cmd); +void ps3_max_sge_cfg_hba(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c index 6b7fe76bcb34..9e00805484d9 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifdef _WINDOWS #else @@ -19,68 +19,69 @@ #include "ps3_ioc_manager.h" #include "ps3_scsi_cmd_err.h" -static inline Bool ps3_reply_word_is_valid(U64 val); +static inline unsigned char ps3_reply_word_is_valid(unsigned long long val); static inline void ps3_reply_word_next(struct ps3_irq *irq, - struct PS3ReplyWord **reply_word); -static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, - struct ps3_instance *instance, struct PS3ReplyWord* reply_word, - S32 *completed_count); -static inline struct PS3ReplyWord* ps3_reply_word_query( - struct ps3_irq *irq, U16 idx); - -S32 ps3_cmd_complete(struct ps3_irq *irq) + struct PS3ReplyWord **reply_word); +static int ps3_reply_fifo_traverse(struct ps3_irq *irq, + struct ps3_instance *instance, + struct PS3ReplyWord *reply_word, + int *completed_count); +static inline struct PS3ReplyWord *ps3_reply_word_query(struct ps3_irq *irq, + unsigned short idx); + +int ps3_cmd_complete(struct ps3_irq *irq) { - S32 ret = PS3_SUCCESS; - S32 completed_count = 0; + int ret = PS3_SUCCESS; + int completed_count = 0; struct PS3ReplyWord *reply_word = NULL; struct ps3_instance *instance = irq->instance; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int cur_state = PS3_INSTANCE_STATE_INIT; #ifndef _WINDOWS - LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, " - "irq_enable:%d, irq_poll:%d, last_reply_idx:%d, is_busy:%d\n", - PS3_HOST(irq->instance), irq->irqNo, irq->name, - irq->isrSN, irq->is_enable_irq, irq->is_sched_irq_poll, - irq->last_reply_idx, atomic_read(&irq->is_busy)); + LOG_DEBUG( + "hno:%u start isr_os:%d, name:%s sn:%d, en:%d, poll:%d, last_reply_idx:%d, is_busy:%d\n", + PS3_HOST(irq->instance), irq->irqNo, irq->name, irq->isrSN, + irq->is_enable_irq, irq->is_sched_irq_poll, + irq->last_reply_idx, atomic_read(&irq->is_busy)); #else - LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, " - "last_reply_idx:%d, is_busy:%d\n", - PS3_HOST(irq->instance), irq->irqNo, irq->name, - irq->isrSN, irq->last_reply_idx, ps3_atomic_read(&irq->is_busy)); + LOG_DEBUG("hno:%u start isr_os:%d, name:%s isr_sn:%d, last_reply_idx:%d, is_busy:%d\n", + PS3_HOST(irq->instance), irq->irqNo, irq->name, irq->isrSN, + irq->last_reply_idx, ps3_atomic_read(&irq->is_busy)); #endif cur_state = ps3_atomic_read(&instance->state_machine.state); - if (unlikely (cur_state == PS3_INSTANCE_STATE_QUIT) ) { + if (unlikely(cur_state == PS3_INSTANCE_STATE_QUIT)) { LOG_WARN_IN_IRQ(instance, "hno:%u instance state is quit\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } if (!ps3_irq_busy_add(irq)) { - LOG_INFO_IN_IRQ(instance, "hno:%u irq is_busy:%d\n", PS3_HOST(instance), - ps3_atomic_read(&irq->is_busy)); + LOG_INFO_IN_IRQ(instance, "hno:%u irq is_busy:%d\n", + PS3_HOST(instance), + ps3_atomic_read(&irq->is_busy)); goto l_out; } reply_word = ps3_reply_word_query(irq, irq->last_reply_idx); - if (!ps3_reply_word_is_valid(*(U64*)reply_word)) { + if (!ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) { ps3_irq_busy_dec(irq); LOG_DEBUG("hno:%u reply_w:0x%llx last_reply_idx:%d\n", - PS3_HOST(instance), *(U64*)reply_word, - irq->last_reply_idx); + PS3_HOST(instance), *(unsigned long long *)reply_word, + irq->last_reply_idx); goto l_out; } - ret = ps3_reply_fifo_traverse(irq, instance, - reply_word, &completed_count); + ret = ps3_reply_fifo_traverse(irq, instance, reply_word, + &completed_count); if (ret == -PS3_IN_IRQ_POLLING) { ps3_irq_busy_dec(irq); LOG_DEBUG("hno:%u reply in irq polling:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } if (completed_count != 0) { - wmb(); + wmb(); /* in order to force CPU ordering */ #ifndef _WINDOWS ps3_can_queue_depth_update(instance); #endif @@ -88,53 +89,53 @@ S32 ps3_cmd_complete(struct ps3_irq *irq) ps3_irq_busy_dec(irq); #ifndef _WINDOWS - LOG_DEBUG("hno:%u end isr_os:%d, name:%s isr_sn:%d, " - "irq_enable:%d, irq_poll:%d, last_reply_idx:%d, complete_count:%d, is_busy:%d\n", - PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, - irq->is_enable_irq, irq->is_sched_irq_poll, irq->last_reply_idx, - completed_count, atomic_read(&irq->is_busy)); + LOG_DEBUG( + "hno:%u end isr_os:%d, name:%s sn:%d, en:%d, poll:%d, lastidx:%d, count:%d, is_busy:%d\n", + PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, + irq->is_enable_irq, irq->is_sched_irq_poll, irq->last_reply_idx, + completed_count, atomic_read(&irq->is_busy)); #else - LOG_DEBUG("hno:%u end isr_os:%d, name:%s isr_sn:%d, " - "irq_enable:%d, complete_count:%d, is_busy:%d\n", - PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, - irq->last_reply_idx, completed_count, ps3_atomic_read(&irq->is_busy)); + LOG_DEBUG( + "hno:%u end isr_os:%d, name:%s sn:%d, irq_enable:%d, complete_count:%d, is_busy:%d\n", + PS3_HOST(instance), irq->irqNo, irq->name, irq->isrSN, + irq->last_reply_idx, completed_count, + ps3_atomic_read(&irq->is_busy)); #endif l_out: return completed_count; } -static inline struct PS3ReplyWord *ps3_reply_word_query( - struct ps3_irq *irq, U16 idx) +static inline struct PS3ReplyWord *ps3_reply_word_query(struct ps3_irq *irq, + unsigned short idx) { return irq->reply_fifo_virt_base_addr + idx; } -static inline Bool ps3_reply_word_is_valid(U64 val) +static inline unsigned char ps3_reply_word_is_valid(unsigned long long val) { - U64 type = val & U64_MAX; + unsigned long long type = val & U64_MAX; + return (type != U64_MAX); } static inline void ps3_reply_word_next(struct ps3_irq *irq, - struct PS3ReplyWord **reply_word) + struct PS3ReplyWord **reply_word) { - if (!irq->last_reply_idx) { + if (!irq->last_reply_idx) *reply_word = ps3_reply_word_query(irq, irq->last_reply_idx); - } else { + else ++(*reply_word); - } - return; } #ifndef _WINDOWS -void ps3_trigger_irq_poll(struct ps3_irq *irq) +static void ps3_trigger_irq_poll(struct ps3_irq *irq) { LOG_DEBUG("host_no:%u trigger irq_poll isrSN:%d\n", - PS3_HOST(irq->instance), irq->isrSN); + PS3_HOST(irq->instance), irq->isrSN); if (irq->is_sched_irq_poll) { LOG_DEBUG("host_no:%u irq_poll_is_processing is PS3_TRUE\n", - PS3_HOST(irq->instance)); + PS3_HOST(irq->instance)); goto l_out; } @@ -148,48 +149,53 @@ void ps3_trigger_irq_poll(struct ps3_irq *irq) void ps3_can_queue_depth_update(struct ps3_instance *instance) { - ULong flag = 0; - ULong time_threahold = 5; - S32 old_host_can_que = 0; + unsigned long flag = 0; + unsigned long time_threahold = 5; + int old_host_can_que = 0; if (instance->fault_context.ioc_busy && - time_after(jiffies, instance->fault_context.last_time + - time_threahold * HZ) && - (atomic_read(&instance->cmd_statistics.io_outstanding) < - (instance->cmd_attr.throttle_que_depth + 1))) { + time_after(jiffies, instance->fault_context.last_time + + time_threahold * HZ) && + (atomic_read(&instance->cmd_statistics.io_outstanding) < + (instance->cmd_attr.throttle_que_depth + 1))) { instance->fault_context.ioc_busy = PS3_FALSE; spin_lock_irqsave(instance->host->host_lock, flag); old_host_can_que = instance->host->can_queue; instance->host->can_queue = instance->cmd_attr.cur_can_que; spin_unlock_irqrestore(instance->host->host_lock, flag); - LOG_INFO("hno:%u old_can_queue:%d, cur_can_que:%d, ioc_busy:%d.\n", + LOG_INFO( + "hno:%u old_can_queue:%d, cur_can_que:%d, ioc_busy:%d.\n", PS3_HOST(instance), old_host_can_que, instance->cmd_attr.cur_can_que, instance->fault_context.ioc_busy); } - return ; } #endif -static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, - struct ps3_instance *instance, struct PS3ReplyWord *reply_word, - S32 *completed_count) +static int ps3_reply_fifo_traverse(struct ps3_irq *irq, + struct ps3_instance *instance, + struct PS3ReplyWord *reply_word, + int *completed_count) { - S32 ret = PS3_SUCCESS; - U32 reply_threshold_count = 0; - U64 *r_word = NULL; - static U16 reply_word_size = sizeof(struct PS3ReplyWord); - - while (ps3_reply_word_is_valid(*(U64*)reply_word)) { - r_word = (U64 *)reply_word; - LOG_DEBUG("hno:%u CFID:%d reply_word:0x%llx reply_f:%d reply_mode:%d rettype:%d\n", - PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID), *r_word, - reply_word->retStatus, reply_word->mode, reply_word->retType); + int ret = PS3_SUCCESS; + unsigned int reply_threshold_count = 0; + unsigned long long *r_word = NULL; + static unsigned short reply_word_size = sizeof(struct PS3ReplyWord); + + while (ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) { + r_word = (unsigned long long *)reply_word; + LOG_DEBUG( + "hno:%u CFID:%d reply_word:0x%llx reply_f:%d reply_mode:%d rettype:%d\n", + PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID), + *r_word, reply_word->retStatus, reply_word->mode, + reply_word->retType); ret = ps3_cmd_dispatch(instance, - le16_to_cpu(reply_word->cmdFrameID), - reply_word); + le16_to_cpu(reply_word->cmdFrameID), + reply_word); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_IN_IRQ(instance, "host_no:%u CFID:%d dispatch cmd fail\n", + LOG_ERROR_IN_IRQ( + instance, + "host_no:%u CFID:%d dispatch cmd fail\n", PS3_HOST(instance), le16_to_cpu(reply_word->cmdFrameID)); } @@ -198,27 +204,26 @@ static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, ++(irq->last_reply_idx); if (irq->last_reply_idx >= - instance->irq_context.reply_fifo_depth) { - LOG_DEBUG("last_reply_idx = %d, depth=%d\n", irq->last_reply_idx, - instance->irq_context.reply_fifo_depth); + instance->irq_context.reply_fifo_depth) { + LOG_DEBUG("last_reply_idx = %d, depth=%d\n", + irq->last_reply_idx, + instance->irq_context.reply_fifo_depth); irq->last_reply_idx = 0; } - if (((++(*completed_count)) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) == 0) { - ps3_qos_waitq_notify(instance); - } + if (((++(*completed_count)) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) == 0) + ps3_qos_waitq_notify(instance, irq->isrSN); ++reply_threshold_count; ps3_reply_word_next(irq, &reply_word); - if (!ps3_reply_word_is_valid(*(U64*)reply_word)) { + if (!ps3_reply_word_is_valid(*(unsigned long long *)reply_word)) break; - } #ifndef _WINDOWS #ifdef CONFIG_IRQ_POLL if (reply_threshold_count >= irq->irq_poll_sched_threshold) { reply_threshold_count = 0; - wmb(); + wmb(); /* in order to force CPU ordering */ ps3_trigger_irq_poll(irq); ret = -PS3_IN_IRQ_POLLING; break; @@ -227,16 +232,15 @@ static S32 ps3_reply_fifo_traverse(struct ps3_irq *irq, #endif } - if (((*completed_count) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) > 0) { - ps3_qos_waitq_notify(instance); - } + if (((*completed_count) & (PS3_QOS_NOTIFY_CMD_COUNT - 1)) > 0) + ps3_qos_waitq_notify(instance, irq->isrSN); return ret; } -S32 ps3_resp_status_convert(U32 resp_status) +static int ps3_resp_status_convert(unsigned int resp_status) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; switch (resp_status) { case U8_MAX: @@ -253,48 +257,49 @@ S32 ps3_resp_status_convert(U32 resp_status) return ret; } -S32 ps3_cmd_reply_polling(struct ps3_instance *instance, - struct ps3_cmd *cmd, ULong timeout, Bool ignore) +int ps3_cmd_reply_polling(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned long timeout, unsigned char ignore) { - const U32 seconds_to_msecs_unit = 1000; - const U32 step_size = 20; - const U32 read_fw_satus_period = 5000; - U32 local_resp_status = U8_MAX; - U32 msecs = U32_MAX; - U32 i = 0; - ULong flags = 0; - U32 time_out; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - - time_out = max((ULong)cmd->time_out, timeout); - if (time_out != 0) { + const unsigned int seconds_to_msecs_unit = 1000; + const unsigned int step_size = 20; + const unsigned int read_fw_satus_period = 5000; + unsigned int local_resp_status = U8_MAX; + unsigned int msecs = U32_MAX; + unsigned int i = 0; + unsigned long flags = 0; + unsigned int time_out; + int cur_state = PS3_INSTANCE_STATE_INIT; + + time_out = max_t(unsigned long, cmd->time_out, timeout); + if (time_out != 0) msecs = time_out * seconds_to_msecs_unit; - } - for (i = 0; (i < msecs) && - (cmd->resp_frame->normalRespFrame.respStatus == PS3_SCSI_STATUS_MASK); - i += step_size) { - rmb(); + for (i = 0; + (i < msecs) && (cmd->resp_frame->normalRespFrame.respStatus == + PS3_SCSI_STATUS_MASK); + i += step_size) { + rmb(); /* in order to force CPU ordering */ ps3_msleep(step_size); - if (i % read_fw_satus_period) { + if (i % read_fw_satus_period) continue; - } if (ignore) { - cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state == PS3_INSTANCE_STATE_DEAD) { + cur_state = + ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD) break; - } } else { - if (!ps3_is_instance_state_allow_cmd_execute(instance)) { + if (!ps3_is_instance_state_allow_cmd_execute( + instance)) { break; } } } - local_resp_status = le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); - LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", - PS3_HOST(instance), cmd->index, local_resp_status); + local_resp_status = + le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); + LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", PS3_HOST(instance), + cmd->index, local_resp_status); if (local_resp_status != U8_MAX) { ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -304,36 +309,37 @@ S32 ps3_cmd_reply_polling(struct ps3_instance *instance, return ps3_resp_status_convert(local_resp_status); } -S32 ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, - struct ps3_cmd *cmd, ULong timeout) +int ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned long timeout) { - const U32 seconds_to_msecs_unit = 1000; - const U32 step_size = 20; - const U32 read_fw_satus_period = 5000; - U32 local_resp_status = U8_MAX; - U32 msecs = U32_MAX; - U32 i = 0; - ULong flags = 0; - U32 time_out; - - time_out = max((ULong)cmd->time_out, timeout); - if (time_out != 0) { + const unsigned int seconds_to_msecs_unit = 1000; + const unsigned int step_size = 20; + const unsigned int read_fw_satus_period = 5000; + unsigned int local_resp_status = U8_MAX; + unsigned int msecs = U32_MAX; + unsigned int i = 0; + unsigned long flags = 0; + unsigned int time_out; + + time_out = max_t(unsigned long, cmd->time_out, timeout); + if (time_out != 0) msecs = time_out * seconds_to_msecs_unit; - } - for (i = 0; (i < msecs) && - (cmd->resp_frame->normalRespFrame.respStatus == PS3_SCSI_STATUS_MASK); - i += step_size) { - rmb(); + for (i = 0; + (i < msecs) && (cmd->resp_frame->normalRespFrame.respStatus == + PS3_SCSI_STATUS_MASK); + i += step_size) { + rmb(); /* in order to force CPU ordering */ ps3_msleep(step_size); - if (i % read_fw_satus_period) { + if (i % read_fw_satus_period) continue; - } } - local_resp_status = le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); - LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", - PS3_HOST(instance), cmd->index, local_resp_status); + local_resp_status = + le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); + LOG_DEBUG("host_no:%u CFID:%d, respStatus:0x%x\n", PS3_HOST(instance), + cmd->index, local_resp_status); if (local_resp_status != U8_MAX) { ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -346,13 +352,10 @@ S32 ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, void ps3_all_reply_fifo_complete(struct ps3_instance *instance) { - U32 i = 0; - if (instance->irq_context.irqs == NULL) { + unsigned int i = 0; + + if (instance->irq_context.irqs == NULL) return; - } - for (; i < instance->irq_context.valid_msix_vector_count; ++i) { + for (; i < instance->irq_context.valid_msix_vector_count; ++i) (void)ps3_cmd_complete(instance->irq_context.irqs + i); - } - - return; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h index b4fe4e1ebdca..bc5f7c701d70 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_complete.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CMD_COMPLETE_H_ #define _PS3_CMD_COMPLETE_H_ @@ -7,13 +7,14 @@ #include "ps3_instance_manager.h" #include "ps3_inner_data.h" -S32 ps3_cmd_complete(struct ps3_irq *irq); +int ps3_cmd_complete(struct ps3_irq *irq); -S32 ps3_cmd_reply_polling(struct ps3_instance *instance, - struct ps3_cmd *cmd, ULong timeout, Bool ignore); +int ps3_cmd_reply_polling(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned long timeout, unsigned char ignore); -S32 ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, - struct ps3_cmd *cmd, ULong timeout); +int ps3_cmd_reply_polling_when_recovery(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned long timeout); void ps3_all_reply_fifo_complete(struct ps3_instance *instance); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h index ed78e04f5744..cfd0e7b6e695 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_stat_def.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CMD_STAT_DEF_H_ #define _PS3_CMD_STAT_DEF_H_ @@ -11,7 +11,7 @@ #include "ps3_htp_def.h" #ifdef __cplusplus -extern "C"{ +extern "C" { #endif struct ps3_instance; @@ -27,9 +27,9 @@ enum { enum ps3_cmd_stat_item { PS3_SCSI_DRV_READ, - PS3_SCSI_DRV_WRITE, - PS3_SCSI_DRV_NORW, - PS3_SCSI_DRV_ALL, + PS3_SCSI_DRV_WRITE, + PS3_SCSI_DRV_NORW, + PS3_SCSI_DRV_ALL, PS3_DRV_IOC_READ, PS3_DRV_IOC_WRITE, PS3_DRV_IOC_NORW, @@ -46,76 +46,78 @@ enum ps3_cmd_stat_item { PS3_DRV_IOC_PD_D_WRITE, PS3_DRV_IOC_MGR, PS3_SCSI_ABORT, - PS3_SCSI_DEVICE_RESET, - PS3_SCSI_RETRY_CMD, - PS3_QOS_PD_PRO, - PS3_QOS_VD_PRO, - PS3_QOS_TAG_PRO, - PS3_QOS_MGR_PRO, - PS3_QOS_CMD_PRO, - PS3_QOS_PD_QUEUE, - PS3_QOS_VD_QUEUE, - PS3_QOS_TAG_QUEUE, - PS3_QOS_MGR_QUEUE, - PS3_QOS_CMD_QUEUE, + PS3_SCSI_DEVICE_RESET, + PS3_SCSI_RETRY_CMD, + PS3_QOS_PD_PRO, + PS3_QOS_VD_PRO, + PS3_QOS_TAG_PRO, + PS3_QOS_MGR_PRO, + PS3_QOS_CMD_PRO, + PS3_QOS_PD_QUEUE, + PS3_QOS_VD_QUEUE, + PS3_QOS_TAG_QUEUE, + PS3_QOS_MGR_QUEUE, + PS3_QOS_CMD_QUEUE, PS3_CMD_STAT_COUNT, }; -static inline const S8 *ps3_cmd_stat_item_tostring(enum ps3_cmd_stat_item type) +static inline const char * +ps3_cmd_stat_item_tostring(enum ps3_cmd_stat_item type) { - static const S8 *itme_string[] = { - [PS3_SCSI_DRV_READ] = "scsi_drv_read", - [PS3_SCSI_DRV_WRITE] = "scsi_drv_write", - [PS3_SCSI_DRV_NORW] = "scsi_drv_norw", - [PS3_SCSI_DRV_ALL] = "scsi_drv_all", - [PS3_DRV_IOC_READ] = "scsi_drv_ioc_read", - [PS3_DRV_IOC_WRITE] = "scsi_drv_ioc_write", - [PS3_DRV_IOC_NORW] = "scsi_drv_ioc_norw", - [PS3_DRV_IOC_ALL] = "scsi_drv_ioc_all", - [PS3_DRV_IOC_VD_READ] = "scsi_drv_ioc_vd_read", - [PS3_DRV_IOC_VD_WRITE] = "scsi_drv_ioc_vd_write", - [PS3_DRV_IOC_VD_NORW] = "scsi_drv_ioc_vd_norw", - [PS3_DRV_IOC_PD_READ] = "scsi_drv_ioc_pd_read", - [PS3_DRV_IOC_PD_WRITE] = "scsi_drv_ioc_pd_write", - [PS3_DRV_IOC_PD_NORW] = "scsi_drv_ioc_pd_norw", - [PS3_DRV_IOC_VD_D_READ] = "scsi_drv_ioc_vd_d_read", - [PS3_DRV_IOC_VD_D_WRITE] = "scsi_drv_ioc_vd_d_write", - [PS3_DRV_IOC_PD_D_READ] = "scsi_drv_ioc_pd_d_read", - [PS3_DRV_IOC_PD_D_WRITE] = "scsi_drv_ioc_pd_d_write", - [PS3_DRV_IOC_MGR] = "mgr_drv_ioc_cmd", - [PS3_SCSI_ABORT] = "task_abort", - [PS3_SCSI_DEVICE_RESET] = "task_reset", - [PS3_SCSI_RETRY_CMD] = "scsi_retry_cmd", - [PS3_QOS_PD_PRO] = "qos_pd_pro", - [PS3_QOS_VD_PRO] = "qos_vd_pro", - [PS3_QOS_TAG_PRO] = "qos_tag_pro", - [PS3_QOS_MGR_PRO] = "qos_mgr_pro", - [PS3_QOS_CMD_PRO] = "qos_cmd_pro", - [PS3_QOS_PD_QUEUE] = "qos_pd_queue", - [PS3_QOS_VD_QUEUE] = "qos_vd_queue", - [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", - [PS3_QOS_MGR_QUEUE] = "qos_mgr_queue", - [PS3_QOS_CMD_QUEUE] = "qos_cmd_queue", - [PS3_CMD_STAT_COUNT] = "type_unknown", + static const char * const itme_string[] = { + [PS3_SCSI_DRV_READ] = "scsi_drv_read", + [PS3_SCSI_DRV_WRITE] = "scsi_drv_write", + [PS3_SCSI_DRV_NORW] = "scsi_drv_norw", + [PS3_SCSI_DRV_ALL] = "scsi_drv_all", + [PS3_DRV_IOC_READ] = "scsi_drv_ioc_read", + [PS3_DRV_IOC_WRITE] = "scsi_drv_ioc_write", + [PS3_DRV_IOC_NORW] = "scsi_drv_ioc_norw", + [PS3_DRV_IOC_ALL] = "scsi_drv_ioc_all", + [PS3_DRV_IOC_VD_READ] = "scsi_drv_ioc_vd_read", + [PS3_DRV_IOC_VD_WRITE] = "scsi_drv_ioc_vd_write", + [PS3_DRV_IOC_VD_NORW] = "scsi_drv_ioc_vd_norw", + [PS3_DRV_IOC_PD_READ] = "scsi_drv_ioc_pd_read", + [PS3_DRV_IOC_PD_WRITE] = "scsi_drv_ioc_pd_write", + [PS3_DRV_IOC_PD_NORW] = "scsi_drv_ioc_pd_norw", + [PS3_DRV_IOC_VD_D_READ] = "scsi_drv_ioc_vd_d_read", + [PS3_DRV_IOC_VD_D_WRITE] = "scsi_drv_ioc_vd_d_write", + [PS3_DRV_IOC_PD_D_READ] = "scsi_drv_ioc_pd_d_read", + [PS3_DRV_IOC_PD_D_WRITE] = "scsi_drv_ioc_pd_d_write", + [PS3_DRV_IOC_MGR] = "mgr_drv_ioc_cmd", + [PS3_SCSI_ABORT] = "task_abort", + [PS3_SCSI_DEVICE_RESET] = "task_reset", + [PS3_SCSI_RETRY_CMD] = "scsi_retry_cmd", + [PS3_QOS_PD_PRO] = "qos_pd_pro", + [PS3_QOS_VD_PRO] = "qos_vd_pro", + [PS3_QOS_TAG_PRO] = "qos_tag_pro", + [PS3_QOS_MGR_PRO] = "qos_mgr_pro", + [PS3_QOS_CMD_PRO] = "qos_cmd_pro", + [PS3_QOS_PD_QUEUE] = "qos_pd_queue", + [PS3_QOS_VD_QUEUE] = "qos_vd_queue", + [PS3_QOS_TAG_QUEUE] = "qos_tag_queue", + [PS3_QOS_MGR_QUEUE] = "qos_mgr_queue", + [PS3_QOS_CMD_QUEUE] = "qos_cmd_queue", + [PS3_CMD_STAT_COUNT] = "type_unknown", }; - return (type >= PS3_CMD_STAT_COUNT) ? "type_unknown" : itme_string[type]; + return (type >= PS3_CMD_STAT_COUNT) ? "type_unknown" : + itme_string[type]; } struct ps3_lagency_info { - U64 start_time; - U64 back_time; - U64 avg; - U64 max_lagency; - U64 min_lagency; - U64 all; + unsigned long long start_time; + unsigned long long back_time; + unsigned long long avg; + unsigned long long max_lagency; + unsigned long long min_lagency; + unsigned long long all; }; struct ps3_cmd_stat_entry { - U64 start; - U64 back_good; - U64 back_err; - U64 not_back; + unsigned long long start; + unsigned long long back_good; + unsigned long long back_err; + unsigned long long not_back; struct ps3_lagency_info lagency; }; @@ -124,9 +126,9 @@ struct ps3_total_cmd_stat { }; enum ps3_cmd_stat_back_flag { - PS3_STAT_BACK_OK, - PS3_STAT_BACK_FAIL, - PS3_STAT_BACK_NO = 0xFF, + PS3_STAT_BACK_OK, + PS3_STAT_BACK_FAIL, + PS3_STAT_BACK_NO = 0xFF, }; struct ps3_single_cmd_stat { @@ -134,55 +136,54 @@ struct ps3_single_cmd_stat { }; enum ps3_cmd_stat_switch_flag { - PS3_STAT_ALL_SWITCH_CLOSE = 0x00, - PS3_STAT_OUTSTAND_SWITCH_OPEN = 0x01, - PS3_STAT_INC_SWITCH_OPEN = 0x02, - PS3_STAT_LOG_SWITCH_OPEN = 0x04, - PS3_STAT_DEV_SWITCH_OPEN = 0x08, - PS3_STAT_QOS_SWITCH_OPEN = 0x10, - PS3_STAT_ALL_SWITCH_OPEN = (PS3_STAT_OUTSTAND_SWITCH_OPEN | - PS3_STAT_INC_SWITCH_OPEN | - PS3_STAT_LOG_SWITCH_OPEN | - PS3_STAT_DEV_SWITCH_OPEN | - PS3_STAT_QOS_SWITCH_OPEN), + PS3_STAT_ALL_SWITCH_CLOSE = 0x00, + PS3_STAT_OUTSTAND_SWITCH_OPEN = 0x01, + PS3_STAT_INC_SWITCH_OPEN = 0x02, + PS3_STAT_LOG_SWITCH_OPEN = 0x04, + PS3_STAT_DEV_SWITCH_OPEN = 0x08, + PS3_STAT_QOS_SWITCH_OPEN = 0x10, + PS3_STAT_ALL_SWITCH_OPEN = + (PS3_STAT_OUTSTAND_SWITCH_OPEN | PS3_STAT_INC_SWITCH_OPEN | + PS3_STAT_LOG_SWITCH_OPEN | PS3_STAT_DEV_SWITCH_OPEN | + PS3_STAT_QOS_SWITCH_OPEN), }; struct ps3_cmd_stat_wrokq_context { #ifndef _WINDOWS - struct delayed_work stat_work; - struct workqueue_struct *stat_queue; - struct ps3_instance *instance; + struct delayed_work stat_work; + struct workqueue_struct *stat_queue; + struct ps3_instance *instance; #else struct ps3_delay_worker statis_work; #endif - Bool is_stop; + unsigned char is_stop; }; struct ps3_cmd_statistics_context { - ps3_atomic32 cmd_outstanding; - ps3_atomic32 io_outstanding; - ps3_atomic32 vd_io_outstanding; - ps3_atomic32 cmd_delivering; - ps3_atomic32 scsi_cmd_delivering; - ps3_atomic64 cmd_word_send_count; - struct ps3_total_cmd_stat total_stat; - struct ps3_total_cmd_stat inc_stat; - struct ps3_single_cmd_stat **cmd_stat_backup_buf; - struct ps3_single_cmd_stat **last_stat_buf; - struct ps3_single_cmd_stat **cmd_stat_buf; - U32 stat_entry_max_count; - U32 stat_interval; - struct ps3_cmd_stat_wrokq_context stat_workq; - U8 cmd_stat_switch; - U8 log_record_count; - ps3_atomic32 cli_cnt; - ps3_atomic32 cmd_qos_processing; - ps3_atomic64 cmd_qos_total; - U8 reserved2[2]; + atomic_t cmd_outstanding; + atomic_t io_outstanding; + atomic_t vd_io_outstanding; + atomic_t cmd_delivering; + atomic_t scsi_cmd_delivering; + atomic64_t cmd_word_send_count; + struct ps3_total_cmd_stat total_stat; + struct ps3_total_cmd_stat inc_stat; + struct ps3_single_cmd_stat **cmd_stat_backup_buf; + struct ps3_single_cmd_stat **last_stat_buf; + struct ps3_single_cmd_stat **cmd_stat_buf; + unsigned int stat_entry_max_count; + unsigned int stat_interval; + struct ps3_cmd_stat_wrokq_context stat_workq; + unsigned char cmd_stat_switch; + unsigned char log_record_count; + atomic_t cli_cnt; + atomic_t cmd_qos_processing; + atomic64_t cmd_qos_total; + unsigned char reserved2[2]; }; #ifdef __cplusplus } #endif -#endif \ No newline at end of file +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c index afa3fe855f84..66a56759786d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #endif @@ -6,63 +6,60 @@ #include "ps3_cmd_statistics.h" #include "ps3_cmd_channel.h" #include "ps3_driver_log.h" +#include "ps3_util.h" -static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance); +static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_stat_buf_free(struct ps3_instance *instance); static inline void ps3_stat_data_collect(struct ps3_instance *instance); static void ps3_cmd_stat_content_init(struct ps3_instance *instance); static inline void ps3_stat_buf_init(struct ps3_instance *instance); static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd); -static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance); -static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance); + const struct ps3_cmd *cmd); +static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance); +static int ps3_last_stat_buf_alloc(struct ps3_instance *instance); static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance); static void ps3_last_stat_buf_free(struct ps3_instance *instance); static inline void ps3_cmd_stat_backup_buf_init(struct ps3_instance *instance); static inline void ps3_last_stat_init(struct ps3_instance *instance); -S32 ps3_cmd_statistics_init(struct ps3_instance *instance) +int ps3_cmd_statistics_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ps3_atomic_set(&instance->cmd_statistics.cmd_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.io_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.vd_io_outstanding, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&instance->cmd_statistics.scsi_cmd_delivering, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); ps3_atomic64_set(&instance->cmd_statistics.cmd_word_send_count, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&instance->cmd_statistics.cmd_qos_total, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&instance->cmd_statistics.cmd_qos_processing, - PS3_CMD_STAT_INIT_VALUE); + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&instance->cmd_statistics.cmd_qos_total, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&instance->cmd_statistics.cmd_qos_processing, + PS3_CMD_STAT_INIT_VALUE); ret = ps3_cmd_stat_buf_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_free_stat_buf; - } ret = ps3_cmd_stat_backup_buf_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_free_stat_buf; - } ret = ps3_last_stat_buf_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_free_stat_buf; - } ps3_cmd_stat_content_init(instance); ret = ps3_stat_workq_start(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_stop_workq; - } goto l_out; @@ -85,9 +82,10 @@ void ps3_cmd_statistics_exit(struct ps3_instance *instance) ps3_last_stat_buf_free(instance); } -void ps3_cmd_stat_content_clear(struct ps3_instance *instance) +static void ps3_cmd_stat_content_clear(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; + memset(&ctx->total_stat, 0, sizeof(struct ps3_total_cmd_stat)); memset(&ctx->inc_stat, 0, sizeof(struct ps3_total_cmd_stat)); ps3_stat_buf_init(instance); @@ -105,60 +103,45 @@ static void ps3_cmd_stat_content_init(struct ps3_instance *instance) #ifdef PS3_CFG_RELEASE ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN; #else - ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN | PS3_STAT_INC_SWITCH_OPEN - | PS3_STAT_QOS_SWITCH_OPEN; + ctx->cmd_stat_switch = PS3_STAT_OUTSTAND_SWITCH_OPEN | + PS3_STAT_INC_SWITCH_OPEN | + PS3_STAT_QOS_SWITCH_OPEN; #endif } -static inline Bool ps3_cmd_is_vd(const struct ps3_cmd *cmd) +static inline unsigned char ps3_cmd_is_vd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_VD; } void ps3_dev_io_statis_init(struct ps3_dev_io_statis *statis) { - ps3_atomic64_set(&statis->read_send_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_ok_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_wait_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_send_err_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_ok_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_recv_err_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->read_ok_bytes, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_ok_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_wait_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_send_err_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_ok_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_recv_err_cnt, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->write_ok_bytes, - PS3_CMD_STAT_INIT_VALUE); - ps3_atomic64_set(&statis->qos_processing_cnt, - PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_ok_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_wait_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_send_err_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_ok_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_recv_err_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->read_ok_bytes, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_ok_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_wait_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_send_err_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_ok_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_recv_err_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->write_ok_bytes, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic64_set(&statis->qos_processing_cnt, PS3_CMD_STAT_INIT_VALUE); } void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) { struct ps3_scsi_priv_data *data = NULL; + data = PS3_SDEV_PRI_DATA(sdev); - switch(type) { + switch (type) { case PS3_DEV_IO_STAT_TYPE_R_SEND: ps3_atomic64_inc(&data->statis.read_send_cnt); break; @@ -208,12 +191,14 @@ void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) } static inline void ps3_io_statis_add(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type, U64 offset) + enum ps3_dev_io_stat_type type, + unsigned long long offset) { struct ps3_scsi_priv_data *data = NULL; + data = PS3_SDEV_PRI_DATA(sdev); - switch(type) { + switch (type) { case PS3_DEV_IO_STAT_TYPE_R_OK_BYTES: ps3_atomic64_add(offset, &data->statis.read_ok_bytes); break; @@ -226,13 +211,13 @@ static inline void ps3_io_statis_add(struct scsi_device *sdev, } } -void ps3_io_statis_dec(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type) +void ps3_io_statis_dec(struct scsi_device *sdev, enum ps3_dev_io_stat_type type) { struct ps3_scsi_priv_data *data = NULL; + data = PS3_SDEV_PRI_DATA(sdev); - switch(type) { + switch (type) { case PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT: ps3_atomic64_dec(&data->statis.read_send_wait_cnt); break; @@ -249,27 +234,27 @@ void ps3_io_statis_clear(struct scsi_device *sdev) { struct ps3_scsi_priv_data *data = NULL; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; + (struct ps3_instance *)sdev->host->hostdata; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); data = PS3_SDEV_PRI_DATA(sdev); - if (data != NULL) { + if (data != NULL) ps3_dev_io_statis_init(&data->statis); - } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } void ps3_dev_io_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) { + if (instance == NULL || cmd == NULL) goto l_out; - } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_SEND); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_SEND); } l_out: @@ -277,16 +262,17 @@ void ps3_dev_io_start_inc(struct ps3_instance *instance, } void ps3_dev_io_start_err_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) { + if (instance == NULL || cmd == NULL) goto l_out; - } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_ERR); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_SEND_ERR); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_ERR); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_SEND_ERR); } l_out: @@ -294,16 +280,17 @@ void ps3_dev_io_start_err_inc(struct ps3_instance *instance, } void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (instance == NULL || cmd == NULL) { + if (instance == NULL || cmd == NULL) goto l_out; - } if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_OK); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_SEND_OK); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_OK); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_SEND_OK); } l_out: @@ -313,32 +300,34 @@ void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, void ps3_dev_io_outstand_dec(const struct ps3_cmd *cmd) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_dec(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); + ps3_io_statis_dec(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_dec(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); + ps3_io_statis_dec(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); } } -void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data* priv_data) +void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data *priv_data) { - ps3_atomic64_inc(&priv_data->statis.qos_processing_cnt); + ps3_atomic64_inc(&priv_data->statis.qos_processing_cnt); } -void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data* priv_data) +void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data *priv_data) { - ps3_atomic64_dec(&priv_data->statis.qos_processing_cnt); + ps3_atomic64_dec(&priv_data->statis.qos_processing_cnt); } void ps3_io_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd) + const struct scsi_cmnd *s_cmd) { - if (instance == NULL || s_cmd == NULL) { + if (instance == NULL || s_cmd == NULL) goto l_out; - } ps3_atomic_dec(&instance->cmd_statistics.io_outstanding); - if((instance->cmd_attr.vd_io_threshold != 0) && ps3_is_vd_rw_cmd(s_cmd)) { + if ((instance->cmd_attr.vd_io_threshold != 0) && + ps3_is_vd_rw_cmd(s_cmd)) { ps3_atomic_dec(&instance->cmd_statistics.vd_io_outstanding); } @@ -346,21 +335,19 @@ void ps3_io_outstand_dec(struct ps3_instance *instance, return; } -void ps3_vd_outstand_dec(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd) +void ps3_vd_outstand_dec(struct ps3_cmd *cmd) { - struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(s_cmd->device); - struct PS3VDEntry *vd_entry = NULL; - + struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(cmd->scmd->device); + const struct PS3VDEntry *vd_entry = NULL; + if (data->dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, s_cmd->device->channel,\ - s_cmd->device->id); - if (unlikely(vd_entry != NULL)) { - if (ps3_is_read_cmd(s_cmd)) { + vd_entry = ps3_dev_mgr_lookup_vd_info( + cmd->instance, cmd->scmd->device->channel, cmd->scmd->device->id); + if (likely(vd_entry != NULL)) { + if (cmd->vd_rd_outstand_flag) { atomic_dec(&data->rd_io_outstand); - } else if (ps3_is_write_cmd(s_cmd)) { - if (!vd_entry->isNvme && !vd_entry->isSsd) { - atomic_dec(&data->wr_io_outstand); - } + } else if (cmd->vd_wr_outstand_flag) { + atomic_dec(&data->wr_io_outstand); } } } @@ -369,75 +356,78 @@ void ps3_vd_outstand_dec(struct ps3_instance *instance, const struct scsi_cmnd * void ps3_dev_io_outstand_inc(const struct ps3_cmd *cmd) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_SEND_WAIT); } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_SEND_WAIT); } } -void ps3_vd_outstand_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd) +void ps3_vd_outstand_inc(struct ps3_cmd *cmd) { - struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(s_cmd->device); - struct PS3VDEntry *vd_entry = NULL; - + struct ps3_scsi_priv_data *data = PS3_SDEV_PRI_DATA(cmd->scmd->device); + const struct PS3VDEntry *vd_entry = NULL; if (data->dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, s_cmd->device->channel,\ - s_cmd->device->id); - if (unlikely(vd_entry != NULL)) { - if (ps3_is_read_cmd(s_cmd)) { + vd_entry = ps3_dev_mgr_lookup_vd_info( + cmd->instance, cmd->scmd->device->channel, cmd->scmd->device->id); + if (likely(vd_entry != NULL)) { + if (ps3_is_read_cmd(cmd->scmd) && + (vd_entry->isReadNeedSeq || ps3_is_hdd_vd(vd_entry))) { atomic_inc(&data->rd_io_outstand); - } else if (ps3_is_write_cmd(s_cmd)) { - if (!vd_entry->isNvme && !vd_entry->isSsd) { + cmd->vd_rd_outstand_flag = PS3_TRUE; + } else if (ps3_is_write_cmd(cmd->scmd) && ps3_is_hdd_vd(vd_entry)) { atomic_inc(&data->wr_io_outstand); - } + cmd->vd_wr_outstand_flag = PS3_TRUE; } } } } void ps3_io_outstand_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { if (ps3_stat_outstand_switch_is_open(instance)) { ps3_atomic_inc(&instance->cmd_statistics.io_outstanding); if (ps3_is_vd_rw_cmd(cmd->scmd) && - (instance->cmd_attr.vd_io_threshold != 0)) { - ps3_atomic_inc(&instance->cmd_statistics.vd_io_outstanding); + (instance->cmd_attr.vd_io_threshold != 0)) { + ps3_atomic_inc( + &instance->cmd_statistics.vd_io_outstanding); } } - - return; } -void ps3_io_recv_ok_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd) +static void ps3_io_recv_ok_stat_inc(struct ps3_instance *ins, + const struct ps3_cmd *cmd) { - if (ins == NULL || cmd == NULL) { + if (ins == NULL || cmd == NULL) goto l_out; - } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV_OK); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV_OK); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_RECV_OK); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_RECV_OK); } l_out: return; } -void ps3_dev_io_back_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd, U8 status) +void ps3_dev_io_back_inc(struct ps3_instance *ins, const struct ps3_cmd *cmd, + unsigned char status) { - if (ins == NULL || cmd == NULL) { + if (ins == NULL || cmd == NULL) goto l_out; - } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_RECV); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_RECV); } if (status == PS3_REPLY_WORD_FLAG_SUCCESS) { @@ -450,20 +440,19 @@ void ps3_dev_io_back_inc(struct ps3_instance *ins, } static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { - if (ins == NULL || cmd == NULL || cmd->scmd == NULL) { + if (ins == NULL || cmd == NULL || cmd->scmd == NULL) goto l_out; - } - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { ps3_io_statis_add(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_R_OK_BYTES, - scsi_bufflen(cmd->scmd)); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ + PS3_DEV_IO_STAT_TYPE_R_OK_BYTES, + scsi_bufflen(cmd->scmd)); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { ps3_io_statis_add(cmd->scmd->device, - PS3_DEV_IO_STAT_TYPE_W_OK_BYTES, - scsi_bufflen(cmd->scmd)); + PS3_DEV_IO_STAT_TYPE_W_OK_BYTES, + scsi_bufflen(cmd->scmd)); } l_out: @@ -472,24 +461,21 @@ static void ps3_dev_io_recv_bytes_stat_inc(struct ps3_instance *ins, void ps3_qos_cmd_inc(struct ps3_instance *instance) { - ps3_atomic64_inc(&instance->cmd_statistics.cmd_qos_total); + ps3_atomic64_inc(&instance->cmd_statistics.cmd_qos_total); } static void ps3_cmd_stat_buf_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->cmd_stat_buf == NULL) { + if (ctx->cmd_stat_buf == NULL) goto l_out; - } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->cmd_stat_buf[i] == NULL) { + if (ctx->cmd_stat_buf[i] == NULL) continue; - } ps3_kfree(instance, ctx->cmd_stat_buf[i]); ctx->cmd_stat_buf[i] = NULL; - } ps3_kfree(instance, ctx->cmd_stat_buf); @@ -498,15 +484,16 @@ static void ps3_cmd_stat_buf_free(struct ps3_instance *instance) return; } -static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) +static int ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->cmd_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, - ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); + ctx->cmd_stat_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( + instance, ctx->stat_entry_max_count * + sizeof(struct ps3_single_cmd_stat *)); INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC1, &ctx->cmd_stat_buf); if (ctx->cmd_stat_buf == NULL) { LOG_ERROR("failed to kcalloc for cmd_stat_buf\n"); @@ -515,11 +502,14 @@ static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->cmd_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, - sizeof(struct ps3_single_cmd_stat)); - INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, &ctx->cmd_stat_buf[i]); + ctx->cmd_stat_buf[i] = + (struct ps3_single_cmd_stat *)ps3_kzalloc( + instance, sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BUF_ALLOC2, + &ctx->cmd_stat_buf[i]); if (ctx->cmd_stat_buf[i] == NULL) { - LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR( + "Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -535,20 +525,17 @@ static S32 ps3_cmd_stat_buf_alloc(struct ps3_instance *instance) static void ps3_last_stat_buf_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->last_stat_buf == NULL) { + if (ctx->last_stat_buf == NULL) goto l_out; - } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->last_stat_buf[i] == NULL) { + if (ctx->last_stat_buf[i] == NULL) continue; - } ps3_kfree(instance, ctx->last_stat_buf[i]); ctx->last_stat_buf[i] = NULL; - } ps3_kfree(instance, ctx->last_stat_buf); @@ -557,16 +544,18 @@ static void ps3_last_stat_buf_free(struct ps3_instance *instance) return; } -static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance) +static int ps3_last_stat_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->last_stat_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, - ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); - INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, &ctx->last_stat_buf); + ctx->last_stat_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( + instance, ctx->stat_entry_max_count * + sizeof(struct ps3_single_cmd_stat *)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC1, + &ctx->last_stat_buf); if (ctx->last_stat_buf == NULL) { LOG_ERROR("failed to kzalloc for last_stat_buf\n"); ret = -PS3_FAILED; @@ -574,11 +563,14 @@ static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->last_stat_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, - sizeof(struct ps3_single_cmd_stat)); - INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, &ctx->last_stat_buf[i]); + ctx->last_stat_buf[i] = + (struct ps3_single_cmd_stat *)ps3_kzalloc( + instance, sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_LAST_STAT_BUF_ALLOC2, + &ctx->last_stat_buf[i]); if (ctx->last_stat_buf[i] == NULL) { - LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR( + "Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -592,41 +584,38 @@ static S32 ps3_last_stat_buf_alloc(struct ps3_instance *instance) return ret; } -static inline struct ps3_single_cmd_stat* ps3_last_stat_entry_find(U32 index, - struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat * +ps3_last_stat_entry_find(unsigned int index, struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.last_stat_buf[index] : NULL; + instance->cmd_statistics.last_stat_buf[index] : + NULL; } static inline void ps3_last_stat_init(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { - memset(ctx->last_stat_buf[i], 0, sizeof(struct ps3_single_cmd_stat)); - mb(); + memset(ctx->last_stat_buf[i], 0, + sizeof(struct ps3_single_cmd_stat)); + mb(); /* in order to force CPU ordering */ } - - return; } static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - if (ctx->cmd_stat_backup_buf == NULL) { + if (ctx->cmd_stat_backup_buf == NULL) goto l_out; - } for (; i < ctx->stat_entry_max_count; ++i) { - if (ctx->cmd_stat_backup_buf[i] == NULL) { + if (ctx->cmd_stat_backup_buf[i] == NULL) continue; - } ps3_kfree(instance, ctx->cmd_stat_backup_buf[i]); ctx->cmd_stat_backup_buf[i] = NULL; - } ps3_kfree(instance, ctx->cmd_stat_backup_buf); @@ -635,16 +624,18 @@ static void ps3_cmd_stat_backup_buf_free(struct ps3_instance *instance) return; } -static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) +static int ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; ctx->stat_entry_max_count = instance->cmd_context.max_cmd_count; - ctx->cmd_stat_backup_buf = (struct ps3_single_cmd_stat**)ps3_kzalloc(instance, - ctx->stat_entry_max_count * sizeof(struct ps3_single_cmd_stat*)); - INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, &ctx->cmd_stat_backup_buf); + ctx->cmd_stat_backup_buf = (struct ps3_single_cmd_stat **)ps3_kzalloc( + instance, ctx->stat_entry_max_count * + sizeof(struct ps3_single_cmd_stat *)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC1, + &ctx->cmd_stat_backup_buf); if (ctx->cmd_stat_backup_buf == NULL) { LOG_ERROR("failed to kzalloc for cmd_stat_backup_buf\n"); ret = -PS3_FAILED; @@ -652,11 +643,14 @@ static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) } for (; i < ctx->stat_entry_max_count; ++i) { - ctx->cmd_stat_backup_buf[i] = (struct ps3_single_cmd_stat*)ps3_kzalloc(instance, - sizeof(struct ps3_single_cmd_stat)); - INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, &ctx->cmd_stat_backup_buf[i]); + ctx->cmd_stat_backup_buf[i] = + (struct ps3_single_cmd_stat *)ps3_kzalloc( + instance, sizeof(struct ps3_single_cmd_stat)); + INJECT_START(PS3_ERR_IJ_PS3_CMD_STAT_BACKUP_BUF_ALLOC2, + &ctx->cmd_stat_backup_buf[i]); if (ctx->cmd_stat_backup_buf[i] == NULL) { - LOG_ERROR("Failed to alloc mem for ps3_single_cmd_stat\n"); + LOG_ERROR( + "Failed to alloc mem for ps3_single_cmd_stat\n"); ret = -PS3_FAILED; goto l_free_mem; } @@ -670,44 +664,43 @@ static S32 ps3_cmd_stat_backup_buf_alloc(struct ps3_instance *instance) return ret; } -static inline struct ps3_single_cmd_stat* ps3_backup_stat_entry_find(U32 index, - struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat * +ps3_backup_stat_entry_find(unsigned int index, struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.cmd_stat_backup_buf[index] : NULL; + instance->cmd_statistics.cmd_stat_backup_buf[index] : + NULL; } static inline void ps3_cmd_stat_backup_buf_init(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memset(ctx->cmd_stat_backup_buf[i], 0, - sizeof(struct ps3_single_cmd_stat)); - mb(); + sizeof(struct ps3_single_cmd_stat)); + mb(); /* in order to force CPU ordering */ } - - return; } -static inline struct ps3_single_cmd_stat* ps3_stat_entry_find(U32 index, - struct ps3_instance *instance) +static inline struct ps3_single_cmd_stat * +ps3_stat_entry_find(unsigned int index, struct ps3_instance *instance) { return (index < instance->cmd_statistics.stat_entry_max_count) ? - instance->cmd_statistics.cmd_stat_buf[index] : NULL; + instance->cmd_statistics.cmd_stat_buf[index] : + NULL; } static inline void ps3_stat_buf_init(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { - memset(ctx->cmd_stat_buf[i], 0, sizeof(struct ps3_single_cmd_stat)); - mb(); + memset(ctx->cmd_stat_buf[i], 0, + sizeof(struct ps3_single_cmd_stat)); + mb(); /* in order to force CPU ordering */ } - - return; } void ps3_stat_all_clear(struct ps3_instance *instance) @@ -715,12 +708,14 @@ void ps3_stat_all_clear(struct ps3_instance *instance) ps3_stat_buf_init(instance); ps3_cmd_stat_backup_buf_init(instance); ps3_last_stat_init(instance); - memset(&instance->cmd_statistics.total_stat, 0, sizeof(struct ps3_total_cmd_stat)); - memset(&instance->cmd_statistics.inc_stat, 0, sizeof(struct ps3_total_cmd_stat)); + memset(&instance->cmd_statistics.total_stat, 0, + sizeof(struct ps3_total_cmd_stat)); + memset(&instance->cmd_statistics.inc_stat, 0, + sizeof(struct ps3_total_cmd_stat)); } -static inline void ps3_stat_start_inc(U16 type, - struct ps3_single_cmd_stat *cmd_stat) +static inline void ps3_stat_start_inc(unsigned short type, + struct ps3_single_cmd_stat *cmd_stat) { if (type >= PS3_CMD_STAT_COUNT) { LOG_ERROR("type:%u overflow\n", type); @@ -736,69 +731,68 @@ static inline void ps3_stat_start_inc(U16 type, } static inline void ps3_stat_lagency_update(struct ps3_lagency_info *lagency, - U64 start_time, U64 back_time) + unsigned long long start_time, + unsigned long long back_time) { - U64 intervals = back_time - start_time; + unsigned long long intervals = back_time - start_time; lagency->all += intervals; - if (intervals > lagency->max_lagency) { + if (intervals > lagency->max_lagency) lagency->max_lagency = intervals; - } - if (intervals < lagency->min_lagency || lagency->min_lagency == 0) { + if (intervals < lagency->min_lagency || lagency->min_lagency == 0) lagency->min_lagency = intervals; - } - - return; } static inline void ps3_stat_lagency_merge(struct ps3_lagency_info *target, - const struct ps3_lagency_info *source) + const struct ps3_lagency_info *source) { target->all += source->all; - if (source->max_lagency > target->max_lagency) { + if (source->max_lagency > target->max_lagency) target->max_lagency = source->max_lagency; - } if ((source->min_lagency < target->min_lagency && - source->min_lagency != 0) || target->min_lagency == 0) { + source->min_lagency != 0) || + target->min_lagency == 0) { target->min_lagency = source->min_lagency; } - - return; } -static inline void ps3_stat_lagency_avg_calc(struct ps3_total_cmd_stat *total_stat) +static inline void +ps3_stat_lagency_avg_calc(struct ps3_total_cmd_stat *total_stat) { - U64 back_count = 0; - U16 i = 0; + unsigned long long back_count = 0; + unsigned short i = 0; - for(; i < PS3_CMD_STAT_COUNT; ++i) { + for (; i < PS3_CMD_STAT_COUNT; ++i) { back_count = total_stat->stat[i].back_good + - total_stat->stat[i].back_err; + total_stat->stat[i].back_err; if (back_count != 0) { - total_stat->stat[i].lagency.avg = - (total_stat->stat[i].lagency.all / back_count); + total_stat->stat[i].lagency.avg = PS3_DIV64_32( + total_stat->stat[i].lagency.all, back_count); } - mb(); + mb(); /* in order to force CPU ordering */ } } static inline void ps3_stat_lagency_inc_cal(struct ps3_lagency_info *inc, - const struct ps3_lagency_info *cur, - const struct ps3_lagency_info *last) + const struct ps3_lagency_info *cur, + const struct ps3_lagency_info *last) { inc->all += cur->all - last->all; inc->max_lagency = (cur->max_lagency > inc->max_lagency) ? - cur->max_lagency : inc->max_lagency; - inc->min_lagency = ((cur->min_lagency < inc->min_lagency && cur->min_lagency != 0) - || inc->min_lagency == 0) ? cur->min_lagency : inc->min_lagency; - - return; + cur->max_lagency : + inc->max_lagency; + inc->min_lagency = ((cur->min_lagency < inc->min_lagency && + cur->min_lagency != 0) || + inc->min_lagency == 0) ? + cur->min_lagency : + inc->min_lagency; } -static inline void ps3_stat_back_inc(U16 type, - struct ps3_single_cmd_stat *single_stat, U8 status) +static inline void ps3_stat_back_inc(unsigned short type, + struct ps3_single_cmd_stat *single_stat, + unsigned char status) { if (type >= PS3_CMD_STAT_COUNT) { LOG_ERROR("type:%u err\n", type); @@ -823,13 +817,13 @@ static inline void ps3_stat_back_inc(U16 type, } ps3_stat_lagency_update(&single_stat->stat[type].lagency, - single_stat->stat[type].lagency.start_time, - single_stat->stat[type].lagency.back_time); + single_stat->stat[type].lagency.start_time, + single_stat->stat[type].lagency.back_time); if (type == PS3_SCSI_ABORT) { LOG_WARN("start:%llu back:%llu all:%llu\n", - single_stat->stat[type].lagency.start_time, - single_stat->stat[type].lagency.back_time, - single_stat->stat[type].lagency.all); + single_stat->stat[type].lagency.start_time, + single_stat->stat[type].lagency.back_time, + single_stat->stat[type].lagency.all); } l_out: @@ -837,39 +831,41 @@ static inline void ps3_stat_back_inc(U16 type, } #ifndef _WINDOWS -static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat* stat_entry, - const struct scsi_cmnd *s_cmd) +static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat *stat_entry, + const struct scsi_cmnd *s_cmd) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + unsigned char type = + PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + if (ps3_scsih_is_rw_type(type)) { - if (ps3_scsih_is_read_cmd(type)) { + if (ps3_scsih_is_read_cmd(type)) ps3_stat_start_inc(PS3_SCSI_DRV_READ, stat_entry); - } else { + else ps3_stat_start_inc(PS3_SCSI_DRV_WRITE, stat_entry); - } } else { ps3_stat_start_inc(PS3_SCSI_DRV_NORW, stat_entry); } ps3_stat_start_inc(PS3_SCSI_DRV_ALL, stat_entry); - if (s_cmd->retries != 0) { + if (s_cmd->retries != 0) ps3_stat_start_inc(PS3_SCSI_RETRY_CMD, stat_entry); - } - - return; } -static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat* stat_entry, - const struct scsi_cmnd *s_cmd, U8 status) +static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat *stat_entry, + const struct scsi_cmnd *s_cmd, + unsigned char status) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + unsigned char type = + PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); if (ps3_scsih_is_rw_type(type)) { if (ps3_scsih_is_read_cmd(type)) { - ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, status); + ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, + status); } else { - ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, + status); } } else { ps3_stat_back_inc(PS3_SCSI_DRV_NORW, stat_entry, status); @@ -877,17 +873,14 @@ static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat* stat_entry, ps3_stat_back_inc(PS3_SCSI_DRV_ALL, stat_entry, status); - if (s_cmd->retries != 0) { + if (s_cmd->retries != 0) ps3_stat_back_inc(PS3_SCSI_RETRY_CMD, stat_entry, status); - } - - return; } -void ps3_scmd_inc(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, U8 type, U8 status) +void ps3_scmd_inc(struct ps3_instance *instance, struct scsi_cmnd *s_cmd, + unsigned char type, unsigned char status) { - struct ps3_single_cmd_stat* stat_entry = NULL; + struct ps3_single_cmd_stat *stat_entry = NULL; if (s_cmd == NULL) { LOG_ERROR("scsi cmd is null\n"); @@ -899,68 +892,68 @@ void ps3_scmd_inc(struct ps3_instance *instance, goto l_out; } - stat_entry = ps3_stat_entry_find(SCMD_GET_REQUEST(s_cmd)->tag, instance); + stat_entry = + ps3_stat_entry_find(SCMD_GET_REQUEST(s_cmd)->tag, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); + PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); goto l_out; } - if (type == PS3_STAT_START) { + if (type == PS3_STAT_START) ps3_scmd_start_inc(stat_entry, s_cmd); - } else if (type == PS3_STAT_BACK) { + else if (type == PS3_STAT_BACK) ps3_scmd_back_inc(stat_entry, s_cmd, status); - } else { + else LOG_ERROR("type:%u is err\n", type); - } l_out: return; } #else -static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat* stat_entry, - const struct scsi_cmnd *s_cmd) +static inline void ps3_scmd_start_inc(struct ps3_single_cmd_stat *stat_entry, + const struct scsi_cmnd *s_cmd) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + unsigned char type = + PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(s_cmd->cmnd)); + if (ps3_scsih_is_rw_type(type)) { - if (ps3_scsih_is_read_cmd(type)) { + if (ps3_scsih_is_read_cmd(type)) ps3_stat_start_inc(PS3_SCSI_DRV_READ, stat_entry); - } else { + else ps3_stat_start_inc(PS3_SCSI_DRV_WRITE, stat_entry); - } - } else { + } else ps3_stat_start_inc(PS3_SCSI_DRV_NORW, stat_entry); - } ps3_stat_start_inc(PS3_SCSI_DRV_ALL, stat_entry); - - return; } -static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat* stat_entry, - const struct scsi_cmnd *s_cmd, U8 status) +static inline void ps3_scmd_back_inc(struct ps3_single_cmd_stat *stat_entry, + const struct scsi_cmnd *s_cmd, + unsigned char status) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(s_cmd))); + unsigned char type = PS3_SCSI_CMD_TYPE( + ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(s_cmd))); if (ps3_scsih_is_rw_type(type)) { if (ps3_scsih_is_read_cmd(type)) { - ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, status); + ps3_stat_back_inc(PS3_SCSI_DRV_READ, stat_entry, + status); } else { - ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_SCSI_DRV_WRITE, stat_entry, + status); } } else { ps3_stat_back_inc(PS3_SCSI_DRV_NORW, stat_entry, status); } ps3_stat_back_inc(PS3_SCSI_DRV_ALL, stat_entry, status); - - return; } -void ps3_scmd_inc(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd, U32 tag, U8 type, U8 status) +void ps3_scmd_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd, + unsigned int tag, unsigned char type, unsigned char status) { - struct ps3_single_cmd_stat* stat_entry = NULL; + struct ps3_single_cmd_stat *stat_entry = NULL; if (s_cmd == NULL) { LOG_ERROR("scsi cmd is null\n"); @@ -970,50 +963,49 @@ void ps3_scmd_inc(struct ps3_instance *instance, stat_entry = ps3_stat_entry_find(tag, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), tag); + PS3_HOST(instance), tag); goto l_out; } - if (type == PS3_STAT_START) { + if (type == PS3_STAT_START) ps3_scmd_start_inc(stat_entry, s_cmd); - } - else if (type == PS3_STAT_BACK) { + else if (type == PS3_STAT_BACK) ps3_scmd_back_inc(stat_entry, s_cmd, status); - } else { + else LOG_ERROR("type:%u is err\n", type); - } l_out: return; } #endif -static inline Bool ps3_is_direct_cmd(U8 type) +static inline unsigned char ps3_is_direct_cmd(unsigned char type) { return (type == PS3_CMDWORD_DIRECT_OK || type == PS3_CMDWORD_DIRECT_ADVICE); } -static inline void ps3_direct_cmd_start_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, Bool vd_flag) +static inline void +ps3_direct_cmd_start_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, + unsigned char vd_flag) { - U16 type = PS3_DRV_IOC_READ; + unsigned short type = PS3_DRV_IOC_READ; if (ps3_is_direct_cmd(cmd->io_attr.direct_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { type = vd_flag ? PS3_DRV_IOC_VD_D_READ : - PS3_DRV_IOC_PD_D_READ; + PS3_DRV_IOC_PD_D_READ; } else { type = vd_flag ? PS3_DRV_IOC_VD_D_WRITE : - PS3_DRV_IOC_PD_D_WRITE; + PS3_DRV_IOC_PD_D_WRITE; } ps3_stat_start_inc(type, stat_entry); } - - return; } -static inline void ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry) +static inline void +ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { @@ -1031,8 +1023,9 @@ static inline void ps3_scmd_drv2ioc_start_vd_inc(const struct ps3_cmd *cmd, ps3_direct_cmd_start_inc(cmd, stat_entry, PS3_TRUE); } -static inline void ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry) +static inline void +ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { @@ -1051,26 +1044,24 @@ static inline void ps3_scmd_drv2ioc_start_pd_inc(const struct ps3_cmd *cmd, } void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) + const struct ps3_cmd *cmd) { struct ps3_single_cmd_stat *stat_entry = NULL; - if (cmd == NULL) { + if (cmd == NULL) goto l_out; - } stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) ps3_scmd_drv2ioc_start_vd_inc(cmd, stat_entry); - } else { + else ps3_scmd_drv2ioc_start_pd_inc(cmd, stat_entry); - } ps3_stat_start_inc(PS3_DRV_IOC_ALL, stat_entry); ps3_atomic_inc(&instance->cmd_statistics.cmd_outstanding); @@ -1079,34 +1070,40 @@ void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, return; } -static inline void ps3_direct_cmd_back_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, Bool vd_flag, U8 status) +static inline void +ps3_direct_cmd_back_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, + unsigned char vd_flag, unsigned char status) { - U16 type = PS3_DRV_IOC_READ; + unsigned short type = PS3_DRV_IOC_READ; + if (ps3_is_direct_cmd(cmd->io_attr.direct_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { type = vd_flag ? PS3_DRV_IOC_VD_D_READ : - PS3_DRV_IOC_PD_D_READ; + PS3_DRV_IOC_PD_D_READ; } else { type = vd_flag ? PS3_DRV_IOC_VD_D_WRITE : - PS3_DRV_IOC_PD_D_WRITE; + PS3_DRV_IOC_PD_D_WRITE; } ps3_stat_back_inc(type, stat_entry, status); } - - return; } -static inline void ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, U8 status) +static inline void +ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, + unsigned char status) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_stat_back_inc(PS3_DRV_IOC_VD_READ, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_VD_READ, stat_entry, + status); ps3_stat_back_inc(PS3_DRV_IOC_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_DRV_IOC_VD_WRITE, stat_entry, status); - ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_VD_WRITE, stat_entry, + status); + ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, + status); } } else { ps3_stat_back_inc(PS3_DRV_IOC_NORW, stat_entry, status); @@ -1114,20 +1111,23 @@ static inline void ps3_scmd_drv2ioc_back_vd_inc(const struct ps3_cmd *cmd, } ps3_direct_cmd_back_inc(cmd, stat_entry, PS3_TRUE, status); - - return; } -static inline void ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, - struct ps3_single_cmd_stat *stat_entry, U8 status) +static inline void +ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, + struct ps3_single_cmd_stat *stat_entry, + unsigned char status) { if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - ps3_stat_back_inc(PS3_DRV_IOC_PD_READ, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_PD_READ, stat_entry, + status); ps3_stat_back_inc(PS3_DRV_IOC_READ, stat_entry, status); } else { - ps3_stat_back_inc(PS3_DRV_IOC_PD_WRITE, stat_entry, status); - ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, status); + ps3_stat_back_inc(PS3_DRV_IOC_PD_WRITE, stat_entry, + status); + ps3_stat_back_inc(PS3_DRV_IOC_WRITE, stat_entry, + status); } } else { ps3_stat_back_inc(PS3_DRV_IOC_PD_NORW, stat_entry, status); @@ -1138,7 +1138,7 @@ static inline void ps3_scmd_drv2ioc_back_pd_inc(const struct ps3_cmd *cmd, } void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, U8 status) + const struct ps3_cmd *cmd, unsigned char status) { struct ps3_single_cmd_stat *stat_entry = NULL; @@ -1150,15 +1150,14 @@ void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) ps3_scmd_drv2ioc_back_vd_inc(cmd, stat_entry, status); - } else { + else ps3_scmd_drv2ioc_back_pd_inc(cmd, stat_entry, status); - } ps3_stat_back_inc(PS3_DRV_IOC_ALL, stat_entry, status); ps3_atomic_dec(&instance->cmd_statistics.cmd_outstanding); @@ -1167,8 +1166,9 @@ void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, return; } -static inline void ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry, - const struct ps3_cmd *cmd) +static inline void +ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry, + const struct ps3_cmd *cmd) { switch (cmd->req_frame->mgrReq.reqHead.cmdSubType) { case PS3_TASK_CMD_SCSI_TASK_ABORT: @@ -1182,18 +1182,15 @@ static inline void ps3_task_cmd_start_inc(struct ps3_single_cmd_stat *stat_entry default: break; } - - return; } -void ps3_mgr_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd) +void ps3_mgr_start_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd) { struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u CFID:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } @@ -1216,7 +1213,8 @@ void ps3_mgr_start_inc(struct ps3_instance *instance, } static inline void ps3_task_cmd_back_inc(struct ps3_single_cmd_stat *stat_entry, - const struct ps3_cmd *cmd, U8 status) + const struct ps3_cmd *cmd, + unsigned char status) { switch (cmd->req_frame->mgrReq.reqHead.cmdSubType) { case PS3_TASK_CMD_SCSI_TASK_ABORT: @@ -1230,18 +1228,16 @@ static inline void ps3_task_cmd_back_inc(struct ps3_single_cmd_stat *stat_entry, default: break; } - - return; } -void ps3_mgr_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, U8 status) +void ps3_mgr_back_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd, + unsigned char status) { struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); goto l_out; } @@ -1269,8 +1265,8 @@ void ps3_mgr_back_inc(struct ps3_instance *instance, static inline void ps3_stat_workq_service(struct work_struct *work) { - struct ps3_cmd_stat_wrokq_context *ctx = ps3_container_of(work, - struct ps3_cmd_stat_wrokq_context, stat_work.work); + struct ps3_cmd_stat_wrokq_context *ctx = ps3_container_of( + work, struct ps3_cmd_stat_wrokq_context, stat_work.work); struct ps3_instance *instance = NULL; if (ctx == NULL) { @@ -1292,24 +1288,27 @@ static inline void ps3_stat_workq_service(struct work_struct *work) ps3_stat_data_collect(instance); if (ctx->stat_queue != NULL) { - queue_delayed_work(ctx->stat_queue, &ctx->stat_work, - msecs_to_jiffies(instance->cmd_statistics.stat_interval)); + queue_delayed_work( + ctx->stat_queue, &ctx->stat_work, + msecs_to_jiffies( + instance->cmd_statistics.stat_interval)); } l_out: return; } -S32 ps3_stat_workq_start(struct ps3_instance *instance) +int ps3_stat_workq_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - struct ps3_cmd_stat_wrokq_context *ctx = &instance->cmd_statistics.stat_workq; + int ret = PS3_SUCCESS; + struct ps3_cmd_stat_wrokq_context *ctx = + &instance->cmd_statistics.stat_workq; char qname[PS3_STAT_WROKQ_NAME_MAX_LEN] = { 0 }; struct delayed_work *work = &ctx->stat_work; if (ctx->stat_queue != NULL) { LOG_INFO("host_no:%u stat work for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1321,7 +1320,7 @@ S32 ps3_stat_workq_start(struct ps3_instance *instance) ctx->stat_queue = create_singlethread_workqueue(qname); if (ctx->stat_queue == NULL) { LOG_ERROR("host_no:%u cmd stat work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1334,7 +1333,8 @@ S32 ps3_stat_workq_start(struct ps3_instance *instance) } ctx->is_stop = PS3_FALSE; - queue_delayed_work(ctx->stat_queue, work, + queue_delayed_work( + ctx->stat_queue, work, msecs_to_jiffies(instance->cmd_statistics.stat_interval)); l_out: @@ -1344,35 +1344,33 @@ S32 ps3_stat_workq_start(struct ps3_instance *instance) void ps3_stat_workq_stop(struct ps3_instance *instance) { - struct ps3_cmd_stat_wrokq_context *ctx = NULL; + struct ps3_cmd_stat_wrokq_context *ctx = NULL; struct workqueue_struct *workq = NULL; ctx = &instance->cmd_statistics.stat_workq; ctx->is_stop = PS3_TRUE; - if (ctx->stat_queue == NULL) { + if (ctx->stat_queue == NULL) goto l_out; - } workq = ctx->stat_queue; - if (!cancel_delayed_work_sync(&ctx->stat_work)) { + if (!cancel_delayed_work_sync(&ctx->stat_work)) flush_workqueue(workq); - } ctx->stat_queue = NULL; destroy_workqueue(workq); l_out: memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); - return; } #else static inline void ps3_stat_workq_service(void *ins) { - struct ps3_instance *instance = (struct ps3_instance*)ins; - struct ps3_cmd_stat_wrokq_context* ctx = &instance->cmd_statistics.stat_workq; + struct ps3_instance *instance = (struct ps3_instance *)ins; + struct ps3_cmd_stat_wrokq_context *ctx = + &instance->cmd_statistics.stat_workq; if (ctx == NULL) { LOG_ERROR("ps3_cmd_stat_wrokq_context is null\n"); @@ -1391,23 +1389,25 @@ static inline void ps3_stat_workq_service(void *ins) ps3_stat_data_collect(instance); - ps3_delay_worker_start(&ctx->statis_work, instance->cmd_statistics.stat_interval); + ps3_delay_worker_start(&ctx->statis_work, + instance->cmd_statistics.stat_interval); l_out: return; } -S32 ps3_stat_workq_start(struct ps3_instance *instance) +int ps3_stat_workq_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - struct ps3_cmd_stat_wrokq_context* ctx = &instance->cmd_statistics.stat_workq; - struct ps3_delay_worker* statis_work = &ctx->statis_work; + int ret = PS3_SUCCESS; + struct ps3_cmd_stat_wrokq_context *ctx = + &instance->cmd_statistics.stat_workq; + struct ps3_delay_worker *statis_work = &ctx->statis_work; memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); - if (ps3_delay_worker_init(instance, statis_work, "ps3_statis", ps3_stat_workq_service) != PS3_SUCCESS) { - LOG_ERROR("host_no:%u timer init failed\n", - PS3_HOST(instance)); + if (ps3_delay_worker_init(instance, statis_work, "ps3_statis", + ps3_stat_workq_service) != PS3_SUCCESS) { + LOG_ERROR("host_no:%u timer init failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1418,9 +1418,11 @@ S32 ps3_stat_workq_start(struct ps3_instance *instance) } ctx->is_stop = PS3_FALSE; - if (ps3_delay_worker_start(statis_work, instance->cmd_statistics.stat_interval) != PS3_SUCCESS) { + if (ps3_delay_worker_start(statis_work, + instance->cmd_statistics.stat_interval) != + PS3_SUCCESS) { LOG_ERROR("host_no:%u timer request failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ctx->is_stop = PS3_TRUE; goto l_out; @@ -1431,161 +1433,155 @@ S32 ps3_stat_workq_start(struct ps3_instance *instance) void ps3_stat_workq_stop(struct ps3_instance *instance) { - struct ps3_cmd_stat_wrokq_context* ctx = NULL; + struct ps3_cmd_stat_wrokq_context *ctx = NULL; + ctx = &instance->cmd_statistics.stat_workq; ctx->is_stop = PS3_TRUE; ps3_delay_worker_exit(&ctx->statis_work); memset(ctx, 0, sizeof(struct ps3_cmd_stat_wrokq_context)); - return; } #endif static void ps3_backup_stat_entry_build(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memcpy(ctx->cmd_stat_backup_buf[i], ctx->cmd_stat_buf[i], - sizeof(struct ps3_single_cmd_stat)); - mb(); + sizeof(struct ps3_single_cmd_stat)); + mb(); /* in order to force CPU ordering */ } - - return; } static inline void ps3_last_stat_entry_build(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; for (; i < ctx->stat_entry_max_count; ++i) { memcpy(ctx->last_stat_buf[i], ctx->cmd_stat_backup_buf[i], - sizeof(struct ps3_single_cmd_stat)); - mb(); + sizeof(struct ps3_single_cmd_stat)); + mb(); /* in order to force CPU ordering */ } - - return; } static void ps3_stat_inc_data_collect(struct ps3_instance *instance) { - U32 i = 0; - U16 j = 0; + unsigned int i = 0; + unsigned short j = 0; struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; struct ps3_single_cmd_stat *backup_stat = NULL; struct ps3_single_cmd_stat *last_stat = NULL; - U64 inc_back_good = 0; - U64 inc_back_err = 0; + unsigned long long inc_back_good = 0; + unsigned long long inc_back_err = 0; memset(&ctx->inc_stat, 0, sizeof(ctx->inc_stat)); for (; i < ctx->stat_entry_max_count; ++i) { backup_stat = ps3_backup_stat_entry_find(i, instance); if (backup_stat == NULL) { LOG_WARN("host_no:%u index:%u get backup_stat err\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } last_stat = ps3_last_stat_entry_find(i, instance); if (last_stat == NULL) { LOG_WARN("host_no:%u index:%u get last_stat err\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - mb(); + mb(); /* in order to force CPU ordering */ for (j = 0; j < PS3_CMD_STAT_COUNT; ++j) { ctx->inc_stat.stat[j].start += - backup_stat->stat[j].start - last_stat->stat[j].start; + backup_stat->stat[j].start - + last_stat->stat[j].start; inc_back_good = backup_stat->stat[j].back_good - - last_stat->stat[j].back_good; + last_stat->stat[j].back_good; inc_back_err = backup_stat->stat[j].back_err - - last_stat->stat[j].back_err; - if ((inc_back_good + inc_back_err) == 0) { + last_stat->stat[j].back_err; + if ((inc_back_good + inc_back_err) == 0) continue; - } - mb(); + mb(); /* in order to force CPU ordering */ ctx->inc_stat.stat[j].back_good += inc_back_good; ctx->inc_stat.stat[j].back_err += inc_back_err; ctx->inc_stat.stat[j].not_back += backup_stat->stat[j].not_back - last_stat->stat[j].not_back; ps3_stat_lagency_inc_cal(&ctx->inc_stat.stat[j].lagency, - &backup_stat->stat[j].lagency, - &last_stat->stat[j].lagency); + &backup_stat->stat[j].lagency, + &last_stat->stat[j].lagency); } } ps3_stat_lagency_avg_calc(&ctx->inc_stat); - - return; } static inline void ps3_stat_total_data_collect(struct ps3_instance *instance) { struct ps3_cmd_statistics_context *ctx = &instance->cmd_statistics; - U64 back_count = 0; - U16 i = 0; + unsigned long long back_count = 0; + unsigned short i = 0; for (; i < PS3_CMD_STAT_COUNT; ++i) { ctx->total_stat.stat[i].start += ctx->inc_stat.stat[i].start; - ctx->total_stat.stat[i].back_good += ctx->inc_stat.stat[i].back_good; - ctx->total_stat.stat[i].back_err += ctx->inc_stat.stat[i].back_err; - back_count = ctx->total_stat.stat[i].back_good + ctx->total_stat.stat[i].back_err; - ctx->total_stat.stat[i].not_back = ctx->total_stat.stat[i].start - back_count; + ctx->total_stat.stat[i].back_good += + ctx->inc_stat.stat[i].back_good; + ctx->total_stat.stat[i].back_err += + ctx->inc_stat.stat[i].back_err; + back_count = ctx->total_stat.stat[i].back_good + + ctx->total_stat.stat[i].back_err; + ctx->total_stat.stat[i].not_back = + ctx->total_stat.stat[i].start - back_count; ps3_stat_lagency_merge(&ctx->total_stat.stat[i].lagency, - &ctx->inc_stat.stat[i].lagency); - mb(); + &ctx->inc_stat.stat[i].lagency); + mb(); /* in order to force CPU ordering */ if (back_count != 0) { - ctx->total_stat.stat[i].lagency.avg = - (ctx->total_stat.stat[i].lagency.all / back_count); + ctx->total_stat.stat[i].lagency.avg = PS3_DIV64_32( + ctx->total_stat.stat[i].lagency.all, + back_count); } } - - return; } static inline void ps3_stat_data_log(const struct ps3_cmd_stat_entry *stat, - const struct ps3_cmd_stat_entry *inc_stat, U16 stat_num) + const struct ps3_cmd_stat_entry *inc_stat, + unsigned short stat_num) { - U16 i = 0; + unsigned short i = 0; for (; i < stat_num; ++i) { - if (inc_stat[i].start == 0) { + if (inc_stat[i].start == 0) continue; - } - LOG_INFO("[%s:] start:%llu back_good:%llu back_err:%llu " - "not_back:%llu avg[%lluus] max[%lluus] min[%lluus]\n", - ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), - stat[i].start, stat[i].back_good, stat[i].back_err, - stat[i].not_back, stat[i].lagency.avg, - stat[i].lagency.max_lagency, stat[i].lagency.min_lagency); + LOG_INFO( + "[%s:] st:%llu bg:%llu ber:%llu nb:%llu avg[%lluus] max[%lluus] min[%lluus]\n", + ps3_cmd_stat_item_tostring((enum ps3_cmd_stat_item)i), + stat[i].start, stat[i].back_good, stat[i].back_err, + stat[i].not_back, stat[i].lagency.avg, + stat[i].lagency.max_lagency, + stat[i].lagency.min_lagency); } - - return; } static inline void ps3_stat_total_data_log(struct ps3_instance *instance) { LOG_INFO("host_no:%u total cmd stat show begin\n", PS3_HOST(instance)); ps3_stat_data_log(instance->cmd_statistics.total_stat.stat, - instance->cmd_statistics.inc_stat.stat, PS3_CMD_STAT_COUNT); + instance->cmd_statistics.inc_stat.stat, + PS3_CMD_STAT_COUNT); LOG_INFO("host_no:%u total cmd stat show end\n", PS3_HOST(instance)); - - return; } static inline void ps3_stat_inc_data_log(struct ps3_instance *instance) { - LOG_INFO("host_no:%u inc cmd stat show begin \n", PS3_HOST(instance)); + LOG_INFO("host_no:%u inc cmd stat show begin\n", PS3_HOST(instance)); ps3_stat_data_log(instance->cmd_statistics.inc_stat.stat, - instance->cmd_statistics.inc_stat.stat, PS3_CMD_STAT_COUNT); - LOG_INFO("host_no:%u inc cmd stat show end \n", PS3_HOST(instance)); - - return; + instance->cmd_statistics.inc_stat.stat, + PS3_CMD_STAT_COUNT); + LOG_INFO("host_no:%u inc cmd stat show end\n", PS3_HOST(instance)); } -static inline Bool ps3_stat_is_write_log(struct ps3_instance *instance) +static inline unsigned char ps3_stat_is_write_log(struct ps3_instance *instance) { return instance->cmd_statistics.log_record_count == PS3_STAT_LOG_COUNT; } @@ -1593,7 +1589,8 @@ static inline Bool ps3_stat_is_write_log(struct ps3_instance *instance) static inline void ps3_stat_log_count_inc(struct ps3_instance *instance) { instance->cmd_statistics.log_record_count++; - if (instance->cmd_statistics.log_record_count == PS3_STAT_LOG_MAX_COUNT) { + if (instance->cmd_statistics.log_record_count == + PS3_STAT_LOG_MAX_COUNT) { instance->cmd_statistics.log_record_count = 0; } } @@ -1601,7 +1598,7 @@ static inline void ps3_stat_log_count_inc(struct ps3_instance *instance) static inline void ps3_stat_write_log(struct ps3_instance *instance) { if (ps3_stat_log_switch_is_open(instance) && - ps3_stat_inc_switch_is_open(instance)) { + ps3_stat_inc_switch_is_open(instance)) { if (ps3_stat_is_write_log(instance)) { ps3_stat_inc_data_log(instance); @@ -1609,8 +1606,6 @@ static inline void ps3_stat_write_log(struct ps3_instance *instance) } ps3_stat_log_count_inc(instance); } - - return; } static inline void ps3_stat_data_collect(struct ps3_instance *instance) @@ -1624,23 +1619,21 @@ static inline void ps3_stat_data_collect(struct ps3_instance *instance) ps3_last_stat_entry_build(instance); ps3_stat_write_log(instance); - - return; } -void ps3_qos_stat_inc(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 stat, U16 type) +void ps3_qos_stat_inc(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned short stat, unsigned short type) { - struct ps3_single_cmd_stat *stat_entry = ps3_stat_entry_find(cmd->index, instance); + struct ps3_single_cmd_stat *stat_entry = + ps3_stat_entry_find(cmd->index, instance); if (stat_entry == NULL) { LOG_ERROR("host_no:%u index:%u stat entry find fail\n", - PS3_HOST(instance), cmd->index); - return; + PS3_HOST(instance), cmd->index); + return; } - if (type == PS3_STAT_START) { + if (type == PS3_STAT_START) ps3_stat_start_inc(stat, stat_entry); - } else if (type == PS3_STAT_BACK) { + else if (type == PS3_STAT_BACK) ps3_stat_back_inc(stat, stat_entry, PS3_STAT_BACK_OK); - } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h index d11d5cdbe39b..d1f1e5ea61ce 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_cmd_statistics.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CMD_STATICTIS_H_ #define _PS3_CMD_STATICTIS_H_ #ifndef _WINDOWS @@ -15,7 +15,7 @@ #include "ps3_scsih.h" #ifdef __cplusplus -extern "C"{ +extern "C" { #endif #define PS3_CMD_STAT_INIT_VALUE (0) @@ -24,346 +24,385 @@ extern "C"{ void ps3_dev_io_statis_init(struct ps3_dev_io_statis *statis); -void ps3_io_statis_inc(struct scsi_device *sdev, enum ps3_dev_io_stat_type type); +void ps3_io_statis_inc(struct scsi_device *sdev, + enum ps3_dev_io_stat_type type); void ps3_io_statis_dec(struct scsi_device *sdev, - enum ps3_dev_io_stat_type type); + enum ps3_dev_io_stat_type type); void ps3_io_statis_clear(struct scsi_device *sdev); -S32 ps3_cmd_statistics_init(struct ps3_instance *instance); +int ps3_cmd_statistics_init(struct ps3_instance *instance); void ps3_cmd_statistics_exit(struct ps3_instance *instance); void ps3_dev_io_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_start_err_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_start_ok_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_dev_io_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, U8 status); + const struct ps3_cmd *cmd, unsigned char status); static inline void ps3_dev_scsi_err_stat_inc(struct ps3_cmd *cmd) { - if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_R_RECV_ERR); - } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)){ - ps3_io_statis_inc(cmd->scmd->device, PS3_DEV_IO_STAT_TYPE_W_RECV_ERR); + if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_R_RECV_ERR); + } else if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag)) { + ps3_io_statis_inc(cmd->scmd->device, + PS3_DEV_IO_STAT_TYPE_W_RECV_ERR); } } -static inline Bool ps3_is_vd_rw_cmd(const struct scsi_cmnd *s_cmd) +static inline unsigned char ps3_is_vd_rw_cmd(const struct scsi_cmnd *s_cmd) { - return (PS3_SDEV_PRI_DATA(s_cmd->device)->dev_type == PS3_DEV_TYPE_VD) && - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd); - + return (PS3_SDEV_PRI_DATA(s_cmd->device)->dev_type == + PS3_DEV_TYPE_VD) && + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd); } -static inline Bool ps3_is_read_cmd(const struct scsi_cmnd *s_cmd) +static inline unsigned char ps3_is_read_cmd(const struct scsi_cmnd *s_cmd) { return ps3_scsih_cdb_is_read_cmd(s_cmd->cmnd); } -static inline Bool ps3_is_write_cmd(const struct scsi_cmnd *s_cmd) +static inline unsigned char ps3_is_write_cmd(const struct scsi_cmnd *s_cmd) { return ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd); } void ps3_io_outstand_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_io_outstand_dec(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd); + const struct scsi_cmnd *s_cmd); -void ps3_vd_outstand_dec(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd); +void ps3_vd_outstand_dec(struct ps3_cmd *cmd); -void ps3_vd_outstand_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd); +void ps3_vd_outstand_inc(struct ps3_cmd *cmd); void ps3_dev_io_outstand_dec(const struct ps3_cmd *cmd); -void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data* priv_data); +void ps3_dev_io_qos_inc(struct ps3_scsi_priv_data *priv_data); -void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data* priv_data); +void ps3_dev_io_qos_dec(struct ps3_scsi_priv_data *priv_data); void ps3_dev_io_outstand_inc(const struct ps3_cmd *cmd); void ps3_qos_cmd_inc(struct ps3_instance *instance); -void ps3_qos_stat_inc(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 stat, U16 type); +void ps3_qos_stat_inc(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned short stat, unsigned short type); -static inline U8 ps3_cmd_word_index_get(struct ps3_instance *instance) +static inline unsigned char +ps3_cmd_word_index_get(struct ps3_instance *instance) { - U64 cmd_count = (U64)ps3_atomic64_inc_return(&instance->cmd_statistics.cmd_word_send_count); - return (U8)(cmd_count & PS3_CMD_WORD_INDEX_SHIFT); + unsigned long long cmd_count = + (unsigned long long)ps3_atomic64_inc_return( + &instance->cmd_statistics.cmd_word_send_count); + return (unsigned char)(cmd_count & PS3_CMD_WORD_INDEX_SHIFT); } static inline void ps3_cmd_word_stat_inc(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { (void)cmd_word; (void)ps3_cmd_word_index_get(instance); - return; } #ifndef _WINDOWS -void ps3_scmd_inc(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, U8 type, U8 status); +void ps3_scmd_inc(struct ps3_instance *instance, struct scsi_cmnd *s_cmd, + unsigned char type, unsigned char status); #else -void ps3_scmd_inc(struct ps3_instance *instance, - const struct scsi_cmnd *s_cmd, U32 tag, U8 type, U8 status); +void ps3_scmd_inc(struct ps3_instance *instance, const struct scsi_cmnd *s_cmd, + unsigned int tag, unsigned char type, unsigned char status); #endif void ps3_scmd_drv2ioc_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); void ps3_scmd_drv2ioc_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, U8 status); - + const struct ps3_cmd *cmd, unsigned char status); -static inline U8 ps3_resp_stauts_to_stat_status(U8 reply_flags) +static inline unsigned char +ps3_resp_stauts_to_stat_status(unsigned char reply_flags) { return (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS) ? - (U8)PS3_STAT_BACK_OK : (U8)PS3_STAT_BACK_FAIL; + (unsigned char)PS3_STAT_BACK_OK : + (unsigned char)PS3_STAT_BACK_FAIL; } void ps3_mgr_start_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd); + const struct ps3_cmd *cmd); -void ps3_mgr_back_inc(struct ps3_instance *instance, - const struct ps3_cmd *cmd, U8 status); +void ps3_mgr_back_inc(struct ps3_instance *instance, const struct ps3_cmd *cmd, + unsigned char status); void ps3_stat_all_clear(struct ps3_instance *instance); -static inline Bool ps3_stat_inc_switch_is_open(const struct ps3_instance *instance) +static inline unsigned char +ps3_stat_inc_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_INC_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & + PS3_STAT_INC_SWITCH_OPEN); } -static inline Bool ps3_stat_log_switch_is_open(const struct ps3_instance *instance) +static inline unsigned char +ps3_stat_log_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_LOG_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & + PS3_STAT_LOG_SWITCH_OPEN); } -static inline Bool ps3_stat_outstand_switch_is_open(const struct ps3_instance *instance) +static inline unsigned char +ps3_stat_outstand_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_OUTSTAND_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & + PS3_STAT_OUTSTAND_SWITCH_OPEN); } -static inline Bool ps3_stat_dev_switch_is_open(const struct ps3_instance *instance) +static inline unsigned char +ps3_stat_dev_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_DEV_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & + PS3_STAT_DEV_SWITCH_OPEN); } #ifndef _WINDOWS static inline void ps3_sdev_busy_inc(struct scsi_cmnd *scmd) { #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)scmd->device->hostdata; - if (device_priv_data == NULL) { + struct ps3_scsi_priv_data *device_priv_data = + (struct ps3_scsi_priv_data *)scmd->device->hostdata; + if (device_priv_data == NULL) return; - } atomic_inc(&device_priv_data->sdev_priv_busy); #else #ifdef PS3_UT atomic_inc(&scmd->device->device_busy); #else - (void) scmd; + (void)scmd; #endif #endif - - return; } static inline void ps3_sdev_busy_dec(struct scsi_cmnd *scmd) { #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)scmd->device->hostdata; - if (device_priv_data == NULL) { + struct ps3_scsi_priv_data *device_priv_data = + (struct ps3_scsi_priv_data *)scmd->device->hostdata; + if (device_priv_data == NULL) return; - } atomic_dec(&device_priv_data->sdev_priv_busy); #else #ifdef PS3_UT atomic_dec(&scmd->device->device_busy); #else - (void) scmd; + (void)scmd; #endif #endif - return; } -#define PS3_DEV_BUSY_DEC(cmd) do { \ - ps3_sdev_busy_dec((cmd)); \ -} while (0) +#define PS3_DEV_BUSY_DEC(cmd) ps3_sdev_busy_dec((cmd)) -#define PS3_DEV_BUSY_INC(cmd) do { \ - ps3_sdev_busy_inc((cmd)); \ -} while (0) +#define PS3_DEV_BUSY_INC(cmd) ps3_sdev_busy_inc((cmd)) #else #define PS3_DEV_BUSY_DEC(cmd) #define PS3_DEV_BUSY_INC(cmd) #endif -static inline Bool ps3_stat_qos_switch_is_open(const struct ps3_instance *instance) +static inline unsigned char +ps3_stat_qos_switch_is_open(const struct ps3_instance *instance) { - return (instance->cmd_statistics.cmd_stat_switch & PS3_STAT_QOS_SWITCH_OPEN); + return (instance->cmd_statistics.cmd_stat_switch & + PS3_STAT_QOS_SWITCH_OPEN); } -#define PS3_CMD_WORD_STAT_INC(instance, cmd_word) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_cmd_word_stat_inc((instance), (cmd_word)); \ - } \ -} while (0) - -#define PS3_DEV_IO_START_OK_INC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_ok_inc((instance), (cmd)); \ - } \ -} while (0); - -#define PS3_DEV_IO_BACK_INC(instance, cmd, status) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_back_inc((instance), (cmd), (status)); \ - } \ -} while (0); - -#define PS3_DEV_IO_START_ERR_INC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_err_inc((instance), (cmd)); \ - } \ -} while (0); - -#define PS3_DEV_IO_START_INC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_start_inc((instance), (cmd)); \ - } \ -} while (0) +#define PS3_CMD_WORD_STAT_INC(instance, cmd_word) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_cmd_word_stat_inc((instance), (cmd_word)); \ + } \ + } while (0) + +#define PS3_DEV_IO_START_OK_INC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_ok_inc((instance), (cmd)); \ + } \ + } while (0) + +#define PS3_DEV_IO_BACK_INC(instance, cmd, status) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_back_inc((instance), (cmd), (status)); \ + } \ + } while (0) + +#define PS3_DEV_IO_START_ERR_INC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_err_inc((instance), (cmd)); \ + } \ + } while (0) + +#define PS3_DEV_IO_START_INC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_start_inc((instance), (cmd)); \ + } \ + } while (0) #ifndef _WINDOWS -#define PS3_IO_BACK_INC(instance, s_cmd, status) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ -} while (0) +#define PS3_IO_BACK_INC(instance, s_cmd, status) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc( \ + (instance), (s_cmd), PS3_STAT_BACK, \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ + } while (0) #else -#define PS3_IO_BACK_INC(instance, s_cmd, tag, status) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_BACK, \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ -} while (0) +#define PS3_IO_BACK_INC(instance, s_cmd, tag, status) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc( \ + (instance), (s_cmd), (tag), PS3_STAT_BACK, \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ + } while (0) #endif -#define PS3_IO_OUTSTANDING_INC(instance, cmd) do { \ - ps3_io_outstand_inc(instance, cmd); \ -} while (0) - -#define PS3_DEV_IO_ERR_STAT_INC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_scsi_err_stat_inc((cmd)); \ - } \ -} while (0) +#define PS3_IO_OUTSTANDING_INC(instance, cmd) ps3_io_outstand_inc(instance, cmd) + +#define PS3_DEV_IO_ERR_STAT_INC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_scsi_err_stat_inc((cmd)); \ + } \ + } while (0) #ifndef _WINDOWS -#define PS3_IO_START_INC(instance, s_cmd) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), PS3_STAT_START, PS3_STAT_BACK_OK); \ - } \ -} while (0) - -#define PS3_IO_BACK_ERR_INC(instance, s_cmd) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ - } \ -} while (0) +#define PS3_IO_START_INC(instance, s_cmd) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), PS3_STAT_START, \ + PS3_STAT_BACK_OK); \ + } \ + } while (0) + +#define PS3_IO_BACK_ERR_INC(instance, s_cmd) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), PS3_STAT_BACK, \ + PS3_STAT_BACK_FAIL); \ + } \ + } while (0) #else -#define PS3_IO_START_INC(instance, s_cmd, tag) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_START, PS3_STAT_BACK_OK); \ - } \ -} while (0) - -#define PS3_IO_BACK_ERR_INC(instance, s_cmd, tag) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_inc((instance), (s_cmd), (tag), PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ - } \ -} while (0) +#define PS3_IO_START_INC(instance, s_cmd, tag) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), (tag), \ + PS3_STAT_START, PS3_STAT_BACK_OK); \ + } \ + } while (0) + +#define PS3_IO_BACK_ERR_INC(instance, s_cmd, tag) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_inc((instance), (s_cmd), (tag), \ + PS3_STAT_BACK, PS3_STAT_BACK_FAIL); \ + } \ + } while (0) #endif -#define PS3_IO_DRV2IOC_START_INC(instance, cmd) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_drv2ioc_start_inc((instance), (cmd)); \ - } \ -} while (0) - -#define PS3_IOC_DRV2IOC_BACK_INC(instance, cmd, status) { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_scmd_drv2ioc_back_inc((instance), (cmd), \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ -} while (0) - -#define PS3_MGR_CMD_STAT_INC(instance, cmd) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_mgr_start_inc((instance), (cmd)); \ - } \ -} while (0) - -#define PS3_MGR_CMD_BACK_INC(instance, cmd, status) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_mgr_back_inc((instance), (cmd), \ - ps3_resp_stauts_to_stat_status((status))); \ - } \ -} while (0) - -#define PS3_IO_OUTSTAND_DEC(instance, s_cmd) do { \ - if (ps3_stat_outstand_switch_is_open((instance))) { \ - ps3_io_outstand_dec((instance), (s_cmd)); \ - } \ -} while (0) - -#define PS3_VD_OUTSTAND_DEC(instance, s_cmd) do { \ - ps3_vd_outstand_dec(instance, s_cmd); \ -} while (0) - -#define PS3_VD_OUTSTAND_INC(instance, s_cmd) do { \ - ps3_vd_outstand_inc(instance, s_cmd); \ -} while (0) - -#define PS3_DEV_IO_OUTSTAND_DEC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_outstand_dec((cmd)); \ - } \ -} while (0) - -#define PS3_DEV_IO_OUTSTAND_INC(instance, cmd) do { \ - if (ps3_stat_dev_switch_is_open((instance))) { \ - ps3_dev_io_outstand_inc((cmd)); \ - } \ -} while (0) - -#define PS3_QOS_CMD_INC(instance) do { \ - if (ps3_stat_qos_switch_is_open((instance))) { \ - ps3_qos_cmd_inc((instance)); \ - } \ -} while (0) - -#define PS3_QOS_STAT_START(instance, cmd, type) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_qos_stat_inc((instance), (cmd), (type), PS3_STAT_START); \ - } \ +#define PS3_IO_DRV2IOC_START_INC(instance, cmd) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_drv2ioc_start_inc((instance), (cmd)); \ + } \ + } while (0) + +#define PS3_IOC_DRV2IOC_BACK_INC(instance, cmd, status) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_scmd_drv2ioc_back_inc( \ + (instance), (cmd), \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ + } while (0) + +#define PS3_MGR_CMD_STAT_INC(instance, cmd) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_mgr_start_inc((instance), (cmd)); \ + } \ + } while (0) + +#define PS3_MGR_CMD_BACK_INC(instance, cmd, status) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_mgr_back_inc( \ + (instance), (cmd), \ + ps3_resp_stauts_to_stat_status((status))); \ + } \ + } while (0) + +#define PS3_IO_OUTSTAND_DEC(instance, s_cmd) \ + do { \ + if (ps3_stat_outstand_switch_is_open((instance))) { \ + ps3_io_outstand_dec((instance), (s_cmd)); \ + } \ + } while (0) + +#define PS3_VD_OUTSTAND_DEC(instance, cmd) ps3_vd_outstand_dec(cmd) + +#define PS3_VD_OUTSTAND_INC(instance, cmd) ps3_vd_outstand_inc(cmd) + +#define PS3_DEV_IO_OUTSTAND_DEC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_outstand_dec((cmd)); \ + } \ } while (0) -#define PS3_QOS_STAT_END(instance, cmd, type) do { \ - if (ps3_stat_inc_switch_is_open((instance))) { \ - ps3_qos_stat_inc((instance), (cmd), (type), PS3_STAT_BACK); \ - } \ +#define PS3_DEV_IO_OUTSTAND_INC(instance, cmd) \ + do { \ + if (ps3_stat_dev_switch_is_open((instance))) { \ + ps3_dev_io_outstand_inc((cmd)); \ + } \ } while (0) -S32 ps3_stat_workq_start(struct ps3_instance *instance); +#define PS3_QOS_CMD_INC(instance) \ + do { \ + if (ps3_stat_qos_switch_is_open((instance))) { \ + ps3_qos_cmd_inc((instance)); \ + } \ + } while (0) + +#define PS3_QOS_STAT_START(instance, cmd, type) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_qos_stat_inc((instance), (cmd), (type), \ + PS3_STAT_START); \ + } \ + } while (0) + +#define PS3_QOS_STAT_END(instance, cmd, type) \ + do { \ + if (ps3_stat_inc_switch_is_open((instance))) { \ + ps3_qos_stat_inc((instance), (cmd), (type), \ + PS3_STAT_BACK); \ + } \ + } while (0) + +#define PS3_VD_READ_OUTSTAND(data) ps3_atomic_read(&(data)->rd_io_outstand) + +#define PS3_VD_WRITE_OUTSTAND(data) ps3_atomic_read(&(data)->wr_io_outstand) + +int ps3_stat_workq_start(struct ps3_instance *instance); void ps3_stat_workq_stop(struct ps3_instance *instance); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_debug.c b/drivers/scsi/linkdata/ps3stor/ps3_debug.c index 6cfe8eff6d47..a48e01f54674 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_debug.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_debug.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include @@ -27,193 +28,197 @@ #include "ps3_instance_manager.h" #include "ps3_event.h" #include "ps3_dump.h" -#define REG_OFFSET_BY_ADDR(instance, reg) ((U8*)(reg) - ((U8*)(instance)->reg_set)) +#include "ps3_kernel_version.h" -#ifndef _WINDOWS -typedef void (*dma_dump_mappings_cb)(struct device *dev); -#endif +#define REG_OFFSET_BY_ADDR(instance, reg) \ + ((unsigned char *)(reg) - ((unsigned char *)(instance)->reg_set)) struct ps3_reg_name { - U64 read_dump_interval_ms; - U64 write_dump_interval_ms; - U32 reg_cnt; - S8 name[32]; + unsigned long long read_dump_interval_ms; + unsigned long long write_dump_interval_ms; + unsigned int reg_cnt; + char name[32]; }; static struct ps3_reg_name g_ps3_reg_name_table[] = { - {0, 0, 8, "reserved0"}, - {0, 0, 1, "ps3Doorbell"}, - {0, 0, 1, "ps3DoorbellIrqClear"}, - {0, 0, 1, "ps3DoorbellIrqMask"}, - {0, 0, 1, "ps3IrqControl"}, - {0, 0, 20, "reserved1"}, - - {0, 0, 1, "ps3SoftresetKey"}, - {1000, 0, 1, "ps3SoftresetState"}, - {0, 0, 1, "ps3Softreset"}, - {0, 0, 1, "ps3SoftresetIrqClear"}, - {0, 0, 1, "ps3SoftresetIrqMask"}, - {0, 0, 1, "ps3SoftresetKeyShiftRegLow"}, - {0, 0, 1, "ps3SoftresetKeyShiftRegHigh"}, - {0, 0, 1, "ps3SoftresetTimeCnt"}, - {0, 0, 1, "ps3SoftresetTimeOutEn"}, - {0, 0, 23, "reserved2"}, - - {0, 0, 1, "ps3HardresetKey"}, - {1000, 0, 1, "ps3HardresetState"}, - {0, 0, 1, "ps3Hardreset"}, - {0, 0, 1, "ps3HardresetKeyShiftRegLow"}, - {0, 0, 1, "ps3HardresetKeyShiftRegHigh"}, - {0, 0, 1, "ps3HardresetTimeCnt"}, - {0, 0, 1, "ps3HardresetTimeOutEn"}, - {0, 0, 1, "ps3KeyGapCfg"}, - {0, 0, 1, "ps3HardresetIrqClear"}, - {0, 0, 1, "ps3HardresetIrqMask"}, - {0, 0, 22, "reserved3"}, - - {10000, 0, 1, "ps3SocFwState"}, - {0, 0, 1, "ps3MaxFwCmd"}, - {0, 0, 1, "ps3MaxChainSize"}, - {0, 0, 1, "ps3MaxVdInfoSize"}, - {0, 0, 1, "ps3MaxNvmePageSize"}, - {0, 0, 1, "ps3FeatureSupport"}, - {0, 0, 1, "ps3FirmwareVersion"}, - {0, 0, 1, "ps3MaxReplyque"}, - {0, 0, 1, "ps3HardwareVersion"}, - {0, 0, 1, "ps3MgrQueueDepth"}, - {0, 0, 1, "ps3CmdQueueDepth"}, - {0, 0, 1, "ps3TfifoDepth"}, - {0, 0, 1, "ps3MaxSecR1xCmds"}, - {0, 0, 19, "reserved4"}, - - {0, 0, 1, "ps3HilAdvice2directCnt0"}, - {0, 0, 1, "ps3HilAdvice2directCnt1"}, - {0, 0, 1, "ps3HilAdvice2directCnt2"}, - {0, 0, 1, "ps3HilAdvice2directCnt3"}, - {0, 0, 1, "ps3HilAdvice2directCntAll"}, - {0, 0, 3, "reserved5"}, - {0, 0, 1, "ps3IrqStatusRpt"}, - {0, 0, 23, "reserved6"}, - - {0, 0, 1, "ps3DumpCtrl"}, - {0, 0, 1, "ps3DumpCtrlIrqClear"}, - {0, 0, 1, "ps3DumpCtrlIrqMask"}, - {0, 0, 1, "ps3DumpStatus"}, - {0, 0, 1, "ps3DumpDataSize"}, - {0, 0, 27, "reserved7"}, - - {0, 0, 1, "ps3CmdTrigger"}, - {0, 0, 1, "ps3CmdTriggerIrqClear"}, - {0, 0, 1, "ps3CmdTriggerIrqMask"}, - {0, 0, 1, "ps3SoftresetCounter"}, - {0, 0, 1, "ps3RegCmdState"}, - {0, 0, 1, "ps3Debug0"}, - {0, 0, 1, "ps3Debug0IrqClear"}, - {0, 0, 1, "ps3Debug0IrqMask"}, - {0, 0, 1, "ps3Debug1"}, - {0, 0, 1, "ps3Debug1IrqClear"}, - {0, 0, 1, "ps3Debug1IrqMask"}, - {0, 0, 1, "ps3Debug2"}, - {0, 0, 1, "ps3Debug2IrqClear"}, - {0, 0, 1, "ps3Debug2IrqMask"}, - {0, 0, 1, "ps3Debug3"}, - {0, 0, 1, "ps3Debug3IrqClear"}, - {0, 0, 1, "ps3Debug3IrqMask"}, - {0, 0, 1, "ps3Debug4"}, - {0, 0, 1, "ps3Debug4IrqClear"}, - {0, 0, 1, "ps3Debug4IrqMask"}, - {0, 0, 1, "ps3Debug5"}, - {0, 0, 1, "ps3Debug6"}, - {0, 0, 1, "ps3Debug7"}, - {0, 0, 1, "ps3Debug8"}, - {0, 0, 1, "ps3Debug9"}, - {0, 0, 1, "ps3Debug10"}, - {0, 0, 1, "ps3Debug11"}, - {0, 0, 1, "ps3Debug12"}, - {0, 0, 4, "reserved8"}, - - {0, 0, 1, "ps3SessioncmdAddr"}, - {0, 0, 1, "ps3SessioncmdAddrIrqClear"}, - {0, 0, 1, "ps3SessioncmdAddrIrqMask"}, - {0, 0, 7965, "reserved9"}, - {0, 0, 1, "ps3RequestQueue"}, - {0, 0, 1, "fifoErrCnt"}, - {0, 0, 1, "fifoStatus"}, - {0, 0, 1, "fifoLevelConfig"}, - {0, 0, 1, "fifoRst"}, - {0, 0, 1, "fifoIOCnt"}, - {0, 0, 1, "fifoFlowCnt"}, - {0, 0, 1, "fifoIntStatus"}, - {0, 0, 1, "fifoIntSet"}, - {0, 0, 1, "fifoIntClr"}, - {0, 0, 1, "fifoIntMask"}, - {0, 0, 1, "fifoCntClr"}, - {0, 0, 1, "fifoOrderError"}, - {0, 0, 4, "fifoDinShift"}, - {0, 0, 4, "fifoDoutShift"}, - {0, 0, 1, "fifoStatusMaxLevel"}, - {0, 0, 1, "fifoInit"}, - {0, 0, 1, "fifoinitEn"}, - {0, 0, 1, "fifoinitMax"}, - {0, 0, 1, "fifoStatusEccCnt"}, - {0, 0, 1, "fifoStatusEccAddr"}, - {0, 0, 1, "fifoDecoderOverflow"}, - {0, 0, 1, "fifoEccBadProject"}, - {0, 0, 1, "fifoOverFlowWord"}, - {0, 0, 34, "reserved10"}, - - {0, 0, 1, "ps3FucntionLock"}, - {0, 0, 1, "ps3FunctionLockOwner"}, - {0, 0, 30, "reserved11"}, + { 0, 0, 8, "reserved0" }, + { 0, 0, 1, "ps3Doorbell" }, + { 0, 0, 1, "ps3DoorbellIrqClear" }, + { 0, 0, 1, "ps3DoorbellIrqMask" }, + { 0, 0, 1, "ps3IrqControl" }, + { 0, 0, 20, "reserved1" }, + + { 0, 0, 1, "ps3SoftresetKey" }, + { 1000, 0, 1, "ps3SoftresetState" }, + { 0, 0, 1, "ps3Softreset" }, + { 0, 0, 1, "ps3SoftresetIrqClear" }, + { 0, 0, 1, "ps3SoftresetIrqMask" }, + { 0, 0, 1, "ps3SoftresetKeyShiftRegLow" }, + { 0, 0, 1, "ps3SoftresetKeyShiftRegHigh" }, + { 0, 0, 1, "ps3SoftresetTimeCnt" }, + { 0, 0, 1, "ps3SoftresetTimeOutEn" }, + { 0, 0, 23, "reserved2" }, + + { 0, 0, 1, "ps3HardresetKey" }, + { 1000, 0, 1, "ps3HardresetState" }, + { 0, 0, 1, "ps3Hardreset" }, + { 0, 0, 1, "ps3HardresetKeyShiftRegLow" }, + { 0, 0, 1, "ps3HardresetKeyShiftRegHigh" }, + { 0, 0, 1, "ps3HardresetTimeCnt" }, + { 0, 0, 1, "ps3HardresetTimeOutEn" }, + { 0, 0, 1, "ps3KeyGapCfg" }, + { 0, 0, 1, "ps3HardresetIrqClear" }, + { 0, 0, 1, "ps3HardresetIrqMask" }, + { 0, 0, 22, "reserved3" }, + + { 10000, 0, 1, "ps3SocFwState" }, + { 0, 0, 1, "ps3MaxFwCmd" }, + { 0, 0, 1, "ps3MaxChainSize" }, + { 0, 0, 1, "ps3MaxVdInfoSize" }, + { 0, 0, 1, "ps3MaxNvmePageSize" }, + { 0, 0, 1, "ps3FeatureSupport" }, + { 0, 0, 1, "ps3FirmwareVersion" }, + { 0, 0, 1, "ps3MaxReplyque" }, + { 0, 0, 1, "ps3HardwareVersion" }, + { 0, 0, 1, "ps3MgrQueueDepth" }, + { 0, 0, 1, "ps3CmdQueueDepth" }, + { 0, 0, 1, "ps3TfifoDepth" }, + { 0, 0, 1, "ps3MaxSecR1xCmds" }, + { 0, 0, 19, "reserved4" }, + + { 0, 0, 1, "ps3HilAdvice2directCnt0" }, + { 0, 0, 1, "ps3HilAdvice2directCnt1" }, + { 0, 0, 1, "ps3HilAdvice2directCnt2" }, + { 0, 0, 1, "ps3HilAdvice2directCnt3" }, + { 0, 0, 1, "ps3HilAdvice2directCntAll" }, + { 0, 0, 3, "reserved5" }, + { 0, 0, 1, "ps3IrqStatusRpt" }, + { 0, 0, 23, "reserved6" }, + + { 0, 0, 1, "ps3DumpCtrl" }, + { 0, 0, 1, "ps3DumpCtrlIrqClear" }, + { 0, 0, 1, "ps3DumpCtrlIrqMask" }, + { 0, 0, 1, "ps3DumpStatus" }, + { 0, 0, 1, "ps3DumpDataSize" }, + { 0, 0, 27, "reserved7" }, + + { 0, 0, 1, "ps3CmdTrigger" }, + { 0, 0, 1, "ps3CmdTriggerIrqClear" }, + { 0, 0, 1, "ps3CmdTriggerIrqMask" }, + { 0, 0, 1, "ps3SoftresetCounter" }, + { 0, 0, 1, "ps3RegCmdState" }, + { 0, 0, 1, "ps3Debug0" }, + { 0, 0, 1, "ps3Debug0IrqClear" }, + { 0, 0, 1, "ps3Debug0IrqMask" }, + { 0, 0, 1, "ps3Debug1" }, + { 0, 0, 1, "ps3Debug1IrqClear" }, + { 0, 0, 1, "ps3Debug1IrqMask" }, + { 0, 0, 1, "ps3Debug2" }, + { 0, 0, 1, "ps3Debug2IrqClear" }, + { 0, 0, 1, "ps3Debug2IrqMask" }, + { 0, 0, 1, "ps3Debug3" }, + { 0, 0, 1, "ps3Debug3IrqClear" }, + { 0, 0, 1, "ps3Debug3IrqMask" }, + { 0, 0, 1, "ps3Debug4" }, + { 0, 0, 1, "ps3Debug4IrqClear" }, + { 0, 0, 1, "ps3Debug4IrqMask" }, + { 0, 0, 1, "ps3Debug5" }, + { 0, 0, 1, "ps3Debug6" }, + { 0, 0, 1, "ps3Debug7" }, + { 0, 0, 1, "ps3Debug8" }, + { 0, 0, 1, "ps3Debug9" }, + { 0, 0, 1, "ps3Debug10" }, + { 0, 0, 1, "ps3Debug11" }, + { 0, 0, 1, "ps3Debug12" }, + { 0, 0, 4, "reserved8" }, + + { 0, 0, 1, "ps3SessioncmdAddr" }, + { 0, 0, 1, "ps3SessioncmdAddrIrqClear" }, + { 0, 0, 1, "ps3SessioncmdAddrIrqMask" }, + { 0, 0, 7965, "reserved9" }, + { 0, 0, 1, "ps3RequestQueue" }, + { 0, 0, 1, "fifoErrCnt" }, + { 0, 0, 1, "fifoStatus" }, + { 0, 0, 1, "fifoLevelConfig" }, + { 0, 0, 1, "fifoRst" }, + { 0, 0, 1, "fifoIOCnt" }, + { 0, 0, 1, "fifoFlowCnt" }, + { 0, 0, 1, "fifoIntStatus" }, + { 0, 0, 1, "fifoIntSet" }, + { 0, 0, 1, "fifoIntClr" }, + { 0, 0, 1, "fifoIntMask" }, + { 0, 0, 1, "fifoCntClr" }, + { 0, 0, 1, "fifoOrderError" }, + { 0, 0, 4, "fifoDinShift" }, + { 0, 0, 4, "fifoDoutShift" }, + { 0, 0, 1, "fifoStatusMaxLevel" }, + { 0, 0, 1, "fifoInit" }, + { 0, 0, 1, "fifoinitEn" }, + { 0, 0, 1, "fifoinitMax" }, + { 0, 0, 1, "fifoStatusEccCnt" }, + { 0, 0, 1, "fifoStatusEccAddr" }, + { 0, 0, 1, "fifoDecoderOverflow" }, + { 0, 0, 1, "fifoEccBadProject" }, + { 0, 0, 1, "fifoOverFlowWord" }, + { 0, 0, 34, "reserved10" }, + + { 0, 0, 1, "ps3FucntionLock" }, + { 0, 0, 1, "ps3FunctionLockOwner" }, + { 0, 0, 30, "reserved11" }, }; -static inline U64 ps3_util_now_timestamp_ms_get(void) +static inline unsigned long long ps3_util_now_timestamp_ms_get(void) { - U64 timenow = 0; + unsigned long long timenow = 0; #ifndef _WINDOWS -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#if defined(PS3_DUMP_TIME_32) struct timespec now; + now = current_kernel_time(); #else struct timespec64 now; + ktime_get_coarse_real_ts64(&now); #endif timenow = now.tv_sec * 1000 + now.tv_nsec / 1000000; #else LARGE_INTEGER now; + StorPortQuerySystemTime(&now); - timenow = (U64)(now.QuadPart / 10000); + timenow = (unsigned long long)(now.QuadPart / 10000); #endif return timenow; - } static void ps3_reg_dump_attr_init(struct ps3_instance *instance) { - U32 local_index = 0; - U32 count = 0; - U32 table_index = 0; - U32 table_cnt = 0; - U32 table_size = (sizeof(g_ps3_reg_name_table)/sizeof(g_ps3_reg_name_table[0])); + unsigned int local_index = 0; + unsigned int count = 0; + unsigned int table_index = 0; + unsigned int table_cnt = 0; + unsigned int table_size = (sizeof(g_ps3_reg_name_table) / + sizeof(g_ps3_reg_name_table[0])); struct ps3_reg_dump_attr *reg_dump = instance->debug_context.reg_dump; for (table_index = 0; table_index < table_size; table_index++) { table_cnt = g_ps3_reg_name_table[table_index].reg_cnt; for (local_index = 0; local_index < table_cnt; local_index++) { - if (count >= (PS3_REGISTER_SET_SIZE/sizeof(U64))) { + if (count >= (PS3_REGISTER_SET_SIZE / + sizeof(unsigned long long))) goto l_out; - } reg_dump[count].read_dump_timestamp = 0; reg_dump[count].write_dump_timestamp = 0; reg_dump[count].read_dump_interval_ms = - g_ps3_reg_name_table[table_index].read_dump_interval_ms; + g_ps3_reg_name_table[table_index] + .read_dump_interval_ms; reg_dump[count].write_dump_interval_ms = - g_ps3_reg_name_table[table_index].write_dump_interval_ms; + g_ps3_reg_name_table[table_index] + .write_dump_interval_ms; memcpy(reg_dump[count].name, - g_ps3_reg_name_table[table_index].name, 32); + g_ps3_reg_name_table[table_index].name, 32); reg_dump[count].lastest_value = 0; count++; @@ -223,20 +228,23 @@ static void ps3_reg_dump_attr_init(struct ps3_instance *instance) return; } -void ps3_reg_dump(struct ps3_instance *instance, - void __iomem *reg, U64 value, Bool is_read) +void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, + unsigned long long value, unsigned char is_read) { - Bool is_dump = PS3_FALSE; - const S8 *dump_type = NULL; - U64 timestamp_ms = ps3_util_now_timestamp_ms_get(); - U64 last_dump_timestamp = 0; - U64 dump_interval = 0; - U32 reg_index = (U32)REG_OFFSET_BY_ADDR(instance, reg)/sizeof(U64); + unsigned char is_dump = PS3_FALSE; + const char *dump_type = NULL; + unsigned long long timestamp_ms = ps3_util_now_timestamp_ms_get(); + unsigned long long last_dump_timestamp = 0; + unsigned long long dump_interval = 0; + unsigned int reg_index = + (unsigned int)REG_OFFSET_BY_ADDR(instance, reg) / + sizeof(unsigned long long); struct ps3_reg_dump_attr *reg_dump = instance->debug_context.reg_dump; - if( (reg == NULL) || - ((U8*)reg < (U8*)instance->reg_set) || - (((U8*)reg - (U8*)instance->reg_set) > PS3_REGISTER_SET_SIZE)) { + if ((reg == NULL) || + ((unsigned char *)reg < (unsigned char *)instance->reg_set) || + (((unsigned char *)reg - (unsigned char *)instance->reg_set) > + PS3_REGISTER_SET_SIZE)) { return; } @@ -250,61 +258,63 @@ void ps3_reg_dump(struct ps3_instance *instance, dump_interval = reg_dump[reg_index].write_dump_interval_ms; } - if (timestamp_ms - last_dump_timestamp >= dump_interval) { + if (timestamp_ms - last_dump_timestamp >= dump_interval) is_dump = PS3_TRUE; - } if (reg_dump[reg_index].lastest_value != value) { is_dump = PS3_TRUE; reg_dump[reg_index].lastest_value = value; } - if (!is_dump) { + if (!is_dump) return; - } - LOG_DEBUG("hno:%u %s:0x%04x:%s:0x%08llx \n", - PS3_HOST(instance), dump_type, - (U32)(reg_index * sizeof(U64)), - reg_dump[reg_index].name, value); - if (is_read) { + LOG_DEBUG("hno:%u %s:0x%04x:%s:0x%08llx\n", PS3_HOST(instance), + dump_type, + (unsigned int)(reg_index * sizeof(unsigned long long)), + reg_dump[reg_index].name, value); + if (is_read) reg_dump[reg_index].read_dump_timestamp = timestamp_ms; - } else { + else reg_dump[reg_index].write_dump_timestamp = timestamp_ms; - } } #ifndef _WINDOWS -static inline Bool ps3_is_alloc_debug_mem(U32 debug_mem_size) +static inline unsigned char ps3_is_alloc_debug_mem(unsigned int debug_mem_size) { return (debug_mem_size != 0); } -static S32 ps3_debug_mem_array_alloc(struct ps3_instance *instance, - U32 debug_mem_size) +static int ps3_debug_mem_array_alloc(struct ps3_instance *instance, + unsigned int debug_mem_size) { - S32 ret = PS3_SUCCESS; - U32 array_num = 0; - U32 alloc_size = 0; + int ret = PS3_SUCCESS; + unsigned int array_num = 0; + unsigned int alloc_size = 0; struct ps3_debug_context *ctx = &instance->debug_context; - Ps3DebugMemEntry_s *entry = (Ps3DebugMemEntry_s*)ctx->debug_mem_buf; - U8 i = 0; + struct Ps3DebugMemEntry *entry = + (struct Ps3DebugMemEntry *)ctx->debug_mem_buf; + unsigned char i = 0; for (; i < PS3_DEBUG_MEM_ARRAY_MAX_NUM; ++i) { - if (debug_mem_size == 0) { + if (debug_mem_size == 0) break; - } array_num++; if (debug_mem_size <= PS3_MAX_DMA_MEM_SIZE) { alloc_size = debug_mem_size * 1024; ctx->debug_mem_vaddr[i].debugMemAddr = - (U64)ps3_dma_alloc_coherent(instance, alloc_size, - &entry[i].debugMemAddr); - INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); + (unsigned long long)(uintptr_t) + ps3_dma_alloc_coherent( + instance, alloc_size, + (unsigned long long *)&entry[i] + .debugMemAddr); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, + &ctx->debug_mem_vaddr[i].debugMemAddr); if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { - LOG_ERROR("hno:%u alloc debug_mem[%u] end failed\n", + LOG_ERROR( + "hno:%u alloc debug_mem[%u] end failed\n", PS3_HOST(instance), i); ret = -PS3_ENOMEM; goto l_out; @@ -312,59 +322,76 @@ static S32 ps3_debug_mem_array_alloc(struct ps3_instance *instance, ctx->debug_mem_vaddr[i].debugMemSize = debug_mem_size; entry[i].debugMemSize = debug_mem_size; debug_mem_size = 0; - LOG_INFO("hno:%u index[%u] vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", - PS3_HOST(instance), i, ctx->debug_mem_vaddr[i].debugMemAddr, + LOG_INFO( + "hno:%u index[%u] vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", + PS3_HOST(instance), i, + ctx->debug_mem_vaddr[i].debugMemAddr, entry[i].debugMemAddr, entry[i].debugMemSize); - break; } else { debug_mem_size -= PS3_MAX_DMA_MEM_SIZE; alloc_size = PS3_MAX_DMA_MEM_SIZE * 1024; ctx->debug_mem_vaddr[i].debugMemAddr = - (U64)ps3_dma_alloc_coherent(instance, alloc_size, - &entry[i].debugMemAddr); - INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, &ctx->debug_mem_vaddr[i].debugMemAddr); + (unsigned long long)(uintptr_t) + ps3_dma_alloc_coherent( + instance, alloc_size, + (unsigned long long *)&entry[i] + .debugMemAddr); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_ADDR_ALLOC, + &ctx->debug_mem_vaddr[i].debugMemAddr); if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { - LOG_ERROR("hno:%u alloc debug_mem index[%u] failed\n", + LOG_ERROR( + "hno:%u alloc debug_mem index[%u] failed\n", PS3_HOST(instance), i); ret = -PS3_ENOMEM; goto l_out; } - ctx->debug_mem_vaddr[i].debugMemSize = PS3_MAX_DMA_MEM_SIZE; + ctx->debug_mem_vaddr[i].debugMemSize = + PS3_MAX_DMA_MEM_SIZE; entry[i].debugMemSize = PS3_MAX_DMA_MEM_SIZE; + LOG_INFO( + "hno:%u index[%u] m vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", + PS3_HOST(instance), i, + ctx->debug_mem_vaddr[i].debugMemAddr, + entry[i].debugMemAddr, entry[i].debugMemSize); } - LOG_INFO("hno:%u index[%u] m vaddr[0x%llx], dma[0x%llx], size[%u]KB\n", - PS3_HOST(instance), i, ctx->debug_mem_vaddr[i].debugMemAddr, - entry[i].debugMemAddr, entry[i].debugMemSize); } ctx->debug_mem_array_num = array_num; - LOG_INFO("hno:%u debug mem array num [%u]\n", PS3_HOST(instance), array_num); + LOG_INFO("hno:%u debug mem array num [%u]\n", PS3_HOST(instance), + array_num); l_out: return ret; } -S32 ps3_debug_mem_alloc(struct ps3_instance *instance) +int ps3_debug_mem_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 debug_mem_size = ps3_debug_mem_size_query(); - U32 buf_size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(Ps3DebugMemEntry_s); + int ret = PS3_SUCCESS; + unsigned int debug_mem_size = ps3_debug_mem_size_query(); + unsigned int buf_size = + PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(struct Ps3DebugMemEntry); - if (!ps3_is_alloc_debug_mem(debug_mem_size)) { + if (!ps3_is_alloc_debug_mem(debug_mem_size)) goto l_out; - } if (debug_mem_size > PS3_MAX_DEBUG_MEM_SIZE_PARA) { - LOG_WARN("hno:%u debug mem size is greater than the maximum value\n", PS3_HOST(instance)); + LOG_WARN( + "hno:%u debug mem size is greater than the maximum value\n", + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } - instance->debug_context.debug_mem_buf = (Ps3DebugMemEntry_s*)ps3_dma_alloc_coherent(instance, - buf_size, &instance->debug_context.debug_mem_buf_phy); - INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, &instance->debug_context.debug_mem_buf); + instance->debug_context.debug_mem_buf = + (struct Ps3DebugMemEntry *)ps3_dma_alloc_coherent( + instance, buf_size, + (unsigned long long *)&instance->debug_context + .debug_mem_buf_phy); + INJECT_START(PS3_ERR_IJ_PS3_DEBUG_MEM_BUF_ALLOC, + &instance->debug_context.debug_mem_buf); if (instance->debug_context.debug_mem_buf == NULL) { - LOG_ERROR("hno:%u alloc debug_mem_buf failed\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u alloc debug_mem_buf failed\n", + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } @@ -372,14 +399,17 @@ S32 ps3_debug_mem_alloc(struct ps3_instance *instance) ret = ps3_debug_mem_array_alloc(instance, debug_mem_size); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u alloc debug_mem_array failed\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u alloc debug_mem_array failed\n", + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_free; } - LOG_INFO("hno:%u alloc debug_mem buf vaddr[0x%p], dma[0x%llx], size[%u]KB\n", + LOG_INFO( + "hno:%u alloc debug_mem buf vaddr[0x%p], dma[0x%llx], size[%u]KB\n", PS3_HOST(instance), instance->debug_context.debug_mem_buf, - instance->debug_context.debug_mem_buf_phy, buf_size); + (unsigned long long)instance->debug_context.debug_mem_buf_phy, + buf_size); goto l_out; @@ -389,13 +419,13 @@ S32 ps3_debug_mem_alloc(struct ps3_instance *instance) return ret; } -S32 ps3_debug_mem_free(struct ps3_instance *instance) +int ps3_debug_mem_free(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_debug_context *ctx = &instance->debug_context; - Ps3DebugMemEntry_s *entry = ctx->debug_mem_buf; - U32 size = 0; - U8 i = 0; + struct Ps3DebugMemEntry *entry = ctx->debug_mem_buf; + unsigned int size = 0; + unsigned char i = 0; if (entry == NULL) { ret = PS3_SUCCESS; @@ -403,21 +433,21 @@ S32 ps3_debug_mem_free(struct ps3_instance *instance) } for (i = 0; i < PS3_DEBUG_MEM_ARRAY_MAX_NUM; ++i) { - if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) { + if (ctx->debug_mem_vaddr[i].debugMemAddr == 0) continue; - } size = ctx->debug_mem_vaddr[i].debugMemSize * 1024; - LOG_INFO("dma free size[%u] addr[0x%llx]\n", - size, ctx->debug_mem_vaddr[i].debugMemAddr); - (void)ps3_dma_free_coherent(instance, size, - (void*)ctx->debug_mem_vaddr[i].debugMemAddr, + LOG_INFO("dma free size[%u] addr[0x%llx]\n", size, + ctx->debug_mem_vaddr[i].debugMemAddr); + (void)ps3_dma_free_coherent( + instance, size, + (void *)(uintptr_t)ctx->debug_mem_vaddr[i].debugMemAddr, entry[i].debugMemAddr); } memset(ctx->debug_mem_vaddr, 0, sizeof(ctx->debug_mem_vaddr)); - size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(Ps3DebugMemEntry_s); - (void)ps3_dma_free_coherent(instance, size, - ctx->debug_mem_buf, ctx->debug_mem_buf_phy); + size = PS3_DEBUG_MEM_ARRAY_MAX_NUM * sizeof(struct Ps3DebugMemEntry); + (void)ps3_dma_free_coherent(instance, size, ctx->debug_mem_buf, + ctx->debug_mem_buf_phy); ctx->debug_mem_buf = NULL; ctx->debug_mem_buf_phy = 0; LOG_INFO("free debug mem end\n"); @@ -434,7 +464,7 @@ void ps3_debug_context_init(struct ps3_instance *instance) ps3_reg_dump_attr_init(instance); } -static inline struct ps3_instance *ps3_debug_instance_query(struct device *cdev, +struct ps3_instance *ps3_debug_instance_query(struct device *cdev, struct device_attribute *attr, const char *buf) { struct Scsi_Host *shost = NULL; @@ -459,18 +489,19 @@ static inline struct ps3_instance *ps3_debug_instance_query(struct device *cdev, } ssize_t ps3_vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; goto l_out; } - ret = snprintf(buf, PAGE_SIZE, "%d\n", + ret = snprintf( + buf, PAGE_SIZE, "%d\n", atomic_read(&instance->cmd_statistics.vd_io_outstanding)); l_out: @@ -478,11 +509,11 @@ ssize_t ps3_vd_io_outstanding_show(struct device *cdev, } ssize_t ps3_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -490,18 +521,18 @@ ssize_t ps3_io_outstanding_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - atomic_read(&instance->cmd_statistics.io_outstanding)); + atomic_read(&instance->cmd_statistics.io_outstanding)); l_out: return ret; } -ssize_t ps3_is_load_show(struct device *cdev, - struct device_attribute *attr, char *buf) +ssize_t ps3_is_load_show(struct device *cdev, struct device_attribute *attr, + char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -514,11 +545,11 @@ ssize_t ps3_is_load_show(struct device *cdev, return ret; } ssize_t ps3_dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -532,11 +563,11 @@ ssize_t ps3_dump_ioc_regs_show(struct device *cdev, } ssize_t ps3_max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -544,30 +575,31 @@ ssize_t ps3_max_scsi_cmds_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->cmd_context.max_scsi_cmd_count); + instance->cmd_context.max_scsi_cmd_count); l_out: return ret; } #endif -static ssize_t ps3_event_map_get(U32 event_type_map, char *buf, - ssize_t left_len) +static ssize_t ps3_event_map_get(unsigned int event_type_map, char *buf, + ssize_t left_len) { ssize_t len = 0; - U32 mask_bit = 0X00000001; - U32 idx = 0; - U32 event_type = event_type_map & mask_bit; - U32 line_cnt = 2; + unsigned int mask_bit = 0X00000001; + unsigned int idx = 0; + unsigned int event_type = event_type_map & mask_bit; + unsigned int line_cnt = 2; while (mask_bit != 0) { if (event_type != 0) { if (idx && (!(idx % line_cnt))) { - len += snprintf(buf + len, - left_len - len, "\n"); + len += snprintf(buf + len, left_len - len, + "\n"); } - len += snprintf(buf + len, left_len - len, "\t%s", - ps3_event_print((MgrEvtType_e)event_type)); + len += snprintf( + buf + len, left_len - len, "\t%s", + ps3_event_print((enum MgrEvtType)event_type)); } mask_bit = mask_bit << 1; @@ -579,51 +611,53 @@ static ssize_t ps3_event_map_get(U32 event_type_map, char *buf, return len; } -ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, - char *buf, ssize_t total_len) +ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, char *buf, + ssize_t total_len) { ssize_t len = 0; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; - ULong flags = 0; - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + unsigned long flags = 0; + + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); cmd = instance->event_context.event_cmd; if (cmd != NULL) { - mgr_req_frame = (PS3MgrReqFrame_s *)cmd->req_frame; + mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; len += snprintf(buf + len, total_len - len, - "Event subscribe cmd index:\t%d\n", - cmd->index); + "Event subscribe cmd index:\t%d\n", cmd->index); len += snprintf(buf + len, total_len - len, - "Event subscribe level:\t%d\n", - event_req_info->eventLevel); + "Event subscribe level:\t%d\n", + event_req_info->eventLevel); len += snprintf(buf + len, total_len - len, - "Event subscribe type:\n"); + "Event subscribe type:\n"); len += ps3_event_map_get(event_req_info->eventTypeMap, - buf + len, total_len - len); + buf + len, total_len - len); len += snprintf(buf + len, total_len - len, - "Event proc failed type:\n"); + "Event proc failed type:\n"); len += ps3_event_map_get(event_req_info->eventTypeMapProcResult, - buf + len, total_len - len); + buf + len, total_len - len); goto l_out; } l_out: - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); return len; } #ifndef _WINDOWS ssize_t ps3_event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -641,17 +675,18 @@ static ssize_t ps3_ioc_state_dump(struct ps3_instance *instance, char *buf) ssize_t total_len = PAGE_SIZE; len += snprintf(buf + len, total_len - len, "%s\n", - ps3_ioc_state_print(instance->ioc_adpter->ioc_state_get(instance))); + ps3_ioc_state_print( + instance->ioc_adpter->ioc_state_get(instance))); return len; } ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, - char *buf) + char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -663,16 +698,15 @@ ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, return ret; } -ssize_t ps3_log_level_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) +ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { int level = 0; ssize_t ret = count; (void)attr; - if (cdev == NULL || buf == NULL) { + if (cdev == NULL || buf == NULL) goto l_out; - } if (kstrtoint(buf, 10, &level)) { LOG_ERROR("invalid log level, could not set log level\n"); @@ -680,8 +714,8 @@ ssize_t ps3_log_level_store(struct device *cdev, goto l_out; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else if (level > LEVEL_INFO) { @@ -697,16 +731,15 @@ ssize_t ps3_log_level_store(struct device *cdev, return ret; } -ssize_t ps3_log_level_show(struct device *cdev, - struct device_attribute *attr, char *buf) +ssize_t ps3_log_level_show(struct device *cdev, struct device_attribute *attr, + char *buf) { ssize_t ret = 0; - S32 level = ps3_level_get(); + int level = ps3_level_get(); (void)attr; - if (cdev == NULL || buf == NULL) { + if (cdev == NULL || buf == NULL) goto l_out; - } ret = snprintf(buf, PAGE_SIZE, "%d\n", level); LOG_DEBUG("get log level to %d\n", level); @@ -715,12 +748,13 @@ ssize_t ps3_log_level_show(struct device *cdev, } ssize_t ps3_io_trace_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - U8 trace_switch = 0; + unsigned char trace_switch = 0; ssize_t ret = count; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = count; @@ -736,18 +770,18 @@ ssize_t ps3_io_trace_switch_store(struct device *cdev, instance->debug_context.io_trace_switch = trace_switch; LOG_WARN("set io trace switch is %d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); l_out: return ret; } ssize_t ps3_io_trace_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -755,20 +789,21 @@ ssize_t ps3_io_trace_switch_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); LOG_DEBUG("get io trace switch is %d\n", - instance->debug_context.io_trace_switch); + instance->debug_context.io_trace_switch); l_out: return ret; } -ssize_t ps3_dump_state_show(struct device *cdev,struct device_attribute *attr, char *buf) +ssize_t ps3_dump_state_show(struct device *cdev, struct device_attribute *attr, + char *buf) { ssize_t ret = 0; struct ps3_dump_context *ctxt = NULL; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -776,30 +811,31 @@ ssize_t ps3_dump_state_show(struct device *cdev,struct device_attribute *attr, c } ctxt = &instance->dump_context; - ret = snprintf(buf, PAGE_SIZE,"%d \n",ctxt->dump_state); + ret = snprintf(buf, PAGE_SIZE, "%d\n", ctxt->dump_state); l_out: return ret; } -ssize_t ps3_dump_state_store(struct device *cdev,struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_dump_state_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { - S32 val = 0; - S32 ret = 0; + int val = 0; + int ret = 0; struct ps3_dump_context *ctxt = NULL; (void)attr; - ctxt = dev_to_dump_context (cdev); + ctxt = dev_to_dump_context(cdev); if (kstrtoint(buf, 0, &val) != 0) { ret = -EINVAL; goto l_ret; } - if ((val != PS3_DUMP_STATE_INVALID) && (val != PS3_DUMP_STATE_ABORTED)) { - LOG_ERROR("hno:%u dump state should be %d or %d," - "%d is an invalid value\n",PS3_HOST(ctxt->instance), - PS3_DUMP_STATE_INVALID,PS3_DUMP_STATE_ABORTED,val); + if ((val != PS3_DUMP_STATE_INVALID) && + (val != PS3_DUMP_STATE_ABORTED)) { + LOG_ERROR("hno:%u dump state should be %d or %d, %d is an invalid value\n", + PS3_HOST(ctxt->instance), PS3_DUMP_STATE_INVALID, + PS3_DUMP_STATE_ABORTED, val); ret = -EINVAL; goto l_ret; } @@ -814,138 +850,70 @@ ssize_t ps3_dump_state_store(struct device *cdev,struct device_attribute *attr, return ret; } -ssize_t ps3_product_model_show(struct device *cdev,struct device_attribute *attr, char *buf) +ssize_t ps3_product_model_show(struct device *cdev, + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); (void)attr; - if (instance == NULL) { + if (instance == NULL) goto l_out; - } ret = snprintf(buf, PAGE_SIZE, "%s\n", instance->product_model); l_out: return ret; } -ssize_t ps3_dump_dir_show(struct device *cdev,struct device_attribute *attr, char *buf) +ssize_t ps3_dump_dir_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct ps3_dump_context *ctxt; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); ssize_t ret = 0; - if (instance == NULL) { + if (instance == NULL) goto l_out; - } ctxt = &instance->dump_context; - ret = snprintf(buf,PAGE_SIZE,"%s\n",ctxt->dump_dir); + ret = snprintf(buf, PAGE_SIZE, "%s\n", ctxt->dump_dir); l_out: return ret; } -S32 ps3_dump_dir_length( const char *buf, size_t count) -{ - S32 i = 0; - char c; - - while ((size_t)i++ < count) { - c = buf[i]; - - if (isdigit(c)) - continue; - - if (isalpha(c)) - continue; - - switch(c) { - case '-': - case '_': - case '/': - case '~': - continue; - break; - default: - goto l_out; - } - } - -l_out: - return i; -} - -#if 0 -ssize_t ps3_dump_dir_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) -{ -#if 1 - LOG_INFO("set dump log dir is not supported\n"); - return 0; -#else - S32 ret = 0, length = 0; - struct ps3_dump_context *ctxt = NULL; - (void)attr; - - LOG_INFO("dir param %s\n", buf); - - ctxt = dev_to_dump_context (cdev); - - length = ps3_dump_dir_length(buf, count); - length = min(length, (S32)PS3_DUMP_FILE_DIR_LEN); - if (length <= 0 || count > PS3_DUMP_FILE_DIR_LEN) { - ret = -EINVAL; - LOG_ERROR("Invalid param %s\n", buf); - goto l_ret; - } - - ps3_mutex_lock(&ctxt->dump_lock); - memset(ctxt->dump_dir, 0, sizeof(ctxt->dump_dir)); - (void)strncpy((char*)ctxt->dump_dir, buf, length); - ps3_mutex_unlock(&ctxt->dump_lock); - - LOG_INFO("dump dir change to %s\n", ctxt->dump_dir); - - ret = count; - -l_ret: - return ret; -#endif -} -#endif - -ssize_t ps3_dump_type_show(struct device *cdev,struct device_attribute *attr, char *buf) +ssize_t ps3_dump_type_show(struct device *cdev, struct device_attribute *attr, + char *buf) { struct ps3_dump_context *ctxt; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); ssize_t ret = 0; - if (instance == NULL) { + if (instance == NULL) goto l_out; - } ctxt = &instance->dump_context; - ret = snprintf(buf,PAGE_SIZE,"%d \n",ctxt->dump_type); + ret = snprintf(buf, PAGE_SIZE, "%d\n", ctxt->dump_type); l_out: return ret; } ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { - S32 val = 0; - S32 ret = 0; + int val = 0; + int ret = 0; struct ps3_dump_context *ctxt = NULL; - Bool is_trigger_log = PS3_FALSE; + unsigned char is_trigger_log = PS3_FALSE; (void)attr; - ctxt = dev_to_dump_context (cdev); + ctxt = dev_to_dump_context(cdev); if (kstrtoint(buf, 0, &val) != 0) { ret = -EINVAL; @@ -953,17 +921,17 @@ ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, } if ((val < PS3_DUMP_TYPE_CRASH) || (val > PS3_DUMP_TYPE_BAR_DATA)) { - LOG_ERROR("host_no[%d],dump state should be %d - %d," - "%d is an invalid value\n", PS3_HOST(ctxt->instance), - PS3_DUMP_TYPE_CRASH, PS3_DUMP_TYPE_BAR_DATA, val); + LOG_ERROR("host_no[%d],dump state should be %d - %d, %d is an invalid value\n", + PS3_HOST(ctxt->instance), PS3_DUMP_TYPE_CRASH, + PS3_DUMP_TYPE_BAR_DATA, val); ret = -EINVAL; goto l_ret; } ps3_ioc_dump_support_get(ctxt->instance); is_trigger_log = ps3_dump_is_trigger_log(ctxt->instance); - INJECT_START(PS3_ERR_IJ_STORE_NO_TRIGGER_LOG, &is_trigger_log) - if(!is_trigger_log) { + INJECT_START(PS3_ERR_IJ_STORE_NO_TRIGGER_LOG, &is_trigger_log); + if (!is_trigger_log) { LOG_INFO("cannot dump type set!\n"); ret = -EBUSY; goto l_ret; @@ -980,28 +948,32 @@ ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, void ps3_dma_dump_mapping(struct pci_dev *pdev) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) - dma_dump_mappings_cb dma_dump_mappings = NULL; - dma_dump_mappings = (dma_dump_mappings_cb) kallsyms_lookup_name("debug_dma_dump_mappings"); +#if defined(PS3_DMA_MAPPING) +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) + void (*dma_dump_mappings)(struct device *dev) = NULL; + + dma_dump_mappings = (void (*)(struct device *)) + kallsyms_lookup_name("debug_dma_dump_mappings"); if (dma_dump_mappings && pdev) { - printk(KERN_INFO "ps3 dma dump mapping begin\n"); + pr_info("ps3 dma dump mapping begin\n"); dma_dump_mappings(&pdev->dev); - printk(KERN_INFO "ps3 dma dump mapping end\n"); + pr_info("ps3 dma dump mapping end\n"); } #endif #endif (void)pdev; } -ssize_t ps3_soc_dead_reset_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_soc_dead_reset_store(struct device *cdev, + struct device_attribute *attr, const char *buf, + size_t count) { - S32 val = 0; - S32 ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, attr, buf); + int val = 0; + int ret = 0; + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); (void)attr; (void)count; @@ -1009,55 +981,54 @@ ssize_t ps3_soc_dead_reset_store(struct device *cdev, struct device_attribute *a ret = -EINVAL; goto l_ret; } - if (ps3_atomic_read(&instance->state_machine.state) - != PS3_INSTANCE_STATE_DEAD) { + if (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { ret = -EPERM; goto l_ret; } if (ps3_need_block_hard_reset_request(instance)) { LOG_WARN("hno:%u can not start hard reset\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { - ps3_hard_recovery_request_with_retry(instance); + ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); } return count; l_ret: return ret; } -ssize_t ps3_halt_support_cli_show(struct device *cdev,struct device_attribute *attr, char *buf) +ssize_t ps3_halt_support_cli_show(struct device *cdev, + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; goto l_out; } - ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->is_halt_support_cli); + ret = snprintf(buf, PAGE_SIZE, "%d\n", instance->is_halt_support_cli); LOG_DEBUG("get halt_support_cli is %d\n", - instance->is_halt_support_cli); + instance->is_halt_support_cli); l_out: return ret; } -ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute *attr, - const char *buf, size_t count) +ssize_t ps3_halt_support_cli_store(struct device *cdev, + struct device_attribute *attr, + const char *buf, size_t count) { - U8 halt_support_cli = 0; - Bool is_halt_support_cli; + unsigned char halt_support_cli = 0; + unsigned char is_halt_support_cli; ssize_t ret = count; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); - - if (instance == NULL) { + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); + if (instance == NULL) goto l_out; - } if (kstrtou8(buf, 10, &halt_support_cli)) { ret = -EINVAL; @@ -1065,34 +1036,34 @@ ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute * goto l_out; } - is_halt_support_cli = (halt_support_cli == 0)?(0):(1); + is_halt_support_cli = (halt_support_cli == 0) ? (0) : (1); instance->is_halt_support_cli = is_halt_support_cli; - LOG_WARN("set halt_support_cli is %d\n", - instance->is_halt_support_cli); + LOG_WARN("set halt_support_cli is %d\n", instance->is_halt_support_cli); l_out: return ret; } -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else ssize_t ps3_irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { - int is_prk_in_irq= 0; + int is_prk_in_irq = 0; ssize_t ret = count; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); - if (cdev == NULL || buf == NULL) { + if (cdev == NULL || buf == NULL) goto l_out; - } if (kstrtoint(buf, 10, &is_prk_in_irq)) { - LOG_ERROR("invalid is_prk_in_irq, could not set is_prk_in_irq\n"); + LOG_ERROR( + "invalid is_prk_in_irq, could not set is_prk_in_irq\n"); ret = -EINVAL; goto l_out; } @@ -1105,15 +1076,14 @@ ssize_t ps3_irq_prk_support_store(struct device *cdev, } ssize_t ps3_irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); - if (cdev == NULL || buf == NULL) { + if (cdev == NULL || buf == NULL) goto l_out; - } ret = snprintf(buf, PAGE_SIZE, "%d\n", instance->is_irq_prk_support); LOG_DEBUG("get log level to %d\n", instance->is_irq_prk_support); @@ -1122,12 +1092,12 @@ ssize_t ps3_irq_prk_support_show(struct device *cdev, } #endif -ssize_t ps3_qos_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf) +ssize_t ps3_qos_switch_show(struct device *cdev, struct device_attribute *attr, + char *buf) { ssize_t ret = 0; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = 0; @@ -1135,19 +1105,19 @@ ssize_t ps3_qos_switch_show(struct device *cdev, } ret = snprintf(buf, PAGE_SIZE, "%d\n", - instance->qos_context.qos_switch); + instance->qos_context.qos_switch); l_out: return ret; } -ssize_t ps3_qos_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count) +ssize_t ps3_qos_switch_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count) { - U8 qos_switch = 0; + unsigned char qos_switch = 0; ssize_t ret = count; - struct ps3_instance *instance = ps3_debug_instance_query(cdev, - attr, buf); + struct ps3_instance *instance = + ps3_debug_instance_query(cdev, attr, buf); if (instance == NULL) { ret = count; @@ -1160,18 +1130,16 @@ ssize_t ps3_qos_switch_store(struct device *cdev, goto l_out; } - if (instance->qos_context.qos_switch > 0 && qos_switch == 0) { - instance->qos_context.qos_switch = 0; - ps3_qos_close(instance); - } - - if (instance->qos_context.qos_switch == 0 && qos_switch > 0) { - ps3_qos_open(instance); - instance->qos_context.qos_switch = qos_switch; - } + if (instance->qos_context.qos_switch > 0 && qos_switch == 0) { + instance->qos_context.qos_switch = 0; + ps3_qos_close(instance); + } + if (instance->qos_context.qos_switch == 0 && qos_switch > 0) { + ps3_qos_open(instance); + instance->qos_context.qos_switch = qos_switch; + } - LOG_WARN("set qos switch is %d\n", - instance->qos_context.qos_switch); + LOG_WARN("set qos switch is %d\n", instance->qos_context.qos_switch); l_out: return ret; diff --git a/drivers/scsi/linkdata/ps3stor/ps3_debug.h b/drivers/scsi/linkdata/ps3stor/ps3_debug.h index fb9609714edc..3ee8a27997dd 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_debug.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_debug.h @@ -1,150 +1,155 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_DEBUG_H_ #define _PS3_DEBUG_H_ -#ifndef _WINDOWS +#ifndef _WINDOWS #include #include #include struct ps3_reg_dump_attr { - U64 read_dump_timestamp; - U64 write_dump_timestamp; - U64 read_dump_interval_ms; - U64 write_dump_interval_ms; - U64 lastest_value; - S8 name[32]; + unsigned long long read_dump_timestamp; + unsigned long long write_dump_timestamp; + unsigned long long read_dump_interval_ms; + unsigned long long write_dump_interval_ms; + unsigned long long lastest_value; + char name[32]; }; struct ps3_debug_context { - U8 io_trace_switch; - U8 reserved[7]; - struct ps3_reg_dump_attr reg_dump[PS3_REGISTER_SET_SIZE/sizeof(U64)]; - Ps3DebugMemEntry_s debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; - Ps3DebugMemEntry_s *debug_mem_buf; - dma_addr_t debug_mem_buf_phy; - U32 debug_mem_array_num; - U8 reserved1[4]; + unsigned char io_trace_switch; + unsigned char reserved[7]; + struct ps3_reg_dump_attr + reg_dump[PS3_REGISTER_SET_SIZE / sizeof(unsigned long long)]; + struct Ps3DebugMemEntry debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; + struct Ps3DebugMemEntry *debug_mem_buf; + dma_addr_t debug_mem_buf_phy; + unsigned int debug_mem_array_num; + unsigned char reserved1[4]; }; void ps3_debug_context_init(struct ps3_instance *instance); -void ps3_reg_dump(struct ps3_instance *instance, - void __iomem *reg, U64 value, Bool is_read); +void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, + unsigned long long value, unsigned char is_read); ssize_t ps3_vd_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_io_outstanding_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); -ssize_t ps3_is_load_show(struct device *cdev, - struct device_attribute *attr, char *buf); +ssize_t ps3_is_load_show(struct device *cdev, struct device_attribute *attr, + char *buf); ssize_t ps3_dump_ioc_regs_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_max_scsi_cmds_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_event_subscribe_info_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); ssize_t ps3_ioc_state_show(struct device *cdev, struct device_attribute *attr, - char *buf); - -ssize_t ps3_log_level_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count); + char *buf); -ssize_t ps3_log_level_show(struct device *cdev, - struct device_attribute *attr, char *buf); +ssize_t ps3_log_level_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count); +ssize_t ps3_log_level_show(struct device *cdev, struct device_attribute *attr, + char *buf); ssize_t ps3_io_trace_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); ssize_t ps3_io_trace_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf); -ssize_t ps3_halt_support_cli_show(struct device *cdev,struct device_attribute *attr, char *buf); - -ssize_t ps3_halt_support_cli_store(struct device *cdev,struct device_attribute *attr, - const char *buf, size_t count); - -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + struct device_attribute *attr, char *buf); +ssize_t ps3_halt_support_cli_show(struct device *cdev, + struct device_attribute *attr, char *buf); +ssize_t ps3_halt_support_cli_store(struct device *cdev, + struct device_attribute *attr, + const char *buf, size_t count); + +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #else ssize_t ps3_irq_prk_support_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count); + struct device_attribute *attr, + const char *buf, size_t count); ssize_t ps3_irq_prk_support_show(struct device *cdev, - struct device_attribute *attr, char *buf); + struct device_attribute *attr, char *buf); #endif -ssize_t ps3_product_model_show(struct device *cdev,struct device_attribute *attr, char *buf); +ssize_t ps3_product_model_show(struct device *cdev, + struct device_attribute *attr, char *buf); -ssize_t ps3_qos_switch_show(struct device *cdev, - struct device_attribute *attr, char *buf); +ssize_t ps3_qos_switch_show(struct device *cdev, struct device_attribute *attr, + char *buf); -ssize_t ps3_qos_switch_store(struct device *cdev, - struct device_attribute *attr, const char *buf, size_t count); +ssize_t ps3_qos_switch_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count); #endif ssize_t ps3_event_subscribe_info_get(struct ps3_instance *instance, char *buf, - ssize_t total_len); + ssize_t total_len); #ifndef _WINDOWS -S32 ps3_debug_mem_alloc(struct ps3_instance *ins); - -S32 ps3_debug_mem_free(struct ps3_instance *ins); - -ssize_t ps3_dump_state_show(struct device *cdev,struct device_attribute *attr, char *buf); - -ssize_t ps3_dump_state_store(struct device *cdev,struct device_attribute *attr, - const char *buf, size_t count); - -ssize_t ps3_dump_type_show(struct device *cdev,struct device_attribute *attr, char *buf); +int ps3_debug_mem_alloc(struct ps3_instance *ins); +int ps3_debug_mem_free(struct ps3_instance *ins); +ssize_t ps3_dump_state_show(struct device *cdev, struct device_attribute *attr, + char *buf); +ssize_t ps3_dump_state_store(struct device *cdev, struct device_attribute *attr, + const char *buf, size_t count); +ssize_t ps3_dump_type_show(struct device *cdev, struct device_attribute *attr, + char *buf); ssize_t ps3_dump_type_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); + const char *buf, size_t count); -#if 0 -ssize_t ps3_dump_dir_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); -#endif -ssize_t ps3_dump_dir_show(struct device *cdev,struct device_attribute *attr, char *buf); +ssize_t ps3_dump_dir_show(struct device *cdev, struct device_attribute *attr, + char *buf); void ps3_dma_dump_mapping(struct pci_dev *pdev); -ssize_t ps3_soc_dead_reset_store(struct device *cdev, struct device_attribute *attr, - const char *buf, size_t count); +ssize_t ps3_soc_dead_reset_store(struct device *cdev, + struct device_attribute *attr, const char *buf, + size_t count); + +struct ps3_instance *ps3_debug_instance_query(struct device *cdev, + struct device_attribute *attr, const char *buf); + #else struct ps3_reg_dump_attr { - U64 read_dump_timestamp; - U64 write_dump_timestamp; - U64 read_dump_interval_ms; - U64 write_dump_interval_ms; - U64 lastest_value; - S8 name[32]; + unsigned long long read_dump_timestamp; + unsigned long long write_dump_timestamp; + unsigned long long read_dump_interval_ms; + unsigned long long write_dump_interval_ms; + unsigned long long lastest_value; + char name[32]; }; struct ps3_debug_context { - U8 io_trace_switch; - U8 reserved[7]; - struct ps3_reg_dump_attr reg_dump[PS3_REGISTER_SET_SIZE / sizeof(U64)]; - Ps3DebugMemEntry_s debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; - Ps3DebugMemEntry_s* debug_mem_buf; - dma_addr_t debug_mem_buf_phy; - U32 debug_mem_array_num; - U8 reserved1[4]; + unsigned char io_trace_switch; + unsigned char reserved[7]; + struct ps3_reg_dump_attr + reg_dump[PS3_REGISTER_SET_SIZE / sizeof(unsigned long long)]; + struct Ps3DebugMemEntry debug_mem_vaddr[PS3_DEBUG_MEM_ARRAY_MAX_NUM]; + struct Ps3DebugMemEntry *debug_mem_buf; + dma_addr_t debug_mem_buf_phy; + unsigned int debug_mem_array_num; + unsigned char reserved1[4]; }; void ps3_debug_context_init(struct ps3_instance *instance); -void ps3_reg_dump(struct ps3_instance *instance, - void __iomem* reg, U64 value, Bool is_read); +void ps3_reg_dump(struct ps3_instance *instance, void __iomem *reg, + unsigned long long value, unsigned char is_read); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c index 96f500ef49de..aa29a778f99d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -15,10 +15,9 @@ #include #include +#include #endif -#include "ps3_meta.h" -#include "ps3_dev_type.h" #include "ps3_device_manager.h" #include "ps3_cmd_statistics.h" #include "ps3_mgr_cmd.h" @@ -28,45 +27,53 @@ #include "ps3_module_para.h" #include "ps3_r1x_write_lock.h" #include "ps3_qos.h" +#include "ps3_debug.h" +#if defined(PS3_SLAVE_CONFIG_SUPPORT) +static void ps3_nvme_attr_set(const struct ps3_instance *instance, + struct scsi_device *sdev); +#define PS3_SDEV_Q_DMA_ALIGN(q, mask) blk_queue_dma_alignment((q), (mask)) +#else static void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev); + struct scsi_device *sdev, struct queue_limits *lim); +#define PS3_SDEV_Q_DMA_ALIGN(q, mask) ((q)->limits.dma_alignment = (mask)) +#endif +static inline unsigned int ps3_vd_max_sectors_get(const struct PS3VDEntry *p_entry); +static inline unsigned int ps3_pd_max_sectors_get(const struct ps3_pd_entry *p_entry); -static S32 ps3_dev_channel_init(struct ps3_instance *instance) +static int ps3_dev_channel_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U8 i = 0; - U16 vd_start = 0; - U16 pd_start = 0; + int ret = PS3_SUCCESS; + unsigned char i = 0; + unsigned short vd_start = 0; + unsigned short pd_start = 0; struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_channel *vd_chan = instance->dev_context.channel_vd; - memset(pd_chan, 0, - sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); - memset(vd_chan, 0, - sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); + memset(pd_chan, 0, sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); + memset(vd_chan, 0, sizeof(struct ps3_channel) * PS3_MAX_CHANNEL_NUM); instance->dev_context.pd_channel_count = 0; instance->dev_context.vd_channel_count = 0; instance->dev_context.max_dev_per_channel = 0; - instance->dev_context.abort_vdpending_cmd = 0; + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); for (i = 0; i < channel_info->channelNum; i++) { LOG_INFO("hno:%u channel[%u] is type %s,max dev num is:%u\n", - PS3_HOST(instance), i, - namePS3ChannelType((enum PS3ChannelType) - channel_info->channels[i].channelType), - channel_info->channels[i].maxDevNum); + PS3_HOST(instance), i, + namePS3ChannelType( + (enum PS3ChannelType)channel_info->channels[i] + .channelType), + channel_info->channels[i].maxDevNum); if (channel_info->channels[i].maxDevNum > - instance->dev_context.max_dev_per_channel) { + instance->dev_context.max_dev_per_channel) { instance->dev_context.max_dev_per_channel = channel_info->channels[i].maxDevNum; } - if (channel_info->channels[i].channelType == - PS3_CHAN_TYPE_VD) { + if (channel_info->channels[i].channelType == PS3_CHAN_TYPE_VD) { vd_chan->channel = i; vd_chan->max_dev_num = channel_info->channels[i].maxDevNum; @@ -78,7 +85,7 @@ static S32 ps3_dev_channel_init(struct ps3_instance *instance) vd_chan++; instance->dev_context.vd_channel_count++; } else if (channel_info->channels[i].channelType == - PS3_CHAN_TYPE_PD) { + PS3_CHAN_TYPE_PD) { pd_chan->channel = i; pd_chan->max_dev_num = channel_info->channels[i].maxDevNum; @@ -93,7 +100,7 @@ static S32 ps3_dev_channel_init(struct ps3_instance *instance) if (instance->dev_context.max_dev_per_channel == 0) { LOG_WARN("hno:%u total dev in channel == 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -103,10 +110,9 @@ static S32 ps3_dev_channel_init(struct ps3_instance *instance) static void ps3_dev_buff_release(struct ps3_instance *instance) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 i = 0; + unsigned char i = 0; - LOG_INFO("hno:%u release all device mgr buffer\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u release all device mgr buffer\n", PS3_HOST(instance)); if (p_dev_ctx->pd_pool.devs_buffer != NULL) { ps3_kfree(instance, p_dev_ctx->pd_pool.devs_buffer); @@ -114,7 +120,8 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) } if (p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array != NULL) { - ps3_vfree(instance, p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array); + ps3_vfree(instance, + p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array); p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs_array = NULL; } @@ -135,7 +142,8 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) for (i = 0; i < PS3_VD_TABLE_NUM; i++) { if (p_dev_ctx->vd_table[i].vd_idxs_array != NULL) { - ps3_kfree(instance, p_dev_ctx->vd_table[i].vd_idxs_array); + ps3_kfree(instance, + p_dev_ctx->vd_table[i].vd_idxs_array); p_dev_ctx->vd_table[i].vd_idxs_array = NULL; } @@ -146,68 +154,80 @@ static void ps3_dev_buff_release(struct ps3_instance *instance) } } -static S32 ps3_vd_buff_alloc(struct ps3_instance *instance) +static int ps3_vd_buff_alloc(struct ps3_instance *instance) { - U8 i = 0; - U8 j = 0; + unsigned char i = 0; + unsigned char j = 0; struct ps3_channel *p_chan = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_dev_pool *vd_pool = &p_dev_ctx->vd_pool; struct ps3_vd_table *p_vd_table = p_dev_ctx->vd_table; - struct ps3_pri_data_table *p_vd_pri_data_table = &p_dev_ctx->vd_pri_data_table; + struct ps3_pri_data_table *p_vd_pri_data_table = + &p_dev_ctx->vd_pri_data_table; - p_dev_ctx->subwork = 0; + ps3_atomic_set(&p_dev_ctx->subwork, 0); p_dev_ctx->total_vd_count = 0; if (p_dev_ctx->vd_channel_count > 0) { - p_chan = &p_dev_ctx->channel_vd[p_dev_ctx->vd_channel_count-1]; - p_dev_ctx->total_vd_count = p_chan->channel_start_num + - p_chan->max_dev_num; + p_chan = + &p_dev_ctx->channel_vd[p_dev_ctx->vd_channel_count - 1]; + p_dev_ctx->total_vd_count = + p_chan->channel_start_num + p_chan->max_dev_num; } for (i = 0; i < PS3_VD_TABLE_NUM; i++) { - p_vd_table[i].vd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * - p_dev_ctx->total_vd_count); - INJECT_START(PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, &p_vd_table[i].vd_idxs_array); + p_vd_table[i].vd_idxs_array = (unsigned short *)ps3_kzalloc( + instance, + sizeof(unsigned short) * p_dev_ctx->total_vd_count); + INJECT_START(PS3_ERR_IJ_PS3_VD_IDX_ARRAY_ALLOC, + &p_vd_table[i].vd_idxs_array); if (p_vd_table[i].vd_idxs_array == NULL) { - LOG_ERROR("hno:%u, Failed to allocate VD table %d buffer\n", + LOG_ERROR( + "hno:%u, Failed to allocate VD table %d buffer\n", PS3_HOST(instance), i); goto free_dev_buff; } - p_dev_ctx->vd_entries_array[i] = (struct PS3VDEntry*) - ps3_kzalloc(instance, sizeof(struct PS3VDEntry) * - (PS3_MAX_VD_COUNT(instance) + 1)); - INJECT_START(PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->vd_entries_array[i]); + p_dev_ctx->vd_entries_array[i] = + (struct PS3VDEntry *)ps3_kzalloc( + instance, + sizeof(struct PS3VDEntry) * + (PS3_MAX_VD_COUNT(instance) + 1)); + INJECT_START(PS3_ERR_IJ_PS3_VD_ENTRIES_ARRAY_ALLOC, + &p_dev_ctx->vd_entries_array[i]); if (p_dev_ctx->vd_entries_array[i] == NULL) { - LOG_ERROR("hno:%u, Failed to allocate VD entry buffer\n", + LOG_ERROR( + "hno:%u, Failed to allocate VD entry buffer\n", PS3_HOST(instance)); goto free_dev_buff; } } - vd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, - sizeof(union PS3Device) * p_dev_ctx->total_vd_count); + vd_pool->devs_buffer = (union PS3Device *)ps3_kzalloc( + instance, sizeof(union PS3Device) * p_dev_ctx->total_vd_count); INJECT_START(PS3_ERR_IJ_PS3_VD_DEVS_BUF_ALLOC, &vd_pool->devs_buffer); if (vd_pool->devs_buffer == NULL) { LOG_ERROR("hno:%u Failed to allocate VD pool buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_buff; } - memset(vd_pool->devs_buffer, 0, sizeof(union PS3Device) * p_dev_ctx->total_vd_count); + memset(vd_pool->devs_buffer, 0, + sizeof(union PS3Device) * p_dev_ctx->total_vd_count); p_vd_pri_data_table->vd_pri_data_idxs_array = - (struct ps3_scsi_priv_data**)ps3_vzalloc(instance, - sizeof(struct ps3_scsi_priv_data*) * p_dev_ctx->total_vd_count); - INJECT_START(PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, &p_vd_pri_data_table->vd_pri_data_idxs_array); + (struct ps3_scsi_priv_data **)ps3_vzalloc( + instance, sizeof(struct ps3_scsi_priv_data *) * + p_dev_ctx->total_vd_count); + INJECT_START(PS3_ERR_IJ_PS3_VD_PRI_DATA_IDXS_ARRAY_ALLOC, + &p_vd_pri_data_table->vd_pri_data_idxs_array); if (p_vd_pri_data_table->vd_pri_data_idxs_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate VD R1X table %d buffer\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto free_dev_buff; } memset(p_vd_pri_data_table->vd_pri_data_idxs_array, 0, - sizeof(struct ps3_scsi_priv_data*) * p_dev_ctx->total_vd_count); + sizeof(struct ps3_scsi_priv_data *) * p_dev_ctx->total_vd_count); p_chan = p_dev_ctx->channel_vd; for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { @@ -215,11 +235,13 @@ static S32 ps3_vd_buff_alloc(struct ps3_instance *instance) &vd_pool->devs_buffer[p_chan->channel_start_num]; p_vd_pri_data_table->vd_pri_data_idxs[p_chan->channel] = - &p_vd_pri_data_table->vd_pri_data_idxs_array[p_chan->channel_start_num]; + &p_vd_pri_data_table->vd_pri_data_idxs_array + [p_chan->channel_start_num]; for (j = 0; j < PS3_VD_TABLE_NUM; j++) { p_vd_table[j].vd_idxs[p_chan->channel] = - &p_vd_table[j].vd_idxs_array[p_chan->channel_start_num]; + &p_vd_table[j].vd_idxs_array + [p_chan->channel_start_num]; } p_chan++; @@ -232,9 +254,9 @@ static S32 ps3_vd_buff_alloc(struct ps3_instance *instance) return -PS3_ENOMEM; } -static S32 ps3_pd_buff_alloc(struct ps3_instance *instance) +static int ps3_pd_buff_alloc(struct ps3_instance *instance) { - U8 i = 0; + unsigned char i = 0; struct ps3_channel *p_chan = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_dev_pool *pd_pool = &p_dev_ctx->pd_pool; @@ -242,36 +264,39 @@ static S32 ps3_pd_buff_alloc(struct ps3_instance *instance) p_dev_ctx->total_pd_count = 0; if (p_dev_ctx->pd_channel_count > 0) { - p_chan = &p_dev_ctx->channel_pd[p_dev_ctx->pd_channel_count - 1]; - p_dev_ctx->total_pd_count = p_chan->channel_start_num + - p_chan->max_dev_num; + p_chan = + &p_dev_ctx->channel_pd[p_dev_ctx->pd_channel_count - 1]; + p_dev_ctx->total_pd_count = + p_chan->channel_start_num + p_chan->max_dev_num; } - p_dev_ctx->pd_entries_array = (struct ps3_pd_entry*) - ps3_kzalloc(instance, sizeof(struct ps3_pd_entry) * - (PS3_MAX_PD_COUNT(instance) + 1)); - INJECT_START(PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, &p_dev_ctx->pd_entries_array); + p_dev_ctx->pd_entries_array = (struct ps3_pd_entry *)ps3_kzalloc( + instance, + sizeof(struct ps3_pd_entry) * (PS3_MAX_PD_COUNT(instance) + 1)); + INJECT_START(PS3_ERR_IJ_PS3_PD_ENTRIES_ARRAY_ALLOC, + &p_dev_ctx->pd_entries_array); if (p_dev_ctx->pd_entries_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD entry buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } - pd_table->pd_idxs_array = (U16*)ps3_kzalloc(instance, sizeof(U16) * - p_dev_ctx->total_pd_count); - INJECT_START(PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, &pd_table->pd_idxs_array); + pd_table->pd_idxs_array = (unsigned short *)ps3_kzalloc( + instance, sizeof(unsigned short) * p_dev_ctx->total_pd_count); + INJECT_START(PS3_ERR_IJ_PS3_PD_IDX_ARRAY_ALLOC, + &pd_table->pd_idxs_array); if (pd_table->pd_idxs_array == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD table buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } - pd_pool->devs_buffer = (union PS3Device*)ps3_kzalloc(instance, - sizeof(union PS3Device) * p_dev_ctx->total_pd_count); + pd_pool->devs_buffer = (union PS3Device *)ps3_kzalloc( + instance, sizeof(union PS3Device) * p_dev_ctx->total_pd_count); INJECT_START(PS3_ERR_IJ_PS3_PD_DEVS_BUF_ALLOC, &pd_pool->devs_buffer); if (pd_pool->devs_buffer == NULL) { LOG_ERROR("hno:%u, Failed to allocate PD pool buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto free_dev_pool; } @@ -291,91 +316,100 @@ static S32 ps3_pd_buff_alloc(struct ps3_instance *instance) return -PS3_ENOMEM; } -static S32 ps3_dev_buff_alloc(struct ps3_instance *instance) +static int ps3_dev_buff_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; LOG_INFO("hno:%u buff alloc pd count %d, vd count %d\n", - PS3_HOST(instance), PS3_MAX_PD_COUNT(instance), PS3_MAX_VD_COUNT(instance)); + PS3_HOST(instance), PS3_MAX_PD_COUNT(instance), + PS3_MAX_VD_COUNT(instance)); if (PS3_MAX_VD_COUNT(instance) > 0) { ret = ps3_vd_buff_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } } if (PS3_MAX_PD_COUNT(instance) > 0) { ret = ps3_pd_buff_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } } l_out: return ret; } -static inline U16 ps3_pd_dma_alignment_calc(U8 align_shift) +static inline unsigned short +ps3_pd_dma_alignment_calc(unsigned char align_shift) { return align_shift ? 1 << align_shift : 0; } -static inline U8 ps3_pd_type_localed(const struct PS3PDInfo *pd_info) +static inline unsigned char ps3_pd_type_localed(const struct PS3PDInfo *pd_info) { - U8 dev_type = PS3_DEV_TYPE_UNKNOWN; + unsigned char dev_type = PS3_DEV_TYPE_UNKNOWN; - dev_type = ps3_get_converted_dev_type(pd_info->driverType, pd_info->mediumType); + dev_type = ps3_get_converted_dev_type(pd_info->driverType, + pd_info->mediumType); if (unlikely(dev_type == PS3_DEV_TYPE_UNKNOWN)) { - LOG_ERROR("pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type is unknown\n", - PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), - PS3_PDID(&pd_info->diskPos), pd_info->diskPos.diskMagicNum, - getDriverTypeName((DriverType_e)pd_info->driverType), - getMediumTypeName((MediumType_e)pd_info->mediumType)); + LOG_ERROR( + "pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type is unknown\n", + PS3_CHANNEL(&pd_info->diskPos), + PS3_TARGET(&pd_info->diskPos), + PS3_PDID(&pd_info->diskPos), + pd_info->diskPos.diskMagicNum, + getDriverTypeName((enum DriverType)pd_info->driverType), + getMediumTypeName( + (enum MediumType)pd_info->mediumType)); PS3_BUG(); } else { - LOG_INFO("pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type[%s]\n", - PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), - PS3_PDID(&pd_info->diskPos), pd_info->diskPos.diskMagicNum, - getDriverTypeName((DriverType_e)pd_info->driverType), - getMediumTypeName((MediumType_e)pd_info->mediumType), + LOG_INFO( + "pd[%u:%u:%u], magic_num[%#x], driver_type[%s], medium_type[%s], dev_type[%s]\n", + PS3_CHANNEL(&pd_info->diskPos), + PS3_TARGET(&pd_info->diskPos), + PS3_PDID(&pd_info->diskPos), + pd_info->diskPos.diskMagicNum, + getDriverTypeName((enum DriverType)pd_info->driverType), + getMediumTypeName((enum MediumType)pd_info->mediumType), namePS3DevType((enum PS3DevType)dev_type)); } return dev_type; } void ps3_vd_info_show(const struct ps3_instance *instance, - const struct PS3VDEntry *vd_entry) + const struct PS3VDEntry *vd_entry) { - U8 i = 0; - U8 j = 0; - U8 channel = (U8)PS3_CHANNEL(&vd_entry->diskPos); - U16 target_id = PS3_TARGET(&vd_entry->diskPos); - U16 vd_id = PS3_VDID(&vd_entry->diskPos); - - LOG_INFO_IN_IRQ(instance, - "hno:%u disk detail info - vd[%u:%u:%u], magicNum[%#x], " - "dev_type: PS3_DEV_TYPE_VD, isHidden[%s], " - "accessPolicy[%s], diskGrpId[%u], sectorSize[%u], " - "stripeDataSize[%u], physDrvCnt[%u], stripSize[%u], " - "isDirectEnable[%s], raidLevel[%u], spanCount[%u], " - "diskState[%u], startLBA[%llu], extentSize[%llu], " - "isTaskMgmtEnable[%u], taskAbortTimeout[%u], " - "taskResetTimeout[%u], mapBlock[%llu], mapBlockVer[%u], " - "maxIOSize[%u], devQueDepth[%u], capacity[%llu], isNvme[%u], isSsd[%u], virtDiskSeq[%d], " - "bdev_bdi_cap[%d], umapBlkDescCnt[%d], umapNumblk[%d], normalQuota[%u], directQuota[%u], " - "dev_busy_scale[%u]\n" - , PS3_HOST(instance), channel, target_id, vd_id, + unsigned char i = 0; + unsigned char j = 0; + unsigned char channel = (unsigned char)PS3_CHANNEL(&vd_entry->diskPos); + unsigned short target_id = PS3_TARGET(&vd_entry->diskPos); + unsigned short vd_id = PS3_VDID(&vd_entry->diskPos); + + LOG_INFO_IN_IRQ( + instance, + "hno:%u disk detail info - vd[%u:%u:%u], magicNum[%#x]\n" + "\tdev_type: PS3_DEV_TYPE_VD, isHidden[%s]\n" + "\taccessPolicy[%s], diskGrpId[%u], sectorSize[%u]\n" + "\tstripeDataSize[%u], physDrvCnt[%u], stripSize[%u]\n" + "\tisDirectEnable[%s], raidLevel[%u], spanCount[%u]\n" + "\tdiskState[%u], startLBA[%llu], extentSize[%llu]\n" + "\tisTaskMgmtEnable[%u], taskAbortTimeout[%u]\n" + "\ttaskResetTimeout[%u], mapBlock[%llu], mapBlockVer[%u]\n" + "\tmaxIOSize[%u], devQueDepth[%u], capacity[%llu], isNvme[%u], isSsd[%u]\n" + "\tvirtDiskSeq[%d] bdev_bdi_cap[%d], umapBlkDescCnt[%d], umapNumblk[%d]\n" + "\tnormalQuota[%u], directQuota[%u] dev_busy_scale[%u] seq_enable[%u %u]\n", + PS3_HOST(instance), channel, target_id, vd_id, vd_entry->diskPos.diskMagicNum, (vd_entry->isHidden) ? "true" : "false", - ps3_get_vd_access_plolicy_str((VDAccessPolicy_e)vd_entry->accessPolicy), - vd_entry->diskGrpId, - vd_entry->sectorSize, vd_entry->stripeDataSize, - vd_entry->physDrvCnt, vd_entry->stripSize, + ps3_get_vd_access_plolicy_str( + (enum VDAccessPolicy)vd_entry->accessPolicy), + vd_entry->diskGrpId, vd_entry->sectorSize, + vd_entry->stripeDataSize, vd_entry->physDrvCnt, + vd_entry->stripSize, (vd_entry->isDirectEnable) ? "true" : "false", - vd_entry->raidLevel, - vd_entry->spanCount, vd_entry->diskState, + vd_entry->raidLevel, vd_entry->spanCount, vd_entry->diskState, vd_entry->startLBA, vd_entry->extentSize, vd_entry->isTaskMgmtEnable, vd_entry->taskAbortTimeout, vd_entry->taskResetTimeout, vd_entry->mapBlock, @@ -384,61 +418,68 @@ void ps3_vd_info_show(const struct ps3_instance *instance, vd_entry->isSsd, vd_entry->virtDiskSeq, vd_entry->bdev_bdi_cap, vd_entry->umapBlkDescCnt, vd_entry->umapNumblk, vd_entry->normalQuota, vd_entry->directQuota, - vd_entry->dev_busy_scale); + vd_entry->dev_busy_scale, vd_entry->isReadNeedSeq, vd_entry->isWriteNeedSeq); for (i = 0; i < vd_entry->spanCount; i++) { - LOG_INFO_IN_IRQ(instance, - "hno:%u vd[%u:%u:%u]----span[%u]----" - "spanStripeDataSize[%u], spanState[%u], spanPdNum[%u]\n" - , PS3_HOST(instance), channel, target_id, vd_id, i, + LOG_INFO_IN_IRQ( + instance, + "hno:%u vd[%u:%u:%u] span[%u] stripeDataSize[%u], state[%u], pdNum[%u]\n", + PS3_HOST(instance), channel, target_id, vd_id, i, vd_entry->span[i].spanStripeDataSize, vd_entry->span[i].spanState, vd_entry->span[i].spanPdNum); for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - LOG_INFO_IN_IRQ(instance, - "hno:%u vd[%u:%u:%u]----span[%u]." - "extent[%u]----pd:[%u:%u:%u], state[%u]\n" - , PS3_HOST(instance), channel, target_id, vd_id, i, j, - vd_entry->span[i].extent[j].phyDiskID.ps3Dev.softChan, - vd_entry->span[i].extent[j].phyDiskID.ps3Dev.devID, - vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID, + LOG_INFO_IN_IRQ( + instance, + "hno:%u vd[%u:%u:%u] span[%u] ext[%u] pd:[%u:%u:%u], state[%u]\n", + PS3_HOST(instance), channel, target_id, vd_id, + i, j, + vd_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.softChan, + vd_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.devID, + vd_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.phyDiskID, vd_entry->span[i].extent[j].state); } } } static void ps3_pd_info_show(const struct ps3_instance *instance, - const struct ps3_pd_entry *pd_entry) + const struct ps3_pd_entry *pd_entry) { - LOG_INFO("hno:%u disk detail info - pd[%u:%u:%u], magicNum[%#x], " - "state[%s], dev_type[%s], config_flag[%s], pd_flags[0x%02x]" - "RWCT[%u], scsi_interface_type[%u], " - "task_abort_timeout[%u], task_reset_timeout[%u], " - "max_io_size[%u], dev_queue_depth[%u], " - "sector_size[%u], encl_id[%u], pd phy_id[%u], " - "dma_addr_alignment[%u], dma_len_alignment[%u]" - "normal_quota[%u] direct_quota[%u] is_direct_disable[%u]\n" - , PS3_HOST(instance), - PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), - PS3_PDID(&pd_entry->disk_pos), + LOG_INFO("hno:%u disk detail info - pd[%u:%u:%u], magicNum[%#x]\n" + "\tstate[%s], dev_type[%s], config_flag[%s], pd_flags[0x%02x]\n" + "\tRWCT[%u], scsi_interface_type[%u]\n" + "\ttask_abort_timeout[%u], task_reset_timeout[%u]\n" + "\tmax_io_size[%u], dev_queue_depth[%u]\n" + "\tsector_size[%u], encl_id[%u], pd phy_id[%u]\n" + "\tdma_addr_alignment[%u], dma_len_alignment[%u]\n" + "\tnormal_quota[%u], direct_quota[%u], is_direct_disable[%u], ncq_prio[%u]\n", + PS3_HOST(instance), PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos), pd_entry->disk_pos.diskMagicNum, - getDeviceStateName((DeviceState_e)pd_entry->state), + getDeviceStateName((enum DeviceState)pd_entry->state), namePS3DevType((enum PS3DevType)pd_entry->dev_type), - getPdStateName((MicPdState_e)pd_entry->config_flag, instance->is_raid), pd_entry->pd_flags, - pd_entry->RWCT, pd_entry->scsi_interface_type, - pd_entry->task_abort_timeout, pd_entry->task_reset_timeout, - pd_entry->max_io_size, pd_entry->dev_queue_depth, - pd_entry->sector_size, pd_entry->encl_id, - pd_entry->phy_id, pd_entry->dma_addr_alignment, - pd_entry->dma_len_alignment, - pd_entry->normal_quota, pd_entry->direct_quota, pd_entry->is_direct_disable - ); + getPdStateName((enum MicPdState)pd_entry->config_flag, + instance->is_raid), + pd_entry->pd_flags, pd_entry->RWCT, + pd_entry->scsi_interface_type, pd_entry->task_abort_timeout, + pd_entry->task_reset_timeout, pd_entry->max_io_size, + pd_entry->dev_queue_depth, pd_entry->sector_size, + pd_entry->encl_id, pd_entry->phy_id, + pd_entry->dma_addr_alignment, pd_entry->dma_len_alignment, + pd_entry->normal_quota, pd_entry->direct_quota, + pd_entry->is_direct_disable, pd_entry->support_ncq_prio); } static inline void ps3_pd_info_localed(const struct ps3_instance *instance, - struct ps3_pd_entry *local_entry, const struct PS3PDInfo *pd_info) + struct ps3_pd_entry *local_entry, + const struct PS3PDInfo *pd_info) { local_entry->disk_pos = pd_info->diskPos; local_entry->dev_type = ps3_pd_type_localed(pd_info); @@ -454,67 +495,74 @@ static inline void ps3_pd_info_localed(const struct ps3_instance *instance, local_entry->is_direct_disable = pd_info->isDirectDisable; local_entry->encl_id = pd_info->enclId; local_entry->phy_id = pd_info->phyId; - local_entry->dma_addr_alignment = ps3_pd_dma_alignment_calc(pd_info->dmaAddrAlignShift); - local_entry->dma_len_alignment = ps3_pd_dma_alignment_calc(pd_info->dmaLenAlignShift); + local_entry->dma_addr_alignment = + ps3_pd_dma_alignment_calc(pd_info->dmaAddrAlignShift); + local_entry->dma_len_alignment = + ps3_pd_dma_alignment_calc(pd_info->dmaLenAlignShift); local_entry->normal_quota = pd_info->normalQuota; local_entry->direct_quota = pd_info->directQuota; + local_entry->support_ncq_prio = pd_info->supportNcqPrio; if (unlikely(local_entry->sector_size == 0)) { LOG_WARN("pd[%u:%u] sector_size is 0\n", - PS3_CHANNEL(&local_entry->disk_pos), - PS3_TARGET(&local_entry->disk_pos)); + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos)); } ps3_pd_info_show(instance, local_entry); } -S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, - U16 target_id, U16 pd_id) +int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, + unsigned short channel, unsigned short target_id, + unsigned short pd_id) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct PS3PDInfo *pd_info = NULL; struct ps3_dev_context *dev_ctx = &instance->dev_context; - LOG_DEBUG("hno:%u, get PD info [%u:%u:%u] start\n", - PS3_HOST(instance), channel, target_id, pd_id); + LOG_DEBUG("hno:%u, get PD info [%u:%u:%u] start\n", PS3_HOST(instance), + channel, target_id, pd_id); ret = ps3_pd_info_get(instance, channel, target_id, pd_id); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL6, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, get single PD info [%u:%u:%u] NOK\n", - PS3_HOST(instance), channel, target_id, pd_id); + PS3_HOST(instance), channel, target_id, pd_id); goto l_out; } pd_info = dev_ctx->pd_info_buf; - INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS1, &pd_info->diskPos.diskDev.diskID); + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS1, + &pd_info->diskPos.diskDev.diskID); if (PS3_PDID_INVALID(&pd_info->diskPos)) { LOG_WARN("hno:%u, cannot found PD info [%u:%u:%u]\n", - PS3_HOST(instance), channel, target_id, pd_id); + PS3_HOST(instance), channel, target_id, pd_id); ret = -PS3_FAILED; goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_MOD_ALIGN, &pd_info->dmaAddrAlignShift); - if (pd_info->dmaAddrAlignShift > - PS3_DMA_ALIGN_SHIFT_MAX) { - LOG_WARN("hno:%u PD info [%u:%u:%u] invalid dmaAddrAlignShift\n", - PS3_HOST(instance), channel, target_id, PS3_PDID(&pd_info->diskPos)); + if (pd_info->dmaAddrAlignShift > PS3_DMA_ALIGN_SHIFT_MAX) { + LOG_WARN( + "hno:%u PD info [%u:%u:%u] invalid dmaAddrAlignShift\n", + PS3_HOST(instance), channel, target_id, + PS3_PDID(&pd_info->diskPos)); ret = -PS3_FAILED; goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_MOD_ALIGN1, &pd_info->dmaLenAlignShift); - if (pd_info->dmaLenAlignShift > - PS3_DMA_ALIGN_SHIFT_MAX) { + if (pd_info->dmaLenAlignShift > PS3_DMA_ALIGN_SHIFT_MAX) { LOG_WARN("hno:%u PD info [%u:%u:%u] invalid dmalenAlignShift\n", - PS3_HOST(instance), channel, target_id, PS3_PDID(&pd_info->diskPos)); + PS3_HOST(instance), channel, target_id, + PS3_PDID(&pd_info->diskPos)); ret = -PS3_FAILED; goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN2, &channel); if (unlikely(PS3_CHANNEL(&pd_info->diskPos) != channel || - PS3_TARGET(&pd_info->diskPos) != target_id)) { - LOG_ERROR("hno:%u PD info get [%u:%u:%u]!=[%u:%u:%u] magic[%#x] unmatched\n", + PS3_TARGET(&pd_info->diskPos) != target_id)) { + LOG_ERROR( + "hno:%u PD info get [%u:%u:%u]!=[%u:%u:%u] magic[%#x] unmatched\n", PS3_HOST(instance), channel, target_id, pd_id, PS3_CHANNEL(&pd_info->diskPos), PS3_TARGET(&pd_info->diskPos), @@ -526,18 +574,21 @@ S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, } INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKID, &PS3_PDID(&pd_info->diskPos)); - if (unlikely(PS3_PDID(&pd_info->diskPos) > PS3_MAX_PD_COUNT(instance))) { + if (unlikely(PS3_PDID(&pd_info->diskPos) > + PS3_MAX_PD_COUNT(instance))) { LOG_ERROR("hno:%u init pd info NOK, pd_id[%d] > max[%d]\n", - PS3_HOST(instance), - PS3_PDID(&pd_info->diskPos), PS3_MAX_PD_COUNT(instance)); + PS3_HOST(instance), PS3_PDID(&pd_info->diskPos), + PS3_MAX_PD_COUNT(instance)); PS3_BUG(); ret = -PS3_FAILED; goto l_out; } - ps3_pd_info_localed(instance, &dev_ctx->pd_entries_array[ - PS3_PDID(&pd_info->diskPos)], pd_info); + ps3_pd_info_localed( + instance, + &dev_ctx->pd_entries_array[PS3_PDID(&pd_info->diskPos)], + pd_info); dev_ctx->pd_table.pd_idxs[channel][target_id] = PS3_PDID(&pd_info->diskPos); l_out: @@ -546,10 +597,10 @@ S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, static void ps3_pd_info_get_all(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; - U8 chan_id = 0; + int ret = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; + unsigned char chan_id = 0; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; @@ -557,49 +608,53 @@ static void ps3_pd_info_get_all(struct ps3_instance *instance) struct ps3_dev_pool *p_pd_pool = &p_dev_ctx->pd_pool; memset(p_table->pd_idxs_array, PS3_INVALID_VALUE, - p_dev_ctx->total_pd_count * sizeof(U16)); + p_dev_ctx->total_pd_count * sizeof(unsigned short)); for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { - if (PS3_PDID_INVALID(&p_pd_pool->devs[chan_id][j].pd.diskPos)) { + if (PS3_PDID_INVALID( + &p_pd_pool->devs[chan_id][j].pd.diskPos)) { continue; } - ret = ps3_dev_mgr_pd_info_get(instance, chan_id, j, - PS3_PDID(&p_pd_pool->devs[chan_id][j].pd.diskPos)); + ret = ps3_dev_mgr_pd_info_get( + instance, chan_id, j, + PS3_PDID(&p_pd_pool->devs[chan_id][j] + .pd.diskPos)); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, get PD[%u:%u] info NOK\n", - PS3_HOST(instance), chan_id, j); + PS3_HOST(instance), chan_id, j); } } } } -S32 ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance) +int ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - LOG_FILE_INFO("hno:%u ps3_dev_mgr_vd_info_subscribe\n", PS3_HOST(instance)); + int ret = PS3_SUCCESS; + + LOG_FILE_INFO("hno:%u %s\n", PS3_HOST(instance), __func__); - if (PS3_MAX_VD_COUNT(instance) <= 0) { + if (PS3_MAX_VD_COUNT(instance) <= 0) goto l_out; - } ret = ps3_vd_info_async_get(instance); if (ret != PS3_SUCCESS) { LOG_FILE_ERROR("hno:%u async get VD info failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; } -S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) +int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; @@ -608,7 +663,7 @@ S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } @@ -617,64 +672,68 @@ S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("hno:%u who steal free this cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_VDPENDING_CMD); - INJECT_START(PS3_ERR_IJ_CANCEL_VDPENDING_CMD_FAIL, &ret) - if(ret == -PS3_ENOMEM){ - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, + 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, + PS3_CANCEL_VDPENDING_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_VDPENDING_CMD_FAIL, &ret); + if (ret == -PS3_ENOMEM) { + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); ret = PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; - }else if(ret != PS3_SUCCESS){ + } else if (ret != PS3_SUCCESS) { LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->dev_context.vdpending_abort_cmd), cmd->index); + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->dev_context.vdpending_abort_cmd), + cmd->index); abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } ret = PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_VDPENDING_CMD); - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_VD_PENDING_FAILED, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u unsubscribe vd pending, cancel cmd NOK\n", - PS3_HOST(instance)); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + PS3_HOST(instance)); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", PS3_HOST(instance), + cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); l_out: return ret; } -S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) +int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - ULong flags1 = 0; - Bool is_need_resend = PS3_FALSE; + unsigned long flags1 = 0; + unsigned char is_need_resend = PS3_FALSE; + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; @@ -683,9 +742,10 @@ S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_need_resend = PS3_TRUE; - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); goto l_resend; } @@ -693,71 +753,84 @@ S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("hno:%u free vdpending cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } + if (ps3_atomic_add_unless(&instance->dev_context.is_vdpending_abort, 1, + 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_VDPENDING_CMD); - if(ret == -PS3_ENOMEM){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, + PS3_CANCEL_VDPENDING_CMD); + if (ret == -PS3_ENOMEM) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; - }else if(ret != PS3_SUCCESS){ - LOG_FILE_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->dev_context.vdpending_abort_cmd), cmd->index); + } else if (ret != PS3_SUCCESS) { + LOG_FILE_INFO( + "hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->dev_context.vdpending_abort_cmd), + cmd->index); abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } ret = -PS3_FAILED; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - instance->dev_context.abort_vdpending_cmd = 1; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_VDPENDING_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u unsubscribe vd pending, cancel cmd NOK\n", - PS3_HOST(instance)); - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + PS3_HOST(instance)); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(instance->dev_context.subwork == 0){ - if(instance->dev_context.abort_vdpending_cmd != 0){ - instance->dev_context.abort_vdpending_cmd = 0; + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (ps3_atomic_read(&instance->dev_context.subwork) == 0) { + if (ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) != 0) { + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); LOG_FILE_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); is_need_resend = PS3_TRUE; } } - ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); + ps3_atomic_set(&instance->dev_context.is_vdpending_abort, 0); l_resend: if (is_need_resend) { ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, + flags1); goto l_out; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); l_out: return ret; @@ -765,114 +838,114 @@ S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance) void ps3_dev_mgr_vd_info_clear(struct ps3_instance *instance) { - ULong flags = 0; - ULong flags1 = 0; + unsigned long flags = 0; + unsigned long flags1 = 0; struct ps3_cmd *cmd = NULL; - instance->dev_context.abort_vdpending_cmd = 0; + + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); cmd = instance->dev_context.vd_pending_cmd; if (cmd == NULL) { LOG_WARN("hno:%u vd pending cmd has been cancel\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO("hno:%u free this cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + LOG_INFO("hno:%u free this cmd,CFID:%d\n", PS3_HOST(instance), + cmd->index); + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); instance->dev_context.vd_pending_cmd = NULL; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + LOG_INFO("hno:%u vd pending cmd free, CFID:%d\n", PS3_HOST(instance), + cmd->index); instance->dev_context.vd_pending_cmd = NULL; - instance->dev_context.subwork = 0; - + ps3_atomic_set(&instance->dev_context.subwork, 0); ps3_mgr_cmd_free(instance, cmd); l_out: return; } -#ifndef _WINDOWS void ps3_change_sdev_max_sector(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry) + struct PS3VDEntry *vd_entry) { struct scsi_device *sdev = NULL; struct PS3Dev *p_vd = &vd_entry->diskPos.diskDev.ps3Dev; + unsigned int max_hw_sectors = 0; - sdev = ps3_scsi_device_lookup(instance, p_vd->softChan, - p_vd->devID, 0); + sdev = ps3_scsi_device_lookup(instance, p_vd->softChan, p_vd->devID, 0); if (sdev != NULL) { - if (vd_entry->sectorSize == PS3_SECTORSIZE_512B) { - blk_queue_max_hw_sectors(sdev->request_queue, vd_entry->maxIOSize); - } else { - blk_queue_max_hw_sectors(sdev->request_queue, - vd_entry->maxIOSize << (ilog2(vd_entry->sectorSize) - PS3_512B_SHIFT)); - } - + if (vd_entry->sectorSize == PS3_SECTORSIZE_512B) + max_hw_sectors = vd_entry->maxIOSize; + else + max_hw_sectors = vd_entry->maxIOSize << + (ilog2(vd_entry->sectorSize) - PS3_512B_SHIFT); + +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + if (queue_max_hw_sectors(sdev->request_queue) != max_hw_sectors) + blk_queue_max_hw_sectors(sdev->request_queue, max_hw_sectors); +#endif LOG_INFO_IN_IRQ(instance, "hno:%u vd[%u:%u] max sector num change to:%d\n", PS3_HOST(instance), p_vd->softChan, p_vd->devID, - vd_entry->maxIOSize); + max_hw_sectors); ps3_scsi_device_put(instance, sdev); } } -#endif -S32 ps3_vd_info_get_all(struct ps3_instance *instance) +int ps3_vd_info_get_all(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - U16 i = 0; + int ret = -PS3_FAILED; + unsigned short i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; - struct ps3_vd_table *p_vd_table = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; + struct ps3_vd_table *p_vd_table = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - struct PS3VDEntry *p_vd_entry = - p_dev_ctx->vd_info_buf_sync->vds; + struct PS3VDEntry *p_vd_entry = p_dev_ctx->vd_info_buf_sync->vds; struct PS3Dev *p_dev = NULL; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; if (PS3_MAX_VD_COUNT(instance) == 0) { - LOG_INFO("hno:%u vd max count is %d\n", - PS3_HOST(instance), PS3_MAX_VD_COUNT(instance)); + LOG_INFO("hno:%u vd max count is %d\n", PS3_HOST(instance), + PS3_MAX_VD_COUNT(instance)); ret = PS3_SUCCESS; goto l_out; } if (p_dev_ctx->vd_list_buf->count == 0) { - LOG_INFO("hno:%u vd list count is 0\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u vd list count is 0\n", PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ret = ps3_vd_info_sync_get(instance, 0, PS3_MAX_VD_COUNT(instance)); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u, sync get VD info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u, sync get VD info NOK\n", PS3_HOST(instance)); goto l_out; } memset(p_vd_table->vd_idxs_array, 0, - p_dev_ctx->total_vd_count * sizeof(U16)); + p_dev_ctx->total_vd_count * sizeof(unsigned short)); - LOG_INFO("hno:%u get vd info count is %d\n", - PS3_HOST(instance),p_dev_ctx->vd_info_buf_sync->count); + LOG_INFO("hno:%u get vd info count is %d\n", PS3_HOST(instance), + p_dev_ctx->vd_info_buf_sync->count); for (i = 0; i < p_dev_ctx->vd_info_buf_sync->count; i++) { if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { - LOG_WARN("hno:%u, init %d of %d vd info NOK, vdid is 0\n", + LOG_WARN( + "hno:%u, init %d of %d vd info NOK, vdid is 0\n", PS3_HOST(instance), i, p_dev_ctx->vd_info_buf_sync->count); continue; @@ -880,17 +953,20 @@ S32 ps3_vd_info_get_all(struct ps3_instance *instance) p_dev = PS3_DEV(&p_vd_entry[i].diskPos); - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_dev->virtDiskID); - if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + p_dev->virtDiskID); + if (!ps3_dev_id_valid_check(instance, + (unsigned char)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { PS3_BUG(); continue; } if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_ERROR("hno:%u init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", - PS3_HOST(instance),i, - p_dev_ctx->vd_info_buf_sync->count-1, + LOG_ERROR( + "hno:%u init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", + PS3_HOST(instance), i, + p_dev_ctx->vd_info_buf_sync->count - 1, virtDiskIdx, PS3_MAX_VD_COUNT(instance)); PS3_BUG(); @@ -898,96 +974,89 @@ S32 ps3_vd_info_get_all(struct ps3_instance *instance) } ps3_vd_busy_scale_get(&p_vd_entry[i]); memcpy(&p_vd_array[virtDiskIdx], &p_vd_entry[i], - sizeof(struct PS3VDEntry)); - p_vd_table->vd_idxs[p_dev->softChan][p_dev->devID] = p_dev->virtDiskID; + sizeof(struct PS3VDEntry)); + p_vd_table->vd_idxs[p_dev->softChan][p_dev->devID] = + p_dev->virtDiskID; ps3_vd_info_show(instance, &p_vd_array[virtDiskIdx]); -#ifndef _WINDOWS - if (p_vd_entry[i].maxIOSize != 0) { +#ifndef _WINDOWS + if (p_vd_entry[i].maxIOSize != 0) ps3_change_sdev_max_sector(instance, &p_vd_entry[i]); - } #endif } - mb(); + mb(); /* in order to force CPU ordering */ p_dev_ctx->vd_table_idx = vd_table_idx; - mb(); + mb(); /* in order to force CPU ordering */ l_out: return ret; } -S32 ps3_device_mgr_data_init(struct ps3_instance *instance) +int ps3_device_mgr_data_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - LOG_DEBUG("hno:%u enter\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u enter\n", PS3_HOST(instance)); if (PS3_MAX_PD_COUNT(instance) != 0) { ret = ps3_dev_mgr_pd_list_get(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } ps3_pd_info_get_all(instance); } if (PS3_MAX_VD_COUNT(instance) != 0) { ret = ps3_dev_mgr_vd_list_get(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } instance->dev_context.vd_table_idx = 0; ps3_vd_info_get_all(instance); } l_out: - LOG_DEBUG("hno:%u out\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u out\n", PS3_HOST(instance)); - return ret ; + return ret; } -S32 ps3_device_mgr_data_exit(struct ps3_instance *instance) +int ps3_device_mgr_data_exit(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - LOG_DEBUG("hno:%u \n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u\n", PS3_HOST(instance)); return ret; } -S32 ps3_device_mgr_init(struct ps3_instance *instance) +int ps3_device_mgr_init(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; if (PS3_MAX_VD_COUNT(instance) == 0 && - PS3_MAX_PD_COUNT(instance) == 0) { + PS3_MAX_PD_COUNT(instance) == 0) { LOG_ERROR("hno:%u max VD and PD count == 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } ret = ps3_dev_channel_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } ret = ps3_dev_buff_alloc(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } ps3_mutex_init(&instance->dev_context.dev_priv_lock); ps3_mutex_init(&instance->dev_context.dev_scan_lock); #ifdef _WINDOWS ps3_windows_channel_map_init(instance); ret = ps3_windows_private_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } #endif l_out: - return ret ; + return ret; } void ps3_device_mgr_exit(struct ps3_instance *instance) @@ -1000,114 +1069,147 @@ void ps3_device_mgr_exit(struct ps3_instance *instance) ps3_mutex_destroy(&instance->dev_context.dev_scan_lock); } -S32 ps3_dev_mgr_pd_list_get(struct ps3_instance *instance) +int ps3_dev_mgr_pd_list_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_pd_list = p_dev_ctx->pd_list_buf; struct PS3Dev *p_dev = NULL; +#if defined(PS3_DISALLOW_ZERO_ARRAY) + union PS3Device *devs = p_pd_list->devs; +#endif ret = ps3_pd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset((U8*)p_dev_ctx->pd_pool.devs_buffer, PS3_INVALID_VALUE, - p_dev_ctx->total_pd_count * sizeof(union PS3Device)); + memset((unsigned char *)p_dev_ctx->pd_pool.devs_buffer, + PS3_INVALID_VALUE, + p_dev_ctx->total_pd_count * sizeof(union PS3Device)); - LOG_INFO("hno:%u get pd list count is %d\n", - PS3_HOST(instance), p_pd_list->count); + LOG_INFO("hno:%u get pd list count is %d\n", PS3_HOST(instance), + p_pd_list->count); for (i = 0; i < p_pd_list->count; i++) { +#if defined(PS3_DISALLOW_ZERO_ARRAY) + p_dev = PS3_DEV(&devs[i].pd.diskPos); + if (PS3_DEV_INVALID(devs[i].pd.diskPos)) { +#else p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); - if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { +#endif LOG_WARN("hno:%u, get pd list %d dev pdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_PD)) { + if (!ps3_dev_id_valid_check(instance, + (unsigned char)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_PD)) { PS3_BUG(); continue; } - LOG_INFO("hno:%u, pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", + LOG_INFO( + "hno:%u, pd list %d dev[%u:%u:%u], magic[%#x], state[%s]\n", PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, p_dev->phyDiskID, +#if defined(PS3_DISALLOW_ZERO_ARRAY) + devs[i].pd.diskPos.diskMagicNum, + getDeviceStateName((enum DeviceState)devs[i].pd.diskState)); + p_dev_ctx->pd_pool.devs[p_dev->softChan][p_dev->devID].pd = devs[i].pd; +#else p_pd_list->devs[i].pd.diskPos.diskMagicNum, - getDeviceStateName((DeviceState_e)p_pd_list->devs[i].pd.diskState)); + getDeviceStateName((enum DeviceState)p_pd_list->devs[i] + .pd.diskState)); p_dev_ctx->pd_pool.devs[p_dev->softChan][p_dev->devID].pd = p_pd_list->devs[i].pd; - +#endif } l_out: return ret; } -S32 ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) +int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_vd_list = p_dev_ctx->vd_list_buf; struct PS3Dev *p_dev = NULL; +#if defined(PS3_DISALLOW_ZERO_ARRAY) + union PS3Device *devs = p_vd_list->devs; +#endif ret = ps3_vd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get vd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset((U8*)p_dev_ctx->vd_pool.devs_buffer, PS3_INVALID_VALUE, - p_dev_ctx->total_vd_count * sizeof(union PS3Device)); + memset((unsigned char *)p_dev_ctx->vd_pool.devs_buffer, + PS3_INVALID_VALUE, + p_dev_ctx->total_vd_count * sizeof(union PS3Device)); - LOG_INFO("hno:%u get vd list count is %d\n", - PS3_HOST(instance), p_vd_list->count); + LOG_INFO("hno:%u get vd list count is %d\n", PS3_HOST(instance), + p_vd_list->count); for (i = 0; i < p_vd_list->count; i++) { +#if defined(PS3_DISALLOW_ZERO_ARRAY) + p_dev = PS3_DEV(&devs[i].vd.diskPos); + if (PS3_DEV_INVALID(devs[i].vd.diskPos)) { +#else p_dev = PS3_DEV(&p_vd_list->devs[i].vd.diskPos); - if (PS3_VDID_INVALID(&p_vd_list->devs[i].vd.diskPos)) { +#endif LOG_WARN("hno:%u, get vd list %d vdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { + if (!ps3_dev_id_valid_check(instance, + (unsigned char)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { PS3_BUG(); continue; } LOG_INFO("hno:%u, vd list %d dev[%u:%u:%u], magic[%#x]\n", - PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, - p_dev->virtDiskID, + PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, + p_dev->virtDiskID, +#if defined(PS3_DISALLOW_ZERO_ARRAY) + devs[i].vd.diskPos.diskMagicNum); + p_dev_ctx->vd_pool.devs[p_dev->softChan][p_dev->devID].vd = devs[i].vd; +#else p_vd_list->devs[i].vd.diskPos.diskMagicNum); p_dev_ctx->vd_pool.devs[p_dev->softChan][p_dev->devID].vd = p_vd_list->devs[i].vd; +#endif } l_out: return ret; } -Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, - U16 target_id, U8 dev_type) +unsigned char ps3_dev_id_valid_check(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char dev_type) { - U8 ret = PS3_DRV_FALSE; + unsigned char ret = PS3_DRV_FALSE; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; if (dev_type == PS3_DISK_TYPE_VD) { INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN1, &channel); if (!PS3_IS_VD_CHANNEL(instance, channel)) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "hno:%u check channel[%u] is not vd channel\n", PS3_HOST(instance), channel); goto l_out; @@ -1116,20 +1218,21 @@ Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, } else if (dev_type == PS3_DISK_TYPE_PD) { INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN3, &channel); if (!PS3_IS_PD_CHANNEL(instance, channel)) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "hno:%u check channel[%u] is not pd channel\n", PS3_HOST(instance), channel); goto l_out; } } else { - LOG_ERROR_IN_IRQ(instance, - "hno:%u dev id[%u:%u] channel err\n", - PS3_HOST(instance), channel, target_id); + LOG_ERROR_IN_IRQ(instance, "hno:%u dev id[%u:%u] channel err\n", + PS3_HOST(instance), channel, target_id); goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_MOD_TARGET, &target_id); if (unlikely(target_id >= p_dev_ctx->max_dev_in_channel[channel])) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "hno:%u check disk[%u:%u] target >= max[%u]\n", PS3_HOST(instance), channel, target_id, p_dev_ctx->max_dev_in_channel[channel]); @@ -1141,92 +1244,98 @@ Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, return ret; } -U8 ps3_get_vd_raid_level(struct ps3_instance *instance, - U8 channel, U16 target_id) +unsigned char ps3_get_vd_raid_level(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - U8 ret = RAID_UNKNOWN; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned char ret = RAID_UNKNOWN; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_table->vd_idxs[channel][target_id]); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + p_table->vd_idxs[channel][target_id]); p_entry = &p_vd_array[virtDiskIdx]; - if (p_entry == NULL) { + if (p_entry == NULL) goto l_out; - } - LOG_DEBUG("hno:%u, vd[%u:%u] raid level is:%d\n", - PS3_HOST(instance), channel, target_id, p_entry->raidLevel); + LOG_DEBUG("hno:%u, vd[%u:%u] raid level is:%d\n", PS3_HOST(instance), + channel, target_id, p_entry->raidLevel); ret = p_entry->raidLevel; l_out: return ret; } -struct ps3_scsi_priv_data *ps3_dev_mgr_lookup_vd_pri_data( - struct ps3_instance *instance, U8 channel, U16 target_id) +struct ps3_scsi_priv_data * +ps3_dev_mgr_lookup_vd_pri_data(struct ps3_instance *instance, + unsigned char channel, unsigned short target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_scsi_priv_data *ret = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - ret = p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs[channel] - [target_id]; + ret = p_dev_ctx->vd_pri_data_table.vd_pri_data_idxs[channel][target_id]; l_out: return ret; } -static inline Bool ps3_dev_is_valid(struct PS3DiskDevPos *diskPos, U8 channel, U16 target_id) +static inline unsigned char ps3_dev_is_valid(struct PS3DiskDevPos *diskPos, + unsigned char channel, + unsigned short target_id) { - if (PS3_DEV_INVALID(*diskPos) || PS3_CHANNEL(diskPos) != channel || PS3_TARGET(diskPos) != target_id) { + if (PS3_DEV_INVALID(*diskPos) || PS3_CHANNEL(diskPos) != channel || + PS3_TARGET(diskPos) != target_id) { return PS3_FALSE; } return PS3_TRUE; } -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( - struct ps3_instance *instance, U8 channel, U16 target_id) +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_table = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_table = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; - LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx); + LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", PS3_HOST(instance), + p_dev_ctx->vd_table_idx); if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), p_table->vd_idxs[channel][target_id]); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + p_table->vd_idxs[channel][target_id]); p_entry = &p_vd_array[virtDiskIdx]; - INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->diskPos.diskDev.diskID); - if (ps3_dev_is_valid(&p_entry->diskPos, channel, target_id) != PS3_TRUE) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, + &p_entry->diskPos.diskDev.diskID); + if (ps3_dev_is_valid(&p_entry->diskPos, channel, target_id) != + PS3_TRUE) { p_entry = NULL; goto l_out; } @@ -1234,24 +1343,27 @@ struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( return p_entry; } -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info( - struct ps3_instance *instance, U8 channel, U16 target_id) +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { struct ps3_pd_table *p_table = &instance->dev_context.pd_table; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_entry *p_entry = NULL; - U16 disk_idx = 0; + unsigned short disk_idx = 0; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_PD)) { + PS3_DISK_TYPE_PD)) { goto l_out; } disk_idx = p_table->pd_idxs[channel][target_id]; p_entry = &p_dev_ctx->pd_entries_array[disk_idx]; - INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, &p_entry->disk_pos.diskDev.diskID); - if (ps3_dev_is_valid(&p_entry->disk_pos, channel, target_id) != PS3_TRUE) { + INJECT_START(PS3_ERR_IJ_FORCE_MOD_DISKPOS, + &p_entry->disk_pos.diskDev.diskID); + if (ps3_dev_is_valid(&p_entry->disk_pos, channel, target_id) != + PS3_TRUE) { p_entry = NULL; goto l_out; } @@ -1259,23 +1371,26 @@ struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info( return p_entry; } -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( - struct ps3_instance *instance, U16 disk_id) +struct PS3VDEntry * +ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, + unsigned short disk_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; struct PS3VDEntry *p_entry = NULL; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; - LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx); + LOG_DEBUG("hno:%u cur_vd_idx[%d]\n", PS3_HOST(instance), + p_dev_ctx->vd_table_idx); virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_ERROR_IN_IRQ(instance, "hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", + LOG_ERROR_IN_IRQ( + instance, + "hno:%u , dev mgr lookup vd info disk id > max count:%d>%d\n", PS3_HOST(instance), disk_id, PS3_MAX_VD_COUNT(instance)); @@ -1286,7 +1401,9 @@ struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( p_entry = &p_vd_array[virtDiskIdx]; if (PS3_DEV_INVALID(p_entry->diskPos)) { - LOG_INFO_IN_IRQ(instance, "hno:%u idx[%d], virDisk[%d] dev id is invalid\n", + LOG_INFO_IN_IRQ( + instance, + "hno:%u idx[%d], virDisk[%d] dev id is invalid\n", PS3_HOST(instance), p_dev_ctx->vd_table_idx, disk_id); p_entry = NULL; goto l_out; @@ -1295,14 +1412,17 @@ struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( return p_entry; } -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( - struct ps3_instance *instance, U16 disk_id) +struct ps3_pd_entry * +ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, + unsigned short disk_id) { struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct ps3_pd_entry *p_entry = NULL; if (unlikely(disk_id > PS3_MAX_PD_COUNT(instance))) { - LOG_ERROR_IN_IRQ(instance, "hno:%u, dev mgr lookup pd info disk id > max count:%d>%d\n", + LOG_ERROR_IN_IRQ( + instance, + "hno:%u, dev mgr lookup pd info disk id > max count:%d>%d\n", PS3_HOST(instance), disk_id, PS3_MAX_PD_COUNT(instance)); PS3_BUG(); @@ -1312,11 +1432,12 @@ struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( p_entry = &p_dev_ctx->pd_entries_array[disk_id]; if (PS3_DEV_INVALID(p_entry->disk_pos) || - p_entry->config_flag == MIC_PD_STATE_UNKNOWN) { - LOG_INFO_IN_IRQ(instance, "hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", + p_entry->config_flag == MIC_PD_STATE_UNKNOWN) { + LOG_INFO_IN_IRQ( + instance, + "hno:%u pdid[%d] dev[%x] id is invalid, config_flag[%d]\n", PS3_HOST(instance), disk_id, - PS3_DISKID(&p_entry->disk_pos), - p_entry->config_flag); + PS3_DISKID(&p_entry->disk_pos), p_entry->config_flag); p_entry = NULL; goto l_out; } @@ -1324,15 +1445,16 @@ struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( return p_entry; } -union PS3Device* ps3_dev_mgr_lookup_vd_list( - struct ps3_instance *instance, U8 channel, U16 target_id) +union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { struct ps3_dev_pool *p_vd_pool = &instance->dev_context.vd_pool; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; union PS3Device *p_vd = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { goto l_out; } @@ -1340,8 +1462,8 @@ union PS3Device* ps3_dev_mgr_lookup_vd_list( if (PS3_DEV_INVALID(p_vd->vd.diskPos)) { LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is invalid\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, - target_id); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, + target_id); p_vd = NULL; goto l_out; } @@ -1349,40 +1471,36 @@ union PS3Device* ps3_dev_mgr_lookup_vd_list( return p_vd; } -union PS3Device* ps3_dev_mgr_lookup_pd_list( - struct ps3_instance *instance, U8 channel, U16 target_id) +union PS3Device *ps3_dev_mgr_lookup_pd_list(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { struct ps3_dev_pool *p_pd_pool = &instance->dev_context.pd_pool; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; union PS3Device *p_pd = NULL; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_PD)) { + PS3_DISK_TYPE_PD)) { goto l_out; } p_pd = &p_pd_pool->devs[channel][target_id]; if (PS3_DEV_INVALID(p_pd->pd.diskPos)) { -#if 0 - LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is invalid\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, - target_id); -#endif p_pd = NULL; goto l_out; } LOG_INFO("hno:%u idx[%d], dev[%u:%u] dev id is valid\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, - target_id); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, channel, + target_id); l_out: return p_pd; } -S32 ps3_adjust_queue_depth(struct ps3_instance *instance, - U8 dev_type, U32 queue_depth) +int ps3_adjust_queue_depth(struct ps3_instance *instance, + unsigned char dev_type, unsigned int queue_depth) { - S32 dev_queue_depth = PS3_QUEUE_DEPTH_DEFAULT; + int dev_queue_depth = PS3_QUEUE_DEPTH_DEFAULT; switch (dev_type) { case PS3_DEV_TYPE_SAS_HDD: @@ -1401,37 +1519,40 @@ S32 ps3_adjust_queue_depth(struct ps3_instance *instance, break; } - if (queue_depth != 0 && (S32)queue_depth <= - instance->cmd_attr.cur_can_que) { + if (queue_depth != 0 && + (int)queue_depth <= instance->cmd_attr.cur_can_que) { dev_queue_depth = queue_depth; } return dev_queue_depth; } -static inline S32 ps3_adjust_device_queue_depth(struct scsi_device *sdev, - struct ps3_instance *instance, S32 q_depth) +static inline int ps3_adjust_device_queue_depth(struct scsi_device *sdev, + struct ps3_instance *instance, + int q_depth) { - S32 queue_depth = q_depth; + int queue_depth = q_depth; struct ps3_pd_entry *p_pd_entry = NULL; + if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, - sdev->channel, sdev->id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, + sdev->id); if (p_pd_entry == NULL) { - LOG_WARN_IN_IRQ(instance, "hno:%u cannot found PD[%u:%u] device info\n", + LOG_WARN_IN_IRQ( + instance, + "hno:%u cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; } if ((p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_HDD) || - (p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD)) { - if (q_depth > PS3_QUEUE_DEPTH_SATA) { + (p_pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD)) { + if (q_depth > PS3_QUEUE_DEPTH_SATA) queue_depth = PS3_QUEUE_DEPTH_SATA; - } } } l_out: -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +#if defined(PS3_CHANGE_QUEUE_DEPTH) scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), queue_depth); #else scsi_change_queue_depth(sdev, queue_depth); @@ -1439,57 +1560,56 @@ static inline S32 ps3_adjust_device_queue_depth(struct scsi_device *sdev, return queue_depth; } -#ifndef _WINDOWS -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) -S32 ps3_change_queue_depth(struct scsi_device *sdev, - S32 queue_depth, S32 reason) +#if defined(PS3_CHANGE_QUEUE_DEPTH) +int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth, + int reason) { - S32 ret = -EOPNOTSUPP; + int ret = -EOPNOTSUPP; struct ps3_instance *instance = NULL; - instance = (struct ps3_instance*)sdev->host->hostdata; + + instance = (struct ps3_instance *)sdev->host->hostdata; if (instance == NULL) { - LOG_ERROR_IN_IRQ(instance,"hno:%u have no host\n", - sdev->host->host_no); + LOG_ERROR_IN_IRQ(instance, "hno:%u have no host\n", + sdev->host->host_no); goto l_out; } - if (queue_depth > sdev->host->can_queue) { + if (queue_depth > sdev->host->can_queue) queue_depth = sdev->host->can_queue; - } if (reason == SCSI_QDEPTH_DEFAULT || reason == SCSI_QDEPTH_RAMP_UP) { - ret = ps3_adjust_device_queue_depth(sdev, instance, queue_depth); + ret = ps3_adjust_device_queue_depth(sdev, instance, + queue_depth); } else if (reason == SCSI_QDEPTH_QFULL) { scsi_track_queue_full(sdev, queue_depth); ret = sdev->queue_depth; } - LOG_INFO_IN_IRQ(instance,"hno:%u change dev[%u:%u] queue depth to [%d] reason [%d]\n", + LOG_INFO_IN_IRQ( + instance, + "hno:%u change dev[%u:%u] queue depth to [%d] reason [%d]\n", PS3_HOST(instance), sdev->channel, sdev->id, ret, reason); l_out: return ret; } #else -S32 ps3_change_queue_depth(struct scsi_device *sdev, - S32 queue_depth) +int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth) { - S32 ret = sdev->queue_depth; + int ret = sdev->queue_depth; struct ps3_instance *instance = NULL; - instance = (struct ps3_instance*)sdev->host->hostdata; + instance = (struct ps3_instance *)sdev->host->hostdata; if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n", - sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); goto l_out; } - if (queue_depth > sdev->host->can_queue) { + if (queue_depth > sdev->host->can_queue) queue_depth = sdev->host->can_queue; - } ret = ps3_adjust_device_queue_depth(sdev, instance, queue_depth); LOG_INFO("hno:%u change dev[%u:%u] queue depth to [%d]\n", - PS3_HOST(instance), sdev->channel, sdev->id, ret); + PS3_HOST(instance), sdev->channel, sdev->id, ret); l_out: return ret; @@ -1498,60 +1618,66 @@ S32 ps3_change_queue_depth(struct scsi_device *sdev, #endif static inline void ps3_init_vd_stream(struct ps3_vd_stream_detect *vdsd) { - U32 index = 0; - U8 tyepIndex = 0; - for(tyepIndex = PS3_SCSI_CMD_TYPE_READ;tyepIndex < PS3_SCSI_CMD_TYPE_WRITE;tyepIndex++){ - vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].mru_bit_map = MR_STREM_BITMAP; - ps3_spin_lock_init(&vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].ps3_sequence_stream_lock); - - for(index = 0;index < PS3_IO_MAX_STREAMS_TRACKED;index++){ - vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].stream_track[index].next_seq_lba = 0; - vdsd[tyepIndex-PS3_SCSI_CMD_TYPE_READ].stream_track[index].rw_type = tyepIndex; - } - } - return; + unsigned int index = 0; + unsigned char tyepIndex = 0; + + for (tyepIndex = PS3_SCSI_CMD_TYPE_READ; + tyepIndex < PS3_SCSI_CMD_TYPE_WRITE; tyepIndex++) { + vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ].mru_bit_map = + MR_STREM_BITMAP; + ps3_spin_lock_init(&vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] + .ps3_sequence_stream_lock); + + for (index = 0; index < PS3_IO_MAX_STREAMS_TRACKED; index++) { + vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] + .stream_track[index] + .next_seq_lba = 0; + vdsd[tyepIndex - PS3_SCSI_CMD_TYPE_READ] + .stream_track[index] + .rw_type = tyepIndex; + } + } } -S32 ps3_scsi_private_init_pd(struct scsi_device *sdev) +static int ps3_scsi_private_init_pd(struct scsi_device *sdev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_pd_entry *p_pd_entry = NULL; struct ps3_qos_pd_mgr *p_qos_pd_mgr = NULL; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; + (struct ps3_instance *)sdev->host->hostdata; - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, - sdev->channel, sdev->id); + p_pd_entry = + ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL1, &p_pd_entry); if (p_pd_entry == NULL) { LOG_WARN("hno:%u cannot found PD[%u:%u] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_PD_STATE_ERROR, &p_pd_entry->state); - if (! ps3_pd_scsi_visible_check(instance, &p_pd_entry->disk_pos, - p_pd_entry->dev_type, p_pd_entry->config_flag, - p_pd_entry->state)) { + if (!ps3_pd_scsi_visible_check( + instance, &p_pd_entry->disk_pos, p_pd_entry->dev_type, + p_pd_entry->config_flag, p_pd_entry->state)) { ret = -ENXIO; LOG_WARN("hno:%u pd was blocked: chan[%d] id[%d]\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; } LOG_DEBUG("hno:%u found PD[%u:%u:%u] magic[%#x] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_PDID(&p_pd_entry->disk_pos), - p_pd_entry->disk_pos.diskMagicNum); + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_PDID(&p_pd_entry->disk_pos), + p_pd_entry->disk_pos.diskMagicNum); - p_priv_data = (struct ps3_scsi_priv_data*)ps3_kzalloc(instance, - sizeof(struct ps3_scsi_priv_data)); + p_priv_data = (struct ps3_scsi_priv_data *)ps3_kzalloc( + instance, sizeof(struct ps3_scsi_priv_data)); INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL2, &p_priv_data); if (p_priv_data == NULL) { - LOG_ERROR("hno:%u pd[%u:%u:%u] Failed" - " to allocate scsi device private data\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_PDID(&p_pd_entry->disk_pos)); + LOG_ERROR("hno:%u pd[%u:%u:%u] Failed to allocate scsi device private data\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_PDID(&p_pd_entry->disk_pos)); ret = -ENOMEM; goto l_out; } @@ -1559,19 +1685,23 @@ S32 ps3_scsi_private_init_pd(struct scsi_device *sdev) p_priv_data->disk_pos = p_pd_entry->disk_pos; p_priv_data->dev_type = p_pd_entry->dev_type; p_priv_data->is_taskmgmt_enable = PS3_DRV_TRUE; - p_priv_data->task_abort_timeout = - p_pd_entry->task_abort_timeout; - p_priv_data->task_reset_timeout = - p_pd_entry->task_reset_timeout; + p_priv_data->task_abort_timeout = p_pd_entry->task_abort_timeout; + p_priv_data->task_reset_timeout = p_pd_entry->task_reset_timeout; p_priv_data->task_manager_busy = 0; p_priv_data->encl_id = p_pd_entry->encl_id; p_priv_data->phy_id = p_pd_entry->phy_id; +#ifdef PS3_NCQ_PRIO_SUPPORT + p_priv_data->ncq_prio_support = p_pd_entry->support_ncq_prio; + p_priv_data->ncq_prio_enable = 0; +#endif ps3_atomic_set(&p_priv_data->rd_io_outstand, PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&p_priv_data->wr_io_outstand, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, + PS3_CMD_STAT_INIT_VALUE); p_qos_pd_mgr = ps3_qos_pd_mgr_init(instance, p_pd_entry); - if (p_qos_pd_mgr != NULL && p_qos_pd_mgr->dev_type != p_pd_entry->dev_type) { + if (p_qos_pd_mgr != NULL && PS3_NEED_UPDATE_PD_QUOTAS(p_qos_pd_mgr, p_pd_entry)) { ps3_qos_pd_rsc_init(p_qos_pd_mgr, p_pd_entry); } p_priv_data->dev_deling = PS3_FALSE; @@ -1583,52 +1713,50 @@ S32 ps3_scsi_private_init_pd(struct scsi_device *sdev) void ps3_vd_busy_scale_get(struct PS3VDEntry *vd_entry) { - U16 scale = 0; - U32 strip_size_shift = 0; + unsigned short scale = 0; + unsigned int strip_size_shift = 0; strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); - scale = vd_entry->span[0].spanStripeDataSize >> strip_size_shift;; - if ((vd_entry->raidLevel == RAID1E || - vd_entry->raidLevel == RAID10) && - (vd_entry->span[0].spanPdNum & 1)) { + scale = vd_entry->span[0].spanStripeDataSize >> strip_size_shift; + if ((vd_entry->raidLevel == RAID1E || vd_entry->raidLevel == RAID10) && + (vd_entry->span[0].spanPdNum & 1)) { scale = scale >> 1; } vd_entry->dev_busy_scale = scale; - return; } -S32 ps3_scsi_private_init_vd(struct scsi_device *sdev) +static int ps3_scsi_private_init_vd(struct scsi_device *sdev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; - struct ps3_pri_data_table *p_vd_pri_data_table = &instance->dev_context.vd_pri_data_table; + (struct ps3_instance *)sdev->host->hostdata; + struct ps3_pri_data_table *p_vd_pri_data_table = + &instance->dev_context.vd_pri_data_table; - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, - sdev->channel, sdev->id); + p_vd_entry = + ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL1, &p_vd_entry); if (p_vd_entry == NULL) { LOG_WARN("hno:%u cannot found VD[%u:%u] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } LOG_DEBUG("hno:%u found VD[%u:%u:%u] magic[%#x] device info\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos), - p_vd_entry->diskPos.diskMagicNum); + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos), + p_vd_entry->diskPos.diskMagicNum); - p_priv_data = (struct ps3_scsi_priv_data*)ps3_kzalloc(instance, - sizeof(struct ps3_scsi_priv_data)); + p_priv_data = (struct ps3_scsi_priv_data *)ps3_kzalloc( + instance, sizeof(struct ps3_scsi_priv_data)); INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL, &p_priv_data); if (p_priv_data == NULL) { - LOG_ERROR("hno:%u vd[%u:%u:%u] Failed" - " to allocate scsi device private data\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos)); + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate scsi device private data\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; goto l_out; } @@ -1641,17 +1769,21 @@ S32 ps3_scsi_private_init_vd(struct scsi_device *sdev) p_priv_data->task_manager_busy = 0; ps3_atomic_set(&p_priv_data->rd_io_outstand, PS3_CMD_STAT_INIT_VALUE); ps3_atomic_set(&p_priv_data->wr_io_outstand, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, PS3_CMD_STAT_INIT_VALUE); - ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_total_cnt, + PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&p_priv_data->r1x_read_cmd_swap_res_cnt, + PS3_CMD_STAT_INIT_VALUE); p_priv_data->dev_deling = PS3_FALSE; p_priv_data->swap_flag = PS3_FALSE; ps3_vd_busy_scale_get(p_vd_entry); ps3_init_vd_stream(p_priv_data->vd_sd); - p_priv_data->r1x_rb_info = (struct ps3_r1x_read_balance_info *)ps3_kzalloc(instance, - sizeof(struct ps3_r1x_read_balance_info)); + p_priv_data->r1x_rb_info = + (struct ps3_r1x_read_balance_info *)ps3_kzalloc( + instance, sizeof(struct ps3_r1x_read_balance_info)); INJECT_START(PS3_ERR_IJ_FORCE_RB_INFO_NULL, &p_priv_data->r1x_rb_info); if (p_priv_data->r1x_rb_info == NULL) { - LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate r1x_lb_info\n", + LOG_ERROR( + "hno:%u vd[%u:%u:%u] Failed to allocate r1x_lb_info\n", PS3_HOST(instance), sdev->channel, sdev->id, PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; @@ -1661,22 +1793,22 @@ S32 ps3_scsi_private_init_vd(struct scsi_device *sdev) sdev->hostdata = p_priv_data; ret = ps3_r1x_lock_prepare_for_vd(instance, sdev, - p_vd_entry->raidLevel); - if(unlikely(PS3_SUCCESS != ret)){ + p_vd_entry->raidLevel); + if (unlikely(ret != PS3_SUCCESS)) { ps3_kfree(instance, p_priv_data->r1x_rb_info); p_priv_data->r1x_rb_info = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - LOG_ERROR("hno:%u vd[%u:%u:%u] Failed" - " to allocate raid1x write lock mgr\n", - PS3_HOST(instance), sdev->channel, sdev->id, - PS3_VDID(&p_vd_entry->diskPos)); + LOG_ERROR("hno:%u vd[%u:%u:%u] Failed to allocate raid1x write lock mgr\n", + PS3_HOST(instance), sdev->channel, sdev->id, + PS3_VDID(&p_vd_entry->diskPos)); ret = -ENOMEM; goto l_err; } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); p_vd_pri_data_table->vd_pri_data_idxs[PS3_SDEV_CHANNEL(sdev)] - [PS3_SDEV_TARGET(sdev)] = p_priv_data; + [PS3_SDEV_TARGET(sdev)] = + p_priv_data; ps3_qos_vd_init(instance, p_vd_entry); @@ -1693,46 +1825,47 @@ S32 ps3_scsi_private_init_vd(struct scsi_device *sdev) return ret; } -S32 ps3_scsi_slave_alloc(struct scsi_device *sdev) +int ps3_scsi_slave_alloc(struct scsi_device *sdev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_instance *instance = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_pd_entry *p_pd_entry = NULL; - U32 dma_addr_alignment = 0; - U32 dma_len_alignment = 0; - U8 dev_type = PS3_DISK_TYPE_UNKNOWN; - struct PS3DiskDevPos* p_diskPos = NULL; + unsigned int dma_addr_alignment = 0; + unsigned int dma_len_alignment = 0; + unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; + struct PS3DiskDevPos *p_diskPos = NULL; - LOG_DEBUG("enter, [%u:%u:%llu]\n", - sdev->channel, sdev->id, (U64)sdev->lun); + LOG_DEBUG("enter, [%u:%u:%llu]\n", sdev->channel, sdev->id, + (unsigned long long)sdev->lun); INJECT_START(PS3_ERR_IJ_FORCE_LUN_ERROR, &sdev->lun); if (sdev->lun != 0) { ret = -ENXIO; goto l_out; } - instance = (struct ps3_instance*)sdev->host->hostdata; + instance = (struct ps3_instance *)sdev->host->hostdata; INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL, &instance); if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n", - sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); ret = -ENXIO; goto l_out; } sdev->hostdata = NULL; - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, + PS3_ERR_IJ_FORCE_WAIT, sdev); ret = -ENXIO; if (PS3_IS_VD_CHANNEL(instance, sdev->channel)) { dev_type = PS3_DISK_TYPE_VD; p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, - sdev->id); + sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL, &p_vd_entry); if (p_vd_entry == NULL) { - LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", + LOG_ERROR( + "hno:%u, cannot found VD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; @@ -1743,10 +1876,11 @@ S32 ps3_scsi_slave_alloc(struct scsi_device *sdev) } else if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { dev_type = PS3_DISK_TYPE_PD; p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, - sdev->id); + sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL, &p_pd_entry); if (p_pd_entry == NULL) { - LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", + LOG_ERROR( + "hno:%u, cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); goto l_out; @@ -1755,78 +1889,84 @@ S32 ps3_scsi_slave_alloc(struct scsi_device *sdev) p_diskPos = &p_pd_entry->disk_pos; } else { LOG_ERROR("hno:%u dev channel[%u] type NOK\n", - PS3_HOST(instance), sdev->channel); + PS3_HOST(instance), sdev->channel); goto l_out; } - if (dev_type == PS3_DISK_TYPE_VD) { + if (dev_type == PS3_DISK_TYPE_VD) ret = ps3_scsi_private_init_vd(sdev); - } else { + else ret = ps3_scsi_private_init_pd(sdev); - } - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_dev_done; - } - p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, NULL); - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, NULL); - ret = ps3_scsi_add_device_ack(instance, p_diskPos, - dev_type); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, + PS3_ERR_IJ_FORCE_WAIT, NULL); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, + PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, + NULL); + ret = ps3_scsi_add_device_ack(instance, p_diskPos, dev_type); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL3, &ret); if (unlikely(ret != PS3_SUCCESS)) { ret = -ENXIO; goto l_dev_ack_failed; } - LOG_INFO("[%u:%u:%llu], dev_type[%s]\n", - sdev->channel, sdev->id, (U64)sdev->lun, - namePS3DevType((enum PS3DevType)p_priv_data->dev_type)); + LOG_INFO("[%u:%u:%llu], dev_type[%s]\n", sdev->channel, sdev->id, + (unsigned long long)sdev->lun, + namePS3DevType((enum PS3DevType)p_priv_data->dev_type)); - if (p_priv_data->task_abort_timeout == 0) { + if (p_priv_data->task_abort_timeout == 0) p_priv_data->task_abort_timeout = PS3_DEFAULT_TASK_MGR_TIMEOUT; - } - if (p_priv_data->task_reset_timeout == 0) { + if (p_priv_data->task_reset_timeout == 0) p_priv_data->task_reset_timeout = PS3_DEFAULT_TASK_MGR_TIMEOUT; - } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +#if defined(PS3_CHANGE_QUEUE_DEPTH) sdev->tagged_supported = 1; scsi_activate_tcq(sdev, sdev->queue_depth); #endif if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { - dma_addr_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaAddrAlignShift); - dma_len_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); + dma_addr_alignment = ps3_pd_dma_alignment_calc( + p_vd_entry->dmaAddrAlignShift); + dma_len_alignment = + ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); } else { dma_addr_alignment = p_pd_entry->dma_addr_alignment; dma_len_alignment = p_pd_entry->dma_len_alignment; } - blk_queue_dma_alignment(sdev->request_queue, PS3_SCSI_ALINNMENT_MASK); - if(dma_addr_alignment){ - blk_queue_dma_alignment(sdev->request_queue, dma_addr_alignment - 1); + PS3_SDEV_Q_DMA_ALIGN(sdev->request_queue, PS3_SCSI_ALINNMENT_MASK); + if (dma_addr_alignment) { + PS3_SDEV_Q_DMA_ALIGN(sdev->request_queue, dma_addr_alignment - 1); } - if(dma_len_alignment){ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) + if (dma_len_alignment) { +#if defined(PS3_BLK_DMA_PAD) blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + blk_queue_update_dma_pad(sdev->request_queue, + dma_len_alignment - 1); +#else + sdev->request_queue->limits.dma_pad_mask = + dma_len_alignment - 1; +#endif #endif - } LOG_INFO("slave_alloc,dma_addr_alignment[%d] dma_len_alignment[%d]\n", - dma_addr_alignment, dma_len_alignment); + dma_addr_alignment, dma_len_alignment); goto l_out; l_dev_ack_failed: ps3_scsi_slave_destroy(sdev); - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, PS3_ERR_IJ_FORCE_WAIT, sdev); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, + PS3_ERR_IJ_FORCE_WAIT, sdev); l_dev_done: ps3_scsi_remove_device_done(instance, p_diskPos, dev_type); l_out: @@ -1836,48 +1976,53 @@ S32 ps3_scsi_slave_alloc(struct scsi_device *sdev) void ps3_scsi_slave_destroy(struct scsi_device *sdev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; - struct ps3_pri_data_table *p_vd_pri_data_table = &instance->dev_context.vd_pri_data_table; + (struct ps3_instance *)sdev->host->hostdata; + struct ps3_pri_data_table *p_vd_pri_data_table = + &instance->dev_context.vd_pri_data_table; INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL2, &instance); if (instance == NULL) { - LOG_ERROR("hno:%u have no host\n",sdev->host->host_no); + LOG_ERROR("hno:%u have no host\n", sdev->host->host_no); goto l_out; } LOG_DEBUG("hno:%u enter, max_chan[%u], max_id[%u], max_lun[%llu]\n", - PS3_HOST(instance), sdev->host->max_channel, - sdev->host->max_id, (U64)sdev->host->max_lun); + PS3_HOST(instance), sdev->host->max_channel, + sdev->host->max_id, (unsigned long long)sdev->host->max_lun); - p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; if (p_priv_data != NULL) { if (PS3_IS_VD_CHANNEL(instance, sdev->channel)) { - LOG_INFO("hno[%u], vd[%u:%u] r1x conflict destory\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + LOG_INFO("hno[%u], vd[%u:%u] r1x conflict destroy\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); INJECT_AT_TIMES(PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - ps3_r1x_lock_destory_for_vd(instance, &p_priv_data->lock_mgr); - ps3_qos_vd_reset(instance, PS3_VDID(&p_priv_data->disk_pos)); - p_vd_pri_data_table->vd_pri_data_idxs - [PS3_SDEV_CHANNEL(sdev)] - [PS3_SDEV_TARGET(sdev)] = NULL; + ps3_r1x_lock_destroy_for_vd(instance, + &p_priv_data->lock_mgr); + ps3_qos_vd_reset(instance, + PS3_VDID(&p_priv_data->disk_pos)); + p_vd_pri_data_table->vd_pri_data_idxs[PS3_SDEV_CHANNEL( + sdev)][PS3_SDEV_TARGET(sdev)] = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); if (p_priv_data->r1x_rb_info != NULL) { ps3_kfree(instance, p_priv_data->r1x_rb_info); p_priv_data->r1x_rb_info = NULL; } } else if (PS3_IS_PD_CHANNEL(instance, sdev->channel)) { - ps3_qos_pd_mgr_reset(instance, PS3_PDID(&p_priv_data->disk_pos)); + ps3_qos_pd_mgr_reset(instance, + PS3_PDID(&p_priv_data->disk_pos)); } - ret = ps3_scsi_remove_device_done(instance, &p_priv_data->disk_pos, - ps3_disk_type((enum PS3DevType) p_priv_data->dev_type)); + ret = ps3_scsi_remove_device_done( + instance, &p_priv_data->disk_pos, + ps3_disk_type((enum PS3DevType)p_priv_data->dev_type)); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL5, &ret); if (ret != PS3_SUCCESS) { - LOG_INFO("hno:%u dev[%u:%u:%u] magic[%#x] dev del done error %d\n", + LOG_INFO( + "hno:%u dev[%u:%u:%u] magic[%#x] dev del done error %d\n", PS3_HOST(instance), PS3_CHANNEL(&p_priv_data->disk_pos), PS3_TARGET(&p_priv_data->disk_pos), @@ -1885,9 +2030,8 @@ void ps3_scsi_slave_destroy(struct scsi_device *sdev) p_priv_data->disk_pos.diskMagicNum, ret); } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - if(sdev->hostdata != NULL) { + if (sdev->hostdata != NULL) ps3_kfree(instance, sdev->hostdata); - } sdev->hostdata = NULL; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } @@ -1896,10 +2040,12 @@ void ps3_scsi_slave_destroy(struct scsi_device *sdev) LOG_DEBUG("exit, hno:%u\n", sdev->host->host_no); } -static Bool ps3_is_nvme_device(struct ps3_instance *instance, U8 dev_type, - U8 channel, U16 target_id) +static unsigned char ps3_is_nvme_device(struct ps3_instance *instance, + unsigned char dev_type, + unsigned char channel, + unsigned short target_id) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; struct PS3VDEntry *vd_entry = NULL; if (dev_type == PS3_DEV_TYPE_NVME_SSD) { @@ -1908,10 +2054,11 @@ static Bool ps3_is_nvme_device(struct ps3_instance *instance, U8 dev_type, } if (dev_type == PS3_DEV_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, + target_id); if (vd_entry == NULL) { LOG_ERROR("hno:%u cannot found VD[%u:%u] device\n", - PS3_HOST(instance), channel, target_id); + PS3_HOST(instance), channel, target_id); ret = PS3_FALSE; goto l_out; } @@ -1927,141 +2074,189 @@ static Bool ps3_is_nvme_device(struct ps3_instance *instance, U8 dev_type, return ret; } +#if defined(PS3_SLAVE_CONFIG_SUPPORT) static void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev) + struct scsi_device *sdev) +#else +static void ps3_nvme_attr_set(const struct ps3_instance *instance, + struct scsi_device *sdev, struct queue_limits *lim) +#endif { - U32 page_size = instance->cmd_attr.nvme_page_size; - U32 align_mask = (page_size == 0) ? page_size : (page_size- 1); + unsigned int page_size = instance->cmd_attr.nvme_page_size; + unsigned int align_mask = + (page_size == 0) ? page_size : (page_size - 1); LOG_INFO("nvme page size is %u\n", page_size); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,16,0) +#if defined(PS3_BLK_EH_NOT_HANDLED) queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, sdev->request_queue); #else blk_queue_flag_set(QUEUE_FLAG_NOMERGES, sdev->request_queue); #endif +#if defined(PS3_SLAVE_CONFIG_SUPPORT) blk_queue_virt_boundary(sdev->request_queue, align_mask); +#else + lim->virt_boundary_mask = align_mask; +#endif } +#if defined(PS3_SLAVE_CONFIG_SUPPORT) static inline void ps3_nvme_pd_attr_set(struct scsi_device *sdev, const struct ps3_pd_entry *p_pd_entry) +#else +static inline void ps3_nvme_pd_attr_set(struct scsi_device *sdev, + const struct ps3_pd_entry *p_pd_entry, struct queue_limits *lim) +#endif { - struct ps3_instance *instance = (struct ps3_instance *)sdev->host->hostdata; - U32 sector_count = 0; + struct ps3_instance *instance = + (struct ps3_instance *)sdev->host->hostdata; + unsigned int sector_count = 0; if (p_pd_entry->max_io_size != 0 && p_pd_entry->sector_size != 0) { sector_count = p_pd_entry->max_io_size >> PS3_512B_SHIFT; +#if defined(PS3_SLAVE_CONFIG_SUPPORT) blk_queue_max_hw_sectors(sdev->request_queue, sector_count); +#else + lim->max_hw_sectors = sector_count; +#endif } - LOG_INFO("nvme attr max_io_size[%u], sector_size[%u], sector_count[%u]\n", + LOG_INFO("nvme max_io_size[%u], sector_size[%u], sector_count[%u]\n", p_pd_entry->max_io_size, p_pd_entry->sector_size, sector_count); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) ps3_nvme_attr_set(instance, sdev); +#else + ps3_nvme_attr_set(instance, sdev, lim); +#endif } -static inline void ps3_set_queue_depth(struct scsi_device *sdev, U8 dev_type, - U32 queue_depth) +static inline void ps3_set_queue_depth(struct scsi_device *sdev, + unsigned char dev_type, unsigned int queue_depth) { - S32 dev_queue_depth = queue_depth; - struct ps3_instance *instance = (struct ps3_instance *)sdev->host->hostdata; + int dev_queue_depth = queue_depth; + struct ps3_instance *instance = + (struct ps3_instance *)sdev->host->hostdata; - dev_queue_depth = ps3_adjust_queue_depth(instance, dev_type, queue_depth); + dev_queue_depth = + ps3_adjust_queue_depth(instance, dev_type, queue_depth); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +#if defined(PS3_CHANGE_QUEUE_DEPTH) scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), dev_queue_depth); #else scsi_change_queue_depth(sdev, dev_queue_depth); #endif } -void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, struct scsi_device *sdev) +#if defined(PS3_SLAVE_CONFIG_SUPPORT) +void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, + struct scsi_device *sdev) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) +#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) (void)instance; - blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, - sdev->request_queue); + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, sdev->request_queue); #else - #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) - sdev->request_queue->backing_dev_info.capabilities - |= BDI_CAP_STABLE_WRITES; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info.capabilities); - #else - sdev->request_queue->backing_dev_info->capabilities - |= BDI_CAP_STABLE_WRITES; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info->capabilities); - #endif +#if defined(PS3_BACK_DEV_INFO) + sdev->request_queue->backing_dev_info.capabilities |= + BDI_CAP_STABLE_WRITES; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); +#else + sdev->request_queue->backing_dev_info->capabilities |= + BDI_CAP_STABLE_WRITES; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(instance), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); +#endif #endif } -S32 ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev) +int ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) +#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) return blk_queue_stable_writes(sdev->request_queue); #else - #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) - return ((sdev->request_queue->backing_dev_info.capabilities & \ - BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); - #else - return ((sdev->request_queue->backing_dev_info->capabilities & \ - BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); - #endif +#if defined(PS3_BACK_DEV_INFO) + return ((sdev->request_queue->backing_dev_info.capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); +#else + return ((sdev->request_queue->backing_dev_info->capabilities & + BDI_CAP_STABLE_WRITES) == BDI_CAP_STABLE_WRITES); +#endif #endif } -void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, struct scsi_device *sdev) +void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *ins, + struct scsi_device *sdev) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) - (void)instance; - blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, - sdev->request_queue); +#if defined(PS3_BLK_QUEUE_FLAG_CLEAR) + (void)ins; + blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, sdev->request_queue); #else - #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) - sdev->request_queue->backing_dev_info.capabilities - &= ~BDI_CAP_STABLE_WRITES;; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info.capabilities); - #else - sdev->request_queue->backing_dev_info->capabilities - &= ~BDI_CAP_STABLE_WRITES;; - LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", - PS3_HOST(instance), sdev->channel, sdev->id, - sdev->request_queue->backing_dev_info->capabilities); - #endif +#if defined(PS3_BACK_DEV_INFO) + sdev->request_queue->backing_dev_info.capabilities &= + ~BDI_CAP_STABLE_WRITES; + ; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(ins), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info.capabilities); +#else + sdev->request_queue->backing_dev_info->capabilities &= + ~BDI_CAP_STABLE_WRITES; + ; + LOG_INFO("hno:%u, dev type[%u:%u] capabilities[0x%x]\n", + PS3_HOST(ins), sdev->channel, sdev->id, + sdev->request_queue->backing_dev_info->capabilities); #endif +#endif +} + +static inline void ps3_stable_writes_set(struct ps3_instance *instance, + struct scsi_device *sdev, struct queue_limits *lim) +{ + (void)lim; + ps3_sdev_bdi_stable_writes_set(instance, sdev); +} +#else +static inline void ps3_stable_writes_set(struct ps3_instance *instance, + struct scsi_device *sdev, struct queue_limits *lim) +{ + (void)sdev; + if (lim != NULL) + lim->features |= BLK_FEAT_STABLE_WRITES; } +#endif -S32 ps3_scsi_slave_configure(struct scsi_device *sdev) +#if defined(PS3_SLAVE_CONFIG_SUPPORT) +int ps3_scsi_slave_configure(struct scsi_device *sdev) +#else +int ps3_scsi_slave_configure(struct scsi_device *sdev, struct queue_limits *lim) +#endif { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; - U32 queue_depth = 0; - U32 dma_addr_alignment = 0; - U32 dma_len_alignment = 0; - U8 io_tmo = PS3_SCSI_CMD_TIMEOUT_DEFAULT; + unsigned int queue_depth = 0; + unsigned int dma_addr_alignment = 0; + unsigned int dma_len_alignment = 0; + unsigned char io_tmo = PS3_SCSI_CMD_TIMEOUT_DEFAULT; + unsigned int max_hw_sectors = 0; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; + (struct ps3_instance *)sdev->host->hostdata; INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_NULL1, &instance); if (unlikely(instance == NULL)) { LOG_ERROR("hno:%u slave configure have no host instance\n", - sdev->host->host_no); + sdev->host->host_no); PS3_BUG(); ret = -ENXIO; goto l_out; } - p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; INJECT_START(PS3_ERR_IJ_FORCE_PRIV_DATA_NULL1, &p_priv_data); if (unlikely(p_priv_data == NULL)) { - LOG_ERROR("hno:%u, slave configure have no private data, [%u:%u]\n", + LOG_ERROR( + "hno:%u, slave configure have no private data, [%u:%u]\n", PS3_HOST(instance), sdev->channel, sdev->id); PS3_BUG(); ret = -ENXIO; @@ -2070,33 +2265,40 @@ S32 ps3_scsi_slave_configure(struct scsi_device *sdev) INJECT_START(PS3_ERR_IJ_FORCE_MOD_DEV_TYPE, &p_priv_data->dev_type); if (unlikely(p_priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN)) { LOG_ERROR("hno:%u, dev type[%u:%u] is PS3_DEV_TYPE_UNKNOWN\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, sdev->channel, - sdev->id); + sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL2, &p_vd_entry); if (p_vd_entry == NULL) { - LOG_ERROR("hno:%u, cannot found VD[%u:%u] device info\n", + LOG_ERROR( + "hno:%u, cannot found VD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; } queue_depth = p_vd_entry->devQueDepth; - dma_addr_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaAddrAlignShift); - dma_len_alignment = ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); - if (p_vd_entry->bdev_bdi_cap & PS3_STABLE_WRITES_MASK) { - ps3_sdev_bdi_stable_writes_set(instance, sdev); - } + dma_addr_alignment = ps3_pd_dma_alignment_calc( + p_vd_entry->dmaAddrAlignShift); + dma_len_alignment = + ps3_pd_dma_alignment_calc(p_vd_entry->dmaLenAlignShift); + if (p_vd_entry->bdev_bdi_cap & PS3_STABLE_WRITES_MASK) +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + ps3_stable_writes_set(instance, sdev, NULL); +#else + ps3_stable_writes_set(instance, sdev, lim); +#endif } else { p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, sdev->channel, - sdev->id); + sdev->id); INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL2, &p_pd_entry); if (p_pd_entry == NULL) { - LOG_ERROR("hno:%u, cannot found PD[%u:%u] device info\n", + LOG_ERROR( + "hno:%u, cannot found PD[%u:%u] device info\n", PS3_HOST(instance), sdev->channel, sdev->id); ret = -ENXIO; goto l_out; @@ -2106,28 +2308,38 @@ S32 ps3_scsi_slave_configure(struct scsi_device *sdev) dma_len_alignment = p_pd_entry->dma_len_alignment; } +#if defined(PS3_SLAVE_CONFIG_SUPPORT) blk_queue_dma_alignment(sdev->request_queue, PS3_SCSI_ALINNMENT_MASK); - if(dma_addr_alignment){ - blk_queue_dma_alignment(sdev->request_queue, dma_addr_alignment - 1); - } + if (dma_addr_alignment) + blk_queue_dma_alignment(sdev->request_queue, + dma_addr_alignment - 1); +#else + lim->dma_alignment = PS3_SCSI_ALINNMENT_MASK; + if (dma_addr_alignment) + lim->dma_alignment = dma_addr_alignment - 1; - if(dma_len_alignment){ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#endif + + if (dma_len_alignment) { +#if defined(PS3_BLK_DMA_PAD) blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + blk_queue_update_dma_pad(sdev->request_queue, + dma_len_alignment - 1); +#else + lim->dma_pad_mask = dma_len_alignment - 1; +#endif #endif } - if (instance->ctrl_info.ioTimeOut != 0) { + if (instance->ctrl_info.ioTimeOut != 0) io_tmo = instance->ctrl_info.ioTimeOut; - } - if (ps3_scsi_cmd_timeout_query() != 0) { + if (ps3_scsi_cmd_timeout_query() != 0) io_tmo = ps3_scsi_cmd_timeout_query(); - } - LOG_INFO("slave_configure, dma_addr_alignment[%d], " - "dma_len_alignment[%d], io_timeout[%u], queue_depth[%u]\n", - dma_addr_alignment, dma_len_alignment, io_tmo, queue_depth); + LOG_INFO("slave_configure, dma_addr_alignment[%d]\n" + "\tdma_len_alignment[%d], io_timeout[%u], queue_depth[%u]\n", + dma_addr_alignment, dma_len_alignment, io_tmo, queue_depth); blk_queue_rq_timeout(sdev->request_queue, io_tmo * HZ); @@ -2135,33 +2347,57 @@ S32 ps3_scsi_slave_configure(struct scsi_device *sdev) if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { if (p_vd_entry->maxIOSize != 0) { - if (p_vd_entry->sectorSize == PS3_SECTORSIZE_512B) { - blk_queue_max_hw_sectors(sdev->request_queue, p_vd_entry->maxIOSize); - } else { - blk_queue_max_hw_sectors(sdev->request_queue, - p_vd_entry->maxIOSize << (ilog2(p_vd_entry->sectorSize) - PS3_512B_SHIFT)); - } + max_hw_sectors = ps3_vd_max_sectors_get(p_vd_entry); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + blk_queue_max_hw_sectors(sdev->request_queue, + max_hw_sectors); +#else + lim->max_hw_sectors = max_hw_sectors; +#endif } else { - LOG_DEBUG("hno:%u vd[%u:%u] update max sector num is:0\n", + LOG_DEBUG( + "hno:%u vd[%u:%u] update max sector num is:0\n", PS3_HOST(instance), sdev->channel, sdev->id); } if (ps3_is_nvme_device(instance, p_priv_data->dev_type, sdev->channel, sdev->id)) { +#if defined(PS3_SLAVE_CONFIG_SUPPORT) ps3_nvme_attr_set(instance, sdev); +#else + ps3_nvme_attr_set(instance, sdev, lim); +#endif } else { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) - blk_queue_dma_pad(sdev->request_queue, dma_len_alignment - 1); +#if defined(PS3_BLK_DMA_PAD) + blk_queue_dma_pad(sdev->request_queue, + dma_len_alignment - 1); #else - blk_queue_update_dma_pad(sdev->request_queue, dma_len_alignment - 1); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) + blk_queue_update_dma_pad(sdev->request_queue, + dma_len_alignment - 1); +#else + lim->dma_pad_mask = dma_len_alignment - 1; +#endif #endif } } else if (p_pd_entry != NULL) { if (p_priv_data->dev_type == PS3_DEV_TYPE_NVME_SSD) { +#if defined(PS3_SLAVE_CONFIG_SUPPORT) ps3_nvme_pd_attr_set(sdev, p_pd_entry); +#else + ps3_nvme_pd_attr_set(sdev, p_pd_entry, lim); +#endif + } else if (PS3_IS_HAC_LIMIT_TYPE(p_priv_data->dev_type)) { - if (p_pd_entry->max_io_size != 0 && p_pd_entry->sector_size != 0) { + if (p_pd_entry->max_io_size != 0 && + p_pd_entry->sector_size != 0) { + max_hw_sectors = + ps3_pd_max_sectors_get(p_pd_entry); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) blk_queue_max_hw_sectors(sdev->request_queue, - p_pd_entry->max_io_size >> PS3_512B_SHIFT); + max_hw_sectors); +#else + lim->max_hw_sectors = max_hw_sectors; +#endif } } } @@ -2169,16 +2405,18 @@ S32 ps3_scsi_slave_configure(struct scsi_device *sdev) if (ps3_sas_is_support_smp(instance) && p_pd_entry != NULL) { if (ps3_check_pd_is_vd_member(p_pd_entry->config_flag)) { LOG_DEBUG("hno:%u, PD[%u:%u] is belong to vd device\n", - PS3_HOST(instance), sdev->channel, sdev->id); + PS3_HOST(instance), sdev->channel, sdev->id); sdev->no_uld_attach = 1; } if (p_priv_data->dev_type == PS3_DEV_TYPE_SAS_HDD || - p_priv_data->dev_type == PS3_DEV_TYPE_SAS_SSD || - p_priv_data->dev_type == PS3_DEV_TYPE_SES) { - LOG_DEBUG("hno:%u pd[%u:%u] dev_type[%s] ready read port mode page\n", + p_priv_data->dev_type == PS3_DEV_TYPE_SAS_SSD || + p_priv_data->dev_type == PS3_DEV_TYPE_SES) { + LOG_DEBUG( + "hno:%u pd[%u:%u] dev_type[%s] rd mode page\n", PS3_HOST(instance), sdev->channel, sdev->id, - namePS3DevType((enum PS3DevType)p_pd_entry->dev_type)); + namePS3DevType( + (enum PS3DevType)p_pd_entry->dev_type)); sas_read_port_mode_page(sdev); } } @@ -2186,11 +2424,106 @@ S32 ps3_scsi_slave_configure(struct scsi_device *sdev) l_out: return ret; } -#else -void ps3_nvme_attr_set(const struct ps3_instance *instance, - struct scsi_device *sdev) +#ifdef PS3_NCQ_PRIO_SUPPORT +ssize_t ps3_dev_ncq_prio_enable_stor(struct device *dev, const char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct ps3_scsi_priv_data *priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + int ncq_prio_enable = 0; + + if (sscanf(buf, "%d", &ncq_prio_enable) != 1) + return -EINVAL; + + if (!priv_data->ncq_prio_support) + return -EINVAL; + + priv_data->ncq_prio_enable = ncq_prio_enable; + + return strlen(buf); +} +#endif + +static inline unsigned int ps3_vd_max_sectors_get(const struct PS3VDEntry *p_entry) { + unsigned int max_hw_sectors = 0; + + if ((p_entry == NULL) || (p_entry->maxIOSize == 0)) + goto l_out; + + if (p_entry->sectorSize == PS3_SECTORSIZE_512B) + max_hw_sectors = p_entry->maxIOSize; + else + max_hw_sectors = p_entry->maxIOSize << + (ilog2(p_entry->sectorSize) - PS3_512B_SHIFT); +l_out: + return max_hw_sectors; +} + +static inline unsigned int ps3_pd_max_sectors_get(const struct ps3_pd_entry *p_entry) +{ + unsigned int max_hw_sectors = 0; + + if ((p_entry == NULL) || (p_entry->max_io_size == 0) || + (p_entry->sector_size == 0)) + goto l_out; + + max_hw_sectors = p_entry->max_io_size >> PS3_512B_SHIFT; +l_out: + return max_hw_sectors; +} + +void ps3_update_max_sectors(struct ps3_instance *instance, + unsigned char channel, unsigned short target, struct scsi_device *sdev) +{ +#if defined(PS3_SLAVE_CONFIG_SUPPORT) (void)instance; + (void)channel; + (void)target; (void)sdev; -} +#else + struct ps3_pd_entry *p_pd_entry = NULL; + struct PS3VDEntry *p_vd_entry = NULL; + unsigned int max_hw_sectors = 0; + struct queue_limits lim; + + if (PS3_IS_VD_CHANNEL(instance, channel)) { + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, + channel, target); + INJECT_START(PS3_ERR_IJ_FORCE_VD_ENTRY_NULL, &p_vd_entry); + if (p_vd_entry == NULL) { + LOG_INFO("hno:%u, not found VD[%u:%u] info\n", + PS3_HOST(instance), channel, target); + goto l_out; + } + + max_hw_sectors = ps3_vd_max_sectors_get(p_vd_entry); + + } else if (PS3_IS_PD_CHANNEL(instance, channel)) { + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, + channel, target); + INJECT_START(PS3_ERR_IJ_FORCE_PD_ENTRY_NULL, &p_vd_entry); + if (p_pd_entry == NULL) { + LOG_INFO("hno:%u, not found PD[%u:%u] info\n", + PS3_HOST(instance), channel, target); + goto l_out; + } + + max_hw_sectors = ps3_pd_max_sectors_get(p_pd_entry); + } + + if (max_hw_sectors == 0) + goto l_out; + + lim = queue_limits_start_update(sdev->request_queue); + if (lim.max_hw_sectors == max_hw_sectors) { + queue_limits_cancel_update(sdev->request_queue); + goto l_out; + } else + lim.max_hw_sectors = max_hw_sectors; + + (void)queue_limits_commit_update(sdev->request_queue, &lim); + +l_out: #endif + return; +} \ No newline at end of file diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h index d40e9225a51b..4960067f3d9c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_DEVICE_MANAGER_H_ #define _PS3_DEVICE_MANAGER_H_ @@ -13,63 +13,52 @@ #endif -#include "ps3_meta.h" -#include "ps3_dev_type.h" +#include "ps3_htp_meta.h" +#include "ps3_htp_dev_info.h" #include "ps3_htp.h" #include "ps3_err_def.h" - -#define PS3_QUEUE_DEPTH_DEFAULT (256) -#define PS3_QUEUE_DEPTH_SATA (32) -#define PS3_QUEUE_DEPTH_SAS (64) -#define PS3_QUEUE_DEPTH_NVME (32) - -#define PS3_INVALID_VALUE (0) -#define PS3_INVALID_DEV_ID (0) -#define PS3_INVALID_LIST_ID (0) -#define PS3_DMA_ALIGN_SHIFT_MAX (15) - -#define PS3_VD_TABLE_NUM (2) -#define PS3_SCSI_4B_ALINNMENT_MASK (4) -#define PS3_SCSI_ALINNMENT_MASK (0x3) -#define PS3_SCSI_32B_ALINNMENT_MASK (0x1f) -#define PS3_SCSI_512B_ALINNMENT_MASK (0x000001FF) -#define PS3_SCSI_4K_ALINNMENT_MASK (0xFFF) -#define PS3_512B_SHIFT (9) -#define PS3_SECTORSIZE_512B (512) - -#define PS3_MAX_VD_COUNT(instance) \ - ((instance)->ctrl_info.maxVdCount) -#define PS3_MAX_PD_COUNT(instance) \ - ((instance)->ctrl_info.maxPdCount) - -#define PS3_CHANNEL(pos) \ - ((U8)((pos)->diskDev.ps3Dev.softChan)) -#define PS3_TARGET(pos) \ - ((U16)((pos)->diskDev.ps3Dev.devID)) -#define PS3_DISKID(pos) \ - ((pos)->diskDev.diskID) -#define PS3_PDID(pos) \ - ((pos)->diskDev.ps3Dev.phyDiskID) -#define PS3_VDID(pos) \ - ((pos)->diskDev.ps3Dev.virtDiskID) -#define PS3_DEV(pos) \ - ((struct PS3Dev*)(&(pos)->diskDev.ps3Dev)) -#define PS3_VDID_OFFSET(instance) \ - ((instance)->ctrl_info.offsetOfVDID) - -#define PS3_DEV_INVALID(pos) \ - ((pos).diskDev.diskID == PS3_INVALID_DEV_ID) -#define PS3_PDID_INVALID(pos) \ - (PS3_PDID(pos) == PS3_INVALID_DEV_ID) -#define PS3_VDID_INVALID(pos) \ - (PS3_VDID(pos) == PS3_INVALID_DEV_ID) -#define PS3_IS_VD_CHANNEL(ins, chan) \ - ((ins->dev_context.vd_table[0].vd_idxs[chan] != NULL) ? \ - PS3_DRV_TRUE : PS3_DRV_FALSE) - -#define PS3_IS_PD_CHANNEL(ins, chan) \ - ((ins->dev_context.pd_table.pd_idxs[chan] != NULL) ? \ - PS3_DRV_TRUE : PS3_DRV_FALSE) +#include "ps3_kernel_version.h" + +#define PS3_QUEUE_DEPTH_DEFAULT (256) +#define PS3_QUEUE_DEPTH_SATA (32) +#define PS3_QUEUE_DEPTH_SAS (64) +#define PS3_QUEUE_DEPTH_NVME (32) + +#define PS3_INVALID_VALUE (0) +#define PS3_INVALID_DEV_ID (0) +#define PS3_INVALID_LIST_ID (0) +#define PS3_DMA_ALIGN_SHIFT_MAX (15) + +#define PS3_VD_TABLE_NUM (2) +#define PS3_SCSI_4B_ALINNMENT_MASK (4) +#define PS3_SCSI_ALINNMENT_MASK (0x3) +#define PS3_SCSI_32B_ALINNMENT_MASK (0x1f) +#define PS3_SCSI_512B_ALINNMENT_MASK (0x000001FF) +#define PS3_SCSI_4K_ALINNMENT_MASK (0xFFF) +#define PS3_512B_SHIFT (9) +#define PS3_SECTORSIZE_512B (512) + +#define PS3_MAX_VD_COUNT(instance) ((instance)->ctrl_info.maxVdCount) +#define PS3_MAX_PD_COUNT(instance) ((instance)->ctrl_info.maxPdCount) + +#define PS3_CHANNEL(pos) ((unsigned char)((pos)->diskDev.ps3Dev.softChan)) +#define PS3_TARGET(pos) ((unsigned short)((pos)->diskDev.ps3Dev.devID)) +#define PS3_DISKID(pos) ((pos)->diskDev.diskID) +#define PS3_PDID(pos) ((pos)->diskDev.ps3Dev.phyDiskID) +#define PS3_VDID(pos) ((pos)->diskDev.ps3Dev.virtDiskID) +#define PS3_DEV(pos) ((struct PS3Dev *)(&(pos)->diskDev.ps3Dev)) +#define PS3_VDID_OFFSET(instance) ((instance)->ctrl_info.offsetOfVDID) + +#define PS3_DEV_INVALID(pos) ((pos).diskDev.diskID == PS3_INVALID_DEV_ID) +#define PS3_PDID_INVALID(pos) (PS3_PDID(pos) == PS3_INVALID_DEV_ID) +#define PS3_VDID_INVALID(pos) (PS3_VDID(pos) == PS3_INVALID_DEV_ID) +#define PS3_IS_VD_CHANNEL(ins, chan) \ + ((ins->dev_context.vd_table[0].vd_idxs[chan] != NULL) ? PS3_DRV_TRUE : \ + PS3_DRV_FALSE) + +#define PS3_IS_PD_CHANNEL(ins, chan) \ + ((ins->dev_context.pd_table.pd_idxs[chan] != NULL) ? PS3_DRV_TRUE : \ + PS3_DRV_FALSE) #define PS3_MAX_PD_NUM_ONE_VD (PS3_MAX_PD_COUNT_IN_SPAN * PS3_MAX_SPAN_IN_VD) @@ -83,57 +72,55 @@ struct ps3_instance; #define ZERO_LAST_STREAM (0x0FFFFFFFFFFFFFFF) #define MAX_QUE_DEPTH (16) -#define TEST_IO_BLOCK_SIZE (8) -#define IO_STREAM_DETECT_RANGE (MAX_QUE_DEPTH * TEST_IO_BLOCK_SIZE) -#define PS3_IS_HAC_LIMIT_TYPE(type) \ - ((type) == PS3_DEV_TYPE_SAS_HDD || \ - (type) == PS3_DEV_TYPE_SATA_HDD || \ - (type) == PS3_DEV_TYPE_SATA_SSD || \ - (type) == PS3_DEV_TYPE_SAS_SSD || \ - (type) == PS3_DEV_TYPE_SES) +#define TEST_IO_BLOCK_SIZE (8) +#define IO_STREAM_DETECT_RANGE (MAX_QUE_DEPTH * TEST_IO_BLOCK_SIZE) +#define PS3_IS_HAC_LIMIT_TYPE(type) \ + ((type) == PS3_DEV_TYPE_SAS_HDD || (type) == PS3_DEV_TYPE_SATA_HDD || \ + (type) == PS3_DEV_TYPE_SATA_SSD || (type) == PS3_DEV_TYPE_SAS_SSD || \ + (type) == PS3_DEV_TYPE_SES) struct ps3_stream_detect { - U64 next_seq_lba; - U8 rw_type; - U8 reserved[7]; + unsigned long long next_seq_lba; + unsigned char rw_type; + unsigned char reserved[7]; }; struct ps3_vd_stream_detect { - ps3_spinlock ps3_sequence_stream_lock; - U64 mru_bit_map; - struct ps3_stream_detect stream_track[PS3_IO_MAX_STREAMS_TRACKED]; + spinlock_t ps3_sequence_stream_lock; + unsigned long long mru_bit_map; + struct ps3_stream_detect stream_track[PS3_IO_MAX_STREAMS_TRACKED]; }; enum PS3DevType { - PS3_DEV_TYPE_UNKNOWN = 0, - PS3_DEV_TYPE_VD = 1, - PS3_DEV_TYPE_SAS_HDD = 2, - PS3_DEV_TYPE_SATA_HDD = 3, - PS3_DEV_TYPE_SATA_SSD = 4, - PS3_DEV_TYPE_SAS_SSD = 5, - PS3_DEV_TYPE_NVME_SSD = 6, - PS3_DEV_TYPE_SES = 7, - PS3_DEV_TYPE_VEP = 8, + PS3_DEV_TYPE_UNKNOWN = 0, + PS3_DEV_TYPE_VD = 1, + PS3_DEV_TYPE_SAS_HDD = 2, + PS3_DEV_TYPE_SATA_HDD = 3, + PS3_DEV_TYPE_SATA_SSD = 4, + PS3_DEV_TYPE_SAS_SSD = 5, + PS3_DEV_TYPE_NVME_SSD = 6, + PS3_DEV_TYPE_SES = 7, + PS3_DEV_TYPE_VEP = 8, PS3_DEV_TYPE_COUNT, }; enum PS3DevTypeV1 { - PS3_DEV_TYPE_SAS_SATA = 0, - PS3_DEV_TYPE_NVME = 1, + PS3_DEV_TYPE_SAS_SATA = 0, + PS3_DEV_TYPE_NVME = 1, }; -static inline const S8 *namePS3DevType(enum PS3DevType e) +static inline const char *namePS3DevType(enum PS3DevType e) { - static const S8 *myNames[] = { - [PS3_DEV_TYPE_UNKNOWN] = "DEV_T_UNKNOWN", - [PS3_DEV_TYPE_VD] = "DEV_T_VD", - [PS3_DEV_TYPE_SAS_HDD] = "DEV_T_SAS_HDD", - [PS3_DEV_TYPE_SATA_HDD] = "DEV_T_SATA_HDD", - [PS3_DEV_TYPE_SATA_SSD] = "DEV_T_SATA_SSD", - [PS3_DEV_TYPE_SAS_SSD] = "DEV_T_SAS_SSD", - [PS3_DEV_TYPE_NVME_SSD] = "DEV_T_NVME_SSD", - [PS3_DEV_TYPE_SES] = "DEV_T_SES", - [PS3_DEV_TYPE_VEP] = "DEV_T_VEP" + static const char * const myNames[] = { + [PS3_DEV_TYPE_UNKNOWN] = "DEV_T_UNKNOWN", + [PS3_DEV_TYPE_VD] = "DEV_T_VD", + [PS3_DEV_TYPE_SAS_HDD] = "DEV_T_SAS_HDD", + [PS3_DEV_TYPE_SATA_HDD] = "DEV_T_SATA_HDD", + [PS3_DEV_TYPE_SATA_SSD] = "DEV_T_SATA_SSD", + [PS3_DEV_TYPE_SAS_SSD] = "DEV_T_SAS_SSD", + [PS3_DEV_TYPE_NVME_SSD] = "DEV_T_NVME_SSD", + [PS3_DEV_TYPE_SES] = "DEV_T_SES", + [PS3_DEV_TYPE_VEP] = "DEV_T_VEP" }; return myNames[e]; @@ -161,152 +148,146 @@ enum ps3_dev_io_stat_type { }; struct ps3_dev_io_statis { - ps3_atomic64 read_send_cnt; - ps3_atomic64 read_send_ok_cnt; - ps3_atomic64 read_send_wait_cnt; - ps3_atomic64 read_send_err_cnt; - ps3_atomic64 read_recv_cnt; - ps3_atomic64 read_recv_ok_cnt; - ps3_atomic64 read_recv_err_cnt; - ps3_atomic64 read_ok_bytes; - - ps3_atomic64 write_send_cnt; - ps3_atomic64 write_send_ok_cnt; - ps3_atomic64 write_send_err_cnt; - ps3_atomic64 write_send_wait_cnt; - ps3_atomic64 write_recv_cnt; - ps3_atomic64 write_recv_ok_cnt; - ps3_atomic64 write_recv_err_cnt; - ps3_atomic64 write_ok_bytes; - - ps3_atomic64 qos_processing_cnt; + atomic64_t read_send_cnt; + atomic64_t read_send_ok_cnt; + atomic64_t read_send_wait_cnt; + atomic64_t read_send_err_cnt; + atomic64_t read_recv_cnt; + atomic64_t read_recv_ok_cnt; + atomic64_t read_recv_err_cnt; + atomic64_t read_ok_bytes; + + atomic64_t write_send_cnt; + atomic64_t write_send_ok_cnt; + atomic64_t write_send_err_cnt; + atomic64_t write_send_wait_cnt; + atomic64_t write_recv_cnt; + atomic64_t write_recv_ok_cnt; + atomic64_t write_recv_err_cnt; + atomic64_t write_ok_bytes; + + atomic64_t qos_processing_cnt; }; -static inline U8 ps3_disk_type(enum PS3DevType e) +static inline unsigned char ps3_disk_type(enum PS3DevType e) { - U8 disk_type = PS3_DISK_TYPE_UNKNOWN; - - switch(e) { - case PS3_DEV_TYPE_VD: - disk_type = PS3_DISK_TYPE_VD; - break; - case PS3_DEV_TYPE_SAS_HDD: - case PS3_DEV_TYPE_SATA_HDD: - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_NVME_SSD: - case PS3_DEV_TYPE_SES: - case PS3_DEV_TYPE_VEP: - disk_type = PS3_DISK_TYPE_PD; - break; - default: - disk_type = PS3_DISK_TYPE_UNKNOWN; - break; + unsigned char disk_type = PS3_DISK_TYPE_UNKNOWN; + + switch (e) { + case PS3_DEV_TYPE_VD: + disk_type = PS3_DISK_TYPE_VD; + break; + case PS3_DEV_TYPE_SAS_HDD: + case PS3_DEV_TYPE_SATA_HDD: + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_NVME_SSD: + case PS3_DEV_TYPE_SES: + case PS3_DEV_TYPE_VEP: + disk_type = PS3_DISK_TYPE_PD; + break; + default: + disk_type = PS3_DISK_TYPE_UNKNOWN; + break; } return disk_type; } -static inline Bool ps3_is_fake_pd(U8 dev_type) +static inline unsigned char ps3_is_fake_pd(unsigned char dev_type) { return (dev_type == PS3_DEV_TYPE_SES || dev_type == PS3_DEV_TYPE_VEP); } struct ps3_r1x_read_balance_info { - ps3_atomic32 scsi_outstanding_cmds[PS3_MAX_PD_NUM_ONE_VD + 1]; - U64 last_accessed_block[PS3_MAX_PD_NUM_ONE_VD + 1]; + atomic_t scsi_outstanding_cmds[PS3_MAX_PD_NUM_ONE_VD + 1]; + unsigned long long last_accessed_block[PS3_MAX_PD_NUM_ONE_VD + 1]; }; struct ps3_r1x_lock_mgr { - S32 (*try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); - S32 (*resend_try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); - void (*unlock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); - ps3_spinlock mgr_lock; + int (*try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); + int (*resend_try_lock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); + void (*unlock)(struct ps3_r1x_lock_mgr *mgr, void *cmd); + spinlock_t mgr_lock; void *hash_mgr; - ps3_list_head conflict_cmd_list; + struct list_head conflict_cmd_list; struct task_struct *conflict_send_th; void *hash_mgr_conflict; - S32 force_ret_code; - U32 cmd_count_in_q; - Bool dev_deling; - Bool thread_stop; + int force_ret_code; + unsigned int cmd_count_in_q; + unsigned char dev_deling; + unsigned char thread_stop; #ifdef _WINDOWS KEVENT thread_sync; #else - struct completion thread_sync; + struct completion thread_sync; #endif - }; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \ - (defined(KYLIN_MAJOR) && defined(CONFIG_X86) && (KYLIN_MAJOR == 10 && KYLIN_MINOR == 4))) -#define DRIVER_SUPPORT_PRIV_BUSY -#endif - struct ps3_scsi_priv_data { - struct PS3DiskDevPos disk_pos; + struct PS3DiskDevPos disk_pos; struct ps3_dev_io_statis statis; struct ps3_vd_stream_detect vd_sd[2]; - struct ps3_r1x_lock_mgr lock_mgr; - struct ps3_r1x_read_balance_info *r1x_rb_info; - U8 is_taskmgmt_enable; - U8 task_manager_busy; - U8 dev_type; - U8 task_abort_timeout; - U8 task_reset_timeout; - U8 encl_id; - U8 phy_id; - U8 reserved; - ps3_atomic32 rd_io_outstand; - ps3_atomic32 wr_io_outstand; - ps3_atomic32 r1x_read_cmd_swap_total_cnt; - ps3_atomic32 r1x_read_cmd_swap_res_cnt; + struct ps3_r1x_lock_mgr lock_mgr; + struct ps3_r1x_read_balance_info *r1x_rb_info; + unsigned char is_taskmgmt_enable; + unsigned char task_manager_busy; + unsigned char dev_type; + unsigned char task_abort_timeout; + unsigned char task_reset_timeout; + unsigned char encl_id; + unsigned char phy_id; +#ifdef PS3_NCQ_PRIO_SUPPORT + unsigned char ncq_prio_support:1; + unsigned char ncq_prio_enable:1; + unsigned char reserved:6; +#else + unsigned char reserved; +#endif + atomic_t rd_io_outstand; + atomic_t wr_io_outstand; + atomic_t r1x_read_cmd_swap_total_cnt; + atomic_t r1x_read_cmd_swap_res_cnt; #if defined DRIVER_SUPPORT_PRIV_BUSY - ps3_atomic32 sdev_priv_busy; + atomic_t sdev_priv_busy; #else - U8 reserved1[4]; + unsigned char reserved1[4]; #endif - ULong ata_cmd_busy; - Bool dev_deling; - Bool swap_flag; - U16 qmask_count; - U8 reserved2[6]; + unsigned long ata_cmd_busy; + unsigned char dev_deling; + unsigned char swap_flag; + unsigned short qmask_count; + unsigned char reserved2[6]; }; #ifdef _WINDOWS struct scsi_device_real { - struct scsi_device sdev; - struct ps3_scsi_priv_data hostdata; + struct scsi_device sdev; + struct ps3_scsi_priv_data hostdata; }; -#define PS3_SDEV_PRI_DATA(sdev) \ - ((struct ps3_scsi_priv_data*)&(((struct scsi_device_real *)(sdev))->hostdata)) -#define PS3_SDEV_POS(sdev) \ - (&(PS3_SDEV_PRI_DATA(sdev)->disk_pos)) -#define PS3_SDEV_CHANNEL(sdev) \ - (PS3_CHANNEL(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_TARGET(sdev) \ - (PS3_TARGET(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_PDID(sdev) \ - (PS3_PDID(PS3_SDEV_POS(sdev))) -#define PS3_SDEV_MAGIC(sdev) \ - (PS3_SDEV_POS(sdev)->diskMagicNum) +#define PS3_SDEV_PRI_DATA(sdev) \ + ((struct ps3_scsi_priv_data *)&( \ + ((struct scsi_device_real *)(sdev))->hostdata)) +#define PS3_SDEV_POS(sdev) (&(PS3_SDEV_PRI_DATA(sdev)->disk_pos)) +#define PS3_SDEV_CHANNEL(sdev) (PS3_CHANNEL(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_TARGET(sdev) (PS3_TARGET(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_PDID(sdev) (PS3_PDID(PS3_SDEV_POS(sdev))) +#define PS3_SDEV_MAGIC(sdev) (PS3_SDEV_POS(sdev)->diskMagicNum) #else -#define PS3_SDEV_CHANNEL(sdev) \ - ((sdev)->channel) -#define PS3_SDEV_TARGET(sdev) \ - ((sdev)->id) +#define PS3_SDEV_CHANNEL(sdev) ((sdev)->channel) +#define PS3_SDEV_TARGET(sdev) ((sdev)->id) -#define PS3_SDEV_PRI_DATA(sdev) \ - ((struct ps3_scsi_priv_data*)((sdev)->hostdata)) +#define PS3_SDEV_PRI_DATA(sdev) \ + ((struct ps3_scsi_priv_data *)((sdev)->hostdata)) #endif struct ps3_channel { - U8 channel; - U8 reserved0; - U16 max_dev_num; - U16 channel_start_num; - U8 reserved1[2]; + unsigned char channel; + unsigned char reserved0; + unsigned short max_dev_num; + unsigned short channel_start_num; + unsigned char reserved1[2]; }; struct ps3_dev_pool { @@ -316,42 +297,43 @@ struct ps3_dev_pool { struct ps3_pd_entry { struct PS3DiskDevPos disk_pos; - U8 state; - U8 config_flag; - U8 RWCT; - U8 scsi_interface_type; - U8 task_abort_timeout; - U8 task_reset_timeout; - U8 dev_type; + unsigned char state; + unsigned char config_flag; + unsigned char RWCT; + unsigned char scsi_interface_type; + unsigned char task_abort_timeout; + unsigned char task_reset_timeout; + unsigned char dev_type; union { struct { - U8 support_ncq:1; - U8 protect:1; - U8 is_direct_disable:1; - U8 reserved:5; + unsigned char support_ncq : 1; + unsigned char protect : 1; + unsigned char is_direct_disable : 1; + unsigned char support_ncq_prio:1; + unsigned char reserved : 4; }; - U8 pd_flags; + unsigned char pd_flags; }; - U32 max_io_size; - U32 dev_queue_depth; - U8 encl_id; - U8 phy_id; - U16 sector_size; - U16 dma_addr_alignment; - U16 dma_len_alignment; + unsigned int max_io_size; + unsigned int dev_queue_depth; + unsigned char encl_id; + unsigned char phy_id; + unsigned short sector_size; + unsigned short dma_addr_alignment; + unsigned short dma_len_alignment; struct sas_rphy *sas_rphy; - U16 normal_quota; - U16 direct_quota; + unsigned short normal_quota; + unsigned short direct_quota; }; struct ps3_pd_table { - U16 *pd_idxs_array; - U16 *pd_idxs[PS3_MAX_CHANNEL_NUM]; + unsigned short *pd_idxs_array; + unsigned short *pd_idxs[PS3_MAX_CHANNEL_NUM]; }; struct ps3_vd_table { - U16 *vd_idxs_array; - U16 *vd_idxs[PS3_MAX_CHANNEL_NUM]; + unsigned short *vd_idxs_array; + unsigned short *vd_idxs[PS3_MAX_CHANNEL_NUM]; }; struct ps3_pri_data_table { @@ -360,180 +342,191 @@ struct ps3_pri_data_table { }; struct ps3_dev_context { - struct ps3_vd_table vd_table[PS3_VD_TABLE_NUM]; - struct ps3_pd_table pd_table; - struct PS3VDEntry *vd_entries_array[PS3_VD_TABLE_NUM]; - struct ps3_pd_entry *pd_entries_array; + struct ps3_vd_table vd_table[PS3_VD_TABLE_NUM]; + struct ps3_pd_table pd_table; + struct PS3VDEntry *vd_entries_array[PS3_VD_TABLE_NUM]; + struct ps3_pd_entry *pd_entries_array; struct ps3_channel channel_pd[PS3_MAX_CHANNEL_NUM]; struct ps3_channel channel_vd[PS3_MAX_CHANNEL_NUM]; struct ps3_pri_data_table vd_pri_data_table; - U16 max_dev_in_channel[PS3_MAX_CHANNEL_NUM]; - volatile U8 subwork; - U8 reserved[3]; - struct ps3_dev_pool vd_pool; - struct ps3_dev_pool pd_pool; - - dma_addr_t pd_list_buf_phys; - struct PS3DevList *pd_list_buf; - dma_addr_t vd_list_buf_phys; - struct PS3DevList *vd_list_buf; - dma_addr_t pd_info_buf_phys; - struct PS3PDInfo *pd_info_buf; - dma_addr_t vd_info_buf_phys_sync; - struct PS3VDInfo *vd_info_buf_sync; - dma_addr_t vd_info_buf_phys_async; - struct PS3VDInfo *vd_info_buf_async; - - struct ps3_cmd *vd_pending_cmd; - struct ps3_cmd *vdpending_abort_cmd; - volatile U32 abort_vdpending_cmd; - ps3_atomic32 is_vdpending_abort; - - U16 total_vd_count; - U16 total_pd_count; - U16 max_dev_per_channel; - U8 vd_table_idx; - U8 pd_channel_count; - U8 vd_channel_count; - ps3_mutex dev_priv_lock; + unsigned short max_dev_in_channel[PS3_MAX_CHANNEL_NUM]; + atomic_t subwork; + unsigned char reserved[3]; + struct ps3_dev_pool vd_pool; + struct ps3_dev_pool pd_pool; + + dma_addr_t pd_list_buf_phys; + struct PS3DevList *pd_list_buf; + dma_addr_t vd_list_buf_phys; + struct PS3DevList *vd_list_buf; + dma_addr_t pd_info_buf_phys; + struct PS3PDInfo *pd_info_buf; + dma_addr_t vd_info_buf_phys_sync; + struct PS3VDInfo *vd_info_buf_sync; + dma_addr_t vd_info_buf_phys_async; + struct PS3VDInfo *vd_info_buf_async; + + struct ps3_cmd *vd_pending_cmd; + struct ps3_cmd *vdpending_abort_cmd; + atomic_t abort_vdpending_cmd; + atomic_t is_vdpending_abort; + + unsigned short total_vd_count; + unsigned short total_pd_count; + unsigned short max_dev_per_channel; + unsigned char vd_table_idx; + unsigned char pd_channel_count; + unsigned char vd_channel_count; + struct mutex dev_priv_lock; #ifdef _WINDOWS - U8 channel_map_rang_num; - U8 total_os_channel; + unsigned char channel_map_rang_num; + unsigned char total_os_channel; struct ps3_windows_private_table windows_table; - U8 reserved2[3]; + unsigned char reserved2[3]; KEVENT disk_sync; - ps3_spinlock dev_lock; + spinlock_t dev_lock; #else - U8 reserved2[7]; + unsigned char reserved2[7]; #endif - ps3_mutex dev_scan_lock; + struct mutex dev_scan_lock; }; -S32 ps3_dev_mgr_cli_register(void); +int ps3_dev_mgr_cli_register(void); -S32 ps3_device_mgr_init(struct ps3_instance *instance); +int ps3_device_mgr_init(struct ps3_instance *instance); void ps3_device_mgr_exit(struct ps3_instance *instance); -S32 ps3_device_mgr_data_init(struct ps3_instance *instance); +int ps3_device_mgr_data_init(struct ps3_instance *instance); -S32 ps3_device_mgr_data_exit(struct ps3_instance *instance); +int ps3_device_mgr_data_exit(struct ps3_instance *instance); -S32 ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance); +int ps3_dev_mgr_vd_info_subscribe(struct ps3_instance *instance); -S32 ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance); -S32 ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance); +int ps3_dev_mgr_vd_info_unsubscribe(struct ps3_instance *instance); +int ps3_dev_mgr_vd_info_resubscribe(struct ps3_instance *instance); void ps3_dev_mgr_vd_info_clear(struct ps3_instance *instance); -S32 ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, U16 channel, - U16 target_id, U16 pd_id); +int ps3_dev_mgr_pd_info_get(struct ps3_instance *instance, + unsigned short channel, unsigned short target_id, + unsigned short pd_id); -struct ps3_pd_entry *ps3_dev_mgr_pd_info_find_by_id( - struct ps3_instance *instance, U16 disk_id); +struct ps3_pd_entry * +ps3_dev_mgr_pd_info_find_by_id(struct ps3_instance *instance, + unsigned short disk_id); -S32 ps3_dev_mgr_pd_list_get(struct ps3_instance *instance); +int ps3_dev_mgr_pd_list_get(struct ps3_instance *instance); -S32 ps3_dev_mgr_vd_list_get(struct ps3_instance *instance); +int ps3_dev_mgr_vd_list_get(struct ps3_instance *instance); -S32 ps3_vd_info_get_all(struct ps3_instance *instance); +int ps3_vd_info_get_all(struct ps3_instance *instance); -static inline U16 get_offset_of_vdid(U16 offsetOfVDID, U16 virtDiskID) +static inline unsigned short get_offset_of_vdid(unsigned short offsetOfVDID, + unsigned short virtDiskID) { - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; - if ( virtDiskID >= offsetOfVDID ) { + if (virtDiskID >= offsetOfVDID) virtDiskIdx = virtDiskID - offsetOfVDID; - } return virtDiskIdx; } -Bool ps3_dev_id_valid_check(struct ps3_instance *instance, U8 channel, - U16 target_id, U8 dev_type); +unsigned char ps3_dev_id_valid_check(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char dev_type); -U8 ps3_get_vd_raid_level( - struct ps3_instance *instance, U8 channel, U16 target_id); +unsigned char ps3_get_vd_raid_level(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id); -struct ps3_scsi_priv_data *ps3_dev_mgr_lookup_vd_pri_data( - struct ps3_instance *instance, U8 channel, U16 target_id); +struct ps3_scsi_priv_data * +ps3_dev_mgr_lookup_vd_pri_data(struct ps3_instance *instance, + unsigned char channel, unsigned short target_id); -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info( - struct ps3_instance *instance, U8 channel, U16 target_id); +struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id); -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info( - struct ps3_instance *instance, U8 channel, U16 target_id); +struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id); -struct PS3VDEntry *ps3_dev_mgr_lookup_vd_info_by_id( - struct ps3_instance *instance, U16 disk_id); +struct PS3VDEntry * +ps3_dev_mgr_lookup_vd_info_by_id(struct ps3_instance *instance, + unsigned short disk_id); -struct ps3_pd_entry *ps3_dev_mgr_lookup_pd_info_by_id( - struct ps3_instance *instance, U16 disk_id); +struct ps3_pd_entry * +ps3_dev_mgr_lookup_pd_info_by_id(struct ps3_instance *instance, + unsigned short disk_id); -union PS3Device* ps3_dev_mgr_lookup_vd_list( - struct ps3_instance *instance, U8 channel, U16 target_id); +union PS3Device *ps3_dev_mgr_lookup_vd_list(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id); -union PS3Device* ps3_dev_mgr_lookup_pd_list( - struct ps3_instance *instance, U8 channel, U16 target_id); +union PS3Device *ps3_dev_mgr_lookup_pd_list(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id); #ifndef _WINDOWS -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) -S32 ps3_change_queue_depth(struct scsi_device *sdev, - S32 queue_depth, S32 reason); +#if defined(PS3_CHANGE_QUEUE_DEPTH) +int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth, + int reason); #else -S32 ps3_change_queue_depth(struct scsi_device *sdev, - S32 queue_depth); +int ps3_change_queue_depth(struct scsi_device *sdev, int queue_depth); #endif -S32 ps3_scsi_slave_alloc(struct scsi_device *sdev); +int ps3_scsi_slave_alloc(struct scsi_device *sdev); void ps3_scsi_slave_destroy(struct scsi_device *sdev); -S32 ps3_scsi_slave_configure(struct scsi_device *sdev); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) +int ps3_scsi_slave_configure(struct scsi_device *sdev); +#else +int ps3_scsi_slave_configure(struct scsi_device *sdev, + struct queue_limits *lim); +#endif #endif -static inline Bool ps3_check_pd_is_vd_member(U8 config_flag) +static inline unsigned char ps3_check_pd_is_vd_member(unsigned char config_flag) { return (config_flag != MIC_PD_STATE_JBOD && config_flag != MIC_PD_STATE_READY && - config_flag != MIC_PD_STATE_UNKNOWN - ); + config_flag != MIC_PD_STATE_UNKNOWN); } -static inline U8 ps3_get_converted_dev_type(U8 driverType, U8 mediumType) +static inline unsigned char ps3_get_converted_dev_type(unsigned char driverType, + unsigned char mediumType) { - U8 dev_type = PS3_DEV_TYPE_UNKNOWN; + unsigned char dev_type = PS3_DEV_TYPE_UNKNOWN; switch (driverType) { case DRIVER_TYPE_SAS: - if (mediumType == DEVICE_TYPE_HDD) { + if (mediumType == DEVICE_TYPE_HDD) dev_type = PS3_DEV_TYPE_SAS_HDD; - } else if (mediumType == DEVICE_TYPE_SSD) { + else if (mediumType == DEVICE_TYPE_SSD) dev_type = PS3_DEV_TYPE_SAS_SSD; - } break; case DRIVER_TYPE_SATA: - if (mediumType == DEVICE_TYPE_HDD) { + if (mediumType == DEVICE_TYPE_HDD) dev_type = PS3_DEV_TYPE_SATA_HDD; - } else if (mediumType == DEVICE_TYPE_SSD) { + else if (mediumType == DEVICE_TYPE_SSD) dev_type = PS3_DEV_TYPE_SATA_SSD; - } break; case DRIVER_TYPE_SES: - if (mediumType == DEVICE_TYPE_ENCLOSURE) { + if (mediumType == DEVICE_TYPE_ENCLOSURE) dev_type = PS3_DEV_TYPE_SES; - } break; case DRIVER_TYPE_VEP: - if (mediumType == DEVICE_TYPE_ENCLOSURE) { + if (mediumType == DEVICE_TYPE_ENCLOSURE) dev_type = PS3_DEV_TYPE_VEP; - } break; case DRIVER_TYPE_NVME: - if (mediumType == DEVICE_TYPE_SSD) { + if (mediumType == DEVICE_TYPE_SSD) dev_type = PS3_DEV_TYPE_NVME_SSD; - } break; default: break; @@ -542,35 +535,61 @@ static inline U8 ps3_get_converted_dev_type(U8 driverType, U8 mediumType) }; void ps3_change_sdev_max_sector(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry); + struct PS3VDEntry *vd_entry); void ps3_vd_info_show(const struct ps3_instance *instance, - const struct PS3VDEntry *vd_entry); -S32 ps3_adjust_queue_depth(struct ps3_instance *instance, - U8 dev_type, U32 queue_depth); + const struct PS3VDEntry *vd_entry); +int ps3_adjust_queue_depth(struct ps3_instance *instance, + unsigned char dev_type, unsigned int queue_depth); -static inline const char *ps3_get_vd_access_plolicy_str(VDAccessPolicy_e policy) +static inline const char * +ps3_get_vd_access_plolicy_str(enum VDAccessPolicy policy) { - static const char *vdAccessPolicyName[] = { - [VD_ACCESS_POLICY_READ_WRITE] = "RW", - [VD_ACCESS_POLICY_READ_ONLY] = "RO", - [VD_ACCESS_POLICY_BLOCK] = "BLOCK", - [VD_ACCESS_POLICY_REMOVE_ACCESS] = "REMOVE_ACCESS", + static const char *const vdAccessPolicyName[] = { + [VD_ACCESS_POLICY_READ_WRITE] = "RW", + [VD_ACCESS_POLICY_READ_ONLY] = "RO", + [VD_ACCESS_POLICY_BLOCK] = "BLOCK", + [VD_ACCESS_POLICY_REMOVE_ACCESS] = "REMOVE_ACCESS", }; return (policy < ARRAY_SIZE(vdAccessPolicyName)) ? - vdAccessPolicyName[policy] : "Unknown"; + vdAccessPolicyName[policy] : + "Unknown"; } -static inline Bool ps3_is_hdd_pd(U8 dev_type) +static inline unsigned char ps3_is_hdd_pd(unsigned char dev_type) { - return (dev_type == PS3_DEV_TYPE_SAS_HDD || dev_type == PS3_DEV_TYPE_SATA_HDD); + return (dev_type == PS3_DEV_TYPE_SAS_HDD || + dev_type == PS3_DEV_TYPE_SATA_HDD); +} + +static inline unsigned char ps3_is_hdd_vd(const struct PS3VDEntry *vd_entry) +{ + return (!vd_entry->isNvme && !vd_entry->isSsd); +} + +static inline unsigned char ps3_vd_member_state_get(const struct PS3VDEntry *vd_entry, + unsigned char span_idx, unsigned char span_pd_idx) +{ + return vd_entry->span[span_idx].extent[span_pd_idx].state; } void ps3_vd_busy_scale_get(struct PS3VDEntry *vd_entry); -void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, struct scsi_device *sdev); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) +void ps3_sdev_bdi_stable_writes_set(struct ps3_instance *instance, + struct scsi_device *sdev); + +void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, + struct scsi_device *sdev); + +int ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev); +#endif + +void ps3_update_max_sectors(struct ps3_instance *instance, + unsigned char channel, unsigned short target, struct scsi_device *sdev); -void ps3_sdev_bdi_stable_writes_clear(struct ps3_instance *instance, struct scsi_device *sdev); -S32 ps3_sdev_bdi_stable_writes_get(struct scsi_device *sdev); +#ifdef PS3_NCQ_PRIO_SUPPORT +ssize_t ps3_dev_ncq_prio_enable_stor(struct device *dev, const char *buf); +#endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c index aed03c800508..31fa22795f83 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include @@ -18,81 +19,95 @@ #include "ps3_util.h" #include "ps3_mgr_cmd.h" -static S32 ps3_sas_expander_event_update(struct ps3_instance *instance, U8 encl_id); +static int ps3_sas_expander_event_update(struct ps3_instance *instance, + unsigned char encl_id); -Bool ps3_sas_is_support_smp(struct ps3_instance *instance) +unsigned char ps3_sas_is_support_smp(struct ps3_instance *instance) { return instance->sas_dev_context.is_support_smp; } -static inline Bool ps3_is_sata_end_device(struct ps3_pd_entry *pd_entry) +static inline unsigned char +ps3_is_sata_end_device(struct ps3_pd_entry *pd_entry) { return (pd_entry->dev_type == PS3_DEV_TYPE_SATA_HDD || - pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD); + pd_entry->dev_type == PS3_DEV_TYPE_SATA_SSD); } -S32 ps3_sas_rphy_slot_get(struct ps3_instance *instance, U64 sas_addr, U32 *slot_id) +int ps3_sas_rphy_slot_get(struct ps3_instance *instance, + unsigned long long sas_addr, unsigned int *slot_id) { - S32 ret = -PS3_FAILED; - struct ps3_sas_node *ps3_sas_node = &instance->sas_dev_context.ps3_hba_sas; + int ret = -PS3_FAILED; + struct ps3_sas_node *ps3_sas_node = + &instance->sas_dev_context.ps3_hba_sas; struct ps3_sas_port *ps3_sas_port = NULL; - ULong flags = 0; + unsigned long flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, list) { - if (ps3_sas_port->remote_identify.sas_address == - sas_addr) { - *slot_id = ps3_sas_node->phys[ps3_sas_port-> - remote_identify.phy_identifier].slot_id; + if (ps3_sas_port->remote_identify.sas_address == sas_addr) { + *slot_id = ps3_sas_node + ->phys[ps3_sas_port->remote_identify + .phy_identifier] + .slot_id; ret = PS3_SUCCESS; - INJECT_START(PS3_ERR_IJ_SAS_RPHY_SLOT_GET_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_SAS_RPHY_SLOT_GET_FAILED, &ret); goto l_out; } } list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, list) { - list_for_each_entry(ps3_sas_port, - &ps3_sas_node->sas_port_list, list) { + &instance->sas_dev_context.ps3_sas_node_list, + list) { + list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, + list) { if (ps3_sas_port->remote_identify.sas_address == - sas_addr) { - *slot_id = ps3_sas_node->phys[ps3_sas_port-> - remote_identify.phy_identifier].slot_id; + sas_addr) { + *slot_id = + ps3_sas_node + ->phys[ps3_sas_port + ->remote_identify + .phy_identifier] + .slot_id; ret = PS3_SUCCESS; - INJECT_START(PS3_ERR_IJ_SAS_EXP_RPHY_SLOT_GET_FAILED, &ret) + INJECT_START( + PS3_ERR_IJ_SAS_EXP_RPHY_SLOT_GET_FAILED, + &ret); goto l_out; } } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); return ret; } -U64 ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, U64 sas_addr) +unsigned long long +ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, + unsigned long long sas_addr) { struct ps3_sas_node *ps3_sas_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; - U64 encl_id = PS3_SAS_INVALID_SAS_ADDR; - ULong flags = 0; + unsigned long long encl_id = PS3_SAS_INVALID_SAS_ADDR; + unsigned long flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - list_for_each_entry(ps3_sas_port, - &instance->sas_dev_context.ps3_hba_sas.sas_port_list, list) { - if (ps3_sas_port->remote_identify.sas_address != - sas_addr) { + list_for_each_entry( + ps3_sas_port, + &instance->sas_dev_context.ps3_hba_sas.sas_port_list, list) { + if (ps3_sas_port->remote_identify.sas_address != sas_addr) continue; - } - list_for_each_entry(ps3_sas_phy, - &ps3_sas_port->phy_list, port_siblings) { + list_for_each_entry(ps3_sas_phy, &ps3_sas_port->phy_list, + port_siblings) { if (ps3_sas_phy->remote_identify.sas_address == - sas_addr) { + sas_addr) { encl_id = ps3_sas_phy->identify.sas_address; goto l_out; } @@ -100,51 +115,56 @@ U64 ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, U64 sas_addr } list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, list) { - list_for_each_entry(ps3_sas_port, - &ps3_sas_node->sas_port_list, list) { + &instance->sas_dev_context.ps3_sas_node_list, + list) { + list_for_each_entry(ps3_sas_port, &ps3_sas_node->sas_port_list, + list) { if (ps3_sas_port->remote_identify.sas_address == - sas_addr) { + sas_addr) { encl_id = ps3_sas_node->sas_address; goto l_out; } } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); return encl_id; } -U8 ps3_sas_encl_id_get(struct ps3_instance *instance, U64 sas_addr) +unsigned char ps3_sas_encl_id_get(struct ps3_instance *instance, + unsigned long long sas_addr) { - U8 encl_id = PS3_SAS_INVALID_ID; + unsigned char encl_id = PS3_SAS_INVALID_ID; struct ps3_sas_node *ps3_sas_node = NULL; - ULong flags = 0; - U8 i = 0; + unsigned long flags = 0; + unsigned char i = 0; for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { - if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) { + if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) return instance->sas_dev_context.ps3_hba_sas.encl_id; - } } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, list) { + &instance->sas_dev_context.ps3_sas_node_list, + list) { if (ps3_sas_node->sas_address == sas_addr) { encl_id = ps3_sas_node->encl_id; goto l_out; } } l_out: - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); return encl_id; } static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, - struct ps3_sas_node *sas_node, struct PS3PhyInfo *phy_info) + struct ps3_sas_node *sas_node, + struct PS3PhyInfo *phy_info) { ps3_phy->phy_id = phy_info->phyId; ps3_phy->encl_id = sas_node->encl_id; @@ -154,13 +174,13 @@ static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, ps3_phy->identify.sas_address = le64_to_cpu(phy_info->sasAddr); ps3_phy->identify.initiator_port_protocols = phy_info->initiatorPortProtocol; - ps3_phy->identify.target_port_protocols = - phy_info->targetPortProtocols; + ps3_phy->identify.target_port_protocols = phy_info->targetPortProtocols; ps3_phy->identify.phy_identifier = phy_info->phyId; if (phy_info->attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR) { ps3_phy->remote_identify.device_type = phy_info->attachDevType; - ps3_phy->remote_identify.sas_address = le64_to_cpu(phy_info->attachedSasAddr); + ps3_phy->remote_identify.sas_address = + le64_to_cpu(phy_info->attachedSasAddr); ps3_phy->remote_identify.initiator_port_protocols = phy_info->attachInitiatorPortProtocol; ps3_phy->remote_identify.target_port_protocols = @@ -169,11 +189,12 @@ static void ps3_sas_node_phy_init(struct ps3_sas_phy *ps3_phy, } } -static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, - struct ps3_sas_phy *ps3_phy, struct ps3_sas_node *sas_node, - struct PS3PhyInfo *phy_info) +static int ps3_sas_node_phy_add(struct ps3_instance *instance, + struct ps3_sas_phy *ps3_phy, + struct ps3_sas_node *sas_node, + struct PS3PhyInfo *phy_info) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct sas_phy *sas_phy = NULL; INIT_LIST_HEAD(&ps3_phy->port_siblings); @@ -181,8 +202,8 @@ static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL1, &sas_phy); if (sas_phy == NULL) { LOG_ERROR("hno:%u alloc node[%d] phys[%d] buffer failed !\n", - PS3_HOST(instance), sas_node->encl_id, - phy_info->phyId); + PS3_HOST(instance), sas_node->encl_id, + phy_info->phyId); ret = -PS3_ENOMEM; goto l_out; } @@ -196,15 +217,15 @@ static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, sas_phy->minimum_linkrate_hw = phy_info->minLinkRateHw; sas_phy->maximum_linkrate_hw = phy_info->maxLinkRateHw; - LOG_INFO("hno:%u phy %d in encl[%d], dev_type[%d]," - "sas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d], " - "remote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]" - " min_linkr[%u:%u], max_linikr[%u:%u] !\n", + LOG_INFO( + "hno:%u phy %d in encl[%d], dev_type[%d]\n" + "\tsas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d]\n" + "\tremote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]\n" + "\tmin_linkr[%u:%u], max_linikr[%u:%u] !\n", PS3_HOST(instance), sas_phy->identify.phy_identifier, sas_node->encl_id, sas_phy->identify.device_type, - sas_phy->identify.sas_address, - sas_phy->negotiated_linkrate, phy_info->slotId, - sas_phy->identify.initiator_port_protocols, + sas_phy->identify.sas_address, sas_phy->negotiated_linkrate, + phy_info->slotId, sas_phy->identify.initiator_port_protocols, sas_phy->identify.target_port_protocols, ps3_phy->remote_identify.device_type, ps3_phy->remote_identify.sas_address, @@ -217,8 +238,8 @@ static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED1, &ret); if (ret != 0) { LOG_ERROR("hno:%u add node[%d]-phys[%d] failed ret[%d] !\n", - PS3_HOST(instance), sas_node->encl_id, - phy_info->phyId, ret); + PS3_HOST(instance), sas_node->encl_id, + phy_info->phyId, ret); sas_phy_free(sas_phy); goto l_out; } @@ -228,27 +249,21 @@ static S32 ps3_sas_node_phy_add(struct ps3_instance *instance, return ret; } -void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy *ps3_phy, - struct PS3PhyInfo *phy_info) +void ps3_sas_node_phy_update(struct ps3_instance *instance, + struct ps3_sas_phy *ps3_phy, + struct PS3PhyInfo *phy_info) { (void)instance; ps3_phy->identify.initiator_port_protocols = phy_info->initiatorPortProtocol; - ps3_phy->identify.target_port_protocols = - phy_info->targetPortProtocols; -#if 0 - if (phy_info->attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR) { -#endif - ps3_phy->remote_identify.device_type = phy_info->attachDevType; - ps3_phy->remote_identify.sas_address = phy_info->attachedSasAddr; - ps3_phy->remote_identify.initiator_port_protocols = - phy_info->attachInitiatorPortProtocol; - ps3_phy->remote_identify.target_port_protocols = - phy_info->attachTargetPortProtocols; - ps3_phy->remote_identify.phy_identifier = phy_info->phyId; -#if 0 - } -#endif + ps3_phy->identify.target_port_protocols = phy_info->targetPortProtocols; + ps3_phy->remote_identify.device_type = phy_info->attachDevType; + ps3_phy->remote_identify.sas_address = phy_info->attachedSasAddr; + ps3_phy->remote_identify.initiator_port_protocols = + phy_info->attachInitiatorPortProtocol; + ps3_phy->remote_identify.target_port_protocols = + phy_info->attachTargetPortProtocols; + ps3_phy->remote_identify.phy_identifier = phy_info->phyId; ps3_phy->phy->identify = ps3_phy->identify; ps3_phy->phy->negotiated_linkrate = phy_info->negLinkRate; @@ -258,13 +273,14 @@ void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy * ps3_phy->phy->minimum_linkrate_hw = phy_info->minLinkRateHw; ps3_phy->phy->maximum_linkrate_hw = phy_info->maxLinkRateHw; - LOG_INFO_IN_IRQ(instance, "update phy %d, dev_type[%d], enable[%d]" - "sas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d], " - "remote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]" - " min_linkr[%u:%u], max_linikr[%u:%u] !\n", + LOG_INFO_IN_IRQ( + instance, + "update phy %d, dev_type[%d], enable[%d]\n" + "\tsas_addr[%016llx], n_linkrate[%d], slot_id[%d], i_prol[%d], t_prol[%d]\n" + "\tremote_dev_type[%d], remote_sas_addr[%016llx], i_prol[%d], t_prol[%d]\n" + "\tmin_linkr[%u:%u], max_linikr[%u:%u] !\n", ps3_phy->phy->identify.phy_identifier, - ps3_phy->phy->identify.device_type, - ps3_phy->phy->enabled, + ps3_phy->phy->identify.device_type, ps3_phy->phy->enabled, ps3_phy->phy->identify.sas_address, ps3_phy->phy->negotiated_linkrate, phy_info->slotId, ps3_phy->phy->identify.initiator_port_protocols, @@ -280,82 +296,99 @@ void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy * } static void ps3_sas_port_phy_update(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) + struct ps3_sas_node *sas_node) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; - U8 i = 0; - ULong flags = 0; + unsigned char i = 0; + unsigned long flags = 0; for (i = 0; i < sas_node->phy_count; i++) { if (sas_node->phys[i].remote_identify.sas_address == 0 || - sas_node->phys[i].remote_identify.device_type == SAS_END_DEVICE) { + sas_node->phys[i].remote_identify.device_type == + SAS_END_DEVICE) { continue; } - if (sas_node->phys[i].attach_port != NULL) { + if (sas_node->phys[i].attach_port != NULL) continue; - } list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { + &sas_node->sas_port_list, list) { if (sas_node->phys[i].remote_identify.sas_address == - ps3_sas_port->remote_identify.sas_address) { - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - list_add_tail(&sas_node->phys[i].port_siblings, &ps3_sas_port->phy_list); + ps3_sas_port->remote_identify.sas_address) { + spin_lock_irqsave(&instance->sas_dev_context + .ps3_sas_node_lock, + flags); + list_add_tail(&sas_node->phys[i].port_siblings, + &ps3_sas_port->phy_list); sas_node->phys[i].attach_port = ps3_sas_port; - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context + .ps3_sas_node_lock, + flags); ps3_sas_port->phy_count++; - sas_port_add_phy(ps3_sas_port->port, sas_node->phys[i].phy); + sas_port_add_phy(ps3_sas_port->port, + sas_node->phys[i].phy); } } } } -static struct ps3_sas_port* ps3_sas_port_find(struct ps3_instance *instance, - struct ps3_sas_node *exp_node, U64 sas_addr) +static struct ps3_sas_port *ps3_sas_port_find(struct ps3_instance *instance, + struct ps3_sas_node *exp_node, + unsigned long long sas_addr) { struct ps3_sas_port *ps3_sas_port = NULL; - ULong flags = 0; + unsigned long flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.sas_address == sas_addr) { - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); return ps3_sas_port; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); return NULL; } static void ps3_sas_port_phy_add(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port, struct ps3_sas_phy *ps3_phy) + struct ps3_sas_port *ps3_sas_port, + struct ps3_sas_phy *ps3_phy) { struct ps3_sas_phy *tmp_phy = NULL; - ULong flags = 0; + unsigned long flags = 0; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(tmp_phy, &ps3_sas_port->phy_list, port_siblings) { if (tmp_phy == ps3_phy) { - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); return; } } list_add_tail(&ps3_phy->port_siblings, &ps3_sas_port->phy_list); ps3_phy->attach_port = ps3_sas_port; - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); ps3_sas_port->phy_count++; sas_port_add_phy(ps3_sas_port->port, ps3_phy->phy); } -static struct sas_port* ps3_sas_sas_port_create(struct ps3_instance *instance, - struct ps3_sas_node *parent_node, struct list_head *phy_list) +static struct sas_port * +ps3_sas_sas_port_create(struct ps3_instance *instance, + struct ps3_sas_node *parent_node, + struct list_head *phy_list) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct sas_port *sas_port = NULL; struct ps3_sas_phy *ps3_phy = NULL; @@ -363,7 +396,7 @@ static struct sas_port* ps3_sas_sas_port_create(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_SAS_ALLOC_NUM_NULL, &sas_port); if (sas_port == NULL) { LOG_ERROR("hno:%u alloc sas_port on node[%d] failed !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_out; } @@ -371,12 +404,13 @@ static struct sas_port* ps3_sas_sas_port_create(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_SAS_PORT_ADD_FAILED, &ret); if (ret != 0) { LOG_ERROR("hno:%u add sas_port on node[%d] failed !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_failed; } list_for_each_entry(ps3_phy, phy_list, port_siblings) { - LOG_DEBUG("hno:%u add phy[%d] in sas_port[%016llx] on node[%d] !\n", + LOG_DEBUG( + "hno:%u add phy[%d] in sas_port[%016llx] on node[%d] !\n", PS3_HOST(instance), ps3_phy->phy_id, ps3_phy->remote_identify.sas_address, parent_node->encl_id); @@ -390,11 +424,12 @@ static struct sas_port* ps3_sas_sas_port_create(struct ps3_instance *instance, return NULL; } -static S32 ps3_sas_end_device_add_past(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port, struct ps3_pd_entry *pd_entry, - struct sas_rphy *sas_rphy) +static int ps3_sas_end_device_add_past(struct ps3_instance *instance, + struct ps3_sas_port *ps3_sas_port, + struct ps3_pd_entry *pd_entry, + struct sas_rphy *sas_rphy) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (ps3_sas_port->remote_identify.device_type != SAS_END_DEVICE) { ret = PS3_SUCCESS; @@ -403,40 +438,51 @@ static S32 ps3_sas_end_device_add_past(struct ps3_instance *instance, sas_rphy->identify = ps3_sas_port->remote_identify; ret = ps3_scsi_add_device_ack(instance, &pd_entry->disk_pos, - PS3_DISK_TYPE_PD); + PS3_DISK_TYPE_PD); INJECT_START(PS3_ERR_IJ_SAS_ADD_ACK_FAILED, &ret); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] " - "magic[%#x] add scsi device ack NOK, ret %d\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), - PS3_PDID(&pd_entry->disk_pos), - pd_entry->disk_pos.diskMagicNum, ret); + LOG_ERROR("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u]\n" + "\tmagic[%#x] add scsi device ack NOK, ret %d\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), + PS3_PDID(&pd_entry->disk_pos), + pd_entry->disk_pos.diskMagicNum, ret); ret = -PS3_ACTIVE_ERR; } else { - LOG_WARN("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add begin\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), + LOG_WARN( + "hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add begin\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos)); - scsi_scan_target(&sas_rphy->dev, PS3_CHANNEL(&pd_entry->disk_pos), - PS3_TARGET(&pd_entry->disk_pos), 0, SCSI_SCAN_INITIAL); - LOG_WARN("hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add end\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, - PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos), + scsi_scan_target(&sas_rphy->dev, + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), 0, + SCSI_SCAN_INITIAL); + LOG_WARN( + "hno:%u rphy sas_addr[%016llx] end-device[%u:%u:%u] add end\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address, + PS3_CHANNEL(&pd_entry->disk_pos), + PS3_TARGET(&pd_entry->disk_pos), PS3_PDID(&pd_entry->disk_pos)); } l_out: return ret; } -static S32 ps3_sas_port_rphy_create(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port) +static int ps3_sas_port_rphy_create(struct ps3_instance *instance, + struct ps3_sas_port *ps3_sas_port) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct sas_rphy *sas_rphy = NULL; struct ps3_pd_entry *pd_entry = NULL; - LOG_DEBUG("hno:%u enter port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", + LOG_DEBUG( + "hno:%u enter port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", PS3_HOST(instance), ps3_sas_port->remote_identify.device_type, ps3_sas_port->pd_flat_id, ps3_sas_port->remote_identify.sas_address); @@ -444,13 +490,17 @@ static S32 ps3_sas_port_rphy_create(struct ps3_instance *instance, if (ps3_sas_port->remote_identify.device_type == SAS_END_DEVICE) { sas_rphy = sas_end_device_alloc(ps3_sas_port->port); } else { - sas_rphy = sas_expander_alloc(ps3_sas_port->port, - (enum sas_device_type)ps3_sas_port->remote_identify.device_type); + sas_rphy = sas_expander_alloc( + ps3_sas_port->port, + (enum sas_device_type) + ps3_sas_port->remote_identify.device_type); } INJECT_START(PS3_ERR_IJ_SAS_ALLOC_PHY_NULL, &sas_rphy); if (unlikely(sas_rphy == NULL)) { - LOG_ERROR("hno:%u alloc SAS rphy for sas_addr[%016llx] failed !\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); + LOG_ERROR( + "hno:%u alloc SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address); goto l_out; } @@ -458,10 +508,11 @@ static S32 ps3_sas_port_rphy_create(struct ps3_instance *instance, if (ps3_sas_port->remote_identify.device_type == SAS_END_DEVICE) { sas_rphy->identify.target_port_protocols = SAS_PROTOCOL_NONE; - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, - ps3_sas_port->pd_flat_id); + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, ps3_sas_port->pd_flat_id); if (unlikely(pd_entry == NULL)) { - LOG_ERROR("hno:%u cannot find pd entry by pd_flat_id[%d] !\n", + LOG_ERROR( + "hno:%u cannot find pd entry by pd_flat_id[%d] !\n", PS3_HOST(instance), ps3_sas_port->pd_flat_id); goto l_out; } @@ -470,28 +521,34 @@ static S32 ps3_sas_port_rphy_create(struct ps3_instance *instance, ret = sas_rphy_add(sas_rphy); INJECT_START(PS3_ERR_IJ_SAS_PHY_ADD_FAILED, &ret); if (unlikely(ret != 0)) { - LOG_ERROR("hno:%u add SAS rphy for sas_addr[%016llx] failed !\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); + LOG_ERROR( + "hno:%u add SAS rphy for sas_addr[%016llx] failed !\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address); goto l_out; } - ret = ps3_sas_end_device_add_past(instance, ps3_sas_port, pd_entry, sas_rphy); + ret = ps3_sas_end_device_add_past(instance, ps3_sas_port, pd_entry, + sas_rphy); l_out: ps3_sas_port->rphy = sas_rphy; - LOG_DEBUG("hno:%u quit port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", + LOG_DEBUG( + "hno:%u quit port rphy create, type[%d], pdflatid[%d], sas_addr[%016llx]\n", PS3_HOST(instance), ps3_sas_port->remote_identify.device_type, - ps3_sas_port->pd_flat_id, ps3_sas_port->remote_identify.sas_address); + ps3_sas_port->pd_flat_id, + ps3_sas_port->remote_identify.sas_address); return ret; } -struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( - struct ps3_instance *instance, U64 sas_addr) +struct ps3_sas_node * +ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, + unsigned long long sas_addr) { struct ps3_sas_node *ps3_sas_node = NULL; struct ps3_sas_node *ret_node = NULL; - ULong flags = 0; - U8 i = 0; + unsigned long flags = 0; + unsigned char i = 0; for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { if (instance->sas_dev_context.ps3_hba_sas_addr[i] == sas_addr) { @@ -502,109 +559,128 @@ struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, list) { + &instance->sas_dev_context.ps3_sas_node_list, + list) { if (ps3_sas_node->sas_address == sas_addr) { ret_node = ps3_sas_node; break; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); l_out: return ret_node; } static void ps3_sanity_check_clean(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, U64 sas_address, struct ps3_sas_port *sas_port) + struct ps3_sas_node *sas_node, + unsigned long long sas_address, + struct ps3_sas_port *sas_port) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; struct ps3_sas_node *exp_node = NULL; - ULong flags = 0; + unsigned long flags = 0; struct ps3_pd_entry *pd_entry = NULL; list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { - if (ps3_sas_port == sas_port) { + &sas_node->sas_port_list, list) { + if (ps3_sas_port == sas_port) continue; - } list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { + &ps3_sas_port->phy_list, + port_siblings) { if (ps3_sas_phy->remote_identify.sas_address != - sas_address) { + sas_address) { continue; } - LOG_WARN("hno:%u phy[%d] sas_addr[%016llx] == new device SAS addr\n", + LOG_WARN( + "hno:%u phy[%d] sas_addr[%016llx] == new device SAS addr\n", PS3_HOST(instance), ps3_sas_phy->phy_id, ps3_sas_port->remote_identify.sas_address); - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_lock_irqsave( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); list_del(&ps3_sas_phy->port_siblings); ps3_sas_phy->attach_port = NULL; - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); ps3_sas_port->phy_count--; - sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); + sas_port_delete_phy(ps3_sas_port->port, + ps3_sas_phy->phy); } - if (ps3_sas_port->phy_count != 0){ + if (ps3_sas_port->phy_count != 0) continue; - } if (ps3_sas_port->remote_identify.device_type == - SAS_EDGE_EXPANDER_DEVICE || - ps3_sas_port->remote_identify.device_type == - SAS_FANOUT_EXPANDER_DEVICE) { - - exp_node = ps3_sas_find_node_by_sas_addr(instance, + SAS_EDGE_EXPANDER_DEVICE || + ps3_sas_port->remote_identify.device_type == + SAS_FANOUT_EXPANDER_DEVICE) { + exp_node = ps3_sas_find_node_by_sas_addr( + instance, ps3_sas_port->remote_identify.sas_address); if (exp_node == NULL) { - LOG_ERROR("hno:%u cannot find node sas_addr[%016llx] !\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); + LOG_ERROR( + "hno:%u cannot find node sas_addr[%016llx] !\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify + .sas_address); PS3_BUG(); continue; } ps3_sas_expander_node_del(instance, exp_node); - }else if (ps3_sas_port->remote_identify.device_type == - SAS_END_DEVICE) { - - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + } else if (ps3_sas_port->remote_identify.device_type == + SAS_END_DEVICE) { + spin_lock_irqsave( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); - LOG_INFO("hno:%u sas_port pdid[%u] delete start, by r SAS addr[0x%llx], change\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, sas_address); + LOG_INFO( + "hno:%u sas_port pdid[%u] delete start, by r SAS addr[0x%llx], change\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, + sas_address); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) { + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) pd_entry->sas_rphy = NULL; - } - LOG_INFO("hno:%u sas_port pdid[%u] delete end, by r SAS addr[0x%llx], change\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, sas_address); + LOG_INFO( + "hno:%u sas_port pdid[%u] delete end, by r SAS addr[0x%llx], change\n", + PS3_HOST(instance), ps3_sas_port->pd_flat_id, + sas_address); kfree(ps3_sas_port); } } - } -static S32 ps3_sas_port_create(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, struct ps3_sas_port *ps3_sas_port) +static int ps3_sas_port_create(struct ps3_instance *instance, + struct ps3_sas_node *sas_node, + struct ps3_sas_port *ps3_sas_port) { - S32 ret = -PS3_FAILED; - ULong flags = 0; - + int ret = -PS3_FAILED; + unsigned long flags = 0; + ps3_sas_port->port = ps3_sas_sas_port_create(instance, sas_node, - &ps3_sas_port->phy_list); + &ps3_sas_port->phy_list); INJECT_START(PS3_ERR_IJ_SAS_PORT_CREATE_FAIL, ps3_sas_port); if (unlikely(ps3_sas_port->port == NULL)) { LOG_ERROR("hno:%u cannot add port on parent[%d] !\n", - PS3_HOST(instance), sas_node->encl_id); + PS3_HOST(instance), sas_node->encl_id); goto l_out; } @@ -612,14 +688,16 @@ static S32 ps3_sas_port_create(struct ps3_instance *instance, ret = ps3_sas_port_rphy_create(instance, ps3_sas_port); if (unlikely(ret != PS3_SUCCESS)) { LOG_ERROR("hno:%u create rphy[%016llx] on parent[%d] NOK!\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address, + sas_node->encl_id); goto l_failed; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_add_tail(&ps3_sas_port->list, &sas_node->sas_port_list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); goto l_out; l_failed: @@ -632,22 +710,22 @@ static S32 ps3_sas_port_create(struct ps3_instance *instance, } static void ps3_sas_port_del(struct ps3_instance *instance, - struct ps3_sas_port *ps3_sas_port) + struct ps3_sas_port *ps3_sas_port) { struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; - ULong flags = 0; + unsigned long flags = 0; struct ps3_pd_entry *pd_entry = NULL; (void)instance; spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { - + &ps3_sas_port->phy_list, port_siblings) { sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); list_del(&ps3_sas_phy->port_siblings); @@ -656,45 +734,52 @@ static void ps3_sas_port_del(struct ps3_instance *instance, } LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); + PS3_HOST(instance), ps3_sas_port->pd_flat_id, + ps3_sas_port->phy_count); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) { + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, + ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) pd_entry->sas_rphy = NULL; - } LOG_WARN("hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); + PS3_HOST(instance), ps3_sas_port->pd_flat_id, + ps3_sas_port->phy_count); kfree(ps3_sas_port); - } -static S32 ps3_sas_end_device_try_add(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, struct ps3_sas_phy *ps3_phy, - struct ps3_pd_entry *pd_entry) +static int ps3_sas_end_device_try_add(struct ps3_instance *instance, + struct ps3_sas_node *sas_node, + struct ps3_sas_phy *ps3_phy, + struct ps3_pd_entry *pd_entry) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_sas_port *ps3_sas_port = NULL; LOG_DEBUG("hno:%u ready add end device[%016llx] on node[%d]\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); ps3_sas_port = ps3_sas_port_find(instance, sas_node, - ps3_phy->remote_identify.sas_address); + ps3_phy->remote_identify.sas_address); - ps3_sanity_check_clean(instance, sas_node, ps3_phy->remote_identify.sas_address, ps3_sas_port); + ps3_sanity_check_clean(instance, sas_node, + ps3_phy->remote_identify.sas_address, + ps3_sas_port); if (ps3_sas_port != NULL) { LOG_DEBUG("hno:%u find exist port[%016llx] on node[%d]\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), + ps3_phy->remote_identify.sas_address, + sas_node->encl_id); if (ps3_is_sata_end_device(pd_entry) && - ps3_sas_port->pd_flat_id != PS3_PDID(&pd_entry->disk_pos)) { - LOG_INFO("hno:%u sata end device [%u:%u] not exist but in port\n", - PS3_HOST(instance), PS3_CHANNEL(&pd_entry->disk_pos), + ps3_sas_port->pd_flat_id != PS3_PDID(&pd_entry->disk_pos)) { + LOG_INFO( + "hno:%u sata end device [%u:%u] not exist but in port\n", + PS3_HOST(instance), + PS3_CHANNEL(&pd_entry->disk_pos), PS3_TARGET(&pd_entry->disk_pos)); ps3_sas_port_del(instance, ps3_sas_port); ps3_sas_port = NULL; @@ -704,11 +789,12 @@ static S32 ps3_sas_end_device_try_add(struct ps3_instance *instance, } } - ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); + ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc( + instance, sizeof(struct ps3_sas_port)); INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL, &ps3_sas_port); if (ps3_sas_port == NULL) { LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", - PS3_HOST(instance), sas_node->encl_id); + PS3_HOST(instance), sas_node->encl_id); ret = -PS3_FAILED; goto l_out; } @@ -721,8 +807,11 @@ static S32 ps3_sas_end_device_try_add(struct ps3_instance *instance, ps3_sas_port->pd_flat_id = pd_entry->disk_pos.diskDev.ps3Dev.phyDiskID; ret = ps3_sas_port_create(instance, sas_node, ps3_sas_port); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u create end device rphy[%016llx] on parent[%d] NOK!\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, sas_node->encl_id); + LOG_ERROR( + "hno:%u create end device rphy[%016llx] on parent[%d] NOK!\n", + PS3_HOST(instance), + ps3_phy->remote_identify.sas_address, + sas_node->encl_id); goto l_failed; } pd_entry->sas_rphy = ps3_sas_port->rphy; @@ -735,19 +824,20 @@ static S32 ps3_sas_end_device_try_add(struct ps3_instance *instance, l_out: LOG_DEBUG("hno:%u add end device[%016llx] on node[%d] end\n", - PS3_HOST(instance), ps3_phy->remote_identify.sas_address, - sas_node->encl_id); + PS3_HOST(instance), ps3_phy->remote_identify.sas_address, + sas_node->encl_id); return ret; } -static S32 ps3_sas_node_all_phys_add(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) +static int ps3_sas_node_all_phys_add(struct ps3_instance *instance, + struct ps3_sas_node *sas_node) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; - U8 i = 0; + struct PS3PhyInfo *phy_info = + instance->sas_dev_context.ps3_sas_phy_buff; + unsigned char i = 0; memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; @@ -760,47 +850,30 @@ static S32 ps3_sas_node_all_phys_add(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR1, &ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u get encl[%d] all phys info NOK\n", - PS3_HOST(instance), sas_req_param.enclID); + PS3_HOST(instance), sas_req_param.enclID); goto l_out; } for (i = 0; i < sas_node->phy_count; i++) { ret = ps3_sas_node_phy_add(instance, &sas_node->phys[i], - sas_node, &phy_info[i]); + sas_node, &phy_info[i]); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u add node[%d]-phys[%d] NOK !\n", - PS3_HOST(instance), sas_node->encl_id, i); + PS3_HOST(instance), sas_node->encl_id, i); goto l_out; } -#if 0 - 不能再此添加,需要通过scsi那边进行添加,否则无法定序,分配正确的channel - if ((phy_info[i].attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR && - phy_info[i].attachDevType == SAS_END_DEVICE) && - phy_info[i].attachedSasAddr != - sas_node->parent_sas_address) { - ret = ps3_sas_end_device_try_add(instance, sas_node, - &sas_node->phys[i]); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add end device[%016llx] on node[%d]-phys[%d] failed !\n", - PS3_HOST(instance), - phy_info[i].attachedSasAddr, - sas_node->encl_id, i); - goto l_out; - } - } -#endif } l_out: return ret; } -static S32 ps3_sas_hba_node_init(struct ps3_instance *instance, - struct PS3ExpanderInfo *exp_info, U64 *hba_sas_addr) +static int ps3_sas_hba_node_init(struct ps3_instance *instance, + struct PS3ExpanderInfo *exp_info, + unsigned long long *hba_sas_addr) { - S32 ret = PS3_SUCCESS; - U8 i = 0; - struct ps3_sas_node *hba_node = - &instance->sas_dev_context.ps3_hba_sas; + int ret = PS3_SUCCESS; + unsigned char i = 0; + struct ps3_sas_node *hba_node = &instance->sas_dev_context.ps3_hba_sas; LOG_DEBUG("hno:%u enter !\n", PS3_HOST(instance)); @@ -808,8 +881,8 @@ static S32 ps3_sas_hba_node_init(struct ps3_instance *instance, instance->sas_dev_context.ps3_hba_sas_addr[i] = le64_to_cpu(hba_sas_addr[i]); LOG_INFO("hno:%u hba SAS addr[%d] is [%016llx] !\n", - PS3_HOST(instance), i, - instance->sas_dev_context.ps3_hba_sas_addr[i]); + PS3_HOST(instance), i, + instance->sas_dev_context.ps3_hba_sas_addr[i]); } hba_node->encl_id = exp_info->enclID; @@ -817,23 +890,23 @@ static S32 ps3_sas_hba_node_init(struct ps3_instance *instance, hba_node->dev_type = exp_info->devType; LOG_INFO("hno:%u hba encl_id[%d], phy_count[%d], dev_type[%d] !\n", - PS3_HOST(instance), hba_node->encl_id, hba_node->phy_count, - hba_node->dev_type); + PS3_HOST(instance), hba_node->encl_id, hba_node->phy_count, + hba_node->dev_type); if (hba_node->phys == NULL) { - hba_node->phys = (struct ps3_sas_phy*)ps3_kcalloc(instance, hba_node->phy_count, + hba_node->phys = (struct ps3_sas_phy *)ps3_kcalloc( + instance, hba_node->phy_count, sizeof(struct ps3_sas_phy)); } if (hba_node->phys == NULL) { LOG_ERROR("hno:%u alloc hba phys buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_sas_node_all_phys_add(instance, hba_node); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hba add phys NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u hba add phys NOK !\n", PS3_HOST(instance)); goto l_out; } @@ -842,55 +915,62 @@ static S32 ps3_sas_hba_node_init(struct ps3_instance *instance, return ret; } -static struct ps3_sas_node* ps3_sas_find_node_by_id(struct ps3_instance *instance, - U8 encl_id) +static struct ps3_sas_node * +ps3_sas_find_node_by_id(struct ps3_instance *instance, unsigned char encl_id) { struct ps3_sas_node *ps3_sas_node = NULL; - ULong flags = 0; + unsigned long flags = 0; - if (instance->sas_dev_context.ps3_hba_sas.encl_id == encl_id) { + if (instance->sas_dev_context.ps3_hba_sas.encl_id == encl_id) return &instance->sas_dev_context.ps3_hba_sas; - } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_for_each_entry(ps3_sas_node, - &instance->sas_dev_context.ps3_sas_node_list, list) { + &instance->sas_dev_context.ps3_sas_node_list, + list) { if (ps3_sas_node->encl_id == encl_id) { - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, + flags); return ps3_sas_node; } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); return NULL; } -static struct ps3_sas_port* ps3_sas_expander_parent_attach(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) +static struct ps3_sas_port * +ps3_sas_expander_parent_attach(struct ps3_instance *instance, + struct ps3_sas_node *exp_node) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_sas_node *parent_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - U8 i = 0; - ULong flags = 0; - Bool is_exist_port = PS3_TRUE; + unsigned char i = 0; + unsigned long flags = 0; + unsigned char is_exist_port = PS3_TRUE; struct ps3_sas_phy *sas_phy = NULL; struct ps3_sas_phy *sas_phy_next = NULL; - parent_node = ps3_sas_find_node_by_id(instance, - exp_node->parent_encl_id); + parent_node = + ps3_sas_find_node_by_id(instance, exp_node->parent_encl_id); if (parent_node == NULL) { LOG_ERROR("hno:%u cannot find parent node[%d] !\n", - PS3_HOST(instance), exp_node->parent_encl_id); + PS3_HOST(instance), exp_node->parent_encl_id); goto l_out; } - ps3_sas_port = ps3_sas_port_find(instance, parent_node, exp_node->sas_address); + ps3_sas_port = + ps3_sas_port_find(instance, parent_node, exp_node->sas_address); if (ps3_sas_port == NULL) { - ps3_sas_port = (struct ps3_sas_port*)ps3_kzalloc(instance, sizeof(struct ps3_sas_port)); + ps3_sas_port = (struct ps3_sas_port *)ps3_kzalloc( + instance, sizeof(struct ps3_sas_port)); INJECT_START(PS3_ERR_IJ_SAS_PORT_ALLOC_NULL1, &ps3_sas_port); if (ps3_sas_port == NULL) { - LOG_ERROR("hno:%u alloc PS3 port on node[%d] failed !\n", + LOG_ERROR( + "hno:%u alloc PS3 port on node[%d] failed !\n", PS3_HOST(instance), parent_node->encl_id); goto l_out; } @@ -898,39 +978,44 @@ static struct ps3_sas_port* ps3_sas_expander_parent_attach(struct ps3_instance * is_exist_port = PS3_FALSE; } - ps3_sanity_check_clean(instance, parent_node, exp_node->sas_address, ps3_sas_port); + ps3_sanity_check_clean(instance, parent_node, exp_node->sas_address, + ps3_sas_port); spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); for (i = 0; i < parent_node->phy_count; i++) { if ((parent_node->phys[i].remote_identify.sas_address == - exp_node->sas_address) && - (parent_node->phys[i].attach_port == NULL)) { + exp_node->sas_address) && + (parent_node->phys[i].attach_port == NULL)) { if (ps3_sas_port->phy_count == 0) { ps3_sas_port->remote_identify = parent_node->phys[i].remote_identify; } list_add_tail(&parent_node->phys[i].port_siblings, - &ps3_sas_port->phy_list); + &ps3_sas_port->phy_list); parent_node->phys[i].attach_port = ps3_sas_port; ps3_sas_port->phy_count++; if (is_exist_port && ps3_sas_port->port != NULL) { - sas_port_add_phy(ps3_sas_port->port, parent_node->phys[i].phy); + sas_port_add_phy(ps3_sas_port->port, + parent_node->phys[i].phy); } } } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); if (!is_exist_port) { if (ps3_sas_port->phy_count == 0) { LOG_ERROR("hno:%u cannot find phy in parent[%d] !\n", - PS3_HOST(instance), parent_node->encl_id); + PS3_HOST(instance), parent_node->encl_id); goto l_failed; } ret = ps3_sas_port_create(instance, parent_node, ps3_sas_port); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u create rphy on parent[%d] for exp[%d] !\n", - PS3_HOST(instance), parent_node->encl_id, exp_node->encl_id); + LOG_ERROR( + "hno:%u create rphy on parent[%d] for exp[%d] !\n", + PS3_HOST(instance), parent_node->encl_id, + exp_node->encl_id); goto l_failed; } @@ -941,7 +1026,7 @@ static struct ps3_sas_port* ps3_sas_expander_parent_attach(struct ps3_instance * l_failed: list_for_each_entry_safe(sas_phy, sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { + &ps3_sas_port->phy_list, port_siblings) { sas_phy->attach_port = NULL; list_del(&sas_phy->port_siblings); } @@ -950,27 +1035,27 @@ static struct ps3_sas_port* ps3_sas_expander_parent_attach(struct ps3_instance * return NULL; } -static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, - struct PS3ExpanderInfo *exp_info) +static int ps3_sas_expander_node_add(struct ps3_instance *instance, + struct PS3ExpanderInfo *exp_info) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_sas_node *exp_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - Bool is_exist_expander = PS3_TRUE; - ULong flags = 0; - U8 old_parent_id = PS3_SAS_INVALID_ID; + unsigned char is_exist_expander = PS3_TRUE; + unsigned long flags = 0; + unsigned char old_parent_id = PS3_SAS_INVALID_ID; LOG_DEBUG("hno:%u enter !\n", PS3_HOST(instance)); - - if ((exp_node = ps3_sas_find_node_by_id(instance, exp_info->enclID)) != NULL && - unlikely(exp_node->parent_sas_address != exp_info->parentSasAddr || - exp_node->parent_encl_id != exp_info->parentId)) { - LOG_WARN("hno:%u SAS node encl_id[%d], change place, " - "parent sas_addr old[0x%016llx]-new[0x%016llx], parent_encl_id old[%d]=new[%d]\n", + exp_node = ps3_sas_find_node_by_id(instance, exp_info->enclID); + if (exp_node != NULL && + unlikely(exp_node->parent_sas_address != exp_info->parentSasAddr || + exp_node->parent_encl_id != exp_info->parentId)) { + LOG_WARN( + "hno:%u SAS node encl_id[%d], change place\n" + "\tpar_sas_addr old[0x%016llx]-new[0x%016llx], par_encl_id old[%d]=new[%d]\n", PS3_HOST(instance), exp_info->enclID, - exp_node->parent_sas_address, - exp_info->parentSasAddr, exp_node->parent_encl_id, - exp_info->parentId); + exp_node->parent_sas_address, exp_info->parentSasAddr, + exp_node->parent_encl_id, exp_info->parentId); old_parent_id = exp_node->parent_encl_id; ps3_sas_expander_node_del(instance, exp_node); ps3_sas_expander_event_update(instance, old_parent_id); @@ -978,11 +1063,12 @@ static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, } if (exp_node == NULL) { - exp_node = (struct ps3_sas_node*)ps3_kzalloc(instance, sizeof(struct ps3_sas_node)); + exp_node = (struct ps3_sas_node *)ps3_kzalloc( + instance, sizeof(struct ps3_sas_node)); INJECT_START(PS3_ERR_IJ_ALLOC_EXP_NODE_NULL, &exp_node); if (exp_node == NULL) { LOG_ERROR("hno:%u alloc node[%d] failed !\n", - PS3_HOST(instance), exp_info->enclID); + PS3_HOST(instance), exp_info->enclID); goto l_out; } @@ -991,31 +1077,33 @@ static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, exp_node->phy_count = exp_info->phyCount; exp_node->dev_type = exp_info->devType; exp_node->parent_encl_id = exp_info->parentId; - exp_node->parent_sas_address = le64_to_cpu(exp_info->parentSasAddr); + exp_node->parent_sas_address = + le64_to_cpu(exp_info->parentSasAddr); - exp_node->phys = (struct ps3_sas_phy*)ps3_kcalloc(instance, exp_node->phy_count, + exp_node->phys = (struct ps3_sas_phy *)ps3_kcalloc( + instance, exp_node->phy_count, sizeof(struct ps3_sas_phy)); INJECT_START(PS3_ERR_IJ_ALLOC_EXP_PHYS_NULL, &exp_node->phys); if (exp_node->phys == NULL) { LOG_ERROR("hno:%u alloc exp[%d] phys buffer failed !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); goto l_failed; } INIT_LIST_HEAD(&exp_node->sas_port_list); is_exist_expander = PS3_FALSE; } - LOG_INFO("hno:%u ready add exp_node sas_address[0x%016llx]," - " encl_id[%d], phy_count[%d], parent_encl_id[%d]," - " parent_sas_address[0x%016llx] !\n", - PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, - exp_node->phy_count, exp_node->parent_encl_id, - exp_node->parent_sas_address); + LOG_INFO("hno:%u ready add exp_node sas_address[0x%016llx]\n" + "\tencl_id[%d], phy_count[%d], parent_encl_id[%d]\n" + "\tparent_sas_address[0x%016llx] !\n", + PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, + exp_node->phy_count, exp_node->parent_encl_id, + exp_node->parent_sas_address); ps3_sas_port = ps3_sas_expander_parent_attach(instance, exp_node); if (ps3_sas_port == NULL) { LOG_ERROR("hno:%u attch exp[%d] on parent NOK !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); ret = -PS3_FAILED; goto l_failed; } @@ -1023,19 +1111,23 @@ static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, ret = ps3_sas_node_all_phys_add(instance, exp_node); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u expander[%d] add phys NOK !\n", - PS3_HOST(instance), exp_node->encl_id); + PS3_HOST(instance), exp_node->encl_id); goto l_failed; } - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - list_add_tail(&exp_node->list,&instance->sas_dev_context.ps3_sas_node_list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_WARN("hno:%u add exp_node sas_address[0x%016llx]," - " encl_id[%d], phy_count[%d], parent_encl_id[%d]," - " parent_sas_address[0x%016llx] end!\n", - PS3_HOST(instance), exp_node->sas_address, exp_node->encl_id, - exp_node->phy_count, exp_node->parent_encl_id, - exp_node->parent_sas_address); + spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, + flags); + list_add_tail(&exp_node->list, + &instance->sas_dev_context.ps3_sas_node_list); + spin_unlock_irqrestore( + &instance->sas_dev_context.ps3_sas_node_lock, flags); + LOG_WARN("hno:%u add exp_node sas_address[0x%016llx]\n" + "\tencl_id[%d], phy_count[%d], parent_encl_id[%d]\n" + "\tparent_sas_address[0x%016llx] end!\n", + PS3_HOST(instance), exp_node->sas_address, + exp_node->encl_id, exp_node->phy_count, + exp_node->parent_encl_id, + exp_node->parent_sas_address); } goto l_out; @@ -1060,19 +1152,20 @@ static S32 ps3_sas_expander_node_add(struct ps3_instance *instance, } static void ps3_sas_expander_del_list_build(struct ps3_instance *instance, - struct list_head *node_del_list) + struct list_head *node_del_list) { struct ps3_sas_node *exp_node = NULL; struct ps3_sas_node *child_exp_node = NULL; struct ps3_sas_port *ps3_sas_port = NULL; - ULong flags = 0; + unsigned long flags = 0; list_for_each_entry(exp_node, node_del_list, list) { - list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, list) { + list_for_each_entry(ps3_sas_port, &exp_node->sas_port_list, + list) { if ((ps3_sas_port->remote_identify.device_type != - SAS_EDGE_EXPANDER_DEVICE) && - (ps3_sas_port->remote_identify.device_type != - SAS_FANOUT_EXPANDER_DEVICE)) { + SAS_EDGE_EXPANDER_DEVICE) && + (ps3_sas_port->remote_identify.device_type != + SAS_FANOUT_EXPANDER_DEVICE)) { continue; } @@ -1080,26 +1173,28 @@ static void ps3_sas_expander_del_list_build(struct ps3_instance *instance, instance, ps3_sas_port->remote_identify.sas_address); if (child_exp_node != NULL) { - spin_lock_irqsave(&instance->sas_dev_context. - ps3_sas_node_lock, flags); + spin_lock_irqsave(&instance->sas_dev_context + .ps3_sas_node_lock, + flags); list_move_tail(&child_exp_node->list, - node_del_list); - spin_unlock_irqrestore(&instance->sas_dev_context. - ps3_sas_node_lock, flags); + node_del_list); + spin_unlock_irqrestore( + &instance->sas_dev_context + .ps3_sas_node_lock, + flags); } } } } static void ps3_sas_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) + struct ps3_sas_node *exp_node) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *tmp_port = NULL; list_for_each_entry_safe(ps3_sas_port, tmp_port, - &exp_node->sas_port_list, list) { - + &exp_node->sas_port_list, list) { ps3_sas_port_del(instance, ps3_sas_port); ps3_sas_port = NULL; } @@ -1107,15 +1202,17 @@ static void ps3_sas_node_del(struct ps3_instance *instance, kfree(exp_node->phys); } -static S32 ps3_sas_node_port_del(struct ps3_instance *instance, - struct ps3_sas_node *parent_node, U64 sas_addr) +static int ps3_sas_node_port_del(struct ps3_instance *instance, + struct ps3_sas_node *parent_node, + unsigned long long sas_addr) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_sas_port *ps3_port = NULL; + ps3_port = ps3_sas_port_find(instance, parent_node, sas_addr); if (ps3_port == NULL) { LOG_ERROR("hno:%u cannot find port[%016llx] in node[%d] !\n", - PS3_HOST(instance), sas_addr, parent_node->encl_id); + PS3_HOST(instance), sas_addr, parent_node->encl_id); ret = -PS3_FAILED; goto l_out; } @@ -1127,24 +1224,27 @@ static S32 ps3_sas_node_port_del(struct ps3_instance *instance, } void ps3_sas_expander_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node) + struct ps3_sas_node *exp_node) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_sas_node *parent_node = NULL; struct ps3_sas_node *del_exp_node = NULL; struct ps3_sas_node *tmp_exp_node = NULL; - struct list_head node_del_list = {NULL, NULL}; - U64 sas_address = exp_node->sas_address; - ULong flags = 0; + struct list_head node_del_list = { NULL, NULL }; + unsigned long long sas_address = exp_node->sas_address; + unsigned long flags = 0; - LOG_INFO("hno:%u enter !, encl_id[%d], parent_id[%d], sas_addr[%016llx]\n", PS3_HOST(instance), - exp_node->encl_id, exp_node->parent_encl_id, exp_node->sas_address); + LOG_INFO( + "hno:%u enter !, encl_id[%d], parent_id[%d], sas_addr[%016llx]\n", + PS3_HOST(instance), exp_node->encl_id, exp_node->parent_encl_id, + exp_node->sas_address); - parent_node = ps3_sas_find_node_by_id(instance, - exp_node->parent_encl_id); + parent_node = + ps3_sas_find_node_by_id(instance, exp_node->parent_encl_id); if (parent_node == NULL) { LOG_ERROR("hno:%u cannot find parent node[%d] !\n", - PS3_HOST(instance), exp_node->parent_encl_id); + + PS3_HOST(instance), exp_node->parent_encl_id); BUG(); goto l_out; } @@ -1152,27 +1252,28 @@ void ps3_sas_expander_node_del(struct ps3_instance *instance, INIT_LIST_HEAD(&node_del_list); spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); list_move_tail(&exp_node->list, &node_del_list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); ps3_sas_expander_del_list_build(instance, &node_del_list); list_for_each_entry_safe_reverse(del_exp_node, tmp_exp_node, - &node_del_list, list) { - LOG_DEBUG("hno:%u remove encl_id[%d], sas_addr[%016llx]\n", PS3_HOST(instance), - del_exp_node->encl_id, del_exp_node->sas_address); + &node_del_list, list) { + LOG_DEBUG("hno:%u remove encl_id[%d], sas_addr[%016llx]\n", + PS3_HOST(instance), del_exp_node->encl_id, + del_exp_node->sas_address); ps3_sas_node_del(instance, del_exp_node); list_del(&del_exp_node->list); kfree(del_exp_node); } - LOG_WARN("hno:%u remove sas_addr[%016llx] from parent[%d]\n", PS3_HOST(instance), - sas_address, parent_node->encl_id); + LOG_WARN("hno:%u remove sas_addr[%016llx] from parent[%d]\n", + PS3_HOST(instance), sas_address, parent_node->encl_id); - ret = ps3_sas_node_port_del(instance, parent_node, - sas_address); + ret = ps3_sas_node_port_del(instance, parent_node, sas_address); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u cannot delete expander[%016llx] from parent[%d] !\n", - PS3_HOST(instance), sas_address, - parent_node->encl_id); + LOG_ERROR( + "hno:%u cannot delete expander[%016llx] from parent[%d] !\n", + PS3_HOST(instance), sas_address, parent_node->encl_id); BUG(); goto l_out; } @@ -1180,72 +1281,68 @@ void ps3_sas_expander_node_del(struct ps3_instance *instance, LOG_DEBUG("hno:%u quit !\n", PS3_HOST(instance)); } -S32 ps3_sas_device_data_init(struct ps3_instance *instance) +int ps3_sas_device_data_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct PS3Expanders *p_expanders = (struct PS3Expanders *)instance->sas_dev_context.ps3_sas_buff; struct PS3ExpanderInfo *exp_info = p_expanders->expanders; - U8 i = 0; + unsigned char i = 0; - if (!ps3_sas_is_support_smp(instance)) { + if (!ps3_sas_is_support_smp(instance)) goto l_out; - } - LOG_DEBUG("hno:%u ready get init expander enter\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready get init expander enter\n", PS3_HOST(instance)); memset(p_expanders, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_all_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); goto l_out; } - LOG_INFO("hno:%u get expander list count[%d]\n", - PS3_HOST(instance), p_expanders->count); + LOG_INFO("hno:%u get expander list count[%d]\n", PS3_HOST(instance), + p_expanders->count); INJECT_START(PS3_ERR_HBA_PHY_COUNT_ZERO, &p_expanders->count); if (p_expanders->count == 0) { LOG_ERROR("hno:%u expander init info count = 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; - goto l_out;; + goto l_out; + ; } - ret = ps3_sas_hba_node_init(instance, exp_info, p_expanders->hbaSasAddr); + ret = ps3_sas_hba_node_init(instance, exp_info, + p_expanders->hbaSasAddr); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init hba info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u init hba info NOK\n", PS3_HOST(instance)); goto l_out; } for (i = 1; i < p_expanders->count; i++) { - if (ps3_sas_expander_node_add(instance, &exp_info[i]) != PS3_SUCCESS) { + if (ps3_sas_expander_node_add(instance, &exp_info[i]) != + PS3_SUCCESS) { LOG_WARN("hno:%u init add expander[%d] info NOK\n", - PS3_HOST(instance), exp_info[i].enclID); + PS3_HOST(instance), exp_info[i].enclID); } } - LOG_DEBUG("hno:%u SAS init end\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS init end\n", PS3_HOST(instance)); l_out: - return ret ; + return ret; } -S32 ps3_sas_device_data_exit(struct ps3_instance *instance) +int ps3_sas_device_data_exit(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - if (!ps3_sas_is_support_smp(instance)) { + if (!ps3_sas_is_support_smp(instance)) goto l_out; - } - LOG_INFO("hno:%u ps3_sas_device_data_exit\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u %s\n", PS3_HOST(instance), __func__); (void)instance; @@ -1253,17 +1350,17 @@ S32 ps3_sas_device_data_exit(struct ps3_instance *instance) return ret; } -static S32 ps3_sas_expander_dma_buf_alloc(struct ps3_instance *instance) +static int ps3_sas_expander_dma_buf_alloc(struct ps3_instance *instance) { struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; - ps3_sas_ctx->ps3_sas_buff = ps3_dma_alloc_coherent(instance, - PS3_SAS_REQ_BUFF_LEN, - &ps3_sas_ctx->ps3_sas_buff_dma_addr); + ps3_sas_ctx->ps3_sas_buff = ps3_dma_alloc_coherent( + instance, PS3_SAS_REQ_BUFF_LEN, + (unsigned long long *)&ps3_sas_ctx->ps3_sas_buff_dma_addr); INJECT_START(PS3_ERR_IJ_PS3_SAS_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_buff); if (ps3_sas_ctx->ps3_sas_buff == NULL) { LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -1277,25 +1374,27 @@ static void ps3_sas_expander_dma_buf_free(struct ps3_instance *instance) if (ps3_sas_ctx->ps3_sas_buff != NULL) { ps3_dma_free_coherent(instance, PS3_SAS_REQ_BUFF_LEN, - ps3_sas_ctx->ps3_sas_buff, - ps3_sas_ctx->ps3_sas_buff_dma_addr); + ps3_sas_ctx->ps3_sas_buff, + ps3_sas_ctx->ps3_sas_buff_dma_addr); ps3_sas_ctx->ps3_sas_buff = NULL; } } -static S32 ps3_sas_phy_dma_buf_alloc(struct ps3_instance *instance) +static int ps3_sas_phy_dma_buf_alloc(struct ps3_instance *instance) { struct ps3_sas_dev_context *ps3_sas_ctx = &instance->sas_dev_context; ps3_sas_ctx->ps3_sas_phy_buff = - (struct PS3PhyInfo *)ps3_dma_alloc_coherent(instance, - PS3_SAS_REQ_BUFF_LEN, - &ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); - INJECT_START(PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, &ps3_sas_ctx->ps3_sas_phy_buff); + (struct PS3PhyInfo *)ps3_dma_alloc_coherent( + instance, PS3_SAS_REQ_BUFF_LEN, + (unsigned long long *)&ps3_sas_ctx + ->ps3_sas_phy_buff_dma_addr); + INJECT_START(PS3_ERR_IJ_PS3_SAS_PHY_BUF_ALLOC, + &ps3_sas_ctx->ps3_sas_phy_buff); if (ps3_sas_ctx->ps3_sas_phy_buff == NULL) { LOG_ERROR("hno:%u alloc SAS req buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -1309,17 +1408,17 @@ static void ps3_sas_phy_dma_buf_free(struct ps3_instance *instance) if (ps3_sas_ctx->ps3_sas_phy_buff != NULL) { ps3_dma_free_coherent(instance, PS3_SAS_REQ_BUFF_LEN, - ps3_sas_ctx->ps3_sas_phy_buff, - ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); + ps3_sas_ctx->ps3_sas_phy_buff, + ps3_sas_ctx->ps3_sas_phy_buff_dma_addr); ps3_sas_ctx->ps3_sas_phy_buff = NULL; } } -S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) +int ps3_sas_device_mgr_init(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - U8 i = 0; + int ret = -PS3_FAILED; + unsigned char i = 0; if (instance->ioc_adpter->sas_transport_get != NULL) { instance->sas_dev_context.is_support_smp = PS3_TRUE; @@ -1327,7 +1426,7 @@ S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) instance->sas_dev_context.is_support_smp = PS3_FALSE; ret = PS3_SUCCESS; LOG_INFO("hno:%u the IOC is not support SAS expander !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1336,14 +1435,14 @@ S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) ret = ps3_sas_expander_dma_buf_alloc(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u alloc SAS expander dma buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_sas_phy_dma_buf_alloc(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u alloc SAS phy dma buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -1351,7 +1450,7 @@ S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) spin_lock_init(&instance->sas_dev_context.ps3_sas_node_lock); memset(&instance->sas_dev_context.ps3_hba_sas, 0, - sizeof(struct ps3_sas_node)); + sizeof(struct ps3_sas_node)); for (i = 0; i < PS3_SAS_HBA_MAX_SAS_NUM; i++) { instance->sas_dev_context.ps3_hba_sas_addr[i] = @@ -1366,10 +1465,10 @@ S32 ps3_sas_device_mgr_init(struct ps3_instance *instance) instance->sas_dev_context.ps3_hba_sas.dev = &instance->host->shost_gendev; l_out: - return ret ; + return ret; } -S32 ps3_sas_device_mgr_exit(struct ps3_instance *instance) +int ps3_sas_device_mgr_exit(struct ps3_instance *instance) { if (ps3_sas_is_support_smp(instance)) { ps3_sas_phy_dma_buf_free(instance); @@ -1381,39 +1480,55 @@ S32 ps3_sas_device_mgr_exit(struct ps3_instance *instance) static void ps3_sas_end_dev_del(struct ps3_instance *instance, - struct ps3_sas_node* parent_node, U8 phy_id) + struct ps3_sas_node *parent_node, + unsigned char phy_id) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; - Bool del_finish = PS3_FALSE; - ULong flags = 0; + unsigned char del_finish = PS3_FALSE; + unsigned long flags = 0; struct ps3_pd_entry *pd_entry = NULL; (void)instance; - list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, &parent_node->sas_port_list, list) { - list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, &ps3_sas_port->phy_list, port_siblings) { + list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, + &parent_node->sas_port_list, list) { + list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, + &ps3_sas_port->phy_list, + port_siblings) { if (likely(ps3_sas_phy->phy_id == phy_id)) { - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_lock_irqsave(&instance->sas_dev_context + .ps3_sas_node_lock, + flags); list_del(&ps3_sas_phy->port_siblings); ps3_sas_phy->attach_port = NULL; - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context + .ps3_sas_node_lock, + flags); - sas_port_delete_phy(ps3_sas_port->port, ps3_sas_phy->phy); + sas_port_delete_phy(ps3_sas_port->port, + ps3_sas_phy->phy); ps3_sas_port->phy_count--; - LOG_DEBUG("hno:%u sas_port pdid[%u] phy_count[%u] -> " - "encl[%u] phy_id[%u] sas_addr[%016llx] sas_remote_addr[%016llx] sas_phy delete\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count, - ps3_sas_phy->encl_id, ps3_sas_phy->phy_id, + LOG_DEBUG( + "hno:%u sas_port pdid[%u] phy_count[%u]\n" + "\tencl[%u] phy_id[%u] sas_addr[%016llx]\n" + "\tsas_remote_addr[%016llx] sas_phy delete\n", + PS3_HOST(instance), + ps3_sas_port->pd_flat_id, + ps3_sas_port->phy_count, + ps3_sas_phy->encl_id, + ps3_sas_phy->phy_id, ps3_sas_phy->identify.sas_address, - ps3_sas_phy->remote_identify.sas_address); + ps3_sas_phy->remote_identify + .sas_address); memset(&ps3_sas_phy->remote_identify, 0, - sizeof(struct sas_identify)); + sizeof(struct sas_identify)); del_finish = PS3_TRUE; break; } @@ -1421,22 +1536,33 @@ static void ps3_sas_end_dev_del(struct ps3_instance *instance, if (del_finish == PS3_TRUE) { if (ps3_sas_port->phy_count == 0) { - spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_lock_irqsave(&instance->sas_dev_context + .ps3_sas_node_lock, + flags); list_del(&ps3_sas_port->list); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore( + &instance->sas_dev_context + .ps3_sas_node_lock, + flags); - LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); + LOG_INFO( + "hno:%u sas_port pdid[%u] phy_count[%u] delete start\n", + PS3_HOST(instance), + ps3_sas_port->pd_flat_id, + ps3_sas_port->phy_count); sas_port_delete(ps3_sas_port->port); - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, ps3_sas_port->pd_flat_id); - if (pd_entry != NULL) { + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, ps3_sas_port->pd_flat_id); + if (pd_entry != NULL) pd_entry->sas_rphy = NULL; - } - LOG_INFO("hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", - PS3_HOST(instance), ps3_sas_port->pd_flat_id, ps3_sas_port->phy_count); + LOG_INFO( + "hno:%u sas_port pdid[%u] phy_count[%u] delete end\n", + PS3_HOST(instance), + ps3_sas_port->pd_flat_id, + ps3_sas_port->phy_count); kfree(ps3_sas_port); } @@ -1445,15 +1571,14 @@ static void ps3_sas_end_dev_del(struct ps3_instance *instance, } } -static Bool ps3_sas_addr_is_exist( - struct PS3Expanders *p_expanders, U64 sas_addr) +static unsigned char ps3_sas_addr_is_exist(struct PS3Expanders *p_expanders, + unsigned long long sas_addr) { - Bool ret = PS3_FALSE; - U8 i = 0; + unsigned char ret = PS3_FALSE; + unsigned char i = 0; - if (p_expanders == NULL) { + if (p_expanders == NULL) goto l_out; - } for (i = 1; i < p_expanders->count; i++) { if (p_expanders->expanders[i].sasAddr == sas_addr) { ret = PS3_TRUE; @@ -1465,237 +1590,244 @@ static Bool ps3_sas_addr_is_exist( } static void ps3_sas_expander_port_clean(struct ps3_instance *instance, - struct ps3_sas_node *sas_node, struct PS3Expanders *p_expanders) + struct ps3_sas_node *sas_node, + struct PS3Expanders *p_expanders) { struct ps3_sas_port *ps3_sas_port = NULL; struct ps3_sas_port *ps3_sas_port_next = NULL; struct ps3_sas_phy *ps3_sas_phy = NULL; struct ps3_sas_phy *ps3_sas_phy_next = NULL; struct ps3_sas_node *exp_node = NULL; - Bool is_exist = PS3_FALSE; - U8 diff_phy_num = 0; + unsigned char is_exist = PS3_FALSE; + unsigned char diff_phy_num = 0; list_for_each_entry_safe(ps3_sas_port, ps3_sas_port_next, - &sas_node->sas_port_list, list) { + &sas_node->sas_port_list, list) { if (ps3_sas_port->remote_identify.device_type != - SAS_EDGE_EXPANDER_DEVICE && - ps3_sas_port->remote_identify.device_type != - SAS_FANOUT_EXPANDER_DEVICE) { + SAS_EDGE_EXPANDER_DEVICE && + ps3_sas_port->remote_identify.device_type != + SAS_FANOUT_EXPANDER_DEVICE) { continue; } - is_exist = ps3_sas_addr_is_exist(p_expanders, ps3_sas_port->remote_identify.sas_address); + is_exist = ps3_sas_addr_is_exist( + p_expanders, ps3_sas_port->remote_identify.sas_address); diff_phy_num = ps3_sas_port->phy_count; list_for_each_entry_safe(ps3_sas_phy, ps3_sas_phy_next, - &ps3_sas_port->phy_list, port_siblings) { - + &ps3_sas_port->phy_list, + port_siblings) { if ((ps3_sas_phy->remote_identify.sas_address == - ps3_sas_port->remote_identify.sas_address) || - (ps3_sas_phy->remote_identify.sas_address == 0 && is_exist)) { + ps3_sas_port->remote_identify.sas_address) || + (ps3_sas_phy->remote_identify.sas_address == 0 && + is_exist)) { continue; } diff_phy_num--; - LOG_WARN("hno:%u phy[%d]'s remote " - "addr[%016llx] != expander " - "port's rphy addr[0x%016llx]!\n", - PS3_HOST(instance), ps3_sas_phy->phy_id, - ps3_sas_phy->remote_identify.sas_address, - ps3_sas_port->remote_identify.sas_address); + LOG_WARN("hno:%u phy[%d]'s remote addr[%016llx] != expander\n" + "\tport's rphy addr[0x%016llx]!\n", + PS3_HOST(instance), ps3_sas_phy->phy_id, + ps3_sas_phy->remote_identify.sas_address, + ps3_sas_port->remote_identify.sas_address); } - if (diff_phy_num != 0) { + if (diff_phy_num != 0) continue; - } - exp_node = ps3_sas_find_node_by_sas_addr(instance, - ps3_sas_port->remote_identify.sas_address); + exp_node = ps3_sas_find_node_by_sas_addr( + instance, ps3_sas_port->remote_identify.sas_address); if (exp_node == NULL) { - LOG_ERROR("hno:%u cannot find node sas_addr[%016llx] !\n", - PS3_HOST(instance), ps3_sas_port->remote_identify.sas_address); + LOG_ERROR( + "hno:%u cannot find node sas_addr[%016llx] !\n", + PS3_HOST(instance), + ps3_sas_port->remote_identify.sas_address); PS3_BUG(); } else { - LOG_INFO("hno:%u del expander in sas port clean. encl_id[%d], sas_addr[%016llx]\n", - PS3_HOST(instance), exp_node->encl_id, exp_node->sas_address); + LOG_INFO( + "hno:%u del expander in sas port clean. encl_id[%d], sas_addr[%016llx]\n", + PS3_HOST(instance), exp_node->encl_id, + exp_node->sas_address); ps3_sas_expander_node_del(instance, exp_node); } } } -S32 ps3_sas_expander_phys_refresh(struct ps3_instance *instance, - struct ps3_sas_node *sas_node) +static int ps3_sas_expander_phys_refresh(struct ps3_instance *instance, + struct ps3_sas_node *sas_node) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; - U8 i = 0; - ULong flags = 0; + struct PS3PhyInfo *phy_info = + instance->sas_dev_context.ps3_sas_phy_buff; + unsigned char i = 0; + unsigned long flags = 0; memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = 0; sas_req_param.phyCount = sas_node->phy_count; LOG_DEBUG("hno:%u ready get phys[%d] of encl_id[%d] !\n", - PS3_HOST(instance), sas_req_param.phyCount, sas_req_param.enclID); + PS3_HOST(instance), sas_req_param.phyCount, + sas_req_param.enclID); memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO_IN_IRQ(instance, "hno:%u ready update %d phys of encl_id[%d]!\n", - PS3_HOST(instance), sas_req_param.phyCount, sas_req_param.enclID); + LOG_INFO_IN_IRQ(instance, + "hno:%u ready update %d phys of encl_id[%d]!\n", + PS3_HOST(instance), sas_req_param.phyCount, + sas_req_param.enclID); for (i = 0; i < sas_node->phy_count; i++) { - ps3_sas_node_phy_update(instance, &sas_node->phys[i], &phy_info[i]); -#if 0 - 所有的添加都应该通过scsi来触发 - if (phy_info[i].attachedSasAddr != PS3_SAS_INVALID_SAS_ADDR && - phy_info[i].attachDevType == SAS_END_DEVICE) { - ret = ps3_sas_end_device_try_add(instance, sas_node, - &sas_node->phys[i]); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add end device[%016llx] on node[%d]-phys[%d] failed !\n", - PS3_HOST(instance), - phy_info[i].attachedSasAddr, - sas_node->encl_id, i); - goto l_out; - } - } -#endif + ps3_sas_node_phy_update(instance, &sas_node->phys[i], + &phy_info[i]); } - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); ps3_sas_port_phy_update(instance, sas_node); l_out: return ret; } -static S32 ps3_sas_device_date_refresh(struct ps3_instance *instance) +static int ps3_sas_device_date_refresh(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - struct PS3Expanders *p_expanders = (struct PS3Expanders*)instance->sas_dev_context.ps3_sas_buff; + int ret = PS3_SUCCESS; + struct PS3Expanders *p_expanders = + (struct PS3Expanders *)instance->sas_dev_context.ps3_sas_buff; struct PS3ExpanderInfo *exp_info = p_expanders->expanders; struct ps3_sas_node *exp_node = NULL; - U8 i = 0; + unsigned char i = 0; - LOG_DEBUG("hno:%u SAS dev refresh enter\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS dev refresh enter\n", PS3_HOST(instance)); memset(p_expanders, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_all_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); goto l_out; } LOG_DEBUG("hno:%u ready refresh expander count[%d]\n", - PS3_HOST(instance), p_expanders->count); + PS3_HOST(instance), p_expanders->count); if (p_expanders->count == 0) { LOG_ERROR("hno:%u expander init info count = 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); BUG(); } LOG_DEBUG("hno:%u ready refresh HBA\n", PS3_HOST(instance)); - ret = ps3_sas_expander_phys_refresh(instance, - &instance->sas_dev_context.ps3_hba_sas); + ret = ps3_sas_expander_phys_refresh( + instance, &instance->sas_dev_context.ps3_hba_sas); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u refresh phys on HBA NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ps3_sas_expander_port_clean(instance, &instance->sas_dev_context.ps3_hba_sas, p_expanders); + ps3_sas_expander_port_clean( + instance, &instance->sas_dev_context.ps3_hba_sas, p_expanders); LOG_DEBUG("hno:%u end refresh HBA\n", PS3_HOST(instance)); for (i = 1; i < p_expanders->count; i++) { - exp_node = ps3_sas_find_node_by_id(instance, exp_info[i].enclID); + exp_node = + ps3_sas_find_node_by_id(instance, exp_info[i].enclID); if (exp_node != NULL) { - if (likely(exp_node->parent_sas_address == exp_info[i].parentSasAddr && - exp_node->parent_encl_id == exp_info[i].parentId)) { + if (likely(exp_node->parent_sas_address == + exp_info[i].parentSasAddr && + exp_node->parent_encl_id == + exp_info[i].parentId)) { LOG_DEBUG("hno:%u ready refresh expander[%d]\n", - PS3_HOST(instance), exp_info[i].enclID); - ret = ps3_sas_expander_phys_refresh(instance, exp_node); + PS3_HOST(instance), + exp_info[i].enclID); + ret = ps3_sas_expander_phys_refresh(instance, + exp_node); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u refresh phys on expander[%d] NOK!\n", - PS3_HOST(instance), exp_info[i].enclID); + LOG_ERROR( + "hno:%u refresh phys on expander[%d] NOK!\n", + PS3_HOST(instance), + exp_info[i].enclID); goto l_out; } - ps3_sas_expander_port_clean(instance, exp_node, p_expanders); + ps3_sas_expander_port_clean(instance, exp_node, + p_expanders); LOG_DEBUG("hno:%u end refresh expander[%d]\n", - PS3_HOST(instance), exp_info[i].enclID); + PS3_HOST(instance), + exp_info[i].enclID); } } - LOG_DEBUG("hno:%u ready add expander[%d]\n", - PS3_HOST(instance), exp_info[i].enclID); + LOG_DEBUG("hno:%u ready add expander[%d]\n", PS3_HOST(instance), + exp_info[i].enclID); ret = ps3_sas_expander_node_add(instance, &exp_info[i]); LOG_DEBUG("hno:%u end add expander[%d], ret[%d]\n", - PS3_HOST(instance), exp_info[i].enclID, ret); + PS3_HOST(instance), exp_info[i].enclID, ret); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u init add expander[%d] info NOK\n", - PS3_HOST(instance), exp_info[i].enclID); + PS3_HOST(instance), exp_info[i].enclID); goto l_out; } } - LOG_DEBUG("hno:%u SAS refresh end\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u SAS refresh end\n", PS3_HOST(instance)); l_out: - return ret ; + return ret; } -static S32 ps3_sas_expander_event_update(struct ps3_instance *instance, U8 encl_id) +static int ps3_sas_expander_event_update(struct ps3_instance *instance, + unsigned char encl_id) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_sas_node *sas_node = NULL; LOG_DEBUG("hno:%u enter SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); sas_node = ps3_sas_find_node_by_id(instance, encl_id); if (sas_node == NULL) { LOG_ERROR("hno:%u cannot find PS3 node[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } ret = ps3_sas_expander_phys_refresh(instance, sas_node); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u refresh phys on node[%d] NOK!\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } l_out: LOG_DEBUG("hno:%u quit SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static S32 ps3_sas_expander_phy_update(struct ps3_instance *instance, U8 encl_id, U8 phy_id) +static int ps3_sas_expander_phy_update(struct ps3_instance *instance, + unsigned char encl_id, + unsigned char phy_id) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_sas_node *sas_node = NULL; struct PS3SasMgr sas_req_param; - struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; - ULong flags = 0; + struct PS3PhyInfo *phy_info = + instance->sas_dev_context.ps3_sas_phy_buff; + unsigned long flags = 0; LOG_DEBUG("hno:%u enter SAS expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); sas_node = ps3_sas_find_node_by_id(instance, encl_id); if (sas_node == NULL) { LOG_ERROR("hno:%u cannot find PS3 node[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); goto l_out; } memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = phy_id; sas_req_param.phyCount = 1; @@ -1703,24 +1835,25 @@ static S32 ps3_sas_expander_phy_update(struct ps3_instance *instance, U8 encl_id ret = ps3_sas_phy_get(instance, &sas_req_param); INJECT_START(PS3_ERR_IJ_SAS_PHY_GET_ERR, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u init get expander NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u init get expander NOK\n", PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); ps3_sas_node_phy_update(instance, &sas_node->phys[phy_id], phy_info); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); l_out: LOG_DEBUG("hno:%u quit sas expander update encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static S32 ps3_sas_expander_event_add(struct ps3_instance *instance, U8 encl_id) +static int ps3_sas_expander_event_add(struct ps3_instance *instance, + unsigned char encl_id) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct PS3ExpanderInfo *exp_info = (struct PS3ExpanderInfo *)instance->sas_dev_context.ps3_sas_buff; struct PS3SasMgr sas_req_param; @@ -1729,13 +1862,13 @@ static S32 ps3_sas_expander_event_add(struct ps3_instance *instance, U8 encl_id) sas_req_param.enclID = encl_id; LOG_WARN("hno:%u enter sas expander add encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); memset(exp_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_expander_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get expander[%d] NOK\n", - PS3_HOST(instance), encl_id); + LOG_ERROR("hno:%u get expander[%d] NOK\n", PS3_HOST(instance), + encl_id); goto l_out; } @@ -1747,7 +1880,7 @@ static S32 ps3_sas_expander_event_add(struct ps3_instance *instance, U8 encl_id) INJECT_START(PS3_ERR_EXP_ID_ERR, &encl_id); if (exp_info->enclID != encl_id) { LOG_ERROR("hno:%u got expander[%d] is not [%d]\n", - PS3_HOST(instance), exp_info->enclID, encl_id); + PS3_HOST(instance), exp_info->enclID, encl_id); PS3_BUG(); ret = -PS3_FAILED; goto l_out; @@ -1756,35 +1889,36 @@ static S32 ps3_sas_expander_event_add(struct ps3_instance *instance, U8 encl_id) ret = ps3_sas_expander_event_update(instance, exp_info->parentId); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u update parent encl[%d] NOK\n", - PS3_HOST(instance), exp_info->parentId); + PS3_HOST(instance), exp_info->parentId); goto l_out; } ret = ps3_sas_expander_node_add(instance, exp_info); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add expander[%d] NOK\n", - PS3_HOST(instance), encl_id); + LOG_ERROR("hno:%u add expander[%d] NOK\n", PS3_HOST(instance), + encl_id); goto l_out; } l_out: LOG_WARN("hno:%u quit sas expander add encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -static S32 ps3_sas_expander_event_del(struct ps3_instance *instance, U8 encl_id) +static int ps3_sas_expander_event_del(struct ps3_instance *instance, + unsigned char encl_id) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_sas_node *exp_node = NULL; - U8 parentId = 0; + unsigned char parentId = 0; LOG_WARN("hno:%u enter sas expander del encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); exp_node = ps3_sas_find_node_by_id(instance, encl_id); if (exp_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%d] !\n", - PS3_HOST(instance), encl_id); + LOG_ERROR("hno:%u cannot find node[%d] !\n", PS3_HOST(instance), + encl_id); ret = -PS3_FAILED; goto l_out; } @@ -1795,23 +1929,23 @@ static S32 ps3_sas_expander_event_del(struct ps3_instance *instance, U8 encl_id) ret = ps3_sas_expander_event_update(instance, parentId); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u update parent encl[%d] NOK\n", - PS3_HOST(instance), parentId); + PS3_HOST(instance), parentId); goto l_out; } l_out: LOG_WARN("hno:%u quit sas expander del encl_id[%d] !\n", - PS3_HOST(instance), encl_id); + PS3_HOST(instance), encl_id); return ret; } -S32 ps3_sas_expander_event_refresh(struct ps3_instance *instance) +int ps3_sas_expander_event_refresh(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + ret = ps3_sas_device_date_refresh(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u refresh all SAS NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u refresh all SAS NOK\n", PS3_HOST(instance)); goto l_out; } @@ -1819,77 +1953,90 @@ S32 ps3_sas_expander_event_refresh(struct ps3_instance *instance) return ret; } -S32 ps3_sas_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, U32 event_cnt) +int ps3_sas_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, + unsigned int event_cnt) { - S32 ret = PS3_SUCCESS; - S32 ret_map = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + int ret_map = PS3_SUCCESS; + unsigned int i = 0; - LOG_DEBUG("hno:%u, event detail count[%d]\n", - PS3_HOST(instance), event_cnt); + LOG_DEBUG("hno:%u, event detail count[%d]\n", PS3_HOST(instance), + event_cnt); for (i = 0; i < event_cnt; i++) { - LOG_INFO("hno:%u, event detail %d eventCode is [%s], encl_Id[%d]\n", - PS3_HOST(instance), i, mgrEvtCodeTrans(event_detail[i].eventCode), + if (!instance->state_machine.is_load) { + INJECT_START(PS3_ERR_IJ_DETAIL_BREAK_CHECK1, instance); + LOG_INFO("hno:%u instance unload, break\n", PS3_HOST(instance)); + break; + } + LOG_INFO( + "hno:%u, event detail %d eventCode is [%s], encl_Id[%d]\n", + PS3_HOST(instance), i, + mgrEvtCodeTrans(event_detail[i].eventCode), event_detail[i].EnclId); switch (event_detail[i].eventCode) { case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_CHANGE): case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_IN): - ret = ps3_sas_expander_event_add(instance, - event_detail[i].EnclId); + ret = ps3_sas_expander_event_add( + instance, event_detail[i].EnclId); break; case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_OUT): - ret = ps3_sas_expander_event_del(instance, - event_detail[i].EnclId); + ret = ps3_sas_expander_event_del( + instance, event_detail[i].EnclId); break; case PS3_EVT_CODE(MGR_EVT_SAS_EXPANDER_UPDATE): - ret = ps3_sas_expander_event_update(instance, - event_detail[i].EnclId); + ret = ps3_sas_expander_event_update( + instance, event_detail[i].EnclId); break; default: break; } - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) ret_map |= event_detail[i].eventType; - } } return ret_map; } -S32 ps3_sas_add_device(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) +int ps3_sas_add_device(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry) { - S32 ret = -PS3_FAILED; - struct ps3_sas_node* parent_node = NULL; + int ret = -PS3_FAILED; + struct ps3_sas_node *parent_node = NULL; struct sas_identify *remote_id = NULL; - U32 softChan = PS3_CHANNEL(&pd_entry->disk_pos); - U32 devID = PS3_TARGET(&pd_entry->disk_pos); - U32 phyDiskID = PS3_PDID(&pd_entry->disk_pos); + unsigned int softChan = PS3_CHANNEL(&pd_entry->disk_pos); + unsigned int devID = PS3_TARGET(&pd_entry->disk_pos); + unsigned int phyDiskID = PS3_PDID(&pd_entry->disk_pos); - LOG_DEBUG("hno:%u enter ps3_sas_add_device pd[%u:%u:%u] on encl[%u], phy[%u]!\n", - PS3_HOST(instance), softChan, devID, phyDiskID, + LOG_DEBUG( + "hno:%u enter %s pd[%u:%u:%u] on encl[%u], phy[%u]!\n", + PS3_HOST(instance), __func__, softChan, devID, phyDiskID, pd_entry->encl_id, pd_entry->phy_id); parent_node = ps3_sas_find_node_by_id(instance, pd_entry->encl_id); if (parent_node == NULL) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] cannot found node[%d] !\n", + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] cannot found node[%d] !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->encl_id); goto l_out; } if (pd_entry->phy_id >= parent_node->phy_count) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->phy_count); goto l_out; } - ret = ps3_sas_expander_phy_update(instance, pd_entry->encl_id, pd_entry->phy_id); + ret = ps3_sas_expander_phy_update(instance, pd_entry->encl_id, + pd_entry->phy_id); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + LOG_ERROR( + "hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->encl_id); goto l_out; @@ -1897,11 +2044,12 @@ S32 ps3_sas_add_device(struct ps3_instance *instance, struct ps3_pd_entry *pd_en remote_id = &parent_node->phys[pd_entry->phy_id].remote_identify; if (remote_id->sas_address == PS3_SAS_INVALID_SAS_ADDR || - remote_id->device_type != SAS_END_DEVICE || - remote_id->sas_address == parent_node->parent_sas_address) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] " - "invalid SAS addr[%016llx] or dev_type[%d] != SAS_END_DEVICE or " - " SAS addr = parent SAS addr[%016llx]!\n", + remote_id->device_type != SAS_END_DEVICE || + remote_id->sas_address == parent_node->parent_sas_address) { + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] phyid[%u]\n" + "\tinvalid SAS addr[%016llx] or dev_type[%d] != SAS_END_DEVICE or\n" + "\tSAS addr = parent SAS addr[%016llx]!\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, remote_id->sas_address, remote_id->device_type, @@ -1910,9 +2058,11 @@ S32 ps3_sas_add_device(struct ps3_instance *instance, struct ps3_pd_entry *pd_en } ret = ps3_sas_end_device_try_add(instance, parent_node, - &parent_node->phys[pd_entry->phy_id], pd_entry); + &parent_node->phys[pd_entry->phy_id], + pd_entry); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", PS3_HOST(instance), softChan, devID, phyDiskID, pd_entry->phy_id, parent_node->encl_id); goto l_out; @@ -1922,43 +2072,47 @@ S32 ps3_sas_add_device(struct ps3_instance *instance, struct ps3_pd_entry *pd_en return ret; } -S32 ps3_sas_remove_device(struct ps3_instance *instance, - struct PS3DiskDevPos *diskPos, U8 encl_id, U8 phy_id) +int ps3_sas_remove_device(struct ps3_instance *instance, + struct PS3DiskDevPos *diskPos, unsigned char encl_id, + unsigned char phy_id) { - S32 ret = -PS3_FAILED; - struct ps3_sas_node* parent_node = NULL; + int ret = -PS3_FAILED; + struct ps3_sas_node *parent_node = NULL; struct sas_identify *remote_id = NULL; - U32 softChan = PS3_CHANNEL(diskPos); - U32 devID = PS3_TARGET(diskPos); - U32 phyDiskID = PS3_PDID(diskPos); + unsigned int softChan = PS3_CHANNEL(diskPos); + unsigned int devID = PS3_TARGET(diskPos); + unsigned int phyDiskID = PS3_PDID(diskPos); - LOG_WARN("hno:%u enter ps3_sas_remove_device pd[%u:%u:%u] on encl[%u], phy[%u]!\n", - PS3_HOST(instance), softChan, - devID, phyDiskID, encl_id, phy_id); + LOG_WARN( + "hno:%u enter %s pd[%u:%u:%u] on encl[%u], phy[%u]!\n", + PS3_HOST(instance), __func__, softChan, devID, phyDiskID, encl_id, + phy_id); parent_node = ps3_sas_find_node_by_id(instance, encl_id); if (parent_node == NULL) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] cannot found node[%u] !\n", - PS3_HOST(instance),softChan, devID, phyDiskID, + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] cannot found node[%u] !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, encl_id); goto l_out; } if (phy_id >= parent_node->phy_count) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", - PS3_HOST(instance), softChan, devID, phyDiskID, - phy_id, parent_node->phy_count); + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] phyid[%u] exceed node phy_count[%u] !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, + parent_node->phy_count); goto l_out; } remote_id = &parent_node->phys[phy_id].remote_identify; if (remote_id->sas_address != PS3_SAS_INVALID_SAS_ADDR && - remote_id->sas_address == parent_node->parent_sas_address) { - LOG_ERROR("hno:%u add end device channel[%u:%u:%u] phyid[%u] " - "SAS addr[%016llx] dev_type[%d] parent SAS addr[%016llx]!\n", - PS3_HOST(instance), softChan, devID, phyDiskID, - phy_id, remote_id->sas_address, - remote_id->device_type, + remote_id->sas_address == parent_node->parent_sas_address) { + LOG_ERROR( + "hno:%u add end device channel[%u:%u:%u] phyid[%u]\n" + "\tSAS addr[%016llx] dev_type[%d] parent SAS addr[%016llx]!\n", + PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, + remote_id->sas_address, remote_id->device_type, parent_node->parent_sas_address); goto l_out; } @@ -1967,49 +2121,63 @@ S32 ps3_sas_remove_device(struct ps3_instance *instance, ret = ps3_sas_expander_phy_update(instance, encl_id, phy_id); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", - PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, encl_id); + LOG_ERROR( + "hno:%u update phy in add pd channel[%u:%u:%u] phyid[%u] on node[%u] NOK !\n", + PS3_HOST(instance), softChan, devID, phyDiskID, phy_id, + encl_id); goto l_out; } l_out: - LOG_WARN("hno:%u ps3_sas_remove_device pd[%u:%u:%u] on encl[%u], phy[%u] end, ret[%d]!\n", - PS3_HOST(instance), softChan, devID, phyDiskID, - encl_id, phy_id, ret); + LOG_WARN( + "hno:%u %s pd[%u:%u:%u] on encl[%u], phy[%u] end, ret[%d]!\n", + PS3_HOST(instance), __func__, softChan, devID, phyDiskID, encl_id, phy_id, + ret); return ret; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) - S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U32 lun) +#if defined(PS3_SAS_LONG_LUN) +int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, + unsigned int id, unsigned int lun) #else - S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U64 lun) +int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, + unsigned int id, unsigned long long lun) #endif { struct PS3ChannelInfo *channel_info = NULL; struct ps3_instance *instance = NULL; struct ps3_pd_entry *pd_entry = NULL; - U16 max_dev_num = 0; - U8 i = 0; - U16 j = 0; + unsigned short max_dev_num = 0; + unsigned char i = 0; + unsigned short j = 0; - if ((lun != 0) && (lun != SCAN_WILD_CARD)) { + if ((lun != 0) && (lun != SCAN_WILD_CARD)) goto l_out; - } instance = (struct ps3_instance *)shost_priv(host); channel_info = &instance->ctrl_info.channelInfo; - INJECT_START(PS3_ERR_IJ_PD_ATTR, NULL); + INJECT_START(PS3_ERR_IJ_PD_ATTR, NULL); ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, PS3_ERR_IJ_PD_ATTR, NULL); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, + PS3_ERR_IJ_PD_ATTR, NULL); for (i = 0; i < channel_info->channelNum; i++) { - if ((channel_info->channels[i].channelType == PS3_CHAN_TYPE_PD) && - (channel == SCAN_WILD_CARD || channel == i)) { + if ((channel_info->channels[i].channelType == + PS3_CHAN_TYPE_PD) && + (channel == SCAN_WILD_CARD || channel == i)) { max_dev_num = channel_info->channels[i].maxDevNum; for (j = 0; j < max_dev_num; j++) { - pd_entry = ps3_dev_mgr_lookup_pd_info(instance, i, j); - if ((pd_entry != NULL) && (pd_entry->sas_rphy != NULL)) { + pd_entry = ps3_dev_mgr_lookup_pd_info(instance, + i, j); + if ((pd_entry != NULL) && + (pd_entry->sas_rphy != NULL)) { if (id == SCAN_WILD_CARD || id == j) { - scsi_scan_target(&pd_entry->sas_rphy->dev, i, j, 0, SCSI_SCAN_MANUAL); - LOG_DEBUG("hno:%u channel:%u target:%u scan\n", PS3_HOST(instance), i, j); + scsi_scan_target( + &pd_entry->sas_rphy->dev, + i, j, 0, + SCSI_SCAN_MANUAL); + LOG_DEBUG( + "hno:%u channel:%u target:%u scan\n", + PS3_HOST(instance), i, + j); } } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h index e083c7402510..e0deaa2396dc 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_manager_sas.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _WINDOWS #ifndef _PS3_DEVICE_MANAGER_SAS_H_ @@ -11,108 +12,119 @@ #include "ps3_htp_dev.h" #include "ps3_htp_event.h" #include "ps3_device_manager.h" +#include "ps3_kernel_version.h" -#define PS3_SAS_HBA_MAX_SAS_NUM 3 +#define PS3_SAS_HBA_MAX_SAS_NUM 3 -#define PS3_SAS_MAX_PHY_NUM (128) -#define PS3_SAS_INVALID_ID (0xFF) -#define PS3_SAS_INVALID_SAS_ADDR (0x0) -#define PS3_SAS_REQ_BUFF_LEN (4096) +#define PS3_SAS_MAX_PHY_NUM (128) +#define PS3_SAS_INVALID_ID (0xFF) +#define PS3_SAS_INVALID_SAS_ADDR (0x0) +#define PS3_SAS_REQ_BUFF_LEN (4096) struct ps3_instance; struct ps3_sas_node { - struct list_head list; - struct device *dev; - struct ps3_sas_phy *phys; - struct list_head sas_port_list; - U64 sas_address; - U64 parent_sas_address; - U8 phy_count; - U8 encl_id; - U8 parent_encl_id; - U8 dev_type; - U8 reserved[4]; + struct list_head list; + struct device *dev; + struct ps3_sas_phy *phys; + struct list_head sas_port_list; + unsigned long long sas_address; + unsigned long long parent_sas_address; + unsigned char phy_count; + unsigned char encl_id; + unsigned char parent_encl_id; + unsigned char dev_type; + unsigned char reserved[4]; }; struct ps3_sas_phy { - struct list_head port_siblings; - struct sas_identify identify; - struct sas_identify remote_identify; - struct sas_phy *phy; - struct ps3_sas_port *attach_port; - U8 phy_id; - U8 encl_id; - U8 slot_id; - U8 reserved[5]; + struct list_head port_siblings; + struct sas_identify identify; + struct sas_identify remote_identify; + struct sas_phy *phy; + struct ps3_sas_port *attach_port; + unsigned char phy_id; + unsigned char encl_id; + unsigned char slot_id; + unsigned char reserved[5]; }; struct ps3_sas_port { - struct list_head list; - struct sas_identify remote_identify; - struct sas_rphy *rphy; - struct sas_port *port; - struct list_head phy_list; - U16 pd_flat_id; - U8 phy_count; - U8 reserved[5]; + struct list_head list; + struct sas_identify remote_identify; + struct sas_rphy *rphy; + struct sas_port *port; + struct list_head phy_list; + unsigned short pd_flat_id; + unsigned char phy_count; + unsigned char reserved[5]; }; struct ps3_sas_dev_context { - struct list_head ps3_sas_node_list; - spinlock_t ps3_sas_node_lock; - struct ps3_sas_node ps3_hba_sas; - U64 ps3_hba_sas_addr[PS3_SAS_HBA_MAX_SAS_NUM]; - struct semaphore ps3_sas_smp_semaphore; - - dma_addr_t ps3_sas_buff_dma_addr; - dma_addr_t ps3_sas_phy_buff_dma_addr; - void *ps3_sas_buff; - struct PS3PhyInfo *ps3_sas_phy_buff; - Bool is_support_smp; - U8 reserved[7]; + struct list_head ps3_sas_node_list; + spinlock_t ps3_sas_node_lock; + struct ps3_sas_node ps3_hba_sas; + unsigned long long ps3_hba_sas_addr[PS3_SAS_HBA_MAX_SAS_NUM]; + struct semaphore ps3_sas_smp_semaphore; + + dma_addr_t ps3_sas_buff_dma_addr; + dma_addr_t ps3_sas_phy_buff_dma_addr; + void *ps3_sas_buff; + struct PS3PhyInfo *ps3_sas_phy_buff; + unsigned char is_support_smp; + unsigned char reserved[7]; }; -Bool ps3_sas_is_support_smp(struct ps3_instance *instance); +unsigned char ps3_sas_is_support_smp(struct ps3_instance *instance); -S32 ps3_sas_device_mgr_init(struct ps3_instance *instance); +int ps3_sas_device_mgr_init(struct ps3_instance *instance); -S32 ps3_sas_device_mgr_exit(struct ps3_instance *instance); +int ps3_sas_device_mgr_exit(struct ps3_instance *instance); -S32 ps3_sas_device_data_init(struct ps3_instance *instance); +int ps3_sas_device_data_init(struct ps3_instance *instance); -S32 ps3_sas_device_data_exit(struct ps3_instance *instance); +int ps3_sas_device_data_exit(struct ps3_instance *instance); -S32 ps3_sas_rphy_slot_get(struct ps3_instance *instance, U64 sas_addr, U32 *slot_id); +int ps3_sas_rphy_slot_get(struct ps3_instance *instance, + unsigned long long sas_addr, unsigned int *slot_id); -U64 ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, U64 sas_addr); +unsigned long long +ps3_sas_rphy_parent_sas_addr_get(struct ps3_instance *instance, + unsigned long long sas_addr); -U8 ps3_sas_encl_id_get(struct ps3_instance *instance, U64 sas_addr); +unsigned char ps3_sas_encl_id_get(struct ps3_instance *instance, + unsigned long long sas_addr); -S32 ps3_sas_expander_event_refresh(struct ps3_instance *instance); +int ps3_sas_expander_event_refresh(struct ps3_instance *instance); -S32 ps3_sas_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, U32 event_cnt); +int ps3_sas_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, + unsigned int event_cnt); -S32 ps3_sas_add_device(struct ps3_instance *instance, - struct ps3_pd_entry *pd_entry); +int ps3_sas_add_device(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry); -S32 ps3_sas_remove_device(struct ps3_instance *instance, - struct PS3DiskDevPos *diskPos, U8 encl_id, U8 phy_id); +int ps3_sas_remove_device(struct ps3_instance *instance, + struct PS3DiskDevPos *diskPos, unsigned char encl_id, + unsigned char phy_id); void ps3_sas_expander_node_del(struct ps3_instance *instance, - struct ps3_sas_node *exp_node); + struct ps3_sas_node *exp_node); -struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( - struct ps3_instance *instance, U64 sas_addr); +struct ps3_sas_node * +ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, + unsigned long long sas_addr); -void ps3_sas_node_phy_update(struct ps3_instance *instance, struct ps3_sas_phy *ps3_phy, - struct PS3PhyInfo *phy_info); +void ps3_sas_node_phy_update(struct ps3_instance *instance, + struct ps3_sas_phy *ps3_phy, + struct PS3PhyInfo *phy_info); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) - S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U32 lun); +#if defined(PS3_SAS_LONG_LUN) +int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, + unsigned int id, unsigned int lun); #else - S32 ps3_sas_user_scan(struct Scsi_Host *host, U32 channel, U32 id, U64 lun); +int ps3_sas_user_scan(struct Scsi_Host *host, unsigned int channel, + unsigned int id, unsigned long long lun); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_update.c b/drivers/scsi/linkdata/ps3stor/ps3_device_update.c index 2fb7ee889c62..c2bb34ceaf9f 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_update.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_update.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_device_update.h" @@ -23,7 +24,7 @@ #endif #include "ps3_event.h" -#include "ps3_meta.h" +#include "ps3_htp_meta.h" #include "ps3_htp_event.h" #include "ps3_mgr_cmd.h" #include "ps3_ioc_manager.h" @@ -33,23 +34,25 @@ #include "ps3_scsi_cmd_err.h" #include "ps3_r1x_write_lock.h" #include "ps3_ioc_state.h" +#include "ps3_kernel_version.h" -static S32 ps3_pd_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, U8 config_flag); +static int ps3_pd_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, unsigned char config_flag); -static S32 ps3_pd_add(struct ps3_instance *instance, - struct PS3DiskDevPos* dev_pos); +static int ps3_pd_add(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos); -U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev) +unsigned int ps3_scsi_dev_magic(struct ps3_instance *instance, + struct scsi_device *sdev) { - U32 dev_magic_num = 0; + unsigned int dev_magic_num = 0; struct ps3_scsi_priv_data *p_priv_data = NULL; ps3_mutex_lock(&instance->dev_context.dev_priv_lock); p_priv_data = PS3_SDEV_PRI_DATA(sdev); if (p_priv_data != NULL) { if (PS3_IS_VD_CHANNEL(instance, PS3_SDEV_CHANNEL(sdev)) || - ps3_sas_is_support_smp(instance)) { + ps3_sas_is_support_smp(instance)) { dev_magic_num = p_priv_data->disk_pos.diskMagicNum; } else { dev_magic_num = p_priv_data->disk_pos.checkSum; @@ -60,146 +63,164 @@ U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev) return dev_magic_num; } -Bool ps3_pd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type, U8 config_flag, - U8 pd_state) +unsigned char ps3_pd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type, + unsigned char config_flag, + unsigned char pd_state) { - Bool visible = PS3_DRV_TRUE; + unsigned char visible = PS3_DRV_TRUE; if (pd_state == DEVICE_STATE_OUTING) { - LOG_INFO("hno:%u PD[%u:%u:%u], dev_type[%s] state[%s] is outing\n", + LOG_INFO( + "hno:%u PD[%u:%u:%u], dev_type[%s] state[%s] is outing\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), namePS3DevType((enum PS3DevType)dev_type), - getDeviceStateName((DeviceState_e)pd_state)); + getDeviceStateName((enum DeviceState)pd_state)); visible = PS3_DRV_FALSE; goto l_out; } if (ps3_is_fake_pd(dev_type)) { - LOG_DEBUG("hno:%u PD[%u:%u:%u], dev_type[%s] device is visible all time\n", + LOG_DEBUG( + "hno:%u PD[%u:%u:%u], dev_type[%s] device is visible all time\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), namePS3DevType((enum PS3DevType)dev_type)); goto l_out; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) - if (!instance->is_support_jbod && - ps3_check_pd_is_vd_member(config_flag)) { - LOG_DEBUG("hno:%u PD[%u:%u:%u] is vd component, config_flag[%s] \n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_PDID(disk_pos), - getPdStateName((MicPdState_e)config_flag, instance->is_raid)); - visible = PS3_DRV_FALSE; - goto l_out; - } +#if defined(PS3_SUPPORT_LINX80) + if (!instance->is_support_jbod && + ps3_check_pd_is_vd_member(config_flag)) { + LOG_DEBUG( + "hno:%u PD[%u:%u:%u] is vd component, config_flag[%s]\n", + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_PDID(disk_pos), + getPdStateName((enum MicPdState)config_flag, + instance->is_raid)); + visible = PS3_DRV_FALSE; + goto l_out; + } #endif - if (instance->is_support_jbod && config_flag != - MIC_PD_STATE_JBOD) { - LOG_DEBUG("hno:%u PD[%u:%u:%u] config_flag is [%s], invisible \n", + if (instance->is_support_jbod && config_flag != MIC_PD_STATE_JBOD) { + LOG_DEBUG( + "hno:%u PD[%u:%u:%u] config_flag is [%s], invisible\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_PDID(disk_pos), - getPdStateName((MicPdState_e)config_flag, instance->is_raid)); + getPdStateName((enum MicPdState)config_flag, + instance->is_raid)); visible = PS3_DRV_FALSE; goto l_out; } l_out: - LOG_DEBUG("hno:%u PD[%u:%u:%u] is %s\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_PDID(disk_pos), - visible ? "visible" : "invisible"); + LOG_DEBUG("hno:%u PD[%u:%u:%u] is %s\n", PS3_HOST(instance), + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_PDID(disk_pos), visible ? "visible" : "invisible"); return visible; } -static inline Bool ps3_vd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, Bool is_hidden, U8 disk_state) +static inline unsigned char +ps3_vd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char is_hidden, unsigned char disk_state) { - Bool visible = PS3_DRV_TRUE; + unsigned char visible = PS3_DRV_TRUE; if (is_hidden) { - LOG_INFO("hno:%u vd[%u:%u:%u] is hidden\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); + LOG_INFO("hno:%u vd[%u:%u:%u] is hidden\n", PS3_HOST(instance), + PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_VDID(disk_pos)); visible = PS3_DRV_FALSE; } if (disk_state == MIC_VD_STATE_OFFLINE) { LOG_INFO("hno:%u vd[%u:%u:%u] state offline\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos)); visible = PS3_DRV_FALSE; } return visible; } -static Bool ps3_scsi_visible_check(struct ps3_instance *instance, - U8 channel, U16 target_id, U8 disk_type) +static unsigned char ps3_scsi_visible_check(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char disk_type) { struct PS3VDEntry *p_vd_entry = NULL; struct ps3_pd_entry *p_pd_entry = NULL; - Bool visible = PS3_DRV_FALSE; + unsigned char visible = PS3_DRV_FALSE; if (disk_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, + target_id); if (p_pd_entry) { - visible = ps3_pd_scsi_visible_check(instance, - &p_pd_entry->disk_pos, p_pd_entry->dev_type, - p_pd_entry->config_flag, p_pd_entry->state); + visible = ps3_pd_scsi_visible_check( + instance, &p_pd_entry->disk_pos, + p_pd_entry->dev_type, p_pd_entry->config_flag, + p_pd_entry->state); } - } else if (disk_type == PS3_DISK_TYPE_VD){ - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); + } else if (disk_type == PS3_DISK_TYPE_VD) { + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, + target_id); if (p_vd_entry) { - visible = ps3_vd_scsi_visible_check(instance, - &p_vd_entry->diskPos, p_vd_entry->isHidden, p_vd_entry->diskState); + visible = ps3_vd_scsi_visible_check( + instance, &p_vd_entry->diskPos, + p_vd_entry->isHidden, p_vd_entry->diskState); } } if (p_pd_entry || p_vd_entry) { LOG_INFO("hno:%u dev[%u:%u] visible is %s\n", - PS3_HOST(instance), channel, target_id, - visible ? "PS3_TRUE" : "PS3_FALSE"); + PS3_HOST(instance), channel, target_id, + visible ? "PS3_TRUE" : "PS3_FALSE"); } return visible; } static inline void __ps3_scsi_add_device(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type) + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type) { - S32 ret = PS3_SUCCESS; - U8 channel = PS3_CHANNEL(disk_pos); - U16 id = PS3_TARGET(disk_pos); + int ret = PS3_SUCCESS; + unsigned char channel = PS3_CHANNEL(disk_pos); + unsigned short id = PS3_TARGET(disk_pos); ret = ps3_scsi_add_device_ack(instance, disk_pos, dev_type); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL2, &ret); if (ret != PS3_SUCCESS) { - LOG_WARN("hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", - PS3_HOST(instance), channel, id, - disk_pos->diskMagicNum, ret); + LOG_WARN( + "hno:%u dev[%u:%u] magic[%#x] add scsi device ack NOK, ret %d\n", + PS3_HOST(instance), channel, id, disk_pos->diskMagicNum, + ret); } else { LOG_INFO("hno:%u dev_type[%d] id[%u:%u] add device begin\n", - PS3_HOST(instance), dev_type, channel, id); + PS3_HOST(instance), dev_type, channel, id); ret = ps3_scsi_add_device(instance, channel, id, 0); LOG_INFO("hno:%u dev_type[%d] id[%u:%u] add end, add ret %d\n", - PS3_HOST(instance), dev_type, channel, id, ret); + PS3_HOST(instance), dev_type, channel, id, ret); } } static void _ps3_scsi_add_device(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type) + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type) { struct scsi_device *sdev = NULL; - U8 channel = PS3_CHANNEL(disk_pos); - U16 target_id = PS3_TARGET(disk_pos); - U16 disk_id = PS3_VDID(disk_pos); + unsigned char channel = PS3_CHANNEL(disk_pos); + unsigned short target_id = PS3_TARGET(disk_pos); + unsigned short disk_id = PS3_VDID(disk_pos); - LOG_DEBUG("hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device start\n", + LOG_DEBUG( + "hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device start\n", PS3_HOST(instance), namePS3DiskType((enum PS3DiskType)dev_type), channel, target_id, disk_id); @@ -208,35 +229,37 @@ static void _ps3_scsi_add_device(struct ps3_instance *instance, __ps3_scsi_add_device(instance, disk_pos, dev_type); } else { ps3_scsi_device_put(instance, sdev); - LOG_INFO("hno:%u channel[%u] target[%u] device already exists in os\n", + LOG_INFO( + "hno:%u channel[%u] target[%u] device already exists in os\n", PS3_HOST(instance), channel, target_id); } - LOG_DEBUG("hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device end\n", + LOG_DEBUG( + "hno:%u dev_type[%s] id[%u:%u] disk_id[%d] add scsi device end\n", PS3_HOST(instance), namePS3DiskType((enum PS3DiskType)dev_type), channel, target_id, disk_id); } -static S32 _ps3_add_disk(struct ps3_instance *instance, - U8 channel, U16 target_id, U8 disk_type) +static int _ps3_add_disk(struct ps3_instance *instance, unsigned char channel, + unsigned short target_id, unsigned char disk_type) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; struct PS3DiskDevPos *p_diskPos = NULL; - U8 dev_type = PS3_DISK_TYPE_UNKNOWN; + unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; - if (!ps3_scsi_visible_check(instance, channel, target_id, disk_type)) { + if (!ps3_scsi_visible_check(instance, channel, target_id, disk_type)) goto l_out; - } if (disk_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, + target_id); if (p_pd_entry) { #ifndef _WINDOWS if (ps3_sas_is_support_smp(instance) && - p_pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD && - p_pd_entry->dev_type != PS3_DEV_TYPE_VEP) { + p_pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD && + p_pd_entry->dev_type != PS3_DEV_TYPE_VEP) { ps3_sas_add_device(instance, p_pd_entry); goto l_out; } else { @@ -247,8 +270,9 @@ static S32 _ps3_add_disk(struct ps3_instance *instance, } #endif } - } else if (disk_type == PS3_DISK_TYPE_VD){ - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); + } else if (disk_type == PS3_DISK_TYPE_VD) { + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, + target_id); if (p_vd_entry) { p_diskPos = &p_vd_entry->diskPos; dev_type = PS3_DISK_TYPE_VD; @@ -259,56 +283,59 @@ static S32 _ps3_add_disk(struct ps3_instance *instance, l_out: return ret; } -#ifndef _WINDOWS - -static Bool ps3_sd_available_check(struct scsi_device *sdev) +#ifndef _WINDOWS +static unsigned char ps3_sd_available_check(struct scsi_device *sdev) { - Bool ret = PS3_TRUE; - if (dev_get_drvdata(&sdev->sdev_gendev) == NULL) { + unsigned char ret = PS3_TRUE; + + if (dev_get_drvdata(&sdev->sdev_gendev) == NULL) ret = PS3_FALSE; - } return ret; } void ps3_scsi_scan_host(struct ps3_instance *instance) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - U16 timeout = instance->ctrl_info.isotoneTimeOut; - U8 channelType = 0; - U16 maxDevNum = 0; - U8 i = 0; - U16 j = 0; + unsigned short timeout = instance->ctrl_info.isotoneTimeOut; + unsigned char channelType = 0; + unsigned short maxDevNum = 0; + unsigned char i = 0; + unsigned short j = 0; struct scsi_device *sdev = NULL; - Bool bootdrv_ok = PS3_FALSE; - U16 count = 0; + unsigned char bootdrv_ok = PS3_FALSE; + unsigned short count = 0; LOG_WARN("hno:%u scan device begin, channel number %d\n", - PS3_HOST(instance), channel_info->channelNum); - INJECT_START(PS3_ERR_IJ_ADD_DISK_HOST_RESET, instance) + PS3_HOST(instance), channel_info->channelNum); + INJECT_START(PS3_ERR_IJ_ADD_DISK_HOST_RESET, instance); for (i = 0; i < channel_info->channelNum; i++) { channelType = channel_info->channels[i].channelType; maxDevNum = channel_info->channels[i].maxDevNum; LOG_INFO("hno:%u channel[%u] is type %s,max dev num is:%d\n", - PS3_HOST(instance), i, - namePS3ChannelType((enum PS3ChannelType)channelType), - maxDevNum); + PS3_HOST(instance), i, + namePS3ChannelType((enum PS3ChannelType)channelType), + maxDevNum); for (j = 0; j < maxDevNum; j++) { _ps3_add_disk(instance, i, j, channelType); if (timeout != 0 && !bootdrv_ok && i == 0 && - ps3_scsi_visible_check(instance, i, j, channelType)) { + ps3_scsi_visible_check(instance, i, j, + channelType)) { for (count = 0; count < timeout; count++) { - sdev = ps3_scsi_device_lookup(instance, i, j, 0); - if (sdev == NULL) { + sdev = ps3_scsi_device_lookup(instance, + i, j, 0); + if (sdev == NULL) continue; - } if (!ps3_sd_available_check(sdev)) { - ps3_scsi_device_put(instance, sdev); - ps3_msleep(PS3_PS3_LOOP_TIME_INTERVAL_1000MS); + ps3_scsi_device_put(instance, + sdev); + ps3_msleep( + PS3_PS3_LOOP_TIME_INTERVAL_1000MS); continue; } ps3_scsi_device_put(instance, sdev); - LOG_WARN("hno:%u bootdrive disk[%u:%u] drive-letter add complete\n", + LOG_WARN( + "hno:%u bootdrive disk[%u:%u] drive-letter add complete\n", PS3_HOST(instance), i, j); break; } @@ -318,21 +345,21 @@ void ps3_scsi_scan_host(struct ps3_instance *instance) } LOG_WARN("hno:%u scan device end, channel number %d\n", - PS3_HOST(instance), channel_info->channelNum); + PS3_HOST(instance), channel_info->channelNum); } #endif -static inline S32 _ps3_del_disk(struct ps3_instance *instance, - struct scsi_device *sdev) +static inline int _ps3_del_disk(struct ps3_instance *instance, + struct scsi_device *sdev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *p_priv_data = NULL; - U8 dev_type = PS3_DISK_TYPE_UNKNOWN; - U8 channel = PS3_SDEV_CHANNEL(sdev); - U16 target_id = PS3_SDEV_TARGET(sdev); + unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; + unsigned char channel = PS3_SDEV_CHANNEL(sdev); + unsigned short target_id = PS3_SDEV_TARGET(sdev); struct PS3DiskDevPos disk_pos; - U8 encl_id = 0; - U8 phy_id = 0; + unsigned char encl_id = 0; + unsigned char phy_id = 0; if (PS3_IS_PD_CHANNEL(instance, channel)) { dev_type = PS3_DISK_TYPE_PD; @@ -340,97 +367,91 @@ static inline S32 _ps3_del_disk(struct ps3_instance *instance, dev_type = PS3_DISK_TYPE_VD; } else { LOG_ERROR("hno:%u dev id[%u:%u] channel NOK\n", - PS3_HOST(instance), channel, - target_id); + PS3_HOST(instance), channel, target_id); PS3_BUG(); goto l_out; } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - p_priv_data = (struct ps3_scsi_priv_data*)sdev->hostdata; + p_priv_data = (struct ps3_scsi_priv_data *)sdev->hostdata; if (p_priv_data != NULL) { INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, + INJECT_START_AT_TIME_WAIT_REV_PRE( + PS3_ERR_IJ_DEL_DEV_WAIT_OS_PRIV_DATA, PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ps3_qos_disk_del(instance, p_priv_data); - if (ps3_sas_is_support_smp(instance) && dev_type == PS3_DISK_TYPE_PD && - p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && - p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { - memset(&disk_pos, 0, sizeof(struct PS3DiskDevPos)); - memcpy(&disk_pos, &p_priv_data->disk_pos, sizeof(struct PS3DiskDevPos)); - encl_id = p_priv_data->encl_id; - phy_id = p_priv_data->phy_id; + if (ps3_sas_is_support_smp(instance) && + dev_type == PS3_DISK_TYPE_PD && + p_priv_data->dev_type != PS3_DEV_TYPE_NVME_SSD && + p_priv_data->dev_type != PS3_DEV_TYPE_VEP) { + memset(&disk_pos, 0, sizeof(struct PS3DiskDevPos)); + memcpy(&disk_pos, &p_priv_data->disk_pos, + sizeof(struct PS3DiskDevPos)); + encl_id = p_priv_data->encl_id; + phy_id = p_priv_data->phy_id; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - ps3_sas_remove_device(instance, &disk_pos, encl_id, phy_id); + ps3_sas_remove_device(instance, &disk_pos, encl_id, + phy_id); } else { if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && - p_priv_data->lock_mgr.hash_mgr != NULL) { + p_priv_data->lock_mgr.hash_mgr != NULL) { p_priv_data->lock_mgr.dev_deling = PS3_TRUE; - ps3_r1x_conflict_queue_clean(p_priv_data, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT)); + ps3_r1x_conflict_queue_clean( + p_priv_data, + PS3_SCSI_RESULT_HOST_STATUS( + DID_NO_CONNECT)); } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - LOG_WARN("remove device channel[%u], id[%u] begin\n", channel, target_id); + LOG_WARN("remove device channel[%u], id[%u] begin\n", + channel, target_id); ps3_scsi_remove_device(instance, sdev); - LOG_WARN("remove device channel[%u], id[%u] end\n", channel, target_id); + LOG_WARN("remove device channel[%u], id[%u] end\n", + channel, target_id); } } else { - ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_DEBUG("hno:%u del disk, priv data NULL, [%u:%u],\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); } l_out: return ret; } -static S32 ps3_del_disk(struct ps3_instance *instance, - U8 channel, U16 target_id) +static int ps3_del_disk(struct ps3_instance *instance, unsigned char channel, + unsigned short target_id) { struct scsi_device *sdev = NULL; - S32 ret = PS3_SUCCESS; -#if 0 - LOG_INFO("hno:%u dev id[%u:%u] delete scsi device start\n", - PS3_HOST(instance), channel, target_id); -#endif + int ret = PS3_SUCCESS; #ifdef _WINDOWS sdev = ps3_scsi_device_lookup_win(instance, channel, target_id); if (sdev == NULL || sdev->add_ack != 1) { LOG_INFO("hno:%u dev[%p] id[%u:%u] not exist scsi device\n", - PS3_HOST(instance), sdev, channel, target_id); + PS3_HOST(instance), sdev, channel, target_id); goto l_out; } #else sdev = ps3_scsi_device_lookup(instance, channel, target_id, 0); - if(sdev == NULL) { -#if 0 - LOG_INFO("hno:%u dev id[%u:%u] not exist scsi device\n", - PS3_HOST(instance), channel, target_id); -#endif + if (sdev == NULL) goto l_out; - } #endif INJECT_AT_TIMES(PS3_ERR_IJ_FORCE_WAIT, sdev); ret = _ps3_del_disk(instance, sdev); ps3_scsi_device_put(instance, sdev); l_out: -#if 0 - LOG_INFO("hno:%u dev id[%u:%u] " - "delete scsi device end\n", PS3_HOST(instance), - channel, target_id); -#endif return ret; } static struct PS3VDEntry *ps3_get_single_vd_info(struct ps3_instance *instance, - struct PS3Dev *dev) + struct PS3Dev *dev) { - S32 ret = -PS3_FAILED; - PS3DiskDev_u vd_id = {0}; + int ret = -PS3_FAILED; + union PS3DiskDev vd_id = { 0 }; struct PS3VDEntry *p_vd_entry = NULL; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; + vd_id.ps3Dev.virtDiskID = dev->virtDiskID; vd_id.ps3Dev.softChan = dev->softChan; vd_id.ps3Dev.devID = dev->devID; @@ -438,35 +459,39 @@ static struct PS3VDEntry *ps3_get_single_vd_info(struct ps3_instance *instance, ret = ps3_vd_info_sync_get(instance, vd_id.diskID, 1); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL1, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u, sync get VD info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u, sync get VD info NOK\n", PS3_HOST(instance)); goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_VD_COUNT_ERR, &instance->dev_context.vd_info_buf_sync->count); + INJECT_START(PS3_ERR_IJ_FORCE_VD_COUNT_ERR, + &instance->dev_context.vd_info_buf_sync->count); if (instance->dev_context.vd_info_buf_sync->count != 1) { LOG_ERROR("hno:%u, single add VD, has no info\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } p_vd_entry = instance->dev_context.vd_info_buf_sync->vds; if (PS3_VDID_INVALID(&p_vd_entry->diskPos)) { LOG_WARN("hno:%u, init single vd info NOK, vdid is 0\n", - PS3_HOST(instance)); + PS3_HOST(instance)); p_vd_entry = NULL; goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&p_vd_entry->diskPos)); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&p_vd_entry->diskPos)); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(instance))) { - LOG_WARN("hno:%u, init single vd info NOK, vir_id[%d] > max[%d]\n", - PS3_HOST(instance), virtDiskIdx, PS3_MAX_VD_COUNT(instance)); + LOG_WARN( + "hno:%u, init single vd info NOK, vir_id[%d] > max[%d]\n", + PS3_HOST(instance), virtDiskIdx, + PS3_MAX_VD_COUNT(instance)); p_vd_entry = NULL; goto l_out; } INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN, dev); if (PS3_CHANNEL(&p_vd_entry->diskPos) != dev->softChan || - PS3_TARGET(&p_vd_entry->diskPos) != dev->devID) { - LOG_ERROR("hno:%u single add VD[%u:%u:%u] != req VD[%u:%u:%u] magic[%#x] unmatched\n", + PS3_TARGET(&p_vd_entry->diskPos) != dev->devID) { + LOG_ERROR( + "hno:%u single add VD[%u:%u:%u] != req VD[%u:%u:%u] magic[%#x] unmatched\n", PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID, PS3_CHANNEL(&p_vd_entry->diskPos), PS3_TARGET(&p_vd_entry->diskPos), @@ -478,73 +503,71 @@ static struct PS3VDEntry *ps3_get_single_vd_info(struct ps3_instance *instance, ps3_vd_busy_scale_get(p_vd_entry); LOG_DEBUG("hno:%u VD[%u:%u:%u] got single vd info success\n", - PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID); + PS3_HOST(instance), dev->softChan, dev->devID, + dev->virtDiskID); l_out: return p_vd_entry; } -static S32 ps3_update_single_vd_info(struct ps3_instance *instance, - struct PS3Dev *dev) +static int ps3_update_single_vd_info(struct ps3_instance *instance, + struct PS3Dev *dev) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct PS3VDEntry *p_vd_entry = NULL; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - U8 vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_vd_tb = - &p_dev_ctx->vd_table[vd_table_idx]; + unsigned char vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_vd_tb = &p_dev_ctx->vd_table[vd_table_idx]; struct PS3VDEntry *p_vd_array = p_dev_ctx->vd_entries_array[vd_table_idx]; - U16 virtDiskIdx = 0; + unsigned short virtDiskIdx = 0; p_vd_entry = ps3_get_single_vd_info(instance, dev); if (p_vd_entry == NULL) { - LOG_ERROR("hno:%u sync get VD info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u sync get VD info NOK\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&p_vd_entry->diskPos)); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&p_vd_entry->diskPos)); if (p_vd_entry->isHidden) { LOG_INFO("hno:%u single add VD[%u:%u] vd info is hidden\n", - PS3_HOST(instance), dev->softChan, dev->devID); + PS3_HOST(instance), dev->softChan, dev->devID); goto l_out; } ps3_qos_vd_init(instance, p_vd_entry); - memcpy(&p_vd_array[virtDiskIdx], - p_vd_entry, sizeof(struct PS3VDEntry)); + memcpy(&p_vd_array[virtDiskIdx], p_vd_entry, sizeof(struct PS3VDEntry)); p_vd_tb->vd_idxs[dev->softChan][dev->devID] = PS3_VDID(&p_vd_entry->diskPos); ps3_vd_info_show(instance, &p_vd_array[virtDiskIdx]); LOG_DEBUG("hno:%u, idx[%d], VD[%u:%u] single add, got vd info\n", - PS3_HOST(instance), p_dev_ctx->vd_table_idx, dev->softChan, - dev->devID); + PS3_HOST(instance), p_dev_ctx->vd_table_idx, dev->softChan, + dev->devID); l_out: return ret; } -static Bool _ps3_add_disk_prepare(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static unsigned char _ps3_add_disk_prepare(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { - Bool is_need_add = PS3_TRUE; + unsigned char is_need_add = PS3_TRUE; struct scsi_device *sdev = NULL; - U32 sdev_magic = 0; - U32 new_magic = 0; - S32 ret = PS3_SUCCESS; + unsigned int sdev_magic = 0; + unsigned int new_magic = 0; + int ret = PS3_SUCCESS; sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), 0); - if (sdev == NULL) { + PS3_TARGET(dev_pos), 0); + if (sdev == NULL) goto l_out; - } sdev_magic = ps3_scsi_dev_magic(instance, sdev); if (PS3_IS_VD_CHANNEL(instance, PS3_SDEV_CHANNEL(sdev)) || - ps3_sas_is_support_smp(instance)) { + ps3_sas_is_support_smp(instance)) { new_magic = dev_pos->diskMagicNum; } else { new_magic = dev_pos->checkSum; @@ -552,19 +575,20 @@ static Bool _ps3_add_disk_prepare(struct ps3_instance *instance, if (new_magic == sdev_magic) { LOG_INFO("hno:%u check magic same [%u:%u] magic[%#x]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev), - sdev_magic); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev), sdev_magic); + ps3_update_max_sectors(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), sdev); is_need_add = PS3_FALSE; } else { LOG_WARN("hno:%u check dev[%u:%u] magic is diff[%#x != %#x]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev), - new_magic, sdev_magic); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev), new_magic, sdev_magic); ret = _ps3_del_disk(instance, sdev); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u del dev[%u:%u] unexpect ret[%d]\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev), ret); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev), ret); } } ps3_scsi_device_put(instance, sdev); @@ -573,28 +597,29 @@ static Bool _ps3_add_disk_prepare(struct ps3_instance *instance, } void ps3_check_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry) + struct ps3_pd_entry *local_entry) { struct scsi_device *sdev = NULL; - if (!ps3_sas_is_support_smp(instance)) { + if (!ps3_sas_is_support_smp(instance)) goto l_out; - } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) +#if defined(PS3_SUPPORT_LINX80) (void)sdev; if (ps3_check_pd_is_vd_member(local_entry->config_flag)) { - LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u], begin\n", - PS3_HOST(instance), - PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN( + "hno:%u change ready to component, remove device channel[%u], id[%u], begin\n", + PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); - ps3_pd_del(instance, &local_entry->disk_pos, local_entry->config_flag); - LOG_WARN("hno:%u change ready to component, remove device channel[%u], id[%u] end\n", - PS3_HOST(instance), - PS3_CHANNEL(&local_entry->disk_pos), + ps3_pd_del(instance, &local_entry->disk_pos, + local_entry->config_flag); + LOG_WARN( + "hno:%u change ready to component, remove device channel[%u], id[%u] end\n", + PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); } else { ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), + sdev = ps3_scsi_device_lookup( + instance, PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos), 0); if (sdev) { ps3_scsi_device_put(instance, sdev); @@ -603,43 +628,55 @@ void ps3_check_vd_member_change(struct ps3_instance *instance, ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); ps3_linx80_vd_member_change(instance, local_entry); } - LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], begin\n", - PS3_HOST(instance), - PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN( + "hno:%u change component to ready, add device channel[%u], id[%u], begin\n", + PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); ps3_pd_add(instance, &local_entry->disk_pos); - LOG_WARN("hno:%u change component to ready, add device channel[%u], id[%u], end\n", - PS3_HOST(instance), - PS3_CHANNEL(&local_entry->disk_pos), + LOG_WARN( + "hno:%u change component to ready, add device channel[%u], id[%u], end\n", + PS3_HOST(instance), PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos)); } #else - INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, PS3_ERR_IJ_OS_SCAN, NULL); + INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, + PS3_ERR_IJ_OS_SCAN, NULL); INJECT_START(PS3_ERR_IJ_OS_SCAN, NULL); ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(&local_entry->disk_pos), - PS3_TARGET(&local_entry->disk_pos), 0); + sdev = ps3_scsi_device_lookup(instance, + PS3_CHANNEL(&local_entry->disk_pos), + PS3_TARGET(&local_entry->disk_pos), 0); if (sdev) { if (ps3_check_pd_is_vd_member(local_entry->config_flag)) { if (sdev->no_uld_attach != 1) { sdev->no_uld_attach = 1; - ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_TRUE); - LOG_WARN("hno:%u pd[%u:%u] change ready to component start\n", - PS3_HOST(instance), sdev->channel, sdev->id); + ps3_qos_vd_member_change(instance, local_entry, + sdev, PS3_TRUE); + LOG_WARN( + "hno:%u pd[%u:%u] change ready to component start\n", + PS3_HOST(instance), sdev->channel, + sdev->id); PS3_WARN_ON(scsi_device_reprobe(sdev)); - LOG_WARN("hno:%u pd[%u:%u] change ready to component end\n", - PS3_HOST(instance), sdev->channel, sdev->id); + LOG_WARN( + "hno:%u pd[%u:%u] change ready to component end\n", + PS3_HOST(instance), sdev->channel, + sdev->id); } } else { if (sdev->no_uld_attach != 0) { sdev->no_uld_attach = 0; - ps3_qos_vd_member_change(instance, local_entry, sdev, PS3_FALSE); - LOG_WARN("hno:%u pd[%u:%u] change component to ready start\n", - PS3_HOST(instance), sdev->channel, sdev->id); + ps3_qos_vd_member_change(instance, local_entry, + sdev, PS3_FALSE); + LOG_WARN( + "hno:%u pd[%u:%u] change component to ready start\n", + PS3_HOST(instance), sdev->channel, + sdev->id); PS3_WARN_ON(scsi_device_reprobe(sdev)); - LOG_WARN("hno:%u pd[%u:%u] change component to ready end\n", - PS3_HOST(instance), sdev->channel, sdev->id); + LOG_WARN( + "hno:%u pd[%u:%u] change component to ready end\n", + PS3_HOST(instance), sdev->channel, + sdev->id); } } ps3_scsi_device_put(instance, sdev); @@ -650,92 +687,92 @@ void ps3_check_vd_member_change(struct ps3_instance *instance, return; } -static struct PS3DiskDevPos* ps3_get_info_pos( - struct ps3_instance *instance, U8 channel, U16 target_id, U8 disk_type) +static struct PS3DiskDevPos *ps3_get_info_pos(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char disk_type) { struct PS3DiskDevPos *disk_Pos_ret = NULL; struct ps3_pd_entry *pd_entry = NULL; struct PS3VDEntry *vd_entry = NULL; if (disk_type == PS3_DISK_TYPE_PD) { - pd_entry = ps3_dev_mgr_lookup_pd_info(instance, - channel, target_id); - if (pd_entry != NULL) { + pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, + target_id); + if (pd_entry != NULL) disk_Pos_ret = &pd_entry->disk_pos; - } - } - else if (disk_type == PS3_DISK_TYPE_VD) { - vd_entry = ps3_dev_mgr_lookup_vd_info(instance, - channel, target_id); - if (vd_entry != NULL) { + } else if (disk_type == PS3_DISK_TYPE_VD) { + vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, + target_id); + if (vd_entry != NULL) disk_Pos_ret = &vd_entry->diskPos; - } } return disk_Pos_ret; } -static inline S32 ps3_add_disk(struct ps3_instance *instance, - struct PS3DiskDevPos* dev_pos, U8 disk_type) +static inline int ps3_add_disk(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, + unsigned char disk_type) { - S32 ret = PS3_SUCCESS; - struct PS3DiskDevPos* dev_pos_newes = NULL; + int ret = PS3_SUCCESS; + struct PS3DiskDevPos *dev_pos_newes = NULL; if (disk_type == PS3_DISK_TYPE_PD) { - ret = ps3_dev_mgr_pd_info_get(instance, - PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), PS3_PDID(dev_pos)); - } - else if (disk_type == PS3_DISK_TYPE_VD) { - ret = ps3_update_single_vd_info(instance, &dev_pos->diskDev.ps3Dev); + ret = ps3_dev_mgr_pd_info_get(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), + PS3_PDID(dev_pos)); + } else if (disk_type == PS3_DISK_TYPE_VD) { + ret = ps3_update_single_vd_info(instance, + &dev_pos->diskDev.ps3Dev); } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u single add dev[%u:%u] get info NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } dev_pos_newes = ps3_get_info_pos(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), disk_type); + PS3_TARGET(dev_pos), disk_type); if (dev_pos_newes == NULL) { ret = -PS3_FAILED; LOG_WARN("hno:%u update pos[%u:%u] invalid\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, - PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); - if (!_ps3_add_disk_prepare(instance, dev_pos_newes)) { + PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + if (!_ps3_add_disk_prepare(instance, dev_pos_newes)) goto l_out; - } INJECT_START_AT_TIME_WAIT_REV_PRE(PS3_ERR_IJ_ADD_DEV_WAIT_OS_PRIV_DATA, - PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); + PS3_ERR_IJ_GET_PRIV_DATA_DELAY, NULL); ret = _ps3_add_disk(instance, PS3_CHANNEL(dev_pos_newes), - PS3_TARGET(dev_pos_newes), disk_type); + PS3_TARGET(dev_pos_newes), disk_type); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u single add dev[%u:%u] NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos_newes), - PS3_TARGET(dev_pos_newes)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos_newes), + PS3_TARGET(dev_pos_newes)); goto l_out; } l_out: return ret; } -static S32 ps3_pd_add(struct ps3_instance *instance, - struct PS3DiskDevPos* dev_pos) +static int ps3_pd_add(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; + ps3_mutex_lock(&instance->dev_context.dev_scan_lock); - if (unlikely(!PS3_IS_PD_CHANNEL(instance, - PS3_CHANNEL(dev_pos)))) { - LOG_ERROR("hno:%u pd[%u:%u] single add, but channel is not pd\n", + if (unlikely(!PS3_IS_PD_CHANNEL(instance, PS3_CHANNEL(dev_pos)))) { + LOG_ERROR( + "hno:%u pd[%u:%u] single add, but channel is not pd\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); PS3_BUG(); @@ -744,8 +781,7 @@ static S32 ps3_pd_add(struct ps3_instance *instance, ret = ps3_add_disk(instance, dev_pos, PS3_DISK_TYPE_PD); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add PD NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u add PD NOK\n", PS3_HOST(instance)); goto l_out; } l_out: @@ -754,33 +790,39 @@ static S32 ps3_pd_add(struct ps3_instance *instance, return ret; } -static Bool ps3_pd_ext_del_done_check(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos) +static unsigned char ps3_pd_ext_del_done_check(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { struct scsi_device *sdev = NULL; - Bool is_need_del_done = PS3_FALSE; - S32 ret = PS3_SUCCESS; + unsigned char is_need_del_done = PS3_FALSE; + int ret = PS3_SUCCESS; #ifdef _WINDOWS - sdev = ps3_scsi_device_lookup_win(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); - if (unlikely(sdev == NULL || sdev->add_ack != 1)) { + sdev = ps3_scsi_device_lookup_win(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); + if (unlikely(sdev == NULL || sdev->add_ack != 1)) is_need_del_done = TRUE; - } #else struct ps3_pd_entry *pd_entry = NULL; - sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), 0); - if(unlikely(sdev == NULL)) { + sdev = ps3_scsi_device_lookup(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), 0); + if (unlikely(sdev == NULL)) { if (ps3_sas_is_support_smp(instance)) { - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, - PS3_PDID(dev_pos)); + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, PS3_PDID(dev_pos)); if (pd_entry != NULL && pd_entry->sas_rphy != NULL) { - ps3_sas_remove_device(instance, &pd_entry->disk_pos, - pd_entry->encl_id, pd_entry->phy_id); + ps3_sas_remove_device(instance, + &pd_entry->disk_pos, + pd_entry->encl_id, + pd_entry->phy_id); } else { - LOG_ERROR("hno:%u, can not found PD [%u:%u:%u] pd_entry:%p or sas_rphy is NULL\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), PS3_PDID(dev_pos), pd_entry); + LOG_ERROR( + "hno:%u, can not found PD [%u:%u:%u] pd_entry:%p or sas_rphy is NULL\n", + PS3_HOST(instance), + PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), PS3_PDID(dev_pos), + pd_entry); } } is_need_del_done = PS3_TRUE; @@ -788,13 +830,15 @@ static Bool ps3_pd_ext_del_done_check(struct ps3_instance *instance, #endif if (is_need_del_done) { LOG_WARN("hno:%u dev id[%u:%u] not exist scsi device\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); ret = ps3_scsi_remove_device_done(instance, dev_pos, - PS3_DISK_TYPE_PD); + PS3_DISK_TYPE_PD); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL7, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u dev[%u:%u:%u] magic[%#x] dev del done NOK %d\n", + LOG_ERROR( + "hno:%u dev[%u:%u:%u] magic[%#x] dev del done NOK %d\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), PS3_PDID(dev_pos), dev_pos->diskMagicNum, ret); @@ -806,18 +850,18 @@ static Bool ps3_pd_ext_del_done_check(struct ps3_instance *instance, return is_need_del_done; } -static S32 ps3_pd_del(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, U8 config_flag) +static int ps3_pd_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, unsigned char config_flag) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - struct ps3_pd_table* p_pd_tb = &p_dev_ctx->pd_table; - U16 disk_idx = 0; + struct ps3_pd_table *p_pd_tb = &p_dev_ctx->pd_table; + unsigned short disk_idx = 0; ps3_mutex_lock(&instance->dev_context.dev_scan_lock); if (!ps3_dev_id_valid_check(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos),PS3_DISK_TYPE_PD)) { + PS3_TARGET(dev_pos), PS3_DISK_TYPE_PD)) { PS3_BUG(); goto l_out; } @@ -830,30 +874,33 @@ static S32 ps3_pd_del(struct ps3_instance *instance, ret = ps3_del_disk(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL8, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u unable to delete scsi device PD[%u:%u] ret %d\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos), ret); + LOG_ERROR( + "hno:%u unable to delete scsi device PD[%u:%u] ret %d\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos), ret); goto l_out; } l_clean_again: disk_idx = p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)]; - p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)] = PS3_INVALID_VALUE; + p_pd_tb->pd_idxs[PS3_CHANNEL(dev_pos)][PS3_TARGET(dev_pos)] = + PS3_INVALID_VALUE; p_dev_ctx->pd_entries_array[disk_idx].config_flag = config_flag; l_out: ps3_mutex_unlock(&instance->dev_context.dev_scan_lock); return ret; - } -static S32 ps3_vd_add(struct ps3_instance *instance, - struct PS3DiskDevPos* dev_pos) +static int ps3_vd_add(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { - S32 ret = -PS3_FAILED; - struct PS3Dev* dev = &dev_pos->diskDev.ps3Dev; + int ret = -PS3_FAILED; + struct PS3Dev *dev = &dev_pos->diskDev.ps3Dev; if (unlikely(!PS3_IS_VD_CHANNEL(instance, dev->softChan))) { - LOG_ERROR("hno:%u VD[%u:%u] single add, but channel is not vd\n", + LOG_ERROR( + "hno:%u VD[%u:%u] single add, but channel is not vd\n", PS3_HOST(instance), dev->softChan, dev->devID); PS3_BUG(); goto l_out; @@ -861,21 +908,20 @@ static S32 ps3_vd_add(struct ps3_instance *instance, ret = ps3_add_disk(instance, dev_pos, PS3_DISK_TYPE_VD); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u add VD NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u add VD NOK\n", PS3_HOST(instance)); goto l_out; } l_out: return ret; } -static S32 ps3_vd_del(struct ps3_instance *instance, - U8 channel, U16 target_id) +static int ps3_vd_del(struct ps3_instance *instance, unsigned char channel, + unsigned short target_id) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; if (!ps3_dev_id_valid_check(instance, channel, target_id, - PS3_DISK_TYPE_VD)) { + PS3_DISK_TYPE_VD)) { PS3_BUG(); goto l_out; } @@ -883,7 +929,8 @@ static S32 ps3_vd_del(struct ps3_instance *instance, ret = ps3_del_disk(instance, channel, target_id); INJECT_START(PS3_ERR_IJ_FORCE_RET_FAIL4, &ret); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u unable to delete scsi device VD[%u:%u] ret %d\n", + LOG_ERROR( + "hno:%u unable to delete scsi device VD[%u:%u] ret %d\n", PS3_HOST(instance), channel, target_id, ret); goto l_out; } @@ -892,17 +939,16 @@ static S32 ps3_vd_del(struct ps3_instance *instance, return ret; } -static S32 ps3_vd_hidden_change(struct ps3_instance *instance, - struct PS3Dev* dev) +static int ps3_vd_hidden_change(struct ps3_instance *instance, + struct PS3Dev *dev) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct PS3VDEntry *p_vd_entry = NULL; struct PS3DiskDevPos disk_pos; p_vd_entry = ps3_get_single_vd_info(instance, dev); if (unlikely(p_vd_entry == NULL)) { - LOG_ERROR("hno:%u sync get VD info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u sync get VD info NOK\n", PS3_HOST(instance)); goto l_out; } @@ -910,11 +956,13 @@ static S32 ps3_vd_hidden_change(struct ps3_instance *instance, disk_pos = p_vd_entry->diskPos; ret = ps3_vd_add(instance, &disk_pos); } else { - ret = ps3_vd_del(instance, (U8)dev->softChan, dev->devID); + ret = ps3_vd_del(instance, (unsigned char)dev->softChan, + dev->devID); } if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u vd hidden change NOK, dev[%u:%u:%u], ret[%d]\n", + LOG_ERROR( + "hno:%u vd hidden change NOK, dev[%u:%u:%u], ret[%d]\n", PS3_HOST(instance), dev->softChan, dev->devID, dev->virtDiskID, ret); ret = -PS3_FAILED; @@ -924,21 +972,24 @@ static S32 ps3_vd_hidden_change(struct ps3_instance *instance, return ret; } -static inline Bool ps3_check_pd_is_same(struct ps3_instance *instance, - struct PS3DiskDevPos* src_dev_pos, struct PS3DiskDevPos* dest_dev_pos) +static inline unsigned char +ps3_check_pd_is_same(struct ps3_instance *instance, + struct PS3DiskDevPos *src_dev_pos, + struct PS3DiskDevPos *dest_dev_pos) { - Bool ret_valid = PS3_FALSE; + unsigned char ret_valid = PS3_FALSE; if (likely(dest_dev_pos->diskMagicNum == src_dev_pos->diskMagicNum && - PS3_DISKID(dest_dev_pos) == PS3_DISKID(src_dev_pos))) { + PS3_DISKID(dest_dev_pos) == PS3_DISKID(src_dev_pos))) { LOG_DEBUG("hno:%u check pd id same [%u:%u:%u] magic[%#x]\n", - PS3_HOST(instance), PS3_CHANNEL(dest_dev_pos), - PS3_TARGET(dest_dev_pos), PS3_PDID(dest_dev_pos), - src_dev_pos->diskMagicNum); + PS3_HOST(instance), PS3_CHANNEL(dest_dev_pos), + PS3_TARGET(dest_dev_pos), PS3_PDID(dest_dev_pos), + src_dev_pos->diskMagicNum); ret_valid = PS3_TRUE; } else { - LOG_FILE_WARN("hno:%u check mismatch, src dev[%u:%u:%u] magic[%#x], " - "dest dev[%u:%u:%u] magic[%#x]\n", + LOG_FILE_WARN( + "hno:%u check mismatch, src dev[%u:%u:%u] magic[%#x]\n" + "\tdest dev[%u:%u:%u] magic[%#x]\n", PS3_HOST(instance), PS3_CHANNEL(src_dev_pos), PS3_TARGET(src_dev_pos), PS3_PDID(src_dev_pos), src_dev_pos->diskMagicNum, PS3_CHANNEL(dest_dev_pos), @@ -948,15 +999,17 @@ static inline Bool ps3_check_pd_is_same(struct ps3_instance *instance, return ret_valid; } -static inline void ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry, - union PS3Device *list_item, Bool is_raid) +static inline void +ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry, + union PS3Device *list_item, unsigned char is_raid) { if (unlikely((local_entry->disk_pos.diskMagicNum != - list_item->pd.diskPos.diskMagicNum) || - (PS3_DISKID(&local_entry->disk_pos) != - PS3_DISKID(&list_item->pd.diskPos)))) { - LOG_ERROR("Device is mismatch, local entry device[%u:%u:%u] " - "and magic[%#x], new device[%u:%u:%u] and magic[%#x]\n", + list_item->pd.diskPos.diskMagicNum) || + (PS3_DISKID(&local_entry->disk_pos) != + PS3_DISKID(&list_item->pd.diskPos)))) { + LOG_ERROR( + "Device is mismatch, local entry device[%u:%u:%u]\n" + "\tand magic[%#x], new device[%u:%u:%u] and magic[%#x]\n", PS3_CHANNEL(&local_entry->disk_pos), PS3_TARGET(&local_entry->disk_pos), PS3_PDID(&local_entry->disk_pos), @@ -971,20 +1024,25 @@ static inline void ps3_update_info_by_list_item(struct ps3_pd_entry *local_entry local_entry->config_flag = list_item->pd.configFlag; local_entry->state = list_item->pd.diskState; LOG_INFO("single pd info update PD[%u:%u] config_flag[%s], state[%s]\n", - PS3_CHANNEL(&list_item->pd.diskPos), PS3_TARGET(&list_item->pd.diskPos), - getPdStateName((MicPdState_e)local_entry->config_flag, is_raid), - getDeviceStateName((DeviceState_e)local_entry->state)); + PS3_CHANNEL(&list_item->pd.diskPos), + PS3_TARGET(&list_item->pd.diskPos), + getPdStateName((enum MicPdState)local_entry->config_flag, + is_raid), + getDeviceStateName((enum DeviceState)local_entry->state)); } -static S32 ps3_update_single_pd_info(struct ps3_instance *instance, - struct PS3DiskDevPos *dev_pos, union PS3Device *list_item) +static int ps3_update_single_pd_info(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos, + union PS3Device *list_item) { - S32 ret = PS3_SUCCESS; - U8 channel = dev_pos->diskDev.ps3Dev.softChan; + int ret = PS3_SUCCESS; + unsigned char channel = dev_pos->diskDev.ps3Dev.softChan; struct ps3_pd_entry *p_pd_entry = NULL; + INJECT_START(PS3_ERR_IJ_FORCE_MOD_CHAN1, &channel); if (unlikely(!PS3_IS_PD_CHANNEL(instance, channel))) { - LOG_ERROR("hno:%u , PD[%u:%u] info update, but channel is not pd\n", + LOG_ERROR( + "hno:%u , PD[%u:%u] info update, but channel is not pd\n", PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); ret = -PS3_FAILED; @@ -992,41 +1050,45 @@ static S32 ps3_update_single_pd_info(struct ps3_instance *instance, goto l_out; } - p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, - PS3_PDID(dev_pos)); + p_pd_entry = + ps3_dev_mgr_lookup_pd_info_by_id(instance, PS3_PDID(dev_pos)); if (p_pd_entry == NULL) { - LOG_FILE_WARN("hno:%u single PD info update[%u:%u], cannot find entry\n", - PS3_HOST(instance), - PS3_CHANNEL(dev_pos), + LOG_FILE_WARN( + "hno:%u single PD info update[%u:%u], cannot find entry\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); } - if (p_pd_entry != NULL && !ps3_check_pd_is_same(instance, - &p_pd_entry->disk_pos, dev_pos) && list_item) { - ps3_update_info_by_list_item(p_pd_entry, list_item, instance->is_raid); + if (p_pd_entry != NULL && + !ps3_check_pd_is_same(instance, &p_pd_entry->disk_pos, dev_pos) && + list_item) { + ps3_update_info_by_list_item(p_pd_entry, list_item, + instance->is_raid); } else { ret = ps3_dev_mgr_pd_info_get(instance, PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos), PS3_PDID(dev_pos)); + PS3_TARGET(dev_pos), + PS3_PDID(dev_pos)); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, single add get PD[%u:%u] info NOK\n", - PS3_HOST(instance), PS3_CHANNEL(dev_pos), - PS3_TARGET(dev_pos)); + PS3_HOST(instance), PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); goto l_out; } - p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, - PS3_PDID(dev_pos)); + p_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, PS3_PDID(dev_pos)); if (p_pd_entry == NULL) { - LOG_WARN("hno:%u single PD info update[%u:%u], cannot find new entry\n", - PS3_HOST(instance), - PS3_CHANNEL(dev_pos), + LOG_WARN( + "hno:%u single PD info update[%u:%u], cannot find new entry\n", + PS3_HOST(instance), PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); goto l_out; } } if (instance->ioc_adpter->check_vd_member_change != NULL) { - instance->ioc_adpter->check_vd_member_change(instance, p_pd_entry); + instance->ioc_adpter->check_vd_member_change(instance, + p_pd_entry); } l_out: @@ -1034,12 +1096,12 @@ static S32 ps3_update_single_pd_info(struct ps3_instance *instance, } static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, - U32 event_cnt) + unsigned int event_cnt) { - U8 i = 0; - U8 vd_count_idx = 0XFF; - U8 pd_count_idx = 0XFF; - U8 pd_info_idx = 0XFF; + unsigned char i = 0; + unsigned char vd_count_idx = 0XFF; + unsigned char pd_count_idx = 0XFF; + unsigned char pd_info_idx = 0XFF; for (i = 0; i < event_cnt; i++) { switch (event_detail[i].eventCode) { @@ -1062,18 +1124,20 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } if (pd_count_idx == 0xFF && vd_count_idx == 0xFF && - pd_info_idx == 0xFF) { + pd_info_idx == 0xFF) { return; } - LOG_DEBUG("detail update pd_count_idx[%d], vd_count_idx[%d], pd_info_idx[%d]\n", + LOG_DEBUG( + "detail update pd_count_idx[%d], vd_count_idx[%d], pd_info_idx[%d]\n", pd_count_idx, vd_count_idx, pd_info_idx); for (i = 0; i < event_cnt; i++) { switch (event_detail[i].eventType) { case PS3_EVT_PD_COUNT: - if (pd_count_idx !=0xFF && pd_count_idx != i) { - LOG_DEBUG("detail update remove %d eventCode[%d]\n", + if (pd_count_idx != 0xFF && pd_count_idx != i) { + LOG_DEBUG( + "detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1082,8 +1146,9 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } break; case PS3_EVT_VD_COUNT: - if (vd_count_idx !=0xFF && vd_count_idx != i) { - LOG_DEBUG("detail update remove %d eventCode[%d]\n", + if (vd_count_idx != 0xFF && vd_count_idx != i) { + LOG_DEBUG( + "detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1092,8 +1157,9 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } break; case PS3_EVT_PD_ATTR: - if (pd_info_idx !=0xFF && pd_info_idx != i) { - LOG_DEBUG("detail update remove %d eventCode[%d]\n", + if (pd_info_idx != 0xFF && pd_info_idx != i) { + LOG_DEBUG( + "detail update remove %d eventCode[%d]\n", i, event_detail[i].eventCode); event_detail[i].eventType = PS3_EVT_ILLEGAL_TYPE; @@ -1108,17 +1174,17 @@ static void ps3_dev_update_pre_check(struct PS3EventDetail *event_detail, } } -static Bool ps3_get_sdev_pose_by_chl_tid(struct ps3_instance *instance, - const U8 channel, const U16 target_id, struct PS3DiskDevPos *disk_Pos) +static unsigned char ps3_get_sdev_pose_by_chl_tid( + struct ps3_instance *instance, const unsigned char channel, + const unsigned short target_id, struct PS3DiskDevPos *disk_Pos) { struct scsi_device *sdev = NULL; struct ps3_scsi_priv_data *scsi_priv = NULL; - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; sdev = ps3_scsi_device_lookup(instance, channel, target_id, 0); - if(unlikely(sdev == NULL)) { + if (unlikely(sdev == NULL)) ret = PS3_FALSE; - } if (ret) { ps3_mutex_lock(&instance->dev_context.dev_priv_lock); scsi_priv = PS3_SDEV_PRI_DATA(sdev); @@ -1126,8 +1192,10 @@ static Bool ps3_get_sdev_pose_by_chl_tid(struct ps3_instance *instance, *disk_Pos = scsi_priv->disk_pos; } else { ret = PS3_FALSE; - LOG_DEBUG("hno:%u get sdev pos, priv data NULL, [%u:%u],\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); + LOG_DEBUG( + "hno:%u get sdev pos, priv data NULL, [%u:%u],\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); } ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ps3_scsi_device_put(instance, sdev); @@ -1136,38 +1204,40 @@ static Bool ps3_get_sdev_pose_by_chl_tid(struct ps3_instance *instance, return ret; } -static S32 _ps3_add_remove_multi_pd(struct ps3_instance *instance, - U8 channel, U16 target_id) +static int _ps3_add_remove_multi_pd(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id) { - S32 ret = PS3_SUCCESS; - S32 ret_tmp = PS3_SUCCESS; - union PS3Device* p_dev = NULL; + int ret = PS3_SUCCESS; + int ret_tmp = PS3_SUCCESS; + union PS3Device *p_dev = NULL; struct PS3DiskDevPos pd_Pos; - U8 config_flag = MIC_PD_STATE_UNKNOWN; + unsigned char config_flag = MIC_PD_STATE_UNKNOWN; p_dev = ps3_dev_mgr_lookup_pd_list(instance, channel, target_id); if (p_dev == NULL) { - if (ps3_get_sdev_pose_by_chl_tid(instance, channel, - target_id, &pd_Pos)) { + if (ps3_get_sdev_pose_by_chl_tid(instance, channel, target_id, + &pd_Pos)) { ret_tmp = ps3_pd_del(instance, &pd_Pos, - MIC_PD_STATE_UNKNOWN); + MIC_PD_STATE_UNKNOWN); } goto l_out; } - if (ps3_pd_scsi_visible_check(instance, &p_dev->pd.diskPos, - ps3_get_converted_dev_type(p_dev->pd.driverType, - p_dev->pd.mediumType), p_dev->pd.configFlag, - p_dev->pd.diskState)) { + if (ps3_pd_scsi_visible_check( + instance, &p_dev->pd.diskPos, + ps3_get_converted_dev_type(p_dev->pd.driverType, + p_dev->pd.mediumType), + p_dev->pd.configFlag, p_dev->pd.diskState)) { ret_tmp = ps3_pd_add(instance, &p_dev->pd.diskPos); } else { - - ret_tmp = ps3_dev_mgr_pd_info_get(instance, - channel, target_id, PS3_PDID(&p_dev->pd.diskPos)); + ret_tmp = ps3_dev_mgr_pd_info_get(instance, channel, target_id, + PS3_PDID(&p_dev->pd.diskPos)); if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u get pd info NOK, [%u:%u], ret[%d]\n", - PS3_HOST(instance), channel, target_id, ret_tmp); + PS3_HOST(instance), channel, target_id, + ret_tmp); ret = -PS3_FAILED; } config_flag = p_dev->pd.configFlag; @@ -1178,164 +1248,195 @@ static S32 _ps3_add_remove_multi_pd(struct ps3_instance *instance, if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u add or del pd NOK, [%u:%u], ret[%d]\n", - PS3_HOST(instance), channel, target_id, ret_tmp); + PS3_HOST(instance), channel, target_id, ret_tmp); ret = -PS3_FAILED; } return ret; } -static S32 ps3_add_remove_multi_pd(struct ps3_instance *instance) +static int ps3_add_remove_multi_pd(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 ret_tmp = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; - U8 chan_id = 0; + int ret = PS3_SUCCESS; + int ret_tmp = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; + unsigned char chan_id = 0; struct ps3_channel *pd_chan = instance->dev_context.channel_pd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; LOG_DEBUG("hno:%u, ready to update full pd count\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = ps3_dev_mgr_pd_list_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get pd list NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u get pd list NOK\n", PS3_HOST(instance)); goto l_out; } for (i = 0; i < p_dev_ctx->pd_channel_count; i++) { chan_id = pd_chan[i].channel; for (j = 0; j < pd_chan[i].max_dev_num; j++) { - ret_tmp = _ps3_add_remove_multi_pd(instance, chan_id, j); - if (ret_tmp != PS3_SUCCESS) { + if (!instance->state_machine.is_load) { ret = -PS3_FAILED; + LOG_INFO("hno:%u, instance unload, break\n", PS3_HOST(instance)); + goto l_out; } + ret_tmp = + _ps3_add_remove_multi_pd(instance, chan_id, j); + if (ret_tmp != PS3_SUCCESS) + ret = -PS3_FAILED; } } l_out: - LOG_DEBUG("hno:%u, update full pd count end\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u, update full pd count end\n", PS3_HOST(instance)); return ret; } -static S32 ps3_add_remove_multi_vd(struct ps3_instance *instance) +static int ps3_add_remove_multi_vd(struct ps3_instance *instance) { - S32 ret_tmp = PS3_SUCCESS; - S32 ret = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; - U8 chan_id = 0; + int ret_tmp = PS3_SUCCESS; + int ret = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; + unsigned char chan_id = 0; struct ps3_channel *vd_chan = instance->dev_context.channel_vd; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; - union PS3Device* p_dev = NULL; + union PS3Device *p_dev = NULL; - LOG_DEBUG("hno:%u ready to update full vd count\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready to update full vd count\n", PS3_HOST(instance)); ret = ps3_dev_mgr_vd_list_get(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get vd list NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u get vd list NOK\n", PS3_HOST(instance)); goto l_out; } for (i = 0; i < p_dev_ctx->vd_channel_count; i++) { chan_id = vd_chan[i].channel; for (j = 0; j < vd_chan[i].max_dev_num; j++) { - - p_dev = ps3_dev_mgr_lookup_vd_list(instance, chan_id, j); - if (p_dev != NULL && ps3_vd_scsi_visible_check(instance, - &p_dev->vd.diskPos, p_dev->vd.isHidden, p_dev->vd.diskState)) { - ret_tmp = ps3_vd_add(instance, &p_dev->pd.diskPos); + if (!instance->state_machine.is_load) { + ret = -PS3_FAILED; + LOG_INFO("hno:%u, instance unload, break\n", PS3_HOST(instance)); + goto l_out; + } + p_dev = ps3_dev_mgr_lookup_vd_list(instance, chan_id, + j); + if (p_dev != NULL && + ps3_vd_scsi_visible_check( + instance, &p_dev->vd.diskPos, + p_dev->vd.isHidden, p_dev->vd.diskState)) { + ret_tmp = ps3_vd_add(instance, + &p_dev->pd.diskPos); } else { ret_tmp = ps3_vd_del(instance, chan_id, j); } if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR("hno:%u update vd[%u:%u] count NOK, ret[%d]\n", - PS3_HOST(instance), chan_id, j, ret_tmp); + LOG_ERROR( + "hno:%u update vd[%u:%u] count NOK, ret[%d]\n", + PS3_HOST(instance), chan_id, j, + ret_tmp); ret = -PS3_FAILED; } } } l_out: - LOG_DEBUG("hno:%u update full vd count end\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u update full vd count end\n", PS3_HOST(instance)); return ret; } -static S32 ps3_update_multi_pd_info(struct ps3_instance *instance) +static int ps3_update_multi_pd_info(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 ret_tmp = PS3_SUCCESS; - U16 i = 0; + int ret = PS3_SUCCESS; + int ret_tmp = PS3_SUCCESS; + unsigned short i = 0; struct ps3_dev_context *p_dev_ctx = &instance->dev_context; struct PS3DevList *p_pd_list = p_dev_ctx->pd_list_buf; struct PS3Dev *p_dev = NULL; +#if defined(PS3_DISALLOW_ZERO_ARRAY) + union PS3Device *devs = p_pd_list->devs; +#endif - LOG_DEBUG("hno:%u ready to update full pd info\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u ready to update full pd info\n", PS3_HOST(instance)); ret = ps3_pd_list_get(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u, dev mgr get pd list NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - LOG_INFO("hno:%u get pd list count is %d\n", - PS3_HOST(instance), p_pd_list->count); + LOG_INFO("hno:%u get pd list count is %d\n", PS3_HOST(instance), + p_pd_list->count); for (i = 0; i < p_pd_list->count; i++) { + if (!instance->state_machine.is_load) { + ret = -PS3_FAILED; + LOG_INFO("hno:%u, instance unload, break\n", PS3_HOST(instance)); + goto l_out; + } +#if defined(PS3_DISALLOW_ZERO_ARRAY) + p_dev = PS3_DEV(&devs[i].pd.diskPos); + if (PS3_DEV_INVALID(devs[i].pd.diskPos)) { +#else p_dev = PS3_DEV(&p_pd_list->devs[i].pd.diskPos); - if (PS3_PDID_INVALID(&p_pd_list->devs[i].pd.diskPos)) { +#endif LOG_WARN("hno:%u check pd list %d dev pdid is 0\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); continue; } - if (!ps3_dev_id_valid_check(instance, (U8)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_PD)) { + if (!ps3_dev_id_valid_check(instance, + (unsigned char)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_PD)) { PS3_BUG(); continue; } - LOG_INFO("hno:%u ready update pd info by list" - " %d dev[%u:%u:%u], magic[%#x], state[%s]\n", + LOG_INFO("hno:%u update pd info %d dev[%u:%u:%u], magic[%#x], state[%s]\n", PS3_HOST(instance), i, p_dev->softChan, p_dev->devID, p_dev->phyDiskID, - p_pd_list->devs[i].pd.diskPos.diskMagicNum, - getDeviceStateName((DeviceState_e)p_pd_list->devs[i].pd.diskState)); +#if defined(PS3_DISALLOW_ZERO_ARRAY) + devs[i].pd.diskPos.diskMagicNum, + getDeviceStateName((enum DeviceState)devs[i].pd.diskState)); + ret_tmp = ps3_update_single_pd_info(instance, &devs[i].pd.diskPos, + &devs[i]); +#else + p_pd_list->devs[i].pd.diskPos.diskMagicNum, + getDeviceStateName((enum DeviceState)p_pd_list->devs[i] + .pd.diskState)); - ret_tmp = ps3_update_single_pd_info(instance, &p_pd_list->devs[i].pd.diskPos, + ret_tmp = ps3_update_single_pd_info( + instance, &p_pd_list->devs[i].pd.diskPos, &p_pd_list->devs[i]); +#endif if (ret_tmp != PS3_SUCCESS) { LOG_ERROR("hno:%u NOK, %u:%u, ret[%d]\n", - PS3_HOST(instance), p_dev->softChan, p_dev->devID, ret_tmp); + PS3_HOST(instance), p_dev->softChan, + p_dev->devID, ret_tmp); ret = -PS3_FAILED; } } l_out: LOG_DEBUG("hno:%u update full pd info end ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); return ret; } -static inline S32 ps3_dev_evt_update_pd_count(struct ps3_instance *instance, - U32 eventCode, struct PS3DiskDevPos *dev_pos) +static inline int ps3_dev_evt_update_pd_count(struct ps3_instance *instance, + unsigned int eventCode, + struct PS3DiskDevPos *dev_pos) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - switch(eventCode) - { + switch (eventCode) { case PS3_EVT_CODE(MGR_EVT_DEVM_DISK_IN): case PS3_EVT_CODE(MGR_EVT_DEVM_JBOD): case PS3_EVT_CODE(MGR_EVT_DEVM_DISK_CHANGE): @@ -1356,22 +1457,25 @@ static inline S32 ps3_dev_evt_update_pd_count(struct ps3_instance *instance, return ret; } -static inline S32 ps3_dev_evt_update_vd_count(struct ps3_instance *instance, - U32 eventCode, struct PS3DiskDevPos *dev_pos) +static inline int ps3_dev_evt_update_vd_count(struct ps3_instance *instance, + unsigned int eventCode, + struct PS3DiskDevPos *dev_pos) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; switch (eventCode) { case PS3_EVT_CODE(MGR_EVT_VD_CREATED): case PS3_EVT_CODE(MGR_EVT_VD_OPTIMAL): case PS3_EVT_CODE(MGR_EVT_VD_PARTIAL_DEGRADE): case PS3_EVT_CODE(MGR_EVT_VD_DEGRADE): + case PS3_EVT_CODE(MGR_EVT_VD_CHANGE): case PS3_EVT_CODE(MGR_EVT_VD_UNLOCK): ret = ps3_vd_add(instance, dev_pos); break; case PS3_EVT_CODE(MGR_EVT_VD_DELETED): case PS3_EVT_CODE(MGR_EVT_VD_OFFLINE): - ret = ps3_vd_del(instance, PS3_CHANNEL(dev_pos), PS3_TARGET(dev_pos)); + ret = ps3_vd_del(instance, PS3_CHANNEL(dev_pos), + PS3_TARGET(dev_pos)); break; case PS3_EVT_CODE(MGR_EVT_VD_HIDDEN_CHANGE): ret = ps3_vd_hidden_change(instance, PS3_DEV(dev_pos)); @@ -1384,10 +1488,11 @@ static inline S32 ps3_dev_evt_update_vd_count(struct ps3_instance *instance, return ret; } -static inline S32 ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, - U32 eventCode, struct PS3DiskDevPos *dev_pos) +static inline int ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, + unsigned int eventCode, + struct PS3DiskDevPos *dev_pos) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; (void)eventCode; ret = ps3_update_single_pd_info(instance, dev_pos, NULL); @@ -1395,61 +1500,65 @@ static inline S32 ps3_dev_evt_update_pd_attr(struct ps3_instance *instance, return ret; } -S32 ps3_dev_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, U32 event_cnt) +int ps3_dev_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, + unsigned int event_cnt) { - S32 ret = PS3_SUCCESS; - S32 ret_map = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + int ret_map = PS3_SUCCESS; + unsigned int i = 0; - LOG_INFO("hno:%u, event detail count[%d]\n", - PS3_HOST(instance), event_cnt); + LOG_INFO("hno:%u, event detail count[%d]\n", PS3_HOST(instance), + event_cnt); ps3_dev_update_pre_check(event_detail, event_cnt); for (i = 0; i < event_cnt; i++) { - - LOG_INFO("hno:%u event detail %d event type[%s]," - " eventCode is [%s], dev[%u:%u:%u]\n", - PS3_HOST(instance), i, - nameMgrEvtType(event_detail[i].eventType), - mgrEvtCodeTrans(event_detail[i].eventCode), - PS3_CHANNEL(&event_detail[i].devicePos), - PS3_TARGET(&event_detail[i].devicePos), - PS3_VDID(&event_detail[i].devicePos)); + if (!instance->state_machine.is_load) { + INJECT_START(PS3_ERR_IJ_DETAIL_BREAK_CHECK2, instance); + LOG_INFO("hno:%u instance unload, break\n", PS3_HOST(instance)); + break; + } + LOG_INFO( + "hno:%u evt i %d evt type[%s], evtCode[%s], dev[%u:%u:%u]\n", + PS3_HOST(instance), i, + nameMgrEvtType(event_detail[i].eventType), + mgrEvtCodeTrans(event_detail[i].eventCode), + PS3_CHANNEL(&event_detail[i].devicePos), + PS3_TARGET(&event_detail[i].devicePos), + PS3_VDID(&event_detail[i].devicePos)); switch (event_detail[i].eventType) { case PS3_EVT_PD_COUNT: - ret = ps3_dev_evt_update_pd_count(instance, - event_detail[i].eventCode, + ret = ps3_dev_evt_update_pd_count( + instance, event_detail[i].eventCode, &event_detail[i].devicePos); break; case PS3_EVT_VD_COUNT: - ret = ps3_dev_evt_update_vd_count(instance, - event_detail[i].eventCode, + ret = ps3_dev_evt_update_vd_count( + instance, event_detail[i].eventCode, &event_detail[i].devicePos); break; case PS3_EVT_PD_ATTR: - ret = ps3_dev_evt_update_pd_attr(instance, - event_detail[i].eventCode, + ret = ps3_dev_evt_update_pd_attr( + instance, event_detail[i].eventCode, &event_detail[i].devicePos); break; default: break; } - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) ret_map |= event_detail[i].eventType; - } } return ret_map; } -S32 ps3_dev_update_full_proc(struct ps3_instance *instance, - MgrEvtType_e event_type) +int ps3_dev_update_full_proc(struct ps3_instance *instance, + enum MgrEvtType event_type) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; switch (event_type) { case PS3_EVT_PD_COUNT: @@ -1468,147 +1577,169 @@ S32 ps3_dev_update_full_proc(struct ps3_instance *instance, return ret; } -static S32 ps3_dev_vd_pending_resend(struct ps3_cmd *cmd) +static int ps3_dev_vd_pending_resend(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dev_context *p_dev_ctx = &cmd->instance->dev_context; - memset(p_dev_ctx->vd_info_buf_async, - 0, sizeof(struct PS3VDInfo)); - ps3_vd_pending_filter_table_build((U8*) - p_dev_ctx->vd_info_buf_async); + memset(p_dev_ctx->vd_info_buf_async, 0, sizeof(struct PS3VDInfo)); + + ps3_vd_pending_filter_table_build( + (unsigned char *)p_dev_ctx->vd_info_buf_async); PS3_MGR_CMD_STAT_INC(cmd->instance, cmd); ret = ps3_async_cmd_send(cmd->instance, cmd); if (ret != PS3_SUCCESS) { - LOG_FILE_ERROR("trace_id[0x%llx], hno:%u re send vd pending cmd faild\n", + LOG_FILE_ERROR( + "trace_id[0x%llx], hno:%u re send vd pending cmd failed\n", cmd->trace_id, PS3_HOST(cmd->instance)); } return ret; - } -static Bool ps3_dev_vd_pending_data_switch(struct ps3_cmd *cmd) +static unsigned char ps3_dev_vd_pending_data_switch(struct ps3_cmd *cmd) { - S32 i = 0; - Bool ret = PS3_FALSE; + int i = 0; + unsigned char ret = PS3_FALSE; struct ps3_dev_context *p_dev_ctx = &cmd->instance->dev_context; - U8 new_vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; - struct ps3_vd_table *p_new_vd_tb = &p_dev_ctx->vd_table[new_vd_table_idx]; - struct PS3VDEntry *p_new_vd_array = p_dev_ctx->vd_entries_array[new_vd_table_idx]; - U8 old_vd_table_idx = p_dev_ctx->vd_table_idx & 1; - struct ps3_vd_table *p_old_vd_tb = &p_dev_ctx->vd_table[old_vd_table_idx]; - struct PS3VDEntry *p_old_vd_array = p_dev_ctx->vd_entries_array[old_vd_table_idx]; + unsigned char new_vd_table_idx = (p_dev_ctx->vd_table_idx + 1) & 1; + struct ps3_vd_table *p_new_vd_tb = + &p_dev_ctx->vd_table[new_vd_table_idx]; + struct PS3VDEntry *p_new_vd_array = + p_dev_ctx->vd_entries_array[new_vd_table_idx]; + unsigned char old_vd_table_idx = p_dev_ctx->vd_table_idx & 1; + struct ps3_vd_table *p_old_vd_tb = + &p_dev_ctx->vd_table[old_vd_table_idx]; + struct PS3VDEntry *p_old_vd_array = + p_dev_ctx->vd_entries_array[old_vd_table_idx]; struct PS3VDEntry *p_vd_entry = p_dev_ctx->vd_info_buf_async->vds; struct PS3VDEntry *vd_entry_old = NULL; struct PS3Dev *p_dev = NULL; - U16 virtDiskIdx = PS3_INVALID_DEV_ID; + unsigned short virtDiskIdx = PS3_INVALID_DEV_ID; struct scsi_device *sdev = NULL; memcpy(p_new_vd_tb->vd_idxs_array, p_old_vd_tb->vd_idxs_array, - p_dev_ctx->total_vd_count * sizeof(U16)); - memcpy(p_new_vd_array, p_old_vd_array, (PS3_MAX_VD_COUNT(cmd->instance) + 1) * - sizeof(struct PS3VDEntry)); + p_dev_ctx->total_vd_count * sizeof(unsigned short)); + memcpy(p_new_vd_array, p_old_vd_array, + (PS3_MAX_VD_COUNT(cmd->instance) + 1) * + sizeof(struct PS3VDEntry)); for (i = 0; i < p_dev_ctx->vd_info_buf_async->count; i++) { if (PS3_VDID_INVALID(&p_vd_entry[i].diskPos)) { - LOG_WARN_IN_IRQ(cmd->instance, + LOG_WARN_IN_IRQ( + cmd->instance, "hno:%u, init %d of %d vd info NOK, vdid is 0\n", PS3_HOST(cmd->instance), i, p_dev_ctx->vd_info_buf_sync->count); continue; } p_dev = PS3_DEV(&p_vd_entry[i].diskPos); - if (!ps3_dev_id_valid_check(cmd->instance, (U8)p_dev->softChan, - p_dev->devID, PS3_DISK_TYPE_VD)) { - LOG_ERROR_IN_IRQ(cmd->instance, - "trace_id[0x%llx], hno:%u vd pending " - "%d err softchan:%d, or dev id > max, %d>%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), - i, p_dev->softChan, p_dev->devID, - p_dev_ctx->max_dev_in_channel[p_dev->softChan]); + if (!ps3_dev_id_valid_check(cmd->instance, + (unsigned char)p_dev->softChan, + p_dev->devID, PS3_DISK_TYPE_VD)) { + LOG_ERROR_IN_IRQ( + cmd->instance, + "tid[0x%llx], hno:%u vd pending %d err chan:%d, or devid>max, %d>%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), i, + p_dev->softChan, p_dev->devID, + p_dev_ctx->max_dev_in_channel[p_dev->softChan]); PS3_BUG_NO_SYNC(); continue; } - virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), p_dev->virtDiskID); + virtDiskIdx = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), + p_dev->virtDiskID); if (unlikely(virtDiskIdx > PS3_MAX_VD_COUNT(cmd->instance))) { - LOG_WARN_IN_IRQ(cmd->instance, "hno:%u, init %d of %d vd info NOK, vir_id[%d] > max[%d]\n", + LOG_WARN_IN_IRQ(cmd->instance, + "hno:%u, init %d of %d vd info NOK, v_id[%d]>max[%d]\n", PS3_HOST(cmd->instance), i, - p_dev_ctx->vd_info_buf_sync->count, - virtDiskIdx, PS3_MAX_VD_COUNT(cmd->instance)); + p_dev_ctx->vd_info_buf_sync->count, virtDiskIdx, + PS3_MAX_VD_COUNT(cmd->instance)); continue; } - LOG_INFO_IN_IRQ(cmd->instance, - "hno:%u update vd[%u:%u] info\n", + LOG_INFO_IN_IRQ(cmd->instance, "hno:%u update vd[%u:%u] info\n", PS3_HOST(cmd->instance), p_dev->softChan, p_dev->devID); ps3_qos_vd_init(cmd->instance, &p_vd_entry[i]); - vd_entry_old = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, p_dev->virtDiskID); - ps3_qos_vd_attr_change(cmd->instance, vd_entry_old, &p_vd_entry[i]); + vd_entry_old = ps3_dev_mgr_lookup_vd_info_by_id( + cmd->instance, p_dev->virtDiskID); + ps3_qos_vd_attr_change(cmd->instance, vd_entry_old, + &p_vd_entry[i]); p_new_vd_tb->vd_idxs[p_dev->softChan][p_dev->devID] = p_dev->virtDiskID; memcpy(&p_new_vd_array[virtDiskIdx], &p_vd_entry[i], - sizeof(struct PS3VDEntry)); + sizeof(struct PS3VDEntry)); - sdev = ps3_scsi_device_lookup(cmd->instance, p_dev->softChan, p_dev->devID, 0); - if(sdev != NULL) { + sdev = ps3_scsi_device_lookup(cmd->instance, p_dev->softChan, + p_dev->devID, 0); + if (sdev != NULL) { ps3_vd_busy_scale_get(&p_new_vd_array[virtDiskIdx]); +#if defined(PS3_SLAVE_CONFIG_SUPPORT) if (ps3_sdev_bdi_stable_writes_get(sdev)) { - if (!(p_vd_entry[i].bdev_bdi_cap & PS3_STABLE_WRITES_MASK)) { - ps3_sdev_bdi_stable_writes_clear(cmd->instance, sdev); + if (!(p_vd_entry[i].bdev_bdi_cap & + PS3_STABLE_WRITES_MASK)) { + ps3_sdev_bdi_stable_writes_clear( + cmd->instance, sdev); } } else { - if (p_vd_entry[i].bdev_bdi_cap & PS3_STABLE_WRITES_MASK) { - ps3_sdev_bdi_stable_writes_set(cmd->instance, sdev); + if (p_vd_entry[i].bdev_bdi_cap & + PS3_STABLE_WRITES_MASK) { + ps3_sdev_bdi_stable_writes_set( + cmd->instance, sdev); } } +#endif ps3_scsi_device_put(cmd->instance, sdev); } ps3_vd_info_show(cmd->instance, &p_new_vd_array[virtDiskIdx]); -#ifndef _WINDOWS + if (p_vd_entry[i].maxIOSize != 0) { - ps3_change_sdev_max_sector(cmd->instance, &p_vd_entry[i]); + ps3_change_sdev_max_sector(cmd->instance, + &p_vd_entry[i]); } else { - LOG_DEBUG("hno:%u vd[%u:%u] update max sector num is:0\n", - PS3_HOST(cmd->instance), p_dev->softChan, p_dev->devID); + LOG_DEBUG( + "hno:%u vd[%u:%u] update max sector num is:0\n", + PS3_HOST(cmd->instance), p_dev->softChan, + p_dev->devID); } -#endif } - mb(); - if ( p_dev_ctx->vd_table_idx == (PS3_VD_TABLE_NUM -1)) { + mb(); /* in order to force CPU ordering */ + if (p_dev_ctx->vd_table_idx == (PS3_VD_TABLE_NUM - 1)) p_dev_ctx->vd_table_idx = 0; - } else { + else p_dev_ctx->vd_table_idx++; - } - mb(); + mb(); /* in order to force CPU ordering */ - LOG_INFO_IN_IRQ(cmd->instance, + LOG_INFO_IN_IRQ( + cmd->instance, "trace_id[0x%llx], hno:%u vd pending change cur_idx to [%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), p_dev_ctx->vd_table_idx); + cmd->trace_id, PS3_HOST(cmd->instance), + p_dev_ctx->vd_table_idx); return ret; } -S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) +int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags) { - ULong flags = 0; - ULong flags1 = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + unsigned long flags1 = 0; + int ret = PS3_SUCCESS; struct ps3_dev_context *p_dev_ctx = NULL; struct ps3_instance *instance = cmd->instance; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int cur_state = PS3_INSTANCE_STATE_INIT; p_dev_ctx = &instance->dev_context; - p_dev_ctx->subwork += 1; - LOG_DEBUG("trace_id[0x%llx], hno:%u got a vd pending response, cur_idx[%d]\n", - cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_table_idx); + ps3_atomic_inc(&p_dev_ctx->subwork); + LOG_DEBUG( + "trace_id[0x%llx], hno:%u got a vd pending response, cur_idx[%d]\n", + cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_table_idx); PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); if (unlikely(reply_flags == PS3_REPLY_WORD_FLAG_FAIL)) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u vd pending cmd return failed\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1616,14 +1747,16 @@ S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) } if (p_dev_ctx->vd_pending_cmd == NULL) { - LOG_INFO_IN_IRQ(instance, + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u vd pending is unsubscribed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - if (!instance->state_machine.is_load) { + if (!instance->state_machine.is_load || + instance->is_suspend) { LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); @@ -1632,8 +1765,9 @@ S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) } cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ(instance, + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u instance is not operational!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -1641,8 +1775,9 @@ S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) } LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u vd pending had [%d] vds\n", - cmd->trace_id, PS3_HOST(instance), p_dev_ctx->vd_info_buf_async->count); + "trace_id[0x%llx], hno:%u vd pending had [%d] vds\n", + cmd->trace_id, PS3_HOST(instance), + p_dev_ctx->vd_info_buf_async->count); ps3_dev_vd_pending_data_switch(cmd); @@ -1650,26 +1785,28 @@ S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(instance->dev_context.abort_vdpending_cmd == 0){ + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) == 0) { ret = ps3_dev_vd_pending_resend(cmd); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - if (ret == PS3_SUCCESS) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + if (ret == PS3_SUCCESS) goto l_out; - } - }else{ + } else { LOG_FILE_INFO("hno:%u vd pending cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); instance->dev_context.vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); ret = ps3_dev_mgr_vd_info_subscribe(instance); if (ret != PS3_SUCCESS) { LOG_INFO_IN_IRQ(instance, "hno:%u subscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - instance->dev_context.abort_vdpending_cmd = 0; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); goto l_out; } l_failed: @@ -1677,61 +1814,64 @@ S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags) cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], CFID[%d], hno:%u to dead\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + "trace_id[0x%llx], CFID[%d], hno:%u to dead\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - p_dev_ctx->subwork -= 1; - LOG_INFO_IN_IRQ(instance, + ps3_atomic_dec(&p_dev_ctx->subwork); + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], CFID[%d], hno:%u end proc a vd pending response, subwork:%d,ret:%d\n", - cmd->trace_id, cmd->index, PS3_HOST(instance), p_dev_ctx->subwork,ret); + cmd->trace_id, cmd->index, PS3_HOST(instance), + ps3_atomic_read(&p_dev_ctx->subwork), ret); return ret; } #ifdef _WINDOWS -BOOL ps3_device_check_and_ack(struct ps3_instance *instance, - U8 channel_type, U8 channel, U16 target_id) +int ps3_device_check_and_ack(struct ps3_instance *instance, + unsigned char channel_type, unsigned char channel, + unsigned short target_id) { - S32 ret_tmp = PS3_SUCCESS; - BOOL ret = FALSE; + int ret_tmp = PS3_SUCCESS; + int ret = FALSE; struct ps3_pd_entry *p_pd_entry = NULL; struct PS3VDEntry *p_vd_entry = NULL; - struct PS3DiskDevPos* p_diskPos = NULL; - U8 dev_type = PS3_DISK_TYPE_UNKNOWN; + struct PS3DiskDevPos *p_diskPos = NULL; + unsigned char dev_type = PS3_DISK_TYPE_UNKNOWN; - if (!ps3_scsi_visible_check(instance, channel, target_id, channel_type)) { + if (!ps3_scsi_visible_check(instance, channel, target_id, + channel_type)) { goto l_out; } if (channel_type == PS3_DISK_TYPE_PD) { - p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, target_id); + p_pd_entry = ps3_dev_mgr_lookup_pd_info(instance, channel, + target_id); if (p_pd_entry) { - p_diskPos = &p_pd_entry->disk_pos; dev_type = PS3_DISK_TYPE_PD; - } - } - else if (channel_type == PS3_DISK_TYPE_VD) { - p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, target_id); + } else if (channel_type == PS3_DISK_TYPE_VD) { + p_vd_entry = ps3_dev_mgr_lookup_vd_info(instance, channel, + target_id); if (p_vd_entry) { p_diskPos = &p_vd_entry->diskPos; dev_type = PS3_DISK_TYPE_VD; } } - if (p_diskPos == NULL) { + if (p_diskPos == NULL) goto l_out; - } ret_tmp = ps3_scsi_add_device_ack(instance, p_diskPos, dev_type); if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR("hno:%u dev[%u:%u] magic[%#x] pre scan ack NOK, ret %d\n", + LOG_ERROR( + "hno:%u dev[%u:%u] magic[%#x] pre scan ack NOK, ret %d\n", PS3_HOST(instance), channel, target_id, p_diskPos->diskMagicNum, ret_tmp); } else { LOG_INFO("hno:%u dev_type[%d] id[%u:%u] send ack success\n", - PS3_HOST(instance), dev_type, channel, target_id); + PS3_HOST(instance), dev_type, channel, target_id); ret = TRUE; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_device_update.h b/drivers/scsi/linkdata/ps3stor/ps3_device_update.h index e51e8db3b04d..13f1e8a9943a 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_device_update.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_device_update.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_DEVICE_UPDATE_H_ #define _PS3_DEVICE_UPDATE_H_ @@ -9,28 +9,33 @@ #include "ps3_htp_event.h" #include "ps3_instance_manager.h" -Bool ps3_pd_scsi_visible_check(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type, U8 config_flag, - U8 pd_state); +unsigned char ps3_pd_scsi_visible_check(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type, + unsigned char config_flag, + unsigned char pd_state); -S32 ps3_dev_update_detail_proc(struct ps3_instance *instance, - struct PS3EventDetail *event_detail, U32 event_cnt); +int ps3_dev_update_detail_proc(struct ps3_instance *instance, + struct PS3EventDetail *event_detail, + unsigned int event_cnt); -S32 ps3_dev_update_full_proc(struct ps3_instance *instance, - MgrEvtType_e event_type); +int ps3_dev_update_full_proc(struct ps3_instance *instance, + enum MgrEvtType event_type); -S32 ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, U16 reply_flags); +int ps3_dev_vd_pending_proc(struct ps3_cmd *cmd, unsigned short reply_flags); #ifdef _WINDOWS -BOOL ps3_device_check_and_ack(struct ps3_instance *instance, - U8 channel_type, U8 channel, U16 target_id); +int ps3_device_check_and_ack(struct ps3_instance *instance, + unsigned char channel_type, unsigned char channel, + unsigned short target_id); #endif -U32 ps3_scsi_dev_magic(struct ps3_instance *instance, struct scsi_device *sdev); +unsigned int ps3_scsi_dev_magic(struct ps3_instance *instance, + struct scsi_device *sdev); void ps3_scsi_scan_host(struct ps3_instance *instance); void ps3_check_vd_member_change(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry); + struct ps3_pd_entry *local_entry); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h b/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h index 9d893bd4eddf..00eb5a0b5580 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_drv_ver.h @@ -1,15 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_DRV_VER_H_ #define _PS3_DRV_VER_H_ #define PS3_PRIVATE_VERSION "00.000.00.01" -#define PS3_DRV_VERSION "2.5.0.16" -#define PS3_DRV_COMMIT_ID "1a43aaf bcd87d4" -#define PS3_DRV_BUILD_TIME "Oct 31 2024 22:09:48" +#define PS3_DRV_VERSION "2.9.0.12" +#define PS3_DRV_COMMIT_ID "b6529a9 9146769" +#define PS3_DRV_BUILD_TIME "Jul 28 2026 20:06:45" #define PS3_DRV_TOOLCHAIN_ID "" #define PS3_DRV_PRODUCT_SUPPORT "RAID/HBA" -#define PS3_DRV_LICENSE "GPL" -#define PS3_DRV_AUTHOR "ps3stor" -#define PS3_DRV_DESCRIPTION "ps3stor driver" +#define PS3_DRV_LICENSE "GPL" +#define PS3_DRV_AUTHOR "ps3stor" +#define PS3_DRV_DESCRIPTION "ps3stor driver" #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_dump.h b/drivers/scsi/linkdata/ps3stor/ps3_dump.h index d17d4323fe35..321bfb13a219 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_dump.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_dump.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_CRASH_DUMP_H_ #define _PS3_CRASH_DUMP_H_ @@ -21,44 +21,43 @@ #include "ps3_htp.h" #include "ps3_htp_def.h" -#define PS3_DUMP_DATA_MAX_NUM 512 +#define PS3_DUMP_DATA_MAX_NUM 512 -#define WAIT_DUMP_COLLECT (1000) -#define WAIT_DUMP_TIMES_DEFAULT (300) -#define WAIT_DUMP_TIMES_MIN (10) -#define WAIT_DUMP_TIMES_MAX (3600) +#define WAIT_DUMP_COLLECT (1000) +#define WAIT_DUMP_TIMES_DEFAULT (300) +#define WAIT_DUMP_TIMES_MIN (10) +#define WAIT_DUMP_TIMES_MAX (3600) -#define WAIT_DUMP_DMA_DONE (200) +#define WAIT_DUMP_DMA_DONE (200) #ifndef _WINDOWS #ifdef __KERNEL__ -#define PS3_DUMP_FILE_DIR "/var/log" +#define PS3_DUMP_FILE_DIR "/var/log" #else -#define PS3_DUMP_FILE_DIR "/tmp" +#define PS3_DUMP_FILE_DIR "/tmp" #endif #else -#define PS3_DUMP_FILE_DIR "c:" +#define PS3_DUMP_FILE_DIR "c:" #endif -#define PS3_DUMP_FILE_CORE_PREFIX "core-" -#define PS3_DUMP_FILE_FWLOG_PREFIX "fwlog-" -#define PS3_DUMP_FILE_BAR_PREFIX "bar-" - -#define PS3_DUMP_STATUS_REG_DMA_FINISH_MASK (0x1 << 0) -#define PS3_DUMP_STATUS_REG_CRASH_DUMP_MASK (0x1 << 1) -#define PS3_DUMP_STATUS_REG_FW_DUMP_MASK (0x1 << 2) -#define PS3_DUMP_STATUS_REG_BAR_DUMP_MASK (0x1 << 3) -#define PS3_DUMP_STATUS_REG_CRASH_DUMP_TRIGGER_MASK (0x1 << 4) -#define PS3_DUMP_STATUS_REG_FW_DUMP_TRIGGER_MASK (0x2 << 4) -#define PS3_DUMP_STATUS_REG_BAR_DUMP_TRIGGER_MASK (0x3 << 4) -#define PS3_DUMP_STATUS_REG_ABORT_MASK (0x1 << 6) -#define PS3_DUMP_STATUS_REG_MASK (0x0F) -#define PS3_DUMP_STATUS_REG_INVALID_BITS_MASK (0x7F) - -#define PS3_REG_TEST(val, mask) (((val) & (mask)) ? PS3_TRUE:PS3_FALSE) -#define PS3_REG_SET(val, mask) (((val) |= (mask))) -#define PS3_REG_CLR(val, mask) ((val) &= (~(mask))) - -#define PS3_IOC_DUMP_SUPPORT(ins) \ - (ins->dump_context.is_dump_support) +#define PS3_DUMP_FILE_CORE_PREFIX "core-" +#define PS3_DUMP_FILE_FWLOG_PREFIX "fwlog-" +#define PS3_DUMP_FILE_BAR_PREFIX "bar-" + +#define PS3_DUMP_STATUS_REG_DMA_FINISH_MASK (0x1 << 0) +#define PS3_DUMP_STATUS_REG_CRASH_DUMP_MASK (0x1 << 1) +#define PS3_DUMP_STATUS_REG_FW_DUMP_MASK (0x1 << 2) +#define PS3_DUMP_STATUS_REG_BAR_DUMP_MASK (0x1 << 3) +#define PS3_DUMP_STATUS_REG_CRASH_DUMP_TRIGGER_MASK (0x1 << 4) +#define PS3_DUMP_STATUS_REG_FW_DUMP_TRIGGER_MASK (0x2 << 4) +#define PS3_DUMP_STATUS_REG_BAR_DUMP_TRIGGER_MASK (0x3 << 4) +#define PS3_DUMP_STATUS_REG_ABORT_MASK (0x1 << 6) +#define PS3_DUMP_STATUS_REG_MASK (0x0F) +#define PS3_DUMP_STATUS_REG_INVALID_BITS_MASK (0x7F) + +#define PS3_REG_TEST(val, mask) (((val) & (mask)) ? PS3_TRUE : PS3_FALSE) +#define PS3_REG_SET(val, mask) (((val) |= (mask))) +#define PS3_REG_CLR(val, mask) ((val) &= (~(mask))) + +#define PS3_IOC_DUMP_SUPPORT(ins) (ins->dump_context.is_dump_support) enum ps3_dump_work_status { PS3_DUMP_WORK_UNKNOWN, @@ -94,34 +93,34 @@ enum ps3_dump_file_status { #define PS3_DUMP_FILE_NAME_LEN (256) struct ps3_dump_file_info { - U8 filename[PS3_DUMP_FILE_NAME_LEN]; + unsigned char filename[PS3_DUMP_FILE_NAME_LEN]; #ifdef _WINDOWS - HANDLE fp; + HANDLE fp; #else - struct file *fp; + struct file *fp; #endif - U64 file_size; - U32 file_w_cnt; - U32 file_status; - U32 type; - U8 reserved[4]; + unsigned long long file_size; + unsigned int file_w_cnt; + unsigned int file_status; + unsigned int type; + unsigned char reserved[4]; }; struct ps3_dump_context { - U8 dump_dir[PS3_DUMP_FILE_DIR_LEN]; - U64 dump_data_size; - S8 dump_type; - S32 dump_state; - U32 dump_env; - U32 dump_work_status; - U32 dump_irq_handler_work_status; - U64 copyed_data_size; - U8 *dump_dma_buf; + unsigned char dump_dir[PS3_DUMP_FILE_DIR_LEN]; + unsigned long long dump_data_size; + char dump_type; + int dump_state; + unsigned int dump_env; + unsigned int dump_work_status; + unsigned int dump_irq_handler_work_status; + unsigned long long copyed_data_size; + unsigned char *dump_dma_buf; dma_addr_t dump_dma_addr; - U32 dump_dma_wait_times; + unsigned int dump_dma_wait_times; #ifdef _WINDOWS - struct ps3_delay_worker dump_work; - ps3_mutex dump_mutex; + struct ps3_delay_worker dump_work; + struct mutex dump_mutex; #else struct workqueue_struct *dump_work_queue; struct delayed_work dump_work; @@ -129,37 +128,36 @@ struct ps3_dump_context { struct workqueue_struct *dump_irq_handler_work_queue; struct work_struct dump_irq_handler_work; spinlock_t dump_irq_handler_lock; - U32 dump_enabled; + unsigned int dump_enabled; #endif - ps3_mutex dump_lock; + struct mutex dump_lock; struct ps3_instance *instance; struct ps3_dump_file_info dump_out_file; struct ps3_cmd *dump_pending_cmd; - U32 dump_pending_send_times; - U32 dump_type_times; - U32 dump_state_times; - Bool is_dump_support; - Bool is_hard_recovered; + unsigned int dump_pending_send_times; + unsigned int dump_type_times; + unsigned int dump_state_times; + unsigned char is_dump_support; + unsigned char is_hard_recovered; - U8 reserved[2]; + unsigned char reserved[2]; }; -static inline const S8 *ps3_dump_type_to_name(S32 dump_type) +static inline const char *ps3_dump_type_to_name(int dump_type) { - static const S8 *name[] = { - [PS3_DUMP_TYPE_UNKNOWN] = "NULL", - [PS3_DUMP_TYPE_CRASH] = "dump_crash", - [PS3_DUMP_TYPE_FW_LOG] = "fw_log", - [PS3_DUMP_TYPE_BAR_DATA] = "bar_data" - }; + static const char * const name[] = { [PS3_DUMP_TYPE_UNKNOWN] = "NULL", + [PS3_DUMP_TYPE_CRASH] = "dump_crash", + [PS3_DUMP_TYPE_FW_LOG] = "fw_log", + [PS3_DUMP_TYPE_BAR_DATA] = "bar_data" }; return name[dump_type]; } -extern S32 ps3_dump_init(struct ps3_instance *instance); +extern int ps3_dump_init(struct ps3_instance *instance); extern void ps3_dump_exit(struct ps3_instance *instance); -extern S32 ps3_dump_type_set(struct ps3_dump_context *ctxt, S32 type, U32 env); -extern S32 ps3_dump_state_set(struct ps3_dump_context *ctxt, S32 state); +extern int ps3_dump_type_set(struct ps3_dump_context *ctxt, int type, + unsigned int env); +extern int ps3_dump_state_set(struct ps3_dump_context *ctxt, int state); #ifndef _WINDOWS extern struct ps3_dump_context *dev_to_dump_context(struct device *cdev); @@ -168,18 +166,18 @@ void ps3_dump_work_stop(struct ps3_instance *instance); #endif -S32 ps3_dump_dma_buf_alloc(struct ps3_instance *instance); +int ps3_dump_dma_buf_alloc(struct ps3_instance *instance); void ps3_dump_dma_buf_free(struct ps3_instance *instance); void ps3_dump_detect(struct ps3_instance *instance); #ifndef _WINDOWS -irqreturn_t ps3_dump_irq_handler(S32 virq, void *dev_id); +irqreturn_t ps3_dump_irq_handler(int virq, void *dev_id); #endif void ps3_dump_ctrl_set_int_ready(struct ps3_instance *instance); -Bool ps3_dump_is_trigger_log(struct ps3_instance *instance); +unsigned char ps3_dump_is_trigger_log(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_err_def.h b/drivers/scsi/linkdata/ps3stor/ps3_err_def.h index 94a112157617..eaa1901928e7 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_err_def.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_err_def.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_ERR_DEF_H_ #define _PS3_ERR_DEF_H_ @@ -7,41 +7,41 @@ enum { - PS3_SUCCESS = 0x00, - PS3_FAILED = 0x01, - PS3_TIMEOUT = 0x02, - PS3_IN_IRQ_POLLING = 0x03, - PS3_DEV_TYPE_UNKOWN = 0x04, - PS3_RETRY = 0x05, - PS3_EBUSY = 0x06, - PS3_EINVAL = 0x07, - PS3_ENOMEM = 0x08, - PS3_ENODEV = 0x09, - PS3_ERESTARTSYS = 0x0a, - PS3_ENOTTY = 0x0b, - PS3_RESP_ERR = 0x0c, - PS3_RESP_INT = 0x0d, - PS3_ACTIVE_ERR = 0x0e, - PS3_CMD_NO_RESP = 0x0f, - PS3_IO_BLOCK = 0x10, - PS3_IO_REQUEUE = 0x11, - PS3_IO_CONFLICT_IN_Q = 0x12, - PS3_IO_CONFLICT = 0x13, - PS3_MGR_REC_FORCE = 0x14, - PS3_RECOVERED = 0x15, - PS3_IN_UNLOAD = 0x16, - PS3_NO_RECOVERED = 0x17, - PS3_IN_QOS_Q = 0x18, - PS3_IN_PCIE_ERR = 0x19, + PS3_SUCCESS = 0x00, + PS3_FAILED = 0x01, + PS3_TIMEOUT = 0x02, + PS3_IN_IRQ_POLLING = 0x03, + PS3_DEV_UNKNOWN = 0x04, + PS3_RETRY = 0x05, + PS3_EBUSY = 0x06, + PS3_EINVAL = 0x07, + PS3_ENOMEM = 0x08, + PS3_ENODEV = 0x09, + PS3_ERESTARTSYS = 0x0a, + PS3_ENOTTY = 0x0b, + PS3_RESP_ERR = 0x0c, + PS3_RESP_INT = 0x0d, + PS3_ACTIVE_ERR = 0x0e, + PS3_CMD_NO_RESP = 0x0f, + PS3_IO_BLOCK = 0x10, + PS3_IO_REQUEUE = 0x11, + PS3_IO_CONFLICT_IN_Q = 0x12, + PS3_IO_CONFLICT = 0x13, + PS3_MGR_REC_FORCE = 0x14, + PS3_RECOVERED = 0x15, + PS3_IN_UNLOAD = 0x16, + PS3_NO_RECOVERED = 0x17, + PS3_IN_QOS_Q = 0x18, + PS3_IN_PCIE_ERR = 0x19, }; -#define PS3_DRV_TRUE (1) -#define PS3_DRV_FALSE (0) +#define PS3_DRV_TRUE (1) +#define PS3_DRV_FALSE (0) struct ps3_fault_context { - U8 ioc_busy; - U8 reserved[2]; - ULong last_time; + unsigned char ioc_busy; + unsigned char reserved[2]; + unsigned long last_time; }; #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_err_inject.c b/drivers/scsi/linkdata/ps3stor/ps3_err_inject.c index 20814cd1e592..3da9abdd0ec7 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_err_inject.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_err_inject.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include @@ -15,478 +16,532 @@ #include "ps3_inject.h" #include "ps3_cmd_statistics.h" #include +#include "ps3_kernel_version.h" #ifdef PS3_SUPPORT_INJECT struct ps3_rec_work_context g_work_que_recovery; struct ps3_rec_work_context g_work_que_probe; -static Ps3Injection_t g_ps3_err_scene[PS3_ERR_SCENE_NUM]; -static Bool is_inject_init = PS3_FALSE; -static U64 sgl_addr; +static struct Ps3Injection g_ps3_err_scene[PS3_ERR_SCENE_NUM]; +static unsigned char is_inject_init = PS3_FALSE; +static unsigned long long sgl_addr; -void ps3_err_inject_sleep(U32 ms, U16 err_type) +static inline unsigned int ps3_prandom_u32_max(unsigned int ep_ro) +{ +#if defined(PS3_INJECT_PRANDOWM) + return prandom_u32_max(ep_ro); +#else + return get_random_u32_below(ep_ro); +#endif +} + +static inline unsigned int ps3_prandom_u32(void) +{ +#if defined(PS3_INJECT_PRANDOWM) + return prandom_u32(); +#else + return get_random_u32(); +#endif +} + +void ps3_err_inject_sleep(unsigned int ms, unsigned short err_type) { if ((err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && - g_ps3_err_scene[err_type - 1].active) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && + g_ps3_err_scene[err_type - 1].active) { ps3_msleep(ms); } } -void ps3_err_inject_sleep_rand(U32 min, U32 max, U16 err_type) +void ps3_err_inject_sleep_rand(unsigned int min, unsigned int max, + unsigned short err_type) { - U16 slepp_ms = min; + unsigned short slepp_ms = min; + if ((err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && - g_ps3_err_scene[err_type - 1].active) { - slepp_ms = min + prandom_u32_max(max - min); + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) && + g_ps3_err_scene[err_type - 1].active) { + slepp_ms = min + ps3_prandom_u32_max(max - min); ps3_msleep(slepp_ms); } } -void ps3_err_inject_err_type_valid(U16 err_type) +void ps3_err_inject_err_type_valid(unsigned short err_type) { if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { g_ps3_err_scene[err_type - 1].active = PS3_TRUE; } } -void ps3_err_inject_err_type_clean(U16 err_type) +void ps3_err_inject_err_type_clean(unsigned short err_type) { if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { g_ps3_err_scene[err_type - 1].active = PS3_FALSE; } } -Bool ps3_err_inject_err_type_get(U16 err_type) +unsigned char ps3_err_inject_err_type_get(unsigned short err_type) { if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { return g_ps3_err_scene[err_type - 1].type; } return PS3_FALSE; } -void ps3_err_inject_wait_pre(U16 err_type_wait) +void ps3_err_inject_wait_pre(unsigned short err_type_wait) { - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { - msleep(5); + while (g_ps3_err_scene[err_type_wait - 1].active && + !g_ps3_err_scene[err_type_wait - 1].is_hit_pre) { + msleep(20); } } -void ps3_err_inject_wait_post(U16 err_type_wait) +void ps3_err_inject_wait_post(unsigned short err_type_wait) { - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { - msleep(5); + while (g_ps3_err_scene[err_type_wait - 1].active && + !g_ps3_err_scene[err_type_wait - 1].is_hit_pre) { + msleep(20); } } -void inject_register(U16 err_type, injectCallback callback) +void inject_register(unsigned short err_type, int (*callback)(void *userData, ...)) { if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { g_ps3_err_scene[err_type - 1].callback = callback; } - - return ; } -void inject_active_intf(U16 err_type, U16 count) +void inject_active_intf(unsigned short err_type, unsigned short count) { if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { g_ps3_err_scene[err_type - 1].active = PS3_TRUE; g_ps3_err_scene[err_type - 1].count = count; g_ps3_err_scene[err_type - 1].is_hit_pre = PS3_FALSE; g_ps3_err_scene[err_type - 1].is_hit_post = PS3_FALSE; } - - return ; } -void inject_execute_callback(U16 err_type, void * data) +void inject_execute_callback(unsigned short err_type, void *data) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && - g_ps3_err_scene[err_type-1].count != 0) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE && + g_ps3_err_scene[err_type - 1].count != 0) { + g_ps3_err_scene[err_type - 1].is_hit_pre = PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].callback != NULL) { + ret = g_ps3_err_scene[err_type - 1].callback( + data); } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + g_ps3_err_scene[err_type - 1].is_hit_post = PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } - - return ; } -void inject_execute_callback_at_time(U16 err_type, void * data) +void inject_execute_callback_at_time(unsigned short err_type, void *data) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { - if (g_ps3_err_scene[err_type-1].count > 1) { - g_ps3_err_scene[err_type-1].count--; - } else if (g_ps3_err_scene[err_type-1].count == 1) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE) { + if (g_ps3_err_scene[err_type - 1].count > 1) { + g_ps3_err_scene[err_type - 1].count--; + } else if (g_ps3_err_scene[err_type - 1].count == 1) { + g_ps3_err_scene[err_type - 1].is_hit_pre = + PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].callback != + NULL) { + ret = g_ps3_err_scene[err_type - 1] + .callback(data); } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + g_ps3_err_scene[err_type - 1].is_hit_post = + PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } } - - return; } -void inject_execute_callback_relevance_wait_pre(U16 err_type, U16 err_type_wait, void * data) +void inject_execute_callback_relevance_wait_pre(unsigned short err_type, + unsigned short err_type_wait, + void *data) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && - g_ps3_err_scene[err_type_wait-1].active == PS3_TRUE && - g_ps3_err_scene[err_type-1].count != 0) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { - msleep(5); + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE && + g_ps3_err_scene[err_type_wait - 1].active == PS3_TRUE && + g_ps3_err_scene[err_type - 1].count != 0) { + g_ps3_err_scene[err_type - 1].is_hit_pre = PS3_TRUE; + while (g_ps3_err_scene[err_type_wait - 1].active && + !g_ps3_err_scene[err_type_wait - 1].is_hit_pre) { + msleep(20); } - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); + if (g_ps3_err_scene[err_type - 1].callback != NULL) { + ret = g_ps3_err_scene[err_type - 1].callback( + data); } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + g_ps3_err_scene[err_type - 1].is_hit_post = PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } - - return ; } -void inject_execute_callback_relevance_wait_post(U16 err_type, U16 err_type_wait, void * data) +void inject_execute_callback_relevance_wait_post(unsigned short err_type, + unsigned short err_type_wait, + void *data) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE && - g_ps3_err_scene[err_type_wait-1].active == PS3_TRUE && - g_ps3_err_scene[err_type-1].count != 0) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_post) { - msleep(5); + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE && + g_ps3_err_scene[err_type_wait - 1].active == PS3_TRUE && + g_ps3_err_scene[err_type - 1].count != 0) { + g_ps3_err_scene[err_type - 1].is_hit_pre = PS3_TRUE; + while (g_ps3_err_scene[err_type_wait - 1].active && + !g_ps3_err_scene[err_type_wait - 1].is_hit_post) { + msleep(20); } - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); + if (g_ps3_err_scene[err_type - 1].callback != NULL) { + ret = g_ps3_err_scene[err_type - 1].callback( + data); } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + g_ps3_err_scene[err_type - 1].is_hit_post = PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } - - return ; } -void inject_execute_callback_at_time_relevance_wait_pre(U16 err_type, - U16 err_type_wait, void * data) +void inject_execute_callback_at_time_relevance_wait_pre( + unsigned short err_type, unsigned short err_type_wait, void *data) { - S32 ret = PS3_SUCCESS; - if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { - if (g_ps3_err_scene[err_type-1].count > 1) { - g_ps3_err_scene[err_type-1].count--; - } else if (g_ps3_err_scene[err_type-1].count == 1) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; + int ret = PS3_SUCCESS; - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_pre) { - msleep(5); + if (err_type < PS3_ERR_SCENE_NUM && + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE) { + if (g_ps3_err_scene[err_type - 1].count > 1) { + g_ps3_err_scene[err_type - 1].count--; + } else if (g_ps3_err_scene[err_type - 1].count == 1) { + g_ps3_err_scene[err_type - 1].is_hit_pre = + PS3_TRUE; + while (g_ps3_err_scene[err_type_wait - 1] + .active && + !g_ps3_err_scene[err_type_wait - 1] + .is_hit_pre) { + msleep(20); } - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); - } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + if (g_ps3_err_scene[err_type - 1].callback != + NULL) { + ret = g_ps3_err_scene[err_type - 1] + .callback(data); + } + g_ps3_err_scene[err_type - 1].is_hit_post = + PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } } - - return; } -void inject_execute_callback_at_time_relevance_wait_post(U16 err_type, - U16 err_type_wait, void * data) +void inject_execute_callback_at_time_relevance_wait_post( + unsigned short err_type, unsigned short err_type_wait, void *data) { - S32 ret = PS3_SUCCESS; - if (err_type < PS3_ERR_SCENE_NUM && - err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { - - if (g_ps3_err_scene[err_type-1].active == PS3_TRUE) { - if (g_ps3_err_scene[err_type-1].count > 1) { - g_ps3_err_scene[err_type-1].count--; - } else if (g_ps3_err_scene[err_type-1].count == 1) { - g_ps3_err_scene[err_type-1].is_hit_pre = PS3_TRUE; + int ret = PS3_SUCCESS; - while(g_ps3_err_scene[err_type_wait-1].active && - !g_ps3_err_scene[err_type_wait-1].is_hit_post) { - msleep(5); + if (err_type < PS3_ERR_SCENE_NUM && + err_type >= PS3_ERR_IJ_WATCHDOG_CONCURY) { + if (g_ps3_err_scene[err_type - 1].active == PS3_TRUE) { + if (g_ps3_err_scene[err_type - 1].count > 1) { + g_ps3_err_scene[err_type - 1].count--; + } else if (g_ps3_err_scene[err_type - 1].count == 1) { + g_ps3_err_scene[err_type - 1].is_hit_pre = + PS3_TRUE; + + while (g_ps3_err_scene[err_type_wait - 1] + .active && + !g_ps3_err_scene[err_type_wait - 1] + .is_hit_post) { + msleep(20); } - if (g_ps3_err_scene[err_type-1].callback != NULL) { - ret = g_ps3_err_scene[err_type-1].callback(data); - } - g_ps3_err_scene[err_type-1].is_hit_post = PS3_TRUE; - if(g_ps3_err_scene[err_type-1].count > 0 && ret == PS3_SUCCESS){ - g_ps3_err_scene[err_type-1].count--; + if (g_ps3_err_scene[err_type - 1].callback != + NULL) { + ret = g_ps3_err_scene[err_type - 1] + .callback(data); + } + g_ps3_err_scene[err_type - 1].is_hit_post = + PS3_TRUE; + if (g_ps3_err_scene[err_type - 1].count > 0 && + ret == PS3_SUCCESS) { + g_ps3_err_scene[err_type - 1].count--; } } } } - - return; } -S32 force_ioctl_cmd_dead(void * ptr) +static int force_ioctl_cmd_dead(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - if (cmd == NULL) { + if (cmd == NULL) goto end; - } - if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { + if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - } end: return PS3_SUCCESS; } -S32 force_ioctl_cmd_pending(void * ptr) +static int force_ioctl_cmd_pending(void *ptr) { - *(S32 *)ptr = 1; + *(int *)ptr = 1; return PS3_SUCCESS; } -S32 force_ioctl_cmd_sig_interrupt(void * ptr) +static int force_ioctl_cmd_sig_interrupt(void *ptr) { - *(S32 *)ptr = 1; + *(int *)ptr = 1; return PS3_SUCCESS; } -S32 force_ioctl_cmd_interrupt(void * ptr) +static int force_ioctl_cmd_interrupt(void *ptr) { - *(S32 *)ptr = -PS3_FAILED; + *(int *)ptr = -PS3_FAILED; return PS3_SUCCESS; } -S32 force_ioctl_cmd_no_resp(void * ptr) +static int force_ioctl_cmd_no_resp(void *ptr) { - *(S32 *)ptr = -PS3_TIMEOUT; + *(int *)ptr = -PS3_TIMEOUT; return PS3_SUCCESS; } -S32 force_mgr_cmd_no_resp(void * ptr) +static int force_mgr_cmd_no_resp(void *ptr) { - *(S32 *)ptr = -PS3_TIMEOUT; + *(int *)ptr = -PS3_TIMEOUT; return PS3_SUCCESS; } -S32 force_return_fail(void * ptr) +static int force_return_fail(void *ptr) { - *(S32 *)ptr = -PS3_FAILED; + *(int *)ptr = -PS3_FAILED; return PS3_SUCCESS; } -S32 force_ioctl_cmd_abort_no_resp(void * ptr) +static int force_ioctl_cmd_abort_no_resp(void *ptr) { - *(S32 *)ptr = -PS3_CMD_NO_RESP; + *(int *)ptr = -PS3_CMD_NO_RESP; return PS3_SUCCESS; } -S32 force_ioctl_cmd_force_done(void * ptr) +static int force_ioctl_cmd_force_done(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + msleep(500); complete(&cmd->sync_done); return PS3_SUCCESS; } -S32 ioctl_cmd_retry_done(void * ptr) +static int ioctl_cmd_retry_done(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + cmd->retry_cnt = 3; return PS3_SUCCESS; } -S32 force_ioctl_cmd_recovery_cancel(void * ptr) +static int force_ioctl_cmd_recovery_cancel(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - S32 ret; - ret = ps3_hard_recovery_request(cmd->instance); + int ret; + + ret = ps3_hard_recovery_request(cmd->instance, PS3_FALSE); if (ret == -PS3_FAILED) { LOG_ERROR("hno:%u hard recovery request failed\n", - PS3_HOST(cmd->instance)); + PS3_HOST(cmd->instance)); return -PS3_FAILED; } - while(ps3_atomic_read(&cmd->instance->state_machine.state) != PS3_INSTANCE_STATE_RECOVERY){ + while (ps3_atomic_read(&cmd->instance->state_machine.state) != + PS3_INSTANCE_STATE_RECOVERY) { msleep(50); } return PS3_SUCCESS; } -S32 wait_instance_normal(void * ptr) +static int wait_instance_normal(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_OPERATIONAL && - ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_PRE_OPERATIONAL){ - msleep(5); + while (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_OPERATIONAL && + ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_PRE_OPERATIONAL) { + msleep(20); } return PS3_SUCCESS; } -S32 wait_instance_operational(void * ptr) +static int wait_instance_operational(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_OPERATIONAL){ - msleep(5); + while (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_OPERATIONAL) { + msleep(20); } return PS3_SUCCESS; } -S32 host_reset_wait_decide_normal(void * ptr) +static int host_reset_wait_decide_normal(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_INFO("inject host_reset_wait_decide_normal enter,recovery_state:%d\n", - instance->recovery_context->recovery_state); - while(instance->recovery_context->host_reset_state == PS3_HOST_RESET_INIT){ - msleep(5); + LOG_INFO( + "inject %s enter,recovery_state:%d\n", + __func__, instance->recovery_context->recovery_state); + + while (instance->recovery_context->host_reset_state == + PS3_HOST_RESET_INIT) { + msleep(20); } msleep(50); - LOG_INFO("inject host_reset_wait_decide_normal end,host_reset_state:%d\n", - instance->recovery_context->host_reset_state); + LOG_INFO( + "%s end,host_reset_state:%d\n", + __func__, instance->recovery_context->host_reset_state); return PS3_SUCCESS; } -S32 force_instance_unload(void * ptr) +static int force_instance_unload(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->state_machine.is_load = PS3_FALSE; - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_instance_state_unnormal(void * ptr) +static int force_instance_state_unnormal(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_OPERATIONAL, - PS3_INSTANCE_STATE_RECOVERY); - return PS3_SUCCESS; + PS3_INSTANCE_STATE_RECOVERY); + return PS3_SUCCESS; } -S32 force_instance_state_pci_err(void * ptr) +static int force_instance_state_pci_err(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->state_machine.is_pci_err_recovery = PS3_TRUE; - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_instance_state_normal(void * ptr) +static int force_instance_state_normal(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_OPERATIONAL); + + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_OPERATIONAL); return PS3_SUCCESS; } -S32 wait_instance_unnormal(void * ptr) +static int wait_instance_unnormal(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(ps3_atomic_read(&instance->state_machine.state) == PS3_INSTANCE_STATE_OPERATIONAL){ - msleep(5); + while (ps3_atomic_read(&instance->state_machine.state) == + PS3_INSTANCE_STATE_OPERATIONAL) { + msleep(20); } return PS3_SUCCESS; } -S32 wait_instance_unnormal_and_set_flag(void * ptr) +static int wait_instance_unnormal_and_set_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - Bool flag = PS3_FALSE; - while(ps3_atomic_read(&instance->state_machine.state) == PS3_INSTANCE_STATE_OPERATIONAL) { + unsigned char flag = PS3_FALSE; + + while (ps3_atomic_read(&instance->state_machine.state) == + PS3_INSTANCE_STATE_OPERATIONAL) { if (!flag) { instance->reserved[0] = 0x11; flag = PS3_TRUE; } - msleep(5); + msleep(20); } msleep(1000); return PS3_SUCCESS; } -S32 wait_ioc_ready(void * ptr) +static int wait_ioc_ready(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 ioc_state = 0; - if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { + unsigned int ioc_state = 0; + + if (instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_RECOVERY) { goto l_out; } - LOG_INFO("wait_ioc_ready inject\n"); + LOG_INFO("%s inject\n", __func__); ioc_state = instance->ioc_adpter->ioc_state_get(instance); - while(ioc_state != PS3_FW_STATE_READY){ + while (ioc_state != PS3_FW_STATE_READY) { ioc_state = instance->ioc_adpter->ioc_state_get(instance); - msleep(5); + msleep(20); } l_out: return PS3_SUCCESS; } -static void force_work_queue_unull_test(struct work_struct* work) +static void force_work_queue_unull_test(struct work_struct *work) { - LOG_INFO("force_work_queue_unull_test inject\n"); + LOG_INFO("%s inject\n", __func__); - (void) work; - return; + (void)work; } -S32 force_work_queue_unull(void * ptr) +static int force_work_queue_unull(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - struct work_struct* recovery_irq_work = &instance->recovery_irq_work; - S8 request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENTH]; - LOG_INFO("force_work_queue_unull inject\n"); + struct work_struct *recovery_irq_work = &instance->recovery_irq_work; + char request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENGTH]; - memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENTH); + LOG_INFO("%s inject\n", __func__); + + memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH); INIT_WORK(recovery_irq_work, force_work_queue_unull_test); - snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENTH, - "ps3_irq_recovery_start_service_host%d", instance->host->host_no); + snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH, + "ps3_irq_recov%d", + instance->host->host_no); instance->recovery_irq_queue = create_singlethread_workqueue(request_irq_queue_name); @@ -494,440 +549,482 @@ S32 force_work_queue_unull(void * ptr) return PS3_SUCCESS; } -S32 force_work_queue_failed(void * ptr) +static int force_work_queue_failed(void *ptr) { - S32 *ret = (S32 *)ptr; - LOG_INFO("force_work_queue_failed\n"); + int *ret = (int *)ptr; + + LOG_INFO("%s\n", __func__); *ret = -PS3_FAILED; return PS3_SUCCESS; } -S32 force_fw_state_ff(void * ptr) +static int force_fw_state_ff(void *ptr) { - U64 *heartbeat_value = (U64 *)ptr; - LOG_INFO("force_fw_state_ff\n"); + unsigned long long *heartbeat_value = (unsigned long long *)ptr; + + LOG_INFO("%s\n", __func__); *heartbeat_value = U64_MAX; return PS3_SUCCESS; } -S32 wait_remove_is_load_flag(void *ptr) +static int wait_remove_is_load_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_INFO("wait_remove_is_load_flag\n"); - while(instance->state_machine.is_load){ - msleep(5); - } + + LOG_INFO("%s\n", __func__); + while (instance->state_machine.is_load) + msleep(20); return PS3_SUCCESS; } -S32 wait_reco_dump_valid(void * ptr) +static int wait_reco_dump_valid(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(instance->dump_context.is_hard_recovered == 0){ - msleep(5); - - } + while (instance->dump_context.is_hard_recovered == 0) + msleep(20); return PS3_SUCCESS; } -S32 force_ret_fail(void * ptr) +static int force_ret_fail(void *ptr) { - S32 *ret = (S32 *)ptr; + int *ret = (int *)ptr; + *ret = -PS3_FAILED; return PS3_SUCCESS; } -S32 force_reg_fail(void * ptr) +static int force_reg_fail(void *ptr) { - U64 *ret = (U64 *)ptr; + unsigned long long *ret = (unsigned long long *)ptr; + *ret = U64_MAX; return PS3_SUCCESS; } -S32 force_ready_failed(void * ptr) +static int force_ready_failed(void *ptr) { - U32 *fw_cur_state = (U32 *)ptr; + unsigned int *fw_cur_state = (unsigned int *)ptr; + *fw_cur_state = PS3_FW_STATE_START; return PS3_SUCCESS; } -S32 force_ioc_critical(void * ptr) +static int force_ioc_critical(void *ptr) { - U32 *fw_cur_state = (U32 *)ptr; + unsigned int *fw_cur_state = (unsigned int *)ptr; + *fw_cur_state = PS3_FW_STATE_CRITICAL; return PS3_SUCCESS; } -S32 force_change_sgl_addr_to_page_mode_5(void * ptr) +static int force_recovery_state_shallow(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_SHALLOW; + return PS3_SUCCESS; +} + +static int force_recovery_halt_break(void * ptr) { - U64 *addr = (U64 *)ptr; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + if (instance->ioc_adpter->ioc_state_get(instance) == PS3_FW_STATE_HALT && + instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_DEAD); + } + instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_DECIDE; + return PS3_SUCCESS; +} + +static int force_recovery_halt_break_1(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + if (PS3_IOC_STATE_HALT_SUPPORT(instance) && + instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { + instance->ioc_adpter->ioc_force_to_halt(instance); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_DEAD); + } + instance->is_ioc_halt_support = PS3_FALSE; + return PS3_SUCCESS; +} + +static int force_recovery_doorbell_done(void * ptr) +{ + U64 *value = (U64 *)ptr; + *value = U64_MAX; + return PS3_SUCCESS; +} + +static int force_change_sgl_addr_to_page_mode_5(void * ptr) +{ + unsigned long long *addr = (unsigned long long *)ptr; + sgl_addr = *addr; *addr = 0xfffffc5600000; return PS3_SUCCESS; } -S32 force_sgl_addr_restore(void * ptr) +static int force_sgl_addr_restore(void *ptr) { - U64 *addr = (U64 *)ptr; + unsigned long long *addr = (unsigned long long *)ptr; + *addr = sgl_addr; return PS3_SUCCESS; } -S32 force_atu_support_failed(void * ptr) +static int force_atu_support_failed(void *ptr) { - U8 *bit_pos = (U8 *)ptr; + unsigned char *bit_pos = (unsigned char *)ptr; + *bit_pos = 0xe0; return PS3_SUCCESS; } -S32 force_reg_zero(void * ptr) +static int force_reg_zero(void *ptr) { - U64 *reg = (U64 *)ptr; + unsigned long long *reg = (unsigned long long *)ptr; + *reg = 0x0; return PS3_SUCCESS; } -S32 force_scan_host_delay(void * ptr) +static int force_scan_host_delay(void *ptr) { - U32 times = *(U32 *)ptr; + unsigned int times = *(unsigned int *)ptr; + LOG_INFO("inject ps3_scsi_scan_host dalay start:%u\n", times); - while(times) { + while (times) { msleep(100); times -= 100; } LOG_INFO("inject ps3_scsi_scan_host dalay end:%u\n", times); return PS3_SUCCESS; } -S32 force_scan_host_fail(void * ptr) +static int force_scan_host_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->is_scan_host_finish = PS3_FALSE; return PS3_SUCCESS; } -S32 force_ignore_task_io(void * ptr) +static int force_ignore_task_io(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - U8 type; - S32 ret = PS3_FAILED; + unsigned char type; + int ret = PS3_FAILED; - if (cmd == NULL) { + if (cmd == NULL) goto end; - } type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cmd->scmd->cmnd)); if (ps3_scsih_is_rw_type(type)) { cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; init_completion(&cmd->sync_done); - LOG_INFO("inject force_ignore_task_io CFID %u no resp\n", cmd->index); + LOG_INFO("inject %s CFID %u no resp\n", + __func__, cmd->index); ret = PS3_SUCCESS; } end: return ret; } -S32 force_ignore_task_abort(void * ptr) +static int force_ignore_task_abort(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - S32 ret = PS3_FAILED; + int ret = PS3_FAILED; - if (cmd == NULL) { + if (cmd == NULL) goto end; - } if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_SCSI_TASK_MANAGEMENT && - PS3_MGR_CMD_SUBTYPE(cmd) == PS3_TASK_CMD_SCSI_TASK_ABORT) { + PS3_MGR_CMD_SUBTYPE(cmd) == PS3_TASK_CMD_SCSI_TASK_ABORT) { cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; init_completion(&cmd->sync_done); - LOG_INFO("inject force_ignore_task_abort CFID %u no resp\n", cmd->index); + LOG_INFO("inject %s CFID %u no resp\n", + __func__, cmd->index); ret = PS3_SUCCESS; } end: return ret; } -S32 force_ignore_task_reset(void * ptr) +static int force_ignore_task_reset(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - S32 ret = PS3_FAILED; + int ret = PS3_FAILED; - if (cmd == NULL) { + if (cmd == NULL) goto end; - } if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_SCSI_TASK_MANAGEMENT && - PS3_MGR_CMD_SUBTYPE(cmd) == PS3_TASK_CMD_SCSI_TASK_RESET) { + PS3_MGR_CMD_SUBTYPE(cmd) == PS3_TASK_CMD_SCSI_TASK_RESET) { cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; init_completion(&cmd->sync_done); - LOG_INFO("inject force_ignore_task_reset CFID %u no resp\n", cmd->index); + LOG_INFO("inject %s CFID %u no resp\n", + __func__, cmd->index); ret = PS3_SUCCESS; } end: return ret; } -S32 force_event_handle(void * ptr) +static int force_event_handle(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance*)ptr; - schedule_delayed_work(&instance->event_context.delay_work->event_work, 0); + struct ps3_instance *instance = (struct ps3_instance *)ptr; + + schedule_delayed_work(&instance->event_context.delay_work->event_work, + 0); return PS3_SUCCESS; } -S32 force_del_disk(void * ptr) +static int force_del_disk(void *ptr) { struct scsi_device *sdev = (struct scsi_device *)ptr; - if (sdev) { + + if (sdev) sdev = NULL; - } return PS3_SUCCESS; } -S32 force_priv_data_null(void * ptr) +static int force_priv_data_null(void *ptr) { struct scsi_device *sdev = (struct scsi_device *)ptr; - struct ps3_instance *instance = (struct ps3_instance*)(sdev->host->hostdata); + struct ps3_instance *instance = + (struct ps3_instance *)(sdev->host->hostdata); - if(sdev->hostdata != NULL) { + if (sdev->hostdata != NULL) ps3_kfree(instance, sdev->hostdata); - } sdev->hostdata = NULL; return PS3_SUCCESS; } -S32 force_wait_hard_flag(void * ptr) +static int force_wait_hard_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 180*HZ; - while (instance->hardreset_event != 1) { + unsigned int wait_time = 180 * HZ; + + while (ps3_atomic_read(&instance->hardreset_event) != 1) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } - LOG_INFO("event wait hard flag %d\n", - instance->hardreset_event); + LOG_INFO("event wait hard flag %d\n", ps3_atomic_read(&instance->hardreset_event)); return PS3_SUCCESS; } -S32 force_int_wait_hard_flag(void * ptr) +static int force_int_wait_hard_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 10*HZ; - while (instance->hardreset_event != 0) { + unsigned int wait_time = 10 * HZ; + + while (ps3_atomic_read(&instance->hardreset_event) != 0) { ps3_mdelay(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } - LOG_INFO("int wait hard flag %d\n", - instance->hardreset_event); + LOG_INFO("int wait hard flag %d\n", ps3_atomic_read(&instance->hardreset_event)); return PS3_SUCCESS; } -S32 force_int_wait_hard_subcribe(void * ptr) +static int force_int_wait_hard_subcribe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 10*HZ; + unsigned int wait_time = 10 * HZ; - while (instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_SHALLOW) { + while (instance->recovery_context->recovery_state != + PS3_HARD_RECOVERY_SHALLOW) { ps3_mdelay(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } LOG_INFO("int wait hard recovery finish %d\n", - instance->recovery_context->recovery_state); + instance->recovery_context->recovery_state); return PS3_SUCCESS; } -S32 force_wait_hard_subcribe(void * ptr) +static int force_wait_hard_subcribe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 180*HZ; - while (instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_SHALLOW) { + unsigned int wait_time = 180 * HZ; + + while (instance->recovery_context->recovery_state != + PS3_HARD_RECOVERY_SHALLOW) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } - while (instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_FINISH) { + while (instance->recovery_context->recovery_state != + PS3_HARD_RECOVERY_FINISH) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } LOG_INFO("event wait hard recovery finish %d\n", - instance->recovery_context->recovery_state); + instance->recovery_context->recovery_state); return PS3_SUCCESS; } -S32 force_wait_event_int(void * ptr) +static int force_wait_event_int(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 180*HZ; - while (instance->event_context.subwork != 1) { + unsigned int wait_time = 180 * HZ; + + while (ps3_atomic_read(&instance->event_context.subwork) != 1) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } LOG_INFO("recovery wait event int %d\n", - instance->event_context.subwork); + ps3_atomic_read(&instance->event_context.subwork)); return PS3_SUCCESS; } -S32 force_wait_event_proc(void * ptr) +static int force_wait_event_proc(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 180*HZ; - while (instance->event_context.subwork != 1) { - ps3_msleep(1); + unsigned int wait_time = 180 * HZ; + + while (ps3_atomic_read(&instance->event_context.subwork) != 1) { wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } - ps3_msleep(100*HZ); + ps3_msleep(100 * HZ); LOG_INFO("recovery wait event proc %d\n", - instance->event_context.subwork); + ps3_atomic_read(&instance->event_context.subwork)); return PS3_SUCCESS; } -S32 force_wait_event_subscribe(void * ptr) +static int force_wait_event_subscribe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 wait_time = 180*HZ; - while (instance->event_context.subwork != 1) { + unsigned int wait_time = 180 * HZ; + + while (ps3_atomic_read(&instance->event_context.subwork) != 1) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } - while (instance->event_context.subwork != 0) { + while (ps3_atomic_read(&instance->event_context.subwork) != 0) { ps3_msleep(1); wait_time--; - if (wait_time == 0) { + if (wait_time == 0) break; - } } LOG_INFO("recovery wait event subc %d\n", - instance->event_context.subwork); + ps3_atomic_read(&instance->event_context.subwork)); return PS3_SUCCESS; } -S32 force_hard_ready_failed(void * ptr) +static int force_hard_ready_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = PS3_FW_STATE_FAULT; - LOG_INFO("force_hard_ready_failed success \n"); + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = + PS3_FW_STATE_FAULT; + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -S32 wait_recovery_func0_running_1(void * ptr) +static int wait_recovery_func0_running_1(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[0] = 0xcc; - while (instance->reserve[0] == 0xcc) { - msleep(10); - } - LOG_INFO("wait_recovery_func0_running_1 success \n"); + while (instance->reserve[0] == 0xcc) + msleep(20); + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -S32 wait_recovery_func1_probe(void * ptr) +static int wait_recovery_func1_probe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_INFO("wait_recovery_func1_probe in \n"); - while (instance->peer_instance == NULL) { - msleep(10); - } - LOG_INFO("wait_recovery_func1_probe success \n"); + + LOG_INFO("%s in\n", __func__); + while (instance->peer_instance == NULL) + msleep(20); + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -S32 wait_recovery_func1_remove(void * ptr) +static int wait_recovery_func1_remove(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[0] = 0xb0; - while (instance->reserve[0] == 0xb0) { - msleep(10); - } - LOG_INFO("wait_recovery_func1_remove success \n"); + while (instance->reserve[0] == 0xb0) + msleep(20); + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -S32 wait_recovery_req_func1_remove(void * ptr) +static int wait_recovery_req_func1_remove(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[0] = 0xb1; - while (instance->reserve[0] == 0xb1) { - msleep(10); - } - LOG_INFO("wait_recovery_func1_remove success \n"); + while (instance->reserve[0] == 0xb1) + msleep(20); + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -S32 wait_recovery_func0_running_2(void * ptr) +static int wait_recovery_func0_running_2(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[0] = 0; - if(instance->peer_instance) { + if (instance->peer_instance) instance->peer_instance->reserve[0] = 0; - } - LOG_INFO("wait_recovery_func0_running_2 \n"); + LOG_INFO("%s\n", __func__); return PS3_SUCCESS; } -S32 force_trigger_log_fail(void * ptr) +static int force_trigger_log_fail(void *ptr) { - U8 * ret = (U8 *)ptr; + unsigned char *ret = (unsigned char *)ptr; + *ret = PS3_FALSE; return PS3_SUCCESS; } -S32 force_event_cmd_null(void * ptr) +static int force_event_cmd_null(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->event_context.event_cmd = NULL; return PS3_SUCCESS; } -S32 force_event_cmd_init(void * ptr) +static int force_event_cmd_init(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_cmd *cmd = instance->event_context.event_cmd; + cmd->cmd_state.state = PS3_CMD_STATE_INIT; return PS3_SUCCESS; } -S32 force_cmd_done(void * ptr) -{ - struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - U8 reply_flags = PS3_SUCCESS; - ps3_scsih_io_done(cmd, reply_flags); - - return PS3_SUCCESS; -} -S32 force_aborted_cmd_done(void * ptr) +static int force_aborted_cmd_done(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - U16 aborted_cmd_frame_id = 0; - U8 reply_flags = PS3_SUCCESS; - PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; + unsigned short aborted_cmd_frame_id = 0; + unsigned char reply_flags = PS3_SUCCESS; + struct PS3MgrTaskReqFrame *mgr_task_req_frame = NULL; struct ps3_instance *instance = cmd->instance; mgr_task_req_frame = &cmd->req_frame->taskReq; @@ -938,10 +1035,11 @@ S32 force_aborted_cmd_done(void * ptr) return PS3_SUCCESS; } -S32 force_stop_aborted_cmd_done(void * ptr) +static int force_stop_aborted_cmd_done(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - ps3_hard_recovery_request(instance); + + ps3_hard_recovery_request(instance, PS3_FALSE); ps3_recovery_cancel_work_sync(instance); @@ -949,11 +1047,11 @@ S32 force_stop_aborted_cmd_done(void * ptr) } #ifdef PS3_UT -S32 force_scsi_cmd_done(void * ptr) +static int force_scsi_cmd_done(void *ptr) { struct scsi_cmnd *scmd = (struct scsi_cmnd *)ptr; - U8 reply_flags = PS3_SUCCESS; - U16 cmd_frame_id = 0; + unsigned char reply_flags = PS3_SUCCESS; + unsigned short cmd_frame_id = 0; struct ps3_cmd *aborted_cmd; struct ps3_instance *instance = scsi_host_data(scmd); @@ -965,70 +1063,73 @@ S32 force_scsi_cmd_done(void * ptr) return PS3_SUCCESS; } -S32 force_set_ioc_in_security(void *ptr) +static int force_set_ioc_in_security(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; - writeq_fake(0x1, &instance->reg_set->reg_f.Excl_reg.ps3Debug7); + struct ps3_instance *instance = (struct ps3_instance *)ptr; + + writeq_fake(0x1, &instance->reg_set->reg_f.Excl_reg.ps3Debug7); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_set_ioc_running(void *ptr) +static int force_set_ioc_running(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + unsigned long long state; if (instance->reg_set != NULL) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_RUNNING; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_RUNNING; } state = instance->ioc_adpter->ioc_state_get(instance); LOG_WARN("ioc state [%llu]\n", state); - return PS3_SUCCESS; + return PS3_SUCCESS; } #else -S32 force_set_ioc_in_security(void *ptr) +static int force_set_ioc_in_security(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug7, 0x1); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_set_ioc_running(void *ptr) +static int force_set_ioc_running(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + unsigned long long state; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, state); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, + state); state |= PS3_FW_STATE_RUNNING; PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3SocFwState, state); - return PS3_SUCCESS; + return PS3_SUCCESS; } #endif -S32 force_set_ioc_fault(void * ptr) +static int force_set_ioc_fault(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; if (instance->reg_set != NULL) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_FAULT; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_FAULT; } state = instance->ioc_adpter->ioc_state_get(instance); LOG_WARN("ioc state [%llu]\n", state); return PS3_SUCCESS; } -S32 force_set_ioc_halt(void * ptr) +static int force_set_ioc_halt(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; if (instance->reg_set != NULL) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_HALT; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_HALT; } state = instance->ioc_adpter->ioc_state_get(instance); @@ -1036,102 +1137,106 @@ S32 force_set_ioc_halt(void * ptr) return PS3_SUCCESS; } -S32 force_set_f0_ioc_critical(void * ptr) +static int force_set_f0_ioc_critical(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; if (instance->reg_set != NULL && instance->peer_instance != NULL && - ps3_get_pci_function(instance->peer_instance->pdev) == PS3_FUNC_ID_0) { - instance->peer_instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_CRITICAL; + ps3_get_pci_function(instance->peer_instance->pdev) == + PS3_FUNC_ID_0) { + instance->peer_instance->reg_set->reg_f.Excl_reg.ps3SocFwState + .reg.ps3SocFwState = PS3_FW_STATE_CRITICAL; } state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); - while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) == 0) { - msleep(5); + while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) == + 0) { + msleep(20); } LOG_WARN("ioc state [%llu]\n", state); return PS3_SUCCESS; } -S32 set_qos_share_cnt(void *ptr) +static int set_qos_share_cnt(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + ps3_atomic_set(&instance->qos_context.tg_ctx.share_free_cnt, 1); return PS3_SUCCESS; } -S32 force_event_cmd_dead(void *ptr) +static int force_event_cmd_dead(void *ptr) { - S32 *cur_state = (S32 *)ptr; + int *cur_state = (int *)ptr; + *cur_state = PS3_INSTANCE_STATE_RECOVERY; return PS3_SUCCESS; } -S32 wait_irq_disable(void * ptr) +static int wait_irq_disable(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; instance->reserved[0] = 0; - while(ps3_irq_is_enable(&instance->irq_context)) { - msleep(1); - } + while (ps3_irq_is_enable(&instance->irq_context)) + msleep(20); return PS3_SUCCESS; } -S32 wait_ioctl_detect_irq_disable(void * ptr) +static int wait_ioctl_detect_irq_disable(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(instance->reserved[0] != 0xab) { - msleep(1); - } + + while (instance->reserved[0] != 0xab) + msleep(20); return PS3_SUCCESS; } -S32 set_send_ioctl_block_flag(void * ptr) +static int set_send_ioctl_block_flag(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; - if (cmd->req_frame->mgrReq.reqHead.cmdType == PS3_CMD_IOCTL) { + if (cmd->req_frame->mgrReq.reqHead.cmdType == PS3_CMD_IOCTL) instance->reserved[0] = 0xab; - } return PS3_SUCCESS; } -S32 force_has_scsi_pending_io(void * ptr) +static int force_has_scsi_pending_io(void *ptr) { - Bool *found = (Bool *)ptr; + unsigned char *found = (unsigned char *)ptr; + *found = PS3_TRUE; return PS3_SUCCESS; } #ifdef PS3_UT -void scsi_cmd_create(struct scsi_cmnd *s_cmd, struct ps3_instance *instance) +static void scsi_cmd_create(struct scsi_cmnd *s_cmd, struct ps3_instance *instance) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0)) - unsigned char scsi_cmnd_tmp[] = {0x2a, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x08, 0x00, 0x00}; +#if defined(PS3_CMD_CREATE_INJECT) + unsigned char scsi_cmnd_tmp[] = { 0x2a, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x08, 0x00, 0x00 }; struct scsi_device *device; #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; + struct ps3_scsi_priv_data *device_priv_data = + (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; #endif memset(s_cmd, 0, sizeof(*s_cmd)); - s_cmd->cmnd = (U8 *)kmalloc(32, GFP_KERNEL); + s_cmd->cmnd = kmalloc(32, GFP_KERNEL); memset(s_cmd->cmnd, 0, sizeof(unsigned char) * 32); - SCMD_GET_REQUEST(s_cmd) = (struct request *)kmalloc(sizeof(struct request), GFP_KERNEL); + SCMD_GET_REQUEST(s_cmd) = kmalloc(sizeof(struct request), GFP_KERNEL); instance->host->can_queue = instance->cmd_context.max_scsi_cmd_count; instance->cmd_attr.nvme_page_size = PAGE_SIZE; s_cmd->sense_buffer = (unsigned char *)kmalloc(96, GFP_KERNEL); memcpy(s_cmd->cmnd, scsi_cmnd_tmp, 10); - device = (struct scsi_device *)kmalloc(sizeof(struct scsi_device), GFP_KERNEL); + device = kmalloc(sizeof(struct scsi_device), GFP_KERNEL); s_cmd->device = device; - s_cmd->device->host = instance->host; + s_cmd->device->host = instance->host; SCMD_GET_REQUEST(s_cmd)->tag = 88; s_cmd->cmd_len = 10; @@ -1143,7 +1248,7 @@ void scsi_cmd_create(struct scsi_cmnd *s_cmd, struct ps3_instance *instance) instance->irq_context.high_iops_io_count.counter = 62; #endif } -void scsi_cmd_free(struct scsi_cmnd *s_cmd) +static void scsi_cmd_free(struct scsi_cmnd *s_cmd) { kfree(s_cmd->cmnd); kfree(SCMD_GET_REQUEST(s_cmd)); @@ -1151,242 +1256,262 @@ void scsi_cmd_free(struct scsi_cmnd *s_cmd) kfree(s_cmd->device); } -S32 force_host_reset(void * ptr) +static int force_host_reset(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - - S32 ret_check = 0; - + int ret_check = 0; struct scsi_cmnd pending_scsi_cmd; + scsi_cmd_create(&pending_scsi_cmd, instance); - ret_check = instance->host->hostt->eh_host_reset_handler(&pending_scsi_cmd); + ret_check = + instance->host->hostt->eh_host_reset_handler(&pending_scsi_cmd); LOG_WARN("host reset [%d]\n", ret_check); scsi_cmd_free(&pending_scsi_cmd); return PS3_SUCCESS; } #endif -S32 force_return_false(void * ptr) +static int force_return_false(void *ptr) { - Bool *found = (Bool *)ptr; + unsigned char *found = (unsigned char *)ptr; + *found = PS3_FALSE; return PS3_SUCCESS; } -S32 force_return_true(void * ptr) +static int force_return_true(void *ptr) { - Bool *ret = (Bool *)ptr; - LOG_WARN("force_return_true in \n"); + unsigned char *ret = (unsigned char *)ptr; + + LOG_WARN("%s in\n", __func__); *ret = PS3_TRUE; - LOG_WARN("force_return_true in \n"); + LOG_WARN("%s in\n", __func__); return PS3_SUCCESS; } -S32 force_scsi_priv_data_null(void * ptr) -{ - S32 ret_check = 0; - struct scsi_cmnd *s_cmd = (struct scsi_cmnd *)ptr; - if (s_cmd->device) { - s_cmd->device->hostdata = NULL; - } - return ret_check; -} -S32 force_scsi_task_cmd_error(void * ptr) +static int force_ioc_not_running(void *ptr) { - struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - struct ps3_instance *instance = cmd->instance; + unsigned int *ioc_state = (unsigned int *)ptr; - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_TM_FAILED; - cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; - complete(&cmd->sync_done); - LOG_WARN("hno:%u force complete task mgr CFID:%d\n", - PS3_HOST(instance), cmd->index); - return PS3_SUCCESS; -} -S32 force_ioc_not_running(void * ptr) -{ - U32 * ioc_state = (U32 *)ptr; - if(ioc_state) { + if (ioc_state) *ioc_state = PS3_FW_STATE_RUNNING + 1; - } return PS3_SUCCESS; } -S32 force_ioc_running(void * ptr) +static int force_ioc_running(void *ptr) { - U32 * ioc_state = (U32 *)ptr; - if(ioc_state) { + unsigned int *ioc_state = (unsigned int *)ptr; + + if (ioc_state) *ioc_state = PS3_FW_STATE_RUNNING; - } return PS3_SUCCESS; } -S32 force_task_cmd_alloc_null(void ** ptr) -{ - struct ps3_cmd *cmd = (struct ps3_cmd *)*ptr; - struct ps3_instance *instance = NULL; - if(cmd) { - instance = (struct ps3_instance *)cmd->instance; - ps3_mgr_cmd_free(instance, cmd); - *ptr = NULL; - } - return PS3_SUCCESS; -} -S32 force_pcie_err(void * ptr) +static int force_pcie_err(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->state_machine.is_pci_err_recovery = PS3_TRUE; - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_ptr_null(void ** ptr) +static int force_ptr_null(void **ptr) { - if (*ptr) { + if (*ptr) *ptr = NULL; - } return PS3_SUCCESS; } -S32 wait_task_mgr_busy(void *ptr) +static int wait_task_mgr_busy(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while (!instance->task_manager_host_busy) { + + while (!instance->task_manager_host_busy) ps3_msleep(10); - } return PS3_SUCCESS; } -S32 wait_pd_clear(void * ptr) +static int wait_pd_clear(void *ptr) { struct ps3_qos_pd_mgr *qos_pd_mgr = (struct ps3_qos_pd_mgr *)ptr; - while (!qos_pd_mgr->clearing) { + + while (!qos_pd_mgr->clearing) ps3_msleep(100); - } return PS3_SUCCESS; } -S32 reset_target_pause(void *ptr) +static int reset_target_pause(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(instance->reserved[0] != 0xab) { + + while (instance->reserved[0] != 0xab) ps3_msleep(10); - } return PS3_SUCCESS; } -S32 set_send_cmd_task_mgr_busy_flag(void *ptr) +static int set_send_cmd_task_mgr_busy_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; return PS3_SUCCESS; } -S32 wait_qos_vd_send(void * ptr) +static int wait_qos_vd_send(void *ptr) { struct ps3_qos_pd_mgr *qos_pd_mgr = (struct ps3_qos_pd_mgr *)ptr; - while((qos_pd_mgr->vd_id == 0) || - (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) >= - qos_pd_mgr->pd_quota)) { - msleep(1); + + while ((qos_pd_mgr->vd_id == 0) || + (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) >= + qos_pd_mgr->pd_quota)) { + msleep(20); } return PS3_SUCCESS; } -S32 force_smp_cmd_error(void * ptr) + +static int force_pdlist_cmd_retry(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_SMP_BACKEND_ERR; + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; + LOG_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), + cmd->index); + + return PS3_SUCCESS; +} + +#ifdef PS3_UT +void ps3_wait_probe_rand_finish(void) +{ + LOG_WARN("enter %s\n", __func__); + while (g_work_que_probe.state != 1) + ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); + if (g_work_que_probe._queue != NULL) { + if (!cancel_delayed_work_sync(&g_work_que_probe._work)) + flush_workqueue(g_work_que_probe._queue); + + destroy_workqueue(g_work_que_probe._queue); + g_work_que_probe._queue = NULL; + } + LOG_WARN("quit %s\n", __func__); +} + +static int force_scsi_task_cmd_error(void *ptr) +{ + struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + struct ps3_instance *instance = cmd->instance; + + cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_TM_FAILED; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); - LOG_WARN("hno:%u force complete task mgr CFID:%d\n", - PS3_HOST(instance), cmd->index); + LOG_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), + cmd->index); + return PS3_SUCCESS; +} +static int force_task_cmd_alloc_null(void **ptr) +{ + struct ps3_cmd *cmd = (struct ps3_cmd *)*ptr; + struct ps3_instance *instance = NULL; + + if (cmd) { + instance = (struct ps3_instance *)cmd->instance; + ps3_mgr_cmd_free(instance, cmd); + *ptr = NULL; + } return PS3_SUCCESS; } -S32 force_pdlist_cmd_retry(void * ptr) +static int force_smp_cmd_error(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; - LOG_WARN("hno:%u force complete task mgr CFID:%d\n", - PS3_HOST(instance), cmd->index); + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_SMP_BACKEND_ERR; + cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; + complete(&cmd->sync_done); + LOG_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), + cmd->index); return PS3_SUCCESS; } -S32 force_get_linkerrors_cmd_error(void * ptr) +static int force_get_linkerrors_cmd_error(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_LINK_GET_BACKEND_ERR; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_LINK_GET_BACKEND_ERR; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); - LOG_WARN("hno:%u force complete task mgr CFID:%d\n", - PS3_HOST(instance), cmd->index); + LOG_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), + cmd->index); return PS3_SUCCESS; } -S32 force_sas_phy_ctrl_cmd_error(void * ptr) + +static int force_sas_phy_ctrl_cmd_error(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; struct ps3_instance *instance = cmd->instance; - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_PHY_CTL_BACKEND_ERR; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_PHY_CTL_BACKEND_ERR; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); - LOG_WARN("hno:%u force complete task mgr CFID:%d\n", - PS3_HOST(instance), cmd->index); + LOG_WARN("hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), + cmd->index); return PS3_SUCCESS; } - -S32 force_instance_state_to_unnormal(void *ptr) +#endif +static int force_instance_state_to_unnormal(void *ptr) { - S32 * state = (S32 *)ptr; - if(state) { + int *state = (int *)ptr; + + if (state) *state = PS3_INSTANCE_STATE_RECOVERY; - } - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_instance_state_to_dead(void *ptr) +static int force_instance_state_to_dead(void *ptr) { - S32 * state = (S32 *)ptr; - if(state) { + int *state = (int *)ptr; + + if (state) *state = PS3_INSTANCE_STATE_DEAD; - } - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 ps3_sas_encl_id_get_failed(void *ptr) +static int ps3_sas_encl_id_get_failed(void *ptr) { - U8 *encl_id = (U8 *)ptr; - if(encl_id) { + unsigned char *encl_id = (unsigned char *)ptr; + + if (encl_id) *encl_id = PS3_SAS_INVALID_ID; - } - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 ps3_sas_rphy_parent_sas_addr_get_failed(void *ptr) +static int ps3_sas_rphy_parent_sas_addr_get_failed(void *ptr) { u64 *encl_id = (u64 *)ptr; - if(encl_id) { + + if (encl_id) *encl_id = PS3_SAS_INVALID_SAS_ADDR; - } - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_mgr_cmd_alloc_null(void ** ptr) +static int force_mgr_cmd_alloc_null(void **ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)*ptr; struct ps3_instance *instance = NULL; - if(cmd) { + + if (cmd) { instance = (struct ps3_instance *)cmd->instance; ps3_mgr_cmd_free(instance, cmd); *ptr = NULL; @@ -1395,111 +1520,134 @@ S32 force_mgr_cmd_alloc_null(void ** ptr) return PS3_SUCCESS; } -S32 force_cmd_polling(void ** ptr) +static int force_cmd_polling(void **ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - if(cmd) { + + if (cmd) cmd->is_force_polling = 1; - } return PS3_SUCCESS; } -S32 force_pci_err_recovery(void ** ptr) +static int force_pci_err_recovery(void **ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - if(instance) { + + if (instance) instance->state_machine.is_pci_err_recovery = PS3_TRUE; - } return PS3_SUCCESS; } -S32 cli_wait_recovery(void *ptr) +static int cli_wait_recovery(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - Bool flag = PS3_FALSE; - while (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_READY) { + unsigned char flag = PS3_FALSE; + + while (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_READY) { if (!flag) { instance->reserve[0] = 1; flag = PS3_TRUE; } - msleep(10); + msleep(20); } instance->reserve[1] = 1; - while (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_OPERATIONAL) { - msleep(10); + while (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_OPERATIONAL) { + msleep(20); } return PS3_SUCCESS; } -S32 recovery_wait_cli(void *ptr) +static int recovery_wait_cli(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while (instance->reserve[1] != 1) { - msleep(10); - } + + while (instance->reserve[1] != 1) + msleep(20); instance->reserve[1] = 0; return PS3_SUCCESS; } -S32 force_blk_rq_bytes_invalid(void * ptr) +static int force_blk_rq_bytes_invalid(void *ptr) { struct request *req = (struct request *)ptr; - if(req) { + if (req) req->__data_len = U32_MAX; - } return PS3_SUCCESS; } -S32 wait_cmd_done(void * ptr) +static int wait_cmd_done(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; - while(instance->reserved[0] == 0xab) { - msleep(10); + while (instance->reserved[0] == 0xab) + msleep(20); + return PS3_SUCCESS; +} + +static int wait_cmd_send_block(void *ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + + while (instance->reserved[0] == 0) { + instance->reserved[1] = 0xcd; + msleep(20); } return PS3_SUCCESS; } -S32 wait_cmd_send_block(void * ptr) +static int qos_waitq_notify_block(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(instance->reserved[0] == 0) { + + while (instance->reserved[0] == 0) { + msleep(20); instance->reserved[1] = 0xcd; - msleep(10); } + + instance->reserved[1] = 0xef; + while (instance->reserved[1] == 0xef) { + msleep(20); + } + return PS3_SUCCESS; } -S32 set_r1x_conflict_process_flag(void *ptr) +static int set_r1x_conflict_process_flag(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; return PS3_SUCCESS; } -S32 force_task_mgr_busy(void * ptr) +static int force_task_mgr_busy(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->task_manager_host_busy = PS3_TRUE; return PS3_SUCCESS; } -S32 block_in_cmd_send(void * ptr) +static int block_in_cmd_send(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; - while(instance->reserved[0] == 0xab) { - msleep(10); - } + while (instance->reserved[0] == 0xab) + msleep(20); return PS3_SUCCESS; } -S32 create_pd_worker_fail(void * ptr) +static int create_pd_worker_fail(void *ptr) { struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct workqueue_struct **work_queues = NULL; + qos_pd_ctx = (struct ps3_qos_pd_context *)ptr; work_queues = qos_pd_ctx->work_queues; @@ -1512,20 +1660,23 @@ S32 create_pd_worker_fail(void * ptr) return PS3_SUCCESS; } -S32 create_tag_waitq_fail(void *ptr) +static int create_tag_waitq_fail(void *ptr) { - struct ps3_qos_tg_context *qos_tg_ctx = (struct ps3_qos_tg_context *)ptr; + struct ps3_qos_tg_context *qos_tg_ctx = + (struct ps3_qos_tg_context *)ptr; + if (qos_tg_ctx->vd_cmd_waitqs != NULL) { ps3_vfree(qos_tg_ctx->instance, qos_tg_ctx->vd_cmd_waitqs); qos_tg_ctx->vd_cmd_waitqs = NULL; - } return PS3_SUCCESS; } -S32 create_tag_workq_fail(void *ptr) +static int create_tag_workq_fail(void *ptr) { - struct ps3_qos_tg_context *qos_tg_ctx = (struct ps3_qos_tg_context *)ptr; + struct ps3_qos_tg_context *qos_tg_ctx = + (struct ps3_qos_tg_context *)ptr; + if (qos_tg_ctx->work_queue != NULL) { destroy_workqueue(qos_tg_ctx->work_queue); qos_tg_ctx->work_queue = NULL; @@ -1534,10 +1685,11 @@ S32 create_tag_workq_fail(void *ptr) return PS3_SUCCESS; } -S32 create_vd_mgrs_fail(void *ptr) +static int create_vd_mgrs_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; + if (qos_vd_ctx->qos_vd_mgrs != NULL) { ps3_vfree(instance, qos_vd_ctx->qos_vd_mgrs); qos_vd_ctx->qos_vd_mgrs = NULL; @@ -1545,22 +1697,23 @@ S32 create_vd_mgrs_fail(void *ptr) return PS3_SUCCESS; } -S32 create_vd_workq_fail(void *ptr) +static int create_vd_workq_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; + if (qos_vd_ctx->work_queues != NULL) { ps3_vfree(instance, qos_vd_ctx->work_queues); qos_vd_ctx->work_queues = NULL; } return PS3_SUCCESS; - } -S32 create_vd_worker_fail(void *ptr) +static int create_vd_worker_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_qos_vd_context *qos_vd_ctx = &instance->qos_context.vd_ctx; + if (qos_vd_ctx->work_queues[0] != NULL) { destroy_workqueue(qos_vd_ctx->work_queues[0]); qos_vd_ctx->work_queues[0] = NULL; @@ -1568,10 +1721,11 @@ S32 create_vd_worker_fail(void *ptr) return PS3_SUCCESS; } -S32 create_pd_mgrs_fail(void *ptr) +static int create_pd_mgrs_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + if (qos_pd_ctx->qos_pd_mgrs != NULL) { ps3_vfree(instance, qos_pd_ctx->qos_pd_mgrs); qos_pd_ctx->qos_pd_mgrs = NULL; @@ -1579,51 +1733,90 @@ S32 create_pd_mgrs_fail(void *ptr) return PS3_SUCCESS; } -S32 create_pd_waitq_fail(void *ptr) +static int create_pd_waitq_fail(void *ptr) +{ + struct ps3_qos_pd_context *qos_pd_ctx = + (struct ps3_qos_pd_context *)ptr; + struct ps3_qos_pd_mgr *qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[2]; + struct ps3_instance *instance = qos_pd_mgr->instance; + + if (qos_pd_mgr->waitqs != NULL) { + ps3_vfree(instance, qos_pd_mgr->waitqs); + qos_pd_mgr->waitqs = NULL; + } + return PS3_SUCCESS; +} + +static int create_pd_workq_fail(void *ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + + if (qos_pd_ctx->work_queues != NULL) { + ps3_vfree(instance, qos_pd_ctx->work_queues); + qos_pd_ctx->work_queues = NULL; + } + return PS3_SUCCESS; +} + +static int create_pd_reply_info_fail(void *ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + + if (qos_pd_ctx->reply_info != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info); + qos_pd_ctx->reply_info = NULL; + } + return PS3_SUCCESS; +} + +static int create_pd_state_fail(void *ptr) { - struct ps3_qos_pd_context *qos_pd_ctx = (struct ps3_qos_pd_context *)ptr; - struct ps3_qos_pd_mgr *qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[2]; - struct ps3_instance *instance = qos_pd_mgr->instance; - if (qos_pd_mgr->waitqs != NULL) { - ps3_vfree(instance, qos_pd_mgr->waitqs); - qos_pd_mgr->waitqs = NULL; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; + if (qos_pd_ctx->reply_info[0].processed_pd_state != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[0].processed_pd_state); + qos_pd_ctx->reply_info[0].processed_pd_state = NULL; } return PS3_SUCCESS; } -S32 create_pd_workq_fail(void *ptr) +static int create_pd_id_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; struct ps3_qos_pd_context *qos_pd_ctx = &instance->qos_context.pd_ctx; - if (qos_pd_ctx->work_queues != NULL) { - ps3_vfree(instance, qos_pd_ctx->work_queues); - qos_pd_ctx->work_queues = NULL; + if (qos_pd_ctx->reply_info[0].processed_pd_id != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[0].processed_pd_id); + qos_pd_ctx->reply_info[0].processed_pd_id = NULL; } return PS3_SUCCESS; } -S32 force_cmd_vd_seq_change(void *ptr) +static int force_cmd_vd_seq_change(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + cmd->req_frame->hwReq.reqHead.virtDiskSeq = 0xFF; return PS3_SUCCESS; } -S32 force_u64_zero(void *ptr) +static int force_u64_zero(void *ptr) { - *(U64 *)ptr = 0; + *(unsigned long long *)ptr = 0; return PS3_SUCCESS; } -S32 force_fifo_depth_zero(void *ptr) +static int force_fifo_depth_zero(void *ptr) { - *(U64 *)ptr = 0; + *(unsigned long long *)ptr = 0; return PS3_SUCCESS; } -S32 create_mgr_waitq_fail(void *ptr) +static int create_mgr_waitq_fail(void *ptr) { struct ps3_qos_softq_mgr *softq_mgr = (struct ps3_qos_softq_mgr *)ptr; + if (softq_mgr->waitqs) { ps3_vfree(softq_mgr->instance, softq_mgr->waitqs); softq_mgr->waitqs = NULL; @@ -1632,9 +1825,10 @@ S32 create_mgr_waitq_fail(void *ptr) return PS3_SUCCESS; } -S32 create_mgr_worker_fail(void *ptr) +static int create_mgr_worker_fail(void *ptr) { struct ps3_qos_softq_mgr *softq_mgr = (struct ps3_qos_softq_mgr *)ptr; + if (softq_mgr->work_queue) { destroy_workqueue(softq_mgr->work_queue); softq_mgr->work_queue = NULL; @@ -1643,9 +1837,10 @@ S32 create_mgr_worker_fail(void *ptr) return PS3_SUCCESS; } -S32 create_cmd_waitq_fail(void *ptr) +static int create_cmd_waitq_fail(void *ptr) { struct ps3_qos_softq_mgr *softq_mgr = (struct ps3_qos_softq_mgr *)ptr; + if (softq_mgr->waitqs) { ps3_vfree(softq_mgr->instance, softq_mgr->waitqs); softq_mgr->waitqs = NULL; @@ -1653,9 +1848,10 @@ S32 create_cmd_waitq_fail(void *ptr) return PS3_SUCCESS; } -S32 create_cmd_worker_fail(void *ptr) +static int create_cmd_worker_fail(void *ptr) { struct ps3_qos_softq_mgr *softq_mgr = (struct ps3_qos_softq_mgr *)ptr; + if (softq_mgr->id == 1 && softq_mgr->work_queue) { destroy_workqueue(softq_mgr->work_queue); softq_mgr->work_queue = NULL; @@ -1663,20 +1859,21 @@ S32 create_cmd_worker_fail(void *ptr) return PS3_SUCCESS; } -S32 wait_for_dead_or_pre_operational(void *ptr) +static int wait_for_dead_or_pre_operational(void *ptr) { - U32 wait_cnt = 180 * 3; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - U32 idx = 0; + unsigned int wait_cnt = 180 * 3; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned int idx = 0; struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_INFO("hno:%u wait dead or pre_operational begin\n", PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational begin\n", + PS3_HOST(instance)); for (idx = 0; idx < wait_cnt; idx++) { cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) { + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_QUIT)) { break; } @@ -1685,44 +1882,44 @@ S32 wait_for_dead_or_pre_operational(void *ptr) if (idx >= wait_cnt) { LOG_WARN("hno:%u wait dead or pre_operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } if ((cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_DEAD)) { + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && + (cur_state != PS3_INSTANCE_STATE_DEAD)) { LOG_WARN("hno:%u wait dead or pre_operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; - } - LOG_INFO("hno:%u wait dead or pre_operational success!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational success!\n", + PS3_HOST(instance)); return PS3_SUCCESS; } -S32 force_init_cmd_failed(void *ptr) +static int force_init_cmd_failed(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + unsigned long long state; if (instance->reg_set != NULL) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_UNDEFINED; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_UNDEFINED; } state = instance->ioc_adpter->ioc_state_get(instance); LOG_WARN("ioc state [%llu]\n", state); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_recovery_init_cmd_failed(void *ptr) +static int force_recovery_init_cmd_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; if (instance->reg_set != NULL && instance->reserve[0]) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_UNDEFINED; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_UNDEFINED; } state = instance->ioc_adpter->ioc_state_get(instance); @@ -1730,13 +1927,14 @@ S32 force_recovery_init_cmd_failed(void *ptr) return PS3_SUCCESS; } -S32 force_recovery_operation_cmd_failed(void *ptr) +static int force_recovery_operation_cmd_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; if (instance->reserve[0]) { - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_RECOVERY); + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_RECOVERY); } state = ps3_atomic_read(&instance->state_machine.state); @@ -1744,31 +1942,33 @@ S32 force_recovery_operation_cmd_failed(void *ptr) return PS3_SUCCESS; } -S32 force_init_cmd_running_failed(void *ptr) +static int force_init_cmd_running_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U64 state; + unsigned long long state; + if (instance->reg_set != NULL) { - instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = - PS3_FW_STATE_FAULT; + instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg + .ps3SocFwState = PS3_FW_STATE_FAULT; } state = instance->ioc_adpter->ioc_state_get(instance); LOG_WARN("ioc state [%llu]\n", state); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 err_abort_block(void * ptr) +static int err_abort_block(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while(instance->reserved2[0] == 0) { + + while (instance->reserved2[0] == 0) { instance->reserved2[1] = 0xcd; - msleep(10); + msleep(20); } return PS3_SUCCESS; } -static void ps3_test_recovery_call(struct work_struct* work) +static void ps3_test_recovery_call(struct work_struct *work) { struct ps3_instance *instance = NULL; @@ -1777,209 +1977,197 @@ static void ps3_test_recovery_call(struct work_struct* work) LOG_WARN("ps3_test_reco_call enter\n"); - ps3_hard_recovery_request(instance); + ps3_hard_recovery_request(instance, PS3_FALSE); g_work_que_recovery.state = 1; LOG_WARN("ps3_test_reco_call quit\n"); } -void ps3_start_recovery_rand_thread(struct ps3_instance *instance) +static void ps3_start_recovery_rand_thread(struct ps3_instance *instance) { - char _queue_name[32] = {"test_reco"}; + char _queue_name[32] = { "test_reco" }; INIT_DELAYED_WORK(&g_work_que_recovery._work, ps3_test_recovery_call); g_work_que_recovery._queue = create_singlethread_workqueue(_queue_name); - if (g_work_que_recovery._queue == NULL) { + if (g_work_que_recovery._queue == NULL) return; - } g_work_que_recovery.instance = instance; g_work_que_recovery.state = 0; - queue_delayed_work(g_work_que_recovery._queue, &g_work_que_recovery._work, - msecs_to_jiffies(prandom_u32() % 800)); + queue_delayed_work(g_work_que_recovery._queue, + &g_work_que_recovery._work, + msecs_to_jiffies(ps3_prandom_u32() % 800)); } -static void ps3_test_probe_call(struct work_struct* work) +static void ps3_test_probe_call(struct work_struct *work) { struct ps3_instance *instance = NULL; - U32 idx = 0; + unsigned int idx = 0; + (void)work; instance = g_work_que_probe.instance; - LOG_WARN("ps3_test_probe_call enter\n"); + LOG_WARN("%s enter\n", __func__); - if (instance->peer_instance == NULL) { - return ; - } + if (instance->peer_instance == NULL) + return; instance->peer_instance->is_probe_finish = false; g_work_que_probe.state = 1; - while (idx++ < 10000) { - msleep(10); - } - + while (idx++ < 10000) + msleep(20); + instance->peer_instance->is_probe_finish = true; - LOG_WARN("ps3_test_probe_call quit\n"); + LOG_WARN("%s quit\n", __func__); } -void ps3_start_probe_rand_thread(struct ps3_instance *instance) +static void ps3_start_probe_rand_thread(struct ps3_instance *instance) { - char _queue_name[32] = {"test_probe"}; + char _queue_name[32] = { "test_probe" }; INIT_DELAYED_WORK(&g_work_que_probe._work, ps3_test_probe_call); g_work_que_probe._queue = create_singlethread_workqueue(_queue_name); - if (g_work_que_probe._queue == NULL) { + if (g_work_que_probe._queue == NULL) return; - } g_work_que_probe.instance = instance; g_work_que_probe.state = 0; queue_delayed_work(g_work_que_probe._queue, &g_work_que_probe._work, - msecs_to_jiffies(prandom_u32() % 800)); + msecs_to_jiffies(ps3_prandom_u32() % 800)); } -S32 wait_recovery_req_func1_probe(void * ptr) +static int wait_recovery_req_func1_probe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + ps3_start_probe_rand_thread(instance); - while (g_work_que_probe.state != 1) { + while (g_work_que_probe.state != 1) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } - LOG_INFO("wait_recovery_func1_probe success \n"); + LOG_INFO("%s success\n", __func__); return PS3_SUCCESS; } -void ps3_wait_probe_rand_finish(void) -{ - LOG_WARN("enter ps3_wait_probe_rand_finish\n"); - while (g_work_que_probe.state != 1) { - ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } - if (g_work_que_probe._queue != NULL) { - if (!cancel_delayed_work_sync(&g_work_que_probe._work)) { - flush_workqueue(g_work_que_probe._queue); - } - - destroy_workqueue(g_work_que_probe._queue); - g_work_que_probe._queue = NULL; - } - LOG_WARN("quit ps3_wait_probe_rand_finish\n"); -} -S32 force_hard_reset_request(void *ptr) +static int force_hard_reset_request(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + if (instance->peer_instance != NULL) { ps3_start_recovery_rand_thread(instance->peer_instance); - while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) == 0) { - msleep(5); + while (ps3_atomic_read( + &instance->recovery_context->hardreset_ref) == + 0) { + msleep(20); } } else { - ps3_hard_recovery_request(instance); + ps3_hard_recovery_request(instance, PS3_FALSE); } return PS3_SUCCESS; } -S32 force_hard_reset_request_1(void *ptr) +static int force_hard_reset_request_1(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("enter force_hard_reset_request_1\n"); - if (instance->reserve[0] == 0) { - ps3_hard_recovery_request(instance); - } else { - ps3_hard_recovery_request(instance->peer_instance); - } - cancel_work_sync(&instance->recovery_context->recovery_work); - LOG_WARN("enter force_hard_reset_request_1 end\n"); + + LOG_WARN("enter %s\n", __func__); + if (instance->reserve[0] == 0) + ps3_hard_recovery_request(instance, PS3_FALSE); + else + ps3_hard_recovery_request(instance->peer_instance, PS3_FALSE); + ps3_cancel_work_sync(&instance->recovery_context->recovery_work); + LOG_WARN("enter %s end\n", __func__); return PS3_SUCCESS; } -S32 force_instance_null(void *ptr) +static int force_instance_null(void *ptr) { struct ps3_instance **instance = (struct ps3_instance **)ptr; - LOG_WARN("enter force_instance_null\n"); + + LOG_WARN("enter %s\n", __func__); *instance = NULL; - LOG_WARN("force_instance_null end\n"); + LOG_WARN("%s end\n", __func__); return PS3_SUCCESS; } -S32 force_half_reset(void *ptr) +static int force_half_reset(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("enter force_half_reset\n"); + + LOG_WARN("enter %s\n", __func__); instance->is_half_hard_reset = PS3_DRV_TRUE; - LOG_WARN("force_half_reset end\n"); + LOG_WARN("%s end\n", __func__); return PS3_SUCCESS; } -S32 force_half_reset_false(void *ptr) +static int force_half_reset_false(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("enter force_half_reset_false\n"); + + LOG_WARN("enter %s\n", __func__); instance->is_half_hard_reset = PS3_DRV_FALSE; - LOG_WARN("force_half_reset_false end\n"); + LOG_WARN("%s end\n", __func__); return PS3_SUCCESS; } -S32 force_web_subscribe_failed(void *ptr) +static int force_web_subscribe_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("enter force_half_reset_false\n"); + LOG_WARN("enter %s\n", __func__); ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, 1); - LOG_WARN("force_half_reset_false end\n"); + LOG_WARN("%s end\n", __func__); return PS3_SUCCESS; } -S32 force_cmd_delivering_zero(void *ptr) +static int force_cmd_delivering_zero(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("enter force_cmd_delivering_zero\n"); + LOG_WARN("enter %s\n", __func__); ps3_atomic_set(&instance->cmd_statistics.cmd_delivering, 0); - LOG_WARN("force_cmd_delivering_zero end\n"); + LOG_WARN("%s end\n", __func__); return PS3_SUCCESS; } -S32 force_async_hard_reset_request(void *ptr) +static int force_async_hard_reset_request(void *ptr) { - struct ps3_instance *instance = (struct ps3_instance *)ptr; + struct ps3_instance *instance = (struct ps3_instance *)ptr; + ps3_start_recovery_rand_thread(instance); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 change_fw_state_to_halt_in_recover_prepare(void *ptr) +static int change_fw_state_to_halt_in_recover_prepare(void *ptr) { - U32 *p_ioc_state = (U32 *)ptr; + unsigned int *p_ioc_state = (unsigned int *)ptr; + *p_ioc_state = PS3_FW_STATE_HALT; return PS3_SUCCESS; } -S32 wait_scsi_cmd_done_fail(void *ptr) +static int wait_scsi_cmd_done_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; - while (*instance->scsi_cmd_deliver != 0) { + while (*instance->scsi_cmd_deliver != 0) ps3_msleep(10); - } return PS3_SUCCESS; } void ps3_wait_recovery_rand_finish(void) { LOG_WARN("enter ps3_wait_reco_rand_finish\n"); - while (g_work_que_recovery.state != 1) { + while (g_work_que_recovery.state != 1) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } if (g_work_que_recovery._queue != NULL) { - if (!cancel_delayed_work_sync(&g_work_que_recovery._work)) { + if (!cancel_delayed_work_sync(&g_work_que_recovery._work)) flush_workqueue(g_work_que_recovery._queue); - } - while (g_work_que_recovery.instance->recovery_context->recovery_state != \ - PS3_HARD_RECOVERY_FINISH) { + while (g_work_que_recovery.instance->recovery_context + ->recovery_state != PS3_HARD_RECOVERY_FINISH) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); } @@ -1989,24 +2177,27 @@ void ps3_wait_recovery_rand_finish(void) LOG_WARN("quit ps3_wait_reco_rand_finish\n"); } -S32 force_hard_recovery_request_nosupport_fail(void *ptr) +static int force_hard_recovery_request_nosupport_fail(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - instance = instance; + + (void)instance; ps3_hard_reset_enable_modify(0); - return PS3_SUCCESS; + return PS3_SUCCESS; } -S32 force_seq_cmd(void *ptr) +static int force_seq_cmd(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + cmd->io_attr.seq_flag = SCSI_RW_SEQ_CMD; return PS3_SUCCESS; } -S32 wait_cmd_free(void *ptr) +static int wait_cmd_free(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + while (cmd->r1x_peer_cmd != NULL) { cmd->instance->reserved2[0] = 0xcd; ps3_msleep(20); @@ -2014,19 +2205,20 @@ S32 wait_cmd_free(void *ptr) return PS3_SUCCESS; } -S32 wait_abort_flag(void *ptr) +static int wait_abort_flag(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - while (cmd->is_aborting != 1) { + + while (cmd->is_aborting != 1) ps3_msleep(20); - } return PS3_SUCCESS; } -S32 wait_cmd_alloc1(void *ptr) +static int wait_cmd_alloc1(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - Bool is_first = PS3_TRUE; + unsigned char is_first = PS3_TRUE; + while (cmd->trace_id != 0xff) { if (is_first) { #ifdef PS3_UT @@ -2040,113 +2232,131 @@ S32 wait_cmd_alloc1(void *ptr) return PS3_SUCCESS; } -S32 wait_cmd_alloc2(void *ptr) +static int wait_cmd_alloc2(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - while (cmd->scmd == NULL) { + + while (cmd->scmd == NULL) ps3_msleep(20); - } #ifdef PS3_UT cmd->scmd->is_in_err += 1; #endif return PS3_SUCCESS; } -S32 set_abort_count(void *ptr) +static int set_abort_count(void *ptr) { #ifdef PS3_UT struct scsi_cmnd *s_cmnd = (struct scsi_cmnd *)ptr; + s_cmnd->abort_count++; #endif return PS3_SUCCESS; } -S32 wait_cmd_alloc(void *ptr) +static int wait_cmd_alloc(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - while (cmd->trace_id != 0xff) { + + while (cmd->trace_id != 0xff) ps3_msleep(20); - } cmd->trace_id = 0; return PS3_SUCCESS; } -S32 set_cmd_tid_flag(void *ptr) +static int set_cmd_tid_flag(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + cmd->trace_id = 0xff; return PS3_SUCCESS; } -S32 set_cmd_io_rw_flag_unkown(void * ptr) +static int set_cmd_io_rw_flag_unknown(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; - cmd->io_attr.rw_flag = PS3_SCSI_CMD_TYPE_UNKOWN; + + cmd->io_attr.rw_flag = PS3_SCSI_CMD_TYPE_UNKNOWN; return PS3_SUCCESS; } -S32 set_soft_zone_type_unkown(void * ptr) +static int set_soft_zone_type_unknown(void *ptr) { - U8 *type = (U8 *)ptr; + unsigned char *type = (unsigned char *)ptr; + *type = PS3_DEV_TYPE_UNKNOWN; return PS3_SUCCESS; } -S32 force_rand_cmd(void *ptr) +static int force_rand_cmd(void *ptr) { struct ps3_cmd *cmd = (struct ps3_cmd *)ptr; + cmd->io_attr.seq_flag = SCSI_RW_RANDOM_CMD; return PS3_SUCCESS; } -S32 force_ret_recovery(void * ptr) +static int force_ret_recovery(void *ptr) { - S32 *ret = (S32 *)ptr; - if(ret) { + int *ret = (int *)ptr; + + if (ret) *ret = -PS3_RECOVERED; - } return PS3_SUCCESS; } -S32 force_return_zero(void * ptr) +static int force_return_zero(void *ptr) { - *(S32 *)ptr = 0; + *(int *)ptr = 0; return PS3_SUCCESS; } -S32 force_return_invalid(void * ptr) +static int force_return_invalid(void *ptr) { - *(S32 *)ptr = 0x80; + *(int *)ptr = 0x80; return PS3_SUCCESS; } -S32 force_ret_failed(void * ptr) +static int force_ret_failed(void *ptr) { - S32 *ret = (S32 *)ptr; - if(ret) { + int *ret = (int *)ptr; + + if (ret) *ret = -PS3_FAILED; - } return PS3_SUCCESS; } -S32 force_cmd_not_mgr_cmd(void * ptr) +static int force_cmd_not_mgr_cmd(void *ptr) { - U16 *index = (U16 *)ptr; + unsigned short *index = (unsigned short *)ptr; + *index = 0; return PS3_SUCCESS; } -S32 force_phy_count_zero(void * ptr) +static int force_phy_count_zero(void *ptr) { - U8 *phy_count = (U8 *)ptr; + unsigned char *phy_count = (unsigned char *)ptr; + *phy_count = 0; return PS3_SUCCESS; } -S32 force_doorbell_failed(void * ptr) +static int force_doorbell_failed_start(void * ptr) +{ + unsigned int *fw_cur_state = (unsigned int *)ptr; + + LOG_INFO("force doorbell failed start\n"); + *fw_cur_state = PS3_FW_STATE_START; + LOG_INFO("force doorbell failed end\n"); + + return PS3_SUCCESS; +} + +static int force_doorbell_failed(void * ptr) { - U32 *fw_cur_state = (U32 *)ptr; + unsigned int *fw_cur_state = (unsigned int *)ptr; LOG_INFO("force doorbell failed start\n"); *fw_cur_state = PS3_FW_STATE_READY; @@ -2155,117 +2365,118 @@ S32 force_doorbell_failed(void * ptr) return PS3_SUCCESS; } -S32 force_vd_count_err(void * ptr) +static int force_vd_count_err(void *ptr) { - U16 *count = (U16 *)ptr; - if(count) { + unsigned short *count = (unsigned short *)ptr; + + if (count) *count = 2; - } return PS3_SUCCESS; } -S32 force_chan_err(void * ptr) +static int force_chan_err(void *ptr) { - U8 *chan = (U8 *)ptr; - if(chan) { + unsigned char *chan = (unsigned char *)ptr; + + if (chan) *chan = 255; - } return PS3_SUCCESS; } -S32 force_dev_err(void * ptr) +static int force_dev_err(void *ptr) { struct PS3Dev *dev = (struct PS3Dev *)ptr; - if(dev) { + + if (dev) dev->softChan = 15; - } return PS3_SUCCESS; } -S32 force_target_err(void * ptr) +static int force_target_err(void *ptr) { - U16 *target = (U16 *)ptr; - if(target) { + unsigned short *target = (unsigned short *)ptr; + + if (target) *target = 65535; - } return PS3_SUCCESS; } -S32 force_diskpos_err(void * ptr) +static int force_diskpos_err(void *ptr) { - U32 *disk_id = (U32 *)ptr; - if(disk_id) { + unsigned int *disk_id = (unsigned int *)ptr; + + if (disk_id) *disk_id = 0; - } return PS3_SUCCESS; } -S32 force_s32_zero(void * ptr) +static int force_s32_zero(void *ptr) { - S32 *ret = (S32 *)ptr; - if(ret) { + int *ret = (int *)ptr; + + if (ret) *ret = 0; - } return PS3_SUCCESS; } -S32 force_s32_letter_zero(void * ptr) +static int force_s32_letter_zero(void *ptr) { - S32 *ret = (S32 *)ptr; - if(ret) { + int *ret = (int *)ptr; + + if (ret) *ret = 0; - } return PS3_SUCCESS; } -S32 force_align_err(void * ptr) +static int force_align_err(void *ptr) { - U8 *align = (U8 *)ptr; - if(align) { + unsigned char *align = (unsigned char *)ptr; + + if (align) *align = 16; - } return PS3_SUCCESS; } -S32 force_lun_err(void * ptr) +static int force_lun_err(void *ptr) { - U64 *lun = (U64 *)ptr; - if(lun) { + unsigned long long *lun = (unsigned long long *)ptr; + + if (lun) *lun = 1; - } return PS3_SUCCESS; } -S32 force_dev_type_err(void * ptr) +static int force_dev_type_err(void *ptr) { - U8 *type = (U8 *)ptr; - if(type) { + unsigned char *type = (unsigned char *)ptr; + + if (type) *type = 0; - } return PS3_SUCCESS; } -S32 force_pd_state_err(void * ptr) +static int force_pd_state_err(void *ptr) { - U8 *align = (U8 *)ptr; - if(align) { + unsigned char *align = (unsigned char *)ptr; + + if (align) *align = DEVICE_STATE_OUTING; - } return PS3_SUCCESS; } -S32 force_thread_null(void * ptr) +static int force_thread_null(void *ptr) { struct ps3_r1x_lock_mgr *mgr = (struct ps3_r1x_lock_mgr *)ptr; + if (mgr->conflict_send_th != NULL) { mgr->thread_stop = PS3_TRUE; complete(&mgr->thread_sync); @@ -2275,229 +2486,315 @@ S32 force_thread_null(void * ptr) return PS3_SUCCESS; } -S32 wait_pcie_err(void * ptr) +static int wait_pcie_err(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; LOG_INFO("wait pcie err start\n"); instance->reserve[0] = 1; - while(!ps3_pci_err_recovery_get(instance)){ + while (!ps3_pci_err_recovery_get(instance)) msleep(50); - } LOG_INFO("wait pcie err end\n"); return PS3_SUCCESS; } -S32 set_iops_channel(void * ptr) +static int set_iops_channel(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { + + if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) instance->irq_context.high_iops_msix_vectors = 16; - } return PS3_SUCCESS; } -S32 force_pcie_frozen(void * ptr) +static int force_pcie_frozen(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reg_set = NULL; return PS3_SUCCESS; } -S32 for_mod_so_addr(void * ptr) +static int for_mod_so_addr(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->so_start_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET(0x5000); instance->so_end_addr = PCIE_DMA_HOST_ADDR_BIT_POS_SET(0x10000); return PS3_SUCCESS; } -S32 force_pci_ioremap_fail(void ** ptr) +static int force_pci_ioremap_fail(void **ptr) { iounmap(*ptr); *ptr = NULL; return PS3_SUCCESS; } -S32 wait_recovery_req_coming(void * ptr) + +static int check_reserved02(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[2] = 1; + LOG_WARN("check reserved02 done\n"); + return PS3_SUCCESS; +} + +static int check_reserved03(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[3] = 1; + LOG_WARN("check reserved03 done\n"); + return PS3_SUCCESS; +} + +static int check_reserved10(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 1; + LOG_WARN("check reserved10 done\n"); + return PS3_SUCCESS; +} + +static int check_suspend_or_remove(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + while(instance->state_machine.is_load && !instance->is_suspend) { + ps3_msleep(1000); + } + LOG_WARN("instance remove/shutdown or suspend\n"); + return PS3_SUCCESS; +} + +static int check_event_null(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + while(instance->event_context.event_cmd != NULL) { + ps3_msleep(1000); + } + LOG_WARN("event_cmd null\n"); + return PS3_SUCCESS; +} + +static int wait_reserved03_end(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + while(!instance->reserve[3]) { + ps3_msleep(100); + } + LOG_WARN("reserve[3] set 1\n"); + return PS3_SUCCESS; +} + +static int check_reserved01_to_unload(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserve[1] = 1; + while(instance->state_machine.is_load && !instance->is_suspend) { + ps3_msleep(100); + LOG_WARN("wait unload\n"); + } + LOG_WARN("check unload done\n"); + return PS3_SUCCESS; +} + +static int check_half_recovery(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + while(!instance->is_half_hard_reset) { + ps3_msleep(100); + } + LOG_WARN("check half recovery\n"); + return PS3_SUCCESS; +} +static int wait_recovery_req_coming(void * ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 count = 0; - LOG_INFO("wait_recovery_req in \n"); - while (1){ - if (ps3_atomic_read(&instance->recovery_context->hardreset_ref) != 0) { + unsigned int count = 0; + + LOG_INFO("wait_recovery_req in\n"); + while (1) { + if (ps3_atomic_read( + &instance->recovery_context->hardreset_ref) != 0) { break; } - if (count == 10000) { + if (count == 10000) break; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); count++; } - LOG_INFO("wait_recovery_req success \n"); + LOG_INFO("wait_recovery_req success\n"); return PS3_SUCCESS; } -S32 wait_hard_recovery_req(void * ptr) + +static int wait_hard_recovery_req(void * ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - U32 count = 0; - LOG_INFO("wait_recovery_req in \n"); - while (1){ - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + unsigned int count = 0; + + LOG_INFO("wait_recovery_req in\n"); + while (1) { + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { break; } - if (count == 10000) { + if (count == 10000) break; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); count++; } - LOG_INFO("wait_recovery_req success \n"); + LOG_INFO("wait_recovery_req success\n"); return PS3_SUCCESS; } -S32 force_u8_1(void * ptr) +static int force_u8_1(void *ptr) { - U8 *ret = (U8 *)ptr; - if(ret) { + unsigned char *ret = (unsigned char *)ptr; + + if (ret) *ret = 1; - } return PS3_SUCCESS; } -S32 force_multi_hard_req(void * ptr) +static int force_multi_hard_req(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_SHALLOW; return PS3_SUCCESS; } -S32 force_multi_hard_req_pending(void * ptr) +static int force_multi_hard_req_pending(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_CONTINUE; } return PS3_SUCCESS; } -S32 force_recovery_wq_null(void * ptr) +static int force_recovery_wq_null(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->recovery_context->recovery_wq = NULL; return PS3_SUCCESS; } -S32 force_recovery_state_dead(void * ptr) +static int force_recovery_state_dead(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_DEAD); return PS3_SUCCESS; } -S32 force_recovery_support_false(void * ptr) +static int force_recovery_support_false(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; instance->is_hard_recovery_support = false; return PS3_SUCCESS; } -S32 force_memory_alloc_failed(void ** ptr) +static int force_memory_alloc_failed(void **ptr) { kfree(*ptr); *ptr = NULL; return PS3_SUCCESS; } -S32 force_web_subcribe(void * ptr) +static int force_web_subcribe(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); return PS3_SUCCESS; } -S32 force_instance_probe_failed(void * ptr) +static int force_instance_probe_failed(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->state_machine.is_load = PS3_FALSE; return PS3_SUCCESS; } -S32 force_func_id_invalid(void ** ptr) +static int force_func_id_invalid(void **ptr) { (void)ptr; - ps3_avaliable_func_id_modify(PS3_FUNC_ID_1); + ps3_available_func_id_modify(PS3_FUNC_ID_1); return PS3_SUCCESS; } -S32 wait_recovery_request(void *ptr) +static int wait_recovery_request(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - while (instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_DECIDE && - instance->recovery_context->recovery_state != PS3_HARD_RECOVERY_SHALLOW) { - msleep(10); + + while (instance->recovery_context->recovery_state != + PS3_HARD_RECOVERY_DECIDE && + instance->recovery_context->recovery_state != + PS3_HARD_RECOVERY_SHALLOW) { + msleep(20); } return PS3_SUCCESS; } -S32 recovery_wait_conditional(void * ptr) +static int recovery_wait_conditional(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; + instance->reserved[0] = 0xab; - while(instance->reserved[0] == 0xab) { - msleep(10); - } + while (instance->reserved[0] == 0xab) + msleep(20); return PS3_SUCCESS; } -S32 wait_recovery_request_2(void *ptr) +static int wait_recovery_request_2(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - ps3_hard_recovery_request(instance); + + ps3_hard_recovery_request(instance, PS3_FALSE); return PS3_SUCCESS; } -S32 wait_f0_watchdog(void *ptr) +static int wait_f0_watchdog(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("wait_f0_watchdog in \n"); - if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { + + LOG_WARN("%s in\n", __func__); + if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) goto l_out; - } - while (instance->recovery_context->recovery_state < PS3_HARD_RECOVERY_DECIDE) { - ps3_msleep(10); + while (instance->recovery_context->recovery_state < + PS3_HARD_RECOVERY_DECIDE) { + ps3_msleep(20); } l_out: - LOG_WARN("wait_f0_watchdog out \n"); + LOG_WARN("%s out\n", __func__); return PS3_SUCCESS; } -S32 wait_f0_watchdog_2(void *ptr) +static int wait_f0_watchdog_2(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("wait_f0_watchdog_2 in \n"); - while (instance->ioc_adpter->ioc_heartbeat_detect(instance) == 0) { - ps3_msleep(10); - } - LOG_WARN("wait_f0_watchdog_2 out \n"); - return PS3_SUCCESS; -} -S32 wait_recovery_end(void * ptr) -{ - struct ps3_instance *instance = (struct ps3_instance *)ptr; - instance->reserved[0] = 0xff; - cancel_work_sync(&instance->recovery_context->recovery_work); + LOG_WARN("%s in\n", __func__); + while (instance->ioc_adpter->ioc_heartbeat_detect(instance) == 0) + ps3_msleep(20); + LOG_WARN("%s out\n", __func__); return PS3_SUCCESS; } -S32 force_sas_port_create_fail(void * ptr) +static int force_sas_port_create_fail(void *ptr) { - struct ps3_sas_port *sas_port = (struct ps3_sas_port *)ptr; + struct ps3_sas_port *sas_port = (struct ps3_sas_port *)ptr; + if (sas_port->port != NULL) { sas_port_delete(sas_port->port); sas_port->port = NULL; @@ -2505,154 +2802,252 @@ S32 force_sas_port_create_fail(void * ptr) return PS3_SUCCESS; } -S32 force_pcie_remove_break(void * ptr) +static int force_pcie_remove_break(void *ptr) { struct ps3_cmd_context *cmd_context = (struct ps3_cmd_context *)ptr; - LOG_WARN("force_pcie_remove_break in \n"); + LOG_WARN("%s in\n", __func__); cmd_context->reserved0[0] = 1; - LOG_WARN("force_pcie_remove_break out \n"); + LOG_WARN("%s out\n", __func__); return PS3_SUCCESS; } -S32 check_pcie_remove_state(void * ptr) +static int check_pcie_remove_state(void *ptr) { struct ps3_instance *instance = (struct ps3_instance *)ptr; - LOG_WARN("check_pcie_remove_state in \n"); - while(instance->cmd_context.reserved0[0] != 1) { + + LOG_WARN("%s in\n", __func__); + while (instance->cmd_context.reserved0[0] != 1) ps3_msleep(10000); - } - LOG_WARN("check_pcie_remove_state out \n"); + LOG_WARN("%s out\n", __func__); + return PS3_SUCCESS; +} + +static int check_suspend(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + LOG_WARN("check_suspend in \n"); + instance->reserve[0] = 1; + LOG_WARN("check_suspend out \n"); + return PS3_SUCCESS; +} +static int force_key_state_check_failed(void * ptr) +{ + unsigned int *read_count = (unsigned int *)ptr; + *read_count = 900; + return PS3_SUCCESS; +} + +static int force_set_ioc_critical(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + U64 state; + + instance->peer_instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = + PS3_FW_STATE_CRITICAL; + state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); + LOG_WARN("ioc state [%llu]\n", state); + return PS3_SUCCESS; +} + +static int force_set_wait_count_max(void * ptr) +{ + unsigned int *count = (unsigned int *)ptr; + *count = 9000; + return PS3_SUCCESS; +} + +static int force_set_ioc_ready(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + U64 state; + + instance->peer_instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = + PS3_FW_STATE_READY; + state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); + LOG_WARN("ioc state [%llu]\n", state); + return PS3_SUCCESS; +} + +static int force_set_ioc_wait(void * ptr) +{ + struct ps3_instance *instance = (struct ps3_instance *)ptr; + U64 state; + + instance->peer_instance->reg_set->reg_f.Excl_reg.ps3SocFwState.reg.ps3SocFwState = + PS3_FW_STATE_WAIT; + state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); + LOG_WARN("ioc state [%llu]\n", state); + return PS3_SUCCESS; +} + +static int force_set_resp_err(void * ptr) +{ + unsigned int *respStatus = (unsigned int *)ptr; + *respStatus = SCSI_STATUS_BUSY; return PS3_SUCCESS; } void active_err_inject(void) { - U32 idx = 0; - U32 *arr_base = ps3_err_inject_array_query(); - U32 err_inject_num = ps3_err_inject_num_query(); - LOG_DEBUG("active err_inject_num:%u\n", - err_inject_num); + unsigned int idx = 0; + unsigned int *arr_base = ps3_err_inject_array_query(); + unsigned int err_inject_num = ps3_err_inject_num_query(); + + LOG_DEBUG("active err_inject_num:%u\n", err_inject_num); - for(; idx < err_inject_num;) - { + for (; idx < err_inject_num;) { if ((arr_base[idx] >= PS3_ERR_IJ_WATCHDOG_CONCURY) && - (arr_base[idx] < PS3_ERR_IJ_MAX_COUNT)) { - INJECT_ACTIVE(arr_base[idx], arr_base[idx + 1]) - LOG_DEBUG("active err_inject:%u count:%u \n", - arr_base[idx], arr_base[idx + 1]); + (arr_base[idx] < PS3_ERR_IJ_MAX_COUNT)) { + INJECT_ACTIVE(arr_base[idx], arr_base[idx + 1]); + LOG_DEBUG("active err_inject:%u count:%u\n", + arr_base[idx], arr_base[idx + 1]); idx += 2; } } } + void inject_init(void) { - if(is_inject_init == PS3_TRUE) { + if (is_inject_init == PS3_TRUE) return; - } is_inject_init = PS3_TRUE; - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_DEAD, force_ioctl_cmd_dead) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_PENDING, force_ioctl_cmd_pending) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_SIG_INTERRUPT, force_ioctl_cmd_sig_interrupt) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_INTERRUPT, force_ioctl_cmd_interrupt) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, force_ioctl_cmd_no_resp) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_ABORT_FAIL, force_return_fail) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, force_ioctl_cmd_recovery_cancel) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_ABORT_NO_RESP, force_ioctl_cmd_abort_no_resp) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_FORCE_DONE, force_ioctl_cmd_force_done) - INJECT_REG(PS3_ERR_IJ_WAIT_NORMAL, wait_instance_normal) - INJECT_REG(PS3_ERR_IJ_FIRMWARE_INIT_FAIL, force_ret_fail) - INJECT_REG(PS3_ERR_IJ_SCSI_SCAN_HOST_DELAY, force_scan_host_delay) - INJECT_REG(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, force_scan_host_fail) - INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_IO, force_ignore_task_io) - INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_ABORT, force_ignore_task_abort) - INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_RESET, force_ignore_task_reset) - INJECT_REG(PS3_ERR_IJ_EVENT_HANDLE, force_event_handle) - INJECT_REG(PS3_ERR_IJ_DEL_SCSI_DEV1, force_del_disk) - INJECT_REG(PS3_ERR_IJ_DEL_SCSI_DEV2, force_del_disk) - INJECT_REG(PS3_ERR_IJ_R1X_DEL_SCSI_DEV1, force_del_disk) - INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL1, force_priv_data_null) - INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL2, force_priv_data_null) - INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL3, force_priv_data_null) - INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL4, force_priv_data_null) - INJECT_REG(PS3_ERR_IJ_R1X_PRIV_DATA_NULL1, force_priv_data_null) - INJECT_REG(PS3_ERR_IJ_HT_ABNORMAL1, force_return_fail) - INJECT_REG(PS3_ERR_IJ_HT_ABNORMAL2, force_return_fail) - INJECT_REG(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_FLAG, force_int_wait_hard_flag) - INJECT_REG(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_SUBCRIBE, force_int_wait_hard_subcribe) - INJECT_REG(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_FLAG, force_wait_hard_flag) - INJECT_REG(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_SUBCRIBE, force_wait_hard_subcribe) - INJECT_REG(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_FLAG, force_wait_hard_flag) - INJECT_REG(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_SUBCRIBE, force_wait_hard_subcribe) - INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_INT, force_wait_event_int) - INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_PROC, force_wait_event_proc) - INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_SUBCRIBE, force_wait_event_subscribe) - INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_INT, force_wait_event_int) - INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_PROC, force_wait_event_proc) - INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_SUBCRIBE, force_wait_event_subscribe) - INJECT_REG(PS3_ERR_IJ_STORE_NO_TRIGGER_LOG, force_trigger_log_fail) - INJECT_REG(PS3_ERR_IJ_DETECT_NO_TRIGGER_LOG, force_trigger_log_fail) - INJECT_REG(PS3_ERR_IJ_EVENT_CMD_NULL, force_event_cmd_null) - INJECT_REG(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, force_event_cmd_null) - INJECT_REG(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT,force_event_cmd_init) - INJECT_REG(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT,force_event_cmd_init) - INJECT_REG(PS3_ERR_IJ_CANCEL_EVENT_CMD_FAIL, force_return_fail) - INJECT_REG(PS3_ERR_IJ_CANCEL_VDPENDING_CMD_FAIL, force_return_fail) - INJECT_REG(PS3_ERR_IJ_FW_STATE_RUNNING, force_return_fail) - INJECT_REG(PS3_ERR_IJ_SET_IOC_IN_SECURITY, force_set_ioc_in_security) - INJECT_REG(PS3_ERR_IJ_WAIT_UNNORMAL, wait_instance_unnormal) - INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, wait_reco_dump_valid) - INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID_2, wait_reco_dump_valid) - INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_NORMAL, wait_instance_normal) - INJECT_REG(PS3_ERR_IJ_WAIT_OPT, wait_instance_operational) - INJECT_REG(PS3_ERR_IJ_WAIT_READY, wait_ioc_ready) - INJECT_REG(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F1, force_hard_ready_failed) - INJECT_REG(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, force_hard_ready_failed) - INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, wait_recovery_func0_running_1) - INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, wait_recovery_func0_running_2) - INJECT_REG(PS3_ERR_IJ_FWSTATE_REMOVE, wait_remove_is_load_flag) - INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, ioctl_cmd_retry_done) - INJECT_REG(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, set_qos_share_cnt) - INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, wait_instance_unnormal_and_set_flag) - INJECT_REG(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, force_event_cmd_dead) - INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, wait_irq_disable) - INJECT_REG(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, wait_ioctl_detect_irq_disable) - INJECT_REG(PS3_ERR_IJ_WAIT_IOCTL_IN_DEVICE_RESET, wait_ioctl_detect_irq_disable) - INJECT_REG(PS3_ERR_IJ_SEND_IOCTL_BLOCK_MODE_FLAG, set_send_ioctl_block_flag) - INJECT_REG(PS3_ERR_IJ_FORCE_HAS_SCIS_PENDING_IO, force_has_scsi_pending_io) - INJECT_REG(PS3_ERR_IJ_HOST_RESET_WAIT_DECIDE, host_reset_wait_decide_normal) + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_DEAD, force_ioctl_cmd_dead); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_PENDING, force_ioctl_cmd_pending); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_SIG_INTERRUPT, + force_ioctl_cmd_sig_interrupt); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_INTERRUPT, force_ioctl_cmd_interrupt); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, force_ioctl_cmd_no_resp); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_ABORT_FAIL, force_return_fail); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, + force_ioctl_cmd_recovery_cancel); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_ABORT_NO_RESP, + force_ioctl_cmd_abort_no_resp); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_FORCE_DONE, force_ioctl_cmd_force_done); + INJECT_REG(PS3_ERR_IJ_WAIT_NORMAL, wait_instance_normal); + INJECT_REG(PS3_ERR_IJ_FIRMWARE_INIT_FAIL, force_ret_fail); + INJECT_REG(PS3_ERR_IJ_SCSI_SCAN_HOST_DELAY, force_scan_host_delay); + INJECT_REG(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, force_scan_host_fail); + INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_IO, force_ignore_task_io); + INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_ABORT, force_ignore_task_abort); + INJECT_REG(PS3_ERR_IJ_IGNORE_TASK_RESET, force_ignore_task_reset); + INJECT_REG(PS3_ERR_IJ_EVENT_HANDLE, force_event_handle); + INJECT_REG(PS3_ERR_IJ_DEL_SCSI_DEV1, force_del_disk); + INJECT_REG(PS3_ERR_IJ_DEL_SCSI_DEV2, force_del_disk); + INJECT_REG(PS3_ERR_IJ_R1X_DEL_SCSI_DEV1, force_del_disk); + INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL1, force_priv_data_null); + INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL2, force_priv_data_null); + INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL3, force_priv_data_null); + INJECT_REG(PS3_ERR_IJ_PRIV_DATA_NULL4, force_priv_data_null); + INJECT_REG(PS3_ERR_IJ_R1X_PRIV_DATA_NULL1, force_priv_data_null); + INJECT_REG(PS3_ERR_IJ_HT_ABNORMAL1, force_return_fail); + INJECT_REG(PS3_ERR_IJ_HT_ABNORMAL2, force_return_fail); + INJECT_REG(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_FLAG, + force_int_wait_hard_flag); + INJECT_REG(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_SUBCRIBE, + force_int_wait_hard_subcribe); + INJECT_REG(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_FLAG, force_wait_hard_flag); + INJECT_REG(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_SUBCRIBE, + force_wait_hard_subcribe); + INJECT_REG(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_FLAG, force_wait_hard_flag); + INJECT_REG(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_SUBCRIBE, + force_wait_hard_subcribe); + INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_INT, force_wait_event_int); + INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_PROC, force_wait_event_proc); + INJECT_REG(PS3_ERR_IJ_FLAG_WAIT_EVENT_SUBCRIBE, + force_wait_event_subscribe); + INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_INT, force_wait_event_int); + INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_PROC, force_wait_event_proc); + INJECT_REG(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_SUBCRIBE, + force_wait_event_subscribe); + INJECT_REG(PS3_ERR_IJ_STORE_NO_TRIGGER_LOG, force_trigger_log_fail); + INJECT_REG(PS3_ERR_IJ_DETECT_NO_TRIGGER_LOG, force_trigger_log_fail); + INJECT_REG(PS3_ERR_IJ_EVENT_CMD_NULL, force_event_cmd_null); + INJECT_REG(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, force_event_cmd_null); + INJECT_REG(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, force_event_cmd_init); + INJECT_REG(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT, force_event_cmd_init); + INJECT_REG(PS3_ERR_IJ_CANCEL_EVENT_CMD_FAIL, force_return_fail); + INJECT_REG(PS3_ERR_IJ_CANCEL_VDPENDING_CMD_FAIL, force_return_fail); + INJECT_REG(PS3_ERR_IJ_FW_STATE_RUNNING, force_return_fail); + INJECT_REG(PS3_ERR_IJ_SET_IOC_IN_SECURITY, force_set_ioc_in_security); + INJECT_REG(PS3_ERR_IJ_WAIT_UNNORMAL, wait_instance_unnormal); + INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID, wait_reco_dump_valid); + INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_RECO_VALID_2, wait_reco_dump_valid); + INJECT_REG(PS3_ERR_IJ_DUMP_WAIT_NORMAL, wait_instance_normal); + INJECT_REG(PS3_ERR_IJ_WAIT_OPT, wait_instance_operational); + INJECT_REG(PS3_ERR_IJ_WAIT_READY, wait_ioc_ready); + INJECT_REG(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F1, + force_hard_ready_failed); + INJECT_REG(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, + force_hard_ready_failed); + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, + wait_recovery_func0_running_1); + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, + wait_recovery_func0_running_2); + INJECT_REG(PS3_ERR_IJ_FWSTATE_REMOVE, wait_remove_is_load_flag); + INJECT_REG(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, ioctl_cmd_retry_done); + INJECT_REG(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, set_qos_share_cnt); + INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, + wait_instance_unnormal_and_set_flag); + INJECT_REG(PS3_ERR_IJ_FORCE_EVENT_CMD_FAIL_DEAD, force_event_cmd_dead); + INJECT_REG(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, wait_irq_disable); + INJECT_REG(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, + wait_ioctl_detect_irq_disable); + INJECT_REG(PS3_ERR_IJ_WAIT_IOCTL_IN_DEVICE_RESET, + wait_ioctl_detect_irq_disable); + INJECT_REG(PS3_ERR_IJ_SEND_IOCTL_BLOCK_MODE_FLAG, + set_send_ioctl_block_flag); + INJECT_REG(PS3_ERR_IJ_FORCE_HAS_SCIS_PENDING_IO, + force_has_scsi_pending_io); + INJECT_REG(PS3_ERR_IJ_HOST_RESET_WAIT_DECIDE, + host_reset_wait_decide_normal); #ifdef PS3_UT - INJECT_REG(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, force_scsi_cmd_done) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, force_scsi_cmd_done) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, force_scsi_cmd_done) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, force_scsi_cmd_done) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, force_scsi_cmd_done) - INJECT_REG(PS3_ERR_IJ_ABORT_CMD_ERROR, force_scsi_task_cmd_error) - INJECT_REG(PS3_ERR_IJ_RESET_CMD_ERROR, force_scsi_task_cmd_error) - INJECT_REG(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, force_pcie_err) - INJECT_REG( PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, force_instance_state_unnormal) - INJECT_REG(PS3_ERR_IJ_TASK_CMD_ALLOC_FAILED, force_task_cmd_alloc_null) - INJECT_REG(PS3_ERR_IJ_SMP_CMD_ERROR, force_smp_cmd_error) - INJECT_REG(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, force_get_linkerrors_cmd_error) - INJECT_REG(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, force_sas_phy_ctrl_cmd_error) - INJECT_REG(PS3_ERR_IJ_PROBE_HOST_RESET, force_host_reset) + INJECT_REG(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, + force_scsi_cmd_done); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, + force_scsi_cmd_done); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, + force_scsi_cmd_done); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, + force_scsi_cmd_done); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, + force_scsi_cmd_done); + INJECT_REG(PS3_ERR_IJ_ABORT_CMD_ERROR, force_scsi_task_cmd_error); + INJECT_REG(PS3_ERR_IJ_RESET_CMD_ERROR, force_scsi_task_cmd_error); + INJECT_REG(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, force_pcie_err); + INJECT_REG(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, + force_instance_state_unnormal); + INJECT_REG(PS3_ERR_IJ_TASK_CMD_ALLOC_FAILED, force_task_cmd_alloc_null); + INJECT_REG(PS3_ERR_IJ_SMP_CMD_ERROR, force_smp_cmd_error); + INJECT_REG(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, + force_get_linkerrors_cmd_error); + INJECT_REG(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, force_sas_phy_ctrl_cmd_error); + INJECT_REG(PS3_ERR_IJ_PROBE_HOST_RESET, force_host_reset); #else - INJECT_REG(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, ps3_scsi_rw_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, ps3_scsi_rw_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, ps3_scsi_rw_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, ps3_scsi_rw_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, ps3_scsi_rw_cmd_filter_handle) - - INJECT_REG(PS3_ERR_IJ_ABORT_CMD_TIMEOUT, ps3_scsi_task_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_RESET_CMD_TIMEOUT, ps3_scsi_task_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_CMD_ERROR, ps3_scsi_task_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_RESET_CMD_ERROR, ps3_scsi_task_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_ABORT_CMD_NORMAL, ps3_scsi_task_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_RESET_CMD_NORMAL, ps3_scsi_task_cmd_filter_handle) - - INJECT_REG(PS3_ERR_IJ_SMP_CMD_TIMEOUT, ps3_mgr_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_SMP_CMD_ERROR, ps3_mgr_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, ps3_mgr_cmd_filter_handle) - INJECT_REG(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, ps3_mgr_cmd_filter_handle) + INJECT_REG(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, + ps3_scsi_rw_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, + ps3_scsi_rw_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, + ps3_scsi_rw_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, + ps3_scsi_rw_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, + ps3_scsi_rw_cmd_filter_handle); + + INJECT_REG(PS3_ERR_IJ_ABORT_CMD_TIMEOUT, + ps3_scsi_task_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_RESET_CMD_TIMEOUT, + ps3_scsi_task_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_CMD_ERROR, ps3_scsi_task_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_RESET_CMD_ERROR, ps3_scsi_task_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_ABORT_CMD_NORMAL, ps3_scsi_task_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_RESET_CMD_NORMAL, ps3_scsi_task_cmd_filter_handle); + + INJECT_REG(PS3_ERR_IJ_SMP_CMD_TIMEOUT, ps3_mgr_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_SMP_CMD_ERROR, ps3_mgr_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, + ps3_mgr_cmd_filter_handle); + INJECT_REG(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, ps3_mgr_cmd_filter_handle); #endif INJECT_REG(PS3_ERR_IJ_ABORT_PRE_DEAL_FORCE_ABORTED_CMD_DONE, force_aborted_cmd_done) INJECT_REG(PS3_ERR_IJ_FORCE_STOP_ALL_CMD_DONE, force_stop_aborted_cmd_done) @@ -2858,8 +3253,8 @@ void inject_init(void) INJECT_REG(PS3_ERR_IJ_FORCE_PCIDRV_INIT_FAIL, force_ret_failed) INJECT_REG(PS3_ERR_IJ_FORCE_VERFILE_INIT_FAIL, force_ret_failed) INJECT_REG(PS3_ERR_IJ_FORCE_VERFILE2_INIT_FAIL, force_ret_failed) - INJECT_REG(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKOWN, set_cmd_io_rw_flag_unkown) - INJECT_REG(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKOWN, set_soft_zone_type_unkown) + INJECT_REG(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKNOWN, set_cmd_io_rw_flag_unknown) + INJECT_REG(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKNOWN, set_soft_zone_type_unknown) INJECT_REG(PS3_ERR_IJ_WATCHDOG_WAIT_RUNNING, wait_ioc_ready) INJECT_REG(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE, force_work_queue_unull) INJECT_REG(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, force_work_queue_failed) @@ -2960,8 +3355,8 @@ void inject_init(void) INJECT_REG(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, force_multi_hard_req) INJECT_REG(PS3_ERR_IJ_WAIT_HARDRESET, wait_hard_recovery_req) INJECT_REG(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, force_multi_hard_req_pending) - INJECT_REG(PS3_ERR_IJ_FORCE_DESTORY_RECOVERY, force_recovery_wq_null) - INJECT_REG(PS3_ERR_IJ_FORCE_START_DESTORY_RECOVERY, force_recovery_wq_null) + INJECT_REG(PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, force_recovery_wq_null) + INJECT_REG(PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, force_recovery_wq_null) INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, force_recovery_state_dead) INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, force_recovery_state_dead) INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, force_recovery_support_false) @@ -2988,7 +3383,7 @@ void inject_init(void) INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, force_ioc_not_running) INJECT_REG(PS3_ERR_IJ_WEB_SUBSCRIBE, force_web_subcribe) INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, force_instance_state_to_unnormal) - INJECT_REG(PS3_ERR_IJ_FORCE_HARD_INIT_RUNING_UNNORMAL, force_instance_probe_failed) + INJECT_REG(PS3_ERR_IJ_FORCE_HARD_INIT_RUNNING_UNNORMAL, force_instance_probe_failed) INJECT_REG(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, force_pcie_err) INJECT_REG(PS3_ERR_IJ_WAIT_PM_INSTANCE_NULL, force_instance_null) INJECT_REG(PS3_ERR_IJ_WAIT_SUSPEND_HALT_RESET, force_half_reset) @@ -3039,6 +3434,30 @@ void inject_init(void) INJECT_REG(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, force_change_sgl_addr_to_page_mode_5) INJECT_REG(PS3_ERR_IJ_SGL_ADDR_RESTORE, force_sgl_addr_restore) INJECT_REG(PS3_ERR_IJ_FORCE_WAIT, NULL) + INJECT_REG(PS3_ERR_IJ_RECOVERY_STATE_SHALLOW, force_recovery_state_shallow) + INJECT_REG(PS3_ERR_IJ_RECOVERY_HALT_BREAK, force_recovery_halt_break) + INJECT_REG(PS3_ERR_IJ_RECOVERY_HALT_BREAK_1, force_recovery_halt_break_1) + INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_DONE, force_recovery_doorbell_done) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_1, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_2, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_3, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_4, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_5, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_6, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_PCIE_ERR_7, force_instance_state_pci_err) + INJECT_REG(PS3_ERR_IJ_RECOVERY_KEY_STATE_CHECK, force_key_state_check_failed) + INJECT_REG(PS3_ERR_IJ_BIT_POS_READ_ERR, force_trigger_log_fail) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_CRITICAL, force_set_ioc_critical) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_FAULT, force_set_ioc_fault) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_COUNT_MAX, force_set_wait_count_max) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_READY, force_set_ioc_ready) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_WAIT, force_set_ioc_wait) + INJECT_REG(PS3_ERR_IJ_WAIT_RUNNING_RESP_ERR, force_set_resp_err) + INJECT_REG(PS3_ERR_IJ_OP_EVENT_SUB_FAILED, force_ret_fail) + INJECT_REG(PS3_ERR_IJ_OP_PENDING_SUB_FAILED, force_ret_fail) + INJECT_REG(PS3_ERR_IJ_OP_WEB_SUB_FAILED, force_ret_fail) + INJECT_REG(PS3_ERR_IJ_COMPLETE_FAULT, force_set_ioc_fault) INJECT_REG(PS3_ERR_IJ_PD_ATTR_WAIT_OS_SCAN, NULL) INJECT_REG(PS3_ERR_IJ_OS_SCAN, NULL) INJECT_REG(PS3_ERR_IJ_PD_ATTR_WAIT_PD_ATTR, NULL) @@ -3070,20 +3489,44 @@ void inject_init(void) INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK, force_return_true) INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, force_pcie_remove_break) INJECT_REG(PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, check_pcie_remove_state) + INJECT_REG(PS3_ERR_IJ_CHECK_SUSPEND, check_suspend) + INJECT_REG(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_START, force_doorbell_failed_start) + INJECT_REG(PS3_ERR_IJ_CMD_TIMEOUT_RECOVERY_CHECK, check_reserved01_to_unload) + INJECT_REG(PS3_ERR_IJ_HALF_RECOVERY_CHECK, check_half_recovery) + INJECT_REG(PS3_ERR_IJ_WITHOUT_DETAIL_BREAK_CHECK, check_reserved02) + INJECT_REG(PS3_ERR_IJ_DETAIL_BREAK_CHECK1, check_reserved03) + INJECT_REG(PS3_ERR_IJ_DETAIL_BREAK_CHECK2, check_reserved03) + INJECT_REG(PS3_ERR_IJ_DETAIL_BREAK_CHECK3, check_reserved03) + INJECT_REG(PS3_ERR_IJ_DETAIL_BREAK_CHECK4, check_reserved10) + INJECT_REG(PS3_ERR_IJ_EVENT_CMD_NULL_CHECK1, check_suspend_or_remove) + INJECT_REG(PS3_ERR_IJ_EVENT_CMD_NULL_CHECK2, check_suspend_or_remove) + INJECT_REG(PS3_ERR_IJ_CHECK_EVENT_CMD_NULL, check_event_null) + INJECT_REG(PS3_ERR_IJ_EVENT_WAIT_SUSPEND_END, wait_reserved03_end) + INJECT_REG(PS3_ERR_IJ_SUSPEND_END, check_reserved03) + INJECT_REG(PS3_ERR_IJ_REPLY_BLOCK, qos_waitq_notify_block) + INJECT_REG(PS3_ERR_IJ_QOS_PD_INIT_FAIL_5, create_pd_reply_info_fail) + INJECT_REG(PS3_ERR_IJ_QOS_PD_INIT_FAIL_6, create_pd_state_fail) + INJECT_REG(PS3_ERR_IJ_QOS_PD_INIT_FAIL_7, create_pd_id_fail) + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET, host_reset_wait_decide_normal) + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_1, host_reset_wait_decide_normal) + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_2, host_reset_wait_decide_normal) + INJECT_REG(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_3, host_reset_wait_decide_normal) + INJECT_REG(PS3_ERR_IJ_QOS_VD_IN_PD_Q_BLOCK, wait_cmd_send_block) + INJECT_REG(PS3_ERR_IJ_QOS_JBOD_IN_PD_Q_BLOCK, wait_cmd_send_block) LOG_INFO("inject_init success\n"); ps3_inject_init(); - return; } void inject_exit(void) { - U32 idx = 0; - for(idx = PS3_ERR_IJ_WATCHDOG_CONCURY ;idx < PS3_ERR_IJ_MAX_COUNT; idx++) - { - memset(&g_ps3_err_scene[idx - 1], 0, sizeof(Ps3Injection_t)); + unsigned int idx = 0; + + for (idx = PS3_ERR_IJ_WATCHDOG_CONCURY; idx < PS3_ERR_IJ_MAX_COUNT; + idx++) { + memset(&g_ps3_err_scene[idx - 1], 0, + sizeof(struct Ps3Injection)); } ps3_inject_exit(); is_inject_init = PS3_FALSE; } #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_err_inject.h b/drivers/scsi/linkdata/ps3stor/ps3_err_inject.h index b7ffdd5304d6..29a16452e824 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_err_inject.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_err_inject.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_ERR_INJECT_H_ #define _PS3_ERR_INJECT_H_ @@ -7,7 +8,7 @@ #include "ps3_platform_utils.h" #include "ps3_htp_def.h" -typedef enum { +enum InjectType { PS3_ERR_IJ_WATCHDOG_CONCURY = 1, PS3_ERR_IJ_STOP_DUMP_CONCURY = 2, PS3_ERR_IJ_SOFT_TO_HARD = 3, @@ -310,8 +311,8 @@ typedef enum { PS3_ERR_IJ_FORCE_VERFILE2_INIT_FAIL, PS3_ERR_IJ_FORCE_RECOVERY_INIT_FAIL, PS3_ERR_IJ_FORCE_RECOVERY_OPE_FAIL, - PS3_ERR_IJ_IO_RW_FLAG_SET_UNKOWN, - PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKOWN, + PS3_ERR_IJ_IO_RW_FLAG_SET_UNKNOWN, + PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKNOWN, PS3_ERR_IJ_WATCHDOG_WAIT_RUNNING, PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE, PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, @@ -411,8 +412,8 @@ typedef enum { PS3_ERR_IJ_FORCE_DUL_RECOVERY, PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, - PS3_ERR_IJ_FORCE_DESTORY_RECOVERY, - PS3_ERR_IJ_FORCE_START_DESTORY_RECOVERY, + PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, + PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, @@ -439,7 +440,7 @@ typedef enum { PS3_ERR_IJ_WAIT_RUNNING_FAIL, PS3_ERR_IJ_WEB_SUBSCRIBE, PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, - PS3_ERR_IJ_FORCE_HARD_INIT_RUNING_UNNORMAL, + PS3_ERR_IJ_FORCE_HARD_INIT_RUNNING_UNNORMAL, PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, PS3_ERR_IJ_WAIT_RUNNING_FAIL1, PS3_ERR_DUMP_ALLOC_FAILED, @@ -522,75 +523,131 @@ typedef enum { PS3_ERR_IJ_DETECTED_REMOVE_BREAK, PS3_ERR_IJ_DETECTED_REMOVE_BREAK_2, PS3_ERR_IJ_DETECTED_REMOVE_BREAK_3, + PS3_ERR_IJ_RECOVERY_STATE_SHALLOW, + PS3_ERR_IJ_RECOVERY_HALT_BREAK, + PS3_ERR_IJ_RECOVERY_HALT_BREAK_1, + PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_DONE, + PS3_ERR_IJ_RECOVERY_PCIE_ERR, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_1, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_2, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_3, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_4, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_5, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_6, + PS3_ERR_IJ_RECOVERY_PCIE_ERR_7, + PS3_ERR_IJ_RECOVERY_KEY_STATE_CHECK, + PS3_ERR_IJ_BIT_POS_READ_ERR, + PS3_ERR_IJ_WAIT_RUNNING_CRITICAL, + PS3_ERR_IJ_WAIT_RUNNING_FAULT, + PS3_ERR_IJ_WAIT_RUNNING_COUNT_MAX, + PS3_ERR_IJ_WAIT_RUNNING_READY, + PS3_ERR_IJ_WAIT_RUNNING_WAIT, + PS3_ERR_IJ_WAIT_RUNNING_RESP_ERR, + PS3_ERR_IJ_OP_EVENT_SUB_FAILED, + PS3_ERR_IJ_OP_PENDING_SUB_FAILED, + PS3_ERR_IJ_OP_WEB_SUB_FAILED, + PS3_ERR_IJ_COMPLETE_FAULT, + PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_START, + PS3_ERR_IJ_CHECK_SUSPEND, + PS3_ERR_IJ_CMD_TIMEOUT_RECOVERY_CHECK, + PS3_ERR_IJ_HALF_RECOVERY_CHECK, + PS3_ERR_IJ_WITHOUT_DETAIL_BREAK_CHECK, + PS3_ERR_IJ_DETAIL_BREAK_CHECK1, + PS3_ERR_IJ_DETAIL_BREAK_CHECK2, + PS3_ERR_IJ_DETAIL_BREAK_CHECK3, + PS3_ERR_IJ_CHECK_EVENT_CMD_NULL, + PS3_ERR_IJ_EVENT_CMD_NULL_CHECK1, + PS3_ERR_IJ_EVENT_CMD_NULL_CHECK2, + PS3_ERR_IJ_DETAIL_BREAK_CHECK4, + PS3_ERR_IJ_EVENT_WAIT_SUSPEND_END, + PS3_ERR_IJ_SUSPEND_END, + PS3_ERR_IJ_REPLY_BLOCK, + PS3_ERR_IJ_QOS_PD_INIT_FAIL_5, + PS3_ERR_IJ_QOS_PD_INIT_FAIL_6, + PS3_ERR_IJ_QOS_PD_INIT_FAIL_7, + PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET, + PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_1, + PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_2, + PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_3, + PS3_ERR_IJ_QOS_VD_IN_PD_Q_BLOCK, + PS3_ERR_IJ_QOS_JBOD_IN_PD_Q_BLOCK, PS3_ERR_IJ_MAX_COUNT, -}InjectType_E; +}; struct ps3_rec_work_context { struct delayed_work _work; struct workqueue_struct *_queue; struct ps3_instance *instance; - U32 state; + unsigned int state; }; #ifdef PS3_SUPPORT_INJECT #define PS3_ERR_SCENE_NUM (1000) -typedef S32 (*injectCallback)(void* userData, ...); +typedef int (*injectCallback)(void* userData, ...); typedef struct Ps3Injection { - InjectType_E type; + enum InjectType type; injectCallback callback; - Bool active; - U16 count; - U8 is_hit_pre:1; - U8 is_hit_post:1; - U8 reserved:6; + unsigned char active; + unsigned short count; + unsigned char is_hit_pre:1; + unsigned char is_hit_post:1; + unsigned char reserved:6; }Ps3Injection_t; -void inject_register(U16 err_type, injectCallback callback); -void inject_active_intf(U16 err_type, U16 count); -void inject_execute_callback(U16 err_type, void * data); -void inject_execute_callback_at_time(U16 err_type, void * data); -void inject_execute_callback_relevance_wait_pre(U16 err_type, U16 err_type_wait, void * data); -void inject_execute_callback_relevance_wait_post(U16 err_type, U16 err_type_wait, void * data); -void inject_execute_callback_at_time_relevance_wait_pre(U16 err_type, - U16 err_type_wait, void * data); -void inject_execute_callback_at_time_relevance_wait_post(U16 err_type, - U16 err_type_wait, void * data); +void inject_register(unsigned short err_type, int (*callback)(void *userData, ...)); +void inject_active_intf(unsigned short err_type, unsigned short count); +void inject_execute_callback(unsigned short err_type, void *data); +void inject_execute_callback_at_time(unsigned short err_type, void *data); +void inject_execute_callback_relevance_wait_pre(unsigned short err_type, + unsigned short err_type_wait, + void *data); +void inject_execute_callback_relevance_wait_post(unsigned short err_type, + unsigned short err_type_wait, + void *data); +void inject_execute_callback_at_time_relevance_wait_pre( + unsigned short err_type, unsigned short err_type_wait, void *data); +void inject_execute_callback_at_time_relevance_wait_post( + unsigned short err_type, unsigned short err_type_wait, void *data); -#define INJECT_REG(type, callback) inject_register(type, (injectCallback)callback); -#define INJECT_ACTIVE(type, count) inject_active_intf(type, count); -#define INJECT_START(type, data) inject_execute_callback(type, data); -#define INJECT_AT_TIMES(type, data) inject_execute_callback_at_time(type, data); -#define INJECT_START_WAIT_REV_PRE(type, type_wait, data) \ - inject_execute_callback_relevance_wait_pre(type, type_wait, data); -#define INJECT_START_WAIT_REV_POST(type, type_wait, data) \ - inject_execute_callback_relevance_wait_post(type, type_wait, data); -#define INJECT_START_AT_TIME_WAIT_REV_PRE(type, type_wait, data) \ - inject_execute_callback_at_time_relevance_wait_pre(type, type_wait, data); -#define INJECT_START_AT_TIME_WAIT_REV_POST(type, type_wait, data) \ - inject_execute_callback_at_time_relevance_wait_post(type, type_wait, data); +#define INJECT_REG(type, callback) \ + inject_register(type, (int (*)(void *userData, ...))callback); +#define INJECT_ACTIVE(type, count) inject_active_intf(type, count); +#define INJECT_START(type, data) inject_execute_callback(type, data); +#define INJECT_AT_TIMES(type, data) inject_execute_callback_at_time(type, data) +#define INJECT_START_WAIT_REV_PRE(type, type_wait, data); \ + inject_execute_callback_relevance_wait_pre(type, type_wait, data) +#define INJECT_START_WAIT_REV_POST(type, type_wait, data); \ + inject_execute_callback_relevance_wait_post(type, type_wait, data) +#define INJECT_START_AT_TIME_WAIT_REV_PRE(type, type_wait, data); \ + inject_execute_callback_at_time_relevance_wait_pre(type, type_wait, \ + data); +#define INJECT_START_AT_TIME_WAIT_REV_POST(type, type_wait, data) \ + inject_execute_callback_at_time_relevance_wait_post(type, type_wait, \ + data); #define PS3_IJ_SLEEP(ms, err_t) do {ps3_err_inject_sleep((ms), (err_t));} while(0) #define PS3_IJ_SLEEP_RAND(min, max, err_t) do {ps3_err_inject_sleep_rand((min), (max), (err_t));} while(0) -void ps3_err_inject_sleep(U32 ms, U16 err_type); +void ps3_err_inject_sleep(unsigned int ms, unsigned short err_type); -void ps3_err_inject_sleep_rand(U32 min, U32 max, U16 err_type); +void ps3_err_inject_sleep_rand(unsigned int min, unsigned int max, + unsigned short err_type); -void ps3_err_inject_err_type_valid(U16 err_type); +void ps3_err_inject_err_type_valid(unsigned short err_type); -void ps3_err_inject_err_type_clean(U16 err_type); +void ps3_err_inject_err_type_clean(unsigned short err_type); -Bool ps3_err_inject_err_type_get(U16 err_type); +unsigned char ps3_err_inject_err_type_get(unsigned short err_type); void active_err_inject(void); void ps3_wait_recovery_rand_finish(void); -void ps3_err_inject_wait_pre(U16 err_type_wait); -void ps3_err_inject_wait_post(U16 err_type_wait); +void ps3_err_inject_wait_pre(unsigned short err_type_wait); +void ps3_err_inject_wait_post(unsigned short err_type_wait); #define INJECT_PROBE_ACTIVE() active_err_inject(); void inject_init(void); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_event.c b/drivers/scsi/linkdata/ps3stor/ps3_event.c index 820f94ec5b75..e10b34feba8d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_event.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_event.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_event.h" #ifndef _WINDOWS #include @@ -20,7 +21,7 @@ #include "ps3_util.h" #include "ps3_cmd_statistics.h" #include "ps3_err_inject.h" -U16 ps3_event_code_pd_count[] = { +unsigned short ps3_event_code_pd_count[] = { PS3_EVT_CODE(MGR_EVT_DEVM_DISK_IN), PS3_EVT_CODE(MGR_EVT_DEVM_DISK_OUT), PS3_EVT_CODE(MGR_EVT_MULITPILE_PD_IN), @@ -36,7 +37,7 @@ U16 ps3_event_code_pd_count[] = { PS3_EVT_CODE(MGR_EVT_PD_PRE_READY) }; -U16 ps3_event_code_pd_attr[] = { +unsigned short ps3_event_code_pd_attr[] = { PS3_EVT_CODE(MGR_EVT_PD_INFO_CHANGE), PS3_EVT_CODE(MGR_EVT_PD_MARKED_READY), PS3_EVT_CODE(MGR_EVT_PD_MARKED_ONLINE), @@ -51,7 +52,7 @@ U16 ps3_event_code_pd_attr[] = { PS3_EVT_CODE(MGR_EVT_PD_MARKED_OFFLINE) }; -U16 ps3_event_code_vd_attr[] = { +unsigned short ps3_event_code_vd_attr[] = { PS3_EVT_CODE(MGR_EVT_VD_SETTINGS_CHANGE), PS3_EVT_CODE(MGR_EVT_VD_PD_CHANGE), PS3_EVT_CODE(MGR_EVT_VD_STATE_CHANGE), @@ -60,105 +61,110 @@ U16 ps3_event_code_vd_attr[] = { }; struct ps3_event_type_desc_map { - MgrEvtType_e event_type; - const char *event_type_desc; + enum MgrEvtType event_type; + const char *event_type_desc; }; static struct ps3_event_type_desc_map g_event_type_desc_table[] = { - {PS3_EVT_PD_COUNT, "PS3_EVT_PD_COUNT"}, - {PS3_EVT_VD_COUNT, "PS3_EVT_VD_COUNT"}, - {PS3_EVT_CTRL_INFO, "PS3_EVT_CTRL_INFO"}, - {PS3_EVT_PD_ATTR, "PS3_EVT_PD_ATTR"}, - {PS3_EVT_VD_ATTR, "PS3_EVT_VD_ATTRs"}, - {PS3_EVT_SAS_INFO, "PS3_EVT_SAS_INFO"}, - {PS3_EVT_DG_INFO, "MGR_EVT_DG_DELETED"}, + { PS3_EVT_PD_COUNT, "PS3_EVT_PD_COUNT" }, + { PS3_EVT_VD_COUNT, "PS3_EVT_VD_COUNT" }, + { PS3_EVT_CTRL_INFO, "PS3_EVT_CTRL_INFO" }, + { PS3_EVT_PD_ATTR, "PS3_EVT_PD_ATTR" }, + { PS3_EVT_VD_ATTR, "PS3_EVT_VD_ATTRs" }, + { PS3_EVT_SAS_INFO, "PS3_EVT_SAS_INFO" }, + { PS3_EVT_DG_INFO, "MGR_EVT_DG_DELETED" }, }; static struct fasync_struct *g_async_queue; -static void ps3_event_print_cmd(struct ps3_cmd *cmd, Bool is_send) +static void ps3_event_print_cmd(struct ps3_cmd *cmd, unsigned char is_send) { - LOG_INFO("trace_id[0x%llx], hno:%u event[%s] print cmd word type[%d]," - "direct[%d], qmask[0x%x], CFID[%d], isr_sn[%d], vid[%d], pid[%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), (is_send) ? "send" : "recv", - cmd->cmd_word.type, cmd->cmd_word.direct, - cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, - cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, - cmd->cmd_word.phyDiskID); + LOG_INFO( + "trace_id[0x%llx], hno:%u event[%s] print cmd word type[%d]\n" + "\tdirect[%d], qmask[0x%x], CFID[%d], isr_sn[%d], vid[%d], pid[%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + (is_send) ? "send" : "recv", cmd->cmd_word.type, + cmd->cmd_word.direct, cmd->cmd_word.qMask, + cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, + cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID); } -void ps3_vd_pending_filter_table_build(U8 *data) +void ps3_vd_pending_filter_table_build(unsigned char *data) { - PS3EventFilter_s *event_filter = (PS3EventFilter_s*)data; - memset(event_filter, 0, sizeof(PS3EventFilter_s)); + struct PS3EventFilter *event_filter = (struct PS3EventFilter *)data; + + memset(event_filter, 0, sizeof(struct PS3EventFilter)); event_filter->eventType = PS3_EVT_VD_ATTR_LOCAL; event_filter->eventCodeCnt = ARRAY_SIZE(ps3_event_code_vd_attr); - data += sizeof(PS3EventFilter_s); + data += sizeof(struct PS3EventFilter); memcpy(data, ps3_event_code_vd_attr, sizeof(ps3_event_code_vd_attr)); } -void ps3_event_filter_table_get_raid(U8 *data) +void ps3_event_filter_table_get_raid(unsigned char *data) { - PS3EventFilter_s event_filter; - memset(&event_filter, 0, sizeof(PS3EventFilter_s)); + struct PS3EventFilter event_filter; + + memset(&event_filter, 0, sizeof(struct PS3EventFilter)); event_filter.eventType = PS3_EVT_PD_COUNT_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_count); - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); memcpy(data, ps3_event_code_pd_count, sizeof(ps3_event_code_pd_count)); data += sizeof(ps3_event_code_pd_count); event_filter.eventType = PS3_EVT_VD_COUNT_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); event_filter.eventType = PS3_EVT_CTRL_INFO_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); event_filter.eventType = PS3_EVT_PD_ATTR_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_attr); - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); memcpy(data, ps3_event_code_pd_attr, sizeof(ps3_event_code_pd_attr)); data += sizeof(ps3_event_code_pd_attr); } -void ps3_event_filter_table_get_hba(U8 *data) +void ps3_event_filter_table_get_hba(unsigned char *data) { - PS3EventFilter_s event_filter; - memset(&event_filter, 0, sizeof(PS3EventFilter_s)); + struct PS3EventFilter event_filter; + + memset(&event_filter, 0, sizeof(struct PS3EventFilter)); event_filter.eventType = PS3_EVT_SAS_INFO_LOCAL; event_filter.eventCodeCnt = 0; - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); ps3_event_filter_table_get_raid(data); } -void ps3_event_filter_table_get_switch(U8 *data) +void ps3_event_filter_table_get_switch(unsigned char *data) { - PS3EventFilter_s event_filter; - memset(&event_filter, 0, sizeof(PS3EventFilter_s)); + struct PS3EventFilter event_filter; + + memset(&event_filter, 0, sizeof(struct PS3EventFilter)); event_filter.eventType = PS3_EVT_PD_COUNT_LOCAL; event_filter.eventCodeCnt = ARRAY_SIZE(ps3_event_code_pd_count); - memcpy(data, &event_filter, sizeof(PS3EventFilter_s)); - data += sizeof(PS3EventFilter_s); + memcpy(data, &event_filter, sizeof(struct PS3EventFilter)); + data += sizeof(struct PS3EventFilter); memcpy(data, ps3_event_code_pd_count, sizeof(ps3_event_code_pd_count)); data += sizeof(ps3_event_code_pd_count); } -static S32 ps3_event_type_proc(struct ps3_instance *instance, - MgrEvtType_e event_type) +static int ps3_event_type_proc(struct ps3_instance *instance, + enum MgrEvtType event_type) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; switch (event_type) { case PS3_EVT_PD_COUNT: @@ -171,8 +177,8 @@ static S32 ps3_event_type_proc(struct ps3_instance *instance, ret = ps3_ctrl_info_get(instance); break; default: - LOG_INFO("hno:%u Not cared event type %s\n", - PS3_HOST(instance), ps3_event_print(event_type)); + LOG_INFO("hno:%u Not cared event type %s\n", PS3_HOST(instance), + ps3_event_print(event_type)); break; } @@ -180,7 +186,7 @@ static S32 ps3_event_type_proc(struct ps3_instance *instance, } #ifndef _WINDOWS -S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay) +int ps3_event_delay_set(struct ps3_instance *instance, unsigned int delay) { struct ps3_event_context *event_ctx = NULL; struct ps3_event_delay_work *delay_work = NULL; @@ -199,15 +205,21 @@ S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay) #endif static void ps3_event_resubscribe(struct ps3_instance *instance, - struct ps3_cmd *cmd, U32 event_proc_result_bitmap) + struct ps3_cmd *cmd, + unsigned int event_proc_result_bitmap) { - ULong flags = 0; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + unsigned long flags = 0; + struct PS3MgrReqFrame *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; - INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, &instance->state_machine.is_load) - if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ(instance, + INJECT_START(PS3_ERR_IJ_INS_STATE_UNNORMAL, + &instance->state_machine.is_load); + + if (!instance->state_machine.is_load || + instance->is_suspend) { + INJECT_START(PS3_ERR_IJ_CHECK_SUSPEND, instance) + LOG_WARN_IN_IRQ( + instance, "hno:%u instance is suspend or instance unload!\n", PS3_HOST(instance)); return; @@ -216,24 +228,27 @@ static void ps3_event_resubscribe(struct ps3_instance *instance, mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u old event proc result bitmap: [0x%x], " - "current event proc result bitmap: [0x%x]\n", + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u old event proc result bitmap: [0x%x]\n" + "\tcurrent event proc result bitmap: [0x%x]\n", cmd->trace_id, PS3_HOST(instance), event_req_info->eventTypeMapProcResult, event_proc_result_bitmap); event_req_info->eventTypeMapProcResult = event_proc_result_bitmap; - LOG_INFO_IN_IRQ(instance, + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u subcribe event proc result bitmap: [0x%x]\n", cmd->trace_id, PS3_HOST(instance), event_req_info->eventTypeMapProcResult); if (instance->ioc_adpter->event_filter_table_get != NULL) { - instance->ioc_adpter->event_filter_table_get((U8*)cmd->ext_buf); + instance->ioc_adpter->event_filter_table_get( + (unsigned char *)cmd->ext_buf); } - wmb(); + wmb(); /* in order to force CPU ordering */ PS3_MGR_CMD_STAT_INC(instance, cmd); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); @@ -241,29 +256,33 @@ static void ps3_event_resubscribe(struct ps3_instance *instance, ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx],CFID[%d],hno:%u re send event cmd faild\n", - cmd->trace_id,cmd->index, PS3_HOST(cmd->instance)); + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx],CFID[%d],hno:%u re send event cmd failed\n", + cmd->trace_id, cmd->index, PS3_HOST(cmd->instance)); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - return; } -static U32 ps3_event_proc_without_details(struct ps3_instance *instance, - struct PS3EventInfo *event_info) +static unsigned int +ps3_event_proc_without_details(struct ps3_instance *instance, + struct PS3EventInfo *event_info) { - S32 ret = -PS3_FAILED; - U32 event_proc_result_bitmap = 0; - U32 mask_bit = 0X00000001; - U32 event_type = event_info->eventTypeMap & mask_bit; -#ifndef _WINDOWS + int ret = -PS3_FAILED; + unsigned int event_proc_result_bitmap = 0; + unsigned int mask_bit = 0X00000001; + unsigned int event_type = event_info->eventTypeMap & mask_bit; + +#ifndef _WINDOWS if (event_info->eventTypeMap & PS3_EVT_SAS_INFO) { ret = ps3_sas_expander_event_refresh(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u Event type PS3_EVT_SAS_INFO proc NOK!\n", + INJECT_START(PS3_ERR_IJ_DETAIL_BREAK_CHECK3, instance); + LOG_ERROR( + "hno:%u Event type PS3_EVT_SAS_INFO proc NOK!\n", PS3_HOST(instance)); event_proc_result_bitmap |= PS3_EVT_SAS_INFO; } @@ -272,12 +291,19 @@ static U32 ps3_event_proc_without_details(struct ps3_instance *instance, } #endif while (mask_bit != 0) { + if (!instance->state_machine.is_load) { + INJECT_START(PS3_ERR_IJ_DETAIL_BREAK_CHECK4, instance); + LOG_INFO("hno:%u instance unload, break\n", PS3_HOST(instance)); + break; + } if (event_type != 0) { - LOG_INFO("hno:%u Event type %s report without details!\n", - PS3_HOST(instance), ps3_event_print((MgrEvtType_e)event_type)); + LOG_INFO( + "hno:%u Event type %s report without details!\n", + PS3_HOST(instance), + ps3_event_print((enum MgrEvtType)event_type)); ret = ps3_event_type_proc(instance, - (MgrEvtType_e)event_type); + (enum MgrEvtType)event_type); } else { ret = PS3_SUCCESS; @@ -285,58 +311,60 @@ static U32 ps3_event_proc_without_details(struct ps3_instance *instance, if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u Event type %s proc NOK!\n", - PS3_HOST(instance), - ps3_event_print((MgrEvtType_e)event_type)); + PS3_HOST(instance), + ps3_event_print((enum MgrEvtType)event_type)); event_proc_result_bitmap |= event_type; } mask_bit = mask_bit << 1; event_type = event_info->eventTypeMap & mask_bit; } - return event_proc_result_bitmap; } static void ps3_event_details_pre_proc(struct ps3_instance *instance, - struct PS3EventInfo *event_info, struct ps3_cmd *cmd) + struct PS3EventInfo *event_info, + struct ps3_cmd *cmd) { - U32 idx = 0; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + unsigned int idx = 0; + struct PS3MgrReqFrame *mgr_req_frame = NULL; struct PS3MgrEvent *event_req_info = NULL; struct PS3EventDetail *event_detail = NULL; - mgr_req_frame = (PS3MgrReqFrame_s *)cmd->req_frame; + mgr_req_frame = (struct PS3MgrReqFrame *)cmd->req_frame; event_req_info = (struct PS3MgrEvent *)&mgr_req_frame->value.event; - for(idx = 0;idx < event_info->eventCount;idx++) { + for (idx = 0; idx < event_info->eventCount; idx++) { event_detail = &event_info->eventDetail[idx]; if (event_detail->eventType & - event_req_info->eventTypeMapProcResult) { - LOG_INFO("trace_id[0x%llx], hno:%u Event type %s code %s with " - "timestamp[%d] dev id[0x%x] magic %#x do not process in details!\n", - cmd->trace_id, PS3_HOST(instance), - ps3_event_print(event_detail->eventType), - mgrEvtCodeTrans(event_detail->eventCode), - event_detail->timestamp, - event_detail->devicePos.diskDev.diskID, - event_detail->devicePos.diskMagicNum); + event_req_info->eventTypeMapProcResult) { + LOG_INFO( + "trace_id[0x%llx], hno:%u Event type %s code %s with\n" + "\ttimestamp[%d] dev id[0x%x] magic %#x do not process in details!\n", + cmd->trace_id, PS3_HOST(instance), + ps3_event_print(event_detail->eventType), + mgrEvtCodeTrans(event_detail->eventCode), + event_detail->timestamp, + event_detail->devicePos.diskDev.diskID, + event_detail->devicePos.diskMagicNum); event_detail->eventType = PS3_EVT_ILLEGAL_TYPE; continue; } - if (event_detail->eventType == - PS3_EVT_CTRL_INFO) { + if (event_detail->eventType == PS3_EVT_CTRL_INFO) { event_detail->eventType = PS3_EVT_ILLEGAL_TYPE; continue; } event_info->eventTypeMap &= (~event_detail->eventType); - LOG_INFO("trace_id[0x%llx], hno:%u Event type %s code %s reports " - "in details with timestamp %d dev id 0x%x magic %#x!\n", + LOG_INFO( + "trace_id[0x%llx], hno:%u Event type %s code %s reports\n" + "\tin details with timestamp %d dev id 0x%x magic %#x!\n", cmd->trace_id, PS3_HOST(instance), ps3_event_print(event_detail->eventType), - mgrEvtCodeTrans(event_detail->eventCode), event_detail->timestamp, + mgrEvtCodeTrans(event_detail->eventCode), + event_detail->timestamp, event_detail->devicePos.diskDev.diskID, event_detail->devicePos.diskMagicNum); } @@ -344,36 +372,39 @@ static void ps3_event_details_pre_proc(struct ps3_instance *instance, event_info->eventTypeMap |= event_req_info->eventTypeMapProcResult; } -static U32 ps3_event_proc_with_details(struct ps3_instance *instance, - struct PS3EventInfo *event_info, struct ps3_cmd *cmd) +static unsigned int ps3_event_proc_with_details(struct ps3_instance *instance, + struct PS3EventInfo *event_info, + struct ps3_cmd *cmd) { - U32 event_proc_result_bitmap = 0; + unsigned int event_proc_result_bitmap = 0; ps3_event_details_pre_proc(instance, event_info, cmd); -#ifndef _WINDOWS - event_proc_result_bitmap |= ps3_sas_update_detail_proc(instance, - event_info->eventDetail, event_info->eventCount); +#ifndef _WINDOWS + event_proc_result_bitmap |= ps3_sas_update_detail_proc( + instance, event_info->eventDetail, event_info->eventCount); #endif - event_proc_result_bitmap = ps3_dev_update_detail_proc(instance, - event_info->eventDetail, event_info->eventCount); + + event_proc_result_bitmap = ps3_dev_update_detail_proc( + instance, event_info->eventDetail, event_info->eventCount); return event_proc_result_bitmap; } static void ps3_event_delay(struct ps3_instance *instance, - struct ps3_event_delay_work *delay_work) + struct ps3_event_delay_work *delay_work) { struct ps3_cmd *cmd = delay_work->cmd; - U32 event_delay = 0; + unsigned int event_delay = 0; event_delay = delay_work->event_delay; - LOG_WARN("trace_id[0x%llx], hno:%u Event handle will delay %d seconds\n", + LOG_WARN( + "trace_id[0x%llx], hno:%u Event handle will delay %d seconds\n", cmd->trace_id, PS3_HOST(instance), event_delay); while (event_delay > 0) { - if (kthread_should_stop() || - delay_work->event_delay == 0){ - LOG_WARN("trace_id[0x%llx], hno:%u Event handle delay cancel\n", + if (kthread_should_stop() || delay_work->event_delay == 0) { + LOG_WARN( + "trace_id[0x%llx], hno:%u Event handle delay cancel\n", cmd->trace_id, PS3_HOST(instance)); return; } @@ -382,53 +413,71 @@ static void ps3_event_delay(struct ps3_instance *instance, schedule_timeout(HZ); event_delay--; } - LOG_WARN("trace_id[0x%llx], hno:%u Event handle delay %d seconds timeout\n", + LOG_WARN( + "trace_id[0x%llx], hno:%u Event handle delay %d seconds timeout\n", cmd->trace_id, PS3_HOST(instance), delay_work->event_delay); } -void ps3_event_handle(struct ps3_event_delay_work* ps3_delay_work) +void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work) { struct ps3_cmd *cmd = ps3_delay_work->cmd; struct ps3_instance *instance = cmd->instance; - struct PS3EventInfo* event_info = instance->event_context.event_info; - U32 event_proc_result_bitmap = PS3_EVT_ILLEGAL_TYPE; - struct ps3_event_delay_work* ps3_new_delay_work = NULL; - ULong flags = 0; - S32 ret; + struct PS3EventInfo *event_info = instance->event_context.event_info; + unsigned int event_proc_result_bitmap = PS3_EVT_ILLEGAL_TYPE; + struct ps3_event_delay_work *ps3_new_delay_work = NULL; + unsigned long flags = 0; + int ret; INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL, instance); + INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL_CHECK1, instance) if (instance->event_context.event_cmd == NULL) { + if (ps3_atomic_read(&instance->event_context.subwork) != 0) + ps3_atomic_dec(&instance->event_context.subwork); LOG_WARN("trace_id[0x%llx], hno:%u Event is unsubscribed\n", - cmd->trace_id, PS3_HOST(instance)); + cmd->trace_id, PS3_HOST(instance)); return; } - if (!instance->state_machine.is_load) { - LOG_WARN("trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", + if (!instance->state_machine.is_load || instance->is_suspend) { + INJECT_START(PS3_ERR_IJ_CHECK_SUSPEND, instance) + if (ps3_atomic_read(&instance->event_context.subwork) != 0) + ps3_atomic_dec(&instance->event_context.subwork); + LOG_WARN( + "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); return; } LOG_INFO("trace_id[0x%llx], hno:%u event count[%d], bitmap[%08x]\n", - cmd->trace_id, PS3_HOST(instance), event_info->eventCount, - event_info->eventTypeMap); + cmd->trace_id, PS3_HOST(instance), event_info->eventCount, + event_info->eventTypeMap); - INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_FLAG, instance) - INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_SUBCRIBE, instance) + INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_FLAG, instance); + INJECT_START(PS3_ERR_IJ_EVENT_PROC_WAIT_HARD_SUBCRIBE, instance); #ifndef _WINDOWS - if (ps3_delay_work->event_delay) { + if (ps3_delay_work->event_delay) ps3_event_delay(instance, ps3_delay_work); - } #endif - INJECT_START(PS3_ERR_IJ_WAIT_NORMAL, instance) + INJECT_START(PS3_ERR_IJ_WAIT_NORMAL, instance); if (event_info->eventCount <= PS3_EVENT_DETAIL_BUF_MAX) { - LOG_INFO("trace_id[0x%llx], hno:%u Event has valid details info!\n", + LOG_INFO( + "trace_id[0x%llx], hno:%u Event has valid details info!\n", cmd->trace_id, PS3_HOST(instance)); event_proc_result_bitmap |= ps3_event_proc_with_details(instance, event_info, cmd); } + INJECT_START(PS3_ERR_IJ_EVENT_CMD_NULL_CHECK2, instance) + if (!instance->state_machine.is_load) { + INJECT_START(PS3_ERR_IJ_WITHOUT_DETAIL_BREAK_CHECK, instance) + if (ps3_atomic_read(&instance->event_context.subwork) != 0) + ps3_atomic_dec(&instance->event_context.subwork); + LOG_INFO("trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", + cmd->trace_id, PS3_HOST(instance)); + return; + } + if (event_info->eventTypeMap) { event_proc_result_bitmap |= ps3_event_proc_without_details(instance, event_info); @@ -439,77 +488,87 @@ void ps3_event_handle(struct ps3_event_delay_work* ps3_delay_work) ps3_event_print_cmd(cmd, PS3_TRUE); INJECT_START(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_FLAG, instance) INJECT_START(PS3_ERR_IJ_EVENT_SUBC_WAIT_HARD_SUBCRIBE, instance) - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - if (instance->event_context.abort_eventcmd == 0 && - instance->hardreset_event == 0) { + INJECT_START(PS3_ERR_IJ_EVENT_WAIT_SUSPEND_END, instance) + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) == 0 && + ps3_atomic_read(&instance->hardreset_event) == 0) { ps3_new_delay_work = - (ps3_delay_work == &instance->event_context.delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - 1])? - (&instance->event_context.delay_work_pool[0]):(ps3_delay_work + 1); + (ps3_delay_work == + &instance->event_context + .delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - + 1]) ? + (&instance->event_context.delay_work_pool[0]) : + (ps3_delay_work + 1); instance->event_context.delay_work = ps3_new_delay_work; ps3_event_resubscribe(instance, cmd, event_proc_result_bitmap); - if (instance->event_context.subwork != 0) { - instance->event_context.subwork -= 1; - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + if (ps3_atomic_read(&instance->event_context.subwork) != 0) + ps3_atomic_dec(&instance->event_context.subwork); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags); } else { - LOG_INFO_IN_IRQ(instance, + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u Event proc free cmd:%d, abort_eventcmd %d!\n", cmd->trace_id, PS3_HOST(instance), cmd->index, - instance->event_context.abort_eventcmd); + ps3_atomic_read(&instance->event_context.abort_eventcmd)); instance->event_context.event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); ps3_new_delay_work = - (ps3_delay_work == &instance->event_context.delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - 1])? - (&instance->event_context.delay_work_pool[0]):(ps3_delay_work + 1); + (ps3_delay_work == + &instance->event_context + .delay_work_pool[PS3_EVENT_WORKER_POOL_SIZE - + 1]) ? + (&instance->event_context.delay_work_pool[0]) : + (ps3_delay_work + 1); instance->event_context.delay_work = ps3_new_delay_work; - instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; + instance->event_req_info.eventTypeMapProcResult = + instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, "hno:%u event subscribe failed!\n", - PS3_HOST(instance)); + LOG_ERROR_IN_IRQ(instance, + "hno:%u event subscribe failed!\n", + PS3_HOST(instance)); } - if(instance->hardreset_event != 0) { - instance->hardreset_event = 0; - } + if (ps3_atomic_read(&instance->hardreset_event) != 0) + ps3_atomic_set(&instance->hardreset_event, 0); - if(instance->event_context.abort_eventcmd != 0) { - instance->event_context.abort_eventcmd = 0; - } - wmb(); - if (instance->event_context.subwork != 0) { - instance->event_context.subwork -= 1; - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + wmb(); /* in order to force CPU ordering */ + if (ps3_atomic_read(&instance->event_context.subwork) != 0) + ps3_atomic_dec(&instance->event_context.subwork); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags); } - - return; } #ifdef _WINDOWS static void ps3_event_polling(void *ins) { - struct ps3_instance *instance = (struct ps3_instance*)ins; + struct ps3_instance *instance = (struct ps3_instance *)ins; + ps3_event_handle(&instance->event_context.delay_work); } #else static void ps3_event_polling(struct work_struct *work) { - struct ps3_event_delay_work *delay_work = ps3_container_of(work, - struct ps3_event_delay_work, event_work.work); + struct ps3_event_delay_work *delay_work = ps3_container_of( + work, struct ps3_event_delay_work, event_work.work); ps3_event_handle(delay_work); } #endif -const char *ps3_event_print(MgrEvtType_e event_type) +const char *ps3_event_print(enum MgrEvtType event_type) { - U32 idx = 0; + unsigned int idx = 0; const char *ps3_event_type_name = NULL; - for (idx = 0;idx < ARRAY_SIZE(g_event_type_desc_table);idx++) { + for (idx = 0; idx < ARRAY_SIZE(g_event_type_desc_table); idx++) { if (g_event_type_desc_table[idx].event_type == event_type) { - ps3_event_type_name - = g_event_type_desc_table[idx].event_type_desc; + ps3_event_type_name = + g_event_type_desc_table[idx].event_type_desc; break; } } @@ -517,44 +576,46 @@ const char *ps3_event_print(MgrEvtType_e event_type) return ps3_event_type_name; } -S32 ps3_event_context_init(struct ps3_instance *instance) +int ps3_event_context_init(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - U32 idx = 0; + int ret = -PS3_FAILED; + unsigned int idx = 0; struct ps3_event_context *event_ctx = &instance->event_context; struct ps3_event_delay_work *delay_work = NULL; struct ps3_event_delay_work *delay_work_pool = NULL; + memset(event_ctx, 0, sizeof(*event_ctx)); #ifndef _WINDOWS - delay_work_pool = (struct ps3_event_delay_work *)ps3_kzalloc(instance, - sizeof(struct ps3_event_delay_work) * PS3_EVENT_WORKER_POOL_SIZE); + delay_work_pool = (struct ps3_event_delay_work *)ps3_kzalloc( + instance, sizeof(struct ps3_event_delay_work) * + PS3_EVENT_WORKER_POOL_SIZE); INJECT_START(PS3_ERR_IJ_PS3_DELAY_WORK_POOL_ALLOC, &delay_work_pool); if (delay_work_pool == NULL) { LOG_ERROR("hno:%u delay work kzalloc failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } event_ctx->delay_work_pool = delay_work_pool; - for(idx = 0; idx < PS3_EVENT_WORKER_POOL_SIZE; idx++){ - delay_work = &delay_work_pool[idx]; - INIT_DELAYED_WORK(&delay_work->event_work, ps3_event_polling); + for (idx = 0; idx < PS3_EVENT_WORKER_POOL_SIZE; idx++) { + delay_work = &delay_work_pool[idx]; + INIT_DELAYED_WORK(&delay_work->event_work, ps3_event_polling); } event_ctx->delay_work = &delay_work_pool[0]; event_ctx->event_cmd = NULL; event_ctx->event_abort_cmd = NULL; - event_ctx->abort_eventcmd = 0; + ps3_atomic_set(&event_ctx->abort_eventcmd, 0); event_ctx->flag = PS3_FALSE; #else delay_work = &event_ctx->delay_work; - if (ps3_worker_init(instance, &delay_work->event_work, "ps3_event_wk", ps3_event_polling) != PS3_SUCCESS) { - LOG_ERROR("hno:%u worker init failed\n", - PS3_HOST(instance)); + if (ps3_worker_init(instance, &delay_work->event_work, "ps3_event_wk", + ps3_event_polling) != PS3_SUCCESS) { + LOG_ERROR("hno:%u worker init failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } #endif - event_ctx->subwork = 0; + ps3_atomic_set(&event_ctx->subwork, 0); ret = PS3_SUCCESS; l_out: @@ -565,7 +626,7 @@ void ps3_event_context_exit(struct ps3_instance *instance) { struct ps3_event_context *event_ctx = &instance->event_context; #ifdef _WINDOWS - struct ps3_event_delay_work* delay_work = NULL; + struct ps3_event_delay_work *delay_work = NULL; delay_work = &event_ctx->delay_work; ps3_worker_exit(&delay_work->event_work); @@ -573,58 +634,65 @@ void ps3_event_context_exit(struct ps3_instance *instance) if (event_ctx->delay_work_pool != NULL) { ps3_kfree(instance, event_ctx->delay_work_pool); event_ctx->delay_work_pool = NULL; - event_ctx->delay_work = NULL; + event_ctx->delay_work = NULL; } #endif memset(event_ctx, 0, sizeof(*event_ctx)); } -S32 ps3_event_subscribe(struct ps3_instance *instance) +int ps3_event_subscribe(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_event_context *event_ctx = &instance->event_context; struct PS3MgrEvent *event_req_info = &instance->event_req_info; if (!instance->is_need_event) { LOG_WARN_IN_IRQ(instance, "hno:%u IOC no need event!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } if (event_ctx->event_cmd != NULL) { LOG_ERROR_IN_IRQ(instance, "hno:%u Event already subscribe!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } - if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ(instance, "hno:%u instance is suspend or instance unload!\n", + if (!instance->state_machine.is_load || + instance->is_suspend) { + INJECT_START(PS3_ERR_IJ_CHECK_SUSPEND, instance) + LOG_WARN_IN_IRQ( + instance, + "hno:%u instance is suspend or instance unload!\n", PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ret = ps3_event_register(instance, event_req_info); - INJECT_START(PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, &ret) + INJECT_START(PS3_ERR_IJ_WAIT_RESUME_EVENT_FAILED, &ret); if (ret != PS3_SUCCESS) { - LOG_WARN_IN_IRQ(instance, "hno:%u Failed to register event cmd, ret: %d\n", + LOG_WARN_IN_IRQ( + instance, + "hno:%u Failed to register event cmd, ret: %d\n", PS3_HOST(instance), ret); goto l_out; } - LOG_INFO_IN_IRQ(instance, "hno:%u Success to subscribe event, bitmap[%08x]!\n", - PS3_HOST(instance), event_req_info->eventTypeMap); + LOG_INFO_IN_IRQ(instance, + "hno:%u Success to subscribe event, bitmap[%08x]!\n", + PS3_HOST(instance), event_req_info->eventTypeMap); l_out: return ret; } -S32 ps3_event_unsubscribe(struct ps3_instance *instance) +int ps3_event_unsubscribe(struct ps3_instance *instance) { - ULong flags = 0; - ULong flags1 = 0; - S32 ret = -PS3_FAILED; + unsigned long flags = 0; + unsigned long flags1 = 0; + int ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_event_context *event_ctx = &instance->event_context; @@ -634,163 +702,193 @@ S32 ps3_event_unsubscribe(struct ps3_instance *instance) goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(event_ctx->flag){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (event_ctx->flag) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); goto l_out; } event_ctx->flag = PS3_TRUE; cmd = event_ctx->event_cmd; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); if (cmd == NULL) { LOG_WARN("hno:%u Event is not register yet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - INJECT_START(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, instance) + INJECT_START(PS3_ERR_IJ_SUBC_EVENT_CMD_INIT, instance); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", - PS3_HOST(instance), cmd->index); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), + cmd->index); + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); event_ctx->event_cmd = NULL; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); ret = PS3_SUCCESS; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_EVENT_CMD); - INJECT_START(PS3_ERR_IJ_CANCEL_EVENT_CMD_FAIL, &ret) - if(ret == -PS3_ENOMEM){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, + PS3_CANCEL_EVENT_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_EVENT_CMD_FAIL, &ret); + if (ret == -PS3_ENOMEM) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); ret = PS3_FAILED; goto l_out; - }else if(ret != PS3_SUCCESS){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + } else if (ret != PS3_SUCCESS) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->event_context.event_abort_cmd), cmd->index); + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->event_context.event_abort_cmd), + cmd->index); abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } ret = PS3_FAILED; goto l_out; } - instance->event_context.abort_eventcmd = 1; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->event_context.abort_eventcmd, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_EVENT_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(instance->event_context.subwork == 0){ - if(instance->event_context.abort_eventcmd != 0){ - instance->event_context.abort_eventcmd = 0; + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (ps3_atomic_read(&instance->event_context.subwork) == 0) { + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) { + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); LOG_FILE_INFO("hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); event_ctx->event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); l_out: - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); event_ctx->flag = PS3_FALSE; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); return ret; } -S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) +int ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) { - ULong flags = 0; - ULong flags1 = 0; - S32 ret = -PS3_FAILED; + unsigned long flags = 0; + unsigned long flags1 = 0; + int ret = -PS3_FAILED; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_event_context *event_ctx = &instance->event_context; - Bool is_need_resend = PS3_FALSE; + unsigned char is_need_resend = PS3_FALSE; if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { ret = -PS3_FAILED; goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(event_ctx->flag){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (event_ctx->flag) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); goto l_out; } event_ctx->flag = PS3_TRUE; cmd = event_ctx->event_cmd; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); if (cmd == NULL) { LOG_WARN("hno:%u Event is not register yet\n", - PS3_HOST(instance)); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + PS3_HOST(instance)); + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); is_need_resend = PS3_TRUE; goto l_resend; } ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - INJECT_START(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT, instance) + INJECT_START(PS3_ERR_IJ_RESUBC_EVENT_CMD_INIT, instance); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", - PS3_HOST(instance), cmd->index); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), + cmd->index); + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); event_ctx->event_cmd = NULL; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); ret = PS3_SUCCESS; goto l_out; } else { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_EVENT_CMD); - if (ret == -PS3_ENOMEM){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, + PS3_CANCEL_EVENT_CMD); + if (ret == -PS3_ENOMEM) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); ret = PS3_FAILED; goto l_out; - } else if (ret != PS3_SUCCESS){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + } else if (ret != PS3_SUCCESS) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->event_context.event_abort_cmd), cmd->index); + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->event_context.event_abort_cmd), + cmd->index); abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } ret = PS3_FAILED; goto l_out; } - instance->event_context.abort_eventcmd = 1; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_atomic_set(&instance->event_context.abort_eventcmd, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_EVENT_CMD); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event cancel cmd failed, ret:%d\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if(instance->event_context.subwork == 0){ - if(instance->event_context.abort_eventcmd != 0){ - instance->event_context.abort_eventcmd = 0; + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (ps3_atomic_read(&instance->event_context.subwork) == 0) { + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) { + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); LOG_FILE_INFO("hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); event_ctx->event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); @@ -805,24 +903,27 @@ S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance) ret = ps3_event_subscribe(instance); if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { LOG_FILE_ERROR("hno:%u event subscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FAILED; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); l_out: - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); event_ctx->flag = PS3_FALSE; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); return ret; } -S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) +int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags) { - ULong flags = 0; - ULong flags1 = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + unsigned long flags1 = 0; + int ret = PS3_SUCCESS; struct ps3_instance *instance = cmd->instance; struct ps3_event_context *event_ctx = &instance->event_context; #ifdef _WINDOWS @@ -830,31 +931,38 @@ S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) #else struct ps3_event_delay_work *delay_work = event_ctx->delay_work; #endif - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int cur_state = PS3_INSTANCE_STATE_INIT; PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); ps3_event_print_cmd(cmd, PS3_FALSE); if (reply_flags != PS3_REPLY_WORD_FLAG_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u Event notify fetal error!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); if (event_ctx->event_cmd == NULL) { - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u Event is unsubscribed!\n", + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u Event is unsubscribed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); - if (!instance->state_machine.is_load) { - LOG_INFO_IN_IRQ(instance, + if (!instance->state_machine.is_load || + instance->is_suspend) { + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -862,8 +970,9 @@ S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) } cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ(instance, + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u instance is not operational!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; @@ -873,17 +982,19 @@ S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) delay_work->cmd = cmd; #ifdef _WINDOWS if (ps3_worker_start(&delay_work->event_work) != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, + LOG_ERROR_IN_IRQ( + instance, "trace_id[0x%llx], hno:%u Event start worker failed!\n", cmd->trace_id, PS3_HOST(instance)); ret = -PS3_FAILED; goto l_failed; } - instance->event_context.subwork += 1; + ps3_atomic_inc(&instance->event_context.subwork); #else INJECT_START(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_FLAG, instance) INJECT_START(PS3_ERR_IJ_EVENT_INT_WAIT_HARD_SUBCRIBE, instance) - instance->event_context.subwork += 1; + INJECT_START(PS3_ERR_IJ_CHECK_EVENT_CMD_NULL, instance) + ps3_atomic_inc(&instance->event_context.subwork); schedule_delayed_work(&delay_work->event_work, 0); #endif goto l_out; @@ -892,366 +1003,396 @@ S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags) ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - LOG_INFO_IN_IRQ(instance, - "instance->event_context.subwork[%u]!\n", - instance->event_context.subwork); + LOG_INFO_IN_IRQ(instance, "instance->event_context.subwork[%u]!\n", + ps3_atomic_read(&instance->event_context.subwork)); return ret; } -S32 ps3_fasync(int fd, struct file *filp, int mode) +int ps3_fasync(int fd, struct file *filp, int mode) { - return fasync_helper(fd, filp, mode, &g_async_queue); + return fasync_helper(fd, filp, mode, &g_async_queue); } -S32 ps3_webSubscribe_context_init(struct ps3_instance *instance) +int ps3_webSubscribe_context_init(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; - memset(web_context, 0, sizeof(*web_context)); - web_context->webSubscribe_cmd = NULL; - web_context->web_abort_cmd = NULL; - ps3_atomic_set(&web_context->subscribe_count, PS3_WEB_FLAG_INIT_VALUE); - ps3_atomic_set(&web_context->is_subscribe, PS3_WEB_FLAG_INIT_VALUE); - ps3_atomic_set(&web_context->is_abort, PS3_WEB_FLAG_INIT_VALUE); - web_context->abort_webcmd = PS3_WEB_FLAG_INIT_VALUE; - ret = PS3_SUCCESS; - return ret; + int ret = -PS3_FAILED; + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; + + memset(web_context, 0, sizeof(*web_context)); + web_context->webSubscribe_cmd = NULL; + web_context->web_abort_cmd = NULL; + ps3_atomic_set(&web_context->subscribe_count, PS3_WEB_FLAG_INIT_VALUE); + ps3_atomic_set(&web_context->is_subscribe, PS3_WEB_FLAG_INIT_VALUE); + ps3_atomic_set(&web_context->is_abort, PS3_WEB_FLAG_INIT_VALUE); + ps3_atomic_set(&web_context->abort_webcmd, PS3_WEB_FLAG_INIT_VALUE); + ret = PS3_SUCCESS; + return ret; } void ps3_webSubscribe_context_exit(struct ps3_instance *instance) { - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; - memset(web_context, 0, sizeof(*web_context)); + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; + + memset(web_context, 0, sizeof(*web_context)); } -static void ps3_web_resubscribe(struct ps3_instance *instance, struct ps3_cmd *cmd) +static void ps3_web_resubscribe(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - ULong flags = 0; - PS3_MGR_CMD_STAT_INC(instance, cmd); - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - - if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", - cmd->trace_id,cmd->index, PS3_HOST(cmd->instance)); - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - return; + unsigned long flags = 0; + + PS3_MGR_CMD_STAT_INC(instance, cmd); + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_PROCESS; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + + if (ps3_async_cmd_send(cmd->instance, cmd) != PS3_SUCCESS) { + LOG_ERROR_IN_IRQ( + instance, + "trace_id[0x%llx],CFID[%d],hno:%u resend web cmd NOK\n", + cmd->trace_id, cmd->index, PS3_HOST(cmd->instance)); + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } } -S32 ps3_webSubscribe_service(struct ps3_cmd *cmd, U16 reply_flags) +int ps3_webSubscribe_service(struct ps3_cmd *cmd, unsigned short reply_flags) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; - struct ps3_instance *instance = cmd->instance; - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; - - S32 cur_state = PS3_INSTANCE_STATE_INIT; - - PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); - ps3_event_print_cmd(cmd, PS3_FALSE); - - if (reply_flags == PS3_REPLY_WORD_FLAG_FAIL) { - LOG_ERROR_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u Web notify fetal error!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - if (web_context->webSubscribe_cmd == NULL) { - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u Web is unsubscribed!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_out; - } - - if (!instance->state_machine.is_load) { - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u instance is not operational!\n", - cmd->trace_id, PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_failed; - } - - kill_fasync(&g_async_queue, PS3_EVENT_NOTICE_SIG, POLL_IN); - - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - if (instance->webSubscribe_context.abort_webcmd == 0) { - ps3_web_resubscribe(instance, cmd); - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); - } else { - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx], hno:%u Web proc free cmd:%d, abort_webcmd %d!\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, - instance->webSubscribe_context.abort_webcmd); - - instance->webSubscribe_context.webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS) { - LOG_ERROR_IN_IRQ(instance, - "hno:%u web subscribe failed!\n", - PS3_HOST(instance)); - } - instance->webSubscribe_context.abort_webcmd = 0; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); - } - goto l_out; + unsigned long flags = 0; + int ret = PS3_SUCCESS; + struct ps3_instance *instance = cmd->instance; + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; + + int cur_state = PS3_INSTANCE_STATE_INIT; + + PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); + ps3_event_print_cmd(cmd, PS3_FALSE); + + if (reply_flags == PS3_REPLY_WORD_FLAG_FAIL) { + LOG_ERROR_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u Web notify fetal error!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + if (web_context->webSubscribe_cmd == NULL) { + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u Web is unsubscribed!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } + + if (!instance->state_machine.is_load || + instance->is_suspend) { + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u instance is suspend or instance unload!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u instance is not operational!\n", + cmd->trace_id, PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_failed; + } + + kill_fasync(&g_async_queue, PS3_EVENT_NOTICE_SIG, POLL_IN); + + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); + if (ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) == 0) { + ps3_web_resubscribe(instance, cmd); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags); + } else { + LOG_INFO_IN_IRQ( + instance, + "trace_id[0x%llx], hno:%u Web proc free cmd:%d, abort_webcmd %d!\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd)); + + instance->webSubscribe_context.webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR_IN_IRQ(instance, + "hno:%u web subscribe failed!\n", + PS3_HOST(instance)); + } + ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags); + } + goto l_out; l_failed: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_IN_IRQ(instance, - "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", - cmd->trace_id, cmd->index, PS3_HOST(instance)); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_INFO_IN_IRQ(instance, "trace_id[0x%llx],CFID[%d], hno:%u failed!\n", + cmd->trace_id, cmd->index, PS3_HOST(instance)); l_out: - return ret; + return ret; } -S32 ps3_web_subscribe(struct ps3_instance *instance) +int ps3_web_subscribe(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (!instance->is_need_event) { LOG_WARN_IN_IRQ(instance, "hno:%u ioc no need web server!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - ret = ps3_web_register(instance); - if (ret != PS3_SUCCESS) { - LOG_WARN_IN_IRQ(instance, "hno:%u Failed to register web cmd, ret: %d\n", - PS3_HOST(instance), ret); - goto l_out; - } + ret = ps3_web_register(instance); + if (ret != PS3_SUCCESS) { + LOG_WARN_IN_IRQ(instance, + "hno:%u Failed to register web cmd, ret: %d\n", + PS3_HOST(instance), ret); + goto l_out; + } LOG_INFO_IN_IRQ(instance, "hno:%u Success to subscribe web event\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: - return ret; + return ret; } -S32 ps3_web_unsubscribe(struct ps3_instance *instance) +int ps3_web_unsubscribe(struct ps3_instance *instance) { - ULong flags = 0; - S32 ret = -PS3_FAILED; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *abort_cmd = NULL; - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; - - if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { - ret = -PS3_FAILED; - goto l_out; - } - cmd = web_context->webSubscribe_cmd; - if (cmd == NULL) { - LOG_WARN("hno:%u web event is not register yet\n", - PS3_HOST(instance)); - ret = PS3_SUCCESS; - goto l_out; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", - PS3_HOST(instance), cmd->index); - web_context->webSubscribe_cmd = NULL; - ret = PS3_SUCCESS; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); - INJECT_START(PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, &ret) - if(ret == -PS3_ENOMEM){ - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } else if(ret != PS3_SUCCESS) { - LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->webSubscribe_context.web_abort_cmd), cmd->index); - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) { - ps3_task_cmd_free(instance, abort_cmd); - } - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, &ret) - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", - PS3_HOST(instance), ret); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - LOG_INFO("hno:%u web cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); - web_context->webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + unsigned long flags = 0; + int ret = -PS3_FAILED; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *abort_cmd = NULL; + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; + + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { + ret = -PS3_FAILED; + goto l_out; + } + cmd = web_context->webSubscribe_cmd; + if (cmd == NULL) { + LOG_WARN("hno:%u web event is not register yet\n", + PS3_HOST(instance)); + ret = PS3_SUCCESS; + goto l_out; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), + cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, + 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); + INJECT_START(PS3_ERR_IJ_CANCEL_WEB_CMD_ALLOC_NULL, &ret); + if (ret == -PS3_ENOMEM) { + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } else if (ret != PS3_SUCCESS) { + LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->webSubscribe_context.web_abort_cmd), + cmd->index); + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) + ps3_task_cmd_free(instance, abort_cmd); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WEB_UNSUB_FAILED_1, &ret); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u event cancel cmd NOK, ret:%d\n", + PS3_HOST(instance), ret); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + LOG_INFO("hno:%u web cmd free, CFID:%d\n", PS3_HOST(instance), + cmd->index); + web_context->webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); l_out: - return ret; + return ret; } -S32 ps3_soft_reset_web_resubscribe(struct ps3_instance *instance) +int ps3_soft_reset_web_resubscribe(struct ps3_instance *instance) { - ULong flags = 0; - ULong flags1 = 0; - S32 ret = -PS3_FAILED; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *abort_cmd = NULL; - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; - Bool is_need_resend = PS3_FALSE; - - if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { - ret = -PS3_FAILED; - goto l_out; - } - - cmd = web_context->webSubscribe_cmd; - if (cmd == NULL) { - LOG_WARN("hno:%u Web is not register yet\n", - PS3_HOST(instance)); - is_need_resend = PS3_TRUE; - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - goto l_resend; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u had been free,CFID:%d\n", - PS3_HOST(instance), cmd->index); - web_context->webSubscribe_cmd = NULL; - ret = PS3_SUCCESS; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, 1) == 0) { - ret = PS3_SUCCESS; - goto l_out; - } - - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); - if (ret == -PS3_ENOMEM){ - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u alloc failed\n",PS3_HOST(instance)); - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } else if (ret != PS3_SUCCESS) { - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", - PS3_HOST(instance), ps3_cmd_frame_id(instance->webSubscribe_context.web_abort_cmd), cmd->index); - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) { - ps3_task_cmd_free(instance, abort_cmd); - } - ret = -PS3_FAILED; - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - instance->webSubscribe_context.abort_webcmd = 1; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); - - ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u web cancel cmd failed, ret:%d\n", - PS3_HOST(instance), ret); - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); - goto l_out; - } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags1); - if (instance->webSubscribe_context.abort_webcmd != 0){ - instance->webSubscribe_context.abort_webcmd = 0; - LOG_FILE_INFO("hno:%u web cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); - web_context->webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); - is_need_resend = PS3_TRUE; - } - ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + unsigned long flags = 0; + unsigned long flags1 = 0; + int ret = -PS3_FAILED; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *abort_cmd = NULL; + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; + unsigned char is_need_resend = PS3_FALSE; + + if (!ps3_check_ioc_state_is_normal_in_unload(instance)) { + ret = -PS3_FAILED; + goto l_out; + } + + cmd = web_context->webSubscribe_cmd; + if (cmd == NULL) { + LOG_WARN("hno:%u Web is not register yet\n", + PS3_HOST(instance)); + is_need_resend = PS3_TRUE; + ps3_spin_lock_irqsave( + &instance->recovery_context->recovery_lock, &flags1); + goto l_resend; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u had been free,CFID:%d\n", PS3_HOST(instance), + cmd->index); + web_context->webSubscribe_cmd = NULL; + ret = PS3_SUCCESS; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + if (ps3_atomic_add_unless(&instance->webSubscribe_context.is_abort, 1, + 1) == 0) { + ret = PS3_SUCCESS; + goto l_out; + } + + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + ret = ps3_mgr_cmd_cancel_send(instance, cmd->index, PS3_CANCEL_WEB_CMD); + if (ret == -PS3_ENOMEM) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u alloc failed\n", PS3_HOST(instance)); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } else if (ret != PS3_SUCCESS) { + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, flags1); + LOG_INFO("hno:%u reqFrameId=%d cancel_cmd_frame_id[%u] free!\n", + PS3_HOST(instance), + ps3_cmd_frame_id( + instance->webSubscribe_context.web_abort_cmd), + cmd->index); + abort_cmd = instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) + ps3_task_cmd_free(instance, abort_cmd); + ret = -PS3_FAILED; + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); + + ret = ps3_mgr_cmd_cancel_wait(instance, PS3_CANCEL_WEB_CMD); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u web cancel cmd failed, ret:%d\n", + PS3_HOST(instance), ret); + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); + goto l_out; + } + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags1); + if (ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) != 0) { + ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); + LOG_FILE_INFO("hno:%u web cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); + web_context->webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); + is_need_resend = PS3_TRUE; + } + ps3_atomic_set(&instance->webSubscribe_context.is_abort, 0); l_resend: - if (is_need_resend) { - ret = ps3_web_subscribe(instance); - if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { - LOG_FILE_ERROR("hno:%u web subscribe failed!\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; - } - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags1); + if (is_need_resend) { + ret = ps3_web_subscribe(instance); + if ((ret != PS3_SUCCESS) && (ret != -PS3_IN_UNLOAD)) { + LOG_FILE_ERROR("hno:%u web subscribe failed!\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + } + } + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags1); l_out: - return ret; + return ret; } void ps3_web_cmd_clear(struct ps3_instance *instance) { - ULong flags = 0; - struct ps3_cmd *cmd = NULL; - instance->webSubscribe_context.abort_webcmd = 0; - - cmd = instance->webSubscribe_context.webSubscribe_cmd; - - if (cmd == NULL) { - LOG_WARN("hno:%u web cmd has been cancel\n", - PS3_HOST(instance)); - goto l_out; - } - - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("hno:%u free this cmd,CFID:%d\n", - PS3_HOST(instance), cmd->index); - instance->webSubscribe_context.webSubscribe_cmd = NULL; - goto l_out; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - } - - LOG_INFO("hno:%u web cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); - instance->webSubscribe_context.webSubscribe_cmd = NULL; - ps3_mgr_cmd_free(instance, cmd); + unsigned long flags = 0; + struct ps3_cmd *cmd = NULL; + + ps3_atomic_set(&instance->webSubscribe_context.abort_webcmd, 0); + cmd = instance->webSubscribe_context.webSubscribe_cmd; + + if (cmd == NULL) { + LOG_WARN("hno:%u web cmd has been cancel\n", + PS3_HOST(instance)); + goto l_out; + } + + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + LOG_WARN("hno:%u free this cmd,CFID:%d\n", PS3_HOST(instance), + cmd->index); + instance->webSubscribe_context.webSubscribe_cmd = NULL; + goto l_out; + } else { + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + } + + LOG_INFO("hno:%u web cmd free, CFID:%d\n", PS3_HOST(instance), + cmd->index); + instance->webSubscribe_context.webSubscribe_cmd = NULL; + ps3_mgr_cmd_free(instance, cmd); l_out: - return; + return; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_event.h b/drivers/scsi/linkdata/ps3stor/ps3_event.h index a3c7ef2069ad..23d4627a7fd0 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_event.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_event.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_EVENT_H_ #define _PS3_EVENT_H_ @@ -6,32 +6,32 @@ #define PS3_EVENT_WORKER_POOL_SIZE (3) #define PS3_WEB_FLAG_INIT_VALUE (0) -S32 ps3_event_context_init(struct ps3_instance *instance); +int ps3_event_context_init(struct ps3_instance *instance); void ps3_event_context_exit(struct ps3_instance *instance); -const char *ps3_event_print(MgrEvtType_e event_type); -S32 ps3_event_subscribe(struct ps3_instance *instance); -S32 ps3_event_unsubscribe(struct ps3_instance *instance); -S32 ps3_soft_reset_event_resubscribe(struct ps3_instance *instance); -void ps3_event_handle(struct ps3_event_delay_work* ps3_delay_work); +const char *ps3_event_print(enum MgrEvtType event_type); +int ps3_event_subscribe(struct ps3_instance *instance); +int ps3_event_unsubscribe(struct ps3_instance *instance); +int ps3_soft_reset_event_resubscribe(struct ps3_instance *instance); +void ps3_event_handle(struct ps3_event_delay_work *ps3_delay_work); -S32 ps3_event_service(struct ps3_cmd *cmd, U16 reply_flags); -S32 ps3_event_delay_set(struct ps3_instance *instance, U32 delay); +int ps3_event_service(struct ps3_cmd *cmd, unsigned short reply_flags); +int ps3_event_delay_set(struct ps3_instance *instance, unsigned int delay); -void ps3_event_filter_table_get_raid(U8 *data); +void ps3_event_filter_table_get_raid(unsigned char *data); -void ps3_event_filter_table_get_hba(U8 *data); +void ps3_event_filter_table_get_hba(unsigned char *data); -void ps3_event_filter_table_get_switch(U8 *data); +void ps3_event_filter_table_get_switch(unsigned char *data); -void ps3_vd_pending_filter_table_build(U8 *data); +void ps3_vd_pending_filter_table_build(unsigned char *data); -S32 ps3_fasync(int fd, struct file *filp, int mode); -S32 ps3_webSubscribe_context_init(struct ps3_instance *instance); +int ps3_fasync(int fd, struct file *filp, int mode); +int ps3_webSubscribe_context_init(struct ps3_instance *instance); void ps3_webSubscribe_context_exit(struct ps3_instance *instance); -S32 ps3_webSubscribe_service(struct ps3_cmd *cmd, U16 reply_flags); -S32 ps3_web_subscribe(struct ps3_instance *instance); -S32 ps3_web_unsubscribe(struct ps3_instance *instance); -S32 ps3_soft_reset_web_resubscribe(struct ps3_instance *instance); +int ps3_webSubscribe_service(struct ps3_cmd *cmd, unsigned short reply_flags); +int ps3_web_subscribe(struct ps3_instance *instance); +int ps3_web_unsubscribe(struct ps3_instance *instance); +int ps3_soft_reset_web_resubscribe(struct ps3_instance *instance); void ps3_web_cmd_clear(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_inject.c b/drivers/scsi/linkdata/ps3stor/ps3_inject.c index 3da0c6839c54..fb07b855c4a3 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_inject.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_inject.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #include #include "ps3_cli.h" #include "ps3_err_inject.h" @@ -11,20 +11,23 @@ #include "ps3_inject.h" #include "ps3_cmd_statistics.h" #include "ps3_r1x_write_lock.h" +#include "ps3_kernel_version.h" #ifdef PS3_SUPPORT_INJECT -static PS3Inject_s g_inject_list; -static PS3HitCmd_s g_hit_cmd_list; +static struct PS3Inject g_inject_list; +static struct PS3HitCmd g_hit_cmd_list; -PS3Inject_s * get_inject(void){ +struct PS3Inject *get_inject(void) +{ return &g_inject_list; } -PS3HitCmd_s * get_hit_inject(void){ +struct PS3HitCmd *get_hit_inject(void) +{ return &g_hit_cmd_list; } -void ps3_inject_list_init(void) +static void ps3_inject_list_init(void) { INIT_LIST_HEAD(&g_inject_list.scsi_rw_list); INIT_LIST_HEAD(&g_inject_list.scsi_task_list); @@ -32,7 +35,7 @@ void ps3_inject_list_init(void) ps3_mutex_init(&g_inject_list.lock); } -void ps3_hit_cmd_list_init(void) +static void ps3_hit_cmd_list_init(void) { INIT_LIST_HEAD(&g_hit_cmd_list.scsi_rw_list); INIT_LIST_HEAD(&g_hit_cmd_list.scsi_task_list); @@ -45,22 +48,26 @@ void ps3_inject_init(void) ps3_inject_list_init(); } -void ps3_inject_list_exit(void) +static void ps3_inject_list_exit(void) { struct inject_cmds_t *pitem = NULL; struct inject_cmds_t *pitem_next = NULL; + ps3_mutex_lock(&g_inject_list.lock); - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_rw_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_rw_list, list) { list_del(&pitem->list); kfree(pitem); } - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_task_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_task_list, list) { list_del(&pitem->list); kfree(pitem); } - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.mgr_list, list) { + list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.mgr_list, + list) { list_del(&pitem->list); kfree(pitem); } @@ -68,28 +75,30 @@ void ps3_inject_list_exit(void) ps3_mutex_destroy(&g_inject_list.lock); } -void ps3_hit_cmd_list_exit(void) +static void ps3_hit_cmd_list_exit(void) { struct inject_hit_cmds_t *pitem = NULL; struct inject_hit_cmds_t *pitem_next = NULL; ps3_mutex_lock(&g_inject_list.lock); - list_for_each_entry_safe(pitem, pitem_next, &g_hit_cmd_list.scsi_rw_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &g_hit_cmd_list.scsi_rw_list, list) { list_del(&pitem->list); kfree(pitem); } - list_for_each_entry_safe(pitem, pitem_next, &g_hit_cmd_list.scsi_task_list, list) { + list_for_each_entry_safe(pitem, pitem_next, + &g_hit_cmd_list.scsi_task_list, list) { list_del(&pitem->list); kfree(pitem); } - list_for_each_entry_safe(pitem, pitem_next, &g_hit_cmd_list.mgr_list, list) { + list_for_each_entry_safe(pitem, pitem_next, &g_hit_cmd_list.mgr_list, + list) { list_del(&pitem->list); kfree(pitem); } ps3_mutex_unlock(&g_inject_list.lock); - return; } void ps3_inject_exit(void) @@ -107,8 +116,9 @@ void ps3_delete_scsi_rw_inject(struct inject_cmds_t *this_pitem) goto l_out; } - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_rw_list, list) { - if(this_pitem == pitem) { + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_rw_list, list) { + if (this_pitem == pitem) { list_del(&pitem->list); kfree(pitem); } @@ -127,8 +137,9 @@ void ps3_delete_scsi_task_inject(struct inject_cmds_t *this_pitem) goto l_out; } - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_task_list, list) { - if(this_pitem == pitem) { + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_task_list, list) { + if (this_pitem == pitem) { list_del(&pitem->list); kfree(pitem); } @@ -147,8 +158,9 @@ void ps3_delete_mgr_inject(struct inject_cmds_t *this_pitem) goto l_out; } - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.mgr_list, list) { - if(this_pitem == pitem) { + list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.mgr_list, + list) { + if (this_pitem == pitem) { list_del(&pitem->list); kfree(pitem); } @@ -158,51 +170,57 @@ void ps3_delete_mgr_inject(struct inject_cmds_t *this_pitem) return; } -Bool ps3_add_scsi_rw_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cmd_word) +static unsigned char ps3_add_scsi_rw_cmd_filter(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word) { struct ps3_cmd *cmd = ps3_cmd_find(instance, cmd_word->cmdFrameID); struct inject_cmds_t *pitem = NULL; struct inject_hit_cmds_t *p_cmd = NULL; struct inject_cmds_t *pitem_next = NULL; - U64 lba; - U32 len; - Bool is_find = PS3_FALSE; + unsigned long long lba; + unsigned int len; + unsigned char is_find = PS3_FALSE; ps3_mutex_lock(&g_inject_list.lock); - if (list_empty(&g_inject_list.scsi_rw_list)) { + if (list_empty(&g_inject_list.scsi_rw_list)) goto l_out; - } - if (cmd == NULL) { - LOG_DEBUG("[inject] tag[%u] cmd null!\n",cmd_word->cmdFrameID); - } + if (cmd == NULL) + LOG_DEBUG("[inject] tag[%u] cmd null!\n", cmd_word->cmdFrameID); ps3_scsih_lba_parse(cmd->scmd->cmnd, &lba); ps3_scsih_len_parse(cmd->scmd->cmnd, &len); - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_rw_list, list) { - if ((cmd->instance->host->host_no == pitem->item.scsi_cmd.host_no) && - (cmd->scmd->device->channel == pitem->item.scsi_cmd.channel) && - (cmd->scmd->device->id == pitem->item.scsi_cmd.id)) { + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_rw_list, list) { + if ((cmd->instance->host->host_no == + pitem->item.scsi_cmd.host_no) && + (cmd->scmd->device->channel == + pitem->item.scsi_cmd.channel) && + (cmd->scmd->device->id == pitem->item.scsi_cmd.id)) { if (((lba >= pitem->item.scsi_cmd.lba) && - (lba <= pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len)) || - ((lba + len >= pitem->item.scsi_cmd.lba) && - (lba + len <= pitem->item.scsi_cmd.lba + pitem->item.scsi_cmd.len))) { - LOG_DEBUG("[inject] add rw cmd [%u:%u:%u] lba[0x%llx], len[0x%x], times[%d], tag[%u]!\n", - pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, - pitem->item.scsi_cmd.id, lba, - len, pitem->item.scsi_cmd.inject_count, cmd->index); + (lba <= pitem->item.scsi_cmd.lba + + pitem->item.scsi_cmd.len)) || + ((lba + len >= pitem->item.scsi_cmd.lba) && + (lba + len <= pitem->item.scsi_cmd.lba + + pitem->item.scsi_cmd.len))) { + LOG_DEBUG( + "[inject] add rw cmd [%u:%u:%u] lba[0x%llx], len[0x%x], times[%d], tag[%u]!\n", + pitem->item.scsi_cmd.host_no, + pitem->item.scsi_cmd.channel, + pitem->item.scsi_cmd.id, lba, len, + pitem->item.scsi_cmd.inject_count, + cmd->index); is_find = PS3_TRUE; break; } } } - if(!is_find){ + if (!is_find) goto l_out; - } - p_cmd = (struct inject_hit_cmds_t *)kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); + p_cmd = kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); if (p_cmd == NULL) { is_find = PS3_FALSE; - goto l_out ; + goto l_out; } p_cmd->cmd = cmd; p_cmd->pitem = pitem; @@ -212,93 +230,148 @@ Bool ps3_add_scsi_rw_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord ps3_mutex_unlock(&g_inject_list.lock); return is_find; } -Bool ps3_add_scsi_task_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cmd_word) +static unsigned char ps3_add_scsi_task_cmd_filter(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word) { struct ps3_cmd *cmd; struct ps3_cmd *abort_cmd; - U16 abort_cmd_id = 0; + unsigned short abort_cmd_id = 0; struct inject_cmds_t *pitem = NULL; struct inject_cmds_t *pitem_next = NULL; struct inject_hit_cmds_t *p_cmd = NULL; - Bool is_find = PS3_FALSE; + unsigned char is_find = PS3_FALSE; struct ps3_scsi_priv_data *scsi_priv_data = NULL; ps3_mutex_lock(&g_inject_list.lock); - if (list_empty(&g_inject_list.scsi_task_list)) { + if (list_empty(&g_inject_list.scsi_task_list)) goto l_out; - } cmd = ps3_cmd_find(instance, cmd_word->cmdFrameID); - if (cmd == NULL) { + if (cmd == NULL) return is_find; - } - if (cmd->req_frame->taskReq.reqHead.cmdSubType == PS3_TASK_CMD_SCSI_TASK_ABORT - && cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT) { + if (cmd->req_frame->taskReq.reqHead.cmdSubType == + PS3_TASK_CMD_SCSI_TASK_ABORT && + cmd->req_frame->taskReq.reqHead.cmdType == + PS3_CMD_SCSI_TASK_MANAGEMENT) { abort_cmd_id = cmd->req_frame->taskReq.taskID; - abort_cmd= ps3_cmd_find(instance, abort_cmd_id); + abort_cmd = ps3_cmd_find(instance, abort_cmd_id); LOG_DEBUG("[inject] {%u:%u:%u} CFID[%u], abort CFID[%u]!\n", - abort_cmd->instance->host->host_no, abort_cmd->scmd->device->channel, - abort_cmd->scmd->device->id, cmd->index, abort_cmd_id); - - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_task_list, list) { - if ((abort_cmd->instance->host->host_no == pitem->item.scsi_task_cmd.host_no) && - (abort_cmd->scmd->device->channel == pitem->item.scsi_task_cmd.channel) && - (abort_cmd->scmd->device->id == pitem->item.scsi_task_cmd.id)) { - if (cmd->req_frame->taskReq.reqHead.cmdType == pitem->item.scsi_task_cmd.cmd_type && - cmd->req_frame->taskReq.reqHead.cmdSubType == pitem->item.scsi_task_cmd.cmd_sub_type) { - LOG_DEBUG("[inject] add abort [%u:%u:%u] type[0x%x], subType[0x%x], CFID[%u], abort CFID[%u]!\n", - pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, - pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, - pitem->item.scsi_task_cmd.cmd_sub_type, cmd->index, abort_cmd_id); + abort_cmd->instance->host->host_no, + abort_cmd->scmd->device->channel, + abort_cmd->scmd->device->id, cmd->index, + abort_cmd_id); + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_task_list, list) { + if ((abort_cmd->instance->host->host_no == + pitem->item.scsi_task_cmd.host_no) && + (abort_cmd->scmd->device->channel == + pitem->item.scsi_task_cmd.channel) && + (abort_cmd->scmd->device->id == + pitem->item.scsi_task_cmd.id)) { + if (cmd->req_frame->taskReq.reqHead.cmdType == + pitem->item.scsi_task_cmd.cmd_type && + cmd->req_frame->taskReq.reqHead.cmdSubType == + pitem->item.scsi_task_cmd + .cmd_sub_type) { + LOG_DEBUG( + "[inject] add abort [%u:%u:%u] type[0x%x], subType[0x%x], CFID[%u], abort CFID[%u]!\n", + pitem->item.scsi_task_cmd + .host_no, + pitem->item.scsi_task_cmd + .channel, + pitem->item.scsi_task_cmd.id, + pitem->item.scsi_task_cmd + .cmd_type, + pitem->item.scsi_task_cmd + .cmd_sub_type, + cmd->index, abort_cmd_id); is_find = PS3_TRUE; - if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_TIMEOUT) { - } else if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_ERROE) { - INJECT_ACTIVE(PS3_ERR_IJ_ABORT_CMD_ERROR, pitem->item.scsi_task_cmd.inject_count) - } else if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_NORMAL) { - INJECT_ACTIVE(PS3_ERR_IJ_ABORT_CMD_NORMAL, pitem->item.scsi_task_cmd.inject_count) + if (pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_TIMEOUT) { + } else if (pitem->item.scsi_task_cmd + .dealType == + PS3_SCSI_TASK_CMD_ERROE) { + INJECT_ACTIVE( + PS3_ERR_IJ_ABORT_CMD_ERROR, + pitem->item + .scsi_task_cmd + .inject_count); + } else if (pitem->item.scsi_task_cmd + .dealType == + PS3_SCSI_TASK_CMD_NORMAL) { + INJECT_ACTIVE( + PS3_ERR_IJ_ABORT_CMD_NORMAL, + pitem->item + .scsi_task_cmd + .inject_count); } else { - LOG_DEBUG("[inject] dealType[%u] is invalid!\n", - pitem->item.scsi_task_cmd.dealType); + LOG_DEBUG( + "[inject] dealType[%u] is invalid!\n", + pitem->item + .scsi_task_cmd + .dealType); } break; } } } - }else if (cmd->req_frame->taskReq.reqHead.cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET - && cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT) { + } else if (cmd->req_frame->taskReq.reqHead.cmdSubType == + PS3_TASK_CMD_SCSI_TASK_RESET && + cmd->req_frame->taskReq.reqHead.cmdType == + PS3_CMD_SCSI_TASK_MANAGEMENT) { LOG_DEBUG("[inject] type %d subType %d CFID[%u]!\n", - cmd->req_frame->taskReq.reqHead.cmdType,cmd->req_frame->taskReq.reqHead.cmdSubType, - cmd->index); - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.scsi_task_list, list) { - scsi_priv_data = PS3_SDEV_PRI_DATA(pitem->item.scsi_task_cmd.device); - if (cmd->req_frame->taskReq.reqHead.cmdType == pitem->item.scsi_task_cmd.cmd_type && - cmd->req_frame->taskReq.reqHead.cmdSubType == pitem->item.scsi_task_cmd.cmd_sub_type && - (cmd->req_frame->taskReq.reqHead.devID.diskID == scsi_priv_data->disk_pos.diskDev.diskID)) { - LOG_DEBUG("[inject] add reset [%u:%u:%u] type[0x%x], subType[0x%x], CFID[%u]!\n", - pitem->item.scsi_task_cmd.host_no, pitem->item.scsi_task_cmd.channel, - pitem->item.scsi_task_cmd.id, pitem->item.scsi_task_cmd.cmd_type, - pitem->item.scsi_task_cmd.cmd_sub_type, cmd->index); + cmd->req_frame->taskReq.reqHead.cmdType, + cmd->req_frame->taskReq.reqHead.cmdSubType, + cmd->index); + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.scsi_task_list, list) { + scsi_priv_data = PS3_SDEV_PRI_DATA( + pitem->item.scsi_task_cmd.device); + if (cmd->req_frame->taskReq.reqHead.cmdType == + pitem->item.scsi_task_cmd.cmd_type && + cmd->req_frame->taskReq.reqHead.cmdSubType == + pitem->item.scsi_task_cmd.cmd_sub_type && + (cmd->req_frame->taskReq.reqHead.devID.diskID == + scsi_priv_data->disk_pos.diskDev.diskID)) { + LOG_DEBUG( + "[inject] add reset [%u:%u:%u] type[0x%x], subType[0x%x], CFID[%u]!\n", + pitem->item.scsi_task_cmd.host_no, + pitem->item.scsi_task_cmd.channel, + pitem->item.scsi_task_cmd.id, + pitem->item.scsi_task_cmd.cmd_type, + pitem->item.scsi_task_cmd.cmd_sub_type, + cmd->index); is_find = PS3_TRUE; - if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_TIMEOUT) { - } else if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_ERROE) { - INJECT_ACTIVE(PS3_ERR_IJ_RESET_CMD_ERROR, pitem->item.scsi_task_cmd.inject_count) - } else if (pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_NORMAL) { - INJECT_ACTIVE(PS3_ERR_IJ_RESET_CMD_NORMAL, pitem->item.scsi_task_cmd.inject_count) + if (pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_TIMEOUT) { + } else if (pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_ERROE) { + INJECT_ACTIVE( + PS3_ERR_IJ_RESET_CMD_ERROR, + pitem->item.scsi_task_cmd + .inject_count); + } else if (pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_NORMAL) { + INJECT_ACTIVE( + PS3_ERR_IJ_RESET_CMD_NORMAL, + pitem->item.scsi_task_cmd + .inject_count); } else { - LOG_DEBUG("[inject] dealType[%u] is invalid!\n", - pitem->item.scsi_task_cmd.dealType); + LOG_DEBUG( + "[inject] dealType[%u] is invalid!\n", + pitem->item.scsi_task_cmd + .dealType); } break; } } } - if (!is_find){ + if (!is_find) goto l_out; - } - p_cmd = (struct inject_hit_cmds_t *)kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); + p_cmd = kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); if (p_cmd == NULL) { is_find = PS3_FALSE; - goto l_out ; + goto l_out; } pitem->item.scsi_task_cmd.inject_count--; p_cmd->cmd = cmd; @@ -309,58 +382,73 @@ Bool ps3_add_scsi_task_cmd_filter(struct ps3_instance *instance, struct PS3CmdWo return is_find; } -Bool ps3_add_mgr_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cmd_word) +static unsigned char ps3_add_mgr_cmd_filter(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word) { struct ps3_cmd *cmd; struct inject_cmds_t *pitem = NULL; struct inject_cmds_t *pitem_next = NULL; struct inject_hit_cmds_t *p_cmd = NULL; - Bool is_find = PS3_FALSE; + unsigned char is_find = PS3_FALSE; ps3_mutex_lock(&g_inject_list.lock); - if (list_empty(&g_inject_list.mgr_list)) { + if (list_empty(&g_inject_list.mgr_list)) goto l_out; - } cmd = ps3_cmd_find(instance, cmd_word->cmdFrameID); - if (cmd == NULL) { + if (cmd == NULL) return is_find; - } - if (cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SAS_MANAGEMENT - || cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_MANAGEMENT) { - LOG_DEBUG("[inject] hostno[%u], mgr CFID[%u], cmdType[%u], cmdSubType[%u]!\n", - cmd->instance->host->host_no, cmd->index, cmd->req_frame->taskReq.reqHead.cmdType, - cmd->req_frame->taskReq.reqHead.cmdSubType); - - list_for_each_entry_safe(pitem, pitem_next, &g_inject_list.mgr_list, list) { - if ((cmd->instance->host->host_no == pitem->item.mgr_cmd.host_no) && - (cmd->req_frame->taskReq.reqHead.cmdType == pitem->item.mgr_cmd.cmd_type) && - (cmd->req_frame->taskReq.reqHead.cmdSubType == pitem->item.mgr_cmd.cmd_sub_type)) { - LOG_DEBUG("[inject] add mgr type[0x%x], subType[0x%x], CFID[%u]!\n", - pitem->item.mgr_cmd.cmd_type, - pitem->item.mgr_cmd.cmd_sub_type, cmd->index); - if (pitem->item.mgr_cmd.dealType == PS3_MGR_CMD_TIMEOUT) { - } else if (pitem->item.mgr_cmd.dealType == PS3_SCSI_TASK_CMD_ERROE) { - INJECT_ACTIVE(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, pitem->item.mgr_cmd.inject_count) - INJECT_ACTIVE(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, pitem->item.mgr_cmd.inject_count) - INJECT_ACTIVE(PS3_ERR_IJ_SMP_CMD_ERROR, pitem->item.mgr_cmd.inject_count) - is_find = PS3_TRUE; - } else { - LOG_DEBUG("[inject] dealType[%u] is invalid!\n", - pitem->item.mgr_cmd.dealType); - } - break; + if (cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SAS_MANAGEMENT || + cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_MANAGEMENT) { + LOG_DEBUG( + "[inject] hostno[%u], mgr CFID[%u], cmdType[%u], cmdSubType[%u]!\n", + cmd->instance->host->host_no, cmd->index, + cmd->req_frame->taskReq.reqHead.cmdType, + cmd->req_frame->taskReq.reqHead.cmdSubType); + + list_for_each_entry_safe(pitem, pitem_next, + &g_inject_list.mgr_list, list) { + if ((cmd->instance->host->host_no == + pitem->item.mgr_cmd.host_no) && + (cmd->req_frame->taskReq.reqHead.cmdType == + pitem->item.mgr_cmd.cmd_type) && + (cmd->req_frame->taskReq.reqHead.cmdSubType == + pitem->item.mgr_cmd.cmd_sub_type)) { + LOG_DEBUG( + "[inject] add mgr type[0x%x], subType[0x%x], CFID[%u]!\n", + pitem->item.mgr_cmd.cmd_type, + pitem->item.mgr_cmd.cmd_sub_type, + cmd->index); + if (pitem->item.mgr_cmd.dealType == + PS3_MGR_CMD_TIMEOUT) { + } else if (pitem->item.mgr_cmd.dealType == + PS3_SCSI_TASK_CMD_ERROE) { + INJECT_ACTIVE( + PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, + pitem->item.mgr_cmd.inject_count); + INJECT_ACTIVE( + PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, + pitem->item.mgr_cmd.inject_count); + INJECT_ACTIVE( + PS3_ERR_IJ_SMP_CMD_ERROR, + pitem->item.mgr_cmd.inject_count); + is_find = PS3_TRUE; + } else { + LOG_DEBUG( + "[inject] dealType[%u] is invalid!\n", + pitem->item.mgr_cmd.dealType); + } + break; } } } - if (!is_find){ + if (!is_find) goto l_out; - } - p_cmd = (struct inject_hit_cmds_t *)kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); + p_cmd = kmalloc(sizeof(struct inject_hit_cmds_t), GFP_KERNEL); if (p_cmd == NULL) { is_find = PS3_FALSE; - goto l_out ; + goto l_out; } pitem->item.mgr_cmd.inject_count--; p_cmd->cmd = cmd; @@ -371,126 +459,133 @@ Bool ps3_add_mgr_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cm return is_find; } -Bool ps3_add_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cmd_word) +unsigned char ps3_add_cmd_filter(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word) { - Bool is_find = PS3_FALSE; + unsigned char is_find = PS3_FALSE; struct ps3_cmd *cmd = ps3_cmd_find(instance, cmd_word->cmdFrameID); - if(ps3_err_inject_state_query() == 0) { + if (ps3_err_inject_state_query() == 0) return is_find; - } - if(cmd == NULL) { - LOG_DEBUG("[inject] CFID[%u] is invalid!\n", - cmd->index); + if (cmd == NULL) { + LOG_DEBUG("[inject] CFID[%u] is invalid!\n", cmd->index); return is_find; } if ((cmd_word->type == PS3_CMDWORD_TYPE_READ) || - (cmd_word->type == PS3_CMDWORD_TYPE_WRITE)) { - if (cmd->req_frame->taskReq.reqHead.cmdType != PS3_CMD_SCSI_TASK_MANAGEMENT) - { - is_find = ps3_add_scsi_rw_cmd_filter(instance, cmd_word); + (cmd_word->type == PS3_CMDWORD_TYPE_WRITE)) { + if (cmd->req_frame->taskReq.reqHead.cmdType != + PS3_CMD_SCSI_TASK_MANAGEMENT) { + is_find = + ps3_add_scsi_rw_cmd_filter(instance, cmd_word); } else { - is_find = ps3_add_scsi_task_cmd_filter(instance, cmd_word); + is_find = ps3_add_scsi_task_cmd_filter(instance, + cmd_word); } } else { - if (cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SCSI_TASK_MANAGEMENT) { - is_find = ps3_add_scsi_task_cmd_filter(instance, cmd_word); - } else if (cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_MANAGEMENT || - cmd->req_frame->taskReq.reqHead.cmdType == PS3_CMD_SAS_MANAGEMENT) { + if (cmd->req_frame->taskReq.reqHead.cmdType == + PS3_CMD_SCSI_TASK_MANAGEMENT) { + is_find = ps3_add_scsi_task_cmd_filter(instance, + cmd_word); + } else if (cmd->req_frame->taskReq.reqHead.cmdType == + PS3_CMD_MANAGEMENT || + cmd->req_frame->taskReq.reqHead.cmdType == + PS3_CMD_SAS_MANAGEMENT) { is_find = ps3_add_mgr_cmd_filter(instance, cmd_word); } } if (is_find) { LOG_DEBUG("[inject] add filter CFID[%u]!\n", - cmd_word->cmdFrameID); + cmd_word->cmdFrameID); } return is_find; } -void ps3_inject_scsi_rw_force_stop(struct ps3_cmd *cmd) +static void ps3_inject_scsi_rw_force_stop(struct ps3_cmd *cmd) { - struct scsi_cmnd *s_cmd; - S32 ret_code = 0 ; - struct ps3_scsi_priv_data *data = NULL; - ret_code = 0; - - if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || - (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { - return; - } - s_cmd = cmd->scmd; - LOG_DEBUG("[inject] hno:%u force stop scsi CFID[%d]\n", - PS3_HOST(cmd->instance), cmd->index); + struct scsi_cmnd *s_cmd; + int ret_code = 0; + struct ps3_scsi_priv_data *data = NULL; + + ret_code = 0; + + if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || + (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { + return; + } + s_cmd = cmd->scmd; + LOG_DEBUG("[inject] hno:%u force stop scsi CFID[%d]\n", + PS3_HOST(cmd->instance), cmd->index); - PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); - PS3_VD_OUTSTAND_DEC(cmd->instance, s_cmd); - PS3_DEV_IO_OUTSTAND_DEC(cmd->instance, cmd); - PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); + PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); + PS3_VD_OUTSTAND_DEC(cmd->instance, cmd); + PS3_DEV_IO_OUTSTAND_DEC(cmd->instance, cmd); + PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); - ps3_qos_cmd_update(cmd->instance, cmd); + ps3_qos_cmd_update(cmd->instance, cmd, PS3_FALSE); #ifndef _WINDOWS - PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd); - PS3_DEV_BUSY_DEC(s_cmd); - s_cmd->result = ret_code; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) - s_cmd->SCp.ptr = NULL; + PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd); + PS3_DEV_BUSY_DEC(s_cmd); + s_cmd->result = ret_code; +#if defined(PS3_SUPPORT_CMD_SCP) + s_cmd->SCp.ptr = NULL; #endif - ps3_scsi_dma_unmap(cmd); - if (likely(cmd && cmd->scmd && cmd->scmd->device && cmd->scmd->device->hostdata)) { - data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; - if (likely(data != NULL) && - data->lock_mgr.hash_mgr != NULL) { - ps3_r1x_write_unlock(&data->lock_mgr, cmd); - } - } else { - LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", - PS3_HOST(cmd->instance), cmd->index); - } - if (cmd->r1x_peer_cmd != NULL) { - LOG_DEBUG("[inject] hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", - PS3_HOST(cmd->instance), cmd->index, cmd->r1x_peer_cmd->index); - if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) { - PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd->r1x_peer_cmd, PS3_REPLY_WORD_FLAG_FAIL); - ps3_scsi_cmd_free(cmd->r1x_peer_cmd); - } + ps3_scsi_dma_unmap(cmd); + if (likely(cmd && cmd->scmd && cmd->scmd->device && + cmd->scmd->device->hostdata)) { + data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; + if (likely(data != NULL) && data->lock_mgr.hash_mgr != NULL) + ps3_r1x_write_unlock(&data->lock_mgr, cmd); + } else { + LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", + PS3_HOST(cmd->instance), cmd->index); + } + if (cmd->r1x_peer_cmd != NULL) { + LOG_DEBUG( + "[inject] hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", + PS3_HOST(cmd->instance), cmd->index, + cmd->r1x_peer_cmd->index); + if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) { + PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, + cmd->r1x_peer_cmd, + PS3_REPLY_WORD_FLAG_FAIL); + ps3_scsi_cmd_free(cmd->r1x_peer_cmd); + } - if (!ps3_r1x_peer_cmd_free_nolock(cmd)) { - ps3_scsi_cmd_free(cmd); - } - } else { - ps3_scsi_cmd_free(cmd); - } - SCMD_IO_DONE(s_cmd); + if (!ps3_r1x_peer_cmd_free_nolock(cmd)) + ps3_scsi_cmd_free(cmd); + } else { + ps3_scsi_cmd_free(cmd); + } + SCMD_IO_DONE(s_cmd); #else - PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd, cmd->index); - scsi_cmnd_hoststatus_set(s_cmd, DID_RESET); - data = scsi_device_private_data(s_cmd); - if(likely(data != NULL) && data->lock_mgr.hash_mgr != NULL){ - ps3_r1x_write_unlock(&data->lock_mgr, cmd); - } - ps3_scsi_cmd_done(cmd); + PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd, cmd->index); + scsi_cmnd_hoststatus_set(s_cmd, DID_RESET); + data = scsi_device_private_data(s_cmd); + if (likely(data != NULL) && data->lock_mgr.hash_mgr != NULL) + ps3_r1x_write_unlock(&data->lock_mgr, cmd); + ps3_scsi_cmd_done(cmd); #endif -return; } -void ps3_task_abort_force_scsi_cmd(struct ps3_cmd *cmd) +static void ps3_task_abort_force_scsi_cmd(struct ps3_cmd *cmd) { struct ps3_cmd *abort_cmd = NULL; struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; - ULong cmd_lock_flags = 0; + unsigned long cmd_lock_flags = 0; struct inject_cmds_t *pitem = NULL; abort_cmd = ps3_cmd_find(cmd->instance, cmd->req_frame->taskReq.taskID); - if (abort_cmd == NULL) { + if (abort_cmd == NULL) goto l_out; - } - list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.scsi_rw_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &g_hit_cmd_list.scsi_rw_list, list) { if (abort_cmd == p_cmd->cmd) { - LOG_DEBUG("[inject] hno:%u del scsi CFID [%u] from hit_rw_list\n", + LOG_DEBUG( + "[inject] hno:%u del scsi CFID [%u] from hit_rw_list\n", PS3_HOST(cmd->instance), abort_cmd->index); list_del(&p_cmd->list); pitem = p_cmd->pitem; @@ -500,10 +595,12 @@ void ps3_task_abort_force_scsi_cmd(struct ps3_cmd *cmd) } if (pitem->item.scsi_cmd.inject_count == 0) { - LOG_DEBUG("[inject] del inject_rw host_no %u channel %u id %u lba 0x%llx len 0x%u type %u, time %u!\n", - pitem->item.scsi_cmd.host_no, pitem->item.scsi_cmd.channel, - pitem->item.scsi_cmd.id, pitem->item.scsi_cmd.lba, - pitem->item.scsi_cmd.len, pitem->item.scsi_cmd.dealType, + LOG_DEBUG( + "[inject] del inject_rw host_no %u channel %u id %u lba 0x%llx len %u type %u, time %u!\n", + pitem->item.scsi_cmd.host_no, + pitem->item.scsi_cmd.channel, pitem->item.scsi_cmd.id, + pitem->item.scsi_cmd.lba, pitem->item.scsi_cmd.len, + pitem->item.scsi_cmd.dealType, pitem->item.scsi_cmd.inject_count); ps3_delete_scsi_rw_inject(pitem); } @@ -517,21 +614,24 @@ void ps3_task_abort_force_scsi_cmd(struct ps3_cmd *cmd) cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; complete(&cmd->sync_done); LOG_DEBUG("[inject] hno:%u force complete task abort CFID:%d\n", - PS3_HOST(cmd->instance), cmd->index); + PS3_HOST(cmd->instance), cmd->index); ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); } -void ps3_task_reset_force_scsi_cmd(struct ps3_cmd *cmd) +static void ps3_task_reset_force_scsi_cmd(struct ps3_cmd *cmd) { struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; struct ps3_scsi_priv_data *scsi_priv_data; - ULong cmd_lock_flags = 0; + unsigned long cmd_lock_flags = 0; - list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.scsi_rw_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &g_hit_cmd_list.scsi_rw_list, list) { scsi_priv_data = scsi_device_private_data(p_cmd->cmd->scmd); - if (scsi_priv_data->disk_pos.diskDev.diskID == cmd->req_frame->taskReq.reqHead.devID.diskID) { - LOG_DEBUG("[inject] hno:%u del scsi CFID [%u] from hit_rw_list\n", + if (scsi_priv_data->disk_pos.diskDev.diskID == + cmd->req_frame->taskReq.reqHead.devID.diskID) { + LOG_DEBUG( + "[inject] hno:%u del scsi CFID [%u] from hit_rw_list\n", PS3_HOST(cmd->instance), p_cmd->cmd->index); list_del(&p_cmd->list); ps3_inject_scsi_rw_force_stop(p_cmd->cmd); @@ -544,26 +644,25 @@ void ps3_task_reset_force_scsi_cmd(struct ps3_cmd *cmd) cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; complete(&cmd->sync_done); LOG_DEBUG("[inject] hno:%u force complete task reset CFID:%d\n", - PS3_HOST(cmd->instance), cmd->index); + PS3_HOST(cmd->instance), cmd->index); ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); - } #ifndef PS3_UT -S32 ps3_scsi_rw_cmd_filter_handle(struct scsi_cmnd *scmd) +int ps3_scsi_rw_cmd_filter_handle(struct scsi_cmnd *scmd) { struct ps3_cmd *cmd = NULL; struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; struct ps3_instance *instance = scsi_host_data(scmd); - Bool is_find = PS3_FALSE; - U16 reply_flags; - S32 iRet = PS3_SUCCESS; + unsigned char is_find = PS3_FALSE; + unsigned short reply_flags; + int iRet = PS3_SUCCESS; struct inject_cmds_t *pitem = NULL; + unsigned char type = + PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(scmd->cmnd)); - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(scmd->cmnd)); - if (!ps3_scsih_is_rw_type(type)) { + if (!ps3_scsih_is_rw_type(type)) goto l_out; - } ps3_mutex_lock(&g_inject_list.lock); if (list_empty(&g_hit_cmd_list.scsi_rw_list)) { LOG_DEBUG("[inject] rw inject list is empty!\n"); @@ -572,63 +671,71 @@ S32 ps3_scsi_rw_cmd_filter_handle(struct scsi_cmnd *scmd) cmd = ps3_cmd_find(instance, SCMD_GET_REQUEST(scmd)->tag); - list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.scsi_rw_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &g_hit_cmd_list.scsi_rw_list, list) { if (cmd == p_cmd->cmd) { is_find = PS3_TRUE; break; } } - if (!is_find){ + if (!is_find) goto l_out; - } pitem = p_cmd->pitem; - if (p_cmd->pitem->item.scsi_cmd.dealType == PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY) { + if (p_cmd->pitem->item.scsi_cmd.dealType == + PS3_SCSI_CMD_TIMEOUT_FORCE_REPLY) { ps3_inject_scsi_rw_force_stop(cmd); } else if (p_cmd->pitem->item.scsi_cmd.dealType == PS3_SCSI_CMD_ERROR) { - scmd->result = p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.result; - scmd->sense_buffer[0] = p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.resp_code; - scmd->sense_buffer[1] = p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.sense_key; - scmd->sense_buffer[2] = p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.asc; - scmd->sense_buffer[3] = p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.ascq; + scmd->result = + p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.result; + scmd->sense_buffer[0] = p_cmd->pitem->item.scsi_cmd.cmdDeal + .errReply.sshdr.resp_code; + scmd->sense_buffer[1] = p_cmd->pitem->item.scsi_cmd.cmdDeal + .errReply.sshdr.sense_key; + scmd->sense_buffer[2] = + p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.asc; + scmd->sense_buffer[3] = + p_cmd->pitem->item.scsi_cmd.cmdDeal.errReply.sshdr.ascq; reply_flags = 1; if (cmd->cmd_receive_cb) { - LOG_DEBUG("[inject] sense: CFID:%d, rcode:0x%x, key:0x%x, asc:0x%x, ascq:0x%x\n", - cmd->index, scmd->sense_buffer[0], scmd->sense_buffer[1], - scmd->sense_buffer[2], scmd->sense_buffer[3]); + LOG_DEBUG( + "[inject] sense: CFID:%d, rcode:0x%x, key:0x%x, asc:0x%x, ascq:0x%x\n", + cmd->index, scmd->sense_buffer[0], + scmd->sense_buffer[1], scmd->sense_buffer[2], + scmd->sense_buffer[3]); iRet = cmd->cmd_receive_cb(cmd, reply_flags); } else { - LOG_DEBUG("[inject] ps3 cmd index %d has no cmd_receive_cb\n", + LOG_DEBUG( + "[inject] ps3 cmd index %d has no cmd_receive_cb\n", cmd->index); } } else { LOG_DEBUG("[inject] ps3 CFID %d dealType %d invalid\n", - cmd->index,p_cmd->pitem->item.scsi_cmd.dealType); + cmd->index, p_cmd->pitem->item.scsi_cmd.dealType); } list_del(&p_cmd->list); kfree(p_cmd); - if (pitem->item.scsi_cmd.inject_count == 0) { + if (pitem->item.scsi_cmd.inject_count == 0) ps3_delete_scsi_rw_inject(pitem); - } l_out: ps3_mutex_unlock(&g_inject_list.lock); return iRet; } -S32 ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd) +int ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd) { struct inject_cmds_t *pitem = NULL; struct ps3_instance *instance = cmd->instance; - Bool is_find = PS3_FALSE; - ULong cmd_lock_flags = 0; - S32 iRet = PS3_SUCCESS; - + unsigned char is_find = PS3_FALSE; + unsigned long cmd_lock_flags = 0; + int iRet = PS3_SUCCESS; struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; - if (cmd->req_frame->taskReq.reqHead.cmdType != PS3_CMD_SCSI_TASK_MANAGEMENT) { + if (cmd->req_frame->taskReq.reqHead.cmdType != + PS3_CMD_SCSI_TASK_MANAGEMENT) { goto l_out; } ps3_mutex_lock(&g_inject_list.lock); @@ -637,7 +744,8 @@ S32 ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd) goto l_out; } - list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.scsi_task_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, + &g_hit_cmd_list.scsi_task_list, list) { if (cmd == p_cmd->cmd) { list_del(&p_cmd->list); pitem = p_cmd->pitem; @@ -647,59 +755,69 @@ S32 ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd) } } - if (!is_find){ + if (!is_find) goto l_out; - } - if (p_cmd->pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_TIMEOUT) { + if (p_cmd->pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_TIMEOUT) { LOG_DEBUG("[inject] hno:%u force task mgr CFID:%d timeout\n", - PS3_HOST(instance), cmd->index); - } else if (p_cmd->pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_ERROE) { + PS3_HOST(instance), cmd->index); + } else if (p_cmd->pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_ERROE) { cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &cmd_lock_flags); - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_TM_FAILED; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_TM_FAILED; complete(&cmd->sync_done); - LOG_DEBUG("[inject] hno:%u force complete task mgr CFID:%d error\n", + LOG_DEBUG( + "[inject] hno:%u force complete task mgr CFID:%d error\n", PS3_HOST(instance), cmd->index); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); - - } else if (p_cmd->pitem->item.scsi_task_cmd.dealType == PS3_SCSI_TASK_CMD_NORMAL){ - if (cmd->req_frame->taskReq.reqHead.cmdSubType == PS3_TASK_CMD_SCSI_TASK_ABORT) { - LOG_DEBUG("[inject] hno:%u force complete task abort CFID:%d normal reply\n", + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); + + } else if (p_cmd->pitem->item.scsi_task_cmd.dealType == + PS3_SCSI_TASK_CMD_NORMAL) { + if (cmd->req_frame->taskReq.reqHead.cmdSubType == + PS3_TASK_CMD_SCSI_TASK_ABORT) { + LOG_DEBUG( + "[inject] hno:%u force complete task abort CFID:%d normal reply\n", PS3_HOST(instance), cmd->index); ps3_task_abort_force_scsi_cmd(cmd); - } else if(cmd->req_frame->taskReq.reqHead.cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET){ - LOG_DEBUG("[inject] hno:%u force complete task reset CFID:%d normal reply\n", + } else if (cmd->req_frame->taskReq.reqHead.cmdSubType == + PS3_TASK_CMD_SCSI_TASK_RESET) { + LOG_DEBUG( + "[inject] hno:%u force complete task reset CFID:%d normal reply\n", PS3_HOST(instance), cmd->index); ps3_task_reset_force_scsi_cmd(cmd); } else { - LOG_INFO("[inject] ps3 CFID %u type %d subType %d invalid\n", - cmd->index,cmd->req_frame->taskReq.reqHead.cmdType, + LOG_INFO( + "[inject] ps3 CFID %u type %d subType %d invalid\n", + cmd->index, + cmd->req_frame->taskReq.reqHead.cmdType, cmd->req_frame->taskReq.reqHead.cmdSubType); } } - if(pitem->item.scsi_cmd.inject_count == 0) { + if (pitem->item.scsi_cmd.inject_count == 0) ps3_delete_scsi_task_inject(pitem); - } l_out: ps3_mutex_unlock(&g_inject_list.lock); return iRet; } -S32 ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd) +int ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd) { struct inject_cmds_t *pitem = NULL; struct ps3_instance *instance = cmd->instance; - Bool is_find = PS3_FALSE; - ULong cmd_lock_flags = 0; - S32 iRet = PS3_SUCCESS; + unsigned char is_find = PS3_FALSE; + unsigned long cmd_lock_flags = 0; + int iRet = PS3_SUCCESS; struct inject_hit_cmds_t *p_cmd = NULL; struct inject_hit_cmds_t *p_cmd_next = NULL; if (cmd->req_frame->taskReq.reqHead.cmdType != PS3_CMD_MANAGEMENT && - cmd->req_frame->taskReq.reqHead.cmdType != PS3_CMD_SAS_MANAGEMENT) { + cmd->req_frame->taskReq.reqHead.cmdType != PS3_CMD_SAS_MANAGEMENT) { goto l_out; } ps3_mutex_lock(&g_inject_list.lock); @@ -708,7 +826,8 @@ S32 ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd) goto l_unlock; } - list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.mgr_list, list) { + list_for_each_entry_safe(p_cmd, p_cmd_next, &g_hit_cmd_list.mgr_list, + list) { if (cmd == p_cmd->cmd) { list_del(&p_cmd->list); pitem = p_cmd->pitem; @@ -718,27 +837,27 @@ S32 ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd) } } - if (!is_find){ + if (!is_find) goto l_unlock; - } if (p_cmd->pitem->item.mgr_cmd.dealType == PS3_MGR_CMD_TIMEOUT) { LOG_DEBUG("[inject] hno:%u force mgr CFID:%d timeout\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); } else if (p_cmd->pitem->item.mgr_cmd.dealType == PS3_MGR_CMD_ERROE) { cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &cmd_lock_flags); - cmd->resp_frame->normalRespFrame.respStatus = pitem->item.mgr_cmd.errType; + cmd->resp_frame->normalRespFrame.respStatus = + pitem->item.mgr_cmd.errType; complete(&cmd->sync_done); - LOG_DEBUG("[inject] hno:%u force complete task mgr CFID:%d error\n", + LOG_DEBUG( + "[inject] hno:%u force complete task mgr CFID:%d error\n", PS3_HOST(instance), cmd->index); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); - + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); } - if(pitem->item.mgr_cmd.inject_count == 0) { + if (pitem->item.mgr_cmd.inject_count == 0) ps3_delete_mgr_inject(pitem); - } l_unlock: ps3_mutex_unlock(&g_inject_list.lock); l_out: diff --git a/drivers/scsi/linkdata/ps3stor/ps3_inject.h b/drivers/scsi/linkdata/ps3stor/ps3_inject.h index 85f482c1c077..e8aa58775689 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_inject.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_inject.h @@ -1,74 +1,74 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_INJECT_H_ #define _PS3_INJECT_H_ -typedef struct PS3Inject { - ps3_mutex lock; +struct PS3Inject { + struct mutex lock; struct list_head scsi_rw_list; struct list_head scsi_task_list; struct list_head mgr_list; -} PS3Inject_s; +}; -typedef struct PS3HitCmd { +struct PS3HitCmd { struct list_head scsi_rw_list; struct list_head scsi_task_list; struct list_head mgr_list; -} PS3HitCmd_s; +}; -typedef struct ps3_scsi_sense{ - U8 resp_code; - U8 sense_key; - U8 asc; - U8 ascq; -} ps3_scsi_sense_s; +struct ps3_scsi_sense { + unsigned char resp_code; + unsigned char sense_key; + unsigned char asc; + unsigned char ascq; +}; -typedef struct PS3ScsiErrorReply { - S32 result; - ps3_scsi_sense_s sshdr; -} PS3ScsiErrorReply_s; +struct PS3ScsiErrorReply { + int result; + struct ps3_scsi_sense sshdr; +}; -typedef struct PS3ScsiForceReply { - U32 step; -} PS3ScsiForceReply_s; +struct PS3ScsiForceReply { + unsigned int step; +}; union PS3CmdInjectDeal { - PS3ScsiErrorReply_s errReply; - PS3ScsiForceReply_s forceReply; + struct PS3ScsiErrorReply errReply; + struct PS3ScsiForceReply forceReply; }; struct inject_scsi_cmds_t { - U32 host_no; - U32 id; - U32 channel; + unsigned int host_no; + unsigned int id; + unsigned int channel; struct scsi_device *device; - U64 lba; - U32 len; - U32 dealType; + unsigned long long lba; + unsigned int len; + unsigned int dealType; union PS3CmdInjectDeal cmdDeal; - U32 inject_count; + unsigned int inject_count; }; struct inject_scsi_task_cmds_t { - U32 host_no; - U32 id; - U32 channel; + unsigned int host_no; + unsigned int id; + unsigned int channel; struct scsi_device *device; - U8 cmd_type; - U8 cmd_sub_type; - U32 dealType; + unsigned char cmd_type; + unsigned char cmd_sub_type; + unsigned int dealType; union PS3CmdInjectDeal cmdDeal; - U32 inject_count; + unsigned int inject_count; }; struct inject_mgr_cmds_t { - U32 host_no; - U8 cmd_type; - U8 cmd_sub_type; - U32 dealType; - U32 errType; - U32 inject_count; + unsigned int host_no; + unsigned char cmd_type; + unsigned char cmd_sub_type; + unsigned int dealType; + unsigned int errType; + unsigned int inject_count; }; union PS3CmdInject { @@ -96,22 +96,23 @@ enum { PS3_MGR_CMD_NORMAL = 6, PS3_MGR_CMD_TIMEOUT = 7, PS3_MGR_CMD_ERROE = 8, -} ; -PS3Inject_s * get_inject(void); +}; +struct PS3Inject *get_inject(void); #ifndef PS3_UT -S32 ps3_scsi_rw_cmd_filter_handle(struct scsi_cmnd *scmd); -S32 ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd); -S32 ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd); +int ps3_scsi_rw_cmd_filter_handle(struct scsi_cmnd *scmd); +int ps3_scsi_task_cmd_filter_handle(struct ps3_cmd *cmd); +int ps3_mgr_cmd_filter_handle(struct ps3_cmd *cmd); #endif -Bool ps3_add_cmd_filter(struct ps3_instance *instance, struct PS3CmdWord *cmd_word); +unsigned char ps3_add_cmd_filter(struct ps3_instance *instance, + struct PS3CmdWord *cmd_word); void ps3_delete_scsi_rw_inject(struct inject_cmds_t *this_pitem); void ps3_delete_scsi_task_inject(struct inject_cmds_t *this_pitem); void ps3_delete_mgr_inject(struct inject_cmds_t *this_pitem); -PS3HitCmd_s * get_hit_inject(void); +struct PS3HitCmd *get_hit_inject(void); void ps3_inject_init(void); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h b/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h index ae2917f6f1c0..6027f67f0513 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_inner_data.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_INNER_DATA_H_ #define _PS3_INNER_DATA_H_ @@ -22,51 +22,44 @@ #include "hwapi/include_v200/s1861_regs/s1861_hil_reg0_ps3_register_s_reg.h" #include "ps3_device_manager.h" -#include "ps3_register_fifo.h" +#include "ps3_htp_register_fifo.h" #include "ps3_err_def.h" - -#define PS3_DEFAULT_PAGE_SIZE_SHIFT (12) -#define PS3_CMD_SGE_FRAME_BUFFER_SIZE (4096) -#define PS3_DUMP_DMA_BUF_SIZE (0x100000) -#define PS3_DEFAULT_TASK_MGR_TIMEOUT (50) -#define PS3_DEFAULT_MGR_CMD_TIMEOUT (180) -#define PS3_CANCEL_MGR_CMD_TIMEOUT (30) -#define PS3_UNLOAD_MGR_CMD_TIMEOUT (60) -#define PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT (360) -#define PS3_SOFT_RESET_WAIT_TIMEOUT (30) -#define PS3_SLEEP_TOLERATE_TIMEOUT (10) -#define PS3_RESET_WAIT_IO_REPLY_MAX_TIME (5) -#define PS3_REGISTER_SET_SIZE (147456) -#define PS3_MAX_DEBUG_REG_CNT (8) +#include "ps3_kernel_version.h" +#define PS3_DEFAULT_PAGE_SIZE_SHIFT (12) +#define PS3_CMD_SGE_FRAME_BUFFER_SIZE (4096) +#define PS3_DUMP_DMA_BUF_SIZE (0x100000) +#define PS3_DEFAULT_TASK_MGR_TIMEOUT (50) +#define PS3_DEFAULT_MGR_CMD_TIMEOUT (180) +#define PS3_CANCEL_MGR_CMD_TIMEOUT (30) +#define PS3_UNLOAD_MGR_CMD_TIMEOUT (60) +#define PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT (360) +#define PS3_SOFT_RESET_WAIT_TIMEOUT (30) +#define PS3_SLEEP_TOLERATE_TIMEOUT (10) +#define PS3_RESET_WAIT_IO_REPLY_MAX_TIME (5) +#define PS3_REGISTER_SET_SIZE (147456) +#define PS3_MAX_DEBUG_REG_CNT (8) #define PS3_HARD_RESET_MAX_RETRY (2) -#define PS3_MAX_REPLY_QUE_COUNT (128) +#define PS3_MAX_REPLY_QUE_COUNT (128) #define PS3_RAIDHBA_NUM_ADJUST_VALUE (1) #define PS3_DEVICE_IO_BUSY_THRESHOLD (8) -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 4)) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0))) -#include -#ifndef PS3_TAGSET_SUPPORT -#define PS3_TAGSET_SUPPORT -#endif -#endif +#define PS3_DEFAULT_EXT_SGE_CNT (256) +#define PS3_DEFAULT_SGE_CNT (262) +#define PS3_MIN_SGE_CNT (128) +#define PS3_MAX_SGE_CNT (512) -#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9 && RHEL_MINOR >= 2)) || \ - (defined(CONFIG_SUSE_KERNEL) && \ - ((CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#if defined(PS3_MAP_QUEUES) #define MAP_QUEUES_RET_TYPE void -#define MAP_QUEUES_RET_VAL(x) return +#define MAP_QUEUES_RET_VAL(x) #else #define MAP_QUEUES_RET_TYPE int -#define MAP_QUEUES_RET_VAL(x) return x +#define MAP_QUEUES_RET_VAL(x) (x) #endif -#define PS3_BLOCK_NUM_OF_32K (1 << 6) +#define PS3_BLOCK_NUM_OF_32K (1 << 6) #define PS3_VD_IO_16_OUTSTANDING (16) #define PS3_VD_IO_1_OUTSTANDING (1) enum { @@ -80,22 +73,22 @@ enum { }; -typedef enum PS3FuncID { - PS3_FUNC_ID_0 = 0, - PS3_FUNC_ID_1 = 1, - PS3_FUNC_UNLIMITED = 2, -}PS3FuncID_e; +enum PS3FuncID { + PS3_FUNC_ID_0 = 0, + PS3_FUNC_ID_1 = 1, + PS3_FUNC_UNLIMITED = 2, +}; enum { - PS3_SHIFT_BYTE = 8, - PS3_SHIFT_WORD = 16, - PS3_SHIFT_3BYTE = 24, - PS3_SHIFT_DWORD = 32, + PS3_SHIFT_BYTE = 8, + PS3_SHIFT_WORD = 16, + PS3_SHIFT_3BYTE = 24, + PS3_SHIFT_DWORD = 32, }; enum { PS3_SGL_MODE_SGE_COUNT_NO_DATA = 0, - PS3_SGL_MODE_SGE_COUNT_DIRECT = 1, + PS3_SGL_MODE_SGE_COUNT_DIRECT = 1, }; struct ps3_event_delay_work { @@ -105,209 +98,270 @@ struct ps3_event_delay_work { struct delayed_work event_work; #endif struct ps3_cmd *cmd; - U32 event_delay; + unsigned int event_delay; }; struct ps3_event_context { - struct PS3EventInfo *event_info; - struct ps3_cmd *event_cmd; - struct ps3_cmd *event_abort_cmd; - volatile U32 abort_eventcmd; + struct PS3EventInfo *event_info; + struct ps3_cmd *event_cmd; + struct ps3_cmd *event_abort_cmd; + atomic_t abort_eventcmd; #ifdef _WINDOWS - struct ps3_event_delay_work delay_work; + struct ps3_event_delay_work delay_work; #else - struct ps3_event_delay_work* delay_work; - struct ps3_event_delay_work* delay_work_pool; + struct ps3_event_delay_work *delay_work; + struct ps3_event_delay_work *delay_work_pool; #endif - U64 event_phy_addr; - volatile U32 subwork; - Bool flag; + unsigned long long event_phy_addr; + atomic_t subwork; + unsigned char flag; }; struct ps3_webSubscribe_context { - struct ps3_cmd *webSubscribe_cmd; - struct ps3_cmd *web_abort_cmd; - ps3_atomic32 is_subscribe; - ps3_atomic32 is_abort; - ps3_atomic32 subscribe_count; - volatile U32 abort_webcmd; + struct ps3_cmd *webSubscribe_cmd; + struct ps3_cmd *web_abort_cmd; + atomic_t is_subscribe; + atomic_t is_abort; + atomic_t subscribe_count; + atomic_t abort_webcmd; }; #ifndef _WINDOWS struct ps3_refire_delay_work { - struct delayed_work refire_cmd_work; - struct ps3_cmd *refire_cmd; + struct delayed_work refire_cmd_work; + struct ps3_cmd *refire_cmd; }; #endif struct ps3_cmd_attr_context { - S32 throttle_que_depth; - S32 cur_can_que; - U32 vd_io_threshold; - U32 nvme_page_size; - Bool is_support_direct_cmd; - U8 reserved[7]; + int throttle_que_depth; + int cur_can_que; + unsigned int vd_io_threshold; + unsigned int nvme_page_size; + unsigned char is_support_direct_cmd; + unsigned char reserved[7]; }; enum { - PS3_REG_OFFSET_REQUEST_QUE = \ - (HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DOORBELL_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_IRQ_CONTROL = \ - (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_STATE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_TIME_CNT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_STATE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_TIME_CNT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_KEY_GAP_CFG = \ - (HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDRESET_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOC_FW_STATE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_FW_CMD = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_CHAIN_SIZE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_VD_INFO_SIZE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_FEATURE_SUPPORT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_FIRMWARE_VERSION = \ - (HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_REPLY_QUE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HARDWARE_VERSION = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MGR_QUEUE_DEPTH = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_QUEUE_DEPTH = \ - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_TFIFO_DEPTH = \ - (HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_MAX_SEC_R1X_CMDS = \ - (HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL = \ - (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_IRQ_STATUS_RPT = \ - (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRL = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_STATUS = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DUMP_DATA_SIZE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER = \ - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_REG_CMD_STATE = \ - (HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_SOFTRESET_COUNTER = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG0_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG1_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG2_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG3_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG4_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG5 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG6 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG7 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG8 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG9 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG10 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG11 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_OFFSET_DEBUG12 = \ - (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR_IRQ_CLEAR = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), - PS3_REG_SESSION_ADDR_IRQ_MASK = \ - (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR - HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REQUEST_QUE = + (HIL_REG0_PS3_REQUEST_QUEUE_PS3_REQUEST_QUEUE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL = (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DOORBELL_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DOORBELL_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_CONTROL = + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_CONTROL_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_STATE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET = (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_LOW = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_LOW_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_KEY_SHIFT_REG_HIGH = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_KEY_SHIFT_REG_HIGH_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_TIME_CNT = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_CNT_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_TIME_OUT_CNT = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_TIME_OUT_EN_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_STATE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET = (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_LOW = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_LOW_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_KEY_SHIFT_REG_HIGH = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_KEY_SHIFT_REG_HIGH_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_TIME_CNT = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_CNT_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_TIME_OUT_CNT = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_TIME_OUT_EN_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_KEY_GAP_CFG = + (HIL_REG0_PS3_REGISTER_F_PS3_KEY_GAP_CFG_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDRESET_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDRESET_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOC_FW_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_SOC_FW_STATE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_FW_CMD = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_FW_CMD_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_CHAIN_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_CHAIN_SIZE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_VD_INFO_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_VD_INFO_SIZE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_NVME_PAGE_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_NVME_PAGE_SIZE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_FEATURE_SUPPORT = + (HIL_REG0_PS3_REGISTER_F_PS3_FEATURE_SUPPORT_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_FIRMWARE_VERSION = + (HIL_REG0_PS3_REGISTER_F_PS3_FIRMWARE_VERSION_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REPLY_QUE = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_REPLYQUE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HARDWARE_VERSION = + (HIL_REG0_PS3_REGISTER_F_PS3_HARDWARE_VERSION_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MGR_QUEUE_DEPTH = + (HIL_REG0_PS3_REGISTER_F_PS3_MGR_QUEUE_DEPTH_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_QUEUE_DEPTH = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_QUEUE_DEPTH_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_TFIFO_DEPTH = + (HIL_REG0_PS3_REGISTER_F_PS3_TFIFO_DEPTH_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_MAX_SEC_R1X_CMDS = + (HIL_REG0_PS3_REGISTER_F_PS3_MAX_SEC_R1X_CMDS_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT0 = + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT0_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT1 = + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT1_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT2 = + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT2_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT3 = + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT3_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_HIL_ADVICE2DIRECT_CNT_ALL = + (HIL_REG0_PS3_REGISTER_F_PS3_HIL_ADVICE2DIRECT_CNT_ALL_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_IRQ_STATUS_RPT = + (HIL_REG0_PS3_REGISTER_F_PS3_IRQ_STATUS_RPT_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRL = (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_CTRl_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_CTRL_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_STATUS = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_STATUS_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DUMP_DATA_SIZE = + (HIL_REG0_PS3_REGISTER_F_PS3_DUMP_DATA_SIZE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_CMD_TRIGGER_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_CMD_TRIGGER_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_REG_CMD_STATE = + (HIL_REG0_PS3_REGISTER_F_PS3_REG_CMD_STATE_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_SOFTRESET_COUNTER = + (HIL_REG0_PS3_REGISTER_F_PS3_SOFTRESET_COUNTER_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG0_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG0_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG1_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG1_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG2_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG2_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG3_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG3_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG4_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG4_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG5 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG5_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG6 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG6_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG7 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG7_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG8 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG8_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG9 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG9_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG10 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG10_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG11 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG11_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_OFFSET_DEBUG12 = (HIL_REG0_PS3_REGISTER_F_PS3_DEBUG12_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR = + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR_IRQ_CLEAR = + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_CLEAR_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), + PS3_REG_SESSION_ADDR_IRQ_MASK = + (HIL_REG0_PS3_REGISTER_F_PS3_SESSIONCMD_ADDR_IRQ_MASK_ADDR - + HIL_REG0_PS3_REGISTER_F_BASEADDR), }; - #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c index 111320caa2e7..6132538da0ec 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.c @@ -1,9 +1,9 @@ - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_instance_manager.h" #include "ps3_driver_log.h" #include "ps3_ioc_manager.h" -#ifndef _WINDOWS +#ifndef _WINDOWS #include "ps3_debug.h" #include #include @@ -11,19 +11,19 @@ #include "ps3_cli_debug.h" #ifdef PS3_HARDWARE_HAPS_V200 -#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) -#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (3600) -#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) -#define PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS (3000) +#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) +#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (3600) +#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) +#define PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS (3000) #else -#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) -#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (420) -#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) +#define PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS (180) +#define PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS (420) +#define PS3_INSTANCE_STATE_CHECK_INTERVAL_MS (1000) #endif struct ps3_host_info g_ps3_host_info; -#ifndef _WINDOWS +#ifndef _WINDOWS struct ps3_mgmt_info *ps3_mgmt_info_get(void) { static struct ps3_mgmt_info g_mgmt_info; @@ -31,29 +31,28 @@ struct ps3_mgmt_info *ps3_mgmt_info_get(void) return &g_mgmt_info; } -struct ps3_instance *ps3_instance_lookup(U16 host_no) +struct ps3_instance *ps3_instance_lookup(unsigned short host_no) { struct ps3_instance *instance = NULL; struct list_head *pitem = NULL; + list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { instance = list_entry(pitem, struct ps3_instance, list_item); - if (instance->host->host_no == host_no) { + if (instance->host->host_no == host_no) return instance; - } } return NULL; } -S32 ps3_instance_add(struct ps3_instance *instance) +int ps3_instance_add(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct list_head *pitem = NULL; struct ps3_instance *peer_instance = NULL; - if (instance == NULL) { + if (instance == NULL) return ret; - } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); list_for_each(pitem, &ps3_mgmt_info_get()->instance_list_head) { @@ -63,24 +62,32 @@ S32 ps3_instance_add(struct ps3_instance *instance) } } - list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + list_for_each_entry(peer_instance, + &ps3_mgmt_info_get()->instance_list_head, + list_item) { if (peer_instance != NULL && - ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && - peer_instance->pdev->bus->number == instance->pdev->bus->number && - PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { - INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, peer_instance) + ps3_get_pci_domain(peer_instance->pdev) == + ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == + instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == + PCI_SLOT(instance->pdev->devfn)) { + INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_PROBE, + peer_instance); peer_instance->recovery_context->instance_change = 1; - INJECT_START(PS3_ERR_IJ_ADD_INSTANCE_WAIT, peer_instance) - mb(); + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE_WAIT, + peer_instance); + mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(peer_instance); instance->peer_instance = peer_instance; peer_instance->peer_instance = instance; - mb(); + mb(); /* in order to force CPU ordering */ peer_instance->recovery_context->instance_change = 0; } } - list_add(&instance->list_item, &ps3_mgmt_info_get()->instance_list_head); + list_add(&instance->list_item, + &ps3_mgmt_info_get()->instance_list_head); mutex_init(&instance->state_machine.lock); ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); @@ -91,36 +98,40 @@ S32 ps3_instance_add(struct ps3_instance *instance) ret = PS3_SUCCESS; l_repeat_add: ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - if (pitem == NULL) { - LOG_WARN("hno:%u repeat add instance!\n", - PS3_HOST(instance)); - } + if (pitem == NULL) + LOG_WARN("hno:%u repeat add instance!\n", PS3_HOST(instance)); return ret; } -S32 ps3_instance_remove(struct ps3_instance *instance) +int ps3_instance_remove(struct ps3_instance *instance) { struct ps3_instance *peer_instance = NULL; - if (instance == NULL) { + if (instance == NULL) return -PS3_FAILED; - } ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); list_del(&instance->list_item); instance->peer_instance = NULL; - list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + list_for_each_entry(peer_instance, + &ps3_mgmt_info_get()->instance_list_head, + list_item) { if (peer_instance != NULL && - ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev) && - peer_instance->pdev->bus->number == instance->pdev->bus->number && - PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) { - INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, peer_instance) - INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, peer_instance) + ps3_get_pci_domain(peer_instance->pdev) == + ps3_get_pci_domain(instance->pdev) && + peer_instance->pdev->bus->number == + instance->pdev->bus->number && + PCI_SLOT(peer_instance->pdev->devfn) == + PCI_SLOT(instance->pdev->devfn)) { + INJECT_START(PS3_ERR_IJ_ASYNC_HARDRESET_REMOVE, + peer_instance); + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE_WAIT, + peer_instance); peer_instance->recovery_context->instance_change = 1; - mb(); + mb(); /* in order to force CPU ordering */ ps3_recovery_cancel_work_sync(peer_instance); peer_instance->peer_instance = NULL; - mb(); + mb(); /* in order to force CPU ordering */ peer_instance->recovery_context->instance_change = 0; } } @@ -138,8 +149,6 @@ void ps3_mgmt_info_init(void) INIT_LIST_HEAD(&ps3_mgmt_info_get()->instance_list_head); ps3_cli_debug_init(); - - return; } void ps3_mgmt_exit(void) @@ -158,30 +167,21 @@ void ps3_instance_init(struct ps3_instance *instance) instance->state_machine.is_pci_err_recovery = PS3_FALSE; } -S32 ps3_instance_state_transfer(struct ps3_instance *instance, - U32 exp_cur_state, U32 dest_state) +int ps3_instance_state_transfer(struct ps3_instance *instance, + unsigned int exp_cur_state, + unsigned int dest_state) { - U32 cur_state = 0; - ps3_mutex_lock(&instance->state_machine.lock); -#if 0 - 由于当前硬件不支持拦截dma等通路,只能通过硬复位 - 来防止片内踩主机内存,所以状态需要正常切换 + unsigned int cur_state = 0; - if (!instance->state_machine.is_load) { - LOG_ERROR("hno:%u driver is unload or suspend!\n", - PS3_HOST(instance)); - goto l_fail; - } -#endif + ps3_mutex_lock(&instance->state_machine.lock); cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state != exp_cur_state) { + if (cur_state != exp_cur_state) goto l_fail; - } - switch(cur_state) { + switch (cur_state) { case PS3_INSTANCE_STATE_INIT: if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -189,8 +189,8 @@ S32 ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_READY: if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_PCIE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -198,8 +198,8 @@ S32 ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_PRE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -207,95 +207,80 @@ S32 ps3_instance_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SUSPEND) || - (dest_state == PS3_INSTANCE_STATE_QUIT)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SUSPEND) || + (dest_state == PS3_INSTANCE_STATE_QUIT)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SOFT_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) - || (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_READY) - || (dest_state == PS3_INSTANCE_STATE_DEAD)) { + if ((dest_state == PS3_INSTANCE_STATE_READY) || + (dest_state == PS3_INSTANCE_STATE_DEAD)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SUSPEND: - if (dest_state == PS3_INSTANCE_STATE_READY) { + if (dest_state == PS3_INSTANCE_STATE_READY) goto l_success; - } else { + else goto l_fail; - } break; case PS3_INSTANCE_STATE_DEAD: - if (dest_state == PS3_INSTANCE_STATE_QUIT) { + if (dest_state == PS3_INSTANCE_STATE_QUIT) goto l_success; - } else { + else goto l_fail; - } break; case PS3_INSTANCE_STATE_QUIT: goto l_fail; case PS3_INSTANCE_STATE_PCIE_RECOVERY: - if (dest_state == PS3_INSTANCE_STATE_RECOVERY) { + if (dest_state == PS3_INSTANCE_STATE_RECOVERY) goto l_success; - } else { + else goto l_fail; - } default: goto l_fail; } l_fail: ps3_mutex_unlock(&instance->state_machine.lock); - LOG_ERROR("hno:%u state transfer NOK!" - "[exp_cur_state:%s][cur_state:%s][dest_state:%s]\n", - PS3_HOST(instance), - namePS3InstanceState(exp_cur_state), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_ERROR("hno:%u state transfer NOK! [exp_cur_state:%s][cur_state:%s][dest_state:%s]\n", + PS3_HOST(instance), namePS3InstanceState(exp_cur_state), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return -PS3_FAILED; l_success: ps3_atomic_set(&instance->state_machine.state, dest_state); ps3_mutex_unlock(&instance->state_machine.lock); - LOG_INFO("hno:%u state transfer from %s to %s!\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_INFO("hno:%u state transfer from %s to %s!\n", PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return PS3_SUCCESS; } -S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, - U32 dest_state) +int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, + unsigned int dest_state) { - U32 cur_state = 0; -#if 0 - 由于当前硬件不支持拦截dma等通路,只能通过硬复位 - 来防止片内踩主机内存,所以状态需要正常切换 - if (!instance->state_machine.is_load) { - LOG_ERROR("hno:%u driver is unload or suspend!\n", - PS3_HOST(instance)); - goto l_fail; - } -#endif + unsigned int cur_state = 0; + cur_state = ps3_atomic_read(&instance->state_machine.state); - if(cur_state == dest_state){ + if (cur_state == dest_state) goto l_success; - } - switch(cur_state) { + switch (cur_state) { case PS3_INSTANCE_STATE_INIT: if ((dest_state == PS3_INSTANCE_STATE_READY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -303,7 +288,7 @@ S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_READY: if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -311,8 +296,8 @@ S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_PRE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY)) { goto l_success; } else { goto l_fail; @@ -320,69 +305,63 @@ S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, break; case PS3_INSTANCE_STATE_OPERATIONAL: if ((dest_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_RECOVERY) || - (dest_state == PS3_INSTANCE_STATE_SUSPEND) || - (dest_state == PS3_INSTANCE_STATE_QUIT)) { + (dest_state == PS3_INSTANCE_STATE_RECOVERY) || + (dest_state == PS3_INSTANCE_STATE_SUSPEND) || + (dest_state == PS3_INSTANCE_STATE_QUIT)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SOFT_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) - || (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { + if ((dest_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (dest_state == PS3_INSTANCE_STATE_RECOVERY)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_RECOVERY: - if ((dest_state == PS3_INSTANCE_STATE_READY) - || (dest_state == PS3_INSTANCE_STATE_DEAD)) { + if ((dest_state == PS3_INSTANCE_STATE_READY) || + (dest_state == PS3_INSTANCE_STATE_DEAD)) { goto l_success; } else { goto l_fail; } break; case PS3_INSTANCE_STATE_SUSPEND: - if (dest_state == PS3_INSTANCE_STATE_READY) { + if (dest_state == PS3_INSTANCE_STATE_READY) goto l_success; - } else { + else goto l_fail; - } break; case PS3_INSTANCE_STATE_DEAD: - if (dest_state == PS3_INSTANCE_STATE_QUIT) { + if (dest_state == PS3_INSTANCE_STATE_QUIT) goto l_success; - } else { + else goto l_fail; - } break; case PS3_INSTANCE_STATE_QUIT: goto l_fail; case PS3_INSTANCE_STATE_PCIE_RECOVERY: - if (dest_state == PS3_INSTANCE_STATE_RECOVERY) { + if (dest_state == PS3_INSTANCE_STATE_RECOVERY) goto l_success; - } else { + else goto l_fail; - } default: goto l_fail; } l_fail: - LOG_ERROR("hno:%u state transfer NOK!" - "[cur_state:%s][dest_state:%s]\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_ERROR("hno:%u state transfer NOK! [cur_state:%s][dest_state:%s]\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return -PS3_FAILED; l_success: ps3_atomic_set(&instance->state_machine.state, dest_state); - LOG_INFO("hno:%u state transfer from %s to %s!\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state), - namePS3InstanceState(dest_state)); + LOG_INFO("hno:%u state transfer from %s to %s!\n", PS3_HOST(instance), + namePS3InstanceState(cur_state), + namePS3InstanceState(dest_state)); return PS3_SUCCESS; } @@ -394,9 +373,10 @@ void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance) void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance) { ps3_mutex_lock(&instance->state_machine.lock); - if(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ + if (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); } ps3_mutex_unlock(&instance->state_machine.lock); } @@ -404,51 +384,56 @@ void ps3_instance_state_transfer_to_dead(struct ps3_instance *instance) void ps3_instance_state_transfer_to_pcie_recovery(struct ps3_instance *instance) { ps3_mutex_lock(&instance->state_machine.lock); - if(ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_PCIE_RECOVERY){ + if (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_PCIE_RECOVERY) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_PCIE_RECOVERY); + PS3_INSTANCE_STATE_PCIE_RECOVERY); } ps3_mutex_unlock(&instance->state_machine.lock); } void ps3_instance_state_transfer_to_quit(struct ps3_instance *instance) { - ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_QUIT); + ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_QUIT); } void ps3_instance_state_transfer_to_suspend(struct ps3_instance *instance) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_SUSPEND); + PS3_INSTANCE_STATE_SUSPEND); } void ps3_instance_state_transition_to_recovery(struct ps3_instance *instance) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_RECOVERY); + PS3_INSTANCE_STATE_RECOVERY); } -S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) +int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) { - U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 2; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - U32 idx = 0; - S32 ret = PS3_SUCCESS; - for (idx = 0;idx < wait_cnt;idx++) { + unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 2; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned int idx = 0; + int ret = PS3_SUCCESS; + + for (idx = 0; idx < wait_cnt; idx++) { cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)){ + (cur_state == PS3_INSTANCE_STATE_QUIT)) { ret = -PS3_FAILED; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_HARD_RESET_DONE && - ps3_atomic_read(&instance->state_machine.state) == PS3_INSTANCE_STATE_OPERATIONAL){ - if(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + if (instance->recovery_context->host_reset_state == + PS3_HOST_RESET_HARD_RESET_DONE && + ps3_atomic_read(&instance->state_machine.state) == + PS3_INSTANCE_STATE_OPERATIONAL) { + if (atomic_read( + &instance->cmd_statistics.io_outstanding) != + 0) { ret = -PS3_RETRY; } - ps3_mutex_unlock(&instance->state_machine.lock); + ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); @@ -458,12 +443,13 @@ S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) if (idx >= wait_cnt) { LOG_WARN("hno:%u wait pre_operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state != PS3_HOST_RESET_HARD_RESET_DONE) { + if (instance->recovery_context->host_reset_state != + PS3_HOST_RESET_HARD_RESET_DONE) { LOG_WARN("hno:%u wait host reset hard reset done NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_RETRY; } ps3_mutex_unlock(&instance->state_machine.lock); @@ -472,19 +458,20 @@ S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance) return ret; } -S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) +int ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) { - U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - U32 idx = 0; + unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned int idx = 0; - LOG_INFO("hno:%u wait dead or pre_operational begin\n", PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational begin\n", + PS3_HOST(instance)); for (idx = 0; idx < wait_cnt; idx++) { cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) { + (cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_QUIT)) { break; } @@ -493,32 +480,34 @@ S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance) if (idx >= wait_cnt) { LOG_WARN("hno:%u wait dead or pre_operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } if ((cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && - (cur_state != PS3_INSTANCE_STATE_DEAD)) { + (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) && + (cur_state != PS3_INSTANCE_STATE_DEAD)) { LOG_WARN("hno:%u wait dead or pre_operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; - } - LOG_INFO("hno:%u wait dead or pre_operational success!\n", PS3_HOST(instance)); + LOG_INFO("hno:%u wait dead or pre_operational success!\n", + PS3_HOST(instance)); return PS3_SUCCESS; } -S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_hardreset) +int ps3_instance_wait_for_operational(struct ps3_instance *instance, + unsigned char is_hardreset) { - U32 wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - U32 idx = 0; - S32 recovery_state = PS3_RESET_LOG_INTERVAL; + unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_OPERATIONAL_MAX_SECS * 3; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned int idx = 0; + int recovery_state = PS3_RESET_LOG_INTERVAL; for (idx = 0; idx < wait_cnt; idx++) { if (!instance->state_machine.is_load) { - LOG_INFO("hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_INFO("hno:%u instance state not is_load\n", + PS3_HOST(instance)); break; } @@ -526,11 +515,16 @@ S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_har cur_state = ps3_atomic_read(&instance->state_machine.state); recovery_state = instance->recovery_context->recovery_state; if (((cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_QUIT)) && - (is_hardreset ? (recovery_state == PS3_HARD_RECOVERY_FINISH) : PS3_TRUE)) { - LOG_INFO("hno:%u wait break, cur_state: %s, recovery_state: %d, is_hardreset: %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), recovery_state, is_hardreset); + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_QUIT)) && + (is_hardreset ? + (recovery_state == PS3_HARD_RECOVERY_FINISH) : + PS3_TRUE)) { + LOG_INFO( + "hno:%u wait break, cur_state: %s, recovery_state: %d, is_hardreset: %d\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), recovery_state, + is_hardreset); ps3_mutex_unlock(&instance->state_machine.lock); break; } @@ -541,51 +535,57 @@ S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_har if (idx >= wait_cnt) { LOG_WARN("hno:%u wait operational timeout!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_WARN("hno:%u wait operational NOK, cur_state: %s, recovery_state: %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), recovery_state); + LOG_WARN( + "hno:%u wait operational NOK, cur_state: %s, recovery_state: %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + recovery_state); return -PS3_FAILED; - } LOG_INFO("hno:%u wait operational success!\n", PS3_HOST(instance)); return PS3_SUCCESS; } -S32 ps3_instance_wait_for_normal(struct ps3_instance *instance) +int ps3_instance_wait_for_normal(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - U32 idx = 0; - Bool is_pci_err_recovery = PS3_FALSE; + int ret = PS3_SUCCESS; + unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned int idx = 0; + unsigned char is_pci_err_recovery = PS3_FALSE; for (idx = 0; idx < wait_cnt; idx++) { INJECT_START(PS3_ERR_IJ_V2_WAKE_RECOVERY_WAIT, instance); - INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, instance); + INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_WAIT_NORMAL, + instance); is_pci_err_recovery = ps3_pci_err_recovery_get(instance); cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD && - PS3_IOC_STATE_HALT_SUPPORT(instance) && - PS3_HALT_CLI_SUPPORT(instance)) { + PS3_IOC_STATE_HALT_SUPPORT(instance) && + PS3_HALT_CLI_SUPPORT(instance)) { goto l_out; - } + } if (ps3_state_is_normal(cur_state) || - cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD || - is_pci_err_recovery) { - LOG_DEBUG("hno:%u cur state: %d, pci err recovery: %d\n", - PS3_HOST(instance), cur_state, is_pci_err_recovery); + cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_DEAD || + is_pci_err_recovery) { + LOG_DEBUG( + "hno:%u cur state: %d, pci err recovery: %d\n", + PS3_HOST(instance), cur_state, + is_pci_err_recovery); break; } if (!(idx % PS3_RESET_LOG_INTERVAL)) { - LOG_DEBUG("hno:%u state[%s] waiting for reset to finish\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_DEBUG( + "hno:%u state[%s] waiting for reset to finish\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); } #ifdef PS3_HARDWARE_HAPS_V200 ps3_msleep(PS3_INSTANCE_STATE_CHECK_NORMAL_INTERVAL_MS); @@ -600,8 +600,10 @@ S32 ps3_instance_wait_for_normal(struct ps3_instance *instance) } if (!ps3_state_is_normal(cur_state) || is_pci_err_recovery) { - LOG_WARN("hno:%u cannot handle cmd, driver state: %s, pci recovery: %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), is_pci_err_recovery); + LOG_WARN( + "hno:%u cannot handle cmd, driver state: %s, pci recovery: %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + is_pci_err_recovery); ret = -PS3_FAILED; goto l_out; } @@ -610,23 +612,25 @@ S32 ps3_instance_wait_for_normal(struct ps3_instance *instance) return ret; } -S32 ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) +int ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; - S32 recovery_state = PS3_RESET_LOG_INTERVAL; - U32 idx = 0; - Bool is_pci_err_recovery = PS3_FALSE; + int ret = PS3_SUCCESS; + unsigned int wait_cnt = PS3_INSTANCE_WAIT_TO_NORMAL_MAX_SECS; + int recovery_state = PS3_RESET_LOG_INTERVAL; + unsigned int idx = 0; + unsigned char is_pci_err_recovery = PS3_FALSE; for (idx = 0; idx < wait_cnt; idx++) { recovery_state = instance->recovery_context->recovery_state; is_pci_err_recovery = ps3_pci_err_recovery_get(instance); - if ( recovery_state == PS3_HARD_RECOVERY_FINISH || - recovery_state == PS3_SOFT_RECOVERY_PROBE_PROCESS || - is_pci_err_recovery) { - LOG_DEBUG("hno:%u recovery state: %d, pci err recovery: %d\n", - PS3_HOST(instance), recovery_state, is_pci_err_recovery); + if (recovery_state == PS3_HARD_RECOVERY_FINISH || + recovery_state == PS3_SOFT_RECOVERY_PROBE_PROCESS || + is_pci_err_recovery) { + LOG_DEBUG( + "hno:%u recovery state: %d, pci err recovery: %d\n", + PS3_HOST(instance), recovery_state, + is_pci_err_recovery); goto l_out; } #ifdef PS3_HARDWARE_HAPS_V200 @@ -643,16 +647,26 @@ S32 ps3_recovery_state_wait_for_normal(struct ps3_instance *instance) ret = -PS3_FAILED; LOG_WARN("hno:%u wait recovery time out, recovery_state: %d\n", - PS3_HOST(instance), recovery_state); + PS3_HOST(instance), recovery_state); l_out: if (is_pci_err_recovery) { LOG_WARN("hno:%u cannot handle cmd, pci recovery: %d\n", - PS3_HOST(instance), is_pci_err_recovery); + PS3_HOST(instance), is_pci_err_recovery); ret = -PS3_FAILED; } return ret; } +static void ps3_cpu_type_parse(struct ps3_host_info *host_info) +{ + if (host_info->vendor == PS3_HOST_VENDOR_HYGON) { + if (host_info->model < 4) + host_info->cpu_type = PS3_HOST_HYGON_CPU_TYPE1; + else + host_info->cpu_type = PS3_HOST_HYGON_CPU_TYPE2; + } +} + void ps3_host_info_get(void) { #if defined(CONFIG_X86) || defined(CONFIG_X86_64) @@ -661,13 +675,13 @@ void ps3_host_info_get(void) memset(&g_ps3_host_info, 0, sizeof(struct ps3_host_info)); cpu = &cpu_data(0); g_ps3_host_info.machine = PS3_HOST_MACHINE_X86; - if (strstr(cpu->x86_vendor_id, "Intel")) { + if (strstr(cpu->x86_vendor_id, "Intel")) g_ps3_host_info.vendor = PS3_HOST_VENDOR_INTEL; - } else if (strstr(cpu->x86_vendor_id, "Hygon")) { + else if (strstr(cpu->x86_vendor_id, "Hygon")) g_ps3_host_info.vendor = PS3_HOST_VENDOR_HYGON; - } else if (strstr(cpu->x86_vendor_id, "AMD")) { + else if (strstr(cpu->x86_vendor_id, "AMD")) g_ps3_host_info.vendor = PS3_HOST_VENDOR_AMD; - } + g_ps3_host_info.model = cpu->x86_model; g_ps3_host_info.processor_cnt = num_online_cpus(); #else memset(&g_ps3_host_info, 0, sizeof(struct ps3_host_info)); @@ -676,23 +690,29 @@ void ps3_host_info_get(void) memset(g_ps3_host_info.release, 0, SYS_INFO_LEN + 1); snprintf(g_ps3_host_info.release, SYS_INFO_LEN, "%s", utsname()->release); - LOG_DEBUG("host info: machine=%u,vendor=%u,processor_cnt=%u release=%s\n", + ps3_cpu_type_parse(&g_ps3_host_info); + LOG_DEBUG("host info: machine=%u,vendor=%u,processor_cnt=%u release=%s cpu_type=%u\n", g_ps3_host_info.machine, g_ps3_host_info.vendor, - g_ps3_host_info.processor_cnt, g_ps3_host_info.release); + g_ps3_host_info.processor_cnt, g_ps3_host_info.release, g_ps3_host_info.cpu_type); } -U16 ps3_host_vendor_get(void) +unsigned short ps3_host_vendor_get(void) { return g_ps3_host_info.vendor; } -char* ps3_host_release_get(void) +char *ps3_host_release_get(void) { return g_ps3_host_info.release; } -U8 ps3_is_last_func(struct ps3_instance *instance) +unsigned short ps3_host_cpu_type_get(void) +{ + return g_ps3_host_info.cpu_type; +} + +unsigned char ps3_is_last_func(struct ps3_instance *instance) { - return (!ps3_ioc_multi_func_support(instance) || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1)); + return (!ps3_ioc_multi_func_support(instance) || + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1)); } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h index 69b2d3f9f6e6..3816f80dcbf9 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_instance_manager.h @@ -1,8 +1,8 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_INSTANCE_MANAGER_H_ #define _PS3_INSTANCE_MANAGER_H_ -#ifndef _WINDOWS +#ifndef _WINDOWS #include #include #include @@ -33,207 +33,211 @@ #include "ps3_qos.h" enum PS3_INSTANCE_STATE_TYPE { - PS3_INSTANCE_STATE_INIT = 0, - PS3_INSTANCE_STATE_READY = 1, - PS3_INSTANCE_STATE_PRE_OPERATIONAL = 2, - PS3_INSTANCE_STATE_OPERATIONAL = 3, - PS3_INSTANCE_STATE_SOFT_RECOVERY = 4, - PS3_INSTANCE_STATE_RECOVERY = 5, - PS3_INSTANCE_STATE_SUSPEND = 6, - PS3_INSTANCE_STATE_DEAD = 7, - PS3_INSTANCE_STATE_QUIT = 8, + PS3_INSTANCE_STATE_INIT = 0, + PS3_INSTANCE_STATE_READY = 1, + PS3_INSTANCE_STATE_PRE_OPERATIONAL = 2, + PS3_INSTANCE_STATE_OPERATIONAL = 3, + PS3_INSTANCE_STATE_SOFT_RECOVERY = 4, + PS3_INSTANCE_STATE_RECOVERY = 5, + PS3_INSTANCE_STATE_SUSPEND = 6, + PS3_INSTANCE_STATE_DEAD = 7, + PS3_INSTANCE_STATE_QUIT = 8, PS3_INSTANCE_STATE_PCIE_RECOVERY = 9, - PS3_INSTANCE_STATE_COUNT = 10 + PS3_INSTANCE_STATE_COUNT = 10 }; enum PS3_DEVICE_ERR_HANDLE_STATE_TYPE { - PS3_DEVICE_ERR_STATE_NORMAL = 0, - PS3_DEVICE_ERR_STATE_CLEAN = 1, - PS3_DEVICE_ERR_STATE_INIT = 2, + PS3_DEVICE_ERR_STATE_NORMAL = 0, + PS3_DEVICE_ERR_STATE_CLEAN = 1, + PS3_DEVICE_ERR_STATE_INIT = 2, }; struct ps3_instance_state_machine { - ps3_mutex lock; - ps3_atomic32 state; - Bool is_load; - Bool is_suspend; - Bool is_poweroff; - Bool is_pci_err_recovery; - Bool can_hostreset; + struct mutex lock; + atomic_t state; + unsigned char is_load; + unsigned char is_suspend; + unsigned char is_poweroff; + unsigned char is_pci_err_recovery; + unsigned char can_hostreset; }; -static inline const S8 *namePS3InstanceState(S32 s) +static inline const char *namePS3InstanceState(int s) { - static const S8 *myNames[] = { - [PS3_INSTANCE_STATE_INIT] = "PS3_INSTANCE_STATE_INIT", - [PS3_INSTANCE_STATE_READY] = "PS3_INSTANCE_STATE_READY", - [PS3_INSTANCE_STATE_PRE_OPERATIONAL] = "PS3_INSTANCE_STATE_PRE_OPERATIONAL", - [PS3_INSTANCE_STATE_OPERATIONAL] = "PS3_INSTANCE_STATE_OPERATIONAL", - [PS3_INSTANCE_STATE_SOFT_RECOVERY] = "PS3_INSTANCE_STATE_SOFT_RECOVERY", - [PS3_INSTANCE_STATE_RECOVERY] = "PS3_INSTANCE_STATE_RECOVERY", - [PS3_INSTANCE_STATE_SUSPEND] = "PS3_INSTANCE_STATE_SUSPEND", - [PS3_INSTANCE_STATE_DEAD] = "PS3_INSTANCE_STATE_DEAD", - [PS3_INSTANCE_STATE_QUIT] = "PS3_INSTANCE_STATE_QUIT", - [PS3_INSTANCE_STATE_PCIE_RECOVERY] = "PS3_INSTANCE_STATE_PCIE_RECOVERY" + static const char * const myNames[] = { + [PS3_INSTANCE_STATE_INIT] = "PS3_INSTANCE_STATE_INIT", + [PS3_INSTANCE_STATE_READY] = "PS3_INSTANCE_STATE_READY", + [PS3_INSTANCE_STATE_PRE_OPERATIONAL] = + "PS3_INSTANCE_STATE_PRE_OPERATIONAL", + [PS3_INSTANCE_STATE_OPERATIONAL] = + "PS3_INSTANCE_STATE_OPERATIONAL", + [PS3_INSTANCE_STATE_SOFT_RECOVERY] = + "PS3_INSTANCE_STATE_SOFT_RECOVERY", + [PS3_INSTANCE_STATE_RECOVERY] = "PS3_INSTANCE_STATE_RECOVERY", + [PS3_INSTANCE_STATE_SUSPEND] = "PS3_INSTANCE_STATE_SUSPEND", + [PS3_INSTANCE_STATE_DEAD] = "PS3_INSTANCE_STATE_DEAD", + [PS3_INSTANCE_STATE_QUIT] = "PS3_INSTANCE_STATE_QUIT", + [PS3_INSTANCE_STATE_PCIE_RECOVERY] = + "PS3_INSTANCE_STATE_PCIE_RECOVERY" }; - if (s >= PS3_INSTANCE_STATE_COUNT) { + if (s >= PS3_INSTANCE_STATE_COUNT) return "PS3_INSTANCE_STATE_INVALID"; - } return myNames[s]; } struct ps3_recovery_function { - S32 (*recovery_handle_cb)(struct ps3_instance *instance, U8 reason); - S32 (*hardreset_handle_pre_cb)(struct ps3_instance *instance); - S32 (*hardreset_handle_wait_ready_cb)(struct ps3_instance *instance); - S32 (*hardreset_handle_init_running_cb)(struct ps3_instance *instance); - S32 (*hardreset_handle_post_cb)(struct ps3_instance *instance); - S32 (*hardreset_handle_finish_cb)(struct ps3_instance *instance); - S32 (*hardreset_handle_offline_cb)(struct ps3_instance *instance); - S32 (*softreset_handle_pre_cb)(struct ps3_instance *instance); - S32 (*softreset_handle_post_cb)(struct ps3_instance *instance); - S32 (*halt_handle_cb)(struct ps3_instance *instance); + int (*recovery_handle_cb)(struct ps3_instance *instance, + unsigned char reason); + int (*hardreset_handle_pre_cb)(struct ps3_instance *instance); + int (*hardreset_handle_wait_ready_cb)(struct ps3_instance *instance); + int (*hardreset_handle_init_running_cb)(struct ps3_instance *instance); + int (*hardreset_handle_post_cb)(struct ps3_instance *instance); + int (*hardreset_handle_finish_cb)(struct ps3_instance *instance); + int (*hardreset_handle_offline_cb)(struct ps3_instance *instance); + int (*softreset_handle_pre_cb)(struct ps3_instance *instance); + int (*softreset_handle_post_cb)(struct ps3_instance *instance); + int (*halt_handle_cb)(struct ps3_instance *instance); }; struct ps3_instance { - ps3_list_head list_item; + struct list_head list_item; struct ps3_instance *peer_instance; -#ifndef _WINDOWS +#ifndef _WINDOWS struct pci_dev *pdev; struct Scsi_Host *host; #else - ULong bus_number; + unsigned long bus_number; struct ps3_pci_context pci_dev_context; #endif - Ps3Fifo_s __iomem *reg_set; - ps3_atomic32 watchdog_reg_read_fail_count; + struct Ps3Fifo __iomem *reg_set; + atomic_t watchdog_reg_read_fail_count; struct ps3_cmd_context cmd_context; struct ps3_irq_context irq_context; struct ps3_dev_context dev_context; -#ifndef _WINDOWS +#ifndef _WINDOWS struct ps3_sas_dev_context sas_dev_context; #endif struct ps3_event_context event_context; - struct ps3_webSubscribe_context webSubscribe_context; + struct ps3_webSubscribe_context webSubscribe_context; struct ps3_fault_context fault_context; struct ps3_watchdog_context watchdog_context; struct ps3_dump_context dump_context; - struct ps3_debug_context debug_context; - struct ps3_cmd_statistics_context cmd_statistics; + struct ps3_debug_context debug_context; + struct ps3_cmd_statistics_context cmd_statistics; struct PS3IocCtrlInfo ctrl_info; struct PS3IocCtrlInfo *ctrl_info_buf; -#ifdef _WINDOWS - ps3_atomic32 ioctl_count; +#ifdef _WINDOWS + atomic_t ioctl_count; #else struct semaphore ioctl_sem; #endif - struct ps3_ioc_adp_template *ioc_adpter; - struct ps3_cmd_attr_context cmd_attr; - struct PS3MgrEvent event_req_info; + struct ps3_ioc_adp_template *ioc_adpter; + struct ps3_cmd_attr_context cmd_attr; + struct PS3MgrEvent event_req_info; - ps3_spinlock req_queue_lock; + spinlock_t req_queue_lock; dma_addr_t ctrl_info_buf_h; - dma_addr_t drv_info_buf_phys; - U8 *drv_info_buf; - dma_addr_t host_mem_info_buf_phys; - U8 *host_mem_info_buf; - U32 max_mgr_cmd_total_count; - U32 max_mgr_cmd_count; - U32 max_task_cmd_count; - U32 min_intr_count; - U8 reserve[4]; - U32 reply_fifo_depth_addition; - - ULong reg_bar; - Bool is_support_sync_cache; - Bool is_use_frontend_prp; - U8 dma_mask; - Bool is_support_jbod; - Bool use_clusting; - Bool is_adjust_register_count; - Bool is_scan_host_finish; - Bool is_probe_finish; - Bool is_probe_failed; - Bool is_suspend; - Bool is_resume; - Bool is_hard_reset; - Bool is_pci_reset; - Bool is_ioc_halt_support; - Bool is_shallow_soft_recovery_support; - Bool is_deep_soft_recovery_support; - Bool is_hard_recovery_support; - Bool is_halt_support_cli; - Bool is_half_hard_reset; - Bool is_host_added; - Bool is_need_event; - Bool is_raid1_direct_skip_mapblock_check; - Bool is_single_disk_raid0_direct_skip_strip_check; - Bool is_support_dump_ctrl; - Bool is_support_io_limit; - Bool task_manager_host_busy; - U8 hilMode; - Bool is_irq_prk_support; - Bool is_support_irq; - Bool is_raid; - Bool smp_affinity_enable; - Bool msix_combined; - U8 reserved[2]; - U16 unload_timeout; - U16 wait_ready_timeout; - U16 dev_id; - U8 dma_addr_bit_pos; - U8 pci_err_handle_state; + dma_addr_t drv_info_buf_phys; + unsigned char *drv_info_buf; + dma_addr_t host_mem_info_buf_phys; + unsigned char *host_mem_info_buf; + unsigned int max_mgr_cmd_total_count; + unsigned int max_mgr_cmd_count; + unsigned int max_task_cmd_count; + unsigned int min_intr_count; + unsigned char reserve[4]; + unsigned int reply_fifo_depth_addition; + + unsigned long reg_bar; + unsigned char is_support_sync_cache; + unsigned char is_use_frontend_prp; + unsigned char dma_mask; + unsigned char is_support_jbod; + unsigned char use_clusting; + unsigned char is_adjust_register_count; + unsigned char is_scan_host_finish; + unsigned char is_probe_finish; + unsigned char is_probe_failed; + unsigned char is_suspend; + unsigned char is_resume; + unsigned char is_hard_reset; + unsigned char is_pci_reset; + unsigned char is_ioc_halt_support; + unsigned char is_shallow_soft_recovery_support; + unsigned char is_deep_soft_recovery_support; + unsigned char is_hard_recovery_support; + unsigned char is_halt_support_cli; + unsigned char is_half_hard_reset; + unsigned char is_host_added; + unsigned char is_need_event; + unsigned char is_raid1_direct_skip_mapblock_check; + unsigned char is_single_disk_raid0_direct_skip_strip_check; + unsigned char is_support_dump_ctrl; + unsigned char is_support_io_limit; + unsigned char task_manager_host_busy; + unsigned char hilMode; + unsigned char is_irq_prk_support; + unsigned char is_support_irq; + unsigned char is_raid; + unsigned char smp_affinity_enable; + unsigned char msix_combined; + unsigned char reserved[2]; + unsigned short unload_timeout; + unsigned short wait_ready_timeout; + unsigned short dev_id; + unsigned char dma_addr_bit_pos; + unsigned char pci_err_handle_state; const char *product_model; - S64 __percpu *scsi_cmd_deliver; + long long __percpu *scsi_cmd_deliver; - U64 ioc_fw_version; - ps3_mutex task_mgr_reset_lock; + unsigned long long ioc_fw_version; + struct mutex task_mgr_reset_lock; #ifdef _WINDOWS STOR_DPC device_reset_dpc; #endif - Bool page_mode_change; - U64 page_mode_addr_mask; - ps3_atomic32 is_err_scsi_processing; - ps3_atomic32 reg_op_count; - ps3_atomic32 host_reset_processing; - ps3_atomic32 watchdog_ref; + unsigned char page_mode_change; + unsigned long long page_mode_addr_mask; + atomic_t is_err_scsi_processing; + atomic_t reg_op_count; + atomic_t host_reset_processing; + atomic_t watchdog_ref; struct ps3_instance_state_machine state_machine; - struct ps3_recovery_context *recovery_context; - struct ps3_recovery_function recovery_function; + struct ps3_recovery_context *recovery_context; + struct ps3_recovery_function recovery_function; #ifndef _WINDOWS - struct work_struct recovery_irq_work; - struct workqueue_struct *recovery_irq_queue; - U8 recovery_irq_enable; - Bool is_print_special_log; - U8 reserved2[2]; - U32 hard_dog_mask; + struct work_struct recovery_irq_work; + struct workqueue_struct *recovery_irq_queue; + unsigned char recovery_irq_enable; + unsigned char is_print_special_log; + unsigned char reserved2[2]; + unsigned int hard_dog_mask; #endif - volatile U32 hardreset_event; + atomic_t hardreset_event; struct ps3_qos_context qos_context; - ps3_mutex task_abort_lock; - U8 r1x_mode; - U64 start_pfn; - U64 end_pfn; - U64 so_start_addr; - U64 so_end_addr; - S32 device_busy_threshold; - U8 is_pcie_err_detected; - U8 reserved3; + struct mutex task_abort_lock; + unsigned char r1x_mode; + unsigned long long start_pfn; + unsigned long long end_pfn; + unsigned long long so_start_addr; + unsigned long long so_end_addr; + int device_busy_threshold; + unsigned char is_pcie_err_detected; + unsigned char reserved3; }; #ifndef _WINDOWS struct ps3_mgmt_info { - ps3_mutex ps3_mgmt_lock; - ps3_list_head instance_list_head; + struct mutex ps3_mgmt_lock; + struct list_head instance_list_head; }; -enum { +enum { PS3_HOST_MACHINE_DEFAULT, PS3_HOST_MACHINE_X86 = 0, PS3_HOST_MACHINE_ARM, @@ -241,7 +245,7 @@ enum { PS3_HOST_MACHINE_COUNT, }; -enum { +enum { PS3_HOST_VENDOR_DEFAULT, PS3_HOST_VENDOR_INTEL = 0, PS3_HOST_VENDOR_HYGON, @@ -249,23 +253,32 @@ enum { PS3_HOST_VENDOR_COUNT, }; -#define SYS_INFO_LEN (64) +enum { + PS3_HOST_CPU_DEFAULT = 0, + PS3_HOST_HYGON_CPU_TYPE1, + PS3_HOST_HYGON_CPU_TYPE2, +}; + +#define SYS_INFO_LEN (65) + struct ps3_host_info { - U8 machine; - U8 vendor; - U16 cpu_cnt; - U16 core_cnt; - U16 processor_cnt; + unsigned char machine; + unsigned char vendor; + unsigned char model; + unsigned short cpu_cnt; + unsigned short core_cnt; + unsigned short processor_cnt; char release[SYS_INFO_LEN + 1]; + unsigned short cpu_type; }; -struct ps3_mgmt_info* ps3_mgmt_info_get(void); +struct ps3_mgmt_info *ps3_mgmt_info_get(void); -struct ps3_instance *ps3_instance_lookup(U16 host_no); +struct ps3_instance *ps3_instance_lookup(unsigned short host_no); -S32 ps3_instance_add(struct ps3_instance *instance); +int ps3_instance_add(struct ps3_instance *instance); -S32 ps3_instance_remove(struct ps3_instance *instance); +int ps3_instance_remove(struct ps3_instance *instance); void ps3_mgmt_info_init(void); @@ -275,10 +288,12 @@ void ps3_mgmt_exit(void); void ps3_instance_init(struct ps3_instance *instance); -S32 ps3_instance_state_transfer(struct ps3_instance *instance, - U32 exp_cur_state, U32 dest_state); -S32 ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, - U32 dest_state); +int ps3_instance_state_transfer(struct ps3_instance *instance, + unsigned int exp_cur_state, + unsigned int dest_state); + +int ps3_instance_no_lock_state_transfer(struct ps3_instance *instance, + unsigned int dest_state); void ps3_instance_state_transfer_to_dead_nolock(struct ps3_instance *instance); @@ -292,20 +307,27 @@ void ps3_instance_state_transfer_to_suspend(struct ps3_instance *instance); void ps3_instance_state_transition_to_recovery(struct ps3_instance *instance); -S32 ps3_instance_wait_for_operational(struct ps3_instance *instance, Bool is_hardreset); -S32 ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance); +int ps3_instance_wait_for_operational(struct ps3_instance *instance, + unsigned char is_hardreset); + +int ps3_instance_wait_for_hard_reset_flag_done(struct ps3_instance *instance); -S32 ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance); +int ps3_instance_wait_for_dead_or_pre_operational(struct ps3_instance *instance); -static inline Bool ps3_is_instance_state_normal(struct ps3_instance *instance, Bool need_prk_err) +static inline unsigned char +ps3_is_instance_state_normal(struct ps3_instance *instance, + unsigned char need_prk_err) { - S32 cur_state = ps3_atomic_read(&instance->state_machine.state); - INJECT_START(PS3_ERR_IJ_SAS_REQ_PRE_CHECK, &cur_state) + int cur_state = ps3_atomic_read(&instance->state_machine.state); + + INJECT_START(PS3_ERR_IJ_SAS_REQ_PRE_CHECK, &cur_state); if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { - LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, "hno:%u instance exception state %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + LOG_WARN_LIM_WITH_CHECK(instance, need_prk_err, + "hno:%u instance exception state %s\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); return PS3_FALSE; } @@ -313,49 +335,62 @@ static inline Bool ps3_is_instance_state_normal(struct ps3_instance *instance, B return PS3_TRUE; } -static inline void ps3_pci_err_recovery_set(struct ps3_instance *instance, Bool state) +static inline void ps3_pci_err_recovery_set(struct ps3_instance *instance, + unsigned char state) { instance->state_machine.is_pci_err_recovery = state; } -static inline Bool ps3_pci_err_recovery_get(struct ps3_instance *instance) +static inline unsigned char +ps3_pci_err_recovery_get(struct ps3_instance *instance) { return instance->state_machine.is_pci_err_recovery; } -static inline Bool ps3_need_block_hard_reset_request(struct ps3_instance *instance) + +static inline unsigned char +ps3_need_block_hard_reset_request(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_LIM("hno[%u], host in pci recovery during reset request\n", + LOG_WARN_LIM( + "hno[%u], host in pci recovery during reset request\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto end; } ps3_mutex_lock(&instance->state_machine.lock); - if(instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { + if (instance->recovery_context->host_reset_state != + PS3_HOST_RESET_INIT) { ps3_mutex_unlock(&instance->state_machine.lock); - LOG_WARN_LIM("hno[%u], host in host reset during reset request\n", + LOG_WARN_LIM( + "hno[%u], host in host reset during reset request\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto end; } ps3_mutex_unlock(&instance->state_machine.lock); end: - return ((ret == PS3_SUCCESS) ? PS3_FALSE:PS3_TRUE); + return ((ret == PS3_SUCCESS) ? PS3_FALSE : PS3_TRUE); } -static inline void ps3_need_wait_hard_reset_request(struct ps3_instance *instance) + +static inline void +ps3_need_wait_hard_reset_request(struct ps3_instance *instance) { do { if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_LIM("hno[%u], host in pci recovery during reset request\n", + LOG_WARN_LIM( + "hno[%u], host in pci recovery during reset request\n", PS3_HOST(instance)); ps3_msleep(100); continue; } ps3_mutex_lock(&instance->state_machine.lock); - if(instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { + if (instance->recovery_context->host_reset_state != + PS3_HOST_RESET_INIT) { ps3_mutex_unlock(&instance->state_machine.lock); - LOG_WARN_LIM("hno[%u], host in host reset during reset request\n", + LOG_WARN_LIM( + "hno[%u], host in host reset during reset request\n", PS3_HOST(instance)); ps3_msleep(100); continue; @@ -365,66 +400,77 @@ static inline void ps3_need_wait_hard_reset_request(struct ps3_instance *instanc } while (1); } -static inline Bool ps3_state_is_normal(S32 cur_state) +static inline unsigned char ps3_state_is_normal(int cur_state) { return (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL) ? - PS3_FALSE : PS3_TRUE; + PS3_FALSE : + PS3_TRUE; } -S32 ps3_instance_wait_for_normal(struct ps3_instance *instance); +int ps3_instance_wait_for_normal(struct ps3_instance *instance); -S32 ps3_recovery_state_wait_for_normal(struct ps3_instance *instance); +int ps3_recovery_state_wait_for_normal(struct ps3_instance *instance); struct ps3_ioc_adp_template { - S32 (*io_cmd_build)(struct ps3_cmd *cmd); - S32 (*mgr_cmd_build)(struct ps3_instance *instance, - struct ps3_cmd *cmd); + int (*io_cmd_build)(struct ps3_cmd *cmd); + int (*mgr_cmd_build)(struct ps3_instance *instance, + struct ps3_cmd *cmd); void (*init_cmd_send)(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void (*cmd_send)(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); - U32 (*ioc_state_get)(struct ps3_instance *instance); - S32 (*ioc_init_state_to_ready)(struct ps3_instance *instance); - S32 (*ioc_init_proc)(struct ps3_instance *instance); + struct PS3CmdWord *cmd_word); + unsigned int (*ioc_state_get)(struct ps3_instance *instance); + int (*ioc_init_state_to_ready)(struct ps3_instance *instance); + int (*ioc_init_proc)(struct ps3_instance *instance); void (*ioc_resource_prepare)(struct ps3_instance *instance); - S32 (*ioc_hard_reset)(struct ps3_instance *instance); - S32 (*ioc_shallow_soft_reset)(struct ps3_instance *instance); - S32 (*ioc_deep_soft_reset)(struct ps3_instance *instance); - S32 (*ioc_force_to_fault)(struct ps3_instance *instance); - S32 (*ioc_force_to_halt)(struct ps3_instance *instance); - S32 (*irq_init)(struct ps3_instance *instance); + int (*ioc_hard_reset)(struct ps3_instance *instance); + int (*ioc_shallow_soft_reset)(struct ps3_instance *instance); + int (*ioc_deep_soft_reset)(struct ps3_instance *instance); + int (*ioc_force_to_fault)(struct ps3_instance *instance); + int (*ioc_force_to_halt)(struct ps3_instance *instance); + int (*irq_init)(struct ps3_instance *instance); void (*irq_enable)(struct ps3_instance *instance); void (*irq_disable)(struct ps3_instance *instance); #ifndef _WINDOWS - irqreturn_t (*isr)(int irq_no, void *data); + irqreturn_t (*isr)(int irq_no, void *data); struct scsi_transport_template *(*sas_transport_get)(void); #else - U8(*isr)(void *instance, ULong irq_no); + unsigned char (*isr)(void *instance, unsigned long irq_no); #endif - void (*event_filter_table_get)(U8 *data); - void (*reg_write)(struct ps3_instance *instance, U64 val, void __iomem *reg); - U64 (*reg_read)(struct ps3_instance *instance, void __iomem *reg); - Bool (*is_need_direct_to_normal)(const struct ps3_cmd *cmd); - Bool (*max_replyq_count_get)(struct ps3_instance *instance, - U32 *max_replyq_count); + void (*event_filter_table_get)(unsigned char *data); + void (*reg_write)(struct ps3_instance *instance, unsigned long long val, + void __iomem *reg); + unsigned long long (*reg_read)(struct ps3_instance *instance, + void __iomem *reg); + unsigned char (*is_need_direct_to_normal)(const struct ps3_cmd *cmd); + unsigned char (*max_replyq_count_get)(struct ps3_instance *instance, + unsigned int *max_replyq_count); void (*check_vd_member_change)(struct ps3_instance *instance, - struct ps3_pd_entry *local_entry); - Bool (*scsih_stream_is_detect)(struct ps3_cmd *cmd); - Bool (*scsih_stream_is_direct)(const struct ps3_cmd *cmd); - U32 (*ioc_heartbeat_detect)(struct ps3_instance *instance); - void __iomem * (*reg_set)(struct pci_dev *pdev, ULong reg_bar); - Bool (*ioc_security_check)(struct ps3_instance *instance); - void (*io_cmd_rebuild)(struct ps3_cmd *cmd); - Bool (*rw_cmd_is_need_split)(struct ps3_cmd *cmd); - Bool (*write_direct_enable)(struct ps3_cmd *cmd); - Bool (*ssd_vd_qmask_calculate)(struct ps3_cmd *cmd); + struct ps3_pd_entry *local_entry); + unsigned char (*scsih_stream_is_detect)(struct ps3_cmd *cmd); + unsigned char (*scsih_stream_is_direct)(const struct ps3_cmd *cmd); + unsigned int (*ioc_heartbeat_detect)(struct ps3_instance *instance); + void __iomem *(*reg_set)(struct pci_dev *pdev, unsigned long reg_bar); + unsigned char (*ioc_security_check)(struct ps3_instance *instance); + void (*io_cmd_rebuild)(struct ps3_cmd *cmd); + unsigned char (*rw_cmd_is_need_split)(struct ps3_cmd *cmd); + unsigned char (*write_direct_enable)(struct ps3_cmd *cmd); + unsigned char (*ssd_vd_qmask_calculate)(struct ps3_cmd *cmd); + void (*pd_cmd_word_cpu_set)(struct ps3_cmd *cmd); +#ifdef PS3_NCQ_PRIO_SUPPORT + ssize_t (*ncq_prio_enable_stor)(struct device *dev, const char *buf); +#endif + int (*ext_sge_cnt_calc)(struct ps3_instance *instance); + void (*max_sge_config)(struct ps3_instance *instance); }; -#define PS3_DEVICE_IS_SWITCH(id) ((id == PCI_DEVICE_ID_PS3_SWITCH || \ - id == PCI_DEVICE_ID_PS3_SWITCH_FPGA)) +#define PS3_DEVICE_IS_SWITCH(id) \ + ((id == PCI_DEVICE_ID_PS3_SWITCH || \ + id == PCI_DEVICE_ID_PS3_SWITCH_FPGA)) #ifndef _WINDOWS -void ps3_ioc_adp_init(struct ps3_instance *instance, const struct pci_device_id *id); +void ps3_ioc_adp_init(struct ps3_instance *instance, + const struct pci_device_id *id); void ps3_remove(struct pci_dev *pdev); @@ -432,22 +478,22 @@ void ps3_remove(struct pci_dev *pdev); void ps3_ioc_adp_init(struct ps3_instance *instance); #endif -static inline S32 ps3_get_pci_function(struct pci_dev *pci) +static inline int ps3_get_pci_function(struct pci_dev *pci) { - return (PCI_FUNC(pci->devfn)); + return PCI_FUNC(pci->devfn); } -static inline S32 ps3_get_pci_slot(struct pci_dev * pci) +static inline int ps3_get_pci_slot(struct pci_dev *pci) { - return (PCI_SLOT(pci->devfn)); + return PCI_SLOT(pci->devfn); } -static inline S32 ps3_get_pci_bus(struct pci_dev * pci) +static inline int ps3_get_pci_bus(struct pci_dev *pci) { - return (pci->bus->number); + return pci->bus->number; } -static inline S32 ps3_get_pci_domain(struct pci_dev * pci) +static inline int ps3_get_pci_domain(struct pci_dev *pci) { return pci_domain_nr(pci->bus); } @@ -457,13 +503,19 @@ static inline bool ps3_is_latest_func(struct ps3_instance *instance) bool ret = PS3_TRUE; struct ps3_instance *peer_instance = NULL; - list_for_each_entry(peer_instance, &ps3_mgmt_info_get()->instance_list_head, list_item) { + list_for_each_entry(peer_instance, + &ps3_mgmt_info_get()->instance_list_head, + list_item) { if ((peer_instance != NULL) && - (ps3_get_pci_domain(peer_instance->pdev) == ps3_get_pci_domain(instance->pdev)) && - (PCI_BUS_NUM(peer_instance->pdev->devfn) == PCI_BUS_NUM(instance->pdev->devfn)) && - (PCI_SLOT(peer_instance->pdev->devfn) == PCI_SLOT(instance->pdev->devfn)) && - (PCI_FUNC(peer_instance->pdev->devfn) != PCI_FUNC(instance->pdev->devfn))) { - ret = PS3_FALSE; + (ps3_get_pci_domain(peer_instance->pdev) == + ps3_get_pci_domain(instance->pdev)) && + (PCI_BUS_NUM(peer_instance->pdev->devfn) == + PCI_BUS_NUM(instance->pdev->devfn)) && + (PCI_SLOT(peer_instance->pdev->devfn) == + PCI_SLOT(instance->pdev->devfn)) && + (PCI_FUNC(peer_instance->pdev->devfn) != + PCI_FUNC(instance->pdev->devfn))) { + ret = PS3_FALSE; } } @@ -471,25 +523,33 @@ static inline bool ps3_is_latest_func(struct ps3_instance *instance) } static inline void ps3_get_so_addr_ranger(struct ps3_instance *instance, - U64 addr, U32 offset) + unsigned long long addr, + unsigned int offset) { - U64 so_end_addr = (addr + offset) - 1; + unsigned long long so_end_addr = (addr + offset) - 1; + if (instance->so_start_addr == 0 && instance->so_end_addr == 0) { instance->so_start_addr = addr; instance->so_end_addr = so_end_addr; goto l_out; } - instance->so_start_addr = ((addr < instance->so_start_addr) ? addr : instance->so_start_addr); - instance->so_end_addr = ((so_end_addr > instance->so_end_addr) ? so_end_addr : instance->so_end_addr); + instance->so_start_addr = + ((addr < instance->so_start_addr) ? addr : + instance->so_start_addr); + instance->so_end_addr = + ((so_end_addr > instance->so_end_addr) ? so_end_addr : + instance->so_end_addr); l_out: return; } void ps3_host_info_get(void); -U16 ps3_host_vendor_get(void); +unsigned short ps3_host_vendor_get(void); + +char *ps3_host_release_get(void); -char* ps3_host_release_get(void); +unsigned short ps3_host_cpu_type_get(void); -U8 ps3_is_last_func(struct ps3_instance *instance); +unsigned char ps3_is_last_func(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c index 6b41c2345089..04b0ef293948 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -6,69 +7,67 @@ #include "ps3_instance_manager.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_io_trace.h" +#include "ps3_kernel_version.h" -static inline const char *ps3_io_trace_direct_name(ps3_io_trace_dtype type) +static inline const char *ps3_io_trace_direct_name(enum ps3_io_trace_dtype type) { - static const char *direct_name[] = { - "cmd send", - "cmd recv", - "unknown" - }; - if(type >= PS3_IO_TRACE_DIRECT_COUNT) { + static const char *const direct_name[] = { "cmd send", "cmd recv", + "unknown" }; + if (type >= PS3_IO_TRACE_DIRECT_COUNT) return direct_name[PS3_IO_TRACE_DIRECT_COUNT]; - } return direct_name[type]; } #ifndef _WINDOWS -static inline Bool ps3_is_scsi_read_cmd(struct scsi_cmnd *s_cmnd) +static inline unsigned char ps3_is_scsi_read_cmd(struct scsi_cmnd *s_cmnd) { - return (s_cmnd != NULL && s_cmnd->sc_data_direction == DMA_FROM_DEVICE && + return (s_cmnd != NULL && + s_cmnd->sc_data_direction == DMA_FROM_DEVICE && (s_cmnd->cmnd[0] == READ_6 || s_cmnd->cmnd[0] == READ_10 || - s_cmnd->cmnd[0] == READ_12 || s_cmnd->cmnd[0] == READ_16)); + s_cmnd->cmnd[0] == READ_12 || s_cmnd->cmnd[0] == READ_16)); } -static inline Bool ps3_is_scsi_write_cmd(struct scsi_cmnd *s_cmnd) +static inline unsigned char ps3_is_scsi_write_cmd(struct scsi_cmnd *s_cmnd) { return (s_cmnd != NULL && s_cmnd->sc_data_direction == DMA_TO_DEVICE && (s_cmnd->cmnd[0] == WRITE_6 || s_cmnd->cmnd[0] == WRITE_10 || - s_cmnd->cmnd[0] == WRITE_12 || s_cmnd->cmnd[0] == WRITE_16)); + s_cmnd->cmnd[0] == WRITE_12 || s_cmnd->cmnd[0] == WRITE_16)); } static void ps3_scsi_sgl_crc(const struct ps3_cmd *cmd) { - U32 sge_count = 0; - U32 i = 0; - U32 crc = 0; - U32 seed = 0x1234; - S8 *pdata = NULL; - U32 buf_len = 0; - S8 buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; + unsigned int sge_count = 0; + unsigned int i = 0; + unsigned int crc = 0; + unsigned int seed = 0x1234; + char *pdata = NULL; + unsigned int buf_len = 0; + char buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; struct scatterlist *os_sgl = NULL; struct ps3_instance *instance = cmd->instance; struct scsi_cmnd *s_cmnd = cmd->scmd; - if (instance->debug_context.io_trace_switch == PS3_FALSE) { + if (instance->debug_context.io_trace_switch == PS3_FALSE) goto l_out; - } sge_count = cmd->os_sge_map_count; scsi_for_each_sg(s_cmnd, os_sgl, sge_count, i) { - pdata = (S8 *)sg_virt(os_sgl); + pdata = (char *)sg_virt(os_sgl); crc = crc32(seed, pdata, sg_dma_len(os_sgl)); memset(buf, '\0', sizeof(buf)); - buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, - "hno:%u channel[%u], target[%u]," - "trace_id[0x%llx], [%u of %u]sge, sge data addr[0x%llx] length[%u], " - "D[%llx:%llx] CRC[0x%x] \n", - PS3_HOST(instance), s_cmnd->device->channel, s_cmnd->device->id, - cmd->trace_id, - i + 1, sge_count, sg_dma_address(os_sgl), - sg_dma_len(os_sgl), *(U64*)pdata, *((U64 *)(pdata + 8)), crc); + buf_len = snprintf( + buf, PS3_IO_TRACE_BUF_LEN, + "hno:%u channel[%u], target[%u], trace_id[0x%llx], [%u of %u]sge\n" + "\tsge data addr[0x%llx] length[%u], D[%llx:%llx] CRC[0x%x]\n", + PS3_HOST(instance), s_cmnd->device->channel, + s_cmnd->device->id, cmd->trace_id, i + 1, sge_count, + (unsigned long long)sg_dma_address(os_sgl), + sg_dma_len(os_sgl), *(unsigned long long *)pdata, + *((unsigned long long *)(pdata + 8)), crc); if (buf_len >= PS3_IO_TRACE_BUF_LEN) { - LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); - goto l_out; - } + LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); + goto l_out; + } DATA_DUMP(NULL, 0, buf); } @@ -76,21 +75,20 @@ static void ps3_scsi_sgl_crc(const struct ps3_cmd *cmd) return; } #endif -void ps3_scsih_io_trace(const struct ps3_cmd *cmd, ps3_io_trace_dtype type) +void ps3_scsih_io_trace(const struct ps3_cmd *cmd, enum ps3_io_trace_dtype type) { - S32 buf_len = 0; + int buf_len = 0; char buf[PS3_IO_TRACE_BUF_LEN] = { 0 }; - U64 lba = 0; + unsigned long long lba = 0; if (cmd == NULL || cmd->scmd == NULL) { LOG_WARN("cmd or scmd is null\n"); goto l_out; } - if (scsi_sg_count(cmd->scmd) == 0) { + if (scsi_sg_count(cmd->scmd) == 0) goto l_out; - } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#if defined(PS3_CMD_CDB_CHECK) if (cmd->scmd->cmnd == NULL || cmd->instance->host == NULL) { LOG_WARN("cdb null\n"); goto l_out; @@ -102,25 +100,28 @@ void ps3_scsih_io_trace(const struct ps3_cmd *cmd, ps3_io_trace_dtype type) } #endif - if ((type == PS3_IO_TRACE_DIRECT_SEND && ps3_is_scsi_write_cmd(cmd->scmd)) || - (type == PS3_IO_TRACE_DIRECT_RECV && ps3_is_scsi_read_cmd(cmd->scmd))){ + if ((type == PS3_IO_TRACE_DIRECT_SEND && + ps3_is_scsi_write_cmd(cmd->scmd)) || + (type == PS3_IO_TRACE_DIRECT_RECV && + ps3_is_scsi_read_cmd(cmd->scmd))) { ps3_scsi_sgl_crc(cmd); } ps3_scsih_lba_parse(cmd->scmd->cmnd, &lba); memset(buf, '\0', sizeof(buf)); buf_len = snprintf(buf, PS3_IO_TRACE_BUF_LEN, - "%s, trace_id[0x%llx], hno:%u lba[0x%llx]\n", - ps3_io_trace_direct_name(type), cmd->trace_id, PS3_HOST(cmd->instance), lba); + "%s, trace_id[0x%llx], hno:%u lba[0x%llx]\n", + ps3_io_trace_direct_name(type), cmd->trace_id, + PS3_HOST(cmd->instance), lba); if (buf_len >= PS3_IO_TRACE_BUF_LEN) { LOG_ERROR("buf_len > PS3_IO_TRACE_BUF_LEN\n"); goto l_out; } DATA_DUMP(sg_virt(cmd->scmd->sdb.table.sgl), - min_t(U32, cmd->scmd->sdb.table.sgl[0].length, - PS3_IO_TRACE_PRINT_COUNT), buf); + min_t(unsigned int, cmd->scmd->sdb.table.sgl[0].length, + PS3_IO_TRACE_PRINT_COUNT), + buf); l_out: return; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h index 3675dad01f6e..a48221340dd2 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_io_trace.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IO_TRACE_H_ #define _PS3_IO_TRACE_H_ @@ -7,18 +7,21 @@ #define PS3_IO_TRACE_PRINT_COUNT (32) #define PS3_IO_TRACE_BUF_LEN (256) -typedef enum { +enum ps3_io_trace_dtype { PS3_IO_TRACE_DIRECT_SEND, PS3_IO_TRACE_DIRECT_RECV, PS3_IO_TRACE_DIRECT_COUNT, -}ps3_io_trace_dtype; +}; -void ps3_scsih_io_trace(const struct ps3_cmd *cmd, ps3_io_trace_dtype type); -#define PS3_IO_TRACE(cmd, type) do { \ - if ((cmd)->instance->debug_context.io_trace_switch == PS3_FALSE) { \ - break; \ - } \ - ps3_scsih_io_trace((cmd),(type)); \ -} while(0); +void ps3_scsih_io_trace(const struct ps3_cmd *cmd, + enum ps3_io_trace_dtype type); +#define PS3_IO_TRACE(cmd, type) \ + do { \ + if ((cmd)->instance->debug_context.io_trace_switch == \ + PS3_FALSE) { \ + break; \ + } \ + ps3_scsih_io_trace((cmd), (type)); \ + } while (0) #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c index da0f02482ffa..3a168ab23f3c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_adp.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifdef _WINDOWS #include "ps3_def.h" #endif @@ -15,84 +16,31 @@ #include "ps3_module_para.h" #include "ps3_scsih.h" -#define MAX_MGR_CMD_COUNT (8) -#define MAX_TASK_CMD_COUNT (8) -#define MIN_MSIX_INT_COUNT (1) -#define PS3_HARD_DOG_MASK (0xF000000UL) +#define MAX_MGR_CMD_COUNT (8) +#define MAX_TASK_CMD_COUNT (8) +#define MIN_MSIX_INT_COUNT (1) +#define PS3_HARD_DOG_MASK (0xF000000UL) -#define SWITCH_MAX_MGR_CMD_COUNT (12) -#define SWITCH_MAX_TASK_CMD_COUNT (2) -#define SWITCH_MAX_MGR_CMD_TOTAL_COUNT (14) -#define SWITCH_MIN_MSI_INT_COUNT (1) -#define SWITCH_REPLY_FIFO_DEP_ADDITION (1) -#define PS3_HARD_DOG_MASK_SWITCH (0x1000000UL) +#define SWITCH_MAX_MGR_CMD_COUNT (12) +#define SWITCH_MAX_TASK_CMD_COUNT (2) +#define SWITCH_MAX_MGR_CMD_TOTAL_COUNT (14) +#define SWITCH_MIN_MSI_INT_COUNT (1) +#define SWITCH_REPLY_FIFO_DEP_ADDITION (1) +#define PS3_HARD_DOG_MASK_SWITCH (0x1000000UL) struct ps3_ioc_adp_temp_entry { - U16 device_id; + unsigned short device_id; struct ps3_ioc_adp_template *adp_template; }; -void ps3_ioc_resource_prepare_switch(struct ps3_instance *instance) +static void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) { struct PS3MgrEvent *event_req_info = &instance->event_req_info; memset(event_req_info, 0, sizeof(struct PS3MgrEvent)); - event_req_info->eventTypeMap = PS3_EVT_PD_COUNT; - event_req_info->eventLevel = PS3_EVENT_LEVEL_INFO; - event_req_info->eventTypeMapProcResult = PS3_EVT_ILLEGAL_TYPE; - - instance->max_mgr_cmd_total_count = SWITCH_MAX_MGR_CMD_TOTAL_COUNT; - instance->max_mgr_cmd_count = SWITCH_MAX_MGR_CMD_COUNT; - instance->max_task_cmd_count = SWITCH_MAX_TASK_CMD_COUNT; - instance->min_intr_count = SWITCH_MIN_MSI_INT_COUNT; - instance->reply_fifo_depth_addition = SWITCH_REPLY_FIFO_DEP_ADDITION; - instance->is_support_jbod = PS3_TRUE; - instance->use_clusting = PS3_TRUE; - instance->is_use_frontend_prp = PS3_FALSE; - instance->is_adjust_register_count = PS3_FALSE; - instance->is_probe_finish = PS3_FALSE; - instance->is_probe_failed = PS3_FALSE; - instance->is_suspend = PS3_FALSE; - instance->is_resume = PS3_FALSE; - instance->is_hard_reset = PS3_FALSE; - instance->is_pci_reset = PS3_FALSE; - instance->ioc_fw_version = 0; - instance->hilMode = HIL_MODEL_SW; - instance->unload_timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; - instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH; - instance ->is_half_hard_reset = PS3_FALSE; - instance->is_need_event = PS3_FALSE; - instance->is_raid1_direct_skip_mapblock_check = PS3_FALSE; - instance->is_single_disk_raid0_direct_skip_strip_check = PS3_FALSE; - instance->is_support_dump_ctrl = PS3_FALSE; - instance->is_support_io_limit = PS3_FALSE; - instance->is_irq_prk_support = PS3_FALSE; - instance->is_support_irq = PS3_FALSE; - instance->is_raid = PS3_FALSE; - instance->hard_dog_mask = PS3_HARD_DOG_MASK_SWITCH; - instance->task_manager_host_busy = PS3_FALSE; - instance->is_print_special_log = PS3_FALSE; - instance->r1x_mode = PS3_R1X_MODE_NORMAL; - instance->smp_affinity_enable = ps3_smp_affinity_query(); - instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; - instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; - ps3_mutex_init(&instance->task_mgr_reset_lock); - ps3_mutex_init(&instance->task_abort_lock); -} - -void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) -{ - struct PS3MgrEvent *event_req_info = &instance->event_req_info; - - memset(event_req_info, 0, sizeof(struct PS3MgrEvent)); - - event_req_info->eventTypeMap = - PS3_EVT_PD_COUNT | - PS3_EVT_VD_COUNT | - PS3_EVT_CTRL_INFO | - PS3_EVT_PD_ATTR; + event_req_info->eventTypeMap = PS3_EVT_PD_COUNT | PS3_EVT_VD_COUNT | + PS3_EVT_CTRL_INFO | PS3_EVT_PD_ATTR; event_req_info->eventLevel = PS3_EVENT_LEVEL_INFO; event_req_info->eventTypeMapProcResult = PS3_EVT_ILLEGAL_TYPE; @@ -115,11 +63,13 @@ void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) instance->hilMode = HIL_MODEL_HW_ENHANCED; instance->unload_timeout = PS3_RAID_UNLOAD_MGR_CMD_TIMEOUT; #ifdef PS3_HARDWARE_HAPS_V200 - instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS; + instance->wait_ready_timeout = + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS; #else - instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID; + instance->wait_ready_timeout = + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID; #endif - instance ->is_half_hard_reset = PS3_FALSE; + instance->is_half_hard_reset = PS3_FALSE; instance->is_need_event = PS3_TRUE; instance->is_raid1_direct_skip_mapblock_check = PS3_FALSE; instance->is_single_disk_raid0_direct_skip_strip_check = PS3_FALSE; @@ -134,25 +84,23 @@ void ps3_ioc_resource_prepare_raid(struct ps3_instance *instance) instance->task_manager_host_busy = PS3_FALSE; instance->smp_affinity_enable = ps3_smp_affinity_query(); instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; + ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : + PS3_TRUE; instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); ps3_raid_qos_prepare(instance); } -void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) +static void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) { struct PS3MgrEvent *event_req_info = &instance->event_req_info; memset(event_req_info, 0, sizeof(struct PS3MgrEvent)); - event_req_info->eventTypeMap = - PS3_EVT_PD_COUNT | - PS3_EVT_VD_COUNT | - PS3_EVT_CTRL_INFO | - PS3_EVT_SAS_INFO | - PS3_EVT_PD_ATTR; + event_req_info->eventTypeMap = PS3_EVT_PD_COUNT | PS3_EVT_VD_COUNT | + PS3_EVT_CTRL_INFO | PS3_EVT_SAS_INFO | + PS3_EVT_PD_ATTR; event_req_info->eventLevel = PS3_EVENT_LEVEL_INFO; event_req_info->eventTypeMapProcResult = PS3_EVT_ILLEGAL_TYPE; @@ -178,7 +126,7 @@ void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) instance->hilMode = HIL_MODEL_HW_ENHANCED; instance->unload_timeout = PS3_UNLOAD_MGR_CMD_TIMEOUT; instance->wait_ready_timeout = PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA; - instance ->is_half_hard_reset = PS3_FALSE; + instance->is_half_hard_reset = PS3_FALSE; instance->is_need_event = PS3_TRUE; instance->is_raid1_direct_skip_mapblock_check = PS3_TRUE; instance->is_single_disk_raid0_direct_skip_strip_check = PS3_TRUE; @@ -194,36 +142,40 @@ void ps3_ioc_resource_prepare_hba(struct ps3_instance *instance) instance->task_manager_host_busy = PS3_FALSE; instance->r1x_mode = PS3_R1X_MODE_NORMAL; instance->page_mode_change = - ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : PS3_TRUE; + ps3_host_vendor_get() == PS3_HOST_VENDOR_INTEL ? PS3_FALSE : + PS3_TRUE; instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_3_ADDR_MASK; ps3_mutex_init(&instance->task_mgr_reset_lock); ps3_mutex_init(&instance->task_abort_lock); ps3_hba_qos_prepare(instance); } -static Bool ps3_replyq_count_raidhba_get(struct ps3_instance *instance, - U32 *max_replyq_count) +static unsigned char +ps3_replyq_count_raidhba_get(struct ps3_instance *instance, + unsigned int *max_replyq_count) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; + if (!ps3_max_replyq_count_get(instance, max_replyq_count)) { LOG_ERROR("hno:%u ps3_max_replyq_count_get NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } *max_replyq_count += PS3_RAIDHBA_NUM_ADJUST_VALUE; *max_replyq_count = *max_replyq_count > PS3_MAX_REPLY_QUE_COUNT ? - PS3_MAX_REPLY_QUE_COUNT : *max_replyq_count; + PS3_MAX_REPLY_QUE_COUNT : + *max_replyq_count; l_out: return ret; } -static Bool ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) +static unsigned char ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; if (ps3_direct_to_normal_query()) { - ret = PS3_TRUE; + ret = PS3_TRUE; goto l_out; } @@ -251,171 +203,131 @@ static Bool ps3_is_need_direct_to_normal_hba(const struct ps3_cmd *cmd) return ret; } -static Bool ps3_is_need_direct_to_normal_raid(const struct ps3_cmd *cmd) +static unsigned char +ps3_is_need_direct_to_normal_raid(const struct ps3_cmd *cmd) { (void)cmd; return PS3_TRUE; } -static Bool ps3_is_need_direct_to_normal_switch(const struct ps3_cmd *cmd) -{ - (void)cmd; - return PS3_FALSE; -} - -struct ps3_ioc_adp_template g_ps3_template_switch = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_switch_normal_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_switch, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init_switch, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, -#ifndef _WINDOWS - .sas_transport_get = NULL, -#endif - .event_filter_table_get = ps3_event_filter_table_get_switch, - .reg_write = ps3_reg_write_u64, -#ifdef _WINDOWS - .reg_read = ps3_reg_read_u64, -#else - .reg_read = ps3_switch_ioc_reg_read, -#endif - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_switch, - .max_replyq_count_get = ps3_max_replyq_count_get, - .check_vd_member_change = NULL, - .scsih_stream_is_detect = NULL, - .scsih_stream_is_direct = NULL, -#ifdef PS3_HARDWARE_ASIC - .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, -#else - .ioc_heartbeat_detect = NULL, -#endif - .reg_set = NULL, - .ioc_security_check = NULL, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = NULL, - .write_direct_enable = NULL, - .ssd_vd_qmask_calculate = NULL, -}; - struct ps3_ioc_adp_template g_ps3_template_hba = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - - - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_ioc_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_hba, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, + .io_cmd_build = ps3_scsih_cmd_build, + .mgr_cmd_build = NULL, + + + .init_cmd_send = ps3_switch_init_cmd_send, + .cmd_send = ps3_ioc_cmd_send, + .ioc_state_get = ps3_ioc_state_get, + .ioc_init_state_to_ready = ps3_ioc_init_to_ready, + .ioc_init_proc = ps3_ioc_init_proc, + .ioc_resource_prepare = ps3_ioc_resource_prepare_hba, + .ioc_hard_reset = ps3_ioc_state_hard_reset, + .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, + .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, + .ioc_force_to_fault = ps3_ioc_state_force_to_fault, + .ioc_force_to_halt = ps3_ioc_state_force_to_halt, + .irq_init = ps3_irqs_init, + .irq_enable = ps3_irqs_enable, + .irq_disable = ps3_irqs_disable, + .isr = ps3_irqs_service, #ifndef _WINDOWS - .sas_transport_get = ps3_sas_transport_get, + .sas_transport_get = ps3_sas_transport_get, #endif - .event_filter_table_get = ps3_event_filter_table_get_hba, - .reg_write = ps3_reg_write_u64, - .reg_read = ps3_reg_read_u64, - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_hba, - .max_replyq_count_get = ps3_replyq_count_raidhba_get, - .check_vd_member_change = ps3_check_vd_member_change, - .scsih_stream_is_detect = ps3_scsih_stream_is_detect, - .scsih_stream_is_direct = ps3_hba_scsih_stream_is_direct, + .event_filter_table_get = ps3_event_filter_table_get_hba, + .reg_write = ps3_reg_write_u64, + .reg_read = ps3_reg_read_u64, + .is_need_direct_to_normal = ps3_is_need_direct_to_normal_hba, + .max_replyq_count_get = ps3_replyq_count_raidhba_get, + .check_vd_member_change = ps3_check_vd_member_change, + .scsih_stream_is_detect = ps3_scsih_stream_is_detect, + .scsih_stream_is_direct = ps3_hba_scsih_stream_is_direct, #ifdef PS3_HARDWARE_ASIC .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, #else .ioc_heartbeat_detect = NULL, #endif - .reg_set = ps3_reg_set_ioremap, - .ioc_security_check = NULL, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_hba, - .write_direct_enable = NULL, - .ssd_vd_qmask_calculate = ps3_ssd_vd_qmask_calculate_hba, + .reg_set = ps3_reg_set_ioremap, + .ioc_security_check = NULL, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_hba, + .write_direct_enable = NULL, + .ssd_vd_qmask_calculate = ps3_ssd_vd_qmask_calculate_hba, + .pd_cmd_word_cpu_set = ps3_scsih_pd_cmd_word_cpu_set, +#ifdef PS3_NCQ_PRIO_SUPPORT + .ncq_prio_enable_stor = ps3_dev_ncq_prio_enable_stor, +#endif + .ext_sge_cnt_calc = ps3_ext_sge_cnt_calc_hba, + .max_sge_config = ps3_max_sge_cfg_hba, }; struct ps3_ioc_adp_template g_ps3_template_raid = { - .io_cmd_build = ps3_scsih_cmd_build, - .mgr_cmd_build = NULL, - - .init_cmd_send = ps3_switch_init_cmd_send, - .cmd_send = ps3_ioc_cmd_send, - .ioc_state_get = ps3_ioc_state_get, - .ioc_init_state_to_ready = ps3_ioc_init_to_ready, - .ioc_init_proc = ps3_ioc_init_proc, - .ioc_resource_prepare = ps3_ioc_resource_prepare_raid, - .ioc_hard_reset = ps3_ioc_state_hard_reset, - .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, - .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, - .ioc_force_to_fault = ps3_ioc_state_force_to_fault, - .ioc_force_to_halt = ps3_ioc_state_force_to_halt, - .irq_init = ps3_irqs_init, - .irq_enable = ps3_irqs_enable, - .irq_disable = ps3_irqs_disable, - .isr = ps3_irqs_service, + .io_cmd_build = ps3_scsih_cmd_build, + .mgr_cmd_build = NULL, + + .init_cmd_send = ps3_switch_init_cmd_send, + .cmd_send = ps3_ioc_cmd_send, + .ioc_state_get = ps3_ioc_state_get, + .ioc_init_state_to_ready = ps3_ioc_init_to_ready, + .ioc_init_proc = ps3_ioc_init_proc, + .ioc_resource_prepare = ps3_ioc_resource_prepare_raid, + .ioc_hard_reset = ps3_ioc_state_hard_reset, + .ioc_shallow_soft_reset = ps3_ioc_state_shallow_soft_reset, + .ioc_deep_soft_reset = ps3_ioc_state_deep_soft_reset, + .ioc_force_to_fault = ps3_ioc_state_force_to_fault, + .ioc_force_to_halt = ps3_ioc_state_force_to_halt, + .irq_init = ps3_irqs_init, + .irq_enable = ps3_irqs_enable, + .irq_disable = ps3_irqs_disable, + .isr = ps3_irqs_service, #ifndef _WINDOWS - .sas_transport_get = NULL, + .sas_transport_get = NULL, #endif - .event_filter_table_get = ps3_event_filter_table_get_raid, - .reg_write = ps3_reg_write_u64, - .reg_read = ps3_reg_read_u64, - .is_need_direct_to_normal = ps3_is_need_direct_to_normal_raid, - .max_replyq_count_get = ps3_replyq_count_raidhba_get, - .check_vd_member_change = NULL, - .scsih_stream_is_detect = ps3_scsih_stream_is_detect, - .scsih_stream_is_direct = ps3_raid_scsih_stream_is_direct, + .event_filter_table_get = ps3_event_filter_table_get_raid, + .reg_write = ps3_reg_write_u64, + .reg_read = ps3_reg_read_u64, + .is_need_direct_to_normal = ps3_is_need_direct_to_normal_raid, + .max_replyq_count_get = ps3_replyq_count_raidhba_get, + .check_vd_member_change = NULL, + .scsih_stream_is_detect = ps3_scsih_stream_is_detect, + .scsih_stream_is_direct = ps3_raid_scsih_stream_is_direct, #ifdef PS3_HARDWARE_ASIC .ioc_heartbeat_detect = ps3_ioc_heartbeat_detect, #else .ioc_heartbeat_detect = NULL, #endif - .reg_set = ps3_reg_set_ioremap, - .ioc_security_check = ps3_ioc_security_state_check, - .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, - .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_raid, - .write_direct_enable = ps3_write_direct_enable, - .ssd_vd_qmask_calculate = NULL, + .reg_set = ps3_reg_set_ioremap, + .ioc_security_check = ps3_ioc_security_state_check, + .io_cmd_rebuild = ps3_scsih_direct_to_normal_req_frame_rebuild, + .rw_cmd_is_need_split = ps3_scsih_rw_cmd_is_need_split_raid, + .write_direct_enable = ps3_write_direct_enable, + .ssd_vd_qmask_calculate = NULL, + .pd_cmd_word_cpu_set = NULL, +#ifdef PS3_NCQ_PRIO_SUPPORT + .ncq_prio_enable_stor = NULL, +#endif + .ext_sge_cnt_calc = ps3_ext_sge_cnt_calc_raid, + .max_sge_config = NULL, }; static struct ps3_ioc_adp_temp_entry ps3_ioc_adp_template_map[] = { - {PCI_DEVICE_ID_PS3_RAID, &g_ps3_template_raid}, - {PCI_DEVICE_ID_PS3_HBA, &g_ps3_template_hba}, - {PCI_DEVICE_ID_PS3_SWITCH, &g_ps3_template_switch}, - {PCI_DEVICE_ID_PS3_SWITCH_FPGA, &g_ps3_template_switch}, - {PCI_DEVICE_ID_STARS_IOC_2020_18i, &g_ps3_template_hba}, - {PCI_DEVICE_ID_STARS_ROC_2020_10i, &g_ps3_template_raid}, - {PCI_DEVICE_ID_PS3_RAID_FPGA, &g_ps3_template_raid}, - {PCI_DEVICE_ID_STARS_IOC_2213_16i, &g_ps3_template_hba}, + { PCI_DEVICE_ID_STARS_IOC_2020_18i, &g_ps3_template_hba }, + { PCI_DEVICE_ID_STARS_ROC_2020_10i, &g_ps3_template_raid }, + { PCI_DEVICE_ID_STARS_IOC_2213_16i, &g_ps3_template_hba }, + { PCI_DEVICE_ID_TL_30A2, &g_ps3_template_raid }, }; #ifndef _WINDOWS -void ps3_ioc_adp_init(struct ps3_instance *instance, const struct pci_device_id *id) +void ps3_ioc_adp_init(struct ps3_instance *instance, + const struct pci_device_id *id) { - U16 i = 0; - U16 adp_num = sizeof(ps3_ioc_adp_template_map) / sizeof(struct ps3_ioc_adp_temp_entry); + unsigned short i = 0; + unsigned short adp_num = sizeof(ps3_ioc_adp_template_map) / + sizeof(struct ps3_ioc_adp_temp_entry); for (i = 0; i < adp_num; i++) { if (id->device == ps3_ioc_adp_template_map[i].device_id) { - instance->ioc_adpter = ps3_ioc_adp_template_map[i].adp_template; + instance->ioc_adpter = + ps3_ioc_adp_template_map[i].adp_template; } } @@ -424,19 +336,24 @@ void ps3_ioc_adp_init(struct ps3_instance *instance, const struct pci_device_id #else void ps3_ioc_adp_init(struct ps3_instance *instance) { - U16 i = 0; - U16 adp_num = sizeof(ps3_ioc_adp_template_map) / sizeof(struct ps3_ioc_adp_temp_entry); + unsigned short i = 0; + unsigned short adp_num = sizeof(ps3_ioc_adp_template_map) / + sizeof(struct ps3_ioc_adp_temp_entry); for (i = 0; i < adp_num; i++) { - if (instance->pci_dev_context.device_id == ps3_ioc_adp_template_map[i].device_id) { - instance->ioc_adpter = ps3_ioc_adp_template_map[i].adp_template; - LOG_WARN("hno:%u pci dev type is [%s]\n", + if (instance->pci_dev_context.device_id == + ps3_ioc_adp_template_map[i].device_id) { + instance->ioc_adpter = + ps3_ioc_adp_template_map[i].adp_template; + LOG_WARN( + "hno:%u pci dev type is [%s]\n", PS3_HOST(instance), - namePciDevType(ps3_ioc_adp_template_map[i].device_id)); + namePciDevType( + ps3_ioc_adp_template_map[i].device_id)); #ifdef _WINDOWS - instance->ioc_adpter->event_filter_table_get = ps3_event_filter_table_get_raid; + instance->ioc_adpter->event_filter_table_get = + ps3_event_filter_table_get_raid; #endif - } } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c index 6242ff3aa34b..5c81c43ca51b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include @@ -20,129 +21,139 @@ #include "ps3_inject.h" #include "ps3_drv_ver.h" -#define PS3_INIT_CMD_WAIT_MAX_TIMEOUT (180) -#define PS3_INIT_CMD_WAIT_INTERVAL (20) +#define PS3_INIT_CMD_WAIT_MAX_TIMEOUT (180) +#define PS3_INIT_CMD_WAIT_INTERVAL (20) #define PS3_INIT_CMD_CHECK_FAULT_INTERVAL (1000) #if (defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) -#define PS3_REG_READ_MAX_TRY_COUNT (60) +#define PS3_REG_READ_MAX_TRY_COUNT (60) #else -#define PS3_REG_READ_MAX_TRY_COUNT (10) +#define PS3_REG_READ_MAX_TRY_COUNT (10) #endif #define PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET (0x10000) #define PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT (2) -static S32 ps3_ioc_init_cmd_result_poll(struct ps3_instance *instance, - struct PS3InitReqFrame *init_frame_msg) +static int ps3_ioc_init_cmd_result_poll(struct ps3_instance *instance, + struct PS3InitReqFrame *init_frame_msg) { - U32 state = PS3_FW_STATE_UNDEFINED; - U32 wait_count = PS3_INIT_CMD_WAIT_MAX_TIMEOUT * 1000 / - PS3_INIT_CMD_WAIT_INTERVAL; - U32 count = 0; - S32 ret = -PS3_FAILED; - + unsigned int state = PS3_FW_STATE_UNDEFINED; + unsigned int wait_count = PS3_INIT_CMD_WAIT_MAX_TIMEOUT * 1000 / + PS3_INIT_CMD_WAIT_INTERVAL; + unsigned int count = 0; + int ret = -PS3_FAILED; + + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_CRITICAL, instance) + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAULT, instance) state = instance->ioc_adpter->ioc_state_get(instance); - while((count < wait_count) && (state != PS3_FW_STATE_FAULT) - && (state != PS3_FW_STATE_CRITICAL)) { - rmb(); + while ((count < wait_count) && (state != PS3_FW_STATE_FAULT) && + (state != PS3_FW_STATE_CRITICAL)) { + rmb(); /* in order to force CPU ordering */ ps3_msleep(PS3_INIT_CMD_WAIT_INTERVAL); INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_8, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_5, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - if (init_frame_msg->respStatus != U32_MAX) { + if (init_frame_msg->respStatus != U32_MAX) break; - } if (!(count % PS3_INIT_CMD_CHECK_FAULT_INTERVAL)) { - state = instance->ioc_adpter->ioc_state_get(instance) - & PS3_FW_STATE_MASK; + state = instance->ioc_adpter->ioc_state_get(instance) & + PS3_FW_STATE_MASK; } count++; } + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_READY, instance) + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_WAIT, instance) + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_COUNT_MAX, &count) + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_RESP_ERR, &init_frame_msg->respStatus) - if (state == PS3_FW_STATE_FAULT || - state == PS3_FW_STATE_CRITICAL) { + if (state == PS3_FW_STATE_FAULT || state == PS3_FW_STATE_CRITICAL) { LOG_ERROR("hno:%u init cmd NOK since IOC state fault\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (count == wait_count) { - LOG_ERROR("hno:%u init cmd timeout, state=%#x, respStatus=%#x\n", + LOG_ERROR( + "hno:%u init cmd timeout, state=%#x, respStatus=%#x\n", PS3_HOST(instance), state, init_frame_msg->respStatus); goto l_out; } if (init_frame_msg->respStatus != 0) { - LOG_ERROR("hno:%u init cmd NOK[%d]\n", - PS3_HOST(instance), init_frame_msg->respStatus); + LOG_ERROR("hno:%u init cmd NOK[%d]\n", PS3_HOST(instance), + init_frame_msg->respStatus); goto l_out; } - ret = PS3_SUCCESS; + ret = PS3_SUCCESS; LOG_WARN("hno:%u init cmd response successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: init_frame_msg->respStatus = U32_MAX; return ret; } -static S32 ps3_ioc_init_cmd_issue(struct ps3_instance *instance, - struct PS3InitReqFrame *init_frame_msg) +static int ps3_ioc_init_cmd_issue(struct ps3_instance *instance, + struct PS3InitReqFrame *init_frame_msg) { struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct PS3InitCmdWord cmd_word; memset(&cmd_word, 0, sizeof(struct PS3InitCmdWord)); - cmd_word.lowAddr = + cmd_word.lowAddr = cpu_to_le32(lower_32_bits(cmd_context->init_frame_buf_phys)); cmd_word.highAddr = cpu_to_le32(upper_32_bits(cmd_context->init_frame_buf_phys)); - cmd_word.type = PS3_CMDWORD_TYPE_INIT; + cmd_word.type = PS3_CMDWORD_TYPE_INIT; cmd_word.direct = PS3_CMDWORD_DIRECT_NORMAL; - instance->ioc_adpter->init_cmd_send(instance, (struct PS3CmdWord *)&cmd_word); + instance->ioc_adpter->init_cmd_send(instance, + (struct PS3CmdWord *)&cmd_word); - LOG_INFO("hno:%u init command: cmd.lowAddr[0x%x], cmd.highAddr[0x%x], " - "cmd.type[%u]\n", PS3_HOST(instance), cmd_word.lowAddr, - cmd_word.highAddr, cmd_word.type); - INJECT_START(PS3_ERR_IJ_FORCE_INIT_FAIL, instance) - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_INIT, instance) - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_INIT_FAIL, instance) + LOG_INFO("hno:%u init command: cmd.lowAddr[0x%x], cmd.highAddr[0x%x], cmd.type[%u]\n", + PS3_HOST(instance), cmd_word.lowAddr, cmd_word.highAddr, + cmd_word.type); + INJECT_START(PS3_ERR_IJ_FORCE_INIT_FAIL, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_A_INIT, instance); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_INIT_FAIL, instance); return ps3_ioc_init_cmd_result_poll(instance, init_frame_msg); } -static S32 ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) +static int ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) { struct ps3_cmd_context *cmd_context = &instance->cmd_context; - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - cmd_context->init_frame_buf = - (U8*)ps3_dma_alloc_coherent(instance, - sizeof(struct PS3InitReqFrame), - &cmd_context->init_frame_buf_phys); + cmd_context->init_frame_buf = (unsigned char *)ps3_dma_alloc_coherent( + instance, sizeof(struct PS3InitReqFrame), + (unsigned long long *)&cmd_context->init_frame_buf_phys); if (!cmd_context->init_frame_buf) { LOG_ERROR("hno:%u Failed to alloc init cmd dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } - cmd_context->init_filter_table_buff = (U8*)ps3_dma_alloc_coherent(instance, - PS3_CMD_EXT_BUF_SIZE_MGR, - &cmd_context->init_filter_table_phy_addr); + cmd_context->init_filter_table_buff = + (unsigned char *)ps3_dma_alloc_coherent( + instance, PS3_CMD_EXT_BUF_SIZE_MGR, + (unsigned long long *)&cmd_context + ->init_filter_table_phy_addr); if (!cmd_context->init_filter_table_buff) { - LOG_ERROR("hno:%u Failed to alloc init filter table dma buffer\n", + LOG_ERROR( + "hno:%u Failed to alloc init filter table dma buffer\n", PS3_HOST(instance)); ret = -PS3_FAILED; } @@ -151,22 +162,24 @@ static S32 ps3_ioc_init_cmd_alloc(struct ps3_instance *instance) } #ifndef _WINDOWS -static S32 ps3_ioc_sys_info_get(struct ps3_instance *instance) +static int ps3_ioc_sys_info_get(struct ps3_instance *instance) { - struct ps3_cmd_context *cmd_context = &instance->cmd_context; - struct PS3DrvSysInfo *drv_sys_info = NULL; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct PS3DrvSysInfo *drv_sys_info = NULL; const char *sys_info = NULL; - U32 sys_info_len = 0; - S32 ret = -PS3_FAILED; + unsigned int sys_info_len = 0; + int ret = -PS3_FAILED; cmd_context->init_frame_sys_info_buf = - (U8*)ps3_dma_alloc_coherent(instance, - sizeof(struct PS3DrvSysInfo), - &cmd_context->init_frame_sys_info_phys); - INJECT_START(PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, &cmd_context->init_frame_sys_info_buf); + (unsigned char *)ps3_dma_alloc_coherent( + instance, sizeof(struct PS3DrvSysInfo), + (unsigned long long *)&cmd_context + ->init_frame_sys_info_phys); + INJECT_START(PS3_ERR_IJ_PS3_INIT_FRAME_SYS_INFO_BUF_ALLOC, + &cmd_context->init_frame_sys_info_buf); if (!cmd_context->init_frame_sys_info_buf) { LOG_ERROR("hno:%u Failed to alloc sysinfo dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -177,8 +190,7 @@ static S32 ps3_ioc_sys_info_get(struct ps3_instance *instance) sys_info = dmi_get_system_info(DMI_PRODUCT_UUID); if (!sys_info) { - LOG_INFO("hno:%u Failed to get sysinfo\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u Failed to get sysinfo\n", PS3_HOST(instance)); drv_sys_info->systemIDLen = 0; drv_sys_info->version = 0; ret = PS3_SUCCESS; @@ -186,7 +198,8 @@ static S32 ps3_ioc_sys_info_get(struct ps3_instance *instance) } sys_info_len = strlen(sys_info) > PS3_DRV_SYSTEM_ID_MAX_LEN ? - PS3_DRV_SYSTEM_ID_MAX_LEN : strlen(sys_info); + PS3_DRV_SYSTEM_ID_MAX_LEN : + strlen(sys_info); memcpy(drv_sys_info->systemID, sys_info, sys_info_len); drv_sys_info->systemIDLen = sys_info_len; @@ -199,15 +212,13 @@ static S32 ps3_ioc_sys_info_get(struct ps3_instance *instance) #endif -S32 ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) +int ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) { - if (ps3_ioc_init_cmd_alloc(instance) != PS3_SUCCESS) { + if (ps3_ioc_init_cmd_alloc(instance) != PS3_SUCCESS) goto l_failed; - } #ifndef _WINDOWS - if (ps3_ioc_sys_info_get(instance) != PS3_SUCCESS) { + if (ps3_ioc_sys_info_get(instance) != PS3_SUCCESS) goto l_failed; - } #endif return PS3_SUCCESS; l_failed: @@ -217,53 +228,53 @@ S32 ps3_ioc_init_cmd_context_init(struct ps3_instance *instance) void ps3_ioc_init_cmd_context_exit(struct ps3_instance *instance) { - struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; LOG_INFO("entry\n"); #ifndef _WINDOWS if (cmd_context->init_frame_sys_info_buf != NULL) { - LOG_INFO("free init_frame_sys_info_buf = %p\n", cmd_context->init_frame_sys_info_buf); - ps3_dma_free_coherent(instance, - sizeof(struct PS3DrvSysInfo), - cmd_context->init_frame_sys_info_buf, - cmd_context->init_frame_sys_info_phys); + LOG_INFO("free init_frame_sys_info_buf = %p\n", + cmd_context->init_frame_sys_info_buf); + ps3_dma_free_coherent(instance, sizeof(struct PS3DrvSysInfo), + cmd_context->init_frame_sys_info_buf, + cmd_context->init_frame_sys_info_phys); cmd_context->init_frame_sys_info_buf = NULL; } #endif if (cmd_context->init_filter_table_buff != NULL) { - LOG_INFO("free init_filter_table_buff = %p\n", cmd_context->init_filter_table_buff); - ps3_dma_free_coherent(instance, - PS3_CMD_EXT_BUF_SIZE_MGR, - cmd_context->init_filter_table_buff, - cmd_context->init_filter_table_phy_addr); + LOG_INFO("free init_filter_table_buff = %p\n", + cmd_context->init_filter_table_buff); + ps3_dma_free_coherent(instance, PS3_CMD_EXT_BUF_SIZE_MGR, + cmd_context->init_filter_table_buff, + cmd_context->init_filter_table_phy_addr); cmd_context->init_filter_table_buff = NULL; cmd_context->init_filter_table_phy_addr = 0; } if (cmd_context->init_frame_buf != NULL) { - LOG_INFO("free init_frame_buf = %p\n", cmd_context->init_frame_buf); - ps3_dma_free_coherent(instance, - sizeof(struct PS3InitReqFrame), - cmd_context->init_frame_buf, - cmd_context->init_frame_buf_phys); + LOG_INFO("free init_frame_buf = %p\n", + cmd_context->init_frame_buf); + ps3_dma_free_coherent(instance, sizeof(struct PS3InitReqFrame), + cmd_context->init_frame_buf, + cmd_context->init_frame_buf_phys); cmd_context->init_frame_buf = NULL; } } -S32 ps3_drv_info_buf_alloc(struct ps3_instance *instance) +int ps3_drv_info_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - instance->drv_info_buf = - (U8*)ps3_dma_alloc_coherent(instance, - sizeof(struct PS3DrvInfo), - &instance->drv_info_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, &instance->drv_info_buf); + instance->drv_info_buf = (unsigned char *)ps3_dma_alloc_coherent( + instance, sizeof(struct PS3DrvInfo), + (unsigned long long *)&instance->drv_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_DRV_INFO_BUF_ALLOC, + &instance->drv_info_buf); if (instance->drv_info_buf == NULL) { LOG_ERROR("hno:%u Failed to alloc drv info dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; @@ -274,24 +285,25 @@ void ps3_drv_info_buf_free(struct ps3_instance *instance) if (instance->drv_info_buf != NULL) { LOG_INFO("drv_info_buf = %p\n", instance->drv_info_buf); ps3_dma_free_coherent(instance, sizeof(struct PS3DrvInfo), - instance->drv_info_buf, - instance->drv_info_buf_phys); + instance->drv_info_buf, + instance->drv_info_buf_phys); instance->drv_info_buf = NULL; } } -S32 ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) +int ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - instance->host_mem_info_buf = - (U8*)ps3_dma_alloc_coherent(instance, + instance->host_mem_info_buf = (unsigned char *)ps3_dma_alloc_coherent( + instance, (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), - &instance->host_mem_info_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, &instance->host_mem_info_buf); + (unsigned long long *)&instance->host_mem_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_HOST_MEM_BUF_ALLOC, + &instance->host_mem_info_buf); if (instance->host_mem_info_buf == NULL) { LOG_ERROR("hno:%u Failed to alloc host mem info dma buffer\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; @@ -300,27 +312,37 @@ S32 ps3_host_mem_info_buf_alloc(struct ps3_instance *instance) void ps3_host_mem_info_buf_free(struct ps3_instance *instance) { if (instance->host_mem_info_buf != NULL) { - LOG_INFO("free host_mem_info_buf = %p\n", instance->host_mem_info_buf); - ps3_dma_free_coherent(instance, (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), + LOG_INFO("free host_mem_info_buf = %p\n", + instance->host_mem_info_buf); + ps3_dma_free_coherent( + instance, + (sizeof(struct PS3HostMemInfo) * PS3_HOST_MEM_INFO_NUM), instance->host_mem_info_buf, instance->host_mem_info_buf_phys); instance->host_mem_info_buf = NULL; } } -S32 ps3_hard_reset_to_ready(struct ps3_instance *instance) +static int ps3_hard_reset_to_ready(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (instance->peer_instance != NULL) { - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context + ->parall_hardreset_state != + PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep( + PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { - ret = ps3_hard_recovery_request(instance); - if (ret != PS3_SUCCESS){ - LOG_WARN("hno:%u hard recovery request failed\n", + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); + if (ret != PS3_SUCCESS) { + LOG_WARN( + "hno:%u hard recovery request failed\n", PS3_HOST(instance)); goto l_out; } @@ -333,92 +355,89 @@ S32 ps3_hard_reset_to_ready(struct ps3_instance *instance) } ret = instance->ioc_adpter->ioc_hard_reset(instance); - if (ret == -PS3_FAILED) { + if (ret == -PS3_FAILED) goto l_out; - } INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, instance); - if ((ret = ps3_ioc_state_ready_wait(instance)) != PS3_SUCCESS) { + ret = ps3_ioc_state_ready_wait(instance); + if (ret != PS3_SUCCESS) goto l_out; - } } l_out: if (ret == PS3_SUCCESS) { LOG_WARN("hno:%u ps3 fw state reset to ready successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { - LOG_ERROR("hno:%u PS3 fw state reset to ready NOK \n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 fw state reset to ready NOK\n", + PS3_HOST(instance)); } return ret; } -S32 ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance) +int ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (!instance->ioc_adpter->ioc_hard_reset) { ret = -PS3_FAILED; goto l_out; } - if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { + if (instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_RECOVERY) { ret = instance->ioc_adpter->ioc_hard_reset(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } } INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F0, instance); - if ((ret = ps3_ioc_state_transfer_to_ready(instance)) != PS3_SUCCESS) { + ret = ps3_ioc_state_transfer_to_ready(instance); + if (ret != PS3_SUCCESS) goto l_out; - } l_out: if (ret == PS3_SUCCESS) { LOG_WARN("hno:%u ps3 fw state reset to ready successfully\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { - LOG_ERROR("hno:%u PS3 fw state reset to ready NOK \n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 fw state reset to ready NOK\n", + PS3_HOST(instance)); } return ret; } -S32 ps3_ioc_init_to_ready(struct ps3_instance *instance) +int ps3_ioc_init_to_ready(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - Bool is_unload_valid = PS3_FALSE; + int ret = PS3_SUCCESS; + unsigned char is_unload_valid = PS3_FALSE; INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING, instance); INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_RESUME_RECOVERY, instance); ret = ps3_ioc_state_transfer_to_ready(instance); - INJECT_START(PS3_ERR_IJ_FW_STATE_RUNNING, &ret) - if (ret == PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FW_STATE_RUNNING, &ret); + if (ret == PS3_SUCCESS) goto l_out; - } ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); - LOG_INFO("hno:%u PS3 fw state cannot directly init to ready successfully\n", + PS3_CMD_TRIGGER_UNLOAD); + LOG_INFO( + "hno:%u PS3 fw state cannot directly init to ready successfully\n", PS3_HOST(instance)); if (ret != -PS3_NO_RECOVERED) { - if(ps3_is_need_hard_reset(instance)) { + if (ps3_is_need_hard_reset(instance)) ret = ps3_hard_reset_to_ready(instance); - } } l_out: if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u PS3 fw state init to ready successfully\n", - PS3_HOST(instance)); - if (is_unload_valid) { + PS3_HOST(instance)); + if (is_unload_valid) ret = ps3_ioc_notify_unload(instance); - } - }else { + } else { LOG_ERROR("hno:%u PS3 fw state init to ready NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } return ret; @@ -427,22 +446,25 @@ S32 ps3_ioc_init_to_ready(struct ps3_instance *instance) static void ps3_drv_info_prepare(struct ps3_instance *instance) { struct PS3DrvInfo *drv_info = NULL; + drv_info = (struct PS3DrvInfo *)instance->drv_info_buf; memset(drv_info, 0, sizeof(struct PS3DrvInfo)); snprintf(drv_info->drvName, PS3_DRV_NAME_MAX_LEN, PS3_DRV_AUTHOR); - snprintf(drv_info->drvVersion, PS3_DRV_VERSION_MAX_LEN, PS3_DRV_VERSION); + snprintf(drv_info->drvVersion, PS3_DRV_VERSION_MAX_LEN, + PS3_DRV_VERSION); drv_info->domain_support = PS3_TRUE; - drv_info->domain = (U32)ps3_get_pci_domain(instance->pdev); + drv_info->domain = (unsigned int)ps3_get_pci_domain(instance->pdev); drv_info->bus = ps3_get_pci_bus(instance->pdev); drv_info->dev = PCI_SLOT(instance->pdev->devfn); drv_info->func = PCI_FUNC(instance->pdev->devfn); drv_info->compatVer = PS3_COMPAT_VER_1; LOG_DEBUG("hno:%u driver information dump:\n" - "\t drvName = %s, drvVersion = %s\n" - "\t domain = %x bus = %llx, dev = %x, func = %x\n", - PS3_HOST(instance), drv_info->drvName, drv_info->drvVersion, - drv_info->domain, drv_info->bus, drv_info->dev, drv_info->func); + "\t drvName = %s, drvVersion = %s\n" + "\t domain = %x bus = %llx, dev = %x, func = %x\n", + PS3_HOST(instance), drv_info->drvName, drv_info->drvVersion, + drv_info->domain, drv_info->bus, drv_info->dev, + drv_info->func); } static inline bool ps3_pgdat_is_empty(pg_data_t *pgdat) @@ -458,32 +480,33 @@ struct pglist_data *ps3_first_online_pgdat(void) struct pglist_data *ps3_next_online_pgdat(struct pglist_data *pgdat) { int nid = next_online_node(pgdat->node_id); - if (nid == MAX_NUMNODES) { + + if (nid == MAX_NUMNODES) return NULL; - } return NODE_DATA(nid); } -static Bool ps3_get_numa_mem_addr(struct ps3_instance *instance) +static unsigned char ps3_get_numa_mem_addr(struct ps3_instance *instance) { - Bool ret = PS3_FALSE; - S32 node = -1; + unsigned char ret = PS3_FALSE; + int node = -1; struct pglist_data *pgdata = NULL; + node = dev_to_node(&instance->pdev->dev); - if (node < 0) { + if (node < 0) goto l_out; - } pgdata = NODE_DATA(node); - if (pgdata == NULL || ps3_pgdat_is_empty(pgdata)) { + if (pgdata == NULL || ps3_pgdat_is_empty(pgdata)) goto l_out; - } instance->start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; instance->end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); - LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", - PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, - instance->so_start_addr, instance->so_end_addr); + LOG_INFO( + "host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", + PS3_HOST(instance), node, instance->start_pfn, + instance->end_pfn, instance->so_start_addr, + instance->so_end_addr); ret = PS3_TRUE; l_out: return ret; @@ -492,22 +515,26 @@ static Bool ps3_get_numa_mem_addr(struct ps3_instance *instance) static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) { struct pglist_data *pgdata = NULL; - S32 node = -1; - Bool is_in_range = PS3_FALSE; - U64 start_pfn = 0; - U64 end_pfn = 0; - if (ps3_get_numa_mem_addr(instance)) { + int node = -1; + unsigned char is_in_range = PS3_FALSE; + unsigned long long start_pfn = 0; + unsigned long long end_pfn = 0; + + if (ps3_get_numa_mem_addr(instance)) goto l_out; - } - for_each_ps3_online_pgdat(pgdata) { - if (ps3_pgdat_is_empty(pgdata)) { + for_each_ps3_online_pgdat(pgdata) + { + if (ps3_pgdat_is_empty(pgdata)) continue; - } start_pfn = pgdata->node_start_pfn << PAGE_SHIFT; end_pfn = ((pgdat_end_pfn(pgdata) << PAGE_SHIFT) - 1); INJECT_START(PS3_ERR_IJ_MOD_SO_ADDR, instance); - if (PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, instance->so_start_addr) >= start_pfn && - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(instance->dma_addr_bit_pos, instance->so_end_addr) <= end_pfn) { + if (PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + instance->dma_addr_bit_pos, + instance->so_start_addr) >= start_pfn && + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + instance->dma_addr_bit_pos, + instance->so_end_addr) <= end_pfn) { node = pgdata->node_id; is_in_range = PS3_TRUE; break; @@ -520,9 +547,11 @@ static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) instance->start_pfn = 0; instance->end_pfn = 0; } - LOG_INFO("host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", - PS3_HOST(instance), node, instance->start_pfn, instance->end_pfn, - instance->so_start_addr, instance->so_end_addr); + LOG_INFO( + "host_no:%u numa:%d, addr range:[0x%llx - 0x%llx], so addr range:[0x%llx - 0x%llx]\n", + PS3_HOST(instance), node, instance->start_pfn, + instance->end_pfn, instance->so_start_addr, + instance->so_end_addr); l_out: return; } @@ -530,6 +559,7 @@ static void ps3_get_all_numa_mem_addr(struct ps3_instance *instance) static void ps3_host_mem_info_prepare(struct ps3_instance *instance) { struct PS3HostMemInfo *host_mem_info = NULL; + host_mem_info = (struct PS3HostMemInfo *)instance->host_mem_info_buf; memset(host_mem_info, 0, sizeof(struct PS3HostMemInfo)); @@ -537,35 +567,35 @@ static void ps3_host_mem_info_prepare(struct ps3_instance *instance) host_mem_info->endAddr = instance->end_pfn; host_mem_info->type = PS3_MEM_TYPE_SO; LOG_DEBUG("hno:%u host mem info dump:\n" - "\t startAddr = 0x%llx, endAddr = 0x%llx, type = %u\n", - PS3_HOST(instance), host_mem_info->startAddr, host_mem_info->endAddr, - host_mem_info->type); + "\t startAddr = 0x%llx, endAddr = 0x%llx, type = %u\n", + PS3_HOST(instance), host_mem_info->startAddr, + host_mem_info->endAddr, host_mem_info->type); } static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) { - - struct ps3_cmd_context *cmd_context = &instance->cmd_context; - struct ps3_irq_context *irq_context = &instance->irq_context; - struct ps3_cmd_attr_context *cmd_attr = &instance->cmd_attr; - struct ps3_dump_context *dump_context = &instance->dump_context; - struct PS3InitReqFrame* init_frame_msg = NULL; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_irq_context *irq_context = &instance->irq_context; + struct ps3_cmd_attr_context *cmd_attr = &instance->cmd_attr; + struct ps3_dump_context *dump_context = &instance->dump_context; + struct PS3InitReqFrame *init_frame_msg = NULL; init_frame_msg = (struct PS3InitReqFrame *)cmd_context->init_frame_buf; - memset(&init_frame_msg->reqHead, 0, sizeof(PS3ReqFrameHead_s)); + memset(&init_frame_msg->reqHead, 0, sizeof(struct PS3ReqFrameHead)); init_frame_msg->reqHead.cmdType = PS3_CMD_INIT_IOC; init_frame_msg->reqHead.timeout = PS3_INIT_CMD_WAIT_MAX_TIMEOUT; - init_frame_msg->ver = 0; - init_frame_msg->length = sizeof(struct PS3InitReqFrame); - init_frame_msg->operater = PS3_CMD_OPERATOR_TYPE_HOST; - init_frame_msg->pageSize = (U8)cmd_attr->nvme_page_size; - init_frame_msg->msixVector = (U16)irq_context->valid_msix_vector_count; - init_frame_msg->pciIrqType = (U16)irq_context->pci_irq_type; - init_frame_msg->osType = PS3_LINUX_FRAME; + init_frame_msg->ver = 0; + init_frame_msg->length = sizeof(struct PS3InitReqFrame); + init_frame_msg->operater = PS3_CMD_OPERATOR_TYPE_HOST; + init_frame_msg->pageSize = (unsigned char)cmd_attr->nvme_page_size; + init_frame_msg->msixVector = + (unsigned short)irq_context->valid_msix_vector_count; + init_frame_msg->pciIrqType = (unsigned short)irq_context->pci_irq_type; + init_frame_msg->osType = PS3_LINUX_FRAME; - init_frame_msg->timeStamp = cpu_to_le64(ps3_1970_now_ms_get()); + init_frame_msg->timeStamp = cpu_to_le64(ps3_1970_now_ms_get()); init_frame_msg->reqFrameBufBaseAddr = cpu_to_le64(cmd_context->req_frame_buf_phys); @@ -575,53 +605,65 @@ static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) init_frame_msg->respFrameBaseAddr = cpu_to_le64(cmd_context->response_frame_buf_phys); - init_frame_msg->reqFrameMaxNum = (U16)cmd_context->max_cmd_count; - init_frame_msg->respFrameMaxNum = (U16)cmd_context->max_cmd_count; + init_frame_msg->reqFrameMaxNum = + (unsigned short)cmd_context->max_cmd_count; + init_frame_msg->respFrameMaxNum = + (unsigned short)cmd_context->max_cmd_count; init_frame_msg->bufSizePerRespFrame = PS3_RESP_FRAME_BUFFER_SIZE; - if(ps3_hil_mode_query() > HIL_MODEL_SW_ASSIST) - { + if (ps3_hil_mode_query() > HIL_MODEL_SW_ASSIST) init_frame_msg->hilMode = instance->hilMode; - }else{ - init_frame_msg->hilMode = (U8)ps3_hil_mode_query(); - } + else + init_frame_msg->hilMode = (unsigned char)ps3_hil_mode_query(); #ifndef _WINDOWS init_frame_msg->systemInfoBufAddr = cmd_context->init_frame_sys_info_phys; #endif if (!reset_devices) { - init_frame_msg->dumpDmaBufAddr = cpu_to_le64(dump_context->dump_dma_addr); - init_frame_msg->dumpDmaBufLen = cpu_to_le32(PS3_DUMP_DMA_BUF_SIZE); - init_frame_msg->dumpIsrSN = cpu_to_le32(irq_context->dump_isrSN); + init_frame_msg->dumpDmaBufAddr = + cpu_to_le64(dump_context->dump_dma_addr); + init_frame_msg->dumpDmaBufLen = + cpu_to_le32(PS3_DUMP_DMA_BUF_SIZE); + init_frame_msg->dumpIsrSN = + cpu_to_le32(irq_context->dump_isrSN); } #ifndef _WINDOWS init_frame_msg->debugMemArrayNum = cpu_to_le32(instance->debug_context.debug_mem_array_num); init_frame_msg->debugMemArrayAddr = (instance->debug_context.debug_mem_array_num != 0) ? - cpu_to_le64(instance->debug_context.debug_mem_buf_phy) : 0; + cpu_to_le64(instance->debug_context.debug_mem_buf_phy) : + 0; #endif - memset(cmd_context->init_filter_table_buff, 0, PS3_CMD_EXT_BUF_SIZE_MGR); + memset(cmd_context->init_filter_table_buff, 0, + PS3_CMD_EXT_BUF_SIZE_MGR); if (instance->ioc_adpter->event_filter_table_get != NULL) { - init_frame_msg->filterTableAddr = cpu_to_le64(cmd_context->init_filter_table_phy_addr); - init_frame_msg->filterTableLen = cpu_to_le32(PS3_CMD_EXT_BUF_SIZE_MGR); - instance->ioc_adpter->event_filter_table_get(cmd_context->init_filter_table_buff); + init_frame_msg->filterTableAddr = + cpu_to_le64(cmd_context->init_filter_table_phy_addr); + init_frame_msg->filterTableLen = + cpu_to_le32(PS3_CMD_EXT_BUF_SIZE_MGR); + instance->ioc_adpter->event_filter_table_get( + cmd_context->init_filter_table_buff); } ps3_drv_info_prepare(instance); - init_frame_msg->drvInfoBufAddr = cpu_to_le64(instance->drv_info_buf_phys); + init_frame_msg->drvInfoBufAddr = + cpu_to_le64(instance->drv_info_buf_phys); init_frame_msg->drvInfoBufLen = cpu_to_le16(sizeof(struct PS3DrvInfo)); ps3_get_all_numa_mem_addr(instance); if (instance->end_pfn != 0) { ps3_host_mem_info_prepare(instance); - init_frame_msg->hostMemInfoBaseAddr = cpu_to_le64(instance->host_mem_info_buf_phys); - init_frame_msg->hostMemInfoNum = cpu_to_le32(PS3_HOST_MEM_INFO_NUM); + init_frame_msg->hostMemInfoBaseAddr = + cpu_to_le64(instance->host_mem_info_buf_phys); + init_frame_msg->hostMemInfoNum = + cpu_to_le32(PS3_HOST_MEM_INFO_NUM); } else { init_frame_msg->hostMemInfoBaseAddr = 0; init_frame_msg->hostMemInfoNum = 0; } - LOG_DEBUG("hno:%u init frame information dump:\n" + LOG_DEBUG( + "hno:%u init frame information dump:\n" "\t initFramePhysicAddr = 0x%llx, initFrameLen = %d, version = %d\n" "\t pciIrqType = %d, msixVectorCount = %d, reqHead.cmdType = %d\n" "\t reqFrameBufBase = 0x%llx, reqFrameMaxNum = %d\n" @@ -630,23 +672,29 @@ static void ps3_ioc_init_cmd_prepare(struct ps3_instance *instance) "\t filterTableAddr = 0x%llx, filterTableLen = %d\n" "\t drvInfoBufAddr = 0x%llx, drvInfoBufLen = %d\n" "\t hostMemInfoBaseAddr = 0x%llx, hostMemInfoNum = %d, function = %d\n", - PS3_HOST(instance), cpu_to_le64(cmd_context->init_frame_buf_phys), + PS3_HOST(instance), + cpu_to_le64(cmd_context->init_frame_buf_phys), init_frame_msg->length, init_frame_msg->ver, - init_frame_msg->pciIrqType, init_frame_msg->msixVector, init_frame_msg->reqHead.cmdType, - init_frame_msg->reqFrameBufBaseAddr, init_frame_msg->reqFrameMaxNum, - init_frame_msg->respFrameBaseAddr, init_frame_msg->reqFrameMaxNum, init_frame_msg->bufSizePerRespFrame, - init_frame_msg->replyFifoDescBaseAddr, init_frame_msg->systemInfoBufAddr, + init_frame_msg->pciIrqType, init_frame_msg->msixVector, + init_frame_msg->reqHead.cmdType, + init_frame_msg->reqFrameBufBaseAddr, + init_frame_msg->reqFrameMaxNum, + init_frame_msg->respFrameBaseAddr, + init_frame_msg->reqFrameMaxNum, + init_frame_msg->bufSizePerRespFrame, + init_frame_msg->replyFifoDescBaseAddr, + init_frame_msg->systemInfoBufAddr, init_frame_msg->filterTableAddr, init_frame_msg->filterTableLen, init_frame_msg->drvInfoBufAddr, init_frame_msg->drvInfoBufLen, - init_frame_msg->hostMemInfoBaseAddr, init_frame_msg->hostMemInfoNum, ps3_get_pci_function(instance->pdev)); - - return; + init_frame_msg->hostMemInfoBaseAddr, + init_frame_msg->hostMemInfoNum, + ps3_get_pci_function(instance->pdev)); } -static S32 ps3_ioc_init_cmd_proc(struct ps3_instance *instance) +static int ps3_ioc_init_cmd_proc(struct ps3_instance *instance) { struct PS3MgrEvent *event_req_info = &instance->event_req_info; - struct ps3_cmd_context *cmd_context = &instance->cmd_context; + struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct PS3InitReqFrame *init_frame_msg = NULL; ps3_ioc_init_cmd_prepare(instance); @@ -657,62 +705,69 @@ static S32 ps3_ioc_init_cmd_proc(struct ps3_instance *instance) init_frame_msg->respStatus = U32_MAX; ps3_all_reply_fifo_init(instance); - LOG_WARN("hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", PS3_HOST(instance), - cmd_context->init_frame_buf_phys, - (U64)cmd_context->init_frame_buf_phys + offsetof(struct PS3InitReqFrame, respStatus)); + LOG_WARN( + "hno:%u start to send init cmd![init:0x%llx, respstats:0x%llx]\n", + PS3_HOST(instance), + (unsigned long long)cmd_context->init_frame_buf_phys, + (unsigned long long)cmd_context->init_frame_buf_phys + + offsetof(struct PS3InitReqFrame, respStatus)); return ps3_ioc_init_cmd_issue(instance, init_frame_msg); } -S32 ps3_ioc_init_proc(struct ps3_instance *instance) +int ps3_ioc_init_proc(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 state = PS3_FW_STATE_UNDEFINED; - S32 retry = 0; + int ret = PS3_SUCCESS; + int state = PS3_FW_STATE_UNDEFINED; + int retry = 0; ps3_ioc_can_hardreset_set(instance, PS3_IOC_CANNOT_HARDRESET); while (retry < PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) { ret = ps3_ioc_init_cmd_proc(instance); - INJECT_START(PS3_ERR_IJ_INIT_CMD_PROC_FAIL, &ret) - if (ret != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_INIT_CMD_PROC_FAIL, &ret); + if (ret != PS3_SUCCESS) goto l_clean; - } - INJECT_START(PS3_ERR_IJ_FORCE_INIT_RUNNING_FAIL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_INIT_RUNNING_FAIL, instance); - INJECT_START(PS3_ERR_IJ_RECOVERY_F1_RUNNING, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_F1_RUNNING, instance); ret = ps3_ioc_state_transfer_wait_to_running(instance); - INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret) + INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret); if (ret != PS3_SUCCESS) { - if (ret == -PS3_IN_PCIE_ERR) { + if (ret == -PS3_IN_PCIE_ERR) goto l_out; - } goto l_clean; } goto l_out; - l_clean: +l_clean: state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret) - INJECT_START(PS3_ERR_IJ_IOC_INIT_PROC_STATE_RUNNING, &state) - INJECT_START(PS3_ERR_IJ_INIT_PROC_FAIL_NOUNLOAD, &state) - if(state == PS3_FW_STATE_WAIT || - state == PS3_FW_STATE_RUNNING){ - if (ps3_soc_unload(instance, PS3_TRUE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) == PS3_SUCCESS) { - LOG_INFO("device[%d] unload success,exit init proc.\n", instance->pdev->dev.id); + INJECT_START(PS3_ERR_IJ_IOC_STATE_WAIT_TO_RUNNING_FAIL, &ret); + INJECT_START(PS3_ERR_IJ_IOC_INIT_PROC_STATE_RUNNING, &state); + INJECT_START(PS3_ERR_IJ_INIT_PROC_FAIL_NOUNLOAD, &state); + if (state == PS3_FW_STATE_WAIT || + state == PS3_FW_STATE_RUNNING) { + if (ps3_soc_unload(instance, PS3_TRUE, + PS3_UNLOAD_SUB_TYPE_REMOVE, + PS3_SUSPEND_TYPE_NONE) == + PS3_SUCCESS) { + LOG_INFO( + "device[%d] unload success,exit init proc.\n", + instance->pdev->dev.id); retry++; continue; } } ret = ps3_init_fail_hard_reset_with_doorbell(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", instance->pdev->dev.id); + LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", + instance->pdev->dev.id); goto l_out; } retry++; } - if (retry == PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) { + if (retry == PS3_IOC_INIT_PROC_FAIL_RETRY_COUNT) ret = -PS3_FAILED; - } - LOG_INFO("device[%d] doorbell success,exit init proc [%d].\n", instance->pdev->dev.id, ret); + LOG_INFO("device[%d] doorbell success,exit init proc [%d].\n", + instance->pdev->dev.id, ret); l_out: return ret; @@ -721,34 +776,32 @@ S32 ps3_ioc_init_proc(struct ps3_instance *instance) void ps3_ioc_legacy_irqs_enable(struct ps3_instance *instance) { LOG_INFO("hno:%u Enable legacy!\n", PS3_HOST(instance)); -#ifndef _WINDOWS +#ifndef _WINDOWS pci_intx(instance->pdev, 1); #else ps3_pci_intx(instance, 1); #endif - return; } void ps3_ioc_legacy_irqs_disable(struct ps3_instance *instance) { LOG_INFO("hno:%u Disable legacy!\n", PS3_HOST(instance)); -#ifndef _WINDOWS +#ifndef _WINDOWS pci_intx(instance->pdev, 0); #else ps3_pci_intx(instance, 0); #endif - return; } void ps3_ioc_msi_enable(struct ps3_instance *instance) { - U32 pos = 0; - U16 control = 0; + unsigned int pos = 0; + unsigned short control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSI); if (pos == 0) { LOG_INFO("hno:%u Find PCI_CAP_ID_MSI failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -756,21 +809,19 @@ void ps3_ioc_msi_enable(struct ps3_instance *instance) if (!(control & PCI_MSI_FLAGS_ENABLE)) { LOG_INFO("hno:%u Enable Msi!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSI_FLAGS, - control | PCI_MSI_FLAGS_ENABLE); + control | PCI_MSI_FLAGS_ENABLE); } - - return; } void ps3_ioc_msi_disable(struct ps3_instance *instance) { - U32 pos = 0; - U16 control = 0; + unsigned int pos = 0; + unsigned short control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSI); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSI failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -778,22 +829,19 @@ void ps3_ioc_msi_disable(struct ps3_instance *instance) if (control & PCI_MSI_FLAGS_ENABLE) { LOG_INFO("hno:%u Disable Msi!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSI_FLAGS, - control & ~PCI_MSI_FLAGS_ENABLE); + control & ~PCI_MSI_FLAGS_ENABLE); } - - return; - } void ps3_ioc_msix_enable(struct ps3_instance *instance) { - U32 pos = 0; - U16 control = 0; + unsigned int pos = 0; + unsigned short control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSIX); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSIX failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -801,21 +849,19 @@ void ps3_ioc_msix_enable(struct ps3_instance *instance) if (!(control & PCI_MSIX_FLAGS_ENABLE)) { LOG_INFO("hno:%u Enable Msix!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSIX_FLAGS, - control | PCI_MSIX_FLAGS_ENABLE); + control | PCI_MSIX_FLAGS_ENABLE); } - - return; } void ps3_ioc_msix_disable(struct ps3_instance *instance) { - U32 pos = 0; - U16 control = 0; + unsigned int pos = 0; + unsigned short control = 0; pos = ps3_pci_find_capability(instance, PCI_CAP_ID_MSIX); if (pos == 0) { LOG_ERROR("hno:%u Find PCI_CAP_ID_MSIX failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return; } @@ -823,28 +869,26 @@ void ps3_ioc_msix_disable(struct ps3_instance *instance) if (control & PCI_MSIX_FLAGS_ENABLE) { LOG_INFO("hno:%u disable Msix!\n", PS3_HOST(instance)); ps3_pci_write_config_word(instance, pos + PCI_MSIX_FLAGS, - control & ~PCI_MSIX_FLAGS_ENABLE); + control & ~PCI_MSIX_FLAGS_ENABLE); } - - return; } -Bool ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) +unsigned char ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) { - U16 status = 0; - Bool is_legacy_irq_existed = PS3_FALSE; + unsigned short status = 0; + unsigned char is_legacy_irq_existed = PS3_FALSE; ps3_pci_read_config_word(instance, PCI_COMMAND, &status); if (status & PCI_COMMAND_INTX_DISABLE) { LOG_INFO("hno:%u Legacy irq is disabled!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ps3_pci_read_config_word(instance, PCI_STATUS, &status); if (status & PCI_STATUS_INTERRUPT) { LOG_INFO("hno:%u Legacy irq is existed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); is_legacy_irq_existed = PS3_TRUE; } @@ -853,20 +897,20 @@ Bool ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance) } void ps3_ioc_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; PS3_CMD_WORD_STAT_INC(instance, cmd_word); - cmd_word_default = (union PS3DefaultCmdWord *) cmd_word; + cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; #ifdef PS3_SUPPORT_INJECT - if(ps3_add_cmd_filter(instance, cmd_word)) { + if (ps3_add_cmd_filter(instance, cmd_word)) goto l_out; - } #endif - PS3_IOC_REG_WRITE(instance, cmd_fifo.request_fifo, ps3RequestQueue, cmd_word_default->words); + PS3_IOC_REG_WRITE(instance, cmd_fifo.request_fifo, ps3RequestQueue, + cmd_word_default->words); #ifdef PS3_SUPPORT_INJECT l_out: return; @@ -874,25 +918,27 @@ void ps3_ioc_cmd_send(struct ps3_instance *instance, } void ps3_ioc_scsi_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; PS3_CMD_WORD_STAT_INC(instance, cmd_word); cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; - if(instance->is_pci_reset == PS3_FALSE) { + if (instance->is_pci_reset == PS3_FALSE) { ps3_ioc_reg_write(instance, cmd_word_default->words, - &instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue); + &instance->reg_set->cmd_fifo.request_fifo + .ps3RequestQueue); } else { LOG_FILE_ERROR("hno:%u register %p,write blocked by pci err\n", - PS3_HOST(instance), - &instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue); + PS3_HOST(instance), + &instance->reg_set->cmd_fifo.request_fifo + .ps3RequestQueue); } } void ps3_switch_normal_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3CmdWordU32 cmd_word_u32; union PS3DefaultCmdWord cmd_word_default; @@ -905,69 +951,84 @@ void ps3_switch_normal_cmd_send(struct ps3_instance *instance, cmd_word_u32.cmdWord.cmdFrameID = cmd_word->cmdFrameID; cmd_word_u32.cmdWord.type = cmd_word->type; cmd_word_u32.cmdWord.isrSN = cmd_word->isrSN; - cmd_word_u32.cmdWord.noReplyWord = cmd->req_frame->frontendReq.reqHead.noReplyWord; + cmd_word_u32.cmdWord.noReplyWord = + cmd->req_frame->frontendReq.reqHead.noReplyWord; cmd_word_default.words = 0; cmd_word_default.u.low = cmd_word_u32.val; - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, reserved0, cmd_word_default.words); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, reserved0, + cmd_word_default.words); } void ps3_switch_init_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word) + struct PS3CmdWord *cmd_word) { union PS3DefaultCmdWord *cmd_word_default = NULL; + PS3_CMD_WORD_STAT_INC(instance, cmd_word); - cmd_word_default = (union PS3DefaultCmdWord *) cmd_word; + cmd_word_default = (union PS3DefaultCmdWord *)cmd_word; ps3_atomic_inc(&(instance)->reg_op_count); - mb(); - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { - PS3_REG_SESSION_ADDR_WRITE(instance, cmd_word_default->words, + mb(); /* in order to force CPU ordering */ + if ((instance)->is_hard_reset == PS3_FALSE && + (instance)->is_pci_reset == PS3_FALSE) { + PS3_REG_SESSION_ADDR_WRITE( + instance, cmd_word_default->words, &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr); } else { - LOG_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", - PS3_HOST(instance), &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr, + LOG_ERROR( + "hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", + PS3_HOST(instance), + &instance->reg_set->reg_f.Excl_reg.ps3SessioncmdAddr, (instance)->is_hard_reset, instance->is_pci_reset); } ps3_atomic_dec(&(instance)->reg_op_count); - LOG_DEBUG("hno:%u init command: cmd.words = 0x%llx, " - "session_reg_offset = %#lx\n", PS3_HOST(instance), - cmd_word_default->words, - offsetof(HilReg0Ps3RegisterF_s, ps3SessioncmdAddr)); + LOG_DEBUG("hno:%u init qommand: cmd.words = 0x%llx, session_reg_offset = %#lx\n", + PS3_HOST(instance), cmd_word_default->words, + (unsigned long)offsetof(struct HilReg0Ps3RegisterF, + ps3SessioncmdAddr)); } #ifndef _WINDOWS -U64 ps3_switch_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg) +unsigned long long ps3_switch_ioc_reg_read(struct ps3_instance *instance, + void __iomem *reg) { - U64 value = 0; - U64 addr = (U64)reg; - value = (((U64)readl((void*)(addr + 0x4UL)) << 32) | (U64)readl(reg)); + unsigned long long value = 0; - if (&instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue == reg) { - reg = (void __iomem *)((U64)reg - PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET); - } + value = (((unsigned long long)readl(reg + 0x4UL) << 32) | + (unsigned long long)readl(reg)); + if (&instance->reg_set->cmd_fifo.request_fifo.ps3RequestQueue == reg) + reg = reg - PS3_REG_SWITCH_QEQUEST_QUEUE_OFFSET; ps3_reg_dump(instance, reg, value, PS3_TRUE); return value; } #endif inline void ps3_ioc_reg_write(struct ps3_instance *instance, - U64 val, void __iomem *reg) + unsigned long long val, void __iomem *reg) { +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) ps3_reg_dump(instance, reg, val, PS3_FALSE); +#endif + if (instance->ioc_adpter->reg_write) { instance->ioc_adpter->reg_write(instance, val, reg); } else { - LOG_FILE_ERROR("hno:%u no register write\n", PS3_HOST(instance)); + LOG_FILE_ERROR("hno:%u no register write\n", + PS3_HOST(instance)); } } void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, - U64 val, void __iomem *reg, Bool is_warn_prk) + unsigned long long val, void __iomem *reg, + unsigned char is_warn_prk) { ps3_reg_dump(instance, reg, val, PS3_FALSE); if (instance->ioc_adpter->reg_write) { if (is_warn_prk) { - LOG_WARN("hno:%u register write reset,val:0x%llx,reg=%p\n", - PS3_HOST(instance),val,reg); + LOG_WARN( + "hno:%u register write reset,val:0x%llx,reg=%p\n", + PS3_HOST(instance), val, reg); } instance->ioc_adpter->reg_write(instance, val, reg); } else { @@ -975,38 +1036,40 @@ void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, } } -inline U64 ps3_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg) +inline unsigned long long ps3_ioc_reg_read(struct ps3_instance *instance, + void __iomem *reg) { - U64 value = 0; - if (instance->ioc_adpter->reg_read) { + unsigned long long value = 0; + + if (instance->ioc_adpter->reg_read) value = instance->ioc_adpter->reg_read(instance, reg); - } else { + else LOG_ERROR("hno:%u no register read\n", PS3_HOST(instance)); - } ps3_reg_dump(instance, reg, value, PS3_TRUE); return value; } -U64 ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, void __iomem *reg) +unsigned long long ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, + void __iomem *reg) { - U64 value = 0; - if (instance->ioc_adpter->reg_read) { + unsigned long long value = 0; + + if (instance->ioc_adpter->reg_read) value = instance->ioc_adpter->reg_read(instance, reg); - } else { + else LOG_ERROR("hno:%u no register read\n", PS3_HOST(instance)); - } return value; } -inline U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, - void __iomem *reg) +inline unsigned long long +ps3_ioc_reg_read_with_check(struct ps3_instance *instance, void __iomem *reg) { - U8 try_count = 0; - U64 reg_value = ps3_ioc_reg_read(instance, reg); + unsigned char try_count = 0; + unsigned long long reg_value = ps3_ioc_reg_read(instance, reg); while (reg_value == U64_MAX && - try_count != PS3_REG_READ_MAX_TRY_COUNT) { + try_count != PS3_REG_READ_MAX_TRY_COUNT) { ps3_msleep(PS3_REG_READ_INTERVAL_MS); try_count++; reg_value = ps3_ioc_reg_read(instance, reg); @@ -1015,15 +1078,16 @@ inline U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, return reg_value; } -static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, - void __iomem *reg) +static unsigned long long ps3_ioc_reg_safe_read(struct ps3_instance *instance, + void __iomem *reg) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - U32 count = 0; - U32 retry_cnt = 0; - U64 tmp_value = U64_MAX; - U64 value = U64_MAX; - Bool is_first = PS3_TRUE; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + unsigned int count = 0; + unsigned int retry_cnt = 0; + unsigned long long tmp_value = U64_MAX; + unsigned long long value = U64_MAX; + unsigned char is_first = PS3_TRUE; + for (; retry_cnt < PS3_REG_READ_SAFE_RETRY_NUM; retry_cnt++) { tmp_value = ps3_ioc_reg_read_with_check(instance, reg); INJECT_START(PS3_ERR_IJ_REG_READ_ERR, &tmp_value); @@ -1036,17 +1100,23 @@ static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); if (!ps3_ioc_state_valid_check(fw_cur_state)) { for (; count < PS3_REG_READ_RETRY_NUM; count++) { - fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, &fw_cur_state); - INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, &fw_cur_state); + fw_cur_state = + instance->ioc_adpter->ioc_state_get( + instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED1, + &fw_cur_state); + INJECT_START(PS3_ERR_IJ_IOC_TO_CRITICAL, + &fw_cur_state); if (ps3_ioc_state_valid_check(fw_cur_state)) { - value = ps3_ioc_reg_read_with_check(instance, reg); + value = ps3_ioc_reg_read_with_check( + instance, reg); goto l_out; } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); } value = U64_MAX; - LOG_WARN_LIM("hno:%u wait ioc to vaild state NOK\n", PS3_HOST(instance)); + LOG_WARN_LIM("hno:%u wait ioc to valid state NOK\n", + PS3_HOST(instance)); goto l_out; } if (is_first) { @@ -1056,7 +1126,8 @@ static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, } INJECT_START(PS3_ERR_IJ_REG_READ_ZERO, &tmp_value); if (value != tmp_value) { - LOG_WARN_LIM("hno:%u reg value not equal old-new[%llu, %llu]\n", + LOG_WARN_LIM( + "hno:%u reg value not equal old-new[%llu, %llu]\n", PS3_HOST(instance), value, tmp_value); value = U64_MAX; goto l_out; @@ -1067,41 +1138,48 @@ static U64 ps3_ioc_reg_safe_read(struct ps3_instance *instance, return value; } -U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg) +unsigned long long ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, + void __iomem *reg) { - U32 retry_cnt = PS3_REG_READ_SAFE_RETRY_NUM; - U64 reg_value = 0; + unsigned int retry_cnt = PS3_REG_READ_SAFE_RETRY_NUM; + unsigned long long reg_value = 0; + while (retry_cnt--) { reg_value = ps3_ioc_reg_safe_read(instance, reg); - if (reg_value != U64_MAX) { + if (reg_value != U64_MAX) break; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); } return reg_value; } -Bool ps3_feature_support_reg_get(struct ps3_instance *instance) +unsigned char ps3_feature_support_reg_get(struct ps3_instance *instance) { - Bool ret = PS3_FALSE; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + unsigned char ret = PS3_FALSE; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3FeatureSupport, value); INJECT_START(PS3_ERR_IJ_FEATURE_REG_READ_ERR, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; - instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); - instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); - instance->is_deep_soft_recovery_support = (ps3_feature_support->reg.deepSoftRecoverySupport == 1); - instance->is_hard_recovery_support = (ps3_feature_support->reg.hardRecoverySupport == 1); - instance->cmd_context.sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_ioc_halt_support = + (ps3_feature_support->reg.fwHaltSupport == 1); + instance->is_shallow_soft_recovery_support = + (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); + instance->is_deep_soft_recovery_support = + (ps3_feature_support->reg.deepSoftRecoverySupport == 1); + instance->is_hard_recovery_support = + (ps3_feature_support->reg.hardRecoverySupport == 1); + instance->cmd_context.sgl_mode_support = + (ps3_feature_support->reg.sglModeSupport == 1); ret = PS3_TRUE; l_out: return ret; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h index 8bd6a820d32a..d92400b23260 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_manager.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IOC_MANAGER_H_ #define _PS3_IOC_MANAGER_H_ @@ -6,212 +6,287 @@ #include "ps3_inner_data.h" #include "ps3_module_para.h" #include "ps3_ioc_state.h" -#ifndef _WINDOWS -#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ - do { \ - ps3_reg_dump(instance, reg, val, PS3_FALSE); \ - writeq(val, reg); \ - } while(0) -#else -#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ + +#define PS3_REG_SESSION_ADDR_WRITE(instance, val, reg) \ do { \ - ps3_reg_dump(instance, reg, val, PS3_FALSE); \ - ps3_ioc_reg_write(instance, val, reg); \ - } while(0) -#endif + ps3_reg_dump(instance, reg, val, PS3_FALSE); \ + ps3_ioc_reg_write(instance, val, reg); \ + } while (0) -#define PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES (100) -#define PS3_REG_READ_INTERVAL_MS (10) +#define PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES (100) +#define PS3_REG_READ_INTERVAL_MS (10) #if (defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) -#define PS3_REG_WRITE_RETRY_NUM (60) +#define PS3_REG_WRITE_RETRY_NUM (60) #else -#define PS3_REG_WRITE_RETRY_NUM (10) +#define PS3_REG_WRITE_RETRY_NUM (10) #endif -#define PS3_REG_WRITE_INTERVAL_MS (10) -#define PS3_REG_READ_RETRY_NUM (5000) +#define PS3_REG_WRITE_INTERVAL_MS (10) +#define PS3_REG_READ_RETRY_NUM (5000) #define PS3_ATU_SUPPORT_READ_RETRY_NUM (3) #define PS3_REG_READ_SAFE_RETRY_NUM (3) #define PS3_HOST_MEM_INFO_NUM (1) -#define PS3_IOC_STATE_HALT_SUPPORT(ins) \ - (ins->is_ioc_halt_support) +#define PS3_IOC_STATE_HALT_SUPPORT(ins) (ins->is_ioc_halt_support) -#define PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(ins) \ +#define PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(ins) \ (ins->is_shallow_soft_recovery_support) -#define PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(ins) \ - ((ins->is_deep_soft_recovery_support) && ps3_deep_soft_reset_enable_query()) - -#define PS3_IOC_HARD_RECOVERY_SUPPORT(ins) \ - (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(ins) || \ - ins->is_hard_recovery_support) - -#define PS3_HALT_CLI_SUPPORT(ins) \ - (ins->is_halt_support_cli) - -#define PS3_IOC_REG_READ_WITH_CHECK(instance, reg_type, reg_name, read_value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read_with_check(instance, &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR("hno:%u register %p,read blocked by hardreset(%d) or pci err(%d)\n", \ - PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, (instance)->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0); - -#define PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_type, reg_name, read_value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_retry_safe_read(instance, &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR("hno:%u register %p,read blocked by hardreset(%d) or pci err(%d)\n", \ - PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, (instance)->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0); - -#define PS3_IOC_REG_READ_OFFSET(instance, offset, read_value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read(instance, (U8 *)(instance)->reg_set + (offset)); \ - } else { \ - LOG_FILE_ERROR("hno:%u register %p, read blocked by hardreset(%d) or pci err(%d)\n", \ - PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0); - -#define PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, offset, read_value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - read_value = ps3_ioc_reg_read_with_check(instance, (U8 *)(instance)->reg_set + (offset)); \ - } else { \ - LOG_WARN("hno:%u register %p, read blocked by hardreset(%d) or pci recovery(%d)\n", \ - PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - read_value = U64_MAX; \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0); - -#define PS3_IOC_REG_WRITE(instance, reg_type, reg_name, value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write(instance, value, &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_FILE_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci err(%d)\n", \ - PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0) - -#define PS3_IOC_REG_WRITE_OFFSET(instance, offset, value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write(instance, value, (U8 *)(instance)->reg_set + (offset)); \ - } else { \ - LOG_FILE_ERROR("hno:%u register %p,write blocked by hardreset(%d) or pci err(%d)\n", \ - PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0) - -#define PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_type, reg_name, value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write_with_check(instance, value, &(instance)->reg_set->reg_type.reg_name); \ - } else { \ - LOG_WARN("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", \ - PS3_HOST(instance), &(instance)->reg_set->reg_type.reg_name, \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0) - -#define PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, offset, value) do {\ - ps3_atomic_inc(&(instance)->reg_op_count); \ - mb(); \ - if((instance)->is_hard_reset == PS3_FALSE && (instance)->is_pci_reset == PS3_FALSE) { \ - ps3_ioc_reg_write_with_check(instance, value, (U8 *)(instance)->reg_set + (offset)); \ - } else { \ - LOG_WARN("hno:%u register %p,write blocked by hardreset(%d) or pci recovery(%d)\n", \ - PS3_HOST(instance), (U8 *)(instance)->reg_set + (offset), \ - (instance)->is_hard_reset, instance->is_pci_reset); \ - } \ - ps3_atomic_dec(&(instance)->reg_op_count); \ -} while(0) - -S32 ps3_ioc_init_cmd_context_init(struct ps3_instance *instance); +#define PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(ins) \ + ((ins->is_deep_soft_recovery_support) && \ + ps3_deep_soft_reset_enable_query()) + +#define PS3_IOC_HARD_RECOVERY_SUPPORT(ins) \ + (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(ins) || \ + ins->is_hard_recovery_support) + +#define PS3_HALT_CLI_SUPPORT(ins) (ins->is_halt_support_cli) + +#define PS3_IOC_REG_READ_WITH_CHECK(instance, reg_type, reg_name, read_value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read_with_check( \ + instance, \ + &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR( \ + "hno:%u register %p,read blocked by hardreset(%d)\n" \ + "\tor pci err(%d)\n", \ + PS3_HOST(instance), \ + &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, \ + (instance)->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_type, reg_name, \ + read_value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_retry_safe_read( \ + instance, \ + &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR( \ + "hno:%u register %p,read blocked by hardreset(%d)\n" \ + "\tor pci err(%d)\n", \ + PS3_HOST(instance), \ + &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, \ + (instance)->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_READ_OFFSET(instance, offset, read_value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read( \ + instance, \ + (unsigned char *)(instance)->reg_set + \ + (offset)); \ + } else { \ + LOG_FILE_ERROR( \ + "hno:%u register %p, read blocked by hardreset(%d)\n" \ + "\tor pci err(%d)\n", \ + PS3_HOST(instance), \ + (unsigned char *)(instance)->reg_set + \ + (offset), \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_READ_OFFSET_WITCH_CHECK(instance, offset, read_value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + read_value = ps3_ioc_reg_read_with_check( \ + instance, \ + (unsigned char *)(instance)->reg_set + \ + (offset)); \ + } else { \ + LOG_WARN( \ + "hno:%u register %p, read blocked by hardreset(%d)\n" \ + "\tor pci recovery(%d)\n", \ + PS3_HOST(instance), \ + (unsigned char *)(instance)->reg_set + \ + (offset), \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + read_value = U64_MAX; \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_WRITE(instance, reg_type, reg_name, value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write( \ + instance, value, \ + &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_FILE_ERROR( \ + "hno:%u register %p,write blocked by hardreset(%d)\n" \ + "\tor pci err(%d)\n", \ + PS3_HOST(instance), \ + &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_WRITE_OFFSET(instance, offset, value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write( \ + instance, value, \ + (unsigned char *)(instance)->reg_set + \ + (offset)); \ + } else { \ + LOG_FILE_ERROR( \ + "hno:%u register %p,write blocked by hardreset(%d)\n" \ + "\tor pci err(%d)\n", \ + PS3_HOST(instance), \ + (unsigned char *)(instance)->reg_set + \ + (offset), \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_type, reg_name, value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write_with_check( \ + instance, value, \ + &(instance)->reg_set->reg_type.reg_name); \ + } else { \ + LOG_WARN( \ + "hno:%u register %p,write blocked by hardreset(%d)\n" \ + "\tor pci recovery(%d)\n", \ + PS3_HOST(instance), \ + &(instance)->reg_set->reg_type.reg_name, \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +#define PS3_IOC_REG_WRITE_OFFSET_WITH_CHECK(instance, offset, value) \ + do { \ + ps3_atomic_inc(&(instance)->reg_op_count); \ + mb(); /* in order to force CPU ordering */ \ + if ((instance)->is_hard_reset == PS3_FALSE && \ + (instance)->is_pci_reset == PS3_FALSE) { \ + ps3_ioc_reg_write_with_check( \ + instance, value, \ + (unsigned char *)(instance)->reg_set + \ + (offset)); \ + } else { \ + LOG_WARN( \ + "hno:%u register %p,write blocked by hardreset(%d)\n" \ + "\tor pci recovery(%d)\n", \ + PS3_HOST(instance), \ + (unsigned char *)(instance)->reg_set + \ + (offset), \ + (instance)->is_hard_reset, \ + instance->is_pci_reset); \ + } \ + ps3_atomic_dec(&(instance)->reg_op_count); \ + } while (0) + +int ps3_ioc_init_cmd_context_init(struct ps3_instance *instance); void ps3_ioc_init_cmd_context_exit(struct ps3_instance *instance); void ps3_ioc_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_switch_init_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_switch_normal_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); void ps3_ioc_legacy_irqs_enable(struct ps3_instance *instance); void ps3_ioc_legacy_irqs_disable(struct ps3_instance *instance); void ps3_ioc_msi_enable(struct ps3_instance *instance); void ps3_ioc_msi_disable(struct ps3_instance *instance); void ps3_ioc_msix_enable(struct ps3_instance *instance); void ps3_ioc_msix_disable(struct ps3_instance *instance); -Bool ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance); -S32 ps3_drv_info_buf_alloc(struct ps3_instance *instance); +unsigned char ps3_ioc_is_legacy_irq_existed(struct ps3_instance *instance); +int ps3_drv_info_buf_alloc(struct ps3_instance *instance); void ps3_drv_info_buf_free(struct ps3_instance *instance); -S32 ps3_host_mem_info_buf_alloc(struct ps3_instance *instance); +int ps3_host_mem_info_buf_alloc(struct ps3_instance *instance); void ps3_host_mem_info_buf_free(struct ps3_instance *instance); -S32 ps3_ioc_init_to_ready(struct ps3_instance *instance); +int ps3_ioc_init_to_ready(struct ps3_instance *instance); + +int ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance); -S32 ps3_ioc_hard_reset_to_ready(struct ps3_instance *instance); +int ps3_ioc_init_proc(struct ps3_instance *instance); -S32 ps3_ioc_init_proc(struct ps3_instance *instance); +void ps3_ioc_reg_write(struct ps3_instance *instance, unsigned long long val, + void __iomem *reg); -void ps3_ioc_reg_write(struct ps3_instance *instance, U64 val, - void __iomem *reg); void ps3_ioc_hardreset_reg_write(struct ps3_instance *instance, - U64 val, void __iomem *reg, Bool is_warn_prk); -U64 ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, - void __iomem *reg); -U64 ps3_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg); + unsigned long long val, void __iomem *reg, + unsigned char is_warn_prk); -U64 ps3_ioc_reg_read_with_check(struct ps3_instance *instance, - void __iomem *reg); +unsigned long long ps3_ioc_hardreset_reg_read(struct ps3_instance *instance, + void __iomem *reg); -static inline Bool ps3_ioc_state_valid_check(U32 fw_cur_state) { - return ((fw_cur_state > PS3_FW_STATE_START) && (fw_cur_state != PS3_FW_STATE_MASK)); +unsigned long long ps3_ioc_reg_read(struct ps3_instance *instance, + void __iomem *reg); + +unsigned long long ps3_ioc_reg_read_with_check(struct ps3_instance *instance, + void __iomem *reg); + +static inline unsigned char ps3_ioc_state_valid_check(unsigned int fw_cur_state) +{ + return ((fw_cur_state > PS3_FW_STATE_START) && + (fw_cur_state != PS3_FW_STATE_MASK)); } -U64 ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, void __iomem *reg); +unsigned long long ps3_ioc_reg_retry_safe_read(struct ps3_instance *instance, + void __iomem *reg); static inline void ps3_ioc_reg_write_with_check(struct ps3_instance *instance, - U64 val, void __iomem *reg) + unsigned long long val, + void __iomem *reg) { - U8 try_count = 0; + unsigned char try_count = 0; ps3_reg_dump(instance, reg, val, PS3_FALSE); if (instance->ioc_adpter->reg_write) { while (try_count != PS3_REG_WRITE_RETRY_NUM) { instance->ioc_adpter->reg_write(instance, val, reg); - if (instance->ioc_adpter->reg_read(instance, reg) == val) { + if (instance->ioc_adpter->reg_read(instance, reg) == + val) { break; } try_count++; @@ -221,157 +296,194 @@ static inline void ps3_ioc_reg_write_with_check(struct ps3_instance *instance, LOG_ERROR("hno:%u no register write\n", PS3_HOST(instance)); } - if (try_count == PS3_REG_WRITE_RETRY_NUM) { + if (try_count == PS3_REG_WRITE_RETRY_NUM) ps3_instance_state_transfer_to_dead(instance); - } } -U64 ps3_switch_ioc_reg_read(struct ps3_instance *instance, void __iomem *reg); +unsigned long long ps3_switch_ioc_reg_read(struct ps3_instance *instance, + void __iomem *reg); static inline void ps3_ioc_mgr_req_queue_lock_init(struct ps3_instance *instance) { - ps3_spin_lock_init(&instance->req_queue_lock); + ps3_spin_lock_init(&instance->req_queue_lock); } -static inline Bool ps3_ioc_mgr_max_fw_cmd_get(struct ps3_instance *instance, - U32 *max_cmd_count) +static inline unsigned char +ps3_ioc_mgr_max_fw_cmd_get(struct ps3_instance *instance, + unsigned int *max_cmd_count) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3MaxFwCmd_u *reg_max_fw_cmd = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxFwCmd *reg_max_fw_cmd = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxFwCmd, value); - INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxFwCmd, + value); + INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxFwCmd NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_cmd_count = 0; ret = PS3_FALSE; goto l_out; } - reg_max_fw_cmd = (HilReg0Ps3RegisterFPs3MaxFwCmd_u *)&value; - *max_cmd_count = (U32)reg_max_fw_cmd->reg.ps3MaxFwCmd; + reg_max_fw_cmd = (union HilReg0Ps3RegisterFPs3MaxFwCmd *)&value; + *max_cmd_count = (unsigned int)reg_max_fw_cmd->reg.ps3MaxFwCmd; - if(instance->is_adjust_register_count) { + if (instance->is_adjust_register_count) *max_cmd_count += 1; - } - if (reset_devices && *max_cmd_count > PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES) { + if (reset_devices && + *max_cmd_count > PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES) { *max_cmd_count = PS3_MAX_CMD_COUNT_DURING_RESET_DEVICES; } l_out: return ret; - } -static inline U32 +static inline unsigned int ps3_ioc_mgr_max_msix_vectors_get(struct ps3_instance *instance) { - U64 reg_max_msix_vectors = PS3_MAX_REPLY_QUE_COUNT; + unsigned long long reg_max_msix_vectors = PS3_MAX_REPLY_QUE_COUNT; (void)instance; - return (U32)(reg_max_msix_vectors & PS3_FW_MAX_MSIX_VECTORS_MASK); + return (unsigned int)(reg_max_msix_vectors & + PS3_FW_MAX_MSIX_VECTORS_MASK); } -static inline Bool ps3_ioc_mgr_max_chain_size_get( - struct ps3_instance *instance, U32 *max_chain_size) +static inline unsigned char +ps3_ioc_mgr_max_chain_size_get(struct ps3_instance *instance, + unsigned int *max_chain_size) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3MaxChainSize_u *max_chain_size_u = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxChainSize *max_chain_size_u = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxChainSize, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3MaxChainSize, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxChainSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_chain_size = 0; ret = PS3_FALSE; goto l_out; } - max_chain_size_u = (HilReg0Ps3RegisterFPs3MaxChainSize_u *)&value; - *max_chain_size = (U32)max_chain_size_u->reg.ps3MaxChainSize; + max_chain_size_u = (union HilReg0Ps3RegisterFPs3MaxChainSize *)&value; + *max_chain_size = (unsigned int)max_chain_size_u->reg.ps3MaxChainSize; +l_out: + return ret; +} + +static inline unsigned char +ps3_ioc_mgr_debug10_get(struct ps3_instance *instance, + unsigned int *max_chain_size) +{ + unsigned char ret = PS3_TRUE; + unsigned long long value = 0; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug10, + value); + if (value == U64_MAX) { + LOG_ERROR("hno:%u read reg ps3Debug10 NOK!\n", + PS3_HOST(instance)); + ret = PS3_FALSE; + goto l_out; + } + + *max_chain_size = (value & 0xFFFF); l_out: return ret; } -static inline Bool ps3_ioc_mgr_max_vd_info_size_get( - struct ps3_instance *instance, U32 *vd_info_size) +static inline unsigned char +ps3_ioc_mgr_max_vd_info_size_get(struct ps3_instance *instance, + unsigned int *vd_info_size) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3MaxVdInfoSize_u *vd_info_size_u = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxVdInfoSize *vd_info_size_u = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxVdInfoSize, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3MaxVdInfoSize, + value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxVdInfoSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *vd_info_size = 0; ret = PS3_FALSE; goto l_out; } - vd_info_size_u = (HilReg0Ps3RegisterFPs3MaxVdInfoSize_u *)&value; + vd_info_size_u = (union HilReg0Ps3RegisterFPs3MaxVdInfoSize *)&value; - *vd_info_size = (U32)vd_info_size_u->reg.ps3MaxVdInfoSize; + *vd_info_size = (unsigned int)vd_info_size_u->reg.ps3MaxVdInfoSize; l_out: return ret; } -static inline Bool ps3_ioc_mgr_max_nvme_page_size_get( - struct ps3_instance *instance, U32 *max_nvme_page_size) +static inline unsigned char +ps3_ioc_mgr_max_nvme_page_size_get(struct ps3_instance *instance, + unsigned int *max_nvme_page_size) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3MaxNvmePageSize_u *max_nvme_page_size_u = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxNvmePageSize *max_nvme_page_size_u = + NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxNvmePageSize, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3MaxNvmePageSize, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxNvmePageSize NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_nvme_page_size = 0; ret = PS3_FALSE; goto l_out; } - max_nvme_page_size_u = (HilReg0Ps3RegisterFPs3MaxNvmePageSize_u *)&value; - *max_nvme_page_size = (U32)max_nvme_page_size_u->reg.ps3MaxNvmePageSize; + max_nvme_page_size_u = + (union HilReg0Ps3RegisterFPs3MaxNvmePageSize *)&value; + *max_nvme_page_size = + (unsigned int)max_nvme_page_size_u->reg.ps3MaxNvmePageSize; l_out: return ret; } -static inline Bool ps3_ioc_mgr_is_dma64_support(struct ps3_instance *instance, - Bool *is_dma64_support) +static inline unsigned char +ps3_ioc_mgr_is_dma64_support(struct ps3_instance *instance, + unsigned char *is_dma64_support) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_dma64_support = PS3_FALSE; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; *is_dma64_support = (ps3_feature_support->reg.dmaBit64Support != 0); l_out: return ret; } -static inline Bool ps3_max_replyq_count_get(struct ps3_instance *instance, - U32 *max_replyq_count) +static inline unsigned char +ps3_max_replyq_count_get(struct ps3_instance *instance, + unsigned int *max_replyq_count) { - Bool ret = PS3_TRUE; - U64 value = 0; + unsigned char ret = PS3_TRUE; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxReplyque, value); - INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value) + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3MaxReplyque, value); + INJECT_START(PS3_ERR_IJ_GET_REPLYQ_COUNT_INVALID, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3MaxReplyque NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_replyq_count = 0; ret = PS3_FALSE; goto l_out; @@ -382,160 +494,162 @@ static inline Bool ps3_max_replyq_count_get(struct ps3_instance *instance, return ret; } -static inline Bool ps3_ioc_fw_version_get(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_fw_version_get(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3FirmwareVersion_u *pver = NULL; - U64 fw_version_last = instance->ioc_fw_version; - U64 ver = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; + unsigned long long fw_version_last = instance->ioc_fw_version; + unsigned long long ver = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3FirmwareVersion, ver); if (ver == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FirmwareVersion NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->ioc_fw_version = fw_version_last; ret = PS3_FALSE; goto l_out; } - pver = (HilReg0Ps3RegisterFPs3FirmwareVersion_u *)&ver; - instance->ioc_fw_version = (U64)pver->reg.ps3FmVer; + pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; + instance->ioc_fw_version = (unsigned long long)pver->reg.ps3FmVer; l_out: return ret; } -static inline Bool ps3_ioc_sgl_mode_support(struct ps3_instance *instance, - Bool *is_sgl_mode_support) +static inline unsigned char +ps3_ioc_sgl_mode_support(struct ps3_instance *instance, + unsigned char *is_sgl_mode_support) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_sgl_mode_support = PS3_FALSE; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; *is_sgl_mode_support = (ps3_feature_support->reg.sglModeSupport == 1); l_out: return ret; } -static inline Bool ps3_ioc_dump_support_get(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_dump_support_get(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - Bool last_dump_support = instance->dump_context.is_dump_support; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; - - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + unsigned char ret = PS3_TRUE; + unsigned char last_dump_support = + instance->dump_context.is_dump_support; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; + + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, + value); INJECT_START(PS3_ERR_IJ_FEATURE_SUPPORT_ERR, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->dump_context.is_dump_support = last_dump_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; instance->dump_context.is_dump_support = (ps3_feature_support->reg.dumpCrashSupport == 1); l_out: return ret; } -static inline Bool ps3_ioc_state_halt_support_get(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_state_halt_support_get(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - Bool last_halt_support = instance->is_ioc_halt_support; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + unsigned char last_halt_support = instance->is_ioc_halt_support; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, + value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->is_ioc_halt_support = last_halt_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; - instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + instance->is_ioc_halt_support = + (ps3_feature_support->reg.fwHaltSupport == 1); l_out: return ret; } -static inline Bool ps3_ioc_recovery_count_get(struct ps3_instance *instance, - U32 *recovery_count) +static inline unsigned char +ps3_ioc_recovery_count_get(struct ps3_instance *instance, + unsigned int *recovery_count) { -#if 0 - Bool ret = PS3_TRUE; - U64 value = 0; - - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SoftresetCounter, value); - if (value == U64_MAX) { - LOG_ERROR("hno:%u read reg ps3Debug4 failed!\n", - PS3_HOST(instance)); - *recovery_count = 0; - ret = PS3_FALSE; - goto l_out; - } - - *recovery_count = (U32)(value & PS3_IOC_RECOVERY_COUNT_MASK); -l_out: - return ret; -#else - (void) instance; + (void)instance; *recovery_count = 0; return PS3_TRUE; -#endif } -static inline U32 ps3_ioc_state_get(struct ps3_instance *instance) +static inline unsigned int ps3_ioc_state_get(struct ps3_instance *instance) { - U64 ioc_state = 0; + unsigned long long ioc_state = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, ioc_state); - return (U32)(ioc_state & PS3_FW_STATE_MASK); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, + ioc_state); + return (unsigned int)(ioc_state & PS3_FW_STATE_MASK); } -static inline Bool ps3_ioc_state_get_with_check(struct ps3_instance *instance, - U32 *ioc_state) +static inline unsigned char +ps3_ioc_state_get_with_check(struct ps3_instance *instance, + unsigned int *ioc_state) { - Bool ret = PS3_TRUE; - U64 value = 0; + unsigned char ret = PS3_TRUE; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3SocFwState, + value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3SocFwState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *ioc_state = 0; ret = PS3_FALSE; goto l_out; } - *ioc_state = (U32)value & PS3_FW_STATE_MASK; + *ioc_state = (unsigned int)value & PS3_FW_STATE_MASK; l_out: return ret; } -static inline Bool ps3_get_doorbell_done_with_check(struct ps3_instance *instance, - Bool *is_doorbell_done) +static inline unsigned char +ps3_get_doorbell_done_with_check(struct ps3_instance *instance, + unsigned char *is_doorbell_done) { - Bool ret = PS3_TRUE; - U64 value = 0; + unsigned char ret = PS3_TRUE; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, + value); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_DONE, &value) if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3RegCmdState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_doorbell_done = PS3_FALSE; ret = PS3_FALSE; goto l_out; @@ -546,51 +660,59 @@ static inline Bool ps3_get_doorbell_done_with_check(struct ps3_instance *instanc if (*is_doorbell_done) { value &= ~PS3_DOORBELL_DONE; if (instance->peer_instance != NULL && - instance->peer_instance->reg_set != NULL) { - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); + instance->peer_instance->reg_set != NULL) { + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, + ps3RegCmdState, value); PS3_IOC_REG_WRITE_WITH_CHECK(instance->peer_instance, - reg_f.Excl_reg, ps3RegCmdState, value); + reg_f.Excl_reg, + ps3RegCmdState, value); } else { - PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, ps3RegCmdState, value); + PS3_IOC_REG_WRITE_WITH_CHECK(instance, reg_f.Excl_reg, + ps3RegCmdState, value); } - } l_out: return ret; } -static inline Bool ps3_get_max_r1x_cmds_with_check(struct ps3_instance *instance, - U16 *max_r1x_cmds) +static inline unsigned char +ps3_get_max_r1x_cmds_with_check(struct ps3_instance *instance, + unsigned short *max_r1x_cmds) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u *ps3_max_sec_r1x_cmds = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *ps3_max_sec_r1x_cmds = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MaxSecR1xCmds, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3MaxSecR1xCmds, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3Debug6 NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *max_r1x_cmds = 0; ret = PS3_FALSE; goto l_out; } - ps3_max_sec_r1x_cmds = (HilReg0Ps3RegisterFPs3MaxSecR1xCmds_u *)&value; + ps3_max_sec_r1x_cmds = + (union HilReg0Ps3RegisterFPs3MaxSecR1xCmds *)&value; *max_r1x_cmds = ps3_max_sec_r1x_cmds->reg.ps3MaxSecR1xCmds; l_out: return ret; } -static inline Bool ps3_check_debug0_valid_with_check( - struct ps3_instance *instance, Bool *is_doorbell_valid, U32 check_mask) +static inline unsigned char +ps3_check_debug0_valid_with_check(struct ps3_instance *instance, + unsigned char *is_doorbell_valid, + unsigned int check_mask) { - Bool ret = PS3_TRUE; - U64 value = 0; + unsigned char ret = PS3_TRUE; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3CmdTrigger, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3CmdTrigger, + value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3CmdTrigger NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *is_doorbell_valid = PS3_FALSE; ret = PS3_FALSE; goto l_out; @@ -601,19 +723,20 @@ static inline Bool ps3_check_debug0_valid_with_check( return ret; } -static inline Bool ps3_ioc_heartbeat_get(struct ps3_instance *instance, - U64 *heartbeat_value) +static inline unsigned char +ps3_ioc_heartbeat_get(struct ps3_instance *instance, + unsigned long long *heartbeat_value) { - Bool ret = PS3_TRUE; - static Bool last_fault_state = PS3_TRUE; + unsigned char ret = PS3_TRUE; + static unsigned char last_fault_state = PS3_TRUE; - *heartbeat_value = ps3_ioc_reg_read_with_check(instance, - &instance->reg_set->reg_f.Excl_reg.ps3SocFwState); - INJECT_START(PS3_ERR_IJ_READ_FW_STATE_REG_FF, heartbeat_value) + *heartbeat_value = ps3_ioc_reg_read_with_check( + instance, &instance->reg_set->reg_f.Excl_reg.ps3SocFwState); + INJECT_START(PS3_ERR_IJ_READ_FW_STATE_REG_FF, heartbeat_value); if (*heartbeat_value == U64_MAX) { if (last_fault_state) { LOG_ERROR("hno:%u read reg ps3SocFwState NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); last_fault_state = PS3_FALSE; } *heartbeat_value = 0; @@ -621,7 +744,8 @@ static inline Bool ps3_ioc_heartbeat_get(struct ps3_instance *instance, goto l_out; } else { last_fault_state = PS3_TRUE; - LOG_DEBUG("hno:%u read reg ps3SocFwState success value[%llu]!\n", + LOG_DEBUG( + "hno:%u read reg ps3SocFwState success value[%llu]!\n", PS3_HOST(instance), *heartbeat_value); } @@ -629,33 +753,35 @@ static inline Bool ps3_ioc_heartbeat_get(struct ps3_instance *instance, return ret; } -static inline Bool ps3_ioc_recovery_support_get(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_recovery_support_get(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - Bool last_shallow_soft_recovery_support = + unsigned char ret = PS3_TRUE; + unsigned char last_shallow_soft_recovery_support = instance->is_shallow_soft_recovery_support; - Bool last_deep_soft_recovery_support = + unsigned char last_deep_soft_recovery_support = instance->is_deep_soft_recovery_support; - Bool last_hard_recovery_support = + unsigned char last_hard_recovery_support = instance->is_hard_recovery_support; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, + value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->is_shallow_soft_recovery_support = last_shallow_soft_recovery_support; instance->is_deep_soft_recovery_support = last_deep_soft_recovery_support; - instance->is_hard_recovery_support = - last_hard_recovery_support; + instance->is_hard_recovery_support = last_hard_recovery_support; ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); instance->is_deep_soft_recovery_support = @@ -666,86 +792,99 @@ static inline Bool ps3_ioc_recovery_support_get(struct ps3_instance *instance) return ret; } -static inline Bool ps3_ioc_multi_func_support(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_multi_func_support(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - U64 value = 0; + unsigned char ret = PS3_TRUE; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + unsigned long long value = 0; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3FeatureSupport, value); + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3FeatureSupport, value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3FeatureSupport failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; ret = (ps3_feature_support->reg.multiDevfnSupport == 1); l_out: return ret; } -static inline Bool ps3_ioc_security_state_check(struct ps3_instance *instance) +static inline unsigned char +ps3_ioc_security_state_check(struct ps3_instance *instance) { - U64 value = 0; - Bool ret = PS3_FALSE; - - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug7, value); - if (value == U64_MAX || (value & 0x1)) { - ret = PS3_TRUE; - LOG_ERROR("hno:%u read register NOK or ioc is security [%llu]\n", - PS3_HOST(instance), value); - } + unsigned long long value = 0; + unsigned char ret = PS3_FALSE; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3Debug7, + value); + if (value == U64_MAX || (value & 0x1)) { + ret = PS3_TRUE; + LOG_ERROR( + "hno:%u read register NOK or ioc is security [%llu]\n", + PS3_HOST(instance), value); + } #ifdef PS3_HARDWARE_SIM - ret = PS3_FALSE; + ret = PS3_FALSE; #endif - return ret; + return ret; } -static inline Bool ps3_ioc_atu_support_get(struct ps3_instance *instance, U8 *bit_pos) +static inline unsigned char +ps3_ioc_atu_support_get(struct ps3_instance *instance, unsigned char *bit_pos) { - Bool ret = PS3_TRUE; - HilRegPs3RegisterFPs3AtuSupport_u *ps3_atu_support = NULL; - U64 value = PS3_BIT_POS_DEFAULT; + unsigned char ret = PS3_TRUE; + union HilRegPs3RegisterFPs3AtuSupport *ps3_atu_support = NULL; + unsigned long long value = PS3_BIT_POS_DEFAULT; PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3Debug8, value); INJECT_START(PS3_ERR_IJ_READ_ATU_REG_FAILED, &value); if (value == U64_MAX) { LOG_ERROR("hno:%u read reg ps3AtuSupport NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *bit_pos = PS3_BIT_POS_DEFAULT; ret = PS3_FALSE; goto l_out; } - ps3_atu_support = (HilRegPs3RegisterFPs3AtuSupport_u *)&value; + ps3_atu_support = (union HilRegPs3RegisterFPs3AtuSupport *)&value; *bit_pos = ps3_atu_support->reg.bitPos; l_out: return ret; } -static inline Bool ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, U8 *bit_pos) +static inline unsigned char +ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, + unsigned char *bit_pos) { - Bool ret = PS3_FALSE; - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - U32 count = 0; - U32 retry_cnt = 0; - U8 tmp_bit_pos = 0; - Bool is_first = PS3_TRUE; + unsigned char ret = PS3_FALSE; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + unsigned int count = 0; + unsigned int retry_cnt = 0; + unsigned char tmp_bit_pos = 0; + unsigned char is_first = PS3_TRUE; + for (; retry_cnt < PS3_ATU_SUPPORT_READ_RETRY_NUM; retry_cnt++) { - if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) { + if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) goto l_out; - } fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); if (!ps3_ioc_state_valid_check(fw_cur_state)) { for (; count < PS3_REG_READ_RETRY_NUM; count++) { - fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, &fw_cur_state); + fw_cur_state = + instance->ioc_adpter->ioc_state_get( + instance); + INJECT_START(PS3_ERR_IJ_IOC_TO_READY_FAILED, + &fw_cur_state); if (ps3_ioc_state_valid_check(fw_cur_state)) { - if (!ps3_ioc_atu_support_get(instance, &tmp_bit_pos)) { + if (!ps3_ioc_atu_support_get( + instance, &tmp_bit_pos)) { goto l_out; } *bit_pos = tmp_bit_pos; @@ -762,9 +901,8 @@ static inline Bool ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, U continue; } INJECT_START(PS3_ERR_IJ_BIT_POS_ERR, &tmp_bit_pos); - if (*bit_pos != tmp_bit_pos) { + if (*bit_pos != tmp_bit_pos) goto l_out; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_50MS); } ret = PS3_TRUE; @@ -772,11 +910,14 @@ static inline Bool ps3_ioc_atu_support_safe_get(struct ps3_instance *instance, U return ret; } -static inline Bool ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, U8 *bit_pos) +static inline unsigned char +ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, + unsigned char *bit_pos) { - U32 retry_cnt = PS3_ATU_SUPPORT_READ_RETRY_NUM; - Bool ret = PS3_FALSE; + unsigned int retry_cnt = PS3_ATU_SUPPORT_READ_RETRY_NUM; + unsigned char ret = PS3_FALSE; + INJECT_START(PS3_ERR_IJ_BIT_POS_READ_ERR, &retry_cnt) while (retry_cnt--) { if (ps3_ioc_atu_support_safe_get(instance, bit_pos)) { ret = PS3_TRUE; @@ -787,28 +928,30 @@ static inline Bool ps3_ioc_atu_support_retry_read(struct ps3_instance *instance, return ret; } -static inline void ps3_ioc_can_hardreset_set(struct ps3_instance *instance, U8 enable) +static inline void ps3_ioc_can_hardreset_set(struct ps3_instance *instance, + unsigned char enable) { - U64 can_hardreset = 0; - HilRegPs3RegisterFPs3CanHardReset_u *ps3_can_hardreset = NULL; + unsigned long long can_hardreset = 0; + union HilRegPs3RegisterFPs3CanHardReset *ps3_can_hardreset = NULL; - ps3_can_hardreset = (HilRegPs3RegisterFPs3CanHardReset_u*)&can_hardreset; + ps3_can_hardreset = + (union HilRegPs3RegisterFPs3CanHardReset *)&can_hardreset; ps3_can_hardreset->reg.canHardReset = enable; - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug9, ps3_can_hardreset->val); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Debug9, + ps3_can_hardreset->val); } -Bool ps3_feature_support_reg_get(struct ps3_instance *instance); +unsigned char ps3_feature_support_reg_get(struct ps3_instance *instance); void ps3_ioc_scsi_cmd_send(struct ps3_instance *instance, - struct PS3CmdWord *cmd_word); + struct PS3CmdWord *cmd_word); struct pglist_data *ps3_first_online_pgdat(void); struct pglist_data *ps3_next_online_pgdat(struct pglist_data *pgdat); -#define for_each_ps3_online_pgdat(pgdat) \ - for (pgdat = ps3_first_online_pgdat(); \ - pgdat; \ +#define for_each_ps3_online_pgdat(pgdat) \ + for (pgdat = ps3_first_online_pgdat(); pgdat; \ pgdat = ps3_next_online_pgdat(pgdat)) #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c index bb5213fd0808..37049eb6eb42 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -10,8 +10,8 @@ #include "ps3_ioc_manager.h" #include "ps3_module_para.h" -#define PS3_SOFTRESET_MASK (0xFF) -#define PS3_HARDRESET_MASK (0xFF) +#define PS3_SOFTRESET_MASK (0xFF) +#define PS3_HARDRESET_MASK (0xFF) enum ps3_reset_type { PS3_FW_HARD_RESET = 0, @@ -19,203 +19,203 @@ enum ps3_reset_type { PS3_FW_DEEP_SOFT_RESET = 2, }; -static inline const S8 *namePS3ResetType(S32 s) +static inline const char *namePS3ResetType(int s) { - static const S8 *myNames[] = { - [PS3_FW_HARD_RESET] = "PS3_FW_HARD_RESET", - [PS3_FW_SHALLOW_SOFT_RESET] = "PS3_FW_SHALLOW_SOFT_RESET", - [PS3_FW_DEEP_SOFT_RESET] = "PS3_FW_DEEP_SOFT_RESET" + static const char * const myNames[] = { + [PS3_FW_HARD_RESET] = "PS3_FW_HARD_RESET", + [PS3_FW_SHALLOW_SOFT_RESET] = "PS3_FW_SHALLOW_SOFT_RESET", + [PS3_FW_DEEP_SOFT_RESET] = "PS3_FW_DEEP_SOFT_RESET" }; - if (s > PS3_FW_DEEP_SOFT_RESET) { + if (s > PS3_FW_DEEP_SOFT_RESET) return "PS3_RESET_TYPE_INVALID"; - } return myNames[s]; } struct ps3_reset_key_map { - U32 reset_key_offset; - U32 reset_state_offset; - U32 reset_offset; - U32 reset_type; - U32 reset_status_offset; - U32 reset_status_mask; + unsigned int reset_key_offset; + unsigned int reset_state_offset; + unsigned int reset_offset; + unsigned int reset_type; + unsigned int reset_status_offset; + unsigned int reset_status_mask; }; struct ps3_state_desc_map { - U32 state; - const char *state_desc; + unsigned int state; + const char *state_desc; }; static struct ps3_reset_key_map g_reset_key_table[] = { - [PS3_FW_HARD_RESET] = { - offsetof(HilReg0Ps3RegisterF_s, ps3HardresetKey), - offsetof(HilReg0Ps3RegisterF_s, ps3HardresetState), - offsetof(HilReg0Ps3RegisterF_s, ps3Hardreset), - PS3_FW_HARD_RESET_ACT, - offsetof(HilReg0Ps3RegisterF_s, ps3Hardreset), - PS3_HARDRESET_MASK - }, - [PS3_FW_SHALLOW_SOFT_RESET] = { - offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetKey), - offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetState), - offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), - PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET, - offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), - PS3_SOFTRESET_MASK - }, - [PS3_FW_DEEP_SOFT_RESET] = { - offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetKey), - offsetof(HilReg0Ps3RegisterF_s, ps3SoftresetState), - offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), - PS3_FW_STATE_ACT_DEEP_SOFT_RESET, - offsetof(HilReg0Ps3RegisterF_s, ps3Softreset), - PS3_SOFTRESET_MASK - }, + [PS3_FW_HARD_RESET] = { offsetof(struct HilReg0Ps3RegisterF, + ps3HardresetKey), + offsetof(struct HilReg0Ps3RegisterF, + ps3HardresetState), + offsetof(struct HilReg0Ps3RegisterF, + ps3Hardreset), + PS3_FW_HARD_RESET_ACT, + offsetof(struct HilReg0Ps3RegisterF, + ps3Hardreset), + PS3_HARDRESET_MASK }, + [PS3_FW_SHALLOW_SOFT_RESET] = { offsetof(struct HilReg0Ps3RegisterF, + ps3SoftresetKey), + offsetof(struct HilReg0Ps3RegisterF, + ps3SoftresetState), + offsetof(struct HilReg0Ps3RegisterF, + ps3Softreset), + PS3_FW_STATE_ACT_SHALLOW_SOFT_RESET, + offsetof(struct HilReg0Ps3RegisterF, + ps3Softreset), + PS3_SOFTRESET_MASK }, + [PS3_FW_DEEP_SOFT_RESET] = { offsetof(struct HilReg0Ps3RegisterF, + ps3SoftresetKey), + offsetof(struct HilReg0Ps3RegisterF, + ps3SoftresetState), + offsetof(struct HilReg0Ps3RegisterF, + ps3Softreset), + PS3_FW_STATE_ACT_DEEP_SOFT_RESET, + offsetof(struct HilReg0Ps3RegisterF, + ps3Softreset), + PS3_SOFTRESET_MASK }, }; static struct ps3_state_desc_map g_state_desc[] = { - {PS3_FW_STATE_UNDEFINED, "PS3_FW_STATE_UNDEFINED"}, - {PS3_FW_STATE_START, "PS3_FW_STATE_START"}, - {PS3_FW_STATE_READY, "PS3_FW_STATE_READY"}, - {PS3_FW_STATE_WAIT, "PS3_FW_STATE_WAIT"}, - {PS3_FW_STATE_RUNNING, "PS3_FW_STATE_RUNNING"}, - {PS3_FW_STATE_FLUSHING, "PS3_FW_STATE_FLUSHING"}, - {PS3_FW_STATE_RESET, "PS3_FW_STATE_RESET"}, - {PS3_FW_STATE_FAULT, "PS3_FW_STATE_FAULT"}, - {PS3_FW_STATE_CRITICAL, "PS3_FW_STATE_CRITICAL"}, - {PS3_FW_STATE_HALT, "PS3_FW_STATE_HALT"} + { PS3_FW_STATE_UNDEFINED, "PS3_FW_STATE_UNDEFINED" }, + { PS3_FW_STATE_START, "PS3_FW_STATE_START" }, + { PS3_FW_STATE_READY, "PS3_FW_STATE_READY" }, + { PS3_FW_STATE_WAIT, "PS3_FW_STATE_WAIT" }, + { PS3_FW_STATE_RUNNING, "PS3_FW_STATE_RUNNING" }, + { PS3_FW_STATE_FLUSHING, "PS3_FW_STATE_FLUSHING" }, + { PS3_FW_STATE_RESET, "PS3_FW_STATE_RESET" }, + { PS3_FW_STATE_FAULT, "PS3_FW_STATE_FAULT" }, + { PS3_FW_STATE_CRITICAL, "PS3_FW_STATE_CRITICAL" }, + { PS3_FW_STATE_HALT, "PS3_FW_STATE_HALT" } }; static void ps3_reset_key_write(struct ps3_instance *instance, - U32 offset) + unsigned int offset) { - static U32 reset_key_array[] = { - PS3_FW_DIAG_1ST_KEY, - PS3_FW_DIAG_2ND_KEY, - PS3_FW_DIAG_3RD_KEY, - PS3_FW_DIAG_4TH_KEY, - PS3_FW_DIAG_5TH_KEY, - PS3_FW_DIAG_6TH_KEY, - PS3_FW_DIAG_7TH_KEY, - PS3_FW_DIAG_8TH_KEY, - PS3_FW_DIAG_9TH_KEY + static unsigned int reset_key_array[] = { + PS3_FW_DIAG_1ST_KEY, PS3_FW_DIAG_2ND_KEY, PS3_FW_DIAG_3RD_KEY, + PS3_FW_DIAG_4TH_KEY, PS3_FW_DIAG_5TH_KEY, PS3_FW_DIAG_6TH_KEY, + PS3_FW_DIAG_7TH_KEY, PS3_FW_DIAG_8TH_KEY, PS3_FW_DIAG_9TH_KEY }; - U32 idx = 0; + unsigned int idx = 0; - for(idx = 0;idx < ARRAY_SIZE(reset_key_array);idx++) { - PS3_IOC_REG_WRITE_OFFSET(instance, offset, (U64)reset_key_array[idx]); + for (idx = 0; idx < ARRAY_SIZE(reset_key_array); idx++) { + PS3_IOC_REG_WRITE_OFFSET( + instance, offset, + (unsigned long long)reset_key_array[idx]); } } static void ps3_hardreset_key_write(struct ps3_instance *instance, - U8 *reset_key_vir_addr, U64 *timeval) + unsigned char *reset_key_vir_addr, + unsigned long long *timeval) { - static U32 reset_key_array[] = { - PS3_FW_DIAG_1ST_KEY, - PS3_FW_DIAG_2ND_KEY, - PS3_FW_DIAG_3RD_KEY, - PS3_FW_DIAG_4TH_KEY, - PS3_FW_DIAG_5TH_KEY, - PS3_FW_DIAG_6TH_KEY, - PS3_FW_DIAG_7TH_KEY, - PS3_FW_DIAG_8TH_KEY, - PS3_FW_DIAG_9TH_KEY + static unsigned int reset_key_array[] = { + PS3_FW_DIAG_1ST_KEY, PS3_FW_DIAG_2ND_KEY, PS3_FW_DIAG_3RD_KEY, + PS3_FW_DIAG_4TH_KEY, PS3_FW_DIAG_5TH_KEY, PS3_FW_DIAG_6TH_KEY, + PS3_FW_DIAG_7TH_KEY, PS3_FW_DIAG_8TH_KEY, PS3_FW_DIAG_9TH_KEY }; - U32 idx = 0; + unsigned int idx = 0; + timeval[PS3_START_WRITE_KEY_REG] = ps3_1970_now_ms_get(); - for(idx = 0;idx < ARRAY_SIZE(reset_key_array);idx++) { - ps3_ioc_hardreset_reg_write(instance, - (U64)reset_key_array[idx], reset_key_vir_addr, 0); + for (idx = 0; idx < ARRAY_SIZE(reset_key_array); idx++) { + ps3_ioc_hardreset_reg_write( + instance, (unsigned long long)reset_key_array[idx], + reset_key_vir_addr, 0); } timeval[PS3_END_WRITE_KEY_REG] = ps3_1970_now_ms_get(); } -static S32 ps3_reset_key_state_check(struct ps3_instance *instance, - U32 offset) +static int ps3_reset_key_state_check(struct ps3_instance *instance, + unsigned int offset) { - U32 reset_key_state = 0; - U32 read_count = 0; - const U32 retry_max = 50; - S32 ret = PS3_SUCCESS; - U64 value = 0; + unsigned int reset_key_state = 0; + unsigned int read_count = 0; + const unsigned int retry_max = 50; + int ret = PS3_SUCCESS; + unsigned long long value = 0; do { if (read_count >= retry_max) { - LOG_ERROR("hno:%u PS3 reset key state is still " - "disabled after 5 sec \n", PS3_HOST(instance)); + LOG_ERROR("hno:%u PS3 reset key state is still disabled after 5 sec\n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; } - if (read_count != 0) { + if (read_count != 0) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } PS3_IOC_REG_READ_OFFSET(instance, offset, value); - reset_key_state = (U32)value; + reset_key_state = (unsigned int)value; read_count++; } while (!(reset_key_state & PS3_FW_DIAG_ENABLE) || - (reset_key_state == U32_MAX)); + (reset_key_state == U32_MAX)); if (ret == PS3_SUCCESS) { - LOG_INFO("hno:%u PS3 reset key state is enabled after %d msecs\n", + LOG_INFO( + "hno:%u PS3 reset key state is enabled after %d msecs\n", PS3_HOST(instance), (read_count - 1) * PS3_LOOP_TIME_INTERVAL_100MS); } return ret; } -static S32 ps3_hardreset_key_state_check(struct ps3_instance *instance, - U8 *reset_key_state_vir_addr, U64 *timeval) +static int +ps3_hardreset_key_state_check(struct ps3_instance *instance, + unsigned char *reset_key_state_vir_addr, + unsigned long long *timeval) { - U32 reset_key_state = 0; - U32 read_count = 0; - const U32 retry_max = 900; - S32 ret = PS3_SUCCESS; + unsigned int reset_key_state = 0; + unsigned int read_count = 0; + const unsigned int retry_max = 900; + int ret = PS3_SUCCESS; timeval[PS3_START_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); do { + INJECT_START(PS3_ERR_IJ_RECOVERY_KEY_STATE_CHECK, &read_count) if (read_count >= retry_max) { ret = -PS3_FAILED; break; } - if (read_count != 0) { + if (read_count != 0) ps3_mdelay(PS3_LOOP_TIME_INTERVAL_1MS); - } - reset_key_state = (U32)ps3_ioc_hardreset_reg_read(instance, - reset_key_state_vir_addr); + reset_key_state = (unsigned int)ps3_ioc_hardreset_reg_read( + instance, reset_key_state_vir_addr); read_count++; } while (!(reset_key_state & PS3_FW_DIAG_ENABLE) || - ((U32_MAX & reset_key_state) == U32_MAX)); + ((U32_MAX & reset_key_state) == U32_MAX)); timeval[PS3_END_WAIT_KEY_READY_REG] = ps3_1970_now_ms_get(); return ret; } -static S32 ps3_after_reset_request_check( - struct ps3_instance *instance, enum ps3_reset_type reset_type) +static int ps3_after_reset_request_check(struct ps3_instance *instance, + enum ps3_reset_type reset_type) { - U32 fw_state = instance->ioc_adpter->ioc_state_get(instance); - U32 read_count = 0; + unsigned int fw_state = instance->ioc_adpter->ioc_state_get(instance); + unsigned int read_count = 0; #ifdef PS3_HARDWARE_HAPS_V200 - const U32 retry_max = 3600; + const unsigned int retry_max = 3600; #else - const U32 retry_max = 1800; + const unsigned int retry_max = 1800; #endif - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; - while(read_count < retry_max) { - if ( (fw_state == PS3_FW_STATE_START) || - (fw_state == PS3_FW_STATE_READY)) { + while (read_count < retry_max) { + if ((fw_state == PS3_FW_STATE_START) || + (fw_state == PS3_FW_STATE_READY)) { ret = PS3_SUCCESS; break; } if ((reset_type == PS3_FW_SHALLOW_SOFT_RESET) || - (reset_type == PS3_FW_DEEP_SOFT_RESET)) { + (reset_type == PS3_FW_DEEP_SOFT_RESET)) { if (fw_state == PS3_FW_STATE_RUNNING) { ret = PS3_SUCCESS; break; @@ -223,7 +223,8 @@ static S32 ps3_after_reset_request_check( } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; break; } @@ -232,70 +233,73 @@ static S32 ps3_after_reset_request_check( #else ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); #endif - fw_state = instance->ioc_adpter->ioc_state_get(instance); + fw_state = instance->ioc_adpter->ioc_state_get(instance); read_count++; } - if ( ret != PS3_SUCCESS ) { - LOG_ERROR("hno:%u PS3 IOC state is not valid 180 secs after IOC reset, fw state is %s\n", - PS3_HOST(instance),ps3_ioc_state_print(fw_state)); + if (ret != PS3_SUCCESS) { + LOG_ERROR( + "hno:%u PS3 IOC state is not valid 180 secs after IOC reset, fw state is %s\n", + PS3_HOST(instance), ps3_ioc_state_print(fw_state)); } LOG_INFO("hno:%u fw state is %s\n", PS3_HOST(instance), - ps3_ioc_state_print(fw_state)); + ps3_ioc_state_print(fw_state)); return ret; - } -static S32 ps3_reset_request_completion_check( - struct ps3_instance *instance, U32 offset, U32 completion_mask) +static int ps3_reset_request_completion_check(struct ps3_instance *instance, + unsigned int offset, + unsigned int completion_mask) { - U32 read_count = 0; - const U32 retry_max = 1000; - S32 ret = PS3_SUCCESS; - U64 value = 0; - U32 completion = 0; + unsigned int read_count = 0; + const unsigned int retry_max = 1000; + int ret = PS3_SUCCESS; + unsigned long long value = 0; + unsigned int completion = 0; PS3_IOC_REG_READ_OFFSET(instance, offset, value); - completion = (U32)value; - while (completion & completion_mask || - completion == U32_MAX) { + completion = (unsigned int)value; + while (completion & completion_mask || completion == U32_MAX) { if (read_count > retry_max) { - LOG_ERROR("hno:%u PS3 reset flag is not " - "clear 100 secs after reset request \n", - PS3_HOST(instance)); + LOG_ERROR( + "hno:%u PS3 reset flag is not clear 100 secs after reset request\n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; } ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); PS3_IOC_REG_READ_OFFSET(instance, offset, value); - completion = (U32)value; + completion = (unsigned int)value; read_count++; } if (ret == PS3_SUCCESS) { - LOG_INFO("hno:%u PS3 reset complete %d msecs after reset complete \n", - PS3_HOST(instance), read_count * PS3_LOOP_TIME_INTERVAL_100MS); + LOG_INFO( + "hno:%u PS3 reset complete %d msecs after reset complete\n", + PS3_HOST(instance), + read_count * PS3_LOOP_TIME_INTERVAL_100MS); } return ret; } -const char *ps3_ioc_state_print(U32 state) +const char *ps3_ioc_state_print(unsigned int state) { - U32 idx = 0; - U32 fw_state = state & PS3_FW_STATE_MASK; + unsigned int idx = 0; + unsigned int fw_state = state & PS3_FW_STATE_MASK; const char *ps3_state_name = "invalid state"; - for (idx = 0;idx < ARRAY_SIZE(g_state_desc);idx++) { + for (idx = 0; idx < ARRAY_SIZE(g_state_desc); idx++) { if (g_state_desc[idx].state == fw_state) { ps3_state_name = g_state_desc[idx].state_desc; break; @@ -305,29 +309,34 @@ const char *ps3_ioc_state_print(U32 state) return ps3_state_name; } -static inline void ps3_ioc_state_trigger_transition(struct ps3_instance *instance, U32 action) +static inline void +ps3_ioc_state_trigger_transition(struct ps3_instance *instance, + unsigned int action) { - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Doorbell, (U64)action); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3Doorbell, + (unsigned long long)action); } -static inline void ps3_ioc_debug0_trigger(struct ps3_instance *instance, U32 mask_value) +static inline void ps3_ioc_debug0_trigger(struct ps3_instance *instance, + unsigned int mask_value) { - PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3CmdTrigger, (U64)mask_value); + PS3_IOC_REG_WRITE(instance, reg_f.Excl_reg, ps3CmdTrigger, + (unsigned long long)mask_value); } -S32 ps3_ioc_state_fault_wait(struct ps3_instance *instance) +int ps3_ioc_state_fault_wait(struct ps3_instance *instance) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - S32 ret = PS3_SUCCESS; - U32 count = 0; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + int ret = PS3_SUCCESS; + unsigned int count = 0; fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); while (count < PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT) { if (fw_cur_state == PS3_FW_STATE_FAULT || - fw_cur_state == PS3_FW_STATE_CRITICAL) { + fw_cur_state == PS3_FW_STATE_CRITICAL) { LOG_INFO("hno:%u within 180s fw transfer to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); break; } @@ -338,87 +347,80 @@ S32 ps3_ioc_state_fault_wait(struct ps3_instance *instance) if (fw_cur_state != PS3_FW_STATE_FAULT) { LOG_ERROR("hno:%u fw state[%s] is not fault\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u fw state transition to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); } return ret; } -S32 ps3_ioc_state_ready_wait(struct ps3_instance *instance) +int ps3_ioc_state_ready_wait(struct ps3_instance *instance) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - S32 ret = PS3_SUCCESS; - U32 count = 0; - Bool is_unload_valid = PS3_FALSE; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + int ret = PS3_SUCCESS; + unsigned int count = 0; + unsigned char is_unload_valid = PS3_FALSE; ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); + PS3_CMD_TRIGGER_UNLOAD); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); while (count < instance->wait_ready_timeout) { -#if 0 - if ( (fw_cur_state == PS3_FW_STATE_READY) - || (fw_cur_state == PS3_FW_STATE_FAULT) - || (fw_cur_state == PS3_FW_STATE_HALT) ){ - break; - } -#else - INJECT_START(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_HARD_READY_PCIE_ERRL, instance); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } if (fw_cur_state == PS3_FW_STATE_READY && !is_unload_valid) { LOG_INFO("hno:%u within 180s fw transfer to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); break; } -#endif #ifdef PS3_HARDWARE_HAPS_V200 ps3_msleep(PS3_LOOP_TIME_INTERVAL_3000MS); #else ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); #endif ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - PS3_CMD_TRIGGER_UNLOAD); + PS3_CMD_TRIGGER_UNLOAD); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); count++; } if (fw_cur_state != PS3_FW_STATE_READY || is_unload_valid) { - LOG_ERROR("hno:%u fw state[%s] is not ready, or unload[%d] not done\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state), is_unload_valid); + LOG_ERROR( + "hno:%u fw state[%s] is not ready, or unload[%d] not done\n", + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state), + is_unload_valid); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u fw state transition to %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); } l_out: return ret; } -S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) +int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - S32 ret = PS3_SUCCESS; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + int ret = PS3_SUCCESS; if (!ps3_ioc_state_get_with_check(instance, &fw_cur_state)) { ret = -PS3_FAILED; goto l_out; } - LOG_INFO("hno:%u fw state is %s(0x%x)\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state), fw_cur_state); + LOG_INFO("hno:%u fw state is %s(0x%x)\n", PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state), fw_cur_state); switch (fw_cur_state) { case PS3_FW_STATE_UNDEFINED: @@ -426,27 +428,26 @@ S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) case PS3_FW_STATE_START: case PS3_FW_STATE_FLUSHING: ret = ps3_ioc_state_ready_wait(instance); - if (ret != PS3_SUCCESS) { - if (ret != -PS3_IN_PCIE_ERR) { - ret = -PS3_NO_RECOVERED; - } - LOG_ERROR("hno:%u fw state to ready NOK \n", - PS3_HOST(instance)); - } + if (ret != PS3_SUCCESS) { + if (ret != -PS3_IN_PCIE_ERR) + ret = -PS3_NO_RECOVERED; + LOG_ERROR("hno:%u fw state to ready NOK\n", + PS3_HOST(instance)); + } break; case PS3_FW_STATE_READY: break; case PS3_FW_STATE_WAIT: case PS3_FW_STATE_RUNNING: LOG_WARN("hno:%u fw state is wait/running\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; break; case PS3_FW_STATE_FAULT: case PS3_FW_STATE_CRITICAL: case PS3_FW_STATE_HALT: - LOG_ERROR("hno:%u fw state is fault/halt, to ready NOK \n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u fw state is fault/halt, to ready NOK\n", + PS3_HOST(instance)); ret = -PS3_FAILED; break; @@ -458,36 +459,36 @@ S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance) return ret; } -S32 ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) +int ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - S32 ret = PS3_SUCCESS; - U32 count = 0; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + int ret = PS3_SUCCESS; + unsigned int count = 0; fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL, &fw_cur_state) - LOG_INFO("hno:%u fw state is %s(0x%x)\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state), fw_cur_state); + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL, &fw_cur_state); + LOG_INFO("hno:%u fw state is %s(0x%x)\n", PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state), fw_cur_state); while (count < PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT) { - if ( (fw_cur_state == PS3_FW_STATE_RUNNING) - || (fw_cur_state == PS3_FW_STATE_FAULT) - || (fw_cur_state == PS3_FW_STATE_HALT) - || (fw_cur_state == PS3_FW_STATE_CRITICAL)){ + if ((fw_cur_state == PS3_FW_STATE_RUNNING) || + (fw_cur_state == PS3_FW_STATE_FAULT) || + (fw_cur_state == PS3_FW_STATE_HALT) || + (fw_cur_state == PS3_FW_STATE_CRITICAL)) { break; } - INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, instance) + INJECT_START(PS3_ERR_IJ_FORCE_IOC_RUNNING_PCI_ERR, instance); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ps3_mutex_unlock(&instance->state_machine.lock); break; @@ -498,124 +499,129 @@ S32 ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance) fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); count++; } - INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, &fw_cur_state) + INJECT_START(PS3_ERR_IJ_WAIT_RUNNING_FAIL1, &fw_cur_state); if (fw_cur_state != PS3_FW_STATE_RUNNING) { LOG_ERROR("hno:%u fw state transition NOK, state is %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(fw_cur_state)); + PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; } else { ret = -PS3_FAILED; } } - LOG_INFO("hno:%u fw state transit to %s\n", - PS3_HOST(instance), ps3_ioc_state_print(fw_cur_state)); + LOG_INFO("hno:%u fw state transit to %s\n", PS3_HOST(instance), + ps3_ioc_state_print(fw_cur_state)); l_out: return ret; } -static S32 ps3_ioc_state_reset_request(struct ps3_instance *instance, - enum ps3_reset_type reset_type) +static int ps3_ioc_state_reset_request(struct ps3_instance *instance, + enum ps3_reset_type reset_type) { - S32 ret = -PS3_FAILED; - U32 ioc_reset_type = 0; - U32 reset_status_mask = 0; - U32 cur_state = 0; + int ret = -PS3_FAILED; + unsigned int ioc_reset_type = 0; + unsigned int reset_status_mask = 0; + unsigned int cur_state = 0; ioc_reset_type = g_reset_key_table[reset_type].reset_type; reset_status_mask = g_reset_key_table[reset_type].reset_status_mask; cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO("hno:%u %s, key_offset: 0x%x, state_offset: 0x%x," - " reset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x" - " status mask: 0x%8x cur_state[%d]\n", + LOG_INFO( + "hno:%u %s, key_offset: 0x%x, state_offset: 0x%x\n" + "\treset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x\n" + "\tstatus mask: 0x%8x cur_state[%d]\n", PS3_HOST(instance), namePS3ResetType(reset_type), g_reset_key_table[reset_type].reset_key_offset, g_reset_key_table[reset_type].reset_state_offset, g_reset_key_table[reset_type].reset_offset, g_reset_key_table[reset_type].reset_status_offset, g_reset_key_table[reset_type].reset_type, - g_reset_key_table[reset_type].reset_status_mask, - cur_state); + g_reset_key_table[reset_type].reset_status_mask, cur_state); preempt_disable(); - ps3_reset_key_write(instance, g_reset_key_table[reset_type].reset_key_offset); + ps3_reset_key_write(instance, + g_reset_key_table[reset_type].reset_key_offset); preempt_enable(); - ps3_reset_key_state_check(instance, g_reset_key_table[reset_type].reset_state_offset); + ps3_reset_key_state_check( + instance, g_reset_key_table[reset_type].reset_state_offset); - PS3_IOC_REG_WRITE_OFFSET(instance, g_reset_key_table[reset_type].reset_offset, (U64)ioc_reset_type); + PS3_IOC_REG_WRITE_OFFSET(instance, + g_reset_key_table[reset_type].reset_offset, + (unsigned long long)ioc_reset_type); - if (ps3_hard_reset_waiting_query()) { + if (ps3_hard_reset_waiting_query()) ps3_msleep(ps3_hard_reset_waiting_query()); - } - if (ps3_reset_request_completion_check(instance, g_reset_key_table[reset_type].reset_status_offset, - reset_status_mask) != PS3_SUCCESS) { + if (ps3_reset_request_completion_check( + instance, g_reset_key_table[reset_type].reset_status_offset, + reset_status_mask) != PS3_SUCCESS) { goto l_out; } if (ps3_after_reset_request_check(instance, reset_type) != - PS3_SUCCESS) { + PS3_SUCCESS) { goto l_out; } ret = PS3_SUCCESS; l_out: - LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", - PS3_HOST(instance), namePS3ResetType(reset_type), ret); + LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", PS3_HOST(instance), + namePS3ResetType(reset_type), ret); return ret; } -static S32 ps3_ioc_state_hardreset_request(struct ps3_instance *instance, - enum ps3_reset_type reset_type) +static int ps3_ioc_state_hardreset_request(struct ps3_instance *instance, + enum ps3_reset_type reset_type) { - S32 ret = -PS3_FAILED; - U8 *reset_key_addr = NULL; - U8 *reset_state_addr = NULL; - U8 *reset_addr = NULL; - U32 ioc_reset_type = 0; - U32 cur_state = 0; - U8 *reg_start = (U8*)instance->reg_set; - U32 read_count = 0; - const U32 retry_max = 180; - ULong flags = 0; - U64 timeval[PS3_RESET_MAX_COUNT] = {0}; - - reset_key_addr = reg_start + - g_reset_key_table[reset_type].reset_key_offset; - reset_state_addr = reg_start + - g_reset_key_table[reset_type].reset_state_offset; - reset_addr = reg_start + - g_reset_key_table[reset_type].reset_offset; + int ret = -PS3_FAILED; + unsigned char *reset_key_addr = NULL; + unsigned char *reset_state_addr = NULL; + unsigned char *reset_addr = NULL; + unsigned int ioc_reset_type = 0; + unsigned int cur_state = 0; + unsigned char *reg_start = (unsigned char *)instance->reg_set; + unsigned int read_count = 0; + const unsigned int retry_max = 180; + unsigned long flags = 0; + unsigned long long timeval[PS3_RESET_MAX_COUNT] = { 0 }; + + reset_key_addr = + reg_start + g_reset_key_table[reset_type].reset_key_offset; + reset_state_addr = + reg_start + g_reset_key_table[reset_type].reset_state_offset; + reset_addr = reg_start + g_reset_key_table[reset_type].reset_offset; ioc_reset_type = g_reset_key_table[reset_type].reset_type; cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO("hno:%u %s, key_offset: 0x%x, state_offset: 0x%x," - " reset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x" - " status mask: 0x%8x cur_state[%d]\n", + LOG_INFO( + "hno:%u %s, key_offset: 0x%x, state_offset: 0x%x\n" + "\treset_offset: 0x%x, status_offset: 0x%x, IOC reset_type: 0x%8x\n" + "\tstatus mask: 0x%8x cur_state[%d]\n", PS3_HOST(instance), namePS3ResetType(reset_type), g_reset_key_table[reset_type].reset_key_offset, g_reset_key_table[reset_type].reset_state_offset, g_reset_key_table[reset_type].reset_offset, g_reset_key_table[reset_type].reset_status_offset, g_reset_key_table[reset_type].reset_type, - g_reset_key_table[reset_type].reset_status_mask, - cur_state); + g_reset_key_table[reset_type].reset_status_mask, cur_state); instance->is_hard_reset = PS3_TRUE; - mb(); - while(ps3_atomic_read(&instance->reg_op_count) != 0){ + mb(); /* in order to force CPU ordering */ + while (ps3_atomic_read(&instance->reg_op_count) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - if(read_count++ > retry_max){ + if (read_count++ > retry_max) { LOG_INFO("hno:%u %s, wait reg op over:%d ms,failed\n", - PS3_HOST(instance), namePS3ResetType(reset_type), - read_count*PS3_LOOP_TIME_INTERVAL_100MS); + PS3_HOST(instance), + namePS3ResetType(reset_type), + read_count * PS3_LOOP_TIME_INTERVAL_100MS); ret = -PS3_FAILED; goto l_out; } @@ -629,103 +635,114 @@ static S32 ps3_ioc_state_hardreset_request(struct ps3_instance *instance, } INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_4, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_3, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_INFO("hno:%u pcie recovery proceess\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u pcie recovery proceess\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - spin_lock_irqsave(&instance->recovery_context->ps3_hardreset_lock, flags); + spin_lock_irqsave(&instance->recovery_context->ps3_hardreset_lock, + flags); ps3_hardreset_key_write(instance, reset_key_addr, timeval); - ret = ps3_hardreset_key_state_check(instance, reset_state_addr, timeval); - if(ret != PS3_SUCCESS){ - spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); + ret = ps3_hardreset_key_state_check(instance, reset_state_addr, + timeval); + if (ret != PS3_SUCCESS) { + spin_unlock_irqrestore( + &instance->recovery_context->ps3_hardreset_lock, flags); LOG_INFO("hno:%u %s, key check failed, ret:%d\n", - PS3_HOST(instance), namePS3ResetType(reset_type),ret); + PS3_HOST(instance), namePS3ResetType(reset_type), ret); goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_5, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_5, instance); if (ps3_pci_err_recovery_get(instance)) { - spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); - LOG_WARN("hno:%u pcie recovery proceess\n", - PS3_HOST(instance)); + spin_unlock_irqrestore( + &instance->recovery_context->ps3_hardreset_lock, flags); + LOG_WARN("hno:%u pcie recovery proceess\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } timeval[PS3_START_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); - ps3_ioc_hardreset_reg_write(instance, (U64)ioc_reset_type, reset_addr, PS3_TRUE); + ps3_ioc_hardreset_reg_write(instance, + (unsigned long long)ioc_reset_type, + reset_addr, PS3_TRUE); timeval[PS3_END_WRITE_HARDRESET_REG] = ps3_1970_now_ms_get(); - spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, flags); - LOG_INFO("hno:%u %s, key_offset: key state success," - "then write hardreset ioc_reset_type:%u, reset_addr:%p\n", - PS3_HOST(instance), namePS3ResetType(reset_type), ioc_reset_type, reset_addr); + spin_unlock_irqrestore(&instance->recovery_context->ps3_hardreset_lock, + flags); + LOG_INFO("hno:%u %s, key_offset: key state success\n" + "\tthen write hardreset ioc_reset_type:%u, reset_addr:%p\n", + PS3_HOST(instance), namePS3ResetType(reset_type), + ioc_reset_type, reset_addr); LOG_INFO("hno:%u time:%lld-%lld-%lld-%lld-%lld-%lld\n", - PS3_HOST(instance), timeval[PS3_START_WRITE_KEY_REG], timeval[PS3_END_WRITE_KEY_REG], - timeval[PS3_START_WAIT_KEY_READY_REG], timeval[PS3_END_WAIT_KEY_READY_REG], - timeval[PS3_START_WRITE_HARDRESET_REG], timeval[PS3_END_WRITE_HARDRESET_REG]); + PS3_HOST(instance), timeval[PS3_START_WRITE_KEY_REG], + timeval[PS3_END_WRITE_KEY_REG], + timeval[PS3_START_WAIT_KEY_READY_REG], + timeval[PS3_END_WAIT_KEY_READY_REG], + timeval[PS3_START_WRITE_HARDRESET_REG], + timeval[PS3_END_WRITE_HARDRESET_REG]); instance->recovery_context->hardreset_count++; - if (ps3_hard_reset_waiting_query()) { + if (ps3_hard_reset_waiting_query()) ps3_msleep(ps3_hard_reset_waiting_query()); - } - LOG_INFO("hno:%u %s, after sleep:%d ms\n", - PS3_HOST(instance), namePS3ResetType(reset_type),ps3_hard_reset_waiting_query()); + LOG_INFO("hno:%u %s, after sleep:%d ms\n", PS3_HOST(instance), + namePS3ResetType(reset_type), ps3_hard_reset_waiting_query()); instance->is_hard_reset = PS3_FALSE; - if ((ret = ps3_after_reset_request_check(instance, reset_type)) != - PS3_SUCCESS) { + ret = ps3_after_reset_request_check(instance, reset_type); + if (ret != PS3_SUCCESS) goto l_out; - } ret = PS3_SUCCESS; l_out: instance->is_hard_reset = PS3_FALSE; - LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", - PS3_HOST(instance), namePS3ResetType(reset_type), ret); + LOG_INFO("hno:%u PS3 %s complete, ret:%d\n", PS3_HOST(instance), + namePS3ResetType(reset_type), ret); return ret; } -S32 ps3_ioc_state_hard_reset(struct ps3_instance *instance) +int ps3_ioc_state_hard_reset(struct ps3_instance *instance) { if (ps3_use_hard_reset_reg_query()) { - return ps3_ioc_state_hardreset_request(instance, PS3_FW_HARD_RESET); + return ps3_ioc_state_hardreset_request(instance, + PS3_FW_HARD_RESET); } else { - return ps3_ioc_state_reset_request(instance, PS3_FW_SHALLOW_SOFT_RESET); + return ps3_ioc_state_reset_request(instance, + PS3_FW_SHALLOW_SOFT_RESET); } } -S32 ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance) +int ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance) { return ps3_ioc_state_reset_request(instance, PS3_FW_SHALLOW_SOFT_RESET); } -S32 ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance) +int ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance) { return ps3_ioc_state_reset_request(instance, PS3_FW_DEEP_SOFT_RESET); } -static S32 ps3_trigger_ioc_state_change_by_doorbell(struct ps3_instance *instance, - U32 expect_fw_state, U32 doorbell_trigger, u32 time_out) +static int ps3_trigger_ioc_state_change_by_doorbell( + struct ps3_instance *instance, unsigned int expect_fw_state, + unsigned int doorbell_trigger, u32 time_out) { - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - Bool is_doorbell_done = PS3_TRUE; - S32 ret = PS3_SUCCESS; - U32 count = 0; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + unsigned char is_doorbell_done = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned int count = 0; LOG2_WARN("hno:%u expect fw state:%s, doorbell_trigger is %d\n", - PS3_HOST(instance), - ps3_ioc_state_print(expect_fw_state), doorbell_trigger); + PS3_HOST(instance), ps3_ioc_state_print(expect_fw_state), + doorbell_trigger); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - if (fw_cur_state == expect_fw_state) { + if (fw_cur_state == expect_fw_state) goto l_out; - } INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_2, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_1, instance) if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; @@ -734,25 +751,27 @@ static S32 ps3_trigger_ioc_state_change_by_doorbell(struct ps3_instance *instanc ps3_ioc_state_trigger_transition(instance, doorbell_trigger); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT) { + if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT) ps3_get_doorbell_done_with_check(instance, &is_doorbell_done); - } while (count < time_out) { - if (fw_cur_state == expect_fw_state && is_doorbell_done) { + if (fw_cur_state == expect_fw_state && is_doorbell_done) break; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); if (fw_cur_state == PS3_FW_STATE_MASK) { - LOG_ERROR("hno:%u break because get fw_cur_state NOK.\n", + LOG_ERROR( + "hno:%u break because get fw_cur_state NOK.\n", PS3_HOST(instance)); break; } - if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT && !is_doorbell_done) { - if (ps3_get_doorbell_done_with_check(instance, &is_doorbell_done) == PS3_FALSE) { - LOG_ERROR("hno:%u break because get doorbell_done NOK.\n", + if (doorbell_trigger == PS3_REG_DOORBELL_STATE_TO_FAULT && + !is_doorbell_done) { + if (ps3_get_doorbell_done_with_check( + instance, &is_doorbell_done) == PS3_FALSE) { + LOG_ERROR( + "hno:%u break because get doorbell_done NOK.\n", PS3_HOST(instance)); break; } @@ -760,11 +779,11 @@ static S32 ps3_trigger_ioc_state_change_by_doorbell(struct ps3_instance *instanc count++; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_FAILED, &fw_cur_state) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DOORBELL_FAILED, &fw_cur_state); if (fw_cur_state != expect_fw_state) { - LOG_ERROR("hno:%u fw state transition NOK, is_doorbell_done %d state is %s\n", - PS3_HOST(instance), - is_doorbell_done, + LOG_ERROR( + "hno:%u fw state transition NOK, is_doorbell_done %d state is %s\n", + PS3_HOST(instance), is_doorbell_done, ps3_ioc_state_print(fw_cur_state)); ret = -PS3_FAILED; } @@ -772,69 +791,65 @@ static S32 ps3_trigger_ioc_state_change_by_doorbell(struct ps3_instance *instanc return ret; } -S32 ps3_ioc_notify_unload(struct ps3_instance *instance) +int ps3_ioc_notify_unload(struct ps3_instance *instance) { - Bool is_unload_valid = PS3_FALSE; - S32 ret = PS3_SUCCESS; - U32 count = 0; - U8 unload_type = PS3_CMD_TRIGGER_UNLOAD; + unsigned char is_unload_valid = PS3_FALSE; + int ret = PS3_SUCCESS; + unsigned int count = 0; + unsigned char unload_type = PS3_CMD_TRIGGER_UNLOAD; - LOG_WARN("hno:%u trigger ioc unload reg!!\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u trigger ioc unload reg!!\n", PS3_HOST(instance)); - if (instance->state_machine.is_suspend) { + if (instance->state_machine.is_suspend) unload_type = PS3_CMD_TRIGGER_UNLOAD_SUSPEND; - } ps3_ioc_debug0_trigger(instance, unload_type); ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - unload_type); + unload_type); while (count < PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT) { - if (!is_unload_valid) { + if (!is_unload_valid) break; - } ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); ps3_check_debug0_valid_with_check(instance, &is_unload_valid, - unload_type); + unload_type); count++; } if (is_unload_valid) { LOG_ERROR("hno:%u do not wait unload done\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } return ret; } -S32 ps3_ioc_state_force_to_fault(struct ps3_instance *instance) +int ps3_ioc_state_force_to_fault(struct ps3_instance *instance) { - return ps3_trigger_ioc_state_change_by_doorbell(instance, - PS3_FW_STATE_FAULT, PS3_REG_DOORBELL_STATE_TO_FAULT, + return ps3_trigger_ioc_state_change_by_doorbell( + instance, PS3_FW_STATE_FAULT, PS3_REG_DOORBELL_STATE_TO_FAULT, PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT); } -S32 ps3_ioc_state_force_to_halt(struct ps3_instance *instance) +int ps3_ioc_state_force_to_halt(struct ps3_instance *instance) { - return ps3_trigger_ioc_state_change_by_doorbell(instance, - PS3_FW_STATE_HALT, PS3_REG_DOORBELL_STATE_TO_HALT, + return ps3_trigger_ioc_state_change_by_doorbell( + instance, PS3_FW_STATE_HALT, PS3_REG_DOORBELL_STATE_TO_HALT, PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT); } #ifdef PS3_HARDWARE_ASIC -U32 ps3_ioc_heartbeat_detect(struct ps3_instance *instance) +unsigned int ps3_ioc_heartbeat_detect(struct ps3_instance *instance) { - U32 ret = PS3_FALSE; - U64 heartbeat_value = 0; + unsigned int ret = PS3_FALSE; + unsigned long long heartbeat_value = 0; - (void) instance; + (void)instance; - if (!ps3_enable_heartbeat_query()) { + if (!ps3_enable_heartbeat_query()) return ret; - } if (!ps3_ioc_heartbeat_get(instance, &heartbeat_value)) { LOG_DEBUG("hno:%u probably Linkdown\n", PS3_HOST(instance)); @@ -842,7 +857,8 @@ U32 ps3_ioc_heartbeat_detect(struct ps3_instance *instance) } if (heartbeat_value & instance->hard_dog_mask) { - LOG_DEBUG("hno:%u heartbeat detect success\n", PS3_HOST(instance)); + LOG_DEBUG("hno:%u heartbeat detect success\n", + PS3_HOST(instance)); ret = PS3_TRUE; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h index 268d87eb1589..4cea1a7b8963 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioc_state.h @@ -1,30 +1,30 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IOC_STATE_H_ #define _PS3_IOC_STATE_H_ #include "ps3_instance_manager.h" enum { - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID = 18000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA = 18000, - PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE = 9000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH = 15000, - PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS = 3600, - PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT = 9000, - PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT = 1500, - PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT = 9000, - PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT = 500, - PS3_WAIT_EVENT_CMD_LOOP_COUNT = 100, - PS3_LOOP_TIME_INTERVAL_1MS = 1, - PS3_LOOP_TIME_INTERVAL_20MS = 20, - PS3_LOOP_TIME_INTERVAL_50MS = 50, - PS3_LOOP_TIME_INTERVAL_100MS = 100, - PS3_LOOP_TIME_INTERVAL_3000MS = 3000, - PS3_WRITE_HARD_RESET_WAIT_TIME_500MS = 500, - PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT =9000, - PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS =20, - PS3_PS3_LOOP_TIME_INTERVAL_1000MS = 1000, - PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT = 10, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID = 18000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_HBA = 18000, + PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE = 9000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_SWITCH = 15000, + PS3_FW_STATE_TO_READY_TMO_LOOP_COUNT_RAID_HAPS = 3600, + PS3_FW_STATE_TO_RUNNING_TMO_LOOP_COUNT = 9000, + PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT = 1500, + PS3_FW_STATE_TO_HALT_TMO_LOOP_COUNT = 9000, + PS3_FW_STATE_TO_UNLOAD_TMO_LOOP_COUNT = 500, + PS3_WAIT_EVENT_CMD_LOOP_COUNT = 100, + PS3_LOOP_TIME_INTERVAL_1MS = 1, + PS3_LOOP_TIME_INTERVAL_20MS = 20, + PS3_LOOP_TIME_INTERVAL_50MS = 50, + PS3_LOOP_TIME_INTERVAL_100MS = 100, + PS3_LOOP_TIME_INTERVAL_3000MS = 3000, + PS3_WRITE_HARD_RESET_WAIT_TIME_500MS = 500, + PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT = 9000, + PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS = 20, + PS3_PS3_LOOP_TIME_INTERVAL_1000MS = 1000, + PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT = 10, }; enum ps3_reset_time_type { PS3_START_WRITE_KEY_REG = 0, @@ -33,49 +33,53 @@ enum ps3_reset_time_type { PS3_END_WAIT_KEY_READY_REG = 3, PS3_START_WRITE_HARDRESET_REG = 4, PS3_END_WRITE_HARDRESET_REG = 5, - PS3_RESET_MAX_COUNT=6, + PS3_RESET_MAX_COUNT = 6, }; -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED (PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT * \ - PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS / HZ + \ - PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT * PS3_LOOP_TIME_INTERVAL_20MS / HZ + \ - PS3_LOOP_TIME_INTERVAL_100MS * PS3_LOOP_TIME_INTERVAL_100MS / HZ + \ - PS3_WRITE_HARD_RESET_WAIT_TIME_500MS / HZ + \ - PS3_SLEEP_TOLERATE_TIMEOUT) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED \ + (PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT * \ + PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS / HZ + \ + PS3_FW_STATE_TO_FAULT_TMO_LOOP_COUNT * PS3_LOOP_TIME_INTERVAL_20MS / \ + HZ + \ + PS3_LOOP_TIME_INTERVAL_100MS * PS3_LOOP_TIME_INTERVAL_100MS / HZ + \ + PS3_WRITE_HARD_RESET_WAIT_TIME_500MS / HZ + \ + PS3_SLEEP_TOLERATE_TIMEOUT) #ifdef PS3_HARDWARE_HAPS_V200 -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ - (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_3000MS / HZ) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) \ + (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ + (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_3000MS / HZ) #else -#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ - (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_20MS / HZ) +#define PS3_HARD_RESET_FORCE_STOP_MAX_TIME(ins) \ + (PS3_HARD_RESET_FORCE_STOP_MAX_TIME_FIXED + \ + (ins)->wait_ready_timeout * PS3_LOOP_TIME_INTERVAL_20MS / HZ) #endif -S32 ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance); +int ps3_ioc_state_transfer_to_ready(struct ps3_instance *instance); -S32 ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance); +int ps3_ioc_state_transfer_wait_to_running(struct ps3_instance *instance); -S32 ps3_ioc_state_hard_reset(struct ps3_instance *instance); +int ps3_ioc_state_hard_reset(struct ps3_instance *instance); -S32 ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance); +int ps3_ioc_state_shallow_soft_reset(struct ps3_instance *instance); -S32 ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance); +int ps3_ioc_state_deep_soft_reset(struct ps3_instance *instance); -S32 ps3_ioc_state_force_to_fault(struct ps3_instance *instance); +int ps3_ioc_state_force_to_fault(struct ps3_instance *instance); -S32 ps3_ioc_state_force_to_halt(struct ps3_instance *instance); +int ps3_ioc_state_force_to_halt(struct ps3_instance *instance); -S32 ps3_ioc_notify_unload(struct ps3_instance *instance); +int ps3_ioc_notify_unload(struct ps3_instance *instance); #ifdef PS3_HARDWARE_ASIC -U32 ps3_ioc_heartbeat_detect(struct ps3_instance *instance); +unsigned int ps3_ioc_heartbeat_detect(struct ps3_instance *instance); #endif -S32 ps3_ioc_state_ready_wait(struct ps3_instance *instance); +int ps3_ioc_state_ready_wait(struct ps3_instance *instance); -S32 ps3_ioc_state_fault_wait(struct ps3_instance *instance); +int ps3_ioc_state_fault_wait(struct ps3_instance *instance); -const char *ps3_ioc_state_print(U32 state); +const char *ps3_ioc_state_print(unsigned int state); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c index f77254b0d965..51c824482955 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.c @@ -1,11 +1,13 @@ - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_ioctl.h" #ifdef _WINDOWS #include -#define PS3_FUNC_FROM_CTL_CODE(ctrlCode) (((ULong)(ctrlCode & 0x3FFC)) >> 2) -#define PS3_ACC_FROM_CTL_CODE(ctrlCode) (((ULong)(ctrlCode & 0xC000)) >> 14) +#define PS3_FUNC_FROM_CTL_CODE(ctrlCode) \ + (((unsigned long)(ctrlCode & 0x3FFC)) >> 2) +#define PS3_ACC_FROM_CTL_CODE(ctrlCode) \ + (((unsigned long)(ctrlCode & 0xC000)) >> 14) #else #include @@ -33,7 +35,7 @@ #include "ps3_err_inject.h" #include "ps3_event.h" -S32 ps3_ioctl_init(struct ps3_instance*instance, S32 cmd_num) +int ps3_ioctl_init(struct ps3_instance *instance, int cmd_num) { #ifdef _WINDOWS (void)cmd_num; @@ -41,18 +43,21 @@ S32 ps3_ioctl_init(struct ps3_instance*instance, S32 cmd_num) #else sema_init(&instance->ioctl_sem, cmd_num); #endif - ps3_atomic_set(&instance->cmd_statistics.cli_cnt, PS3_CMD_STAT_INIT_VALUE); + ps3_atomic_set(&instance->cmd_statistics.cli_cnt, + PS3_CMD_STAT_INIT_VALUE); return PS3_SUCCESS; } -static S32 ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, - struct PS3IoctlSyncCmd* ioc) +static int ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, + struct PS3IoctlSyncCmd *ioc) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (ioc->sgeCount > PS3_MAX_IOCTL_SGE_NUM || ioc->sgeCount == 0) { - LOG_WARN("hno:%u ioctl req, SGE count [%d] > max limit [%d], or SGE count = 0\n", - PS3_HOST(instance), ioc->sgeCount, PS3_MAX_IOCTL_SGE_NUM); + LOG_WARN( + "hno:%u ioctl req, SGE count [%d] > max limit [%d], or SGE count = 0\n", + PS3_HOST(instance), ioc->sgeCount, + PS3_MAX_IOCTL_SGE_NUM); ret = -PS3_EINVAL; goto l_out; } @@ -64,28 +69,31 @@ static S32 ps3_ioctl_capbility_pre_check(struct ps3_instance *instance, void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) { - U8 i = 0; - struct PS3Sge *pSge = (struct PS3Sge*)cmd->req_frame->mgrReq.sgl; + unsigned char i = 0; + struct PS3Sge *pSge = (struct PS3Sge *)cmd->req_frame->mgrReq.sgl; struct ps3_instance *instance = cmd->instance; - U8 bit_pos = 0; + unsigned char bit_pos = 0; - if (cmd->transient == NULL) { + if (cmd->transient == NULL) goto l_out; - } - if (cmd->transient->sge_num == 0) { + if (cmd->transient->sge_num == 0) goto l_out; - } for (i = 0; i < cmd->transient->sge_num; i++) { if (cmd->transient->transient_buff[i] != NULL) { - if (pSge->ext == 1) { - pSge = (struct PS3Sge*)cmd->ext_buf; - } - bit_pos = ps3_dma_addr_bit_pos_check((dma_addr_t)le64_to_cpu(pSge->addr)); + if (pSge->ext == 1) + pSge = (struct PS3Sge *)cmd->ext_buf; + bit_pos = ps3_dma_addr_bit_pos_check( + (dma_addr_t)le64_to_cpu(pSge->addr)); if (bit_pos != instance->dma_addr_bit_pos) { - pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, le64_to_cpu(pSge->addr))); - pSge->addr = cpu_to_le64(PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + pSge->addr = cpu_to_le64( + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + bit_pos, + le64_to_cpu(pSge->addr))); + pSge->addr = cpu_to_le64( + PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, le64_to_cpu(pSge->addr))); } } @@ -97,25 +105,22 @@ void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd) void ps3_ioctl_buff_release(struct ps3_cmd *cmd) { - U8 i = 0; - struct PS3Sge *pSge = (struct PS3Sge*)cmd->req_frame->mgrReq.sgl; + unsigned char i = 0; + struct PS3Sge *pSge = (struct PS3Sge *)cmd->req_frame->mgrReq.sgl; struct ps3_instance *instance = cmd->instance; - if (cmd->transient == NULL) { + if (cmd->transient == NULL) return; - } - if (cmd->transient->sge_num == 0) { + if (cmd->transient->sge_num == 0) return; - } for (i = 0; i < cmd->transient->sge_num; i++) { if (cmd->transient->transient_buff[i] != NULL) { - if (pSge->ext == 1) { - pSge = (struct PS3Sge*)cmd->ext_buf; - } - ps3_dma_free_coherent(instance, - cpu_to_le32(pSge->length), + if (pSge->ext == 1) + pSge = (struct PS3Sge *)cmd->ext_buf; + ps3_dma_free_coherent( + instance, cpu_to_le32(pSge->length), cmd->transient->transient_buff[i], (dma_addr_t)cpu_to_le64(pSge->addr)); @@ -124,21 +129,24 @@ void ps3_ioctl_buff_release(struct ps3_cmd *cmd) } pSge++; } - memset((void*)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); + memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); cmd->transient->sge_num = 0; } -static S32 ps3_ioctl_sge_fill(struct ps3_instance *instance, U8 *base_addr, - struct PS3Sge *psrc_sge, struct PS3Sge *pdst_sge, void **transient_buff) +static int ps3_ioctl_sge_fill(struct ps3_instance *instance, + unsigned char *base_addr, struct PS3Sge *psrc_sge, + struct PS3Sge *pdst_sge, void **transient_buff) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; dma_addr_t transient_addr = 0; - *transient_buff = ps3_dma_alloc_coherent(instance, - psrc_sge->length, &transient_addr); + *transient_buff = + ps3_dma_alloc_coherent(instance, psrc_sge->length, + (unsigned long long *)&transient_addr); if (*transient_buff == NULL) { - LOG_ERROR("hno:%u Failed to alloc kernel SGL buffer for IOCTL\n", + LOG_ERROR( + "hno:%u Failed to alloc kernel SGL buffer for IOCTL\n", PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; @@ -147,16 +155,19 @@ static S32 ps3_ioctl_sge_fill(struct ps3_instance *instance, U8 *base_addr, pdst_sge->length = cpu_to_le32(psrc_sge->length); pdst_sge->ext = 0; pdst_sge->lastSge = 0; - pdst_sge->addr = (U64)cpu_to_le64(transient_addr); + pdst_sge->addr = (unsigned long long)cpu_to_le64(transient_addr); #ifdef _WINDOWS - LOG_DEBUG("===base_addr[%p],psrc_sge->addr[%d], psrc_sge->length[%d] \n", + LOG_DEBUG( + "===base_addr[%p],psrc_sge->addr[%d], psrc_sge->length[%d]\n", base_addr, psrc_sge->addr, psrc_sge->length); - memcpy(*transient_buff, (void*)(base_addr + psrc_sge->addr), psrc_sge->length); + memcpy(*transient_buff, (void *)(base_addr + psrc_sge->addr), + psrc_sge->length); #else (void)base_addr; - if (copy_from_user(*transient_buff, (void __user*)psrc_sge->addr, psrc_sge->length)) { - LOG_ERROR("hno:%u, copy from user err\n", - PS3_HOST(instance)); + if (copy_from_user(*transient_buff, + (void __user *)(uintptr_t)psrc_sge->addr, + psrc_sge->length)) { + LOG_ERROR("hno:%u, copy from user err\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -165,20 +176,22 @@ static S32 ps3_ioctl_sge_fill(struct ps3_instance *instance, U8 *base_addr, return ret; } -static S32 ps3_ioctl_sgl_fill(struct ps3_instance *instance, - struct ps3_cmd *cmd, struct PS3IoctlSyncCmd* ioc) +static int ps3_ioctl_sgl_fill(struct ps3_instance *instance, + struct ps3_cmd *cmd, struct PS3IoctlSyncCmd *ioc) { - U8 i = 0; - S32 ret = PS3_SUCCESS; + unsigned char i = 0; + int ret = PS3_SUCCESS; struct PS3Sge *pdst_sge = NULL; - struct PS3Sge *psrc_sge = (struct PS3Sge*)((U32*)ioc + - ioc->sglOffset); - U8 pre_sge_count = (U8)((ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) ? - (PS3_FRAME_REQ_SGE_NUM_MGR - 1) : ioc->sgeCount); + struct PS3Sge *psrc_sge = + (struct PS3Sge *)((unsigned int *)ioc + ioc->sglOffset); + unsigned char pre_sge_count = + (unsigned char)((ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) ? + (PS3_FRAME_REQ_SGE_NUM_MGR - 1) : + ioc->sgeCount); if (cmd->transient->sge_num != 0) { LOG_ERROR("trace_id[0x%llx], hno:%u got cmd NOK: %d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index); + cmd->trace_id, PS3_HOST(instance), cmd->index); PS3_BUG(); ret = -PS3_FAILED; goto l_out; @@ -186,25 +199,27 @@ static S32 ps3_ioctl_sgl_fill(struct ps3_instance *instance, cmd->transient->sge_num = ioc->sgeCount; cmd->req_frame->mgrReq.sgeOffset = - offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + offsetof(struct PS3MgrReqFrame, sgl) >> + PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; cmd->req_frame->mgrReq.sgeCount = ioc->sgeCount; pdst_sge = cmd->req_frame->mgrReq.sgl; for (i = 0; i < pre_sge_count; i++) { LOG_DEBUG("trace_id[0x%llx], hno:%u sge[%u] size : %d\n", - cmd->trace_id, PS3_HOST(instance), i, - psrc_sge->length); + cmd->trace_id, PS3_HOST(instance), i, + psrc_sge->length); pdst_sge->length = 0; if (psrc_sge->length > 0) { - ret = ps3_ioctl_sge_fill(instance, (U8*)ioc, psrc_sge, pdst_sge, - &cmd->transient->transient_buff[i]); + ret = ps3_ioctl_sge_fill( + instance, (unsigned char *)ioc, psrc_sge, + pdst_sge, &cmd->transient->transient_buff[i]); if (ret != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u sge[%u] " - "fill data error(%d)\n", cmd->trace_id, - PS3_HOST(instance), i, ret); + LOG_ERROR( + "trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", + cmd->trace_id, PS3_HOST(instance), i, ret); goto l_out; } } @@ -214,29 +229,37 @@ static S32 ps3_ioctl_sgl_fill(struct ps3_instance *instance, } if (ioc->sgeCount > PS3_FRAME_REQ_SGE_NUM_MGR) { - LOG_FILE_INFO("hno:%u ioctl req num %d is bigger than req frame num %d\n", - PS3_HOST(instance), ioc->sgeCount, PS3_FRAME_REQ_SGE_NUM_MGR); - pdst_sge->addr = (U64)cpu_to_le64(cmd->ext_buf_phys); + LOG_FILE_INFO( + "hno:%u ioctl req num %d is bigger than req frame num %d\n", + PS3_HOST(instance), ioc->sgeCount, + PS3_FRAME_REQ_SGE_NUM_MGR); + pdst_sge->addr = + (unsigned long long)cpu_to_le64(cmd->ext_buf_phys); pdst_sge->length = 0; pdst_sge->ext = 1; - pdst_sge = (struct PS3Sge*)cmd->ext_buf; + pdst_sge = (struct PS3Sge *)cmd->ext_buf; cmd->req_frame->mgrReq.sgeCount++; - for (i = PS3_FRAME_REQ_SGE_NUM_MGR - 1; i < ioc->sgeCount; i++) { - LOG_DEBUG("trace_id[0x%llx], hno:%u sge[%u] size : %d\n", + for (i = PS3_FRAME_REQ_SGE_NUM_MGR - 1; i < ioc->sgeCount; + i++) { + LOG_DEBUG( + "trace_id[0x%llx], hno:%u sge[%u] size : %d\n", cmd->trace_id, PS3_HOST(instance), i, psrc_sge->length); pdst_sge->length = 0; if (psrc_sge->length > 0) { - ret = ps3_ioctl_sge_fill(instance, (U8*)ioc, psrc_sge, pdst_sge, + ret = ps3_ioctl_sge_fill( + instance, (unsigned char *)ioc, + psrc_sge, pdst_sge, &cmd->transient->transient_buff[i]); if (ret != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", - cmd->trace_id, PS3_HOST(instance), i, - ret); + LOG_ERROR( + "trace_id[0x%llx], hno:%u sge[%u] fill data error(%d)\n", + cmd->trace_id, + PS3_HOST(instance), i, ret); goto l_out; } } @@ -252,29 +275,33 @@ static S32 ps3_ioctl_sgl_fill(struct ps3_instance *instance, return ret; } -static S32 ps3_ioctl_complete(struct ps3_instance *instance, - struct ps3_cmd *cmd, - struct PS3IoctlSyncCmd* ioc) +static int ps3_ioctl_complete(struct ps3_instance *instance, + struct ps3_cmd *cmd, struct PS3IoctlSyncCmd *ioc) { - S32 ret = PS3_SUCCESS; - U32 i = 0; + int ret = PS3_SUCCESS; + unsigned int i = 0; - struct PS3Sge *psrc_sge = (struct PS3Sge*)((U32*)ioc + - ioc->sglOffset); + struct PS3Sge *psrc_sge = + (struct PS3Sge *)((unsigned int *)ioc + ioc->sglOffset); for (i = 0; i < ioc->sgeCount; i++) { - LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%d], transient_buff[%u] address: %p, data size: %d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, - i, cmd->transient->transient_buff[i], psrc_sge->length); + LOG_DEBUG( + "trace_id[0x%llx], hno:%u CFID [%d], transient_buff[%u] address: %p, data size: %d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, i, + cmd->transient->transient_buff[i], psrc_sge->length); if (psrc_sge->length > 0) { #ifdef _WINDOWS - memcpy((void*)((U8*)ioc + psrc_sge->addr), cmd->transient->transient_buff[i], psrc_sge->length); + memcpy((void *)((unsigned char *)ioc + psrc_sge->addr), + cmd->transient->transient_buff[i], + psrc_sge->length); #else - if (copy_to_user((void __user*)psrc_sge->addr, - cmd->transient->transient_buff[i], psrc_sge->length)) { + if (copy_to_user( + (void __user *)(uintptr_t)psrc_sge->addr, + cmd->transient->transient_buff[i], + psrc_sge->length)) { LOG_ERROR("hno:%u copy to user err\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -283,34 +310,41 @@ static S32 ps3_ioctl_complete(struct ps3_instance *instance, psrc_sge++; } #ifndef _WINDOWS - l_out: +l_out: #endif - LOG_FILE_INFO("trace_id[0x%llx], ioctl complete hno:%u CFID [%u], ret[%d]\n", + LOG_FILE_INFO( + "trace_id[0x%llx], ioctl complete hno:%u CFID [%u], ret[%d]\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); return ret; } -static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, - struct PS3IoctlSyncCmd* ioc) - +static int ps3_ioctl_mgr_handle(struct ps3_instance *instance, + struct PS3IoctlSyncCmd *ioc) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - S32 send_result = PS3_SUCCESS; - U8 retry_count = 0; + int send_result = PS3_SUCCESS; + unsigned char retry_count = 0; while (retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - if ((ret = ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE)) != PS3_SUCCESS) { - ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ret = ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE); + if (ret != PS3_SUCCESS) { + ps3_atomic_dec( + &instance->cmd_statistics.cmd_delivering); if (ret == -PS3_RECOVERED) { - if (++retry_count < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { - INJECT_START(PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, instance); - ret = ps3_instance_wait_for_normal(instance); + if (++retry_count < + PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + INJECT_START( + PS3_ERR_IJ_V2_FORCE_INSTANCE_STATE_NORMAL, + instance); + ret = ps3_instance_wait_for_normal( + instance); } } if (ret != PS3_SUCCESS) { - LOG_WARN_LIM("tid[0x%llx], hno:%u ioctl cmd pre check NOK ret:%d!\n", + LOG_WARN_LIM( + "tid[0x%llx], hno:%u ioctl cmd pre check NOK ret:%d!\n", ioc->traceId, PS3_HOST(instance), ret); goto l_no_free_cmd; } @@ -319,29 +353,31 @@ static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, break; } cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_ALLOC_CMD_FAILED, &cmd) + INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_ALLOC_CMD_FAILED, &cmd); if (cmd == NULL) { LOG_WARN("hno:%u ioctl req, not get a cmd packet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_no_free_cmd; } LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%u], get mgr cmd succeed\n", - cmd->trace_id, PS3_HOST(instance), cmd->index); + cmd->trace_id, PS3_HOST(instance), cmd->index); cmd->time_out = 0; cmd->is_interrupt = PS3_DRV_TRUE; if (ioc->traceId != 0) { ps3_cmd_trace_id_replace(cmd, ioc->traceId); - LOG_DEBUG("trace_id[0x%llx], hno:%u CFID [%u], change trace id from cli\n", + LOG_DEBUG( + "trace_id[0x%llx], hno:%u CFID [%u], change trace id from cli\n", cmd->trace_id, PS3_HOST(instance), cmd->index); } memset(&cmd->req_frame->mgrReq, 0, sizeof(struct PS3MgrReqFrame)); - memset(cmd->transient->transient_buff, 0, sizeof(void*) * PS3_MAX_IOCTL_SGE_NUM); + memset(cmd->transient->transient_buff, 0, + sizeof(void *) * PS3_MAX_IOCTL_SGE_NUM); ret = ps3_ioctl_sgl_fill(instance, cmd, ioc); if (ret != PS3_SUCCESS) { ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); @@ -354,26 +390,28 @@ static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_IRQ_DISABLE, cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } INJECT_START(PS3_ERR_IJ_IOCTL_CMD_NO_RESP, &send_result); ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { - LOG_ERROR("trace_id[0x%llx], hno:%u ioctl request no response!\n", + LOG_ERROR( + "trace_id[0x%llx], hno:%u ioctl request no response!\n", cmd->trace_id, PS3_HOST(instance)); goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request NOK!%d\n", + LOG_ERROR( + "trace_id[0x%llx], hno:%u ioctl send request NOK!%d\n", cmd->trace_id, PS3_HOST(instance), ret); goto l_out; } ret = ps3_ioctl_complete(instance, cmd, ioc); - LOG_INFO("trace_id[0x%llx], hno:%u CFID [%u], ioctl cmd_type[%d], sub_type[%d] end\n", + LOG_INFO( + "trace_id[0x%llx], hno:%u CFID [%u], ioctl cmd_type[%d], sub_type[%d] end\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ioc->msg.header.cmdType, ioc->msg.header.cmdSubType); @@ -386,35 +424,42 @@ static S32 ps3_ioctl_mgr_handle(struct ps3_instance *instance, #ifdef _WINDOWS -static U8 ps3_ioctl_windows_pre_check(struct ps3_instance *instance, - PPS3_IO_CONTROL ioctl) +static unsigned char ps3_ioctl_windows_pre_check(struct ps3_instance *instance, + struct _PS3_IO_CONTROL ioctl) { - U8 ret = PS3_TRUE; - U8 i = 0; - U8 *base_addr = (U8*)&ioctl->ps3Ioctl; - U8 *last_addr = base_addr + ioctl->SrbHeader.Length; + unsigned char ret = PS3_TRUE; + unsigned char i = 0; + unsigned char *base_addr = (unsigned char *)&ioctl->ps3Ioctl; + unsigned char *last_addr = base_addr + ioctl->SrbHeader.Length; if (ioctl->ps3Ioctl.data == NULL || ioctl->SrbHeader.Length == 0) { - LOG_WARN("hno:%u ioctl req, data is [%p], or data len is [%llu]\n", - PS3_HOST(instance), ioctl->ps3Ioctl.data, ioctl->SrbHeader.Length); + LOG_WARN( + "hno:%u ioctl req, data is [%p], or data len is [%llu]\n", + PS3_HOST(instance), ioctl->ps3Ioctl.data, + ioctl->SrbHeader.Length); ret = PS3_FALSE; goto l_out; } - if (ps3_ioctl_capbility_pre_check(instance, &ioctl->ps3Ioctl) != PS3_SUCCESS) { + if (ps3_ioctl_capbility_pre_check(instance, &ioctl->ps3Ioctl) != + PS3_SUCCESS) { ret = PS3_FALSE; goto l_out; } LOG_INFO("hno:%u base_addr[%p], Length[%d], last_addr[%p]\n", - PS3_HOST(instance), base_addr, ioctl->SrbHeader.Length, last_addr); + PS3_HOST(instance), base_addr, ioctl->SrbHeader.Length, + last_addr); for (i = 0; i < ioctl->ps3Ioctl.sgeCount; i++) { if (base_addr + ioctl->ps3Ioctl.Sgl[i].addr + - ioctl->ps3Ioctl.Sgl[i].length > last_addr) { - - LOG_ERROR("hno:%u ioctl req, sge[%d] len[%d] > total len[%d], sge offset[%p], base addr[%p]\n", - PS3_HOST(instance), i, ioctl->ps3Ioctl.Sgl[i].length, ioctl->SrbHeader.Length, + ioctl->ps3Ioctl.Sgl[i].length > + last_addr) { + LOG_ERROR( + "hno:%u ioctl req, sge[%d] len[%d] > total len[%d], sge offset[%p], base addr[%p]\n", + PS3_HOST(instance), i, + ioctl->ps3Ioctl.Sgl[i].length, + ioctl->SrbHeader.Length, ioctl->ps3Ioctl.Sgl[i].addr, &ioctl->ps3Ioctl); ret = PS3_FALSE; goto l_out; @@ -427,33 +472,34 @@ static U8 ps3_ioctl_windows_pre_check(struct ps3_instance *instance, return ret; } -S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags) +int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; struct ps3_instance *instance = cmd->instance; - S32 send_result = -PS3_RESP_ERR; + int send_result = -PS3_RESP_ERR; SCSI_REQUEST_BLOCK *srb = cmd->srb; - PPS3_IO_CONTROL ps3_ioctl = NULL; + struct _PS3_IO_CONTROL ps3_ioctl = NULL; - LOG_DEBUG("hno:%u trace_id[0x%llx], got a ioctl response, reply_flags[0x%x]\n", + LOG_DEBUG( + "hno:%u trace_id[0x%llx], got a ioctl response, reply_flags[0x%x]\n", PS3_HOST(instance), cmd->trace_id, reply_flags); PS3_MGR_CMD_BACK_INC(instance, cmd, reply_flags); if (unlikely(reply_flags != PS3_REPLY_WORD_FLAG_SUCCESS) && - cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { LOG_ERROR("trace_id[0x%llx], hno:%u ioctl cmd return failed\n", - cmd->trace_id, PS3_HOST(instance)); + cmd->trace_id, PS3_HOST(instance)); ret = ps3_err_mgr_cmd_proc(instance, send_result, cmd); - if (ret == -PS3_CMD_NO_RESP) { + if (ret == -PS3_CMD_NO_RESP) ret = ps3_mgr_cmd_no_resp_proc(instance, cmd); - } if (ret != -PS3_RETRY) { LOG_WARN("hno:%u CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt, ret); + PS3_HOST(instance), cmd->index, cmd->retry_cnt, + ret); goto l_out; } @@ -463,16 +509,17 @@ S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags) cmd->retry_cnt++; if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { LOG_ERROR("hno:%u retry time full.\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - LOG_INFO("hno:%u mgr CFID[%d] retry:%u\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + LOG_INFO("hno:%u mgr CFID[%d] retry:%u\n", PS3_HOST(instance), + cmd->index, cmd->retry_cnt); ret = ps3_srb_send(instance, srb); if (ret != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", + LOG_ERROR( + "trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", cmd->trace_id, PS3_HOST(instance), ret); goto l_out; } @@ -482,12 +529,13 @@ S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags) l_out: SrbSetSrbStatus(srb, SRB_STATUS_ERROR); - if((cmd->resp_frame->normalRespFrame.respStatus == PS3_DRV_MGR_RESTART_COMMAND_RSP) && - (reply_flags == PS3_REPLY_WORD_FLAG_FAIL)){ - reply_flags = PS3_REPLY_WORD_FLAG_SUCCESS; + if ((cmd->resp_frame->normalRespFrame.respStatus == + PS3_DRV_MGR_RESTART_COMMAND_RSP) && + (reply_flags == PS3_REPLY_WORD_FLAG_FAIL)) { + reply_flags = PS3_REPLY_WORD_FLAG_SUCCESS; } if (likely(reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { - ps3_ioctl = (PPS3_IO_CONTROL)SrbGetDataBuffer(srb); + ps3_ioctl = (struct _PS3_IO_CONTROL)SrbGetDataBuffer(srb); ps3_ioctl_complete(instance, cmd, &ps3_ioctl->ps3Ioctl); SrbSetSrbStatus(srb, SRB_STATUS_SUCCESS); } @@ -498,38 +546,45 @@ S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags) ps3_atomic_dec(&instance->ioctl_count); l_retry: - LOG_DEBUG("hno:%u trace_id[0x%llx], end proc a ioctl response, ret[%d]\n", + LOG_DEBUG( + "hno:%u trace_id[0x%llx], end proc a ioctl response, ret[%d]\n", PS3_HOST(instance), cmd->trace_id, ret); return ret; } -U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb) +unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, + _In_ PSCSI_REQUEST_BLOCK Srb) { - U8 ret = PS3_FALSE; - PPS3_IO_CONTROL ps3_ioctl = (PPS3_IO_CONTROL)SrbGetDataBuffer(Srb); - - LOG_INFO("ioctl parase: Type[0x%x], Method[0x%x], Function[0x%x], Access[0x%x] \n", - DEVICE_TYPE_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), METHOD_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), - PS3_FUNC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), PS3_ACC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode)); - - if (memcmp(ps3_ioctl->SrbHeader.Signature, PS3_IOCTL_SIG, sizeof(PS3_IOCTL_SIG)) != 0) { - LOG_ERROR("hno:%u ioctl signature error\n", - PS3_HOST(instance)); + unsigned char ret = PS3_FALSE; + struct _PS3_IO_CONTROL ps3_ioctl = + (struct _PS3_IO_CONTROL)SrbGetDataBuffer(Srb); + + LOG_INFO( + "ioctl parase: Type[0x%x], Method[0x%x], Function[0x%x], Access[0x%x]\n", + DEVICE_TYPE_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), + METHOD_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), + PS3_FUNC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode), + PS3_ACC_FROM_CTL_CODE(ps3_ioctl->SrbHeader.ControlCode)); + + if (memcmp(ps3_ioctl->SrbHeader.Signature, PS3_IOCTL_SIG, + sizeof(PS3_IOCTL_SIG)) != 0) { + LOG_ERROR("hno:%u ioctl signature error\n", PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_INVALID_REQUEST); goto l_out; } if (!instance->state_machine.is_load) { - LOG_WARN("trace_id[0x%llx], hno:%u instance state not is_load\n", + LOG_WARN( + "trace_id[0x%llx], hno:%u instance state not is_load\n", ps3_ioctl->ps3Ioctl.traceId, PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_NO_HBA); goto l_out; } - if (!ps3_atomic_add_unless(&instance->ioctl_count, 1, PS3_MAX_IOCTL_CMDS)) { - LOG_WARN("hno:%u ioctl concurrency full\n", - PS3_HOST(instance)); + if (!ps3_atomic_add_unless(&instance->ioctl_count, 1, + PS3_MAX_IOCTL_CMDS)) { + LOG_WARN("hno:%u ioctl concurrency full\n", PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_BUSY); goto l_out; @@ -543,15 +598,15 @@ U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLO ret = ps3_ioctl_windows_pre_check(instance, ps3_ioctl); if (!ret) { LOG_WARN("hno:%u ioctl capblity not support\n", - PS3_HOST(instance)); + PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_INVALID_REQUEST); ps3_atomic_dec(&instance->ioctl_count); goto l_out; } - if (ps3_ioctl_mgr_handle(instance, &ps3_ioctl->ps3Ioctl, Srb) != PS3_SUCCESS) { - LOG_ERROR("hno:%u ioctl handle err\n", - PS3_HOST(instance)); + if (ps3_ioctl_mgr_handle(instance, &ps3_ioctl->ps3Ioctl, Srb) != + PS3_SUCCESS) { + LOG_ERROR("hno:%u ioctl handle err\n", PS3_HOST(instance)); SrbSetSrbStatus(Srb, SRB_STATUS_ERROR); ps3_atomic_dec(&instance->ioctl_count); goto l_out; @@ -560,22 +615,24 @@ U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLO ret = PS3_TRUE; SrbSetSrbStatus(Srb, SRB_STATUS_SUCCESS); l_out: - if (!ret) { + if (!ret) StorPortNotification(RequestComplete, instance, Srb); - } return ret; } -U8 ps3_ioctl_start_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb) +unsigned char ps3_ioctl_start_io(_In_ struct ps3_instance *instance, + _In_ PSCSI_REQUEST_BLOCK Srb) { struct ps3_cmd *cmd = ps3_cmd_from_srb_extension_get(Srb); - U8 ret = PS3_FALSE; - S32 ret_tmp = PS3_SUCCESS; + unsigned char ret = PS3_FALSE; + int ret_tmp = PS3_SUCCESS; + SrbSetSrbStatus(Srb, SRB_STATUS_ERROR); ret_tmp = ps3_srb_send(instance, Srb); if (ret_tmp != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", + LOG_ERROR( + "trace_id[0x%llx], hno:%u ioctl send request failed!%d\n", cmd->trace_id, PS3_HOST(instance), ret_tmp); goto l_out; } @@ -594,26 +651,26 @@ U8 ps3_ioctl_start_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLO #else -static S32 ps3_ioctl_mgr_sync(ULong arg) +static int ps3_ioctl_mgr_sync(unsigned long arg) { - S32 ret = PS3_SUCCESS; - struct PS3IoctlSyncCmd* ioc = NULL; + int ret = PS3_SUCCESS; + struct PS3IoctlSyncCmd *ioc = NULL; struct ps3_instance *instance = NULL; - struct PS3IoctlSyncCmd __user* user_ioc = - (struct PS3IoctlSyncCmd __user*)arg; + struct PS3IoctlSyncCmd __user *user_ioc = + (struct PS3IoctlSyncCmd __user *)arg; - ioc = (struct PS3IoctlSyncCmd*)memdup_user( - (const void __user*)user_ioc, sizeof(*ioc)); - INJECT_START(PS3_ERR_IJ_FORCE_MEMDUP_USER_RETURN_FAILED, &ioc) + ioc = (struct PS3IoctlSyncCmd *)memdup_user( + (const void __user *)user_ioc, sizeof(*ioc)); + INJECT_START(PS3_ERR_IJ_FORCE_MEMDUP_USER_RETURN_FAILED, &ioc); if (IS_ERR(ioc)) { LOG_ERROR("ioctl memdup_user err\n"); return PTR_ERR(ioc); } - LOG_INFO("ioctl ps3_ioctl_sync_cmd: trace_id[0x%llx], hno:%u " - "cmd_type[%d], sgl_offset[%d], sge_count[%d], result[%d]\n", - ioc->traceId, ioc->hostId, ioc->msg.header.cmdType, - ioc->sglOffset, ioc->sgeCount, ioc->resultCode); + LOG_INFO("ioctl ps3_ioctl_sync_cmd: trace_id[0x%llx], hno:%u\n" + "\tcmd_type[%d], sgl_offset[%d], sge_count[%d], result[%d]\n", + ioc->traceId, ioc->hostId, ioc->msg.header.cmdType, + ioc->sglOffset, ioc->sgeCount, ioc->resultCode); ps3_mutex_lock(&ps3_mgmt_info_get()->ps3_mgmt_lock); instance = ps3_instance_lookup(ioc->hostId); @@ -627,16 +684,17 @@ static S32 ps3_ioctl_mgr_sync(ULong arg) if (!instance->state_machine.is_load) { ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); LOG_WARN("trace_id[0x%llx], hno:%u instance state [%d]\n", - ioc->traceId, PS3_HOST(instance), - instance->state_machine.is_load); + ioc->traceId, PS3_HOST(instance), + instance->state_machine.is_load); ret = -ENODEV; goto l_out_free_ioc; } - INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, instance) + INJECT_START(PS3_ERR_IJ_SCSI_SCAN_HOST_NOT_FINISH, instance); if (!instance->is_scan_host_finish) { ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - LOG_WARN("trace_id[0x%llx], hno:%u instance scan host not finish\n", + LOG_WARN( + "trace_id[0x%llx], hno:%u instance scan host not finish\n", ioc->traceId, PS3_HOST(instance)); ret = -EAGAIN; goto l_out_free_ioc; @@ -645,11 +703,9 @@ static S32 ps3_ioctl_mgr_sync(ULong arg) ps3_atomic_inc(&instance->cmd_statistics.cli_cnt); ps3_mutex_unlock(&ps3_mgmt_info_get()->ps3_mgmt_lock); - LOG_FILE_INFO("hno:%u ioctl ready get sem\n", - PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u ioctl ready get sem\n", PS3_HOST(instance)); if (down_interruptible(&instance->ioctl_sem)) { - LOG_WARN("hno:%u ioctl concurrency full\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u ioctl concurrency full\n", PS3_HOST(instance)); ret = -ERESTARTSYS; goto l_out_dec_cnt; } @@ -657,49 +713,58 @@ static S32 ps3_ioctl_mgr_sync(ULong arg) ret = ps3_instance_wait_for_normal(instance); INJECT_START(PS3_ERR_IJ_FORCE_IOCTL_WAIT_NORMAL_FAILED, &ret); if (ret != PS3_SUCCESS) { - LOG_WARN("trace_id[0x%llx], hno:%u instance state not allowed ioctl req\n", + LOG_WARN( + "trace_id[0x%llx], hno:%u instance state not allowed ioctl req\n", ioc->traceId, PS3_HOST(instance)); ret = -ENODEV; goto l_out_up; } - LOG_INFO("hno:%u ioctl got sem\n", - PS3_HOST(instance)); - - if (ioc->msg.header.cmdType == PS3_IOCTL_CMD_WEB_SUBSCRIBE) { - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) != 1) { - if (ps3_atomic_add_unless(&instance->webSubscribe_context.subscribe_count, 1, 1) != 0) { - ret = ps3_web_subscribe(instance); - if (ret != PS3_SUCCESS) { - ps3_atomic_set(&instance->webSubscribe_context.subscribe_count, 0); - ret = -EBUSY; - goto l_out_up; - } - ps3_atomic_set(&instance->webSubscribe_context.is_subscribe, 1); - goto l_out_dec_cnt; - } else { - ret = -EAGAIN; - goto l_out_up; - } - } else { - ret = PS3_SUCCESS; - goto l_out_up; - } - } else { - ret = ps3_ioctl_capbility_pre_check(instance, ioc); - if (ret != PS3_SUCCESS) { - LOG_WARN("hno:%u ioctl capblity not support\n", - PS3_HOST(instance)); - ret = -EINVAL; - goto l_out_up; - } - ret = ps3_ioctl_mgr_handle(instance, ioc); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u ioctl handle NOK\n", - PS3_HOST(instance)); - ret = -EBUSY; - } - } + LOG_INFO("hno:%u ioctl got sem\n", PS3_HOST(instance)); + + if (ioc->msg.header.cmdType == PS3_IOCTL_CMD_WEB_SUBSCRIBE) { + if (ps3_atomic_read( + &instance->webSubscribe_context.is_subscribe) != + 1) { + if (ps3_atomic_add_unless(&instance->webSubscribe_context + .subscribe_count, + 1, 1) != 0) { + ret = ps3_web_subscribe(instance); + if (ret != PS3_SUCCESS) { + ps3_atomic_set( + &instance->webSubscribe_context + .subscribe_count, + 0); + ret = -EBUSY; + goto l_out_up; + } + ps3_atomic_set(&instance->webSubscribe_context + .is_subscribe, + 1); + goto l_out_dec_cnt; + } else { + ret = -EAGAIN; + goto l_out_up; + } + } else { + ret = PS3_SUCCESS; + goto l_out_up; + } + } else { + ret = ps3_ioctl_capbility_pre_check(instance, ioc); + if (ret != PS3_SUCCESS) { + LOG_WARN("hno:%u ioctl capblity not support\n", + PS3_HOST(instance)); + ret = -EINVAL; + goto l_out_up; + } + ret = ps3_ioctl_mgr_handle(instance, ioc); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u ioctl handle NOK\n", + PS3_HOST(instance)); + ret = -EBUSY; + } + } l_out_up: up(&instance->ioctl_sem); @@ -710,31 +775,17 @@ static S32 ps3_ioctl_mgr_sync(ULong arg) return ret; } -#if 0 -static S32 ps3_ioctl_mgr_async(struct file *file, ULong arg) +long ps3_ioctl_fops(struct file *file, unsigned int cmd, unsigned long arg) { - (void)file; - (void)arg; - return PS3_SUCCESS; -} -#endif + int ret = -ENOTTY; -long ps3_ioctl_fops(struct file *file, U32 cmd, ULong arg) -{ - S32 ret = -ENOTTY; - if (file == NULL || arg == 0) { + if (file == NULL || arg == 0) goto l_out; - } switch (cmd) { case PS3_CMD_IOCTL_SYNC_CMD: ret = ps3_ioctl_mgr_sync(arg); break; -#if 0 - case PS3_CMD_IOCTL_ASYNC_CMD: - return ps3_ioctl_mgr_async(file, arg); - break; -#endif default: break; } @@ -742,23 +793,24 @@ long ps3_ioctl_fops(struct file *file, U32 cmd, ULong arg) return ret; } -void ps3_clean_mgr_cmd(struct ps3_instance *instance) +static void ps3_clean_mgr_cmd(struct ps3_instance *instance) { struct ps3_cmd_context *context = &instance->cmd_context; - U32 mgr_cmd_idx = 0; - U32 mgr_start_idx = context->max_scsi_cmd_count; - U32 mgr_end_idx = context->max_scsi_cmd_count + - instance->max_mgr_cmd_count; + unsigned int mgr_cmd_idx = 0; + unsigned int mgr_start_idx = context->max_scsi_cmd_count; + unsigned int mgr_end_idx = + context->max_scsi_cmd_count + instance->max_mgr_cmd_count; struct ps3_cmd *cmd = NULL; for (mgr_cmd_idx = mgr_start_idx; mgr_cmd_idx < mgr_end_idx; - mgr_cmd_idx++) { + mgr_cmd_idx++) { cmd = context->cmd_buf[mgr_cmd_idx]; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { LOG_WARN("hno:%u mgr cmd[%d] complete force!\n", - PS3_HOST(instance), cmd->index); + PS3_HOST(instance), cmd->index); - cmd->resp_frame->normalRespFrame.respStatus = PS3_MGR_REC_FORCE; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_MGR_REC_FORCE; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); } @@ -768,13 +820,12 @@ void ps3_clean_mgr_cmd(struct ps3_instance *instance) void ps3_ioctl_clean(struct ps3_instance *instance) { if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_QUIT){ + PS3_INSTANCE_STATE_QUIT) { goto l_out; } while (ps3_atomic_read(&instance->cmd_statistics.cli_cnt) != 0) { - LOG_INFO("hno:%u ioctls not finish\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u ioctls not finish\n", PS3_HOST(instance)); ps3_clean_mgr_cmd(instance); ps3_msleep(1000); } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h index 01ad0c7e9744..a373a2a007f0 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_ioctl.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IOCTL_H_ #define _PS3_IOCTL_H_ @@ -9,22 +9,24 @@ #include "ps3_cmd_channel.h" #include "ps3_htp_ioctl.h" -#define PS3_MAX_IOCTL_CMDS 3 +#define PS3_MAX_IOCTL_CMDS 3 #ifdef _WINDOWS -U8 ps3_ioctl_start_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb); -U8 ps3_ioctl_build_io(_In_ struct ps3_instance *instance, _In_ PSCSI_REQUEST_BLOCK Srb); +unsigned char ps3_ioctl_start_io(_In_ struct ps3_instance *instance, + _In_ PSCSI_REQUEST_BLOCK Srb); +unsigned char ps3_ioctl_build_io(_In_ struct ps3_instance *instance, + _In_ PSCSI_REQUEST_BLOCK Srb); #else -long ps3_ioctl_fops(struct file *file, U32 cmd, ULong arg); +long ps3_ioctl_fops(struct file *file, unsigned int cmd, unsigned long arg); #endif -S32 ps3_ioctl_init(struct ps3_instance *instance, S32 cmd_num); +int ps3_ioctl_init(struct ps3_instance *instance, int cmd_num); void ps3_ioctl_buff_release(struct ps3_cmd *cmd); -inline static void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) +static inline void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) { - PS3MgrReqFrame_s* mgr_req = &cmd->req_frame->mgrReq; + struct PS3MgrReqFrame *mgr_req = &cmd->req_frame->mgrReq; mgr_req->reqHead.traceID = cmd->trace_id; mgr_req->reqHead.cmdType = PS3_CMD_IOCTL; @@ -35,10 +37,12 @@ inline static void ps3_ioctl_req_frame_build(struct ps3_cmd *cmd) mgr_req->syncFlag = 1; } -inline static void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 cmd_frame_id) +static inline void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned short cmd_frame_id) { - struct PS3CmdWord* cmd_word = &cmd->cmd_word; + struct PS3CmdWord *cmd_word = &cmd->cmd_word; + memset(cmd_word, 0, sizeof(*cmd_word)); (void)instance; @@ -51,11 +55,10 @@ inline static void ps3_ioctl_cmd_word_build(struct ps3_instance *instance, #endif } -S32 ps3_ioctl_callback_proc(struct ps3_cmd *cmd, U8 reply_flags); +int ps3_ioctl_callback_proc(struct ps3_cmd *cmd, unsigned char reply_flags); void ps3_ioctl_clean(struct ps3_instance *instance); void ps3_ioctl_buff_bit_pos_update(struct ps3_cmd *cmd); #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_irq.c b/drivers/scsi/linkdata/ps3stor/ps3_irq.c index e386f507e730..12064a948683 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_irq.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_irq.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_irq.h" #ifndef _WINDOWS @@ -17,53 +18,58 @@ #ifndef _WINDOWS -const U32 PS3_INTERRUPT_STATUS_NO_IRQ = 0x00; -const U32 PS3_INTERRUPT_CMD_DISABLE_ALL_MASK = 0x02; -const U32 PS3_INTERRUPT_CMD_ENABLE_MSIX = 0x01; -const U32 PS3_INTERRUPT_MASK_DISABLE = 0x00000002; -const U32 PS3_INTERRUPT_STATUS_EXIST_IRQ = 0x00000001; -const U32 PS3_INTERRUPT_CLEAR_IRQ= 0x00000001; - -const U32 PS3_SSD_IOPS_MSIX_VECTORS = 8; -const U32 PS3_HDD_IOPS_MSIX_VECTORS = 8; -const U32 PS3_IRQ_POLL_SCHED_THRESHOLD = 1024; -const U32 PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT = 5; -const U32 PS3_BALANCE_MODE_MIN_CPU_NUM = 16; -const S32 PS3_SSD_MAX_BUSY_THRESHOLD = 40; -const U32 PS3_IOPS_MSIX_VECTORS = 12; -const S32 PS3_HYGON_BUSY_ADJUST_THRESHOLD = 32; -const U32 PS3_MSIX_COMBINED_MODE_MSIX_VECTORS = 16; - -#define PS3_IRQCTX_HOST(irq_context) \ - ps3_container_of((irq_context), struct ps3_instance, irq_context)->host->host_no - -#define PS3_MGR_CMD_MSIX_INDEX(irq_context) ((irq_context)->high_iops_msix_vectors) -#define IS_HIGN_OPS_IRQ(irq_context, irq) \ +static const unsigned int PS3_INTERRUPT_CMD_DISABLE_ALL_MASK = 0x02; +static const unsigned int PS3_INTERRUPT_CMD_ENABLE_MSIX = 0x01; +static const unsigned int PS3_INTERRUPT_MASK_DISABLE = 0x00000002; +static const unsigned int PS3_INTERRUPT_STATUS_EXIST_IRQ = 0x00000001; +static const unsigned int PS3_INTERRUPT_CLEAR_IRQ = 0x00000001; + +static const unsigned int PS3_SSD_IOPS_MSIX_VECTORS = 8; +static const unsigned int PS3_HDD_IOPS_MSIX_VECTORS = 8; +static const unsigned int PS3_IRQ_POLL_SCHED_THRESHOLD = 1024; +static const unsigned int PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT = 5; +static const unsigned int PS3_BALANCE_MODE_MIN_CPU_NUM = 16; +static const int PS3_SSD_MAX_BUSY_THRESHOLD = 40; +static const unsigned int PS3_IOPS_MSIX_VECTORS = 12; +static const int PS3_HYGON_BUSY_ADJUST_THRESHOLD = 32; +static const unsigned int PS3_MSIX_COMBINED_MODE_MSIX_VECTORS = 16; + +#define PS3_IRQCTX_HOST(irq_context) \ + (ps3_container_of((irq_context), struct ps3_instance, irq_context) \ + ->host->host_no) + +#define PS3_MGR_CMD_MSIX_INDEX(irq_context) \ + ((irq_context)->high_iops_msix_vectors) +#define IS_HIGN_OPS_IRQ(irq_context, irq) \ (((irq_context)->high_iops_msix_vectors > (irq)->isrSN)) #define PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(var, base) ((var) > (base)) static void msix_irq_mode_check(struct ps3_irq_context *irq_context, - U32 max_vectors) + unsigned int max_vectors) { - U32 online_cpu_num = num_online_cpus(); - U16 speed = 0; - U16 lnksta = 0; - U32 iops_msix_cnt = 0; + unsigned int online_cpu_num = num_online_cpus(); + unsigned short speed = 0; + unsigned short lnksta = 0; + unsigned int iops_msix_cnt = 0; if (!ps3_ioc_multi_func_support(irq_context->instance) || - ps3_get_pci_function(irq_context->instance->pdev) == PS3_FUNC_ID_1) { + ps3_get_pci_function(irq_context->instance->pdev) == + PS3_FUNC_ID_1) { iops_msix_cnt = PS3_IOPS_MSIX_VECTORS; } else { iops_msix_cnt = 0; } - pcie_capability_read_word(irq_context->instance->pdev, PCI_EXP_LNKSTA, &lnksta); + pcie_capability_read_word(irq_context->instance->pdev, PCI_EXP_LNKSTA, + &lnksta); speed = lnksta & PCI_EXP_LNKSTA_CLS; - if ((iops_msix_cnt > 0) && (online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && + if (!ps3_latency_perf_mode_query() && (iops_msix_cnt > 0) && + (online_cpu_num >= PS3_BALANCE_MODE_MIN_CPU_NUM) && (iops_msix_cnt < max_vectors) && (speed >= 0x4)) { irq_context->high_iops_msix_vectors = iops_msix_cnt; - irq_context->valid_msix_vector_count = - min(irq_context->high_iops_msix_vectors + online_cpu_num, max_vectors); + irq_context->valid_msix_vector_count = min( + irq_context->high_iops_msix_vectors + online_cpu_num, + max_vectors); irq_context->is_support_balance = PS3_TRUE; irq_context->is_balance_current_perf_mode = PS3_TRUE; } else { @@ -73,13 +79,11 @@ static void msix_irq_mode_check(struct ps3_irq_context *irq_context, irq_context->valid_msix_vector_count = min(online_cpu_num, max_vectors); } - - return; } -static inline Bool ps3_is_linx80_os(void) +static inline unsigned char ps3_is_linx80_os(void) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; #if (!defined(PS3_OS_MANAGED_IRQ_SUPPORT)) ret = PS3_TRUE; #endif @@ -87,143 +91,148 @@ static inline Bool ps3_is_linx80_os(void) return ret; } -static inline Bool ps3_support_irq_affinity(void) +static inline unsigned char ps3_support_irq_affinity(void) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; #if defined(DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY) ret = PS3_TRUE; #endif if (!ret) { - if (strstr(ps3_host_release_get(), "an8")) { + if (strstr(ps3_host_release_get(), "an8")) ret = PS3_TRUE; - } } return ret; } -static U32 __ps3_irq_vectors_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static unsigned int __ps3_irq_vectors_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { int msix_vectors = 0; - U32 irq_flags = PCI_IRQ_MSIX | PCI_IRQ_MSI; + unsigned int irq_flags = PCI_IRQ_MSIX | PCI_IRQ_MSI; struct ps3_instance *instance = irq_context->instance; - U32 ps3_irq_mode = ps3_pci_irq_mode_query(); + unsigned int ps3_irq_mode = ps3_pci_irq_mode_query(); struct irq_affinity *descp = NULL; #if defined(PS3_OS_MANAGED_IRQ_SUPPORT) - struct irq_affinity desc = { .pre_vectors = irq_context->high_iops_msix_vectors }; + struct irq_affinity desc = { + .pre_vectors = irq_context->high_iops_msix_vectors + }; descp = &desc; #endif switch (ps3_irq_mode) { - case PS3_PCI_IRQ_MODE_LEGACY: - irq_flags = PCI_IRQ_LEGACY; - break; - case PS3_PCI_IRQ_MODE_MSI: - irq_flags = PCI_IRQ_MSI; - break; - case PS3_PCI_IRQ_MODE_MSIX: - irq_flags = PCI_IRQ_MSIX; - break; - default: - break; + case PS3_PCI_IRQ_MODE_LEGACY: +#if defined(PS3_OS_IRQ_INTX) + irq_flags = PCI_IRQ_INTX; +#else + irq_flags = PCI_IRQ_LEGACY; +#endif + break; + case PS3_PCI_IRQ_MODE_MSI: + irq_flags = PCI_IRQ_MSI; + break; + case PS3_PCI_IRQ_MODE_MSIX: + irq_flags = PCI_IRQ_MSIX; + break; + default: + break; } if (ps3_support_irq_affinity() || ps3_is_linx80_os()) { - if (irq_context->instance->smp_affinity_enable) { + if (irq_context->instance->smp_affinity_enable) irq_flags |= PCI_IRQ_AFFINITY; - } else { + else descp = NULL; - } } else { if (irq_context->is_support_balance == PS3_TRUE && - irq_context->is_balance_current_perf_mode == PS3_TRUE) { + irq_context->is_balance_current_perf_mode == PS3_TRUE) { descp = NULL; } else { - if (irq_context->instance->smp_affinity_enable) { + if (irq_context->instance->smp_affinity_enable) irq_flags |= PCI_IRQ_AFFINITY; - } else { + else descp = NULL; - } } } - LOG_INFO("host_no:%u pci_irq_mode:%d specified, msix_vectors:%d max:%d\n", + LOG_INFO( + "host_no:%u pci_irq_mode:%d specified, msix_vectors:%d max:%d\n", PS3_IRQCTX_HOST(irq_context), ps3_irq_mode, irq_context->high_iops_msix_vectors, irq_context->valid_msix_vector_count); #if defined(PS3_OS_MANAGED_IRQ_SUPPORT) - msix_vectors = pci_alloc_irq_vectors_affinity(pdev, - max(instance->min_intr_count, irq_context->high_iops_msix_vectors), + msix_vectors = pci_alloc_irq_vectors_affinity( + pdev, + max(instance->min_intr_count, + irq_context->high_iops_msix_vectors), irq_context->valid_msix_vector_count, irq_flags, descp); #else - msix_vectors = pci_alloc_irq_vectors(pdev, - max(instance->min_intr_count, irq_context->high_iops_msix_vectors), - irq_context->valid_msix_vector_count, irq_flags); + msix_vectors = + pci_alloc_irq_vectors(pdev, + max(instance->min_intr_count, + irq_context->high_iops_msix_vectors), + irq_context->valid_msix_vector_count, + irq_flags); #endif if (msix_vectors <= 0) { LOG_WARN("host_no:%u alloc msi irq fail! msix_vectors:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); msix_vectors = 0; } else { if (pdev->msix_enabled == 1) { irq_context->pci_irq_type = PS3_PCI_IRQ_MSIX; LOG_DEBUG("host_no:%u alloc msix count:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); } else if (pdev->msi_enabled == 1) { irq_context->pci_irq_type = PS3_PCI_IRQ_MSI; LOG_DEBUG("host_no:%u alloc msi count:%d\n", - PS3_IRQCTX_HOST(irq_context), msix_vectors); + PS3_IRQCTX_HOST(irq_context), msix_vectors); } else { - LOG_ERROR("host_no:%u msi/msix all disable, msix_vectors:%d\n", + LOG_ERROR( + "host_no:%u msi/msix all disable, msix_vectors:%d\n", PS3_IRQCTX_HOST(irq_context), msix_vectors); } } - return (U32)msix_vectors; + return (unsigned int)msix_vectors; } -static void ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static void +ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - U32 msix_vector = 0; - U32 os_vector = 0; - S32 node = -1; - const struct cpumask* mask = NULL; - S32 cpu_id = 0; + unsigned int msix_vector = 0; + unsigned int os_vector = 0; + int node = -1; + const struct cpumask *mask = NULL; + int cpu_id = 0; - if (!ps3_support_irq_affinity()) { + if (!ps3_support_irq_affinity()) goto l_out; - } - if (!irq_context->is_support_balance) { + if (!irq_context->is_support_balance) goto l_out; - } - if (!irq_context->instance->smp_affinity_enable) { + if (!irq_context->instance->smp_affinity_enable) goto l_out; - } node = dev_to_node(&pdev->dev); - if (node >= 0) { + if (node >= 0) mask = cpumask_of_node(node); - } - if (mask == NULL) { + if (mask == NULL) mask = cpu_online_mask; - } for_each_cpu_and(cpu_id, mask, cpu_online_mask) { - LOG_DEBUG("host_no:%u affinity_hint cpu_id:%d, node:%d \n", - PS3_IRQCTX_HOST(irq_context), cpu_id, node); + LOG_DEBUG("host_no:%u affinity_hint cpu_id:%d, node:%d\n", + PS3_IRQCTX_HOST(irq_context), cpu_id, node); } - for (msix_vector = 0; - msix_vector < irq_context->high_iops_msix_vectors; - msix_vector++) { + for (msix_vector = 0; msix_vector < irq_context->high_iops_msix_vectors; + msix_vector++) { os_vector = pci_irq_vector(pdev, msix_vector); irq_set_affinity_hint(os_vector, mask); } @@ -231,17 +240,18 @@ static void ps3_iops_vectors_affinity_hint_set(struct pci_dev *pdev, return; } -static U32 ps3_irq_vectors_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context, - U32 max_vectors) +static unsigned int ps3_irq_vectors_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context, + unsigned int max_vectors) { - U32 msix_vectors = 0; - S32 nr_entries = 0; + unsigned int msix_vectors = 0; + int nr_entries = 0; + msix_irq_mode_check(irq_context, max_vectors); msix_vectors = __ps3_irq_vectors_alloc(pdev, irq_context); if ((msix_vectors != irq_context->valid_msix_vector_count) && - (irq_context->is_support_balance)) { + (irq_context->is_support_balance)) { pci_free_irq_vectors(pdev); irq_context->is_support_balance = PS3_FALSE; irq_context->is_balance_current_perf_mode = PS3_FALSE; @@ -249,10 +259,10 @@ static U32 ps3_irq_vectors_alloc(struct pci_dev *pdev, irq_context->valid_msix_vector_count = min(num_online_cpus(), max_vectors); msix_vectors = __ps3_irq_vectors_alloc(pdev, irq_context); - LOG_DEBUG("host_no:%u alloc resource for normal perf mode! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_DEBUG("host_no:%u alloc resource for normal perf mode!\n", + PS3_IRQCTX_HOST(irq_context)); } - INJECT_START(PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, &msix_vectors) + INJECT_START(PS3_ERR_IJ_IRQ_VECTORS_ALLOC_FAILED, &msix_vectors); if (msix_vectors > 0) { irq_context->valid_msix_vector_count = msix_vectors; ps3_iops_vectors_affinity_hint_set(pdev, irq_context); @@ -260,130 +270,146 @@ static U32 ps3_irq_vectors_alloc(struct pci_dev *pdev, irq_context->high_iops_msix_vectors = 0; irq_context->is_support_balance = PS3_FALSE; irq_context->is_balance_current_perf_mode = PS3_FALSE; +#if defined(PS3_OS_IRQ_INTX) + nr_entries = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_INTX); +#else nr_entries = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY); - INJECT_START(PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, &nr_entries) +#endif + INJECT_START(PS3_ERR_IJ_ALLOC_LEGACY_VECTOR_FAILED, &nr_entries); if (nr_entries != 1) { - LOG_ERROR("host_no:%u alloc irq fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u alloc irq fail!\n", + PS3_IRQCTX_HOST(irq_context)); irq_context->valid_msix_vector_count = 0; } else { irq_context->valid_msix_vector_count = 1; irq_context->pci_irq_type = PS3_PCI_IRQ_LEGACY; LOG_DEBUG("host_no:%u alloc legacy irq\n", - PS3_IRQCTX_HOST(irq_context)); + PS3_IRQCTX_HOST(irq_context)); } } return irq_context->valid_msix_vector_count; } -static inline Bool ps3_irq_set_affinity_hint(struct pci_dev *pdev, - U32 msix_vector, const struct cpumask *mask, Bool smp_affinity_enable) { - U32 os_vector = pci_irq_vector(pdev, msix_vector); - Bool ret = PS3_TRUE; +static inline unsigned char +ps3_irq_set_affinity_hint(struct pci_dev *pdev, unsigned int msix_vector, + const struct cpumask *mask, + unsigned char smp_affinity_enable) +{ + unsigned int os_vector = pci_irq_vector(pdev, msix_vector); + unsigned char ret = PS3_TRUE; if (smp_affinity_enable) { - if (irq_set_affinity_hint(os_vector, mask)) { + if (irq_set_affinity_hint(os_vector, mask)) ret = PS3_FALSE; - } } return ret; } static void __ps3_cpu_msix_table_init(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) + struct ps3_irq_context *irq_context) { const struct cpumask *mask = NULL; - S32 cpu_id = 0; - U32 normal_msix_index = irq_context->high_iops_msix_vectors; - Bool smp_affinify_enable = irq_context->instance->smp_affinity_enable; + int cpu_id = 0; + unsigned int normal_msix_index = irq_context->high_iops_msix_vectors; + unsigned char smp_affinify_enable = + irq_context->instance->smp_affinity_enable; for (; normal_msix_index < irq_context->valid_msix_vector_count; - normal_msix_index++) { + normal_msix_index++) { mask = pci_irq_get_affinity(pdev, normal_msix_index); - if (mask == NULL) { + if (mask == NULL) goto l_get_affinity_failed; - } for_each_cpu_and(cpu_id, mask, cpu_online_mask) { - if (cpu_id >= irq_context->cpu_msix_table_sz) { + if (cpu_id >= irq_context->cpu_msix_table_sz) break; - } irq_context->cpu_msix_table[cpu_id] = normal_msix_index; - LOG_DEBUG("host_no:%u affinity cpu_id:%d, msix_index:%d \n", - PS3_IRQCTX_HOST(irq_context), cpu_id, normal_msix_index); + LOG_DEBUG( + "host_no:%u affinity cpu_id:%d, msix_index:%d\n", + PS3_IRQCTX_HOST(irq_context), cpu_id, + normal_msix_index); } } - + return; l_get_affinity_failed: cpu_id = cpumask_first(cpu_online_mask); normal_msix_index = irq_context->high_iops_msix_vectors; for (; normal_msix_index < irq_context->valid_msix_vector_count; - normal_msix_index++) { + normal_msix_index++) { mask = get_cpu_mask(cpu_id); - if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, - mask, smp_affinify_enable)) { + if (!ps3_irq_set_affinity_hint(pdev, normal_msix_index, mask, + smp_affinify_enable)) { LOG_ERROR("host_no:%u set affinity failed, %d.\n", - PS3_IRQCTX_HOST(irq_context), normal_msix_index); + PS3_IRQCTX_HOST(irq_context), + normal_msix_index); } else { irq_context->cpu_msix_table[cpu_id] = normal_msix_index; - LOG_DEBUG("host_no:%u affinity cpu_id:%d, msix_index:%d \n", - PS3_IRQCTX_HOST(irq_context), cpu_id, normal_msix_index); + LOG_DEBUG( + "host_no:%u affinity cpu_id:%d, msix_index:%d\n", + PS3_IRQCTX_HOST(irq_context), cpu_id, + normal_msix_index); } cpu_id = cpumask_next(cpu_id, cpu_online_mask); } - return; } -static S32 ps3_cpu_msix_table_init(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static int ps3_cpu_msix_table_init(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - S32 last_cpu_id = 0; - S32 cpu_id = 0; + int last_cpu_id = 0; + int cpu_id = 0; + for_each_online_cpu(cpu_id) { last_cpu_id = cpu_id; } irq_context->cpu_msix_table_sz = last_cpu_id + 1; irq_context->cpu_msix_table = - (U32*)kcalloc(irq_context->cpu_msix_table_sz, sizeof(S32), GFP_KERNEL); - INJECT_START(PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, &(irq_context->cpu_msix_table)) + kcalloc(irq_context->cpu_msix_table_sz, sizeof(int), GFP_KERNEL); + INJECT_START(PS3_ERR_IJ_CPU_MSIX_TABLE_ALLOC_FAILED, + &(irq_context->cpu_msix_table)); if (irq_context->cpu_msix_table == NULL) { - LOG_ERROR("host_no:%u kcalloc fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail!\n", + PS3_IRQCTX_HOST(irq_context)); return -PS3_FAILED; } - __ps3_cpu_msix_table_init(pdev, irq_context) ; + __ps3_cpu_msix_table_init(pdev, irq_context); return PS3_SUCCESS; } -static S32 ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static int ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { size_t reply_fifo_desc_buf_size = sizeof(struct PS3ReplyFifoDesc) * - irq_context->valid_msix_vector_count; - irq_context->reply_fifo_desc_buf_pool = (struct dma_pool *) - ps3_dma_pool_create("PS3 reply fifo desc pool", - &pdev->dev, reply_fifo_desc_buf_size, + irq_context->valid_msix_vector_count; + + irq_context->reply_fifo_desc_buf_pool = + (struct dma_pool *)ps3_dma_pool_create( + "PS3 reply fifo desc pool", &pdev->dev, + reply_fifo_desc_buf_size, sizeof(struct PS3ReplyFifoDesc), 0); - INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf_pool)) + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_POOL_ALLOC_FAILED, + &(irq_context->reply_fifo_desc_buf_pool)); if (irq_context->reply_fifo_desc_buf_pool == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_desc_buf_pool_failed; } - irq_context->reply_fifo_desc_buf = (struct PS3ReplyFifoDesc*) - ps3_dma_pool_zalloc(irq_context->instance, irq_context->reply_fifo_desc_buf_pool, - GFP_KERNEL, + irq_context->reply_fifo_desc_buf = + (struct PS3ReplyFifoDesc *)ps3_dma_pool_zalloc( + irq_context->instance, + irq_context->reply_fifo_desc_buf_pool, GFP_KERNEL, &irq_context->reply_fifo_desc_buf_phys); - INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, &(irq_context->reply_fifo_desc_buf)) + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_DESC_BUF_ALLOC_FAILED, + &(irq_context->reply_fifo_desc_buf)); if (irq_context->reply_fifo_desc_buf == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_desc_buf_alloc_failed; } @@ -399,80 +425,80 @@ static S32 ps3_reply_fifo_desc_alloc(struct pci_dev *pdev, static void ps3_reply_fifo_desc_free(struct ps3_irq_context *irq_context) { if (irq_context->reply_fifo_desc_buf != NULL) { - ps3_dma_pool_free( - irq_context->reply_fifo_desc_buf_pool, - irq_context->reply_fifo_desc_buf, - irq_context->reply_fifo_desc_buf_phys); - irq_context->reply_fifo_desc_buf = NULL; - irq_context->reply_fifo_desc_buf_phys = 0; + ps3_dma_pool_free(irq_context->reply_fifo_desc_buf_pool, + irq_context->reply_fifo_desc_buf, + irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf = NULL; + irq_context->reply_fifo_desc_buf_phys = 0; } if (irq_context->reply_fifo_desc_buf_pool != NULL) { ps3_dma_pool_destroy(irq_context->reply_fifo_desc_buf_pool); irq_context->reply_fifo_desc_buf_pool = NULL; } - - return; } -static S32 __ps3_reply_fifo_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static int __ps3_reply_fifo_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - size_t reply_fifo_size = sizeof(struct PS3ReplyWord) * - irq_context->reply_fifo_depth; - U32 i = 0; - (void)pdev; + size_t reply_fifo_size = + sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; + unsigned int i = 0; + (void)pdev; for (; i < irq_context->valid_msix_vector_count; i++) { - virt_base[i] = (struct PS3ReplyWord *) - ps3_dma_pool_alloc(irq_context->instance, irq_context->reply_fifo_pool, - GFP_KERNEL, - &phys_base[i]); - INJECT_START(PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, &(virt_base[i])) + virt_base[i] = (struct PS3ReplyWord *)ps3_dma_pool_alloc( + irq_context->instance, irq_context->reply_fifo_pool, + GFP_KERNEL, &phys_base[i]); + INJECT_START(PS3_ERR_IJ_REPLY_VIRT_BASE_ALLOC_FAILED, + &(virt_base[i])); if (virt_base[i] == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_alloc_failed; } memset(virt_base[i], 0xff, reply_fifo_size); - ps3_get_so_addr_ranger(irq_context->instance, phys_base[i], reply_fifo_size); - LOG_DEBUG("host_no:%u reply_fifo index:%u phy addr:0x%llx! \n", - PS3_IRQCTX_HOST(irq_context), i, phys_base[i]); + ps3_get_so_addr_ranger(irq_context->instance, phys_base[i], + reply_fifo_size); + LOG_DEBUG("host_no:%u reply_fifo index:%u phy addr:0x%llx!\n", + PS3_IRQCTX_HOST(irq_context), i, + (unsigned long long)phys_base[i]); } return PS3_SUCCESS; l_alloc_failed: for (; i > 0; i--) { - ps3_dma_pool_free( - irq_context->reply_fifo_pool, - virt_base[i-1], phys_base[i-1]); - virt_base[i-1] = NULL; - phys_base[i-1] = 0; + ps3_dma_pool_free(irq_context->reply_fifo_pool, + virt_base[i - 1], phys_base[i - 1]); + virt_base[i - 1] = NULL; + phys_base[i - 1] = 0; } return -PS3_FAILED; } -static S32 ps3_reply_fifo_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static int ps3_reply_fifo_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - size_t reply_fifo_size = sizeof(struct PS3ReplyWord) * - irq_context->reply_fifo_depth; + size_t reply_fifo_size = + sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; + irq_context->reply_fifo_pool = - ps3_dma_pool_create("PS3 reply fifo pool", - &pdev->dev, reply_fifo_size, DMA_ALIGN_BYTES_4K, 0); - INJECT_START(PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED,& (irq_context->reply_fifo_pool)) + ps3_dma_pool_create("PS3 reply fifo pool", &pdev->dev, + reply_fifo_size, DMA_ALIGN_BYTES_4K, 0); + INJECT_START(PS3_ERR_IJ_REPLY_FIFO_POOL_ALLOC_FAILED, + &(irq_context->reply_fifo_pool)); if (irq_context->reply_fifo_pool == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_create fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u ps3_dma_pool_create fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_reply_fifo_pool_failed; } - if (__ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) { + if (__ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) goto l_reply_fifo_alloc_failed; - } return PS3_SUCCESS; @@ -485,23 +511,20 @@ static S32 ps3_reply_fifo_alloc(struct pci_dev *pdev, static void ps3_reply_fifo_free(struct ps3_irq_context *irq_context) { - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - U32 i = 0; + unsigned int i = 0; - if (irq_context->reply_fifo_pool == NULL) { + if (irq_context->reply_fifo_pool == NULL) goto l_out; - } for (; i < irq_context->valid_msix_vector_count; i++) { - - if (virt_base[i] == NULL) { + if (virt_base[i] == NULL) continue; - } - ps3_dma_pool_free( - irq_context->reply_fifo_pool, - virt_base[i], phys_base[i]); + ps3_dma_pool_free(irq_context->reply_fifo_pool, virt_base[i], + phys_base[i]); virt_base[i] = NULL; phys_base[i] = 0; } @@ -512,16 +535,14 @@ static void ps3_reply_fifo_free(struct ps3_irq_context *irq_context) return; } -static S32 ps3_irq_resource_alloc(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) +static int ps3_irq_resource_alloc(struct pci_dev *pdev, + struct ps3_irq_context *irq_context) { - if (ps3_reply_fifo_desc_alloc(pdev, irq_context) != PS3_SUCCESS) { + if (ps3_reply_fifo_desc_alloc(pdev, irq_context) != PS3_SUCCESS) goto l_desc_alloc_failed; - } - if (ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) { + if (ps3_reply_fifo_alloc(pdev, irq_context) != PS3_SUCCESS) goto l_reply_fifo_alloc_failed; - } return PS3_SUCCESS; @@ -535,16 +556,14 @@ static void ps3_irq_resource_free(struct ps3_irq_context *irq_context) { ps3_reply_fifo_free(irq_context); ps3_reply_fifo_desc_free(irq_context); - - return; } static void ps3_reply_fifo_desc_set(struct pci_dev *pdev, - struct ps3_irq_context *irq_context) + struct ps3_irq_context *irq_context) { struct PS3ReplyFifoDesc *desc_buf = irq_context->reply_fifo_desc_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - U32 i = 0; + unsigned int i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { desc_buf[i].ReplyFifoBaseAddr = cpu_to_le64(phys_base[i]); @@ -552,18 +571,16 @@ static void ps3_reply_fifo_desc_set(struct pci_dev *pdev, desc_buf[i].depthReplyFifo = irq_context->reply_fifo_depth; if (irq_context->is_support_balance && - i < irq_context->high_iops_msix_vectors) { + i < irq_context->high_iops_msix_vectors) { desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_IOPS_VER0; - } - else { + } else { desc_buf[i].isrAccMode = PS3_ISR_ACC_MODE_LATENCY; } } - - return; } -static inline void __ps3_irqs_exit(struct ps3_irq *irq, struct ps3_irq_context *irq_context) +static inline void __ps3_irqs_exit(struct ps3_irq *irq, + struct ps3_irq_context *irq_context) { irq_set_affinity_hint(irq->irqNo, NULL); @@ -572,33 +589,35 @@ static inline void __ps3_irqs_exit(struct ps3_irq *irq, struct ps3_irq_context * irq->is_irq_poll_disabled = PS3_TRUE; } else { LOG_INFO("host_no:%u irq poll(%u) already disabled!\n", - PS3_HOST(irq_context->instance), irq->isrSN); + PS3_HOST(irq_context->instance), irq->isrSN); } free_irq(irq->irqNo, irq); } -S32 ps3_irqs_init(struct ps3_instance *instance) +int ps3_irqs_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; struct pci_dev *pdev = instance->pdev; struct ps3_irq *irqs = NULL; - U32 i = 0; - U32 dump_irq_index; - S32 retval; - irq_context->irqs = (struct ps3_irq*) - ps3_kcalloc(instance, irq_context->valid_msix_vector_count, + unsigned int i = 0; + unsigned int dump_irq_index; + int retval; + + irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( + instance, irq_context->valid_msix_vector_count, sizeof(struct ps3_irq)); - INJECT_START(PS3_ERR_IJ_IRQS_ALLOC_FAILED, &(irq_context->irqs)) + INJECT_START(PS3_ERR_IJ_IRQS_ALLOC_FAILED, &(irq_context->irqs)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_out; } irqs = irq_context->irqs; - for (i=0; i < irq_context->valid_msix_vector_count; i++) { + for (i = 0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].irqNo = pci_irq_vector(pdev, i); irqs[i].isrSN = i; irqs[i].reply_fifo_virt_base_addr = virt_base[i]; @@ -610,38 +629,39 @@ S32 ps3_irqs_init(struct ps3_instance *instance) atomic_set(&irqs[i].is_busy, 0); irqs[i].last_reply_idx = 0; snprintf(irqs[i].name, PS3_IRQ_NAME_LENGTH, "ps3_irq_%d_%d", - instance->host->host_no, i); + instance->host->host_no, i); retval = request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, - IRQF_SHARED, irqs[i].name, &(irqs[i])); - INJECT_START(PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, &retval) + IRQF_SHARED, irqs[i].name, &(irqs[i])); + INJECT_START(PS3_ERR_IJ_REPLY_REQ_IRQS_FAILED, &retval); if (retval) { LOG_ERROR("host_no:%u request_irq failed! SN:%d\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto l_failed; } - ps3_irq_poll_init(&irqs[i].irqpoll, PS3_IRQ_POLL_SCHED_THRESHOLD, - ps3_irqpoll_service); + ps3_irq_poll_init(&irqs[i].irqpoll, + PS3_IRQ_POLL_SCHED_THRESHOLD, + ps3_irqpoll_service); } - dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); - retval = request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, IRQF_SHARED, "ps3_dump_irq", (void *)instance); - INJECT_START(PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, &retval) - if (retval) { - LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", - PS3_HOST(instance), dump_irq_index); - goto l_failed; - } + dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); + retval = request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, + IRQF_SHARED, "ps3_dump_irq", (void *)instance); + INJECT_START(PS3_ERR_IJ_DUMP_REQ_IRQS_FAILED, &retval); + if (retval) { + LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", + PS3_HOST(instance), dump_irq_index); + goto l_failed; + } irq_context->dump_isrSN = dump_irq_index; instance->ioc_adpter->irq_disable(instance); return PS3_SUCCESS; l_failed: - for (; i > 0; i--) { - __ps3_irqs_exit(&irqs[i-1], irq_context); - } + for (; i > 0; i--) + __ps3_irqs_exit(&irqs[i - 1], irq_context); if (irq_context->irqs != NULL) { ps3_kfree(instance, irq_context->irqs); @@ -651,28 +671,29 @@ S32 ps3_irqs_init(struct ps3_instance *instance) return -PS3_FAILED; } -S32 ps3_irqs_init_switch(struct ps3_instance *instance) +int ps3_irqs_init_switch(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; struct pci_dev *pdev = instance->pdev; struct ps3_irq *irqs = NULL; struct ps3_irq_recovery *irqs_recovery = NULL; - U32 i = 0; - U32 dump_irq_index; - U32 watch_irq_index = PS3_SWITCH_IRQ_INDEX; + unsigned int i = 0; + unsigned int dump_irq_index; + unsigned int watch_irq_index = PS3_SWITCH_IRQ_INDEX; - irq_context->irqs = (struct ps3_irq*) - ps3_kcalloc(instance, irq_context->valid_msix_vector_count, + irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( + instance, irq_context->valid_msix_vector_count, sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_out; } irqs = irq_context->irqs; - for (i=0; i < irq_context->valid_msix_vector_count; i++) { + for (i = 0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].irqNo = pci_irq_vector(pdev, i); irqs[i].isrSN = i; irqs[i].reply_fifo_virt_base_addr = virt_base[i]; @@ -684,34 +705,34 @@ S32 ps3_irqs_init_switch(struct ps3_instance *instance) atomic_set(&irqs[i].is_busy, 0); irqs[i].last_reply_idx = 0; snprintf(irqs[i].name, PS3_IRQ_NAME_LENGTH, "ps3_irq_%d_%d", - instance->host->host_no, i); + instance->host->host_no, i); if (request_irq(irqs[i].irqNo, instance->ioc_adpter->isr, - IRQF_SHARED, irqs[i].name, &(irqs[i]))) { + IRQF_SHARED, irqs[i].name, &(irqs[i]))) { LOG_ERROR("host_no:%u request_irq failed! SN:%d\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); goto l_failed; } - ps3_irq_poll_init(&irqs[i].irqpoll, PS3_IRQ_POLL_SCHED_THRESHOLD, - ps3_irqpoll_service); + ps3_irq_poll_init(&irqs[i].irqpoll, + PS3_IRQ_POLL_SCHED_THRESHOLD, + ps3_irqpoll_service); } - dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); - if (request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, IRQF_SHARED, "ps3_dump_irq", (void *)instance)) { - LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", - PS3_HOST(instance), dump_irq_index); - goto l_failed; - } + dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); + if (request_irq(irqs[dump_irq_index].irqNo, ps3_dump_irq_handler, + IRQF_SHARED, "ps3_dump_irq", (void *)instance)) { + LOG_ERROR("host_no:%u request dump irq failed! SN:%d\n", + PS3_HOST(instance), dump_irq_index); + goto l_failed; + } irq_context->dump_isrSN = dump_irq_index; - - irq_context->irq_recovery = (struct ps3_irq_recovery*) - ps3_kcalloc(instance, 1, - sizeof(struct ps3_irq_recovery)); + irq_context->irq_recovery = (struct ps3_irq_recovery *)ps3_kcalloc( + instance, 1, sizeof(struct ps3_irq_recovery)); if (irq_context->irq_recovery == NULL) { - LOG_ERROR("host_no:%u kcalloc irq_recovery fail! \n", - PS3_IRQCTX_HOST(irq_context)); + LOG_ERROR("host_no:%u kcalloc irq_recovery fail!\n", + PS3_IRQCTX_HOST(irq_context)); goto l_free_dump; } irqs_recovery = irq_context->irq_recovery; @@ -719,10 +740,11 @@ S32 ps3_irqs_init_switch(struct ps3_instance *instance) irqs_recovery->isrSN = watch_irq_index; irqs_recovery->instance = instance; - if (request_irq(irqs_recovery[watch_irq_index].irqNo, ps3_recovery_irq_handler, - IRQF_SHARED, "ps3_watchdog_irq", (void *)irqs_recovery)) { + if (request_irq(irqs_recovery[watch_irq_index].irqNo, + ps3_recovery_irq_handler, IRQF_SHARED, + "ps3_watchdog_irq", (void *)irqs_recovery)) { LOG_ERROR("host_no:%u request watchdog irq failed! SN:%d\n", - PS3_HOST(instance), watch_irq_index); + PS3_HOST(instance), watch_irq_index); goto l_free_dump; } instance->ioc_adpter->irq_disable(instance); @@ -731,9 +753,8 @@ S32 ps3_irqs_init_switch(struct ps3_instance *instance) l_free_dump: free_irq(irqs[dump_irq_index].irqNo, instance); l_failed: - for (; i > 0; i--) { - __ps3_irqs_exit(&irqs[i-1], irq_context); - } + for (; i > 0; i--) + __ps3_irqs_exit(&irqs[i - 1], irq_context); if (irq_context->irqs != NULL) { ps3_kfree(instance, irq_context->irqs); @@ -753,109 +774,114 @@ void ps3_irqs_exit(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; struct pci_dev *pdev = instance->pdev; - U32 i = 0; - U32 dump_irq_index; - U32 watch_irq_index = PS3_SWITCH_IRQ_INDEX; - struct ps3_irq_recovery * irq_recovery; + unsigned int i = 0; + unsigned int dump_irq_index; + unsigned int watch_irq_index = PS3_SWITCH_IRQ_INDEX; + struct ps3_irq_recovery *irq_recovery; - if (irqs == NULL) { + if (irqs == NULL) goto l_out; - } dump_irq_index = PS3_MGR_CMD_MSIX_INDEX(irq_context); irq_set_affinity_hint(irqs[dump_irq_index].irqNo, NULL); free_irq(irqs[dump_irq_index].irqNo, instance); if (irq_context->irq_recovery != NULL) { - irq_set_affinity_hint(irq_context->irq_recovery[watch_irq_index].irqNo, NULL); - free_irq(irq_context->irq_recovery[watch_irq_index].irqNo, irq_context->irq_recovery); + irq_set_affinity_hint( + irq_context->irq_recovery[watch_irq_index].irqNo, NULL); + free_irq(irq_context->irq_recovery[watch_irq_index].irqNo, + irq_context->irq_recovery); irq_recovery = irq_context->irq_recovery; irq_context->irq_recovery = NULL; ps3_kfree(instance, irq_recovery); } - for (i=0; i < irq_context->valid_msix_vector_count; i++) { + for (i = 0; i < irq_context->valid_msix_vector_count; i++) __ps3_irqs_exit(&irqs[i], irq_context); - } irq_context->irqs = NULL; kfree(irqs); - if (pdev->msix_enabled || pdev->msi_enabled) { + if (pdev->msix_enabled || pdev->msi_enabled) pci_free_irq_vectors(pdev); - } l_out: return; } -static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, - S32 *max_vectors) +static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, + int *max_vectors) { - Bool ret = PS3_TRUE; - U32 max_replyq_count = 0; + unsigned char ret = PS3_TRUE; + unsigned int max_replyq_count = 0; - if (!instance->ioc_adpter->max_replyq_count_get(instance, &max_replyq_count)) { - LOG_ERROR("host_no:%u get max replyq count NOK\n", PS3_HOST(instance)); + if (!instance->ioc_adpter->max_replyq_count_get(instance, + &max_replyq_count)) { + LOG_ERROR("host_no:%u get max replyq count NOK\n", + PS3_HOST(instance)); ret = PS3_FALSE; goto l_out; } - if (max_replyq_count > PS3_MSIX_COMBINED_MODE_MSIX_VECTORS) { + if (max_replyq_count > PS3_MSIX_COMBINED_MODE_MSIX_VECTORS) instance->msix_combined = PS3_TRUE; - } LOG_INFO("reqlyq max_replyq_count:%d\n", max_replyq_count); *max_vectors = pci_msix_vec_count(instance->pdev); - INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) + INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors); if (*max_vectors <= 0) { *max_vectors = pci_msi_vec_count(instance->pdev); - INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors) + INJECT_START(PS3_ERR_IJ_GET_MSIX_VEC_COUNT_INVALID, max_vectors); if (*max_vectors < 0) { *max_vectors = 0; goto l_out; } } - *max_vectors = min_t(S32, *max_vectors, max_replyq_count); + *max_vectors = min_t(int, *max_vectors, max_replyq_count); l_out: return ret; } -S32 ps3_irq_context_init(struct ps3_instance *instance) +int ps3_irq_context_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct pci_dev *pdev = instance->pdev; - S32 max_vectors = 0; - if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) { + int max_vectors = 0; + + if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) goto l_irq_vectors_alloc_failed; - } if (!ps3_ioc_mgr_max_fw_cmd_get(instance, - &irq_context->reply_fifo_depth)) { + &irq_context->reply_fifo_depth)) { goto l_irq_vectors_alloc_failed; } irq_context->reply_fifo_depth += instance->reply_fifo_depth_addition; irq_context->instance = instance; - LOG_INFO("max_vectors:%d replyQ_depth:%d\n", - max_vectors, irq_context->reply_fifo_depth); + if (ps3_host_cpu_type_get() == PS3_HOST_HYGON_CPU_TYPE2) + irq_context->iops_batch_cnt_shift = PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT - 1; + else + irq_context->iops_batch_cnt_shift = PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT; + + LOG_INFO("max_vectors:%d replyQ_depth:%d iops_batch_cnt:%u\n", + max_vectors, irq_context->reply_fifo_depth, irq_context->iops_batch_cnt_shift); if (max_vectors <= 0) { - LOG_ERROR("host_no:%u IOC max_vectors invliad:%d \n", - PS3_IRQCTX_HOST(irq_context), max_vectors); + LOG_ERROR("host_no:%u IOC max_vectors invliad:%d\n", + PS3_IRQCTX_HOST(irq_context), max_vectors); goto l_irq_vectors_alloc_failed; } - if (!instance->msix_combined) { + if (!instance->msix_combined) instance->smp_affinity_enable = PS3_FALSE; - } if (ps3_irq_vectors_alloc(pdev, irq_context, max_vectors) < - instance->min_intr_count) { - LOG_ERROR("host_no:%u alloc irq NOK![cpunum:%d][irq_type:%d][min_intr:%d] \n", + instance->min_intr_count) { + LOG_ERROR( + "host_no:%u alloc irq NOK![cpunum:%d][irq_type:%d][min_intr:%d]\n", PS3_IRQCTX_HOST(irq_context), num_online_cpus(), irq_context->pci_irq_type, instance->min_intr_count); if (irq_context->valid_msix_vector_count > 0) { @@ -866,13 +892,11 @@ S32 ps3_irq_context_init(struct ps3_instance *instance) goto l_irq_vectors_alloc_failed; } - if (ps3_cpu_msix_table_init(pdev, irq_context) != PS3_SUCCESS) { + if (ps3_cpu_msix_table_init(pdev, irq_context) != PS3_SUCCESS) goto l_cpu_msix_table_init_failed; - } - if (ps3_irq_resource_alloc(pdev, irq_context) != PS3_SUCCESS) { + if (ps3_irq_resource_alloc(pdev, irq_context) != PS3_SUCCESS) goto l_irq_resource_alloc_failed; - } ps3_reply_fifo_desc_set(pdev, irq_context); instance->is_support_irq = PS3_TRUE; @@ -891,93 +915,93 @@ S32 ps3_irq_context_init(struct ps3_instance *instance) return -PS3_FAILED; } -S32 ps3_irq_context_exit(struct ps3_instance *instance) +int ps3_irq_context_exit(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct pci_dev *pdev = instance->pdev; - if (!instance->is_pcie_err_detected) { + if (!instance->is_pcie_err_detected) ps3_irq_resource_free(irq_context); - } if (irq_context->cpu_msix_table != NULL) { kfree(irq_context->cpu_msix_table); irq_context->cpu_msix_table = NULL; } - if (pdev->msix_enabled || pdev->msi_enabled) { + if (pdev->msix_enabled || pdev->msi_enabled) pci_free_irq_vectors(pdev); - } - if (!instance->is_pcie_err_detected) { + if (!instance->is_pcie_err_detected) memset(irq_context, 0, sizeof(struct ps3_irq_context)); - } return PS3_SUCCESS; } -static inline Bool ps3_is_hdd_cmd(struct ps3_cmd *cmd) +static inline unsigned char ps3_is_hdd_cmd(struct ps3_cmd *cmd) { - Bool is_hdd_io = PS3_FALSE; + unsigned char is_hdd_io = PS3_FALSE; const struct PS3VDEntry *vd_entry = NULL; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { vd_entry = cmd->io_attr.vd_entry; - if (!vd_entry->isNvme && !vd_entry->isSsd) { + if (!vd_entry->isNvme && !vd_entry->isSsd) is_hdd_io = PS3_TRUE; - } } else { - if (ps3_is_hdd_pd(cmd->io_attr.pd_entry->dev_type)) { + if (ps3_is_hdd_pd(cmd->io_attr.pd_entry->dev_type)) is_hdd_io = PS3_TRUE; - } } return is_hdd_io; } -static inline Bool ps3_sdev_is_high_load(struct ps3_cmd *cmd, U16 scale) +static inline unsigned char ps3_sdev_is_high_load(struct ps3_cmd *cmd, + unsigned short scale) { - S32 busy_base = cmd->instance->device_busy_threshold; - S32 busy_threshold = busy_base * scale; - S32 device_busy = 0; + int busy_base = cmd->instance->device_busy_threshold; + int busy_threshold = busy_base * scale; + int device_busy = 0; #if defined DRIVER_SUPPORT_PRIV_BUSY - struct ps3_scsi_priv_data *device_priv_data = (struct ps3_scsi_priv_data*)cmd->scmd->device->hostdata; - if (device_priv_data == NULL) { + struct ps3_scsi_priv_data *device_priv_data = + (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; + + if (device_priv_data == NULL) return PS3_FALSE; - } device_busy = atomic_read(&device_priv_data->sdev_priv_busy); #else device_busy = atomic_read(&cmd->scmd->device->device_busy); #endif - if (PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(busy_threshold, busy_base) && !ps3_is_hdd_cmd(cmd)) { + if (PS3_MULTI_DATA_DISK_BUSY_THRESHOLD(busy_threshold, busy_base) && + !ps3_is_hdd_cmd(cmd)) { if (ps3_host_vendor_get() == PS3_HOST_VENDOR_HYGON && - busy_threshold <= PS3_HYGON_BUSY_ADJUST_THRESHOLD) { + ps3_host_cpu_type_get() != PS3_HOST_HYGON_CPU_TYPE2 && + busy_threshold <= PS3_HYGON_BUSY_ADJUST_THRESHOLD) { busy_threshold = busy_base; } else if (busy_threshold > PS3_SSD_MAX_BUSY_THRESHOLD) { busy_threshold = PS3_SSD_MAX_BUSY_THRESHOLD; } } - if (device_busy > busy_threshold) { + if (device_busy > busy_threshold) return PS3_TRUE; - } return PS3_FALSE; } -static inline U32 ps3_iops_msix_index_get(struct ps3_irq_context *irq_context) +static inline unsigned int +ps3_iops_msix_index_get(struct ps3_irq_context *irq_context) { - U32 msix_index = 0; - U32 ioc_count = atomic_add_return(1, &irq_context->high_iops_io_count); - U32 batch_num = ioc_count >> PS3_HIGH_IOPS_VECTOR_BATCH_COUNT_SHIFT; + + unsigned int msix_index = 0; + unsigned int ioc_count = atomic_add_return(1, &irq_context->high_iops_io_count); + unsigned int batch_num = ioc_count >> irq_context->iops_batch_cnt_shift; msix_index = batch_num % PS3_IOPS_MSIX_VECTORS; return msix_index; } -U32 ps3_msix_index_get(struct ps3_cmd *cmd, U16 scale) +unsigned int ps3_msix_index_get(struct ps3_cmd *cmd, unsigned short scale) { int processor_id = 0; - U32 msix_index = 0; + unsigned int msix_index = 0; struct ps3_irq_context *irq_context = &cmd->instance->irq_context; if (irq_context->valid_msix_vector_count == 1) { @@ -991,41 +1015,38 @@ U32 ps3_msix_index_get(struct ps3_cmd *cmd, U16 scale) } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type) && - (irq_context->is_balance_current_perf_mode) && - ps3_sdev_is_high_load(cmd, scale)) { + (irq_context->is_balance_current_perf_mode) && + ps3_sdev_is_high_load(cmd, scale)) { msix_index = ps3_iops_msix_index_get(irq_context); } else if (cmd->instance->host->nr_hw_queues > 1) { - msix_index = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(SCMD_GET_REQUEST(cmd->scmd))) + - irq_context->high_iops_msix_vectors; - } else { + msix_index = blk_mq_unique_tag_to_hwq(blk_mq_unique_tag( + SCMD_GET_REQUEST(cmd->scmd))) + + irq_context->high_iops_msix_vectors; + } else { processor_id = raw_smp_processor_id(); msix_index = irq_context->cpu_msix_table[processor_id]; - if (msix_index == PS3_MGR_CMD_MSIX_INDEX(irq_context)) { + if (msix_index == PS3_MGR_CMD_MSIX_INDEX(irq_context)) msix_index++; - } } l_out: return msix_index; } -void ps3_perf_update(struct ps3_instance *instance, U8 iocPerfMode) +void ps3_perf_update(struct ps3_instance *instance, unsigned char iocPerfMode) { struct ps3_irq_context *irq_context = &instance->irq_context; - Bool support_balance = irq_context->is_support_balance; - Bool *is_balance = &irq_context->is_balance_current_perf_mode; + unsigned char support_balance = irq_context->is_support_balance; + unsigned char *is_balance = &irq_context->is_balance_current_perf_mode; if (support_balance) { - if (iocPerfMode == PS3_PERF_MODE_BALANCE) { + if (iocPerfMode == PS3_PERF_MODE_BALANCE) *is_balance = PS3_TRUE; - } else { + else *is_balance = PS3_FALSE; - } } else { *is_balance = PS3_FALSE; } - - return; } void ps3_irqs_enable(struct ps3_instance *instance) { @@ -1033,8 +1054,7 @@ void ps3_irqs_enable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq enable\n", PS3_HOST(instance)); - switch (irq_context->pci_irq_type) - { + switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_enable(instance); break; @@ -1045,13 +1065,12 @@ void ps3_irqs_enable(struct ps3_instance *instance) ps3_ioc_msix_enable(instance); break; default: - LOG_ERROR("host_no:%u irq type is NOK :%d \n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is NOK :%d\n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } irq_context->is_enable_interrupts = PS3_DRV_TRUE; - mb(); - return; + mb(); /* in order to force CPU ordering */ } void ps3_irqs_disable(struct ps3_instance *instance) @@ -1060,14 +1079,12 @@ void ps3_irqs_disable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq disable\n", PS3_HOST(instance)); - if(irq_context->is_enable_interrupts == PS3_DRV_FALSE) { + if (irq_context->is_enable_interrupts == PS3_DRV_FALSE) goto l_out; - } irq_context->is_enable_interrupts = PS3_DRV_FALSE; - mb(); - switch (irq_context->pci_irq_type) - { + mb(); /* in order to force CPU ordering */ + switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_disable(instance); break; @@ -1078,8 +1095,8 @@ void ps3_irqs_disable(struct ps3_instance *instance) ps3_ioc_msix_disable(instance); break; default: - LOG_ERROR("host_no:%u irq type is NOK :%d \n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is NOK :%d\n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } @@ -1101,26 +1118,26 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) } irq_context = &irq->instance->irq_context; - if ((U32)irq_so != irq->irqNo) { + if ((unsigned int)irq_so != irq->irqNo) { LOG_ERROR_IN_IRQ(irq->instance, - "irq_so:%d != irq->irqNo:%d !\n", - irq_so, irq->irqNo); + "irq_so:%d != irq->irqNo:%d !\n", irq_so, + irq->irqNo); ret = IRQ_NONE; goto l_out; } if (!irq_context->is_enable_interrupts) { LOG_INFO_IN_IRQ(irq->instance, - "host_no:%u interrupt has disabled !\n", - PS3_HOST(irq->instance)); + "host_no:%u interrupt has disabled !\n", + PS3_HOST(irq->instance)); ret = IRQ_NONE; goto l_out; } if (irq->is_sched_irq_poll) { LOG_WARN_IN_IRQ(irq->instance, - "host_no:%u had enter into irq poll !\n", - PS3_HOST(irq->instance)); + "host_no:%u had enter into irq poll !\n", + PS3_HOST(irq->instance)); ret = IRQ_HANDLED; goto l_out; } @@ -1128,7 +1145,7 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) complete_num = ps3_cmd_complete(irq); if (complete_num <= 0) { LOG_DEBUG("host_no:%u there is no completed ps3_cmd !\n", - PS3_HOST(irq->instance)); + PS3_HOST(irq->instance)); ret = IRQ_NONE; } else { ret = IRQ_HANDLED; @@ -1138,10 +1155,11 @@ irqreturn_t ps3_irqs_service(int irq_so, void *priv) return ret; } -S32 ps3_irqpoll_service(struct irq_poll *irqpoll, int budget) +int ps3_irqpoll_service(struct irq_poll *irqpoll, int budget) { - S32 complete_num = 0; - struct ps3_irq *irq = ps3_container_of(irqpoll, struct ps3_irq, irqpoll); + int complete_num = 0; + struct ps3_irq *irq = + ps3_container_of(irqpoll, struct ps3_irq, irqpoll); if (irq->is_enable_irq) { disable_irq(irq->irqNo); @@ -1163,32 +1181,30 @@ void ps3_irqpolls_enable(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - U32 i = 0; - if (irqs == NULL) { + unsigned int i = 0; + + if (irqs == NULL) return; - } - + for (; i < irq_context->valid_msix_vector_count; i++) { if (irqs[i].is_irq_poll_disabled == PS3_TRUE) { ps3_irq_poll_enable(&irqs[i].irqpoll); irqs[i].is_irq_poll_disabled = PS3_FALSE; } else { LOG_INFO("host_no:%u irq poll(%d) not disabled!\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); } } - - return; } void ps3_irqs_sync(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - U32 i = 0; - if (irqs == NULL) { + unsigned int i = 0; + + if (irqs == NULL) goto l_out; - } for (; i < irq_context->valid_msix_vector_count; i++) { synchronize_irq(irqs[i].irqNo); @@ -1197,7 +1213,7 @@ void ps3_irqs_sync(struct ps3_instance *instance) irqs[i].is_irq_poll_disabled = PS3_TRUE; } else { LOG_INFO("host_no:%u irq poll(%d) already disabled!\n", - PS3_HOST(instance), i); + PS3_HOST(instance), i); } } l_out: @@ -1210,14 +1226,14 @@ static void ps3_reply_fifo_desc_free(struct ps3_instance *instance); static void ps3_reply_fifo_free(struct ps3_instance *instance); static void ps3_irq_resource_free(struct ps3_instance *instance); -static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, - U32 *max_vectors) +static unsigned char ps3_irq_max_vectors_calc(struct ps3_instance *instance, + unsigned int *max_vectors) { - Bool ret = PS3_TRUE; - U32 max_replyq_count = 0; + unsigned char ret = PS3_TRUE; + unsigned int max_replyq_count = 0; if (!instance->ioc_adpter->max_replyq_count_get(instance, - &max_replyq_count)) { + &max_replyq_count)) { ret = PS3_FALSE; goto l_out; } @@ -1227,25 +1243,27 @@ static Bool ps3_irq_max_vectors_calc(struct ps3_instance *instance, *max_vectors = instance->pci_dev_context.irq_vec_count; *max_vectors = PS3_MIN(*max_vectors, max_replyq_count); - *max_vectors = PS3_MIN(*max_vectors, (U32)num_online_cpus() + 1); + *max_vectors = + PS3_MIN(*max_vectors, (unsigned int)num_online_cpus() + 1); l_out: return ret; } -static S32 ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) +static int ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - irq_context->reply_fifo_desc_buf_size = sizeof(struct PS3ReplyFifoDesc) * + irq_context->reply_fifo_desc_buf_size = + sizeof(struct PS3ReplyFifoDesc) * irq_context->valid_msix_vector_count; - irq_context->reply_fifo_desc_buf = (struct PS3ReplyFifoDesc*) - ps3_dma_alloc_coherent(instance, - irq_context->reply_fifo_desc_buf_size, - &irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf = + (struct PS3ReplyFifoDesc *)ps3_dma_alloc_coherent( + instance, irq_context->reply_fifo_desc_buf_size, + (unsigned long long *)&irq_context + ->reply_fifo_desc_buf_phys); if (irq_context->reply_fifo_desc_buf == NULL) { - LOG_ERROR("host_no:%u dma alloc fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u dma alloc fail!\n", PS3_HOST(instance)); goto l_failed; } @@ -1258,37 +1276,36 @@ static S32 ps3_reply_fifo_desc_alloc(struct ps3_instance *instance) static void ps3_reply_fifo_desc_free(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; + if (irq_context->reply_fifo_desc_buf != NULL) { ps3_dma_free_coherent(instance, - irq_context->reply_fifo_desc_buf_size, - irq_context->reply_fifo_desc_buf, - irq_context->reply_fifo_desc_buf_phys); + irq_context->reply_fifo_desc_buf_size, + irq_context->reply_fifo_desc_buf, + irq_context->reply_fifo_desc_buf_phys); irq_context->reply_fifo_desc_buf = NULL; irq_context->reply_fifo_desc_buf_phys = 0; } - - return; } -static S32 ps3_reply_fifo_alloc(struct ps3_instance *instance) +static int ps3_reply_fifo_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - U32 i = 0; + unsigned int i = 0; - irq_context->reply_fifo_size = sizeof(struct PS3ReplyWord) * - irq_context->reply_fifo_depth; + irq_context->reply_fifo_size = + sizeof(struct PS3ReplyWord) * irq_context->reply_fifo_depth; for (; i < irq_context->valid_msix_vector_count; i++) { - virt_base[i] = (struct PS3ReplyWord*) - ps3_dma_alloc_coherent(instance, - irq_context->reply_fifo_size, - &phys_base[i]); + virt_base[i] = (struct PS3ReplyWord *)ps3_dma_alloc_coherent( + instance, irq_context->reply_fifo_size, + (unsigned long long *)&phys_base[i]); if (virt_base[i] == NULL) { - LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u ps3_dma_pool_zalloc fail!\n", + PS3_HOST(instance)); goto l_failed; } memset(virt_base[i], 0xff, irq_context->reply_fifo_size); @@ -1304,36 +1321,33 @@ static S32 ps3_reply_fifo_alloc(struct ps3_instance *instance) static void ps3_reply_fifo_free(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; - U32 i = 0; + unsigned int i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { - - if (virt_base[i] == NULL) { + if (virt_base[i] == NULL) continue; - } - ps3_dma_free_coherent(instance, - irq_context->reply_fifo_size, - virt_base[i], - phys_base[i]); + ps3_dma_free_coherent(instance, irq_context->reply_fifo_size, + virt_base[i], phys_base[i]); virt_base[i] = NULL; phys_base[i] = 0; } - - return; } -static inline S32 ps3_irq_group_affinity_alloc(struct ps3_instance *instance) +static inline int ps3_irq_group_affinity_alloc(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - U32 size = sizeof(GROUP_AFFINITY) * irq_context->valid_msix_vector_count; + unsigned int size = + sizeof(GROUP_AFFINITY) * irq_context->valid_msix_vector_count; irq_context->group_affinity = ps3_kzalloc(instance, size); if (irq_context->group_affinity == NULL) { - LOG_ERROR("host_no:%u, group_affinity alloc failed\n", PS3_HOST(instance)); + LOG_ERROR("host_no:%u, group_affinity alloc failed\n", + PS3_HOST(instance)); return -PS3_FAILED; } return PS3_SUCCESS; @@ -1347,19 +1361,16 @@ static inline void ps3_irq_group_affinity_free(struct ps3_instance *instance) } } -static S32 ps3_irq_resource_alloc(struct ps3_instance *instance) +static int ps3_irq_resource_alloc(struct ps3_instance *instance) { - if (ps3_reply_fifo_desc_alloc(instance) != PS3_SUCCESS) { + if (ps3_reply_fifo_desc_alloc(instance) != PS3_SUCCESS) goto l_failed; - } - if (ps3_reply_fifo_alloc(instance) != PS3_SUCCESS) { + if (ps3_reply_fifo_alloc(instance) != PS3_SUCCESS) goto l_failed; - } - if (ps3_irq_group_affinity_alloc(instance) != PS3_SUCCESS) { + if (ps3_irq_group_affinity_alloc(instance) != PS3_SUCCESS) goto l_failed; - } return PS3_SUCCESS; @@ -1373,8 +1384,6 @@ static void ps3_irq_resource_free(struct ps3_instance *instance) ps3_irq_group_affinity_free(instance); ps3_reply_fifo_free(instance); ps3_reply_fifo_desc_free(instance); - - return; } static void ps3_reply_fifo_desc_set(struct ps3_instance *instance) @@ -1382,33 +1391,31 @@ static void ps3_reply_fifo_desc_set(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct PS3ReplyFifoDesc *desc_buf = irq_context->reply_fifo_desc_buf; dma_addr_t *phys_base = irq_context->reply_fifo_phys_base_addr_buf; + unsigned int i = 0; - U32 i = 0; for (; i < irq_context->valid_msix_vector_count; i++) { desc_buf[i].ReplyFifoBaseAddr = cpu_to_le64(phys_base[i]); desc_buf[i].irqNo = i; - desc_buf[i].depthReplyFifo = (U16)irq_context->reply_fifo_depth; + desc_buf[i].depthReplyFifo = + (unsigned short)irq_context->reply_fifo_depth; - if (i < irq_context->high_iops_msix_vectors) { + if (i < irq_context->high_iops_msix_vectors) desc_buf[i].isHighIops = PS3_TRUE; - } else { + else desc_buf[i].isHighIops = PS3_FALSE; - } } - - return; } -S32 ps3_irq_context_init(struct ps3_instance *instance) +int ps3_irq_context_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - U32 max_vectors = 0; - if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) { + unsigned int max_vectors = 0; + + if (!ps3_irq_max_vectors_calc(instance, &max_vectors)) goto l_failed; - } if (!ps3_ioc_mgr_max_fw_cmd_get(instance, - &irq_context->reply_fifo_depth)) { + &irq_context->reply_fifo_depth)) { goto l_failed; } @@ -1417,11 +1424,12 @@ S32 ps3_irq_context_init(struct ps3_instance *instance) irq_context->high_iops_msix_vectors = 0; - LOG_INFO("max_vectors:%d replyQ_depth:%d\n", - max_vectors, irq_context->reply_fifo_depth); + LOG_INFO("max_vectors:%d replyQ_depth:%d\n", max_vectors, + irq_context->reply_fifo_depth); if (max_vectors <= instance->min_intr_count) { - LOG_ERROR("host_no:%u alloc irq failed![cpunum:%d][irq_type:%d][min_intr:%d] \n", + LOG_ERROR( + "host_no:%u alloc irq failed![cpunum:%d][irq_type:%d][min_intr:%d]\n", PS3_HOST(instance), num_online_cpus(), irq_context->pci_irq_type, instance->min_intr_count); goto l_failed; @@ -1429,9 +1437,8 @@ S32 ps3_irq_context_init(struct ps3_instance *instance) irq_context->pci_irq_type = instance->pci_dev_context.pci_irq_type; irq_context->valid_msix_vector_count = max_vectors; - if (ps3_irq_resource_alloc(instance) != PS3_SUCCESS) { + if (ps3_irq_resource_alloc(instance) != PS3_SUCCESS) goto l_failed; - } ps3_reply_fifo_desc_set(instance); @@ -1442,46 +1449,40 @@ S32 ps3_irq_context_init(struct ps3_instance *instance) return -PS3_FAILED; } -S32 ps3_irq_context_exit(struct ps3_instance *instance) +int ps3_irq_context_exit(struct ps3_instance *instance) { ps3_irq_resource_free(instance); return PS3_SUCCESS; } -U8 ps3_irqs_service(void *priv, ULong irq_no) +unsigned char ps3_irqs_service(void *priv, unsigned long irq_no) { - struct ps3_instance *instance = (struct ps3_instance*)priv; - U32 isrSN = (U32)irq_no; - if (isrSN >= instance->irq_context.valid_msix_vector_count) { + struct ps3_instance *instance = (struct ps3_instance *)priv; + unsigned int isrSN = (unsigned int)irq_no; + + if (isrSN >= instance->irq_context.valid_msix_vector_count) goto l_out; - } - if (!instance->irq_context.is_enable_interrupts) { + if (!instance->irq_context.is_enable_interrupts) goto l_out; - } - StorPortIssueDpc(instance, - &instance->irq_context.irqs[isrSN].dpc, - &instance->irq_context.irqs[isrSN].isrSN, - NULL); + StorPortIssueDpc(instance, &instance->irq_context.irqs[isrSN].dpc, + &instance->irq_context.irqs[isrSN].isrSN, NULL); l_out: return PS3_TRUE; } -static void ps3_irq_dpc_routine(PSTOR_DPC dpc, - void *context, - void *isr_no, - void *arg -) +static void ps3_irq_dpc_routine(PSTOR_DPC dpc, void *context, void *isr_no, + void *arg) { - struct ps3_instance *instance = (struct ps3_instance*)context; - U32 isrSN = *((U32*)isr_no); + struct ps3_instance *instance = (struct ps3_instance *)context; + unsigned int isrSN = *((unsigned int *)isr_no); struct ps3_irq *irqs = &instance->irq_context.irqs[isrSN]; + (void)arg; (void)dpc; - LOG_DEBUG("%d\n", isrSN); irqs->is_dpc_running = PS3_TRUE; @@ -1490,22 +1491,22 @@ static void ps3_irq_dpc_routine(PSTOR_DPC dpc, irqs->is_dpc_running = PS3_FALSE; } -S32 ps3_irqs_dpc_init(struct ps3_instance *instance) +int ps3_irqs_dpc_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = NULL; - U32 i = 0; + unsigned int i = 0; irqs = irq_context->irqs; if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); goto l_out; } for (i = 0; i < irq_context->valid_msix_vector_count; i++) { irqs[i].is_dpc_running = PS3_FALSE; - StorPortInitializeDpc(instance, &irqs[i].dpc, ps3_irq_dpc_routine); + StorPortInitializeDpc(instance, &irqs[i].dpc, + ps3_irq_dpc_routine); } instance->ioc_adpter->irq_disable(instance); return PS3_SUCCESS; @@ -1514,19 +1515,19 @@ S32 ps3_irqs_dpc_init(struct ps3_instance *instance) return -PS3_FAILED; } -S32 ps3_irqs_init(struct ps3_instance *instance) +int ps3_irqs_init(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; struct ps3_irq *irqs = NULL; - U32 i = 0; + unsigned int i = 0; - irq_context->irqs = (struct ps3_irq*) - ps3_kcalloc(instance, irq_context->valid_msix_vector_count, - sizeof(struct ps3_irq)); + irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( + instance, irq_context->valid_msix_vector_count, + sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u kcalloc fail!\n", PS3_HOST(instance)); goto l_out; } irqs = irq_context->irqs; @@ -1546,19 +1547,19 @@ S32 ps3_irqs_init(struct ps3_instance *instance) return -PS3_FAILED; } -S32 ps3_irqs_init_switch(struct ps3_instance *instance) +int ps3_irqs_init_switch(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; - struct PS3ReplyWord **virt_base = irq_context->reply_fifo_virt_base_addr_buf; + struct PS3ReplyWord **virt_base = + irq_context->reply_fifo_virt_base_addr_buf; struct ps3_irq *irqs = NULL; - U32 i = 0; + unsigned int i = 0; - irq_context->irqs = (struct ps3_irq*) - ps3_kcalloc(instance, irq_context->valid_msix_vector_count, - sizeof(struct ps3_irq)); + irq_context->irqs = (struct ps3_irq *)ps3_kcalloc( + instance, irq_context->valid_msix_vector_count, + sizeof(struct ps3_irq)); if (irq_context->irqs == NULL) { - LOG_ERROR("host_no:%u kcalloc fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u kcalloc fail!\n", PS3_HOST(instance)); goto l_out; } irqs = irq_context->irqs; @@ -1578,29 +1579,28 @@ S32 ps3_irqs_init_switch(struct ps3_instance *instance) return -PS3_FAILED; } -static void ps3_irq_dpc_sync(struct ps3_instance *instance, struct ps3_irq *irqs) +static void ps3_irq_dpc_sync(struct ps3_instance *instance, + struct ps3_irq *irqs) { - ULong status = STOR_STATUS_SUCCESS; - U8 cancel_ret = PS3_TRUE; + unsigned long status = STOR_STATUS_SUCCESS; + unsigned char cancel_ret = PS3_TRUE; if (irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); goto l_out; } status = StorPortCancelDpc(instance, &irqs->dpc, &cancel_ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, cancel dpc failed,status:0x%x\n", PS3_HOST(instance), status); + LOG_ERROR("host_no:%u, cancel dpc failed,status:0x%x\n", + PS3_HOST(instance), status); } - if (cancel_ret) { + if (cancel_ret) goto l_out; - } - while (irqs->is_dpc_running) { + while (irqs->is_dpc_running) ps3_msleep(10); - } l_out: return; } @@ -1610,9 +1610,8 @@ void ps3_irqs_exit(struct ps3_instance *instance) struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - if (irqs == NULL) { + if (irqs == NULL) goto l_out; - } instance->ioc_adpter->irq_disable(instance); ps3_kfree(instance, irqs); @@ -1628,8 +1627,7 @@ void ps3_irqs_enable(struct ps3_instance *instance) LOG_DEBUG("host_no:%u irq enable\n", PS3_HOST(instance)); - switch (irq_context->pci_irq_type) - { + switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_enable(instance); break; @@ -1640,27 +1638,25 @@ void ps3_irqs_enable(struct ps3_instance *instance) ps3_ioc_msix_enable(instance); break; default: - LOG_ERROR("host_no:%u irq type is failed :%d \n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is failed :%d\n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } irq_context->is_enable_interrupts = PS3_DRV_TRUE; - mb(); - return; + mb(); /* in order to force CPU ordering */ } void ps3_irqs_disable(struct ps3_instance *instance) { struct ps3_irq_context *irq_context = &instance->irq_context; struct ps3_irq *irqs = irq_context->irqs; - U32 i = 0; + unsigned int i = 0; + LOG_DEBUG("host_no:%u irq disable\n", PS3_HOST(instance)); - if(irq_context->is_enable_interrupts == PS3_DRV_FALSE) { + if (irq_context->is_enable_interrupts == PS3_DRV_FALSE) goto l_out; - } - switch (irq_context->pci_irq_type) - { + switch (irq_context->pci_irq_type) { case PS3_PCI_IRQ_LEGACY: ps3_ioc_legacy_irqs_disable(instance); break; @@ -1671,21 +1667,19 @@ void ps3_irqs_disable(struct ps3_instance *instance) ps3_ioc_msix_disable(instance); break; default: - LOG_ERROR("host_no:%u irq type is failed :%d \n", - PS3_HOST(instance), irq_context->pci_irq_type); + LOG_ERROR("host_no:%u irq type is failed :%d\n", + PS3_HOST(instance), irq_context->pci_irq_type); break; } if (irqs == NULL) { - LOG_ERROR("host_no:%u irqs fail! \n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u irqs fail!\n", PS3_HOST(instance)); goto l_out; } - for (i = 0; i < irq_context->valid_msix_vector_count; i++) { + for (i = 0; i < irq_context->valid_msix_vector_count; i++) ps3_irq_dpc_sync(instance, &irqs[i]); - } irq_context->is_enable_interrupts = PS3_DRV_FALSE; - mb(); + mb(); /* in order to force CPU ordering */ l_out: return; @@ -1695,14 +1689,14 @@ void ps3_irqs_disable(struct ps3_instance *instance) void ps3_all_reply_fifo_init(struct ps3_instance *instance) { - U32 reply_fifo_size = sizeof(struct PS3ReplyWord) * - instance->irq_context.reply_fifo_depth; + unsigned int reply_fifo_size = sizeof(struct PS3ReplyWord) * + instance->irq_context.reply_fifo_depth; struct ps3_irq *irq = NULL; - U32 i = 0; + unsigned int i = 0; + LOG_DEBUG("host_no:%u start to reply fifo init!\n", PS3_HOST(instance)); - if (instance->irq_context.irqs == NULL) { + if (instance->irq_context.irqs == NULL) return; - } for (; i < instance->irq_context.valid_msix_vector_count; ++i) { irq = instance->irq_context.irqs + i; @@ -1710,7 +1704,4 @@ void ps3_all_reply_fifo_init(struct ps3_instance *instance) irq->last_reply_idx = 0; } LOG_DEBUG("host_no:%u end to reply fifo init!\n", PS3_HOST(instance)); - - return; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_irq.h b/drivers/scsi/linkdata/ps3stor/ps3_irq.h index 758a8c00f439..ac3105d558a1 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_irq.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_irq.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_IRQ_H_ #define _PS3_IRQ_H_ @@ -13,21 +14,13 @@ #include "ps3_err_def.h" #include "ps3_cmd_channel.h" #include "ps3_inner_data.h" +#include "ps3_kernel_version.h" -#define PS3_IRQ_NAME_LENGTH (32) -#define PS3_SWITCH_IRQ_INDEX (0) +#define PS3_IRQ_NAME_LENGTH (32) +#define PS3_SWITCH_IRQ_INDEX (0) struct ps3_instance; -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 2)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0))) -#define DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) -#define PS3_OS_MANAGED_IRQ_SUPPORT -#endif - enum { PS3_PCI_IRQ_MODE_NONE_SPE = 0, PS3_PCI_IRQ_MODE_LEGACY = 1, @@ -40,83 +33,85 @@ struct ps3_irq { struct PS3ReplyWord *reply_fifo_virt_base_addr; struct ps3_instance *instance; - U32 irqNo; - U32 isrSN; - U16 last_reply_idx; - U8 reserved0[6]; + unsigned int irqNo; + unsigned int isrSN; + unsigned short last_reply_idx; + unsigned char reserved0[6]; #ifdef _WINDOWS STOR_DPC dpc; - volatile U8 is_dpc_running; #else struct irq_poll irqpoll; - Bool is_irq_poll_disabled; - U32 irq_poll_sched_threshold; - Bool is_sched_irq_poll; - Bool is_enable_irq; - U8 reserved1[2]; + unsigned char is_irq_poll_disabled; + unsigned int irq_poll_sched_threshold; + unsigned char is_sched_irq_poll; + unsigned char is_enable_irq; + unsigned char reserved1[2]; #endif - ps3_atomic32 is_busy; + atomic_t is_busy; }; struct ps3_irq_recovery { - U32 irqNo; - U32 isrSN; - U8 reserved0[8]; + unsigned int irqNo; + unsigned int isrSN; + unsigned char reserved0[8]; struct ps3_instance *instance; }; struct ps3_irq_context { struct ps3_instance *instance; - U32 reply_fifo_depth; - U32 valid_msix_vector_count; - U32 high_iops_msix_vectors; - U32 dump_isrSN; - U32 reply_fifo_desc_buf_size; + unsigned int reply_fifo_depth; + unsigned int valid_msix_vector_count; + unsigned int high_iops_msix_vectors; + unsigned int dump_isrSN; + unsigned int reply_fifo_desc_buf_size; #ifndef _WINDOWS struct dma_pool *reply_fifo_desc_buf_pool; #endif - U32 reply_fifo_size; + unsigned int reply_fifo_size; dma_addr_t reply_fifo_desc_buf_phys; struct PS3ReplyFifoDesc *reply_fifo_desc_buf; #ifndef _WINDOWS struct dma_pool *reply_fifo_pool; #endif - struct PS3ReplyWord *reply_fifo_virt_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; + struct PS3ReplyWord + *reply_fifo_virt_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; dma_addr_t reply_fifo_phys_base_addr_buf[PS3_MAX_REPLY_QUE_COUNT]; struct ps3_irq *irqs; #ifndef _WINDOWS - U32 *cpu_msix_table; + unsigned int *cpu_msix_table; atomic_t high_iops_io_count; - S32 cpu_msix_table_sz; + int cpu_msix_table_sz; #endif - Bool is_enable_interrupts; - Bool is_support_balance; - Bool is_balance_current_perf_mode; - U8 pci_irq_type; + unsigned char is_enable_interrupts; + unsigned char is_support_balance; + unsigned char is_balance_current_perf_mode; + unsigned char pci_irq_type; #ifdef _WINDOWS - PGROUP_AFFINITY group_affinity; + PGROUP_AFFINITY group_affinity; #endif - struct ps3_irq_recovery * irq_recovery; + + struct ps3_irq_recovery *irq_recovery; + unsigned short iops_batch_cnt_shift; }; -S32 ps3_irq_context_init(struct ps3_instance *instance); +int ps3_irq_context_init(struct ps3_instance *instance); -S32 ps3_irq_context_exit(struct ps3_instance *instance); +int ps3_irq_context_exit(struct ps3_instance *instance); -S32 ps3_irqs_dpc_init(struct ps3_instance *instance); +int ps3_irqs_dpc_init(struct ps3_instance *instance); -S32 ps3_irqs_init(struct ps3_instance *instance); +int ps3_irqs_init(struct ps3_instance *instance); -S32 ps3_irqs_init_switch(struct ps3_instance *instance); +int ps3_irqs_init_switch(struct ps3_instance *instance); void ps3_irqs_exit(struct ps3_instance *instance); #ifndef _WINDOWS -U32 ps3_msix_index_get(struct ps3_cmd *cmd, U16 pd_count); +unsigned int ps3_msix_index_get(struct ps3_cmd *cmd, unsigned short pd_count); -void ps3_perf_update(struct ps3_instance *instance, U8 iocPerfMode); +void ps3_perf_update(struct ps3_instance *instance, unsigned char iocPerfMode); #endif void ps3_irqs_enable(struct ps3_instance *instance); @@ -129,13 +124,13 @@ void ps3_irqs_sync(struct ps3_instance *instance); #ifndef _WINDOWS irqreturn_t ps3_irqs_service(int irq_so, void *priv); #else -U8 ps3_irqs_service(void *priv, ULong irq_no); +unsigned char ps3_irqs_service(void *priv, unsigned long irq_no); #endif #ifndef _WINDOWS int ps3_irqpoll_service(struct irq_poll *irqpoll, int budget); #endif -static inline Bool ps3_irq_busy_add(struct ps3_irq *irq) +static inline unsigned char ps3_irq_busy_add(struct ps3_irq *irq) { return ps3_atomic_add_unless(&irq->is_busy, 1, 1); } @@ -145,7 +140,8 @@ static inline void ps3_irq_busy_dec(struct ps3_irq *irq) ps3_atomic_dec(&irq->is_busy); } -static inline Bool ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) +static inline unsigned char +ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) { return (irq_ctx->is_enable_interrupts == PS3_DRV_TRUE); } @@ -153,7 +149,7 @@ static inline Bool ps3_irq_is_enable(const struct ps3_irq_context *irq_ctx) void ps3_all_reply_fifo_init(struct ps3_instance *instance); #ifndef _WINDOWS -static inline void ps3_irq_poll_sched(struct irq_poll * iop) +static inline void ps3_irq_poll_sched(struct irq_poll *iop) { #ifdef CONFIG_IRQ_POLL irq_poll_sched(iop); @@ -162,7 +158,8 @@ static inline void ps3_irq_poll_sched(struct irq_poll * iop) #endif } -static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, irq_poll_fn *func) +static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, + irq_poll_fn *func) { #ifdef CONFIG_IRQ_POLL irq_poll_init(iop, weight, func); @@ -173,7 +170,7 @@ static inline void ps3_irq_poll_init(struct irq_poll *iop, int weight, irq_poll_ #endif } -static inline void ps3_irq_poll_complete(struct irq_poll * iop) +static inline void ps3_irq_poll_complete(struct irq_poll *iop) { #ifdef CONFIG_IRQ_POLL irq_poll_complete(iop); @@ -182,7 +179,7 @@ static inline void ps3_irq_poll_complete(struct irq_poll * iop) #endif } -static inline void ps3_irq_poll_enable(struct irq_poll * iop) +static inline void ps3_irq_poll_enable(struct irq_poll *iop) { #ifdef CONFIG_IRQ_POLL irq_poll_enable(iop); @@ -191,7 +188,7 @@ static inline void ps3_irq_poll_enable(struct irq_poll * iop) #endif } -static inline void ps3_irq_poll_disable(struct irq_poll * iop) +static inline void ps3_irq_poll_disable(struct irq_poll *iop) { #ifdef CONFIG_IRQ_POLL irq_poll_disable(iop); @@ -200,4 +197,4 @@ static inline void ps3_irq_poll_disable(struct irq_poll * iop) #endif } #endif -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h b/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h new file mode 100644 index 000000000000..c5a36c6ee27d --- /dev/null +++ b/drivers/scsi/linkdata/ps3stor/ps3_kernel_version.h @@ -0,0 +1,290 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _PS3_KERNEL_VERSION_H_ +#define _PS3_KERNEL_VERSION_H_ + +#if (defined(PS3_PRIV_BUSY) || (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) || \ + (defined(KYLIN_MAJOR) && defined(CONFIG_X86) && (KYLIN_MAJOR == 10 && KYLIN_MINOR == 4)))) +#define DRIVER_SUPPORT_PRIV_BUSY +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + (defined(CONFIG_SUSE_VERSION) && (CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#define PS3_HOST_ATTRS +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) +#define PS3_TRACK_QUEUE_DEPTH +#endif + +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 8) || (RHEL_MAJOR == 9 && RHEL_MINOR < 4))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE <= KERNEL_VERSION(6, 5, 13))) +#define PS3_SUPPORT_PCIE_REPORT +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#define PS3_SUPPORT_BIO_MERGE +#endif + +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0))) +#define PS3_RESET_TIMER +#endif + +#if (!defined(CONFIG_SUSE_VERSION) && LINUX_VERSION_CODE <= KERNEL_VERSION(4, 16, 0)) || \ + (defined(CONFIG_SUSE_VERSION) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 14)) +#define PS3_BLK_EH_NOT_HANDLED +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#define PS3_SUPPORT_CMD_SCP +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) +#define PS3_SUPPORT_DRIVER_SENSE +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) +#define PS3_SUPPORT_FS +#endif + +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 38))) +#define PS3_DID_NEXUS_FAILURE +#endif + +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) && (RHEL_MINOR == 3)) || \ + ((LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)) && \ + (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 14)))) +#define PS3_DID_REQUEUE +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +#define PS3_FALLTHROUGH +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + (defined(CONFIG_SUSE_VERSION) && (CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#define PS3_SCMD_IO_DONE +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + (defined(CONFIG_SUSE_VERSION) && (CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#define PS3_SCMD_GET_REQUEST +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) \ + || (defined(CONFIG_SUSE_KERNEL) && \ + defined(CONFIG_SUSE_VERSION) && ((CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 1))) \ + || (defined(CONFIG_SUSE_KERNEL) && \ + defined(CONFIG_SUSE_VERSION) && ((CONFIG_SUSE_VERSION == 12) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#define PS3_SAS_SMP_RETURN_VOID +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) +#define PS3_NCQ_PRIO_SUPPORT +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) +#define PS3_SYPPORT_BIO_ITER +#endif + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(4, 9, 0) && \ + LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) +#define PS3_SUPPORT_LINX80 +#endif + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 10, 0) +#define PS3_SCSI_DEVICE_LOOKUP +#endif + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 10, 0) +#define PS3_CHANGE_QUEUE_DEPTH +#endif + +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 3)) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + (defined(CONFIG_SUSE_VERSION) && (CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 2)))) +#define PS3_AER_CLEAR_STATUS +#elif ((LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19)) && \ + (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0))) +#define PS3_AER_CLEAR_STATUS_LOW_KERNER +#endif + +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR > 5)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0))) +#define PS3_SUPPORT_TAGSET +#endif + +#if (!defined(CONFIG_SUSE_KERNEL) && (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0) || \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0))) || \ + (defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE > KERNEL_VERSION(4, 4, 73)) +#define PS3_LINUX_SIGNAL +#endif + +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 2)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))) +#define DRIVER_SUPPORT_KERNEL_IRQ_AFFINITY +#endif + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0) || \ + LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) +#define PS3_OS_MANAGED_IRQ_SUPPORT +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) +#define PS3_KERNEL_START_WITH_516 +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#define PS3_CMD_CDB_CHECK +#endif + +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9 && RHEL_MINOR >= 2)) || \ + (defined(CONFIG_SUSE_KERNEL) && \ + (defined(CONFIG_SUSE_VERSION) && (CONFIG_SUSE_VERSION == 15) && (CONFIG_SUSE_PATCHLEVEL >= 5)))) +#define PS3_MAP_QUEUES +#endif + +#if (defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 4)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) && \ + (LINUX_VERSION_CODE < KERNEL_VERSION(6, 14, 0)) && \ + !(defined(RHEL_MAJOR) && (RHEL_MAJOR == 10) && (RHEL_MINOR >= 1)))) +#include +#endif + +#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR >= 4)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0))) +#ifndef PS3_TAGSET_SUPPORT +#define PS3_TAGSET_SUPPORT +#endif +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0)) +#define PS3_CMD_CREATE_INJECT +#endif + +#if (!defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)) || \ + (defined(CONFIG_SUSE_KERNEL) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)) +#define PS3_INJECT_PRANDOWM +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0) +#define PS3_KERNEL_WRITE_GET_DS +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) +#define PS3_KERNEL_WRITE +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#define PS3_VFS_WRITE +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) +#define PS3_SET_FS +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0) +#define PS3_FORCE_UACCESS +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) +#define PS3_DMA_MAPPING +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#define PS3_DUMP_TIME_32 +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) +#define PS3_FSNOTIFY_FILE +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) +#define PS3_FSNOTIFY_FILE_PATH +#endif + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(4, 9, 0) +#define PS3_KERNEL_WRITE_FILE_OP +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0) +#define PS3_KERNEL_WRITE_FILE_VFS +#else +#define PS3_KERNEL_WRITE_FILE +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) +#define PS3_FILEMAP_WAIT +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) +#define PS3_THREAD_INFO +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) +#define PS3_SAS_LONG_LUN +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)) +#define PS3_BLK_DMA_PAD +#endif + +#if (!defined(CONFIG_SUSE_KERNEL) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0))) || \ + (defined(CONFIG_SUSE_KERNEL) && (LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 73))) +#define PS3_BACK_DEV_INFO +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR >= 8) && (RHEL_MINOR >= 6))) +#define PS3_BLK_QUEUE_FLAG_CLEAR +#endif + +#if ((defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ + (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0))) +#define PS3_STATIC_MINOR +#endif + +#if ((LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) && !defined(RHEL_MAJOR)) || \ + (defined(RHEL_MAJOR) && ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 5)))) +#define PS3_SUPPORT_FLUSH_SCHEDULED +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0)) +#define PS3_MAP_QUEUES_RET +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) +#define PS3_DISALLOW_ZERO_ARRAY +#define PS3_WORK_FUNC_CHECK +#endif + +#if (defined(CONFIG_SUSE_KERNEL) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0))) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,14,0)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 7)) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 10) && (RHEL_MINOR >= 1)) +#define PS3_MAP_HW_QUEUES +#endif + +#if (defined(CONFIG_SUSE_KERNEL) && (LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0))) || \ + (defined(RHEL_MAJOR) && (RHEL_MAJOR == 10) && (RHEL_MINOR >= 1)) || \ + (!defined(RHEL_MAJOR) && !defined(CONFIG_SUSE_KERNEL) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,14,0))) +#define PS3_SDEV_CONFIG_SUPPORT +#elif (defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 10 && RHEL_MINOR == 0) || (RHEL_MAJOR == 9 && RHEL_MINOR >= 6))) || \ + (!defined(RHEL_MAJOR) && !defined(CONFIG_SUSE_KERNEL) && \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0))) +#define PS3_DEVICE_CONFIG_SUPPORT +#else +#define PS3_SLAVE_CONFIG_SUPPORT +#endif + +#if (defined(RHEL_MAJOR) && \ + ((RHEL_MAJOR == 9 && RHEL_MINOR >= 6) || (RHEL_MAJOR >= 10))) || \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(6,10,0)) +#define PS3_OS_IRQ_INTX +#endif + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_load.c b/drivers/scsi/linkdata/ps3stor/ps3_load.c index ed7c6308e05e..43d1d771395d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_load.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_load.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_load.h" #include "ps3_instance_manager.h" #include "ps3_ioc_manager.h" @@ -11,273 +11,249 @@ #ifdef _WINDOWS -static S32 ps3_init_ioc_prepare(struct ps3_instance *instance); +static int ps3_init_ioc_prepare(struct ps3_instance *instance); static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance); -static S32 ps3_init_ioc_complete(struct ps3_instance *instance); +static int ps3_init_ioc_complete(struct ps3_instance *instance); static void ps3_init_ioc_complete_exit(struct ps3_instance *instance); -static S32 ps3_pci_init_complete(struct ps3_instance *instance); +static int ps3_pci_init_complete(struct ps3_instance *instance); static void ps3_pci_init_complete_exit(struct ps3_instance *instance); -S32 ps3_firmware_init(struct ps3_instance *instance) +int ps3_firmware_init(struct ps3_instance *instance) { - ps3_ioc_adp_init(instance); + ps3_ioc_adp_init(instance); - if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != PS3_SUCCESS) { - goto l_failed; - } - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_READY); + if (instance->ioc_adpter->ioc_init_state_to_ready(instance) != + PS3_SUCCESS) { + goto l_failed; + } + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_READY); - if (ps3_pci_init_complete(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_pci_init_complete(instance) != PS3_SUCCESS) + goto l_failed; - if (ps3_init_ioc_prepare(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_init_ioc_prepare(instance) != PS3_SUCCESS) + goto l_failed; - if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) { - goto l_failed; - } - ps3_atomic_set(&instance->state_machine.state, PS3_INSTANCE_STATE_PRE_OPERATIONAL); + if (instance->ioc_adpter->ioc_init_proc(instance) != PS3_SUCCESS) + goto l_failed; + ps3_atomic_set(&instance->state_machine.state, + PS3_INSTANCE_STATE_PRE_OPERATIONAL); - if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_ctrl_info_get(instance) != PS3_SUCCESS) + goto l_failed; - if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_init_ioc_complete(instance) != PS3_SUCCESS) + goto l_failed; - ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); + ps3_ioctl_init(instance, PS3_MAX_IOCTL_CMDS); - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - DbgPrint("fireware init failed\n"); - ps3_firmware_exit(instance); - return -PS3_FAILED; + DbgPrint("fireware init failed\n"); + ps3_firmware_exit(instance); + return -PS3_FAILED; } void ps3_firmware_exit(struct ps3_instance *instance) { - ps3_pci_init_complete_exit(instance); - ps3_init_ioc_complete_exit(instance); - ps3_init_ioc_prepare_exit(instance); - - return; + ps3_pci_init_complete_exit(instance); + ps3_init_ioc_complete_exit(instance); + ps3_init_ioc_prepare_exit(instance); } void ps3_remove(struct ps3_instance *instance) { - ULong flags = 0; - LOG_INFO("hno:%u ps3_remove\n", PS3_HOST(instance)); + unsigned long flags = 0; - instance->state_machine.is_load = PS3_FALSE; - instance->ioc_adpter->irq_disable(instance); + LOG_INFO("hno:%u %s\n", PS3_HOST(instance), __func__); + instance->state_machine.is_load = PS3_FALSE; + instance->ioc_adpter->irq_disable(instance); - ps3_watchdog_stop(instance); + ps3_watchdog_stop(instance); + ps3_recovery_context_exit(instance); - ps3_recovery_context_exit(instance); - - ps3_event_unsubscribe(instance); - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - instance->event_context.abort_eventcmd = 0; - instance->dev_context.abort_vdpending_cmd = 0; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); - ps3_dev_mgr_vd_info_unsubscribe(instance); + ps3_event_unsubscribe(instance); + ps3_spin_lock_irqsave(&instance->recov ery_context->recovery_lock, + &flags); + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); + ps3_atomic_set(&instance->dev_context.abort_vdpending_cmd, 0); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); + ps3_dev_mgr_vd_info_unsubscribe(instance); #ifndef _WINDOWS - ps3_sas_device_data_exit(instance); + ps3_sas_device_data_exit(instance); #endif - ps3_device_mgr_data_exit(instance); + ps3_device_mgr_data_exit(instance); #ifndef _WINDOWS - if (ps3_sas_is_support_smp(instance)) { - sas_remove_host(instance->host); - } - else { - scsi_remove_host(instance->host); - } + if (ps3_sas_is_support_smp(instance)) + sas_remove_host(instance->host); + else + scsi_remove_host(instance->host); #else - ps3_device_unload_done(instance); + ps3_device_unload_done(instance); #endif - if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { - LOG_ERROR("hno:%u unload failed.\n", PS3_HOST(instance)); - if (ps3_ioc_hard_reset_to_ready(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset failed.\n", PS3_HOST(instance)); - } - } + if (ps3_soc_unload(instance, PS3_FALSE, PS3_UNLOAD_SUB_TYPE_REMOVE, + PS3_SUSPEND_TYPE_NONE) != PS3_SUCCESS) { + LOG_ERROR("hno:%u unload failed.\n", PS3_HOST(instance)); + if (ps3_ioc_hard_reset_to_ready(instance) != PS3_SUCCESS) { + LOG_ERROR("hno:%u hard reset failed.\n", + PS3_HOST(instance)); + } + } #ifndef _WINDOWS - ps3_irqs_sync(instance); - ps3_irqpolls_enable(instance); + ps3_irqs_sync(instance); + ps3_irqpolls_enable(instance); #endif - ps3_instance_state_transfer_to_quit(instance); + ps3_instance_state_transfer_to_quit(instance); - ps3_firmware_exit(instance); - ps3_pci_exit(instance); + ps3_firmware_exit(instance); + ps3_pci_exit(instance); #ifndef _WINDOWS - pci_set_drvdata(instance->pdev, NULL); - ps3_instance_put(instance); - scsi_host_put(instance->host); + pci_set_drvdata(instance->pdev, NULL); + ps3_instance_put(instance); + scsi_host_put(instance->host); - ps3_dma_dump_mapping(pdev); + ps3_dma_dump_mapping(pdev); #endif - return; } static void ps3_cmd_attr_context_init(struct ps3_instance *instance) { - U32 cmd_qdepth = 0; - instance->cmd_attr.cur_can_que = - instance->cmd_context.max_scsi_cmd_count - - instance->cmd_context.max_r1x_cmd_count; + unsigned int cmd_qdepth = 0; + + instance->cmd_attr.cur_can_que = + instance->cmd_context.max_scsi_cmd_count - + instance->cmd_context.max_r1x_cmd_count; #ifndef _WINDOWS - cmd_qdepth = ps3_throttle_qdepth_query(); - if ((cmd_qdepth != 0) && - cmd_qdepth <= instance->cmd_attr.cur_can_que) { - instance->cmd_attr.throttle_que_depth = cmd_qdepth; - } - else { - instance->cmd_attr.throttle_que_depth = - PS3_DEVICE_QDEPTH_DEFAULT_VALUE; - } + cmd_qdepth = ps3_throttle_qdepth_query(); + if ((cmd_qdepth != 0) && cmd_qdepth <= instance->cmd_attr.cur_can_que) { + instance->cmd_attr.throttle_que_depth = cmd_qdepth; + } else { + instance->cmd_attr.throttle_que_depth = + PS3_DEVICE_QDEPTH_DEFAULT_VALUE; + } #else - instance->cmd_attr.throttle_que_depth = - PS3_DEVICE_QDEPTH_DEFAULT_VALUE; + instance->cmd_attr.throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; #endif - instance->cmd_attr.vd_io_threshold = 0; - instance->cmd_attr.is_support_direct_cmd = PS3_FALSE; + instance->cmd_attr.vd_io_threshold = 0; + instance->cmd_attr.is_support_direct_cmd = PS3_FALSE; } -static S32 ps3_init_ioc_prepare(struct ps3_instance *instance) +static int ps3_init_ioc_prepare(struct ps3_instance *instance) { - ps3_ioc_mgr_req_queue_lock_init(instance); - ps3_err_fault_context_init(instance); + ps3_ioc_mgr_req_queue_lock_init(instance); + ps3_err_fault_context_init(instance); - if (!ps3_ioc_fw_version_get(instance)) { + if (!ps3_ioc_fw_version_get(instance)) goto l_fail; - } - if (!ps3_ioc_state_halt_support_get(instance)) { + if (!ps3_ioc_state_halt_support_get(instance)) goto l_fail; - } - if (!ps3_ioc_recovery_support_get(instance)) { + if (!ps3_ioc_recovery_support_get(instance)) goto l_fail; - } - if (ps3_recovery_context_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_recovery_context_init(instance) != PS3_SUCCESS) + goto l_fail; - if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_ioc_init_cmd_context_init(instance) != PS3_SUCCESS) + goto l_fail; - if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_ctrl_info_buf_alloc(instance) != PS3_SUCCESS) + goto l_fail; - if (ps3_cmd_context_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_cmd_context_init(instance) != PS3_SUCCESS) + goto l_fail; - ps3_cmd_attr_context_init(instance); + ps3_cmd_attr_context_init(instance); - if (ps3_event_context_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_event_context_init(instance) != PS3_SUCCESS) + goto l_fail; - if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_cmd_statistics_init(instance) != PS3_SUCCESS) + goto l_fail; - if (ps3_dump_init(instance) != PS3_SUCCESS) { - goto l_fail; - } + if (ps3_dump_init(instance) != PS3_SUCCESS) + goto l_fail; - return PS3_SUCCESS; + return PS3_SUCCESS; l_fail: - ps3_init_ioc_prepare_exit(instance); - return -PS3_FAILED; + ps3_init_ioc_prepare_exit(instance); + return -PS3_FAILED; } static void ps3_init_ioc_prepare_exit(struct ps3_instance *instance) { - ps3_ioc_init_cmd_context_exit(instance); - ps3_err_fault_context_exit(instance); - ps3_ctrl_info_buf_free(instance); - ps3_cmd_statistics_exit(instance); - ps3_event_context_exit(instance); - ps3_recovery_context_exit(instance); - ps3_cmd_context_exit(instance); + ps3_ioc_init_cmd_context_exit(instance); + ps3_err_fault_context_exit(instance); + ps3_ctrl_info_buf_free(instance); + ps3_cmd_statistics_exit(instance); + ps3_event_context_exit(instance); + ps3_recovery_context_exit(instance); + ps3_cmd_context_exit(instance); ps3_dump_dma_buf_free(instance); - ps3_dump_exit(instance); + ps3_dump_exit(instance); #ifndef _WINDOWS - (void)ps3_debug_mem_free(instance); + (void)ps3_debug_mem_free(instance); #endif } -static S32 ps3_init_ioc_complete(struct ps3_instance *instance) +static int ps3_init_ioc_complete(struct ps3_instance *instance) { - if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_mgr_cmd_init(instance) != PS3_SUCCESS) + goto l_failed; - if (ps3_device_mgr_init(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_device_mgr_init(instance) != PS3_SUCCESS) + goto l_failed; #ifndef _WINDOWS - if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) { - goto l_failed; - } + if (ps3_sas_device_mgr_init(instance) != PS3_SUCCESS) + goto l_failed; #endif - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - ps3_init_ioc_complete_exit(instance); - return -PS3_FAILED; + ps3_init_ioc_complete_exit(instance); + return -PS3_FAILED; } static void ps3_init_ioc_complete_exit(struct ps3_instance *instance) { #ifndef _WINDOWS - ps3_sas_device_mgr_exit(instance); + ps3_sas_device_mgr_exit(instance); #endif - ps3_device_mgr_exit(instance); - ps3_mgr_cmd_exit(instance); - - return; + ps3_device_mgr_exit(instance); + ps3_mgr_cmd_exit(instance); } -static S32 ps3_pci_init_complete(struct ps3_instance *instance) +static int ps3_pci_init_complete(struct ps3_instance *instance) { - if (ps3_irq_context_init(instance) != PS3_SUCCESS) { - goto l_failed; - } - if (instance->ioc_adpter->irq_init) { - if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) { - goto l_failed; - } - } else { - if (ps3_irqs_init(instance) != PS3_SUCCESS) { - goto l_failed; - } - } + if (ps3_irq_context_init(instance) != PS3_SUCCESS) + goto l_failed; + if (instance->ioc_adpter->irq_init) { + if (instance->ioc_adpter->irq_init(instance) != PS3_SUCCESS) + goto l_failed; + } else { + if (ps3_irqs_init(instance) != PS3_SUCCESS) + goto l_failed; + } - return PS3_SUCCESS; + return PS3_SUCCESS; l_failed: - ps3_pci_init_complete_exit(instance); - return -PS3_FAILED; + ps3_pci_init_complete_exit(instance); + return -PS3_FAILED; } static void ps3_pci_init_complete_exit(struct ps3_instance *instance) { - ps3_irqs_exit(instance); - ps3_irq_context_exit(instance); + ps3_irqs_exit(instance); + ps3_irq_context_exit(instance); } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_load.h b/drivers/scsi/linkdata/ps3stor/ps3_load.h index fc5ace49222d..f885a6e40280 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_load.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_load.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_LOAD_H_ #define _PS3_LOAD_H_ @@ -8,7 +8,7 @@ struct ps3_instance; -S32 ps3_firmware_init(struct ps3_instance *instance); +int ps3_firmware_init(struct ps3_instance *instance); void ps3_firmware_exit(struct ps3_instance *instance); @@ -16,4 +16,3 @@ void ps3_remove(struct ps3_instance *instance); #endif #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c index bd20a4b1b800..6675f33c4204 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifdef _WINDOWS #include "ps3_def.h" @@ -30,48 +30,53 @@ #include "ps3_instance_manager.h" #include "ps3_cmd_statistics.h" #include "ps3_err_inject.h" +#include "ps3_kernel_version.h" -#ifndef _WINDOWS -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4,9,0) || LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) +#ifndef _WINDOWS +#if defined(PS3_LINUX_SIGNAL) #include #else #include #endif #endif -#define CMD_MAX_RETRY_COUNT (10) +#define CMD_MAX_RETRY_COUNT (10) -#define SEND_IOCTL_CMD_CHECK(instance, cmd) ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL)\ - && (instance)->is_support_irq) +#define SEND_IOCTL_CMD_CHECK(instance, cmd) \ + ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) && (instance)->is_support_irq) -static inline Bool is_interrupt_signal(struct task_struct *p) +static inline unsigned char is_interrupt_signal(struct task_struct *p) { if (sigismember(&p->pending.signal, SIGINT) || - sigismember(&p->pending.signal, SIGKILL) || - sigismember(&p->pending.signal, SIGQUIT)) { + sigismember(&p->pending.signal, SIGKILL) || + sigismember(&p->pending.signal, SIGQUIT)) { return PS3_TRUE; } return PS3_FALSE; } void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - ULong flags = 0; - Bool is_send_cancel = PS3_FALSE; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - S32 retry_count = 0; - - while(1) { - INJECT_START(PS3_ERR_IJ_IOCTL_CMD_FORCE_DONE, cmd) + int ret = PS3_SUCCESS; + unsigned long flags = 0; + unsigned char is_send_cancel = PS3_FALSE; + int cur_state = PS3_INSTANCE_STATE_INIT; + int retry_count = 0; + + while (1) { + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_FORCE_DONE, cmd); ret = wait_for_completion_interruptible(&cmd->sync_done); - INJECT_START(PS3_ERR_IJ_IOCTL_CMD_INTERRUPT, &ret) + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_INTERRUPT, &ret); if (ret == PS3_SUCCESS) { - LOG_DEBUG("host_no:%u wait_for_completion_interrupted success\n", + LOG_DEBUG( + "host_no:%u wait_for_completion_interrupted success\n", PS3_HOST(instance)); - if((cmd->resp_frame->normalRespFrame.respStatus == PS3_DRV_MGR_BUSY) && is_send_cancel) { - cmd->resp_frame->normalRespFrame.respStatus = PS3_MGR_REC_FORCE; + if ((cmd->resp_frame->normalRespFrame.respStatus == + PS3_DRV_MGR_BUSY) && + is_send_cancel) { + cmd->resp_frame->normalRespFrame.respStatus = + PS3_MGR_REC_FORCE; } break; } @@ -79,144 +84,170 @@ void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); ret = signal_pending(current); - INJECT_START(PS3_ERR_IJ_IOCTL_CMD_PENDING, &ret) - if(!ret) { + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_PENDING, &ret); + if (!ret) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_msleep(100); continue; } ret = is_interrupt_signal(current); - INJECT_START(PS3_ERR_IJ_IOCTL_CMD_SIG_INTERRUPT, &ret) + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_SIG_INTERRUPT, &ret); if (ret) { - cur_state = ps3_atomic_read(&instance->state_machine.state); + cur_state = + ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG_INFO_IN_IRQ(instance, "host_no:%u cur_state:%s\n", - PS3_HOST(instance),namePS3InstanceState(cur_state)); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + cur_state == PS3_INSTANCE_STATE_DEAD) { + LOG_INFO_IN_IRQ( + instance, "host_no:%u cur_state:%s\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + flags); break; } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_INFO_LIM("host_no:%u wait_for_completion_interrupted by SIG INT OR KILL, QUIT\n", + LOG_INFO_LIM( + "host_no:%u wait_for_completion_interrupted by SIG INT OR KILL, QUIT\n", PS3_HOST(instance)); - if(is_send_cancel) { + if (is_send_cancel) { ps3_msleep(100); continue; } is_send_cancel = PS3_TRUE; cancel: ret = ps3_mgr_cmd_cancel(instance, cmd->index); - INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, &ret); - INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, &ret); + INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_RET_RECOVERY, + &ret); + INJECT_START(PS3_ERR_IJ_FORCE_CANCEL_CMD_PCIE_ERR, + &ret); if (ret != PS3_SUCCESS) { if (ret == -PS3_RECOVERED) { - LOG_INFO_LIM("host_no:%u cancel cmd %u send failed, wait\n", + LOG_INFO_LIM( + "host_no:%u cancel cmd %u send failed, wait\n", PS3_HOST(instance), cmd->index); + ps3_msleep(100); continue; - } else if(ret == -PS3_EBUSY) { - if(retry_count++ < CMD_MAX_RETRY_COUNT) { - ps3_msleep(100); + } else if (ret == -PS3_EBUSY) { + ps3_msleep(100); + if (retry_count++ < + CMD_MAX_RETRY_COUNT) { goto cancel; } continue; } - LOG_INFO("host_no:%u cancel cmd %u failed, QUIT, ret:%d\n", + LOG_INFO( + "host_no:%u cancel cmd %u failed, QUIT, ret:%d\n", PS3_HOST(instance), cmd->index, ret); } else { - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, + &flags); cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + flags); } break; - } else { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_msleep(100); } - - return ; } -static S32 ps3_mgr_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_mgr_cmd_send(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - - if (!instance->state_machine.is_load) { - if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ - LOG_WARN("host_no:%u instance state is unloading or suspend\n", + int ret = PS3_SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; + + if (!instance->state_machine.is_load || + instance->is_suspend) { + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { + LOG_WARN( + "host_no:%u instance state is unloading or suspend\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } } - INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, instance) - INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance) + INJECT_START(PS3_ERR_IJ_IOCTL_WAIT_UNNORMAL, instance); + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance); if (!ps3_is_instance_state_allow_cmd_execute(instance)) { - LOG_WARN("host_no:%u cannot send block cmd\n", PS3_HOST(instance)); + LOG_WARN("host_no:%u cannot send block cmd\n", + PS3_HOST(instance)); ret = -PS3_RECOVERED; if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - cur_state = ps3_atomic_read(&instance->state_machine.state); + cur_state = + ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG_WARN("host_no:%u cur_state:%s\n", PS3_HOST(instance),namePS3InstanceState(cur_state)); + cur_state == PS3_INSTANCE_STATE_DEAD) { + LOG_WARN("host_no:%u cur_state:%s\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); goto l_out; } - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; - LOG_WARN("host_no:%u ioctl cannot send block cmd:%u,resp:%d, will retry\n", - PS3_HOST(instance), cmd->index, cmd->resp_frame->normalRespFrame.respStatus); + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_BUSY; + LOG_WARN( + "host_no:%u ioctl cannot send block cmd:%u,resp:%d, will retry\n", + PS3_HOST(instance), cmd->index, + cmd->resp_frame->normalRespFrame.respStatus); ret = -PS3_RESP_ERR; } goto l_out; } - INJECT_START(PS3_ERR_IJ_PCI_ERR_RECOVERY, instance) + INJECT_START(PS3_ERR_IJ_PCI_ERR_RECOVERY, instance); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("host_no:%u cannot send block cmd due to pci recovery\n", + LOG_WARN( + "host_no:%u cannot send block cmd due to pci recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - PS3_MGR_CMD_STAT_INC(instance, cmd); + PS3_MGR_CMD_STAT_INC(instance, cmd); LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx ready send\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id); LOG_DEBUG("host_no:%u req cmd info:\n" - "\t reqFrameBufBase = 0x%llx, function = %d\n", - PS3_HOST(instance), - cpu_to_le64(instance->cmd_context.req_frame_buf_phys), - ps3_get_pci_function(instance->pdev)); + "\t reqFrameBufBase = 0x%llx, function = %d\n", + PS3_HOST(instance), + cpu_to_le64(instance->cmd_context.req_frame_buf_phys), + ps3_get_pci_function(instance->pdev)); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); l_out: return ret; } -static S32 ps3_blocked_unload_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_blocked_unload_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - PS3_MGR_CMD_STAT_INC(instance, cmd); + int ret = PS3_SUCCESS; + + PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); ret = ps3_block_cmd_wait(instance, cmd, 0); - INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret) + INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret); LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx ret:%d\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, + ret); return ret; } -static S32 ps3_blocked_cmd_wake(struct ps3_cmd *cmd) +static int ps3_blocked_cmd_wake(struct ps3_cmd *cmd) { - ULong flags = 0; + unsigned long flags = 0; + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_DEAD) { - LOG_WARN_IN_IRQ(cmd->instance, + LOG_WARN_IN_IRQ( + cmd->instance, "host_no:%u CFID:%d trace_id:0x%llx dead free\n", PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); - PS3_MGR_CMD_BACK_INC(cmd->instance, cmd, 0); + PS3_MGR_CMD_BACK_INC(cmd->instance, cmd, 0); ps3_mgr_cmd_free_nolock(cmd->instance, cmd); goto l_out; } @@ -227,9 +258,10 @@ static S32 ps3_blocked_cmd_wake(struct ps3_cmd *cmd) complete(&cmd->sync_done); INJECT_START(PS3_ERR_IJ_IGNORE_TASK_ABORT, cmd); - PS3_MGR_CMD_BACK_INC(cmd->instance, cmd, 0); + PS3_MGR_CMD_BACK_INC(cmd->instance, cmd, 0); } else { - LOG_ERROR_IN_IRQ(cmd->instance, + LOG_ERROR_IN_IRQ( + cmd->instance, "host_no:%u CFID:%d trace_id:0x%llx repeat reply\n", PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); } @@ -239,14 +271,16 @@ static S32 ps3_blocked_cmd_wake(struct ps3_cmd *cmd) return PS3_SUCCESS; } -static S32 ps3_polled_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_polled_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - if (!instance->state_machine.is_load) { - if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT){ - LOG_WARN("host_no:%u instance state is unloading or suspend\n", + if (!instance->state_machine.is_load || + instance->is_suspend) { + if (PS3_MGR_CMD_TYPE(cmd) != PS3_CMD_MANAGEMENT) { + LOG_WARN( + "host_no:%u instance state is unloading or suspend\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -259,70 +293,78 @@ static S32 ps3_polled_cmd_send(struct ps3_instance *instance, } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("host_no:%u cannot send block cmd due to pci recovery\n", + LOG_WARN( + "host_no:%u cannot send block cmd due to pci recovery\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - PS3_MGR_CMD_STAT_INC(instance, cmd); + PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); l_out: return ret; } -static S32 ps3_polled_unload_cmd_send(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_polled_unload_cmd_send(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; - PS3_MGR_CMD_STAT_INC(instance, cmd); + PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_TRUE); - INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret) + INJECT_START(PS3_ERR_IJ_UNLOAD_TIMEOUT, &ret); if (ret != -PS3_TIMEOUT) { - PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? - PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); + PS3_MGR_CMD_BACK_INC(instance, cmd, + (ret == PS3_SUCCESS) ? + PS3_REPLY_WORD_FLAG_SUCCESS : + PS3_REPLY_WORD_FLAG_FAIL); } return ret; } -static S32 ps3_blocked_cmd_cb(struct ps3_cmd *cmd, U16 reply_flags) +static int ps3_blocked_cmd_cb(struct ps3_cmd *cmd, unsigned short reply_flags) { - if((cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) - && (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { + if ((cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) && + (reply_flags == PS3_REPLY_WORD_FLAG_SUCCESS)) { cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; } return ps3_blocked_cmd_wake(cmd); } -S32 ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { - if ((cmd->is_force_polling == 0 && ps3_irq_is_enable(&cmd->instance->irq_context)) - || SEND_IOCTL_CMD_CHECK(instance, cmd)){ + if ((cmd->is_force_polling == 0 && + ps3_irq_is_enable(&cmd->instance->irq_context)) || + SEND_IOCTL_CMD_CHECK(instance, cmd)) { INJECT_START(PS3_ERR_IJ_SEND_IOCTL_BLOCK_MODE_FLAG, cmd); cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = + PS3_CMD_WORD_NEED_REPLY_WORD; return ps3_mgr_cmd_send(instance, cmd); - } else { - cmd->cmd_receive_cb = NULL; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; - return ps3_polled_cmd_send(instance, cmd); } + cmd->cmd_receive_cb = NULL; + cmd->req_frame->mgrReq.reqHead.noReplyWord = + PS3_CMD_WORD_NO_REPLY_WORD; + return ps3_polled_cmd_send(instance, cmd); } -S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { - INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR ,cmd); - INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR ,cmd); - INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL ,cmd); - INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL ,cmd); - INJECT_START(PS3_ERR_IJ_SMP_CMD_ERROR ,cmd); - INJECT_START(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR ,cmd); - INJECT_START(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR ,cmd); + int ret = PS3_SUCCESS; + + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) { + INJECT_START(PS3_ERR_IJ_ABORT_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_ABORT_CMD_NORMAL, cmd); + INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); + INJECT_START(PS3_ERR_IJ_SMP_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_GET_LINKERRORS_CMD_ERROR, cmd); + INJECT_START(PS3_ERR_IJ_PHY_CTRL_CMD_ERROR, cmd); INJECT_START(PS3_ERR_IJ_PD_LIST_RESP_RETRY, cmd); ret = ps3_block_cmd_wait(instance, cmd, 0); INJECT_START(PS3_ERR_IJ_PD_LIST_CMD_NO_RESP, &ret); @@ -333,70 +375,79 @@ S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) INJECT_START(PS3_ERR_IJ_RESET_CMD_NORMAL, cmd); ret = ps3_cmd_reply_polling(instance, cmd, 0, PS3_FALSE); if (ret != -PS3_TIMEOUT) { - PS3_MGR_CMD_BACK_INC(instance, cmd, (ret == PS3_SUCCESS) ? - PS3_REPLY_WORD_FLAG_SUCCESS : PS3_REPLY_WORD_FLAG_FAIL); + PS3_MGR_CMD_BACK_INC( + instance, cmd, + (ret == PS3_SUCCESS) ? + PS3_REPLY_WORD_FLAG_SUCCESS : + PS3_REPLY_WORD_FLAG_FAIL); } } LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx recv ret:%d\n", - PS3_HOST(instance), cmd->cmd_word.cmdFrameID, cmd->trace_id, ret); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id, ret); return ret; } -S32 ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd) { if (cmd->is_force_polling == 0 && - ps3_irq_is_enable(&cmd->instance->irq_context)) { + ps3_irq_is_enable(&cmd->instance->irq_context)) { cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = + PS3_CMD_WORD_NEED_REPLY_WORD; return ps3_blocked_unload_cmd_send(instance, cmd); - } else { - cmd->cmd_receive_cb = NULL; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; - return ps3_polled_unload_cmd_send(instance, cmd); } + cmd->cmd_receive_cb = NULL; + cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NO_REPLY_WORD; + return ps3_polled_unload_cmd_send(instance, cmd); } -S32 ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd) +int ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; cmd->cmd_receive_cb = ps3_blocked_cmd_cb; - cmd->req_frame->mgrReq.reqHead.noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; + cmd->req_frame->mgrReq.reqHead.noReplyWord = + PS3_CMD_WORD_NEED_REPLY_WORD; if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_FAILED; goto l_out; } - PS3_MGR_CMD_STAT_INC(instance, cmd); + PS3_MGR_CMD_STAT_INC(instance, cmd); instance->ioc_adpter->cmd_send(instance, &cmd->cmd_word); l_out: return ret; } -S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout) +int ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned long timeout) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (cmd->is_interrupt) { #ifdef WINDOWS_DELAY ps3_wait_cmd_for_completion_interrupt(instance, cmd); #endif } else { - ret = ps3_wait_cmd_for_completion_timeout(instance, cmd, timeout); + ret = ps3_wait_cmd_for_completion_timeout(instance, cmd, + timeout); if (ret == -PS3_TIMEOUT) { - LOG_ERROR("host_no:%u CFID:%d trace_id:0x%llx time out\n", - PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id); + LOG_ERROR( + "host_no:%u CFID:%d trace_id:0x%llx time out\n", + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id); goto l_out; } } if (cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx not complete,state:%u\n", - PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id, cmd->cmd_state.state); + LOG_INFO( + "host_no:%u CFID:%d trace_id:0x%llx not complete,state:%u\n", + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id, cmd->cmd_state.state); ret = -PS3_TIMEOUT; goto l_out; } @@ -404,16 +455,15 @@ S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong if (ps3_cmd_resp_status(cmd) != SCSI_STATUS_GOOD) { ret = -PS3_RESP_ERR; LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx resp err:0x%x\n", - PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id, - ps3_cmd_resp_status(cmd)); + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id, ps3_cmd_resp_status(cmd)); } l_out: return ret; } -S32 ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, - S32 (*cmd_receive_cb)(struct ps3_cmd *, U16)) +int ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, + int (*cmd_receive_cb)(struct ps3_cmd *, unsigned short)) { cmd->cmd_receive_cb = cmd_receive_cb; PS3_MGR_CMD_STAT_INC(instance, cmd); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h index 2b407a6e11b4..32e20a71af05 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_channel.h @@ -1,27 +1,32 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_MGR_CHANNEL_H_ #define _PS3_MGR_CHANNEL_H_ #include "ps3_cmd_channel.h" -S32 ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); -S32 ps3_unload_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); -S32 ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout); -S32 ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, -S32 (*cmd_receive_cb)(struct ps3_cmd *, U16)); +int ps3_cmd_send_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_unload_cmd_send_sync(struct ps3_instance *instance, + struct ps3_cmd *cmd); +int ps3_block_cmd_wait(struct ps3_instance *instance, struct ps3_cmd *cmd, + unsigned long timeout); +int ps3_cmd_send_async(struct ps3_instance *instance, struct ps3_cmd *cmd, + int (*cmd_receive_cb)(struct ps3_cmd *, unsigned short)); -S32 ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_cmd_wait_sync(struct ps3_instance *instance, struct ps3_cmd *cmd); -S32 ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd); +int ps3_cmd_no_block_send(struct ps3_instance *instance, struct ps3_cmd *cmd); #ifndef _WINDOWS -void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, struct ps3_cmd *cmd); +void ps3_wait_cmd_for_completion_interrupt(struct ps3_instance *instance, + struct ps3_cmd *cmd); #endif -static inline PS3RespFrame_u * ps3_cmd_resp_frame_get(struct ps3_cmd *cmd){ +static inline union PS3RespFrame *ps3_cmd_resp_frame_get(struct ps3_cmd *cmd) +{ return cmd->resp_frame; } -static inline U32 ps3_cmd_resp_status(struct ps3_cmd *cmd){ +static inline unsigned int ps3_cmd_resp_status(struct ps3_cmd *cmd) +{ return le32_to_cpu(cmd->resp_frame->normalRespFrame.respStatus); }; diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c index ea6e64a67312..f34700177e0b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -27,18 +27,19 @@ #include "ps3_ioc_state.h" #include "ps3_ioctl.h" -static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 time_out); +static int ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, unsigned short time_out); -S32 ps3_ctrl_info_buf_alloc(struct ps3_instance *instance) +int ps3_ctrl_info_buf_alloc(struct ps3_instance *instance) { - instance->ctrl_info_buf = (struct PS3IocCtrlInfo *) - ps3_dma_alloc_coherent(instance, sizeof(struct PS3IocCtrlInfo), - &instance->ctrl_info_buf_h); + instance->ctrl_info_buf = + (struct PS3IocCtrlInfo *)ps3_dma_alloc_coherent( + instance, sizeof(struct PS3IocCtrlInfo), + (unsigned long long *)&instance->ctrl_info_buf_h); if (instance->ctrl_info_buf == NULL) { LOG_ERROR("host_no:%u alloc ctrl info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_fail; } return PS3_SUCCESS; @@ -51,65 +52,68 @@ void ps3_ctrl_info_buf_free(struct ps3_instance *instance) if (instance->ctrl_info_buf != NULL) { LOG_INFO("ctrl_info_buf = %p\n", instance->ctrl_info_buf); ps3_dma_free_coherent(instance, sizeof(struct PS3IocCtrlInfo), - instance->ctrl_info_buf, - instance->ctrl_info_buf_h); + instance->ctrl_info_buf, + instance->ctrl_info_buf_h); instance->ctrl_info_buf = NULL; } memset(&instance->ctrl_info, 0, sizeof(struct PS3IocCtrlInfo)); } -static S32 ps3_mgr_pd_list_init(struct ps3_instance *instance) +static int ps3_mgr_pd_list_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->pd_list_buf = (struct PS3DevList *) - ps3_dma_alloc_coherent(instance, - PS3_MAX_PD_COUNT(instance) * - sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList), - &dev_context->pd_list_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, &dev_context->pd_list_buf); + dev_context->pd_list_buf = (struct PS3DevList *)ps3_dma_alloc_coherent( + instance, + PS3_MAX_PD_COUNT(instance) * sizeof(struct PS3PhyDevice) + + sizeof(struct PS3DevList), + (unsigned long long *)&dev_context->pd_list_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_PD_LIST_BUF_ALLOC, + &dev_context->pd_list_buf); if (dev_context->pd_list_buf == NULL) { LOG_ERROR("host_no:%u alloc pd list buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; } -static S32 ps3_mgr_vd_list_init(struct ps3_instance *instance) +static int ps3_mgr_vd_list_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->vd_list_buf = (struct PS3DevList *) - ps3_dma_alloc_coherent(instance, - PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList), - &dev_context->vd_list_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, &dev_context->vd_list_buf); + dev_context->vd_list_buf = (struct PS3DevList *)ps3_dma_alloc_coherent( + instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VirtDevice) + + sizeof(struct PS3DevList), + (unsigned long long *)&dev_context->vd_list_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_VD_LIST_BUF_ALLOC, + &dev_context->vd_list_buf); if (dev_context->vd_list_buf == NULL) { LOG_ERROR("host_no:%u alloc vd list buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; } -static S32 ps3_mgr_pd_info_init(struct ps3_instance *instance) +static int ps3_mgr_pd_info_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; - dev_context->pd_info_buf = (struct PS3PDInfo *) - ps3_dma_alloc_coherent(instance, sizeof(struct PS3PDInfo), - &dev_context->pd_info_buf_phys); - INJECT_START(PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, &dev_context->pd_info_buf); + dev_context->pd_info_buf = (struct PS3PDInfo *)ps3_dma_alloc_coherent( + instance, sizeof(struct PS3PDInfo), + (unsigned long long *)&dev_context->pd_info_buf_phys); + INJECT_START(PS3_ERR_IJ_PS3_PD_INFO_BUF_ALLOC, + &dev_context->pd_info_buf); if (dev_context->pd_info_buf == NULL) { LOG_ERROR("host_no:%u alloc pd info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; } return ret; @@ -120,10 +124,11 @@ static inline void ps3_mgr_pd_list_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->pd_list_buf != NULL) { - ps3_dma_free_coherent(instance, + ps3_dma_free_coherent( + instance, PS3_MAX_PD_COUNT(instance) * - sizeof(struct PS3PhyDevice) + - sizeof(struct PS3DevList), + sizeof(struct PS3PhyDevice) + + sizeof(struct PS3DevList), dev_context->pd_list_buf, dev_context->pd_list_buf_phys); dev_context->pd_list_buf = NULL; @@ -135,10 +140,11 @@ static inline void ps3_mgr_vd_list_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->vd_list_buf != NULL) { - ps3_dma_free_coherent(instance, + ps3_dma_free_coherent( + instance, PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VirtDevice) + - sizeof(struct PS3DevList), + sizeof(struct PS3VirtDevice) + + sizeof(struct PS3DevList), dev_context->vd_list_buf, dev_context->vd_list_buf_phys); dev_context->vd_list_buf = NULL; @@ -151,8 +157,8 @@ static inline void ps3_mgr_pd_info_exit(struct ps3_instance *instance) if (dev_context->pd_info_buf != NULL) { ps3_dma_free_coherent(instance, sizeof(struct PS3PDInfo), - dev_context->pd_info_buf, - dev_context->pd_info_buf_phys); + dev_context->pd_info_buf, + dev_context->pd_info_buf_phys); dev_context->pd_info_buf = NULL; } } @@ -162,53 +168,59 @@ static inline void ps3_mgr_vd_info_exit(struct ps3_instance *instance) struct ps3_dev_context *dev_context = &instance->dev_context; if (dev_context->vd_info_buf_sync != NULL) { - ps3_dma_free_coherent(instance, PS3_MAX_VD_COUNT(instance) - * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), + ps3_dma_free_coherent( + instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), dev_context->vd_info_buf_sync, dev_context->vd_info_buf_phys_sync); dev_context->vd_info_buf_sync = NULL; } if (dev_context->vd_info_buf_async != NULL) { - ps3_dma_free_coherent(instance, PS3_MAX_VD_COUNT(instance) - * sizeof(struct PS3VDEntry) + - sizeof(struct PS3VDInfo), + ps3_dma_free_coherent( + instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), dev_context->vd_info_buf_async, dev_context->vd_info_buf_phys_async); dev_context->vd_info_buf_async = NULL; } - } -static S32 ps3_mgr_vd_info_init(struct ps3_instance *instance) +static int ps3_mgr_vd_info_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_dev_context *dev_context = &instance->dev_context; dev_context->vd_table_idx = 0; - dev_context->vd_info_buf_sync = (struct PS3VDInfo *) - ps3_dma_alloc_coherent(instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) - + sizeof(struct PS3VDInfo), - &dev_context->vd_info_buf_phys_sync); - INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, &dev_context->vd_info_buf_sync); + dev_context + ->vd_info_buf_sync = (struct PS3VDInfo *)ps3_dma_alloc_coherent( + instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + (unsigned long long *)&dev_context->vd_info_buf_phys_sync); + INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_SYNC_ALLOC, + &dev_context->vd_info_buf_sync); if (dev_context->vd_info_buf_sync == NULL) { LOG_ERROR("host_no:%u alloc vd sync info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } - dev_context->vd_info_buf_async = (struct PS3VDInfo *) - ps3_dma_alloc_coherent(instance, - PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) - + sizeof(struct PS3VDInfo), - &dev_context->vd_info_buf_phys_async); - INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, &dev_context->vd_info_buf_async); + dev_context->vd_info_buf_async = + (struct PS3VDInfo *)ps3_dma_alloc_coherent( + instance, + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo), + (unsigned long long *)&dev_context + ->vd_info_buf_phys_async); + INJECT_START(PS3_ERR_IJ_PS3_VD_INFO_BUF_ASYNC_ALLOC, + &dev_context->vd_info_buf_async); if (dev_context->vd_info_buf_async == NULL) { LOG_ERROR("host_no:%u alloc vd async info buffer failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_failed; } @@ -221,31 +233,27 @@ static S32 ps3_mgr_vd_info_init(struct ps3_instance *instance) return ret; } -S32 ps3_mgr_cmd_init(struct ps3_instance *instance) +int ps3_mgr_cmd_init(struct ps3_instance *instance) { LOG_INFO("host_no:%u, Soc VD max is:%d\n", PS3_HOST(instance), - PS3_MAX_VD_COUNT(instance)); + PS3_MAX_VD_COUNT(instance)); LOG_INFO("host_no:%u, Soc PD max is:%d\n", PS3_HOST(instance), - PS3_MAX_PD_COUNT(instance)); + PS3_MAX_PD_COUNT(instance)); if (PS3_MAX_PD_COUNT(instance) > 0) { - if (ps3_mgr_pd_list_init(instance) != PS3_SUCCESS) { + if (ps3_mgr_pd_list_init(instance) != PS3_SUCCESS) goto free_mgr_cmd; - } - if (ps3_mgr_pd_info_init(instance) != PS3_SUCCESS) { + if (ps3_mgr_pd_info_init(instance) != PS3_SUCCESS) goto free_mgr_cmd; - } } if (PS3_MAX_VD_COUNT(instance) > 0) { - if (ps3_mgr_vd_list_init(instance) != PS3_SUCCESS) { + if (ps3_mgr_vd_list_init(instance) != PS3_SUCCESS) goto free_mgr_cmd; - } - if (ps3_mgr_vd_info_init(instance) != PS3_SUCCESS) { + if (ps3_mgr_vd_info_init(instance) != PS3_SUCCESS) goto free_mgr_cmd; - } } return PS3_SUCCESS; @@ -261,13 +269,12 @@ void ps3_mgr_cmd_exit(struct ps3_instance *instance) ps3_mgr_vd_list_exit(instance); ps3_mgr_pd_info_exit(instance); ps3_mgr_vd_info_exit(instance); - - return ; } void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd) { struct PS3CmdWord *cmd_word = &cmd->cmd_word; + memset(cmd_word, 0, sizeof(*cmd_word)); cmd_word->type = PS3_CMDWORD_TYPE_MGR; @@ -280,20 +287,23 @@ void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd) #endif } -static void ps3_mgr_print_cmd(struct ps3_cmd *cmd, const S8 *cmd_type, Bool is_send) +static void ps3_mgr_print_cmd(struct ps3_cmd *cmd, const char *cmd_type, + unsigned char is_send) { - LOG_DEBUG("host_no:%u t_id:0x%llx mgr:%s:%s cmd word type:%d " - "direct:%d qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d function:%d\n", + LOG_DEBUG( + "host_no:%u t_id:0x%llx mgr:%s:%s cmd word type:%d\n" + "\tdirect:%d qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d function:%d\n", PS3_HOST(cmd->instance), cmd->trace_id, - (is_send) ? "send" : "recv", cmd_type, - cmd->cmd_word.type, cmd->cmd_word.direct, - cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, - cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, - cmd->cmd_word.phyDiskID, ps3_get_pci_function(cmd->instance->pdev)); + (is_send) ? "send" : "recv", cmd_type, cmd->cmd_word.type, + cmd->cmd_word.direct, cmd->cmd_word.qMask, + cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, + cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID, + ps3_get_pci_function(cmd->instance->pdev)); } static inline void ps3_mgr_req_head_init(struct ps3_cmd *cmd, - PS3ReqFrameHead_s *req_header, U8 cmdSubType) + struct PS3ReqFrameHead *req_header, + unsigned char cmdSubType) { req_header->timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; req_header->traceID = ps3_cmd_trace_id(cmd); @@ -305,23 +315,25 @@ static inline void ps3_mgr_req_head_init(struct ps3_cmd *cmd, req_header->noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; } -static inline void ps3_mgr_req_frame_sge_build(PS3MgrReqFrame_s *mgr_req_frame, - dma_addr_t dma_addr, U32 dma_len) +static inline void +ps3_mgr_req_frame_sge_build(struct PS3MgrReqFrame *mgr_req_frame, + dma_addr_t dma_addr, unsigned int dma_len) { struct PS3Sge *p_sge = mgr_req_frame->sgl; - mgr_req_frame->sgeOffset = offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgr_req_frame->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> + PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgr_req_frame->sgeCount = 1; p_sge->addr = cpu_to_le64(dma_addr); p_sge->length = cpu_to_le32(dma_len); - p_sge->lastSge = 1; - p_sge->ext = 0; + p_sge->lastSge = 1; + p_sge->ext = 0; } -static S32 ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, U16 time_out) +static int ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, unsigned short time_out) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; enum PS3MgrCmdSubType cmd_type = (enum PS3MgrCmdSubType)cmd->req_frame->mgrReq.reqHead.cmdSubType; @@ -333,41 +345,43 @@ static S32 ps3_mgr_unload_cmd_send(struct ps3_cmd *cmd, U16 time_out) ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(cmd_type), PS3_DRV_FALSE); if (ret == PS3_SUCCESS) { - LOG_INFO("host_no:%u send %s success\n", PS3_HOST(cmd->instance), - namePS3MgrCmdSubType(cmd_type)); + LOG_INFO("host_no:%u send %s success\n", + PS3_HOST(cmd->instance), + namePS3MgrCmdSubType(cmd_type)); } else { - LOG_ERROR("host_no:%u send %s %s respStatus:%d\n", PS3_HOST(cmd->instance), - namePS3MgrCmdSubType(cmd_type), - (ret == -PS3_TIMEOUT) ? "timeout" : "failed", - ps3_cmd_resp_status(cmd)); + LOG_ERROR("host_no:%u send %s %s respStatus:%d\n", + PS3_HOST(cmd->instance), + namePS3MgrCmdSubType(cmd_type), + (ret == -PS3_TIMEOUT) ? "timeout" : "failed", + ps3_cmd_resp_status(cmd)); } return ret; } -S32 ps3_pd_list_get(struct ps3_instance *instance) +int ps3_pd_list_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U32 pd_list_size = PS3_MAX_PD_COUNT(instance) * - sizeof(struct PS3PhyDevice) + sizeof(struct PS3DevList); + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned int pd_list_size = + PS3_MAX_PD_COUNT(instance) * sizeof(struct PS3PhyDevice) + + sizeof(struct PS3DevList); LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u pd list cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -377,47 +391,50 @@ S32 ps3_pd_list_get(struct ps3_instance *instance) memset(instance->dev_context.pd_list_buf, 0, pd_list_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_PD_LIST); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_PD_LIST); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = 0; mgr_req_frame->value.dev.num = PS3_MAX_PD_COUNT(instance); ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.pd_list_buf_phys, - pd_list_size); + instance->dev_context.pd_list_buf_phys, + pd_list_size); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_LIST), PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_LIST), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_INFO("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_vd_list_get(struct ps3_instance *instance) +int ps3_vd_list_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U32 vd_list_size = PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VirtDevice) + sizeof(struct PS3DevList); + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned int vd_list_size = + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VirtDevice) + + sizeof(struct PS3DevList); LOG_INFO("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u vd list cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -425,8 +442,7 @@ S32 ps3_vd_list_get(struct ps3_instance *instance) cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -436,45 +452,48 @@ S32 ps3_vd_list_get(struct ps3_instance *instance) memset(instance->dev_context.vd_list_buf, 0, vd_list_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_LIST); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_VD_LIST); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = 0; mgr_req_frame->value.dev.num = PS3_MAX_VD_COUNT(instance); ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.vd_list_buf_phys, - vd_list_size); + instance->dev_context.vd_list_buf_phys, + vd_list_size); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_LIST), PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_LIST), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_INFO("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U16 pd_disk_id) +int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, + unsigned short target_id, unsigned short pd_disk_id) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U32 pd_info_size = sizeof(struct PS3PDInfo); + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned int pd_info_size = sizeof(struct PS3PDInfo); LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u pd info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -482,8 +501,7 @@ S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -493,7 +511,8 @@ S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U memset(instance->dev_context.pd_info_buf, 0, pd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_PD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_PD_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; @@ -504,27 +523,28 @@ S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U mgr_req_frame->value.dev.devID.diskDev.ps3Dev.phyDiskID = pd_disk_id; ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->dev_context.pd_info_buf_phys, - pd_info_size); + instance->dev_context.pd_info_buf_phys, + pd_info_size); LOG_INFO("host_no:%u ready send, reqFrameId=%d, [%d:%d:%d]!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), channel, target_id, - pd_disk_id); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), channel, target_id, + pd_disk_id); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_INFO), PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_PD_INFO), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); LOG_INFO("host_no:%u get pd info [%d:%d:%d] finished!:ret = %d\n", - PS3_HOST(instance), channel, target_id, pd_disk_id, ret); + PS3_HOST(instance), channel, target_id, pd_disk_id, ret); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } INJECT_START(PS3_ERR_IJ_GET_PD_INFO_RETURN_FAILED, &ret); @@ -532,22 +552,23 @@ S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U return ret; } -S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, - U16 vd_num) +int ps3_vd_info_sync_get(struct ps3_instance *instance, unsigned int disk_id, + unsigned short vd_num) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U32 vd_info_size = PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VDEntry) + sizeof(struct PS3VDInfo); + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned int vd_info_size = + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo); struct ps3_dev_context *dev_context = &instance->dev_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u vd info sync cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -555,8 +576,7 @@ S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -566,44 +586,49 @@ S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, memset(dev_context->vd_info_buf_sync, 0, vd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_VD_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->value.dev.devID.diskDev.diskID = disk_id; mgr_req_frame->value.dev.num = vd_num; ps3_mgr_req_frame_sge_build(mgr_req_frame, - dev_context->vd_info_buf_phys_sync, - vd_info_size); + dev_context->vd_info_buf_phys_sync, + vd_info_size); - LOG_INFO("host_no:%u ready send, reqFrameId=%d, disk_id=0x%x, num=%d !\n", + LOG_INFO( + "host_no:%u ready send, reqFrameId=%d, disk_id=0x%x, num=%d !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_INFO), PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_GET_VD_INFO), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_INFO("host_no:%u get vd info, reqFrameId=%d, disk_id=0x%x, num=%d finish!\n", + LOG_INFO( + "host_no:%u get vd info, reqFrameId=%d, disk_id=0x%x, num=%d finish!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), disk_id, vd_num); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_vd_info_async_get(struct ps3_instance *instance) +int ps3_vd_info_async_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U32 vd_info_size = PS3_MAX_VD_COUNT(instance) * - sizeof(struct PS3VDEntry) + sizeof(struct PS3VDInfo); + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned int vd_info_size = + PS3_MAX_VD_COUNT(instance) * sizeof(struct PS3VDEntry) + + sizeof(struct PS3VDInfo); struct ps3_dev_context *dev_context = &instance->dev_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); @@ -614,57 +639,64 @@ S32 ps3_vd_info_async_get(struct ps3_instance *instance) INJECT_START(PS3_ERR_IJ_PS3_VD_PENDING_CMD_ALLOC, &cmd); if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } mgr_req_frame = &cmd->req_frame->mgrReq; - memset(dev_context->vd_info_buf_async, - 0, vd_info_size); + memset(dev_context->vd_info_buf_async, 0, vd_info_size); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_VD_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_VD_INFO); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_req_frame_sge_build(mgr_req_frame, - dev_context->vd_info_buf_phys_async, - vd_info_size); + dev_context->vd_info_buf_phys_async, + vd_info_size); - ps3_vd_pending_filter_table_build((U8*) - dev_context->vd_info_buf_async); + ps3_vd_pending_filter_table_build( + (unsigned char *)dev_context->vd_info_buf_async); ps3_mgr_cmd_word_build(cmd); - LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d, t_id:0x%llx!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); + LOG_FILE_INFO( + "host_no:%u ready send, reqFrameId=%d, t_id:0x%llx!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), + cmd->trace_id); ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_TRUE); dev_context->vd_pending_cmd = cmd; - ret = ps3_cmd_send_async(instance, cmd, ps3_dev_vd_pending_proc); - INJECT_START(PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, &ret) + ret = ps3_cmd_send_async(instance, cmd, + ps3_dev_vd_pending_proc); + INJECT_START(PS3_ERR_IJ_FORCE_VDINFO_SUB_FAIL, &ret); ps3_mgr_print_cmd(cmd, "vd info async", PS3_DRV_FALSE); if (ret != PS3_SUCCESS) { - LOG_FILE_ERROR("host_no:%u send error, reqFrameId=%d, t_id:0x%llx ret:%d!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), - cmd->trace_id, ret); + LOG_FILE_ERROR( + "host_no:%u send error, reqFrameId=%d, t_id:0x%llx ret:%d!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), + cmd->trace_id, ret); dev_context->vd_pending_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); } } else { - LOG_FILE_INFO("host_no:%u vd info already subscribed\n", PS3_HOST(instance)); + LOG_FILE_INFO("host_no:%u vd info already subscribed\n", + PS3_HOST(instance)); } l_out: LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -static inline void ps3_ctrl_info_capablity_dump(struct ps3_instance *instance) +static inline void ps3_ctrl_info_capability_dump(struct ps3_instance *instance) { - LOG_WARN("host_no:%u ctrl info--supportUnevenSpans:%d supportJbodSecure:%d " - "supportNvmePassthru:%d supportDirectCmd:%d " - "supportAcceleration:%d supportSataDirectCmd:%d supportSataNcq:%d ioTimeOut:%u cancelTimeOut:%u isotoneTimeOut:%u\n", + LOG_WARN( + "host_no:%u ctrl info--supportUnevenSpans:%d supportJbodSecure:%d\n" + "\tsupportNvmePassthru:%d supportDirectCmd:%d\n" + "\tsupportAcceleration:%d supportSataDirectCmd:%d supportSataNcq:%d\n" + "\tioTimeOut:%u cancelTimeOut:%u isotoneTimeOut:%u\n", PS3_HOST(instance), instance->ctrl_info.capabilities.supportUnevenSpans, instance->ctrl_info.capabilities.supportJbodSecure, @@ -675,66 +707,64 @@ static inline void ps3_ctrl_info_capablity_dump(struct ps3_instance *instance) instance->ctrl_info.capabilities.supportSataNcq, instance->ctrl_info.ioTimeOut, instance->ctrl_info.cancelTimeOut, - instance->ctrl_info.isotoneTimeOut - ); + instance->ctrl_info.isotoneTimeOut); } static void ps3_ctrl_info_update(struct ps3_instance *instance) { - Bool is_need_dump_info = (0 != memcmp(&instance->ctrl_info, - instance->ctrl_info_buf, sizeof(instance->ctrl_info))); + unsigned char is_need_dump_info = + (memcmp(&instance->ctrl_info, instance->ctrl_info_buf, + sizeof(instance->ctrl_info)) != 0); memcpy(&instance->ctrl_info, instance->ctrl_info_buf, - sizeof(instance->ctrl_info)); + sizeof(instance->ctrl_info)); - if (is_need_dump_info) { - ps3_ctrl_info_capablity_dump(instance); - } + if (is_need_dump_info) + ps3_ctrl_info_capability_dump(instance); if (instance->ctrl_info.capabilities.supportDirectCmd) { instance->cmd_attr.is_support_direct_cmd = PS3_DRV_TRUE; LOG_INFO("host_no:%u change is_support_direct_cmd to :%d !\n", - PS3_HOST(instance), - instance->cmd_attr.is_support_direct_cmd); + PS3_HOST(instance), + instance->cmd_attr.is_support_direct_cmd); } else { instance->cmd_attr.is_support_direct_cmd = PS3_DRV_FALSE; LOG_INFO("host_no:%u change is_support_direct_cmd to :%d !\n", - PS3_HOST(instance), - instance->cmd_attr.is_support_direct_cmd); + PS3_HOST(instance), + instance->cmd_attr.is_support_direct_cmd); } instance->cmd_attr.vd_io_threshold = le32_to_cpu(instance->ctrl_info.vdIOThreshold); LOG_INFO("host_no:%u change vdIOThreshold to :%d !\n", - PS3_HOST(instance), - instance->cmd_attr.vd_io_threshold); + PS3_HOST(instance), instance->cmd_attr.vd_io_threshold); ps3_perf_update(instance, instance->ctrl_info.iocPerfMode); if (instance->ctrl_info.vdQueueNum == 0) { LOG_ERROR("host_no:%u ctrl info update vd Queue Num is 0!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); instance->ctrl_info.vdQueueNum = 1; } - LOG_DEBUG("host_no:%u offsetOfVDID:%u\n", - PS3_HOST(instance), instance->ctrl_info.offsetOfVDID); + LOG_DEBUG("host_no:%u offsetOfVDID:%u\n", PS3_HOST(instance), + instance->ctrl_info.offsetOfVDID); LOG_INFO("host_no:%u change is_balance_current_perf_mode to :%d !\n", - PS3_HOST(instance), - instance->irq_context.is_balance_current_perf_mode); + PS3_HOST(instance), + instance->irq_context.is_balance_current_perf_mode); } -S32 ps3_ctrl_info_get(struct ps3_instance *instance) +int ps3_ctrl_info_get(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u ctrl info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -742,8 +772,7 @@ S32 ps3_ctrl_info_get(struct ps3_instance *instance) cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -753,21 +782,23 @@ S32 ps3_ctrl_info_get(struct ps3_instance *instance) memset(instance->ctrl_info_buf, 0, sizeof(struct PS3IocCtrlInfo)); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_GET_CTRL_INFO); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_GET_CTRL_INFO); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; cmd->is_force_polling = 1; - ps3_mgr_req_frame_sge_build(mgr_req_frame, - instance->ctrl_info_buf_h, - sizeof(struct PS3IocCtrlInfo)); + ps3_mgr_req_frame_sge_build(mgr_req_frame, instance->ctrl_info_buf_h, + sizeof(struct PS3IocCtrlInfo)); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_GET_CTRL_INFO), PS3_DRV_FALSE); + ps3_mgr_print_cmd( + cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_GET_CTRL_INFO), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { @@ -776,18 +807,18 @@ S32 ps3_ctrl_info_get(struct ps3_instance *instance) } ps3_ctrl_info_update(instance); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 suspend_type) +int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, + unsigned char type, unsigned char suspend_type) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); @@ -800,10 +831,9 @@ S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 s ps3_wait_mgr_cmd_done(instance, PS3_TRUE); cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_ROMOVE_UNLOAD_FAIL, &cmd) + INJECT_START(PS3_ERR_IJ_ROMOVE_UNLOAD_FAIL, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } @@ -821,32 +851,32 @@ S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 s mgr_req_frame->suspend_type = suspend_type; cmd->is_force_polling = is_polling; - LOG_WARN("host_no:%u ready send unload, reqFrameId=%d suspend_type:%d!\n", + LOG_WARN( + "host_no:%u ready send unload, reqFrameId=%d suspend_type:%d!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), suspend_type); ret = ps3_mgr_unload_cmd_send(cmd, instance->unload_timeout); - INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, &ret) + INJECT_START(PS3_ERR_IJ_WAIT_SUSPEND_WAIT_RECOVERY, &ret); LOG_WARN("host_no:%u reqFrameId=%d finished ret:%d!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), ret); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), ret); l_out: - if (cmd != NULL) { + if (cmd != NULL) ps3_mgr_cmd_free(instance, cmd); - } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; struct ps3_dump_context *dump_context = &instance->dump_context; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); cmd = ps3_mgr_cmd_alloc(instance); if (cmd == NULL) { LOG_ERROR("host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } @@ -854,38 +884,40 @@ struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance) memset(dump_context->dump_dma_buf, 0, PS3_DUMP_DMA_BUF_SIZE); memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_AUTODUMP_NOTIFY); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_AUTODUMP_NOTIFY); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_req_frame_sge_build(mgr_req_frame, dump_context->dump_dma_addr, - PS3_DUMP_DMA_BUF_SIZE); + PS3_DUMP_DMA_BUF_SIZE); ps3_mgr_cmd_word_build(cmd); - LOG_DEBUG("host_no:%u reqFrameId=%d !\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + LOG_DEBUG("host_no:%u reqFrameId=%d !\n", PS3_HOST(instance), + ps3_cmd_frame_id(cmd)); l_out: LOG_DEBUG("host_no:%u exit ! ret %d\n", PS3_HOST(instance), ret); return cmd; } -S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type) +int ps3_scsi_remove_device_done(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u remove done cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -893,8 +925,7 @@ S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -903,7 +934,8 @@ S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_DEV_DEL_DONE); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_DEV_DEL_DONE); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->reqHead.devID.ps3Dev = disk_pos->diskDev.ps3Dev; @@ -911,56 +943,58 @@ S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, mgr_req_frame->value.dev.devID.diskMagicNum = disk_pos->diskMagicNum; mgr_req_frame->value.dev.devType = dev_type; - - LOG_INFO("host_no:%u ready send, t_id:0x%llx reqFrameId=%d, dev_type=%d, " - "[%d:%d:%d:%u]!\n", - PS3_HOST(instance), cmd->trace_id, ps3_cmd_frame_id(cmd), dev_type, - PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + LOG_INFO( + "host_no:%u ready send, t_id:0x%llx reqFrameId=%d, dev_type=%d,\n" + "\t[%d:%d:%d:%u]!\n", + PS3_HOST(instance), cmd->trace_id, ps3_cmd_frame_id(cmd), + dev_type, PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), disk_pos->diskMagicNum); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_DEL_DONE), PS3_DRV_FALSE); + ps3_mgr_print_cmd( + cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_DEL_DONE), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_INFO("host_no:%u send [%u:%u:%u:%u][type:%d] del done failed!:ret = %d\n", + LOG_INFO( + "host_no:%u send [%u:%u:%u:%u][type:%d] del done failed!:ret = %d\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, - dev_type, ret); + disk_pos->diskMagicNum, dev_type, ret); } l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_INFO("host_no:%u send [%d:%d:%d:%u] finish!:ret = %d\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, ret); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos), + disk_pos->diskMagicNum, ret); LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type) +int ps3_scsi_add_device_ack(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u add ack cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -968,8 +1002,7 @@ S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_ERROR("host_no:%u mgr cmd get NOK !\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u mgr cmd get NOK !\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -978,7 +1011,8 @@ S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_DEV_ADD_ACK); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_DEV_ADD_ACK); mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 1; mgr_req_frame->reqHead.devID.ps3Dev = disk_pos->diskDev.ps3Dev; @@ -986,73 +1020,74 @@ S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, mgr_req_frame->value.dev.devID.diskMagicNum = disk_pos->diskMagicNum; mgr_req_frame->value.dev.devType = dev_type; - LOG_INFO("t_id:0x%llx host_no:%u ready send, CFID:%d dev_type:%d " - "[%u:%u:%u:%u]!\n", - cmd->trace_id, PS3_HOST(instance), ps3_cmd_frame_id(cmd), dev_type, - PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), - PS3_VDID(disk_pos), disk_pos->diskMagicNum); + LOG_INFO("t_id:0x%llx host_no:%u ready send, CFID:%d dev_type:%d\n" + "\t[%u:%u:%u:%u]!\n", + cmd->trace_id, PS3_HOST(instance), ps3_cmd_frame_id(cmd), + dev_type, PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), + PS3_VDID(disk_pos), disk_pos->diskMagicNum); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_ADD_ACK), PS3_DRV_FALSE); + namePS3MgrCmdSubType(PS3_MGR_CMD_DEV_ADD_ACK), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_ERROR("host_no:%u send [%u:%u:%u:%u][type:%d] add ack NOK!:ret = %d\n", + LOG_ERROR( + "host_no:%u send [%u:%u:%u:%u][type:%d] add ack NOK!:ret = %d\n", PS3_HOST(instance), PS3_CHANNEL(disk_pos), PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, - dev_type, ret); + disk_pos->diskMagicNum, dev_type, ret); } l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } LOG_INFO("host_no:%u send [%u:%u:%u:%u] finish!:ret = %d\n", - PS3_HOST(instance), PS3_CHANNEL(disk_pos), - PS3_TARGET(disk_pos), PS3_VDID(disk_pos), - disk_pos->diskMagicNum, ret); + PS3_HOST(instance), PS3_CHANNEL(disk_pos), + PS3_TARGET(disk_pos), PS3_VDID(disk_pos), + disk_pos->diskMagicNum, ret); LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id) +int ps3_mgr_cmd_cancel(struct ps3_instance *instance, + unsigned short cancel_cmd_frame_id) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - U16 cancel_time_out = PS3_CANCEL_MGR_CMD_TIMEOUT; + struct PS3MgrReqFrame *mgr_req_frame = NULL; + unsigned short cancel_time_out = PS3_CANCEL_MGR_CMD_TIMEOUT; - LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", - PS3_HOST(instance), cancel_cmd_frame_id); + LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", PS3_HOST(instance), + cancel_cmd_frame_id); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u mgr cancel cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } cmd = ps3_task_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, &cmd) + INJECT_START(PS3_ERR_IJ_FORCE_ALLOC_CANCEL_CMD_FAILED, &cmd); if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u task cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } - if (instance->ctrl_info.cancelTimeOut > cancel_time_out) { + if (instance->ctrl_info.cancelTimeOut > cancel_time_out) cancel_time_out = instance->ctrl_info.cancelTimeOut; - } mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); @@ -1065,7 +1100,8 @@ S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id) mgr_req_frame->abortFlag = 0; mgr_req_frame->value.originalCmdFrameID = cancel_cmd_frame_id; - LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", + LOG_FILE_INFO( + "host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RECOVERY_CANCEL, cmd); @@ -1073,33 +1109,35 @@ S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id) ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(PS3_MGR_CMD_CANCEL), PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(PS3_MGR_CMD_CANCEL), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_FILE_INFO("host_no:%u reqFrameId=%d cancel_cmd_frame_id:%u finished!\n", + LOG_FILE_INFO( + "host_no:%u reqFrameId=%d cancel_cmd_frame_id:%u finished!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_task_cmd_free(instance, cmd); - } LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, - U16 cancel_cmd_frame_id, U8 type) +int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, + unsigned short cancel_cmd_frame_id, + unsigned char type) { - S32 ret = PS3_SUCCESS; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + int ret = PS3_SUCCESS; + struct PS3MgrReqFrame *mgr_req_frame = NULL; enum PS3MgrCmdSubType sub_type; struct ps3_cmd *cmd = NULL; - LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", - PS3_HOST(instance), cancel_cmd_frame_id); + + LOG_DEBUG("host_no:%u enter, be cancel CFID:%d !\n", PS3_HOST(instance), + cancel_cmd_frame_id); cmd = ps3_task_cmd_alloc(instance); if (cmd == NULL) { LOG_FILE_ERROR("host_no:%u task cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_ENOMEM; goto l_out; } @@ -1114,7 +1152,8 @@ S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, mgr_req_frame->abortFlag = 0; mgr_req_frame->value.originalCmdFrameID = cancel_cmd_frame_id; - LOG_FILE_INFO("host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", + LOG_FILE_INFO( + "host_no:%u ready send, reqFrameId=%d cancel_cmd_frame_id:%u !\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cancel_cmd_frame_id); sub_type = (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); @@ -1123,54 +1162,53 @@ S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, cmd->is_interrupt = PS3_DRV_FALSE; ps3_mgr_cmd_word_build(cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); - if(type == PS3_CANCEL_EVENT_CMD){ + ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + if (type == PS3_CANCEL_EVENT_CMD) instance->event_context.event_abort_cmd = cmd; - }else if(type == PS3_CANCEL_WEB_CMD){ - instance->webSubscribe_context.web_abort_cmd = cmd; - }else{ + else if (type == PS3_CANCEL_WEB_CMD) + instance->webSubscribe_context.web_abort_cmd = cmd; + else instance->dev_context.vdpending_abort_cmd = cmd; - } ret = ps3_cmd_no_block_send(instance, cmd); if (ret != PS3_SUCCESS) { - LOG_FILE_INFO("host_no:%u CFID:%d trace_id:0x%llx send failed\n", - PS3_HOST(instance), - ps3_cmd_frame_id(cmd), cmd->trace_id); + LOG_FILE_INFO( + "host_no:%u CFID:%d trace_id:0x%llx send failed\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), + cmd->trace_id); } - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); l_out: return ret; } -S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type) +int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; - ULong flags = 0; - S32 send_result; - if (type == PS3_CANCEL_EVENT_CMD){ + unsigned long flags = 0; + int send_result; + + if (type == PS3_CANCEL_EVENT_CMD) { cmd = instance->event_context.event_abort_cmd; - if (cmd == NULL){ + if (cmd == NULL) { LOG_INFO("host_no:%u event abort cmd null!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto l_out; + } + } else if (type == PS3_CANCEL_WEB_CMD) { + cmd = instance->webSubscribe_context.web_abort_cmd; + if (cmd == NULL) { + LOG_INFO("host_no:%u web abort cmd null!\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - }else if(type == PS3_CANCEL_WEB_CMD){ - cmd = instance->webSubscribe_context.web_abort_cmd; - if (cmd == NULL){ - LOG_INFO("host_no:%u web abort cmd null!\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; - goto l_out; - } - }else{ + } else { cmd = instance->dev_context.vdpending_abort_cmd; - if (cmd == NULL){ + if (cmd == NULL) { LOG_INFO("host_no:%u vdpending abort cmd null!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -1178,7 +1216,7 @@ S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type) send_result = ps3_block_cmd_wait(instance, cmd, 0); ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if(cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE){ + if (cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); ret = -PS3_RECOVERED; goto l_out; @@ -1187,39 +1225,36 @@ S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type) ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_INFO("host_no:%u reqFrameId=%d finished!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + LOG_INFO("host_no:%u reqFrameId=%d finished!\n", PS3_HOST(instance), + ps3_cmd_frame_id(cmd)); if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { - if(type == PS3_CANCEL_EVENT_CMD){ + if (type == PS3_CANCEL_EVENT_CMD) { abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } - }else if(type == PS3_CANCEL_WEB_CMD){ - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - if (abort_cmd != NULL) { - ps3_task_cmd_free(instance, abort_cmd); - } - }else{ + } else if (type == PS3_CANCEL_WEB_CMD) { + abort_cmd = + instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + if (abort_cmd != NULL) + ps3_task_cmd_free(instance, abort_cmd); + } else { abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; - if (abort_cmd != NULL) { + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } } } l_out: return ret; } -S32 ps3_event_register(struct ps3_instance *instance, - struct PS3MgrEvent *event) +int ps3_event_register(struct ps3_instance *instance, struct PS3MgrEvent *event) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; + struct PS3MgrReqFrame *mgr_req_frame = NULL; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); @@ -1227,7 +1262,7 @@ S32 ps3_event_register(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_ERROR_IN_IRQ(instance, "host_no:%u mgr cmd get failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_EBUSY; goto l_out; } @@ -1235,32 +1270,33 @@ S32 ps3_event_register(struct ps3_instance *instance, mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(*mgr_req_frame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_SUBSCRIBE_EVENT); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_SUBSCRIBE_EVENT); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; - mgr_req_frame->value.event.eventTypeMap = - event->eventTypeMap; + mgr_req_frame->value.event.eventTypeMap = event->eventTypeMap; mgr_req_frame->value.event.eventTypeMapProcResult = event->eventTypeMapProcResult; mgr_req_frame->value.event.eventLevel = event->eventLevel; - instance->event_context.event_info = (struct PS3EventInfo*)cmd->ext_buf; + instance->event_context.event_info = + (struct PS3EventInfo *)cmd->ext_buf; - ps3_mgr_req_frame_sge_build(mgr_req_frame, - cmd->ext_buf_phys, - cmd->instance->cmd_context.ext_buf_size); + ps3_mgr_req_frame_sge_build(mgr_req_frame, cmd->ext_buf_phys, + cmd->instance->cmd_context.ext_buf_size); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); if (instance->ioc_adpter->event_filter_table_get != NULL) { - instance->ioc_adpter->event_filter_table_get((U8*)cmd->ext_buf); + instance->ioc_adpter->event_filter_table_get( + (unsigned char *)cmd->ext_buf); } ps3_mgr_cmd_word_build(cmd); LOG_INFO_IN_IRQ(instance, "host_no:%u ready send, reqFrameId=%d !\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); ps3_mgr_print_cmd(cmd, "event register", PS3_DRV_TRUE); instance->event_context.event_cmd = cmd; @@ -1275,71 +1311,81 @@ S32 ps3_event_register(struct ps3_instance *instance, return ret; } -S32 ps3_web_register(struct ps3_instance *instance) +int ps3_web_register(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - PS3MgrReqFrame_s *mgr_req_frame = NULL; - struct ps3_webSubscribe_context *web_context = &instance->webSubscribe_context; + struct PS3MgrReqFrame *mgr_req_frame = NULL; + struct ps3_webSubscribe_context *web_context = + &instance->webSubscribe_context; cmd = web_context->webSubscribe_cmd; if (cmd == NULL) { ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != PS3_SUCCESS) { + if (ps3_mgr_cmd_send_pre_check(instance, PS3_TRUE) != + PS3_SUCCESS) { LOG_WARN_LIM("hno:%u web cmd pre check NOK\n", - PS3_HOST(instance)); - ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + PS3_HOST(instance)); + ps3_atomic_dec( + &instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; } cmd = ps3_mgr_cmd_alloc(instance); INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_WARN_IN_IRQ(instance, + LOG_WARN_IN_IRQ( + instance, "host_no:%u ioctl req, Failed to get a cmd packet\n", PS3_HOST(instance)); - ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + ps3_atomic_dec( + &instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; } mgr_req_frame = &cmd->req_frame->mgrReq; memset(mgr_req_frame, 0, sizeof(struct PS3MgrReqFrame)); - ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); + ps3_mgr_req_head_init(cmd, &mgr_req_frame->reqHead, + PS3_MGR_CMD_WEBSUBSCRIBE_EVENT); mgr_req_frame->reqHead.timeout = 0; mgr_req_frame->timeout = 0; mgr_req_frame->syncFlag = 0; mgr_req_frame->pendingFlag = 1; ps3_mgr_cmd_word_build(cmd); - LOG_INFO_IN_IRQ(instance, "host_no:%u ready send, reqFrameId=%d !\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd)); + LOG_INFO_IN_IRQ(instance, + "host_no:%u ready send, reqFrameId=%d !\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd)); ps3_mgr_print_cmd(cmd, "web event register", PS3_DRV_TRUE); web_context->webSubscribe_cmd = cmd; - ret = ps3_cmd_send_async(instance, cmd, ps3_webSubscribe_service); + ret = ps3_cmd_send_async(instance, cmd, + ps3_webSubscribe_service); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - INJECT_START(PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, &ret) + INJECT_START(PS3_ERR_IJ_FORCE_WEB_SUB_FAIL, &ret); if (ret != PS3_SUCCESS) { web_context->webSubscribe_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); goto l_out; } - }else { - LOG_INFO_IN_IRQ(instance, "host_no:%u web event already subscribed\n", - PS3_HOST(instance)); + } else { + LOG_INFO_IN_IRQ(instance, + "host_no:%u web event already subscribed\n", + PS3_HOST(instance)); } l_out: LOG_DEBUG("host_no:%u exit !\n", PS3_HOST(instance)); return ret; } -static S32 ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, struct ps3_cmd *abort_cmd, - struct ps3_scsi_priv_data *priv_data) +static int ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, + struct ps3_cmd *abort_cmd, + struct ps3_scsi_priv_data *priv_data) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; cmd->cmd_word_value = abort_cmd->cmd_word_value; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_INIT) { @@ -1352,21 +1398,23 @@ static S32 ps3_scsi_task_abort_sync_proc(struct ps3_instance *instance, cmd->time_out = priv_data->task_abort_timeout; cmd->is_interrupt = PS3_DRV_FALSE; - INJECT_START(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, abort_cmd->scmd) + INJECT_START(PS3_ERR_IJ_ABORT_PRE_SEND_FORCE_ABORTED_CMD_DONE, + abort_cmd->scmd); ret = ps3_cmd_send_sync(instance, cmd); end: return ret; } -static inline void ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, - PS3ReqFrameHead_s *req_header, U8 cmdSubType, U32 disk_id, - struct ps3_scsi_priv_data *priv_data) +static inline void +ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, + struct PS3ReqFrameHead *req_header, + unsigned char cmdSubType, unsigned int disk_id, + struct ps3_scsi_priv_data *priv_data) { - if (cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET) { + if (cmdSubType == PS3_TASK_CMD_SCSI_TASK_RESET) req_header->timeout = priv_data->task_reset_timeout; - } else { + else req_header->timeout = priv_data->task_abort_timeout; - } req_header->traceID = ps3_cmd_trace_id(cmd); req_header->cmdType = PS3_CMD_SCSI_TASK_MANAGEMENT; req_header->cmdSubType = cmdSubType; @@ -1375,36 +1423,38 @@ static inline void ps3_mgr_scsi_req_head_init(struct ps3_cmd *cmd, req_header->devID.diskID = disk_id; } -struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data) +struct ps3_cmd * +ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data) { struct ps3_cmd *cmd = NULL; - PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; - U32 disk_id = priv_data->disk_pos.diskDev.diskID; + struct PS3MgrTaskReqFrame *mgr_task_req_frame = NULL; + unsigned int disk_id = priv_data->disk_pos.diskDev.diskID; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); if ((priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN) || - (disk_id == PS3_INVALID_DEV_ID)) { - LOG_ERROR("host_no:%u unknow dev type !\n", - PS3_HOST(instance)); + (disk_id == PS3_INVALID_DEV_ID)) { + LOG_ERROR("host_no:%u unknown dev type !\n", PS3_HOST(instance)); goto l_out; } cmd = ps3_task_cmd_alloc(instance); if (cmd == NULL) { LOG_ERROR("host_no:%u task cmd get NOK !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } mgr_task_req_frame = &cmd->req_frame->taskReq; - mgr_task_req_frame->taskID = 0; + mgr_task_req_frame->taskID = 0; memset(mgr_task_req_frame, 0, sizeof(*mgr_task_req_frame)); ps3_mgr_scsi_req_head_init(cmd, &mgr_task_req_frame->reqHead, - PS3_TASK_CMD_SCSI_TASK_RESET, disk_id, priv_data); + PS3_TASK_CMD_SCSI_TASK_RESET, disk_id, + priv_data); - LOG_WARN("host_no:%u ready send reset, CFID:%u t_id:0x%llx [%u:%u:%u]!\n", + LOG_WARN( + "host_no:%u ready send reset, CFID:%u t_id:0x%llx [%u:%u:%u]!\n", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id, PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), @@ -1413,9 +1463,12 @@ struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, ps3_mgr_cmd_word_build(cmd); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { - cmd->cmd_word.virtDiskID = (U8)priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + cmd->cmd_word.virtDiskID = + (unsigned char) + priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; } else { - cmd->cmd_word.phyDiskID = priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; + cmd->cmd_word.phyDiskID = + priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; } cmd->time_out = priv_data->task_reset_timeout; @@ -1425,79 +1478,32 @@ struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, return cmd; } -#ifndef _WINDOWS -#if 0 -static void ps3_abort_req_frame_dump(struct ps3_cmd *cmd) -{ - PS3_BUG_ON((cmd->req_frame == NULL) || (cmd->scmd == NULL)); - - switch (cmd->cmd_word.type) - { - case PS3_CMDWORD_TYPE_MGR: - if ((cmd->req_frame->word[0] == PS3_CMD_VD_SCSI_IO_NORW) || - (cmd->req_frame->word[0] == PS3_CMD_PD_SCSI_IO_NORW)) { - LOG_DEBUG("t_id:0x%llx host_no:%u aborted_cmd CFID:%u " - "type:%d fe isr_sn:%d cmd_type:%d opcode:0x%x!\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, - cmd->cmd_word.isrSN, - cmd->req_frame->frontendReq.reqHead.cmdType, - cmd->scmd->cmnd[0]); - } else { - LOG_ERROR("host_no:%u abort_cmd no scsi cmd! cmd_type:%d\n", - PS3_HOST(cmd->instance), - (int)cmd->req_frame->word[0]); - } - break; - case PS3_CMDWORD_TYPE_READ: - case PS3_CMDWORD_TYPE_WRITE: - if (cmd->cmd_word.isHardCmd) { - LOG_DEBUG("t_id:0x%llx host_no:%u abort_cmd CFID:%u type:%d " - "hwReq isr_sn:%d opcode:0x%x!\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, - cmd->cmd_word.isrSN, cmd->scmd->cmnd[0]); - } else { - LOG_DEBUG("t_id:0x%llx host_no:%u abort_cmd CFID:%u type:%d " - "fe isr_sn:%d opcode:0x%x cmd_type:%u !\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->cmd_word.cmdFrameID, cmd->cmd_word.type, - cmd->cmd_word.isrSN, cmd->scmd->cmnd[0], - cmd->req_frame->frontendReq.reqHead.cmdType); - } - break; - default: - LOG_ERROR("host_no:%u abort_cmd no scsi cmd! \n", - PS3_HOST(cmd->instance)); - break; - } - return; -} -#endif -S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd) +#ifndef _WINDOWS +int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, + unsigned short aborted_cmd_frame_id, + struct scsi_cmnd *scmd) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_cmd *aborted_cmd = NULL; - PS3MgrTaskReqFrame_s *mgr_task_req_frame = NULL; - U32 disk_id = priv_data->disk_pos.diskDev.diskID; + struct PS3MgrTaskReqFrame *mgr_task_req_frame = NULL; + unsigned int disk_id = priv_data->disk_pos.diskDev.diskID; LOG_DEBUG("host_no:%u enter !\n", PS3_HOST(instance)); if ((priv_data->dev_type == PS3_DEV_TYPE_UNKNOWN) || - (disk_id == PS3_INVALID_DEV_ID)) { - LOG_ERROR("host_no:%u unknow dev type !\n", - PS3_HOST(instance)); + (disk_id == PS3_INVALID_DEV_ID)) { + LOG_ERROR("host_no:%u unknown dev type !\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID_FORCE_ABORTED_CMD_DONE, scmd); aborted_cmd = ps3_cmd_find(instance, aborted_cmd_frame_id); if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { LOG_ERROR("host_no:%u there is no aborted cmd CFID:%u\n", - PS3_HOST(instance), aborted_cmd_frame_id); + PS3_HOST(instance), aborted_cmd_frame_id); ret = PS3_SUCCESS; goto l_out; @@ -1505,7 +1511,7 @@ S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u aborted cmd pre check NOK CFID:%d\n", - PS3_HOST(instance), aborted_cmd_frame_id); + PS3_HOST(instance), aborted_cmd_frame_id); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; @@ -1514,32 +1520,37 @@ S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_ERROR("host_no:%u task cmd get NOK !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_EBUSY; goto l_out; } - LOG_DEBUG("t_id:0x%llx aborted_t_id:0x%llx host_no:%u mgr abort CFID:%d\n", - cmd->trace_id, aborted_cmd->trace_id, PS3_HOST(instance), cmd->index); + LOG_DEBUG( + "t_id:0x%llx aborted_t_id:0x%llx host_no:%u mgr abort CFID:%d\n", + cmd->trace_id, aborted_cmd->trace_id, PS3_HOST(instance), + cmd->index); mgr_task_req_frame = &cmd->req_frame->taskReq; memset(mgr_task_req_frame, 0, sizeof(*mgr_task_req_frame)); ps3_mgr_scsi_req_head_init(cmd, &mgr_task_req_frame->reqHead, - PS3_TASK_CMD_SCSI_TASK_ABORT, disk_id, priv_data); + PS3_TASK_CMD_SCSI_TASK_ABORT, disk_id, + priv_data); mgr_task_req_frame->taskID = aborted_cmd_frame_id; mgr_task_req_frame->abortedCmdType = aborted_cmd->cmd_word.direct; - mgr_task_req_frame->reqHead.reqFrameFormat = PS3_REQFRAME_FORMAT_FRONTEND; + mgr_task_req_frame->reqHead.reqFrameFormat = + PS3_REQFRAME_FORMAT_FRONTEND; - LOG_WARN("host_no:%u ready send abort, CFID:%d t_id:0x%llx aborted cmd info:" - "CFID:%d t_id:0x%llx op:0x%x is_retry_cmd:%d timeout:%d dev[%u:%u:%u:%u], " - "cmdword[0x%08llx]{type:%d direct:%d que:%d isr_sn:%d}!\n ", + LOG_WARN( + "host_no:%u ready send abort, CFID:%d t_id:0x%llx aborted cmd info:\n" + "\tCFID:%d t_id:0x%llx op:0x%x is_retry_cmd:%d timeout:%d dev[%u:%u:%u:%u],\n" + "\tcmdword[0x%08llx]{type:%d direct:%d que:%d isr_sn:%d}!\n ", PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id, aborted_cmd_frame_id, aborted_cmd->trace_id, - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, - scmd->retries, - SCMD_GET_REQUEST(scmd)->timeout, PS3_CHANNEL(&priv_data->disk_pos), + scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, scmd->retries, + SCMD_GET_REQUEST(scmd)->timeout, + PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), PS3_VDID(&priv_data->disk_pos), priv_data->disk_pos.diskMagicNum, aborted_cmd->cmd_word_value, @@ -1547,37 +1558,40 @@ S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, aborted_cmd->cmd_word.qMask, aborted_cmd->cmd_word.isrSN); ps3_scsih_print_req(aborted_cmd, LEVEL_INFO); - INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_ABORT_PRE_BULID1_FORCE_ABORTED_CMD_DONE, scmd); INJECT_START(PS3_ERR_IJ_SET_ABORT_COUNT, scmd); - send_result = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, priv_data); + send_result = ps3_scsi_task_abort_sync_proc(instance, cmd, aborted_cmd, + priv_data); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); - LOG_WARN("host_no:%u abort finish, CFID:%d aborted CFID:%d aborted cmdword[0x%08llx], " - "[%u:%u:%u:%u]!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), aborted_cmd_frame_id, aborted_cmd->cmd_word_value, - PS3_CHANNEL(&priv_data->disk_pos), + LOG_WARN( + "host_no:%u abort finish, CFID:%d aborted CFID:%d aborted cmdword[0x%08llx],\n" + "\t[%u:%u:%u:%u]!\n", + PS3_HOST(instance), ps3_cmd_frame_id(cmd), aborted_cmd_frame_id, + aborted_cmd->cmd_word_value, PS3_CHANNEL(&priv_data->disk_pos), PS3_TARGET(&priv_data->disk_pos), PS3_VDID(&priv_data->disk_pos), priv_data->disk_pos.diskMagicNum); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_task_cmd_free(instance, cmd); - } LOG_WARN("host_no:%u exit !, ret:%d\n", PS3_HOST(instance), ret); return ret; } #endif -#ifndef _WINDOWS +#ifndef _WINDOWS static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, - enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) + enum PS3MgrCmdSubType sub_type, + dma_addr_t *sge_addr, + struct PS3SasMgr *sas_req) { - PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; + struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; + mgrReq->reqHead.timeout = PS3_DEFAULT_MGR_CMD_TIMEOUT; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -1586,8 +1600,8 @@ static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, mgrReq->reqHead.control = 0; mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = - offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> + PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(PS3_SAS_REQ_BUFF_LEN); mgrReq->sgl[0].addr = cpu_to_le64(*sge_addr); @@ -1595,25 +1609,25 @@ static inline void ps3_sas_info_reqframe_build(struct ps3_cmd *cmd, mgrReq->sgl[0].ext = 0; if (sas_req != NULL) { - mgrReq->value.sasMgr.sasAddr = - cpu_to_le64(sas_req->sasAddr); + mgrReq->value.sasMgr.sasAddr = cpu_to_le64(sas_req->sasAddr); mgrReq->value.sasMgr.enclID = sas_req->enclID; mgrReq->value.sasMgr.startPhyID = sas_req->startPhyID; mgrReq->value.sasMgr.phyCount = sas_req->phyCount; } } -static S32 __ps3_sas_info_get(struct ps3_instance *instance, - enum PS3MgrCmdSubType sub_type, dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) +static int __ps3_sas_info_get(struct ps3_instance *instance, + enum PS3MgrCmdSubType sub_type, + dma_addr_t *sge_addr, struct PS3SasMgr *sas_req) { - S32 ret = 0; - S32 send_result = PS3_SUCCESS; + int ret = 0; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u sas info cmd pre check NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; @@ -1622,7 +1636,7 @@ static S32 __ps3_sas_info_get(struct ps3_instance *instance, INJECT_START(PS3_ERR_IJ_EVENT_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { LOG_WARN("host_no:%u not get a cmd packet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -PS3_FAILED; goto l_out; @@ -1632,175 +1646,181 @@ static S32 __ps3_sas_info_get(struct ps3_instance *instance, ps3_mgr_cmd_word_build(cmd); LOG_INFO("host_no:%u ready send t_id:0x%llx CFID:%u req type:%s\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type)); + PS3_HOST(instance), cmd->trace_id, cmd->index, + namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type)); - send_result = ps3_mgr_cmd_sync_proc(instance, cmd, PS3_DEFAULT_MGR_CMD_TIMEOUT); + send_result = ps3_mgr_cmd_sync_proc(instance, cmd, + PS3_DEFAULT_MGR_CMD_TIMEOUT); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); if (send_result == PS3_SUCCESS) { send_result = ps3_cmd_wait_sync(instance, cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(sub_type), PS3_DRV_FALSE); + ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), + PS3_DRV_FALSE); } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret != PS3_SUCCESS) { - LOG_ERROR("host_no:%u %d respStatus NOK CFID:%d respStatus:%d\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, + LOG_ERROR( + "host_no:%u %d respStatus NOK CFID:%d respStatus:%d\n", + PS3_HOST(cmd->instance), ret, cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); } LOG_INFO("host_no:%u t_id:0x%llx CFID :%u type:%s end, ret:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type), ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, + namePS3MgrCmdSubType((enum PS3MgrCmdSubType)sub_type), ret); l_out: - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_mgr_cmd_free(instance, cmd); - } return ret; } -S32 ps3_sas_expander_all_get(struct ps3_instance *instance) +int ps3_sas_expander_all_get(struct ps3_instance *instance) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); - return __ps3_sas_info_get(instance, PS3_SAS_GET_EXPANDERS, - &instance->sas_dev_context.ps3_sas_buff_dma_addr, - NULL); + return __ps3_sas_info_get( + instance, PS3_SAS_GET_EXPANDERS, + &instance->sas_dev_context.ps3_sas_buff_dma_addr, NULL); } -S32 ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) +int ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); if (sas_req->phyCount == 0) { LOG_WARN("host_no:%u unexpect phyCount:%d !\n", - PS3_HOST(instance), sas_req->phyCount); + PS3_HOST(instance), sas_req->phyCount); return -PS3_FAILED; } - return __ps3_sas_info_get(instance, PS3_SAS_GET_PHY_INFO, - &instance->sas_dev_context.ps3_sas_phy_buff_dma_addr, - sas_req); + return __ps3_sas_info_get( + instance, PS3_SAS_GET_PHY_INFO, + &instance->sas_dev_context.ps3_sas_phy_buff_dma_addr, sas_req); } -S32 ps3_sas_expander_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req) +int ps3_sas_expander_get(struct ps3_instance *instance, + struct PS3SasMgr *sas_req) { LOG_DEBUG("host_no:%u\n", PS3_HOST(instance)); - return __ps3_sas_info_get(instance, PS3_SAS_GET_EXPANDER_INFO, - &instance->sas_dev_context.ps3_sas_buff_dma_addr, - sas_req); + return __ps3_sas_info_get( + instance, PS3_SAS_GET_EXPANDER_INFO, + &instance->sas_dev_context.ps3_sas_buff_dma_addr, sas_req); } #endif -static S32 ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 time_out) +static int ps3_mgr_cmd_sync_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd, unsigned short time_out) { - enum PS3MgrCmdSubType sub_type = (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); + enum PS3MgrCmdSubType sub_type = + (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd); cmd->time_out = time_out; cmd->is_interrupt = PS3_DRV_FALSE; ps3_mgr_cmd_word_build(cmd); - ps3_mgr_print_cmd(cmd, - namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); - + ps3_mgr_print_cmd(cmd, namePS3MgrCmdSubType(sub_type), PS3_DRV_TRUE); + INJECT_START(PS3_ERR_IJ_PD_LIST_WAIT_IRQ_DISABLE, cmd); return ps3_cmd_send_sync(instance, cmd); } -static S32 ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_no_resp_cmd_dead_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("host_no:%u CFID:%d finished\n", - PS3_HOST(instance), cmd->index); + LOG_WARN("host_no:%u CFID:%d finished\n", PS3_HOST(instance), + cmd->index); ret = -PS3_FAILED; goto l_out; } cmd->cmd_state.state = PS3_CMD_STATE_DEAD; ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); - LOG_WARN("host_no:%u cmd_dead_proc entry reset due to cmd not resp!\n", PS3_HOST(instance)); + LOG_WARN("host_no:%u cmd_dead_proc entry reset due to cmd not resp!\n", + PS3_HOST(instance)); - if (!instance->is_probe_finish || - !instance->state_machine.is_load) { + + INJECT_START(PS3_ERR_IJ_CMD_TIMEOUT_RECOVERY_CHECK, instance); + if (!instance->is_probe_finish || !instance->state_machine.is_load) { ps3_need_wait_hard_reset_request(instance); - ret = ps3_hard_recovery_request_with_retry(instance); + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); if (ret == PS3_SUCCESS) { ps3_instance_wait_for_dead_or_pre_operational(instance); } else { LOG_WARN("host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } else { ps3_need_wait_hard_reset_request(instance); - ps3_recovery_request_with_retry(instance); + ps3_recovery_request_with_retry(instance, PS3_FALSE); } LOG_ERROR("t_id:0x%llx CFID:%d host_no:%u state %u, recovery request\n", - cmd->trace_id, cmd->index, PS3_HOST(instance),cmd->cmd_state.state); + cmd->trace_id, cmd->index, PS3_HOST(instance), + cmd->cmd_state.state); ret = -PS3_CMD_NO_RESP; l_out: return ret; } -static S32 ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; - Bool is_probe_finish = PS3_FALSE; + unsigned long flags = 0; + int ret = PS3_SUCCESS; + unsigned char is_probe_finish = PS3_FALSE; + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("host_no:%u CFID:%d finished, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ret = -PS3_FAILED; goto l_out; } else { - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) { init_completion(&cmd->sync_done); } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } - LOG_WARN("host_no:%u cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", + LOG_WARN( + "host_no:%u cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", PS3_HOST(instance), cmd->index, cmd->trace_id); is_probe_finish = instance->is_probe_finish; ps3_need_wait_hard_reset_request(instance); - if (!is_probe_finish) { - ret = ps3_hard_recovery_request_with_retry(instance); - } else { - ret = ps3_recovery_request_with_retry(instance); - } + if (!is_probe_finish) + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); + else + ret = ps3_recovery_request_with_retry(instance, PS3_FALSE); if (ret == -PS3_FAILED) { ret = -PS3_CMD_NO_RESP; LOG_ERROR("host_no:%u recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_dead; } - INJECT_START(PS3_ERR_IJ_WAIT_HARD_RESET, instance) + INJECT_START(PS3_ERR_IJ_WAIT_HARD_RESET, instance); - if (!is_probe_finish) { + if (!is_probe_finish) ps3_instance_wait_for_dead_or_pre_operational(instance); - } LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) { ret = ps3_block_cmd_wait(instance, cmd, 0); } else { ret = ps3_cmd_reply_polling_when_recovery(instance, cmd, 0); @@ -1808,91 +1828,99 @@ static S32 ps3_no_resp_cmd_wait_proc(struct ps3_instance *instance, ret = ps3_err_mgr_cmd_proc(instance, ret, cmd); if (ret == -PS3_CMD_NO_RESP) { - LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + LOG_WARN("host_no:%u CFID:%d wait again, retries:%d\n", + PS3_HOST(instance), cmd->index, cmd->retry_cnt); } l_dead: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && - cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", - PS3_HOST(instance), cmd->index); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && + cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { + LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", + PS3_HOST(instance), cmd->index); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); l_out: - LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", - PS3_HOST(instance),ret); + LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", PS3_HOST(instance), + ret); return ret; } -static S32 ps3_no_resp_scsi_task_cmd_wait_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +static int ps3_no_resp_scsi_task_cmd_wait_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - ULong flags = 0; - S32 ret = PS3_SUCCESS; + unsigned long flags = 0; + int ret = PS3_SUCCESS; + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); if (cmd->cmd_state.state == PS3_CMD_STATE_INIT || - cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { + cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE) { ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); LOG_WARN("host_no:%u CFID:%d finished, retries:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ret = -PS3_FAILED; goto l_out; } else { - if (cmd->req_frame->frontendReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { + if (cmd->req_frame->frontendReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) { init_completion(&cmd->sync_done); } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } ps3_need_wait_hard_reset_request(instance); - LOG_WARN("host_no:%u scsi_task_cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", + LOG_WARN( + "host_no:%u scsi_task_cmd_wait_proc entry reset due to cmd not resp, CFID:%d t_id:0x%llx !\n", PS3_HOST(instance), cmd->index, cmd->trace_id); - ret = ps3_hard_recovery_request_with_retry(instance); + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); if (ret == -PS3_FAILED) { ret = -PS3_CMD_NO_RESP; LOG_ERROR("host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_dead; } - if (cmd->req_frame->frontendReq.reqHead.noReplyWord == PS3_CMD_WORD_NEED_REPLY_WORD) { - ret = ps3_block_cmd_wait(instance, cmd, PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); + if (cmd->req_frame->frontendReq.reqHead.noReplyWord == + PS3_CMD_WORD_NEED_REPLY_WORD) { + ret = ps3_block_cmd_wait( + instance, cmd, + PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); } else { - ret = ps3_cmd_reply_polling_when_recovery(instance, cmd, PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); + ret = ps3_cmd_reply_polling_when_recovery( + instance, cmd, + PS3_HARD_RESET_FORCE_STOP_MAX_TIME(instance)); } ret = ps3_err_mgr_cmd_proc(instance, ret, cmd); - if (ret == -PS3_CMD_NO_RESP) { - LOG_ERROR("host_no:%u hard recovery request,cmd timeout again\n", + if (ret == -PS3_CMD_NO_RESP) { + LOG_ERROR( + "host_no:%u hard recovery request,cmd timeout again\n", PS3_HOST(instance)); goto l_dead; - }else{ + } else { goto l_out; } l_dead: - ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && - cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { - LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", - PS3_HOST(instance), cmd->index); - cmd->cmd_state.state = PS3_CMD_STATE_DEAD; - } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); + ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT && + cmd->cmd_state.state != PS3_CMD_STATE_COMPLETE) { + LOG_FILE_ERROR("host_no:%u CFID:%d is dead\n", + PS3_HOST(instance), cmd->index); + cmd->cmd_state.state = PS3_CMD_STATE_DEAD; + } + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); l_out: - LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", - PS3_HOST(instance),ret); + LOG_INFO("host_no:%u noresp cmd deal ret:%d\n", PS3_HOST(instance), + ret); return ret; } -S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - switch (PS3_MGR_CMD_TYPE(cmd)) - { + int ret = PS3_SUCCESS; + + switch (PS3_MGR_CMD_TYPE(cmd)) { case PS3_CMD_MANAGEMENT: ret = ps3_no_resp_cmd_dead_proc(instance, cmd); break; @@ -1904,16 +1932,18 @@ S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, break; case PS3_CMD_SAS_MANAGEMENT: if ((PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_SMP_REQUEST) || - (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_GET_LINK_ERR) || - (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_PHY_CTRL) ) { + (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_GET_LINK_ERR) || + (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_SAS_PHY_CTRL)) { ret = ps3_no_resp_cmd_wait_proc(instance, cmd); } else { ret = ps3_no_resp_cmd_dead_proc(instance, cmd); } break; default: - LOG_ERROR("host_no:%u UNEXPEXT!!!! no response proc cmd_type:%d, sub_type:%d \n", - PS3_HOST(instance), PS3_MGR_CMD_TYPE(cmd), PS3_MGR_CMD_SUBTYPE(cmd)); + LOG_ERROR( + "host_no:%u UNEXPEXT!!!! no response proc cmd_type:%d, sub_type:%d\n", + PS3_HOST(instance), PS3_MGR_CMD_TYPE(cmd), + PS3_MGR_CMD_SUBTYPE(cmd)); ret = -PS3_FAILED; break; } @@ -1921,60 +1951,67 @@ S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, return ret; } -S32 ps3_mgr_complete_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, S32 send_result) +int ps3_mgr_complete_proc(struct ps3_instance *instance, struct ps3_cmd *cmd, + int send_result) { - S32 ret = PS3_SUCCESS; - ULong flags = 0; + int ret = PS3_SUCCESS; + unsigned long flags = 0; - while(cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + while (cmd->retry_cnt < PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { if (send_result == PS3_SUCCESS) { - LOG_FILE_INFO("host_no:%u externel mgr CFID:%d respStatus:%d success\n", - PS3_HOST(instance), - cmd->index, + LOG_FILE_INFO( + "host_no:%u externel mgr CFID:%d respStatus:%d success\n", + PS3_HOST(instance), cmd->index, ps3_cmd_resp_status(cmd)); ret = PS3_SUCCESS; break; } - if(send_result == -PS3_RECOVERED) { - LOG_INFO("host_no:%u mgr CFID:%d respStatus:%d cannot send because recovery process\n", - PS3_HOST(instance), - cmd->index, + if (send_result == -PS3_RECOVERED) { + LOG_INFO( + "host_no:%u mgr CFID:%d respStatus:%d cannot send because recovery process\n", + PS3_HOST(instance), cmd->index, ps3_cmd_resp_status(cmd)); ret = -PS3_RECOVERED; break; } ret = ps3_err_mgr_cmd_proc(instance, send_result, cmd); - if (ret == -PS3_CMD_NO_RESP) { + if (ret == -PS3_CMD_NO_RESP) ret = ps3_mgr_cmd_no_resp_proc(instance, cmd); - } if (ret != -PS3_RETRY) { if ((PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_MANAGEMENT) && - (PS3_MGR_CMD_SUBTYPE(cmd) == PS3_MGR_CMD_DEV_DEL_DONE)) { - LOG_FILE_INFO("host_no:%u CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt, ret); + (PS3_MGR_CMD_SUBTYPE(cmd) == + PS3_MGR_CMD_DEV_DEL_DONE)) { + LOG_FILE_INFO( + "host_no:%u CFID:%d retry, retries:%d, ret:%d\n", + PS3_HOST(instance), cmd->index, + cmd->retry_cnt, ret); } else { - LOG_INFO("host_no:%u cmd:%s CFID:%d retry, retries:%d, ret:%d\n", - PS3_HOST(instance), namePS3MgrCmdSubType( - (enum PS3MgrCmdSubType)PS3_MGR_CMD_SUBTYPE(cmd)), + LOG_INFO( + "host_no:%u cmd:%s CFID:%d retry, retries:%d, ret:%d\n", + PS3_HOST(instance), + namePS3MgrCmdSubType( + (enum PS3MgrCmdSubType) + PS3_MGR_CMD_SUBTYPE( + cmd)), cmd->index, cmd->retry_cnt, ret); } break; } cmd->retry_cnt++; - INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, cmd) - if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { + INJECT_START(PS3_ERR_IJ_IOCTL_CMD_RETRY_DONE, cmd); + if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) break; - } LOG_INFO("host_no:%u mgr CFID:%d retry:%u\n", - PS3_HOST(instance), cmd->index, cmd->retry_cnt); + PS3_HOST(instance), cmd->index, cmd->retry_cnt); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - if ((send_result = ps3_mgr_cmd_send_check(instance, cmd)) != PS3_SUCCESS) { - ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); + send_result = ps3_mgr_cmd_send_check(instance, cmd); + if (send_result != PS3_SUCCESS) { + ps3_atomic_dec( + &instance->cmd_statistics.cmd_delivering); continue; } cmd->resp_frame->normalRespFrame.respStatus = 0xff; @@ -1985,43 +2022,39 @@ S32 ps3_mgr_complete_proc(struct ps3_instance *instance, ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } }; if (cmd->retry_cnt >= PS3_ERR_MGR_CMD_FAULT_RETRY_MAX) { ret = -PS3_FAILED; - LOG_ERROR("host_no:%u cmd request NOK.\n", - PS3_HOST(instance)); + LOG_ERROR("host_no:%u cmd request NOK.\n", PS3_HOST(instance)); } return ret; } -Bool ps3_check_ioc_state_is_normal_in_unload( - struct ps3_instance *instance) +unsigned char +ps3_check_ioc_state_is_normal_in_unload(struct ps3_instance *instance) { - Bool ret = PS3_TRUE; - U32 ioc_state = PS3_FW_STATE_UNDEFINED; + unsigned char ret = PS3_TRUE; + unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; - if (instance->state_machine.is_load) { + if (instance->state_machine.is_load) goto l_out; - } if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { ret = PS3_FALSE; goto l_out; } - INJECT_START(PS3_ERR_IJ_IOC_IS_NOT_NORMAL_IN_UNLOAD, &ioc_state) - if ((ioc_state != PS3_FW_STATE_RUNNING)) { + INJECT_START(PS3_ERR_IJ_IOC_IS_NOT_NORMAL_IN_UNLOAD, &ioc_state); + if (ioc_state != PS3_FW_STATE_RUNNING) { LOG_ERROR("host_no:%d ioc_state:%d is not running.\n", - PS3_HOST(instance), ioc_state); + PS3_HOST(instance), ioc_state); ret = PS3_FALSE; goto l_out; } l_out: return ret; - } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h index aa4e1371818a..778dd7bc178d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd.h @@ -1,85 +1,95 @@ - -#ifndef _PS3_MANAGMENT_CMD_H_ -#define _PS3_MANAGMENT_CMD_H_ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _PS3_MANAGEMENT_CMD_H_ +#define _PS3_MANAGEMENT_CMD_H_ #include "ps3_instance_manager.h" #include "ps3_device_manager.h" -#define PS3_MGR_BASE_DATA_SIZE (64) +#define PS3_MGR_BASE_DATA_SIZE (64) #define PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT (2) #define PS3_MGR_CMD_TYPE(cmd) ((cmd)->req_frame->mgrReq.reqHead.cmdType) #define PS3_MGR_CMD_SUBTYPE(cmd) ((cmd)->req_frame->mgrReq.reqHead.cmdSubType) -enum{ +enum { PS3_CANCEL_EVENT_CMD = 1, PS3_CANCEL_VDPENDING_CMD, - PS3_CANCEL_WEB_CMD, + PS3_CANCEL_WEB_CMD, }; -S32 ps3_ctrl_info_buf_alloc(struct ps3_instance *instance); +int ps3_ctrl_info_buf_alloc(struct ps3_instance *instance); void ps3_ctrl_info_buf_free(struct ps3_instance *instance); -S32 ps3_mgr_cmd_init(struct ps3_instance *instance); +int ps3_mgr_cmd_init(struct ps3_instance *instance); void ps3_mgr_cmd_exit(struct ps3_instance *instance); -S32 ps3_pd_list_get(struct ps3_instance *instance); +int ps3_pd_list_get(struct ps3_instance *instance); + +int ps3_vd_list_get(struct ps3_instance *instance); -S32 ps3_vd_list_get(struct ps3_instance *instance); +int ps3_pd_info_get(struct ps3_instance *instance, unsigned short channel, + unsigned short target_id, unsigned short pd_disk_id); -S32 ps3_pd_info_get(struct ps3_instance *instance, U16 channel, U16 target_id, U16 pd_disk_id); +int ps3_vd_info_sync_get(struct ps3_instance *instance, unsigned int disk_id, + unsigned short vd_num); -S32 ps3_vd_info_sync_get(struct ps3_instance *instance, U32 disk_id, - U16 vd_num); +int ps3_vd_info_async_get(struct ps3_instance *instance); -S32 ps3_vd_info_async_get(struct ps3_instance *instance); +int ps3_ctrl_info_get(struct ps3_instance *instance); -S32 ps3_ctrl_info_get(struct ps3_instance *instance); +int ps3_soc_unload(struct ps3_instance *instance, unsigned char is_polling, + unsigned char type, unsigned char suspend_type); -S32 ps3_soc_unload(struct ps3_instance *instance, Bool is_polling, U8 type, U8 suspend_type); +int ps3_scsi_remove_device_done(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type); -S32 ps3_scsi_remove_device_done(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type); +int ps3_scsi_add_device_ack(struct ps3_instance *instance, + struct PS3DiskDevPos *disk_pos, + unsigned char dev_type); -S32 ps3_scsi_add_device_ack(struct ps3_instance *instance, - struct PS3DiskDevPos *disk_pos, U8 dev_type); +int ps3_mgr_cmd_cancel(struct ps3_instance *instance, + unsigned short cancel_cmd_frame_id); -S32 ps3_mgr_cmd_cancel(struct ps3_instance *instance, U16 cancel_cmd_frame_id); +int ps3_event_register(struct ps3_instance *instance, + struct PS3MgrEvent *event); -S32 ps3_event_register(struct ps3_instance *instance, - struct PS3MgrEvent *event); -S32 ps3_web_register(struct ps3_instance *instance); +int ps3_web_register(struct ps3_instance *instance); -S32 ps3_scsi_task_mgr_abort(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, U16 aborted_cmd_frame_id, struct scsi_cmnd *scmd); +int ps3_scsi_task_mgr_abort(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, + unsigned short aborted_cmd_frame_id, + struct scsi_cmnd *scmd); void ps3_mgr_cmd_word_build(struct ps3_cmd *cmd); -S32 ps3_sas_expander_all_get(struct ps3_instance *instance); +int ps3_sas_expander_all_get(struct ps3_instance *instance); -S32 ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); +int ps3_sas_phy_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); -S32 ps3_sas_expander_get(struct ps3_instance *instance, struct PS3SasMgr *sas_req); +int ps3_sas_expander_get(struct ps3_instance *instance, + struct PS3SasMgr *sas_req); -S32 ps3_mgr_complete_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd, S32 send_result); +int ps3_mgr_complete_proc(struct ps3_instance *instance, struct ps3_cmd *cmd, + int send_result); struct ps3_cmd *ps3_dump_notify_cmd_build(struct ps3_instance *instance); -struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data); -struct ps3_cmd * ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data); +struct ps3_cmd * +ps3_scsi_task_mgr_reset_build(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data); + +int ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd); -S32 ps3_mgr_cmd_no_resp_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd); +unsigned char +ps3_check_ioc_state_is_normal_in_unload(struct ps3_instance *instance); -Bool ps3_check_ioc_state_is_normal_in_unload( - struct ps3_instance *instance); +int ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, + unsigned short cancel_cmd_frame_id, + unsigned char type); -S32 ps3_mgr_cmd_cancel_send(struct ps3_instance *instance, - U16 cancel_cmd_frame_id, U8 type); -S32 ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, U8 type); +int ps3_mgr_cmd_cancel_wait(struct ps3_instance *instance, unsigned char type); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c index 61feecb0059b..55b3e2292dcd 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_mgr_cmd_err.h" #ifndef _WINDOWS @@ -18,56 +19,55 @@ #include "ps3_recovery.h" enum ps3_fault_action { - PS3_FAULT_STRATEGY_NONE = 0, - PS3_FAULT_STRATEGY_RETRY, + PS3_FAULT_STRATEGY_NONE = 0, + PS3_FAULT_STRATEGY_RETRY, }; enum ps3_reset_type { - PS3_RESET_TYPE_SOFT, - PS3_RESET_TYPE_HARD, + PS3_RESET_TYPE_SOFT, + PS3_RESET_TYPE_HARD, }; struct ps3_fault_strategy { - U32 resp_status; - enum ps3_fault_action fault_action; + unsigned int resp_status; + enum ps3_fault_action fault_action; }; static struct ps3_fault_strategy ps3_fault_strategy_desc[] = { - {PS3_DRV_MGR_UNRUNING ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_INVAL_CMD ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_NORESOURCE ,PS3_FAULT_STRATEGY_RETRY}, - {PS3_DRV_MGR_INVAL_PARAM ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_DEV_NOEXIST ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_DEV_DATA_ERR ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_EVT_REPEAT ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_EVT_CANCLE_ERR ,PS3_FAULT_STRATEGY_NONE }, - {PS3_DRV_MGR_FLUSH_FAIELD ,PS3_FAULT_STRATEGY_RETRY}, - {PS3_DRV_MGR_BUSY ,PS3_FAULT_STRATEGY_RETRY}, - {PS3_DRV_MGR_TIMEOUT ,PS3_FAULT_STRATEGY_RETRY}, - {PS3_DRV_MGR_SMP_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, - {PS3_DRV_MGR_LINK_GET_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, - {PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE}, - {PS3_DRV_MGR_RESTART_COMMAND_RSP, PS3_FAULT_STRATEGY_NONE}, - {PS3_DRV_MGR_TM_FAILED, PS3_FAULT_STRATEGY_NONE}, - {U32_MAX ,PS3_FAULT_STRATEGY_NONE} + { PS3_DRV_MGR_UNRUNING, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_INVAL_CMD, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_NORESOURCE, PS3_FAULT_STRATEGY_RETRY }, + { PS3_DRV_MGR_INVAL_PARAM, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_DEV_NOEXIST, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_DEV_DATA_ERR, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_EVT_REPEAT, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_EVT_CANCEL_ERR, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_FLUSH_FAILED, PS3_FAULT_STRATEGY_RETRY }, + { PS3_DRV_MGR_BUSY, PS3_FAULT_STRATEGY_RETRY }, + { PS3_DRV_MGR_TIMEOUT, PS3_FAULT_STRATEGY_RETRY }, + { PS3_DRV_MGR_SMP_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_LINK_GET_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_PHY_CTL_BACKEND_ERR, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_RESTART_COMMAND_RSP, PS3_FAULT_STRATEGY_NONE }, + { PS3_DRV_MGR_TM_FAILED, PS3_FAULT_STRATEGY_NONE }, + { U32_MAX, PS3_FAULT_STRATEGY_NONE } }; -static inline const S8 *ps3_err_action_print(enum ps3_fault_action action) +static inline const char *ps3_err_action_print(enum ps3_fault_action action) { - static const S8 *action_string[] = { - [PS3_FAULT_STRATEGY_NONE] = "PS3_FAULT_STRATEGY_NONE", - [PS3_FAULT_STRATEGY_RETRY] = "PS3_FAULT_STRATEGY_RETRY" + static const char * const action_string[] = { + [PS3_FAULT_STRATEGY_NONE] = "PS3_FAULT_STRATEGY_NONE", + [PS3_FAULT_STRATEGY_RETRY] = "PS3_FAULT_STRATEGY_RETRY" }; return action_string[action]; } -const S8 *ps3_err_mgr_fault_proc_result_print(S32 result) +const char *ps3_err_mgr_fault_proc_result_print(int result) { - const S8 *proc_result_string = NULL; + const char *proc_result_string = NULL; - switch (result) - { + switch (result) { case PS3_SUCCESS: proc_result_string = "SUCCESS"; break; @@ -97,34 +97,34 @@ const S8 *ps3_err_mgr_fault_proc_result_print(S32 result) return proc_result_string; } -static enum ps3_fault_action ps3_err_fault_strategy_lookup( - struct ps3_instance *instance, U32 resp_status, U32 retry_cnt) +static enum ps3_fault_action +ps3_err_fault_strategy_lookup(struct ps3_instance *instance, + unsigned int resp_status, unsigned int retry_cnt) { - U32 idx = 0; + unsigned int idx = 0; enum ps3_fault_action fault_action = PS3_FAULT_STRATEGY_RETRY; - for (idx = 0;idx < ARRAY_SIZE(ps3_fault_strategy_desc);idx++) { + for (idx = 0; idx < ARRAY_SIZE(ps3_fault_strategy_desc); idx++) { if (ps3_fault_strategy_desc[idx].resp_status == resp_status) { - fault_action - = ps3_fault_strategy_desc[idx].fault_action; + fault_action = + ps3_fault_strategy_desc[idx].fault_action; break; } } - if ((fault_action == PS3_FAULT_STRATEGY_RETRY) - && (retry_cnt > 0)) { + if ((fault_action == PS3_FAULT_STRATEGY_RETRY) && (retry_cnt > 0)) fault_action = PS3_FAULT_STRATEGY_NONE; - } - LOG_INFO("host_no:%u error_no:%d fault_action is %s!\n", PS3_HOST(instance), - resp_status,ps3_err_action_print(fault_action)); + LOG_INFO("host_no:%u error_no:%d fault_action is %s!\n", + PS3_HOST(instance), resp_status, + ps3_err_action_print(fault_action)); return fault_action; } -static S32 ps3_err_fault_strategy_exec(struct ps3_instance *instance, - enum ps3_fault_action fault_action) +static int ps3_err_fault_strategy_exec(struct ps3_instance *instance, + enum ps3_fault_action fault_action) { - S32 proc_result = -PS3_FAILED; + int proc_result = -PS3_FAILED; switch (fault_action) { case PS3_FAULT_STRATEGY_RETRY: @@ -136,23 +136,25 @@ static S32 ps3_err_fault_strategy_exec(struct ps3_instance *instance, } LOG_INFO("host_no:%u proc result for mgr cmd fault is %s!\n", - PS3_HOST(instance), ps3_err_mgr_fault_proc_result_print(proc_result)); + PS3_HOST(instance), + ps3_err_mgr_fault_proc_result_print(proc_result)); return proc_result; } -S32 ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, - struct ps3_cmd *cmd) +int ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; enum ps3_fault_action fault_action = PS3_FAULT_STRATEGY_NONE; - U32 resp_status = cmd->resp_frame->normalRespFrame.respStatus; + unsigned int resp_status = cmd->resp_frame->normalRespFrame.respStatus; if (!ps3_is_instance_state_allow_cmd_execute(instance)) { ret = -PS3_FAILED; goto l_out; } - fault_action = ps3_err_fault_strategy_lookup(instance, resp_status, cmd->retry_cnt); + fault_action = ps3_err_fault_strategy_lookup(instance, resp_status, + cmd->retry_cnt); ret = ps3_err_fault_strategy_exec(instance, fault_action); l_out: return ret; @@ -164,7 +166,6 @@ void ps3_err_fault_context_init(struct ps3_instance *instance) memset(fault_context, 0, sizeof(*fault_context)); ps3_atomic_set(&instance->is_err_scsi_processing, 0); - } void ps3_err_fault_context_exit(struct ps3_instance *instance) @@ -174,54 +175,69 @@ void ps3_err_fault_context_exit(struct ps3_instance *instance) memset(fault_context, 0, sizeof(*fault_context)); } -S32 ps3_err_mgr_cmd_proc(struct ps3_instance *instance, - S32 fault_type, struct ps3_cmd *cmd) +int ps3_err_mgr_cmd_proc(struct ps3_instance *instance, int fault_type, + struct ps3_cmd *cmd) { - S32 proc_result = PS3_SUCCESS; - S32 ret = PS3_SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - LOG_INFO("host_no:%u fault_type: %s, retries:%d!\n", - PS3_HOST(instance), - ps3_err_mgr_fault_proc_result_print(fault_type), cmd->retry_cnt); + int proc_result = PS3_SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; + + LOG_INFO("host_no:%u fault_type: %s, retries:%d!\n", PS3_HOST(instance), + ps3_err_mgr_fault_proc_result_print(fault_type), + cmd->retry_cnt); switch (fault_type) { case PS3_SUCCESS: break; case -PS3_RESP_ERR: if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { - LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx cli return err:%u\n", - PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id, ps3_cmd_resp_status(cmd)); + LOG_INFO( + "host_no:%u CFID:%d trace_id:0x%llx cli return err:%u\n", + PS3_HOST(instance), cmd->cmd_word.cmdFrameID, + cmd->trace_id, ps3_cmd_resp_status(cmd)); if (instance->is_probe_finish) { - if (ps3_cmd_resp_status(cmd) == PS3_DRV_MGR_BUSY) { - LOG_INFO("host_no:%u CFID:%d trace_id:0x%llx cli return busy\n", + if (ps3_cmd_resp_status(cmd) == + PS3_DRV_MGR_BUSY) { + LOG_INFO( + "host_no:%u CFID:%d trace_id:0x%llx cli return busy\n", PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id); - if (ps3_instance_wait_for_normal(instance) == PS3_SUCCESS){ - cmd->req_frame->mgrReq.value.isRetry = PS3_TRUE; + cmd->cmd_word.cmdFrameID, + cmd->trace_id); + if (ps3_instance_wait_for_normal( + instance) == PS3_SUCCESS) { + cmd->req_frame->mgrReq.value + .isRetry = PS3_TRUE; proc_result = -PS3_RETRY; } else { proc_result = -PS3_FAILED; } - } else if(ps3_cmd_resp_status(cmd) == PS3_DRV_MGR_RESTART_COMMAND_RSP){ - LOG_WARN("host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", + } else if (ps3_cmd_resp_status(cmd) == + PS3_DRV_MGR_RESTART_COMMAND_RSP) { + LOG_WARN( + "host_no:%u CFID:%d trace_id:0x%llx cli cx restart return success\n", PS3_HOST(instance), - cmd->cmd_word.cmdFrameID, cmd->trace_id); - ps3_need_wait_hard_reset_request(instance); - INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, instance) - if (ps3_recovery_state_wait_for_normal(instance) == PS3_SUCCESS){ - ret = ps3_hard_recovery_request_with_retry(instance); - if (ret != PS3_SUCCESS){ - LOG_WARN("host_no:%u hard recovery request NOK\n", - PS3_HOST(instance)); - } - } else { + cmd->cmd_word.cmdFrameID, + cmd->trace_id); + ps3_need_wait_hard_reset_request( + instance); + INJECT_START( + PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_2, + instance); + if (ps3_recovery_state_wait_for_normal( + instance) != PS3_SUCCESS) { proc_result = -PS3_FAILED; + } else if (ps3_hard_recovery_request_with_retry(instance, PS3_FALSE) + != PS3_SUCCESS) { + LOG_WARN( + "host_no:%u hard recovery request NOK\n", + PS3_HOST(instance)); } } else { - cur_state = ps3_atomic_read(&instance->state_machine.state); - if (cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_DEAD) { + cur_state = ps3_atomic_read( + &instance->state_machine.state); + if (cur_state == + PS3_INSTANCE_STATE_QUIT || + cur_state == + PS3_INSTANCE_STATE_DEAD) { proc_result = -PS3_ENODEV; } else { proc_result = -PS3_FAILED; @@ -243,13 +259,13 @@ S32 ps3_err_mgr_cmd_proc(struct ps3_instance *instance, break; } - if (proc_result != -PS3_CMD_NO_RESP) { + if (proc_result != -PS3_CMD_NO_RESP) cmd->cmd_state.reset_flag = 0; - } LOG_INFO("host_no:%u proc_result: %s, retries:%d!\n", - PS3_HOST(instance), - ps3_err_mgr_fault_proc_result_print(proc_result), cmd->retry_cnt); + PS3_HOST(instance), + ps3_err_mgr_fault_proc_result_print(proc_result), + cmd->retry_cnt); return proc_result; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h index 4805dbbe4a55..6fca182f7fca 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_mgr_cmd_err.h @@ -1,27 +1,28 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_MGR_CMD_ERR_H_ #define _PS3_MGR_CMD_ERR_H_ #ifndef _WINDOWS #include #include +#include "linux/kernel.h" #endif #include "ps3_htp_def.h" #include "ps3_instance_manager.h" -#define PS3_ERR_MGR_CMD_FAULT_RETRY_MAX (3) -#define PS3_ERR_MGR_CMD_DELAY_TIME_BEFORE_RERTY (500) +#define PS3_ERR_MGR_CMD_FAULT_RETRY_MAX (3) +#define PS3_ERR_MGR_CMD_DELAY_TIME_BEFORE_RERTY (500) void ps3_err_fault_context_init(struct ps3_instance *instance); void ps3_err_fault_context_exit(struct ps3_instance *instance); -S32 ps3_err_mgr_cmd_proc(struct ps3_instance *instance, - S32 fault_type, struct ps3_cmd *cmd); +int ps3_err_mgr_cmd_proc(struct ps3_instance *instance, int fault_type, + struct ps3_cmd *cmd); -S32 ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, - struct ps3_cmd *cmd); +int ps3_err_mgr_cmd_failed_check(struct ps3_instance *instance, + struct ps3_cmd *cmd); -const S8 *ps3_err_mgr_fault_proc_result_print(S32 result); +const char *ps3_err_mgr_fault_proc_result_print(int result); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_module_para.c b/drivers/scsi/linkdata/ps3stor/ps3_module_para.c index 2a89115a3b23..a7752ef65291 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_module_para.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_module_para.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include "linux/moduleparam.h" #endif @@ -7,638 +7,682 @@ #include "ps3_driver_log.h" #include "ps3_drv_ver.h" #include "ps3_ioc_state.h" +#include "ps3_kernel_version.h" #ifndef _WINDOWS -static U32 cli_ver = PS3_IOCTL_VERSION; -module_param(cli_ver, uint, S_IRUGO | S_IRUSR); +static unsigned int cli_ver = PS3_IOCTL_VERSION; +module_param(cli_ver, uint, 0444); MODULE_PARM_DESC(cli_ver, - "The version for communication between driver and CLI"); + "The version for communication between driver and CLI"); #endif -static U32 g_throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; +static unsigned int g_throttle_que_depth = PS3_DEVICE_QDEPTH_DEFAULT_VALUE; #ifndef _WINDOWS -module_param(g_throttle_que_depth, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_throttle_que_depth, +module_param(g_throttle_que_depth, uint, 0644); +MODULE_PARM_DESC( + g_throttle_que_depth, "IOC queue depth when throttled due to SCSI cmd timeout. Default: 16"); #endif -static U32 g_debug_mem_size = 0; +static unsigned int g_debug_mem_size; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_debug_mem_size, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_debug_mem_size, +module_param(g_debug_mem_size, uint, 0644); +MODULE_PARM_DESC( + g_debug_mem_size, "Allocate DMA memory for IOC debugging little than 65535KB. Default: 0KB"); #endif #endif -static U32 g_use_clustering = 1; +static unsigned int g_use_clustering = 1; #ifndef _WINDOWS -module_param(g_use_clustering, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_use_clustering, +module_param(g_use_clustering, uint, 0644); +MODULE_PARM_DESC( + g_use_clustering, "SCSI mid-layer bio merge feature enable/disable. Default: enable(1)"); #endif -static U32 g_scsi_cmd_timeout = 0; +static unsigned int g_scsi_cmd_timeout; #ifndef _WINDOWS -module_param(g_scsi_cmd_timeout, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_scsi_cmd_timeout, +module_param(g_scsi_cmd_timeout, uint, 0644); +MODULE_PARM_DESC( + g_scsi_cmd_timeout, "SCSI cmd timeout (10-255s). Default: 0(No specify default 90s)"); #endif -extern U32 g_ps3_r1x_lock_flag; -extern U32 g_ps3_r1x_lock_enable; +extern unsigned int g_ps3_r1x_lock_flag; +extern unsigned int g_ps3_r1x_lock_enable; #ifndef _WINDOWS -#if 0 -module_param(g_ps3_r1x_lock_flag, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_ps3_r1x_lock_flag, - "R1X write conflict check func. 0 - hash+bitmap, 1 - " - "hash+rangetree. Default: 0"); -#endif -module_param(g_ps3_r1x_lock_enable, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_ps3_r1x_lock_enable, - "R1x write conflict check feature enable/disable. Default: enable(1)"); +module_param(g_ps3_r1x_lock_enable, uint, 0444); +MODULE_PARM_DESC( + g_ps3_r1x_lock_enable, + "R1x write conflict check feature enable/disable. Default: disable(0)"); #endif -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -extern U32 g_ps3_qos_hdd_pd_quota; -extern U32 g_ps3_qos_nvme_pd_quota; +extern unsigned int g_ps3_qos_hdd_pd_quota; +extern unsigned int g_ps3_qos_nvme_pd_quota; #ifndef _WINDOWS -module_param(g_ps3_qos_hdd_pd_quota, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_ps3_qos_hdd_pd_quota, - "Qos pd quota. Default: 40"); -module_param(g_ps3_qos_nvme_pd_quota, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_ps3_qos_nvme_pd_quota, - "Qos nvme pd quota. Default: 127"); +module_param(g_ps3_qos_hdd_pd_quota, uint, 0644); +MODULE_PARM_DESC(g_ps3_qos_hdd_pd_quota, "Qos pd quota. Default: 40"); +module_param(g_ps3_qos_nvme_pd_quota, uint, 0644); +MODULE_PARM_DESC(g_ps3_qos_nvme_pd_quota, "Qos nvme pd quota. Default: 127"); #endif -extern U32 g_ps3_r1x_rb_diff_cmds; +extern unsigned int g_ps3_r1x_rb_diff_cmds; #ifndef _WINDOWS -module_param(g_ps3_r1x_rb_diff_cmds, uint, S_IRUGO | S_IWUSR); +module_param(g_ps3_r1x_rb_diff_cmds, uint, 0644); MODULE_PARM_DESC(g_ps3_r1x_rb_diff_cmds, - "R1x read balancing outstanding threshold. Default: 4"); + "R1x read balancing outstanding threshold. Default: 4"); #endif #endif -static U32 g_direct_to_normal_enable = 1; +static unsigned int g_direct_to_normal_enable = 1; #ifndef _WINDOWS -module_param(g_direct_to_normal_enable, uint, S_IRUGO | S_IWUSR); +module_param(g_direct_to_normal_enable, uint, 0644); MODULE_PARM_DESC(g_direct_to_normal_enable, - "Direct to normal feature enable/disable. Default: enable(1)"); + "Direct to normal feature enable/disable. Default: enable(1)"); #endif -static U32 g_hba_check_time = 10; +static unsigned int g_hba_check_time = 10; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hba_check_time, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_hba_check_time, "HBA device id check time out. Default: 10s"); +module_param(g_hba_check_time, uint, 0644); +MODULE_PARM_DESC(g_hba_check_time, + "HBA device id check time out. Default: 10s"); #endif #endif -static U32 g_task_reset_delay_time = 50; +static unsigned int g_task_reset_delay_time = 50; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_task_reset_delay_time, uint, S_IRUGO | S_IWUSR); +module_param(g_task_reset_delay_time, uint, 0644); MODULE_PARM_DESC(g_task_reset_delay_time, - "Task reset delay time (0-1000ms). Default: 50ms"); + "Task reset delay time (0-1000ms). Default: 50ms"); #endif #endif -static U32 g_r1x_ring_size = 16; +static unsigned int g_r1x_ring_size = 16; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_ring_size, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_r1x_ring_size, +module_param(g_r1x_ring_size, uint, 0644); +MODULE_PARM_DESC( + g_r1x_ring_size, "If R1X direct read more than g_r1x_ring_size, read from spare. Default: 16MB"); #endif #endif -static U32 g_direct_check_stream_enable = PS3_TRUE; +static unsigned int g_direct_check_stream_enable = PS3_TRUE; #ifndef _WINDOWS -module_param(g_direct_check_stream_enable, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_direct_check_stream_enable, +module_param(g_direct_check_stream_enable, uint, 0644); +MODULE_PARM_DESC( + g_direct_check_stream_enable, "Direct detect stream or not feature enable/disable. Default: enable(1)"); #endif -static S32 g_device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; +static int g_device_busy_threshold = PS3_DEVICE_IO_BUSY_THRESHOLD; #ifndef _WINDOWS -module_param(g_device_busy_threshold, int, S_IRUGO | S_IWUSR); +module_param(g_device_busy_threshold, int, 0644); MODULE_PARM_DESC(g_device_busy_threshold, - "Device busy threshold value. Default: 8"); + "Device busy threshold value. Default: 8"); #endif #ifndef __cplusplus -static char g_log_path[80] = {0}; +static char g_log_path[80] = { 0 }; #ifndef _WINDOWS -module_param_string(g_log_path, g_log_path, 80, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_log_path, "The log path of host driver will be saved little than 80 chars. Default: /var/log"); +module_param_string(g_log_path, g_log_path, 80, 0644); +MODULE_PARM_DESC( + g_log_path, + "The log path of host driver will be saved little than 80 chars. Default: /var/log"); +#endif #endif -#endif -static U32 g_log_file_size = 200; +static unsigned int g_log_file_size = 200; #ifdef PS3_CFG_RELEASE -static U32 g_log_level = LEVEL_INFO; +static unsigned int g_log_level = LEVEL_INFO; #else -static U32 g_log_level = LEVEL_DEBUG; +static unsigned int g_log_level = LEVEL_DEBUG; #endif -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) #ifndef _WINDOWS -module_param(g_log_file_size, uint, S_IRUGO | S_IWUSR); +module_param(g_log_file_size, uint, 0644); MODULE_PARM_DESC(g_log_file_size, - "Single driver log file size (10-200MB). Default: 200MB"); + "Single driver log file size (10-200MB). Default: 200MB"); -module_param(g_log_level, uint, S_IRUGO | S_IWUSR); +module_param(g_log_level, uint, 0644); MODULE_PARM_DESC(g_log_level, - "Specify driver log level." + "Specify driver log level." #ifdef PS3_CFG_RELEASE - "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 2"); + "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 2"); #else - "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 3"); + "0 - error, 1 - warn, 2 - info, 3 - debug. Default: 3"); #endif #endif #endif -static U32 g_r1x_time_out = 3000; +static unsigned int g_r1x_time_out = 3000; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_time_out, uint, S_IRUGO | S_IWUSR); +module_param(g_r1x_time_out, uint, 0644); MODULE_PARM_DESC(g_r1x_time_out, - "R1X conflict in queue after time. Default: 3000ms"); + "R1X conflict in queue after time. Default: 3000ms"); #endif #endif -static U32 g_r1x_conflict_queue_enable = PS3_TRUE; +static unsigned int g_r1x_conflict_queue_enable = PS3_TRUE; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_r1x_conflict_queue_enable, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_r1x_conflict_queue_enable, +module_param(g_r1x_conflict_queue_enable, uint, 0644); +MODULE_PARM_DESC( + g_r1x_conflict_queue_enable, "R1X conflict queue function feature enable/disable. Default: enable(1)"); #endif #endif +static unsigned int g_latency_perf_mode_enable = 0; +module_param(g_latency_perf_mode_enable, uint, 0444); +MODULE_PARM_DESC(g_latency_perf_mode_enable, + "Latency perf mode enable/disable. Default: disable(0)"); + #ifndef _WINDOWS #ifdef PS3_SUPPORT_INJECT -#define PS3_MAX_ERR_INJECT (16) -static U32 g_err_inject[PS3_MAX_ERR_INJECT]; -static U32 num_inject; -static U32 g_enable_inject = 0; +#define PS3_MAX_ERR_INJECT (16) +static unsigned int g_err_inject[PS3_MAX_ERR_INJECT]; +static unsigned int num_inject; +static unsigned int g_enable_inject; module_param_array(g_err_inject, uint, &num_inject, 0); -MODULE_PARM_DESC(g_err_inject, - "Err inject array. Default: 0"); -module_param(g_enable_inject, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(g_err_inject, "Err inject array. Default: 0"); +module_param(g_enable_inject, uint, 0644); MODULE_PARM_DESC(g_enable_inject, - "Err inject feature enable/disable. Default: disable(0)"); + "Err inject feature enable/disable. Default: disable(0)"); -U32 ps3_err_inject_num_query(void) +unsigned int ps3_err_inject_num_query(void) { return num_inject; } -U32* ps3_err_inject_array_query(void) +unsigned int *ps3_err_inject_array_query(void) { return &g_err_inject[0]; } -U32 ps3_err_inject_state_query(void) +unsigned int ps3_err_inject_state_query(void) { return g_enable_inject; } #endif #endif -static U32 g_log_space_size = 0; +static unsigned int g_log_space_size; -static U32 g_log_tty = 0; +static unsigned int g_log_tty; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_log_tty, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_log_tty, +module_param(g_log_tty, uint, 0644); +MODULE_PARM_DESC( + g_log_tty, "Allow driver log output to tty console feature enable/disable. Default: disable(0)"); #endif #endif #if defined PS3_HARDWARE_ASIC -static U32 g_hard_reset_enable = 1; -static U32 g_deep_soft_reset_enable = 0; -#elif (((defined PS3_HARDWARE_FPGA || defined PS3_HARDWARE_ASIC) \ - && defined PS3_MODEL_V200)\ - || defined(PS3_HARDWARE_HAPS_V200)) -static U32 g_hard_reset_enable = 1; -static U32 g_deep_soft_reset_enable = 0; +static unsigned int g_hard_reset_enable = 1; +static unsigned int g_deep_soft_reset_enable; +#elif (((defined PS3_HARDWARE_FPGA || defined PS3_HARDWARE_ASIC) && \ + defined PS3_MODEL_V200) || \ + defined(PS3_HARDWARE_HAPS_V200)) +static unsigned int g_hard_reset_enable = 1; +static unsigned int g_deep_soft_reset_enable; #else -static U32 g_hard_reset_enable = 0; -static U32 g_deep_soft_reset_enable = 0; +static unsigned int g_hard_reset_enable; +static unsigned int g_deep_soft_reset_enable; #endif #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hard_reset_enable, uint, S_IRUGO | S_IWUSR); +module_param(g_hard_reset_enable, uint, 0644); MODULE_PARM_DESC(g_hard_reset_enable, - "Hard reset feature enable/disable. Default: enable(1)"); -module_param(g_deep_soft_reset_enable, uint, S_IRUGO | S_IWUSR); + "Hard reset feature enable/disable. Default: enable(1)"); +module_param(g_deep_soft_reset_enable, uint, 0644); MODULE_PARM_DESC(g_deep_soft_reset_enable, - "Deep soft reset feature enable/disable. Default: disable(0)"); + "Deep soft reset feature enable/disable. Default: disable(0)"); #endif #endif -static U32 g_aer_handle_support = 1; +static unsigned int g_aer_handle_support = 1; #ifndef _WINDOWS -module_param(g_aer_handle_support, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_aer_handle_support, +module_param(g_aer_handle_support, uint, 0644); +MODULE_PARM_DESC( + g_aer_handle_support, "Driver aer handle support feature enable/disable. Default: enable(1)"); #endif #ifndef __cplusplus -static char g_version_verbose[512] = {0}; +static char g_version_verbose[512] = { 0 }; #ifndef _WINDOWS -module_param_string(g_version_verbose, g_version_verbose, 511, S_IRUGO); -MODULE_PARM_DESC(g_version_verbose, "Display detailed version information about ps3stor driver"); -#endif -#endif +module_param_string(g_version_verbose, g_version_verbose, 511, 0444); +MODULE_PARM_DESC(g_version_verbose, + "Display detailed version information about ps3stor driver"); +#endif +#endif -static U32 g_hard_reset_waiting = 0; -static U32 g_use_hard_reset_reg = 1; -static U32 g_use_hard_reset_max_retry = PS3_HARD_RESET_MAX_RETRY; +static unsigned int g_hard_reset_waiting; +static unsigned int g_use_hard_reset_reg = 1; +static unsigned int g_use_hard_reset_max_retry = PS3_HARD_RESET_MAX_RETRY; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hard_reset_waiting, uint, S_IRUGO | S_IWUSR); +module_param(g_hard_reset_waiting, uint, 0644); MODULE_PARM_DESC(g_hard_reset_waiting, - "Allow to access PCIe Config/BAR after xxx ms. Default: 0"); -module_param(g_use_hard_reset_reg, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_use_hard_reset_reg, + "Allow to access PCIe Config/BAR after xxx ms. Default: 0"); +module_param(g_use_hard_reset_reg, uint, 0644); +MODULE_PARM_DESC( + g_use_hard_reset_reg, "Write hard reset reg triggered feature enable/disable. Default: enable(1)"); -module_param(g_use_hard_reset_max_retry, uint, S_IRUGO | S_IWUSR); +module_param(g_use_hard_reset_max_retry, uint, 0644); MODULE_PARM_DESC(g_use_hard_reset_max_retry, - "Hard reset retry max count. Default: 2"); + "Hard reset retry max count. Default: 2"); +#endif #endif -#endif -#if ((defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) \ - || defined(PS3_HARDWARE_HAPS_V200) || defined(PS3_HARDWARE_ASIC)) -static U32 g_enable_heartbeat = 1; -module_param(g_enable_heartbeat, uint, S_IRUGO | S_IWUSR); +#if ((defined PS3_HARDWARE_FPGA && defined PS3_MODEL_V200) || \ + defined(PS3_HARDWARE_HAPS_V200) || defined(PS3_HARDWARE_ASIC)) +static unsigned int g_enable_heartbeat = 1; +module_param(g_enable_heartbeat, uint, 0644); MODULE_PARM_DESC(g_enable_heartbeat, - "Heartbeat query feature enable/disable. Default: enable(1)"); -#else -static U32 g_enable_heartbeat = 0; -module_param(g_enable_heartbeat, uint, S_IRUGO | S_IWUSR); + "Heartbeat query feature enable/disable. Default: enable(1)"); +#else +static unsigned int g_enable_heartbeat; +module_param(g_enable_heartbeat, uint, 0644); MODULE_PARM_DESC(g_enable_heartbeat, - "Heartbeat query feature enable/disable. Default: disable(0)"); -#endif + "Heartbeat query feature enable/disable. Default: disable(0)"); +#endif -static U32 g_hil_mode = 0xFFFF; +static unsigned int g_hil_mode = 0xFFFF; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_hil_mode, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_hil_mode, - "Set HIL operational mode." - "0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 65535(0xFFFF)"); +module_param(g_hil_mode, uint, 0644); +MODULE_PARM_DESC( +g_hil_mode, +"Set HIL operational mode.\n" +"\t0 - SW mode, 1 - HW mode, 2 - Enhanced HW mode, 3 - SW assist mode. Default: 65535(0xFFFF)"); #endif #endif -static U32 g_avaliable_func_id = 0xFF; +static unsigned int g_available_func_id = 0xFF; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_avaliable_func_id, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(g_avaliable_func_id, - "Set function id." - "0 - Func0, 1 - Func1, 2 - Unlimited. Default: 255(0xFF)"); +module_param(g_available_func_id, uint, 0644); +MODULE_PARM_DESC(g_available_func_id, + "Set function id.\n" + "\t0 - Func0, 1 - Func1, 2 - Unlimited. Default: 255(0xFF)"); #endif #endif -static U32 g_pci_irq_mode = PS3_PCI_IRQ_MODE_NONE_SPE; +static unsigned int g_pci_irq_mode = PS3_PCI_IRQ_MODE_NONE_SPE; #ifndef _WINDOWS -#if defined(PS3_SUPPORT_DEBUG) || \ - (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ +#if defined(PS3_SUPPORT_DEBUG) || \ + (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_DBGBUG)) || \ (defined(PS3_CFG_RELEASE) && defined(PS3_CFG_OCM_RELEASE)) -module_param(g_pci_irq_mode, uint, S_IRUGO | S_IWUSR); +module_param(g_pci_irq_mode, uint, 0644); MODULE_PARM_DESC(g_pci_irq_mode, - "Specify pci irq mode." - "0 - none specify, 1 - legacy, 2 - msi, 3 - msix. Default: 0"); + "Specify pci irq mode.\n" + "\t0 - none specify, 1 - legacy, 2 - msi, 3 - msix. Default: 0"); #endif #endif #if defined(PS3_TAGSET_SUPPORT) -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 8) && (RHEL_MINOR > 5)) || \ - (defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 1)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0))) -S32 g_ps3_tagset_enable = 1; +#if defined(PS3_SUPPORT_TAGSET) +static int g_ps3_tagset_enable = 1; module_param(g_ps3_tagset_enable, int, 0444); -MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: enable(1)"); +MODULE_PARM_DESC(g_ps3_tagset_enable, + "Shared host tagset enable/disable. Default: enable(1)"); #else -S32 g_ps3_tagset_enable = 0; +static int g_ps3_tagset_enable; module_param(g_ps3_tagset_enable, int, 0444); -MODULE_PARM_DESC(g_ps3_tagset_enable, "Shared host tagset enable/disable. Default: disable(0)"); +MODULE_PARM_DESC(g_ps3_tagset_enable, + "Shared host tagset enable/disable. Default: disable(0)"); #endif #endif -static U32 g_smp_affinity_enable = 1; +static unsigned int g_smp_affinity_enable = 1; module_param(g_smp_affinity_enable, int, 0444); -MODULE_PARM_DESC(g_smp_affinity_enable, "SMP affinity feature enable/disable. Default: enable(1)"); +MODULE_PARM_DESC(g_smp_affinity_enable, + "SMP affinity feature enable/disable. Default: enable(1)"); + +static int max_sgl_entries = PS3_DEFAULT_SGE_CNT; +module_param(max_sgl_entries, int, 0444); +MODULE_PARM_DESC(max_sgl_entries, + "Preferred max number of SGE to be used for a single I/O\n\t\t" + "The actual value will be determined by the driver\n\t\t" + "This parameter can be [128,256,262,512]. Default: 262"); void ps3_version_verbose_fill(void) { #ifndef __cplusplus - S32 len = 0; - S32 total_len = sizeof(g_version_verbose) - 1; + int len = 0; + int total_len = sizeof(g_version_verbose) - 1; memset(g_version_verbose, 0, sizeof(g_version_verbose)); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "version", PS3_DRV_VERSION); + "version", PS3_DRV_VERSION); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "commit_id", PS3_DRV_COMMIT_ID); + "commit_id", PS3_DRV_COMMIT_ID); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "toolchain_id", PS3_DRV_TOOLCHAIN_ID); + "toolchain_id", PS3_DRV_TOOLCHAIN_ID); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "build_time", PS3_DRV_BUILD_TIME); + "build_time", PS3_DRV_BUILD_TIME); len += snprintf(g_version_verbose + len, total_len - len, "%-20s:%s\n", - "product_support", PS3_DRV_PRODUCT_SUPPORT); + "product_support", PS3_DRV_PRODUCT_SUPPORT); #endif } -U32 ps3_throttle_qdepth_query(void) +unsigned int ps3_throttle_qdepth_query(void) { return g_throttle_que_depth; } -void ps3_debug_mem_size_modify(U32 size) +void ps3_debug_mem_size_modify(unsigned int size) { g_debug_mem_size = size; } -U32 ps3_debug_mem_size_query(void) +unsigned int ps3_debug_mem_size_query(void) { return g_debug_mem_size; } -U16 ps3_use_clustering_query(void) +unsigned short ps3_use_clustering_query(void) { - return (U16)g_use_clustering; + return (unsigned short)g_use_clustering; } -void ps3_scsi_cmd_timeout_modify(U32 val) +void ps3_scsi_cmd_timeout_modify(unsigned int val) { g_scsi_cmd_timeout = val; } void ps3_scsi_cmd_timeout_adjust(void) { - - if (g_scsi_cmd_timeout != 0 && ( - g_scsi_cmd_timeout < PS3_SCSI_CMD_TIMEOUT_MIN || - g_scsi_cmd_timeout > PS3_SCSI_CMD_TIMEOUT_MAX)) { + if (g_scsi_cmd_timeout != 0 && + (g_scsi_cmd_timeout < PS3_SCSI_CMD_TIMEOUT_MIN || + g_scsi_cmd_timeout > PS3_SCSI_CMD_TIMEOUT_MAX)) { g_scsi_cmd_timeout = PS3_SCSI_CMD_TIMEOUT_DEFAULT; } } -U32 ps3_scsi_cmd_timeout_query(void) +unsigned int ps3_scsi_cmd_timeout_query(void) { return g_scsi_cmd_timeout; } -U32 ps3_r1x_lock_flag_quiry(void) +unsigned int ps3_r1x_lock_flag_quiry(void) { return g_ps3_r1x_lock_flag; } -void ps3_r1x_lock_flag_modify(U32 val) +void ps3_r1x_lock_flag_modify(unsigned int val) { g_ps3_r1x_lock_flag = val; } -U32 ps3_direct_to_normal_query(void) +unsigned int ps3_direct_to_normal_query(void) { return g_direct_to_normal_enable; } -void ps3_direct_to_normal_modify(U32 val) +void ps3_direct_to_normal_modify(unsigned int val) { g_direct_to_normal_enable = val; } -U32 ps3_hba_check_time_query(void) +unsigned int ps3_hba_check_time_query(void) { return g_hba_check_time; } -U32 ps3_task_reset_delay_time_query(void) +unsigned int ps3_task_reset_delay_time_query(void) { return g_task_reset_delay_time; } -U64 ps3_r1x_ring_size_query(void) +unsigned long long ps3_r1x_ring_size_query(void) { - U64 ring_size_byte = (U64)g_r1x_ring_size; + unsigned long long ring_size_byte = (unsigned long long)g_r1x_ring_size; + ring_size_byte = MB_TO_BYTE(ring_size_byte); return ring_size_byte; } -void ps3_r1x_ring_size_modify(U32 size) +void ps3_r1x_ring_size_modify(unsigned int size) { g_r1x_ring_size = size; } -U32 ps3_direct_check_stream_query(void) +unsigned int ps3_direct_check_stream_query(void) { return g_direct_check_stream_enable; } -void ps3_direct_check_stream_modify(U32 val) +void ps3_direct_check_stream_modify(unsigned int val) { g_direct_check_stream_enable = val; } -S32 ps3_device_busy_threshold_query(void) +int ps3_device_busy_threshold_query(void) { return g_device_busy_threshold; } -void ps3_device_busy_threshold_modify(S32 busy) +void ps3_device_busy_threshold_modify(int busy) { g_device_busy_threshold = busy; } -void ps3_log_level_modify(U32 level) +void ps3_log_level_modify(unsigned int level) { - ps3_level_set(level); + ps3_level_set(level); } -char* ps3_log_path_query(void) +char *ps3_log_path_query(void) { #ifndef __cplusplus - return g_log_path; + return g_log_path; #else - return NULL; + return NULL; #endif } -U32 ps3_log_space_size_query(void) +unsigned int ps3_log_space_size_query(void) { - return g_log_space_size; + return g_log_space_size; } -U32 ps3_log_file_size_query(void) +unsigned int ps3_log_file_size_query(void) { - return g_log_file_size; + return g_log_file_size; } -U32 ps3_log_level_query(void) +unsigned int ps3_log_level_query(void) { return g_log_level; } -void ps3_log_file_size_modify(U32 size) +void ps3_log_file_size_modify(unsigned int size) { - g_log_file_size = size; + g_log_file_size = size; } -U32 ps3_log_tty_query(void) +unsigned int ps3_log_tty_query(void) { - return g_log_tty; + return g_log_tty; } -void ps3_log_tty_modify(U32 enable) +void ps3_log_tty_modify(unsigned int enable) { - g_log_tty = enable; + g_log_tty = enable; } -void ps3_hard_reset_enable_modify(U32 val) +void ps3_hard_reset_enable_modify(unsigned int val) { g_hard_reset_enable = val; } -U32 ps3_hard_reset_enable_query(void) +unsigned int ps3_hard_reset_enable_query(void) { return g_hard_reset_enable; } -U32 ps3_deep_soft_reset_enable_query(void) +unsigned int ps3_deep_soft_reset_enable_query(void) { return g_deep_soft_reset_enable; } -void ps3_deep_soft_reset_enable_modify(U32 val) +void ps3_deep_soft_reset_enable_modify(unsigned int val) { g_deep_soft_reset_enable = val; } -U32 ps3_aer_handle_support_query(void) +unsigned int ps3_aer_handle_support_query(void) { return g_aer_handle_support; } -void ps3_aer_handle_support_set(U32 aer_handle_support) +void ps3_aer_handle_support_set(unsigned int aer_handle_support) { g_aer_handle_support = aer_handle_support; } -U32 ps3_hard_reset_waiting_query(void) +unsigned int ps3_hard_reset_waiting_query(void) { return g_hard_reset_waiting; } -U32 ps3_use_hard_reset_reg_query(void) +unsigned int ps3_use_hard_reset_reg_query(void) { return g_use_hard_reset_reg; } -U32 ps3_use_hard_reset_max_retry(void) +unsigned int ps3_use_hard_reset_max_retry(void) { return g_use_hard_reset_max_retry; } -U32 ps3_enable_heartbeat_query(void) +unsigned int ps3_enable_heartbeat_query(void) { return g_enable_heartbeat; } -U32 ps3_enable_heartbeat_set(U32 val) +unsigned int ps3_enable_heartbeat_set(unsigned int val) { return g_enable_heartbeat = val; } -U32 ps3_hil_mode_query(void) +unsigned int ps3_hil_mode_query(void) { return g_hil_mode; } -void ps3_hil_mode_modify(U32 val) +void ps3_hil_mode_modify(unsigned int val) { g_hil_mode = val; - return; } -U32 ps3_avaliable_func_id_query(void) +unsigned int ps3_available_func_id_query(void) { - return g_avaliable_func_id; + return g_available_func_id; } -void ps3_avaliable_func_id_modify(U32 val) +void ps3_available_func_id_modify(unsigned int val) { - g_avaliable_func_id = val; - return; + g_available_func_id = val; } -U32 ps3_r1x_tmo_query(void) +unsigned int ps3_r1x_tmo_query(void) { - if (unlikely(g_r1x_time_out > 360000)) { + if (unlikely(g_r1x_time_out > 360000)) g_r1x_time_out = 360000; - } return g_r1x_time_out * HZ / 1000; } -U32 ps3_r1x_conflict_queue_support_query(void) +unsigned int ps3_r1x_conflict_queue_support_query(void) { return g_r1x_conflict_queue_enable; } -U32 ps3_pci_irq_mode_query(void) +unsigned int ps3_pci_irq_mode_query(void) { return g_pci_irq_mode; } -U32 ps3_cli_ver_query(void) +#ifdef PS3_UT +unsigned int ps3_cli_ver_query(void) { return cli_ver; } +#endif #if defined(PS3_TAGSET_SUPPORT) -Bool ps3_tagset_enable_query(void) +void ps3_tagset_enable_modify(unsigned char enable) { - return (g_ps3_tagset_enable == 1) ? PS3_TRUE: PS3_FALSE; + g_ps3_tagset_enable = enable; +} + +unsigned char ps3_tagset_enable_query(void) +{ + return (g_ps3_tagset_enable == 1) ? PS3_TRUE : PS3_FALSE; } #endif -Bool ps3_smp_affinity_query(void) +unsigned char ps3_smp_affinity_query(void) +{ + return (g_smp_affinity_enable == 1) ? PS3_TRUE : PS3_FALSE; +} + +unsigned char ps3_latency_perf_mode_query(void) +{ + return (g_latency_perf_mode_enable == 1); +} + +void ps3_latency_perf_mode_modify(unsigned char enable) { - return (g_smp_affinity_enable == 1) ? PS3_TRUE: PS3_FALSE; + g_latency_perf_mode_enable = enable; } +int ps3_max_sge_cnt_query(void) +{ + return max_sgl_entries; +} + +void ps3_max_sge_cnt_modify(int value) +{ + max_sgl_entries = value; +} diff --git a/drivers/scsi/linkdata/ps3stor/ps3_module_para.h b/drivers/scsi/linkdata/ps3stor/ps3_module_para.h index 3428fbce9e11..5558ad2d768d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_module_para.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_module_para.h @@ -1,119 +1,114 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_MODULE_PARA_H_ #define _PS3_MODULE_PARA_H_ -#include "ps3_types.h" - #define MB_TO_BYTE(MB) ((MB) << 20) -#define PS3_MAX_FUNC_ID (2) +#define PS3_MAX_FUNC_ID (2) -U32 ps3_throttle_qdepth_query(void); +unsigned int ps3_throttle_qdepth_query(void); -void ps3_debug_mem_size_modify(U32 size); +void ps3_debug_mem_size_modify(unsigned int size); -U32 ps3_debug_mem_size_query(void); +unsigned int ps3_debug_mem_size_query(void); -U32 ps3_sata_direct_query(void); +unsigned int ps3_sata_direct_query(void); -void ps3_sata_direct_modify(U32 val); +void ps3_sata_direct_modify(unsigned int val); -U16 ps3_use_clustering_query(void); +unsigned short ps3_use_clustering_query(void); -void ps3_scsi_cmd_timeout_modify(U32 val); +void ps3_scsi_cmd_timeout_modify(unsigned int val); -U32 ps3_scsi_cmd_timeout_query(void); +unsigned int ps3_scsi_cmd_timeout_query(void); void ps3_scsi_cmd_timeout_adjust(void); -U32 ps3_r1x_lock_flag_quiry(void); +unsigned int ps3_r1x_lock_flag_quiry(void); -void ps3_r1x_lock_flag_modify(U32 val); +void ps3_r1x_lock_flag_modify(unsigned int val); -U32 ps3_direct_to_normal_query(void); +unsigned int ps3_direct_to_normal_query(void); -void ps3_direct_to_normal_modify(U32 val); +void ps3_direct_to_normal_modify(unsigned int val); -U32 ps3_hba_check_time_query(void); +unsigned int ps3_hba_check_time_query(void); -U32 ps3_task_reset_delay_time_query(void); +unsigned int ps3_task_reset_delay_time_query(void); -U64 ps3_r1x_ring_size_query(void); +unsigned long long ps3_r1x_ring_size_query(void); -void ps3_r1x_ring_size_modify(U32 size); +void ps3_r1x_ring_size_modify(unsigned int size); -U32 ps3_direct_check_stream_query(void); +unsigned int ps3_direct_check_stream_query(void); -S32 ps3_device_busy_threshold_query(void); +int ps3_device_busy_threshold_query(void); -void ps3_device_busy_threshold_modify(S32 busy); +void ps3_device_busy_threshold_modify(int busy); -void ps3_log_level_modify(U32 level); +void ps3_log_level_modify(unsigned int level); -char* ps3_log_path_query(void); +char *ps3_log_path_query(void); -U32 ps3_log_space_size_query(void); +unsigned int ps3_log_space_size_query(void); -U32 ps3_log_file_size_query(void); +unsigned int ps3_log_file_size_query(void); -void ps3_log_file_size_modify(U32 size); +void ps3_log_file_size_modify(unsigned int size); -U32 ps3_log_level_query(void); +unsigned int ps3_log_level_query(void); -U32 ps3_log_tty_query(void); +unsigned int ps3_log_tty_query(void); -void ps3_log_tty_modify(U32 enable); +void ps3_log_tty_modify(unsigned int enable); -void ps3_hard_reset_enable_modify(U32 val); -void ps3_deep_soft_reset_enable_modify(U32 val); +void ps3_hard_reset_enable_modify(unsigned int val); +void ps3_deep_soft_reset_enable_modify(unsigned int val); -U32 ps3_hard_reset_enable_query(void); -U32 ps3_deep_soft_reset_enable_query(void); +unsigned int ps3_hard_reset_enable_query(void); +unsigned int ps3_deep_soft_reset_enable_query(void); -U32 ps3_log_level_query(void); +unsigned int ps3_log_level_query(void); -U32 ps3_aer_handle_support_query(void); - -void ps3_aer_handle_support_set(U32 aer_handle_support); +unsigned int ps3_aer_handle_support_query(void); +void ps3_aer_handle_support_set(unsigned int aer_handle_support); void ps3_version_verbose_fill(void); -U32 ps3_hard_reset_waiting_query(void); - -U32 ps3_use_hard_reset_reg_query(void); -U32 ps3_use_hard_reset_max_retry(void); - -U32 ps3_enable_heartbeat_query(void); - -U32 ps3_enable_heartbeat_set(U32 val); - -U32 ps3_hil_mode_query(void); +unsigned int ps3_hard_reset_waiting_query(void); +unsigned int ps3_use_hard_reset_reg_query(void); +unsigned int ps3_use_hard_reset_max_retry(void); +unsigned int ps3_enable_heartbeat_query(void); +unsigned int ps3_enable_heartbeat_set(unsigned int val); +unsigned int ps3_hil_mode_query(void); +void ps3_hil_mode_modify(unsigned int val); +unsigned int ps3_available_func_id_query(void); +void ps3_available_func_id_modify(unsigned int val); +void ps3_direct_check_stream_modify(unsigned int val); +unsigned int ps3_r1x_tmo_query(void); +unsigned int ps3_r1x_conflict_queue_support_query(void); +unsigned int ps3_pci_irq_mode_query(void); -void ps3_hil_mode_modify(U32 val); - -U32 ps3_avaliable_func_id_query(void); - -void ps3_avaliable_func_id_modify(U32 val); - -void ps3_direct_check_stream_modify(U32 val); +#if defined(PS3_TAGSET_SUPPORT) -U32 ps3_r1x_tmo_query(void); +void ps3_tagset_enable_modify(unsigned char enable); -U32 ps3_r1x_conflict_queue_support_query(void); +unsigned char ps3_tagset_enable_query(void); +#endif +unsigned char ps3_smp_affinity_query(void); -U32 ps3_pci_irq_mode_query(void); +unsigned char ps3_latency_perf_mode_query(void); -#if defined(PS3_TAGSET_SUPPORT) +void ps3_latency_perf_mode_modify(unsigned char enable); -Bool ps3_tagset_enable_query(void); -#endif +int ps3_max_sge_cnt_query(void); -Bool ps3_smp_affinity_query(void); +void ps3_max_sge_cnt_modify(int value); #ifndef _WINDOWS #ifdef PS3_SUPPORT_INJECT -U32 ps3_err_inject_num_query(void); -U32* ps3_err_inject_array_query(void); -U32 ps3_err_inject_state_query(void); +unsigned int ps3_err_inject_num_query(void); +unsigned int *ps3_err_inject_array_query(void); +unsigned int ps3_err_inject_state_query(void); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c index e799e954a1b7..d4fb135c9853 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.c @@ -1,143 +1,145 @@ - +// SPDX-License-Identifier: GPL-2.0 #include -#include "ps3_nvme_spec.h" +#include "ps3_htp_nvme_spec.h" #include "ps3_nvme_resp_to_scsi.h" #include "ps3_instance_manager.h" #include "ps3_htp_def.h" #include "ps3_htp.h" enum { - SENSE_KEY_NO_SENSE = 0x00, + SENSE_KEY_NO_SENSE = 0x00, SENSE_KEY_RECOVERED_ERROR = 0x01, - SENSE_KEY_NOT_READY = 0x02, - SENSE_KEY_MEDIUM_ERROR = 0x03, - SENSE_KEY_HARDWARE_ERROR = 0x04, + SENSE_KEY_NOT_READY = 0x02, + SENSE_KEY_MEDIUM_ERROR = 0x03, + SENSE_KEY_HARDWARE_ERROR = 0x04, SENSE_KEY_ILLEGAL_REQUEST = 0x05, - SENSE_KEY_UNIT_ATTENTION = 0x06, - SENSE_KEY_DATA_PROTECT = 0x07, - SENSE_KEY_BLANK_CHECK = 0x08, + SENSE_KEY_UNIT_ATTENTION = 0x06, + SENSE_KEY_DATA_PROTECT = 0x07, + SENSE_KEY_BLANK_CHECK = 0x08, SENSE_KEY_VENDOR_SPECIFIC = 0x09, - SENSE_KEY_COPY_ABORTED = 0x0a, + SENSE_KEY_COPY_ABORTED = 0x0a, SENSE_KEY_ABORTED_COMMAND = 0x0b, SENSE_KEY_VOLUME_OVERFLOW = 0x0d, - SENSE_KEY_MISCOMPARE = 0x0e, -} ; + SENSE_KEY_MISCOMPARE = 0x0e, +}; enum { - SCSI_ASC_NO_ADDITIONAL_SENSE = 0x00, - SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03, - SCSI_ASC_LOGICAL_UNIT_NOT_READY = 0x04, - SCSI_ASC_WARNING = 0x0b, - SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x10, - SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x10, - SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x10, - SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11, + SCSI_ASC_NO_ADDITIONAL_SENSE = 0x00, + SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT = 0x03, + SCSI_ASC_LOGICAL_UNIT_NOT_READY = 0x04, + SCSI_ASC_WARNING = 0x0b, + SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x10, + SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x10, + SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x10, + SCSI_ASC_UNRECOVERED_READ_ERROR = 0x11, SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION = 0x1d, - SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20, - SCSI_ASC_ACCESS_DENIED = 0x20, + SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x20, + SCSI_ASC_ACCESS_DENIED = 0x20, SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE = 0x21, - SCSI_ASC_INVALID_FIELD_IN_CDB = 0x24, - SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25, - SCSI_ASC_WRITE_PROTECTED = 0x27, - SCSI_ASC_FORMAT_COMMAND_FAILED = 0x31, - SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39, - SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x44, - SCSI_ASC_DATA_PHASE_ERROR = 0x4b, -} ; + SCSI_ASC_INVALID_FIELD_IN_CDB = 0x24, + SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED = 0x25, + SCSI_ASC_WRITE_PROTECTED = 0x27, + SCSI_ASC_FORMAT_COMMAND_FAILED = 0x31, + SCSI_ASC_SAVING_PARAMETERS_NOT_SUPPORTED = 0x39, + SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x44, + SCSI_ASC_DATA_PHASE_ERROR = 0x4b, +}; -typedef enum ScsiAscq { - SCSI_ASCQ_CAUSE_NOT_REPORTABLE = 0x00, - SCSI_ASCQ_BECOMING_READY = 0x01, - SCSI_ASCQ_FORMAT_COMMAND_FAILED = 0x01, - SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x01, +enum ScsiAscq { + SCSI_ASCQ_CAUSE_NOT_REPORTABLE = 0x00, + SCSI_ASCQ_BECOMING_READY = 0x01, + SCSI_ASCQ_FORMAT_COMMAND_FAILED = 0x01, + SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED = 0x01, SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED = 0x02, - SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02, + SCSI_ASCQ_NO_ACCESS_RIGHTS = 0x02, SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED = 0x03, - SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, + SCSI_ASCQ_SANITIZE_COMMAND_FAILED = 0x03, SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS = 0x04, - SCSI_ASCQ_DATA_OFFSET_ERROR = 0x05, - SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08, - SCSI_ASCQ_INVALID_LU_IDENTIFIER = 0x09, - SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW = 0x0C, - SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE = 0x13, - SCSI_ASCQ_ERASE_OPEARTION_IN_PROGRESS = 0x18, + SCSI_ASCQ_DATA_OFFSET_ERROR = 0x05, + SCSI_ASCQ_POWER_LOSS_EXPECTED = 0x08, + SCSI_ASCQ_INVALID_LU_IDENTIFIER = 0x09, + SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW = 0x0C, + SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE = 0x13, + SCSI_ASCQ_ERASE_OPEARTION_IN_PROGRESS = 0x18, SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS = 0x1b, -} ScsiAscq_e; +}; -#define PS3_MEDIUM_ERROR_LEN (4) -static void ps3_nvme_generic_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) +#define PS3_MEDIUM_ERROR_LEN (4) +static void +ps3_nvme_generic_error_to_scsi_status(unsigned char nvmeSc, + struct ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_SC_SUCCESS: - cpl->status = SCSI_STATUS_GOOD; + cpl->status = SCSI_STATUS_GOOD; cpl->senseKey = SENSE_KEY_NO_SENSE; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_OPCODE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_COMMAND_OPERATION_CODE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_COMMAND_OPERATION_CODE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_FIELD: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_DATA_TRANSFER_ERROR: case NVME_SC_CAPACITY_EXCEEDED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_ABORTED_POWER_LOSS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_WARNING; - cpl->ascq = SCSI_ASCQ_POWER_LOSS_EXPECTED; + cpl->asc = SCSI_ASC_WARNING; + cpl->ascq = SCSI_ASCQ_POWER_LOSS_EXPECTED; break; case NVME_SC_INTERNAL_DEVICE_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_HARDWARE_ERROR; - cpl->asc = SCSI_ASC_INTERNAL_TARGET_FAILURE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; - break; + cpl->asc = SCSI_ASC_INTERNAL_TARGET_FAILURE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + break; case NVME_SC_ABORTED_BY_REQUEST: case NVME_SC_ABORTED_SQ_DELETION: case NVME_SC_ABORTED_FAILED_FUSED: case NVME_SC_ABORTED_MISSING_FUSED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_INVALID_NAMESPACE_OR_FORMAT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_ACCESS_DENIED; - cpl->ascq = SCSI_ASCQ_INVALID_LU_IDENTIFIER; + cpl->asc = SCSI_ASC_ACCESS_DENIED; + cpl->ascq = SCSI_ASCQ_INVALID_LU_IDENTIFIER; break; case NVME_SC_LBA_OUT_OF_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_NAMESPACE_NOT_READY: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_RESERVATION_CONFLICT: - cpl->status = SCSI_STATUS_RESERVATION_CONFLICT; + cpl->status = SCSI_STATUS_RESERVATION_CONFLICT; cpl->senseKey = SENSE_KEY_NO_SENSE; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_SC_COMMAND_ID_CONFLICT: case NVME_SC_COMMAND_SEQUENCE_ERROR: @@ -148,83 +150,85 @@ static void ps3_nvme_generic_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_statu case NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID: case NVME_SC_INVALID_CONTROLLER_MEM_BUF: case NVME_SC_INVALID_PRP_OFFSET: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_DATA_PHASE_ERROR; - cpl->ascq = SCSI_ASCQ_DATA_OFFSET_ERROR; - break; + cpl->asc = SCSI_ASC_DATA_PHASE_ERROR; + cpl->ascq = SCSI_ASCQ_DATA_OFFSET_ERROR; + break; case NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED: case NVME_SC_INVALID_SGL_OFFSET: case NVME_SC_HOSTID_INCONSISTENT_FORMAT: case NVME_SC_KEEP_ALIVE_EXPIRED: case NVME_SC_KEEP_ALIVE_INVALID: case NVME_SC_FORMAT_IN_PROGRESS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS; - break; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_FORMAT_IN_PROGRESS; + break; case NVME_SC_SANITIZE_FAILED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; - cpl->ascq = SCSI_ASCQ_SANITIZE_COMMAND_FAILED; - break; + cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; + cpl->ascq = SCSI_ASCQ_SANITIZE_COMMAND_FAILED; + break; case NVME_SC_SANITIZE_IN_PROGRESS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_NOT_READY; - cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; - cpl->ascq = SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS; - break; + cpl->asc = SCSI_ASC_LOGICAL_UNIT_NOT_READY; + cpl->ascq = + SCSI_ASCQ_LOGICAL_UNIT_NOT_READY_SANITIZE_IN_PROGRESS; + break; case NVME_SC_NAMESPACE_IS_WRITE_PROTECTED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_WRITE_PROTECTED; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; - break; + cpl->asc = SCSI_ASC_WRITE_PROTECTED; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + break; case NVME_SC_COMMAND_INTERRUPTED: case NVME_SC_TRANSIENT_TRANSPORT_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -static void ps3_nvme_spec_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) +static void ps3_nvme_spec_error_to_scsi_status(unsigned char nvmeSc, + struct ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_CSC_COMPLETION_QUEUE_INVALID: case NVME_CSC_ABORT_COMMAND_LIMIT_EXCEEDED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_FORMAT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; - cpl->ascq = SCSI_ASCQ_FORMAT_COMMAND_FAILED; + cpl->asc = SCSI_ASC_FORMAT_COMMAND_FAILED; + cpl->ascq = SCSI_ASCQ_FORMAT_COMMAND_FAILED; break; case NVME_CSC_CONFLICTING_ATTRIBUTES: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_ATTEMPTED_WRITE_TO_RO_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_WRITE_PROTECTED; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_WRITE_PROTECTED; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_QUEUE_IDENTIFIER: case NVME_CSC_MAXIMUM_QUEUE_SIZE_EXCEEDED: @@ -235,16 +239,17 @@ static void ps3_nvme_spec_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status * case NVME_CSC_FIRMWARE_ACTIVATION_PROHIBITED: case NVME_CSC_BOOT_PARTITION_WRITE_PROHIBITED: case NVME_CSC_INVALID_FIRMWARE_SLOT: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_INVALID_FIRMWARE_IMAGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_WARNING; - cpl->ascq = SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE; + cpl->asc = SCSI_ASC_WARNING; + cpl->ascq = + SCSI_ASCQ_WARNING_MICROCODE_DIGITAL_SIGNATURE_VALIDATION_FAILURE; break; case NVME_CSC_INVALID_INTERRUPT_VECTOR: case NVME_CSC_INVALID_LOG_PAGE: @@ -255,10 +260,10 @@ static void ps3_nvme_spec_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status * case NVME_CSC_FEATURE_NOT_NAMESPACE_SPECIFIC: case NVME_CSC_FIRMWARE_REQ_RESET: case NVME_CSC_OVERLAPPING_RANGE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_INVALID_FIELD_IN_CDB; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_CSC_NAMESPACE_INSUFFICIENT_CAPACITY: case NVME_CSC_NAMESPACE_ID_UNAVAILABLE: @@ -269,78 +274,81 @@ static void ps3_nvme_spec_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status * case NVME_CSC_CONTROLLER_LIST_INVALID: default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -static void ps3_nvme_media_error_to_scsi_status(U8 nvmeSc, ps3_nvme_scsi_status *cpl) +static void +ps3_nvme_media_error_to_scsi_status(unsigned char nvmeSc, + struct ps3_nvme_scsi_status *cpl) { switch (nvmeSc) { case NVME_MSC_WRITE_FAULTS: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_PERIPHERAL_DEVICE_WRITE_FAULT; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_UNRECOVERED_READ_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_GUARD_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_GUARD_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_GUARD_CHECK_FAILED; break; case NVME_MSC_APPLICATION_TAG_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_APPTAG_CHECK_FAILED; break; case NVME_MSC_REFERENCE_TAG_CHECK_ERROR: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ABORTED_COMMAND; - cpl->asc = SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; - cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; + cpl->asc = SCSI_ASC_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; + cpl->ascq = SCSI_ASCQ_LOGICAL_BLOCK_REFTAG_CHECK_FAILED; break; case NVME_MSC_COMPARE_FAILURE: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MISCOMPARE; - cpl->asc = SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_MISCOMPARE_DURING_VERIFY_OPERATION; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; case NVME_MSC_ACCESS_DENIED: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_DATA_PROTECT; - cpl->asc = SCSI_ASC_ACCESS_DENIED; - cpl->ascq = SCSI_ASCQ_NO_ACCESS_RIGHTS; + cpl->asc = SCSI_ASC_ACCESS_DENIED; + cpl->ascq = SCSI_ASCQ_NO_ACCESS_RIGHTS; break; case NVME_MSC_DEALLOCATED_OR_UNWRITTEN_BLOCK: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_MEDIUM_ERROR; - cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; - cpl->ascq = SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW; + cpl->asc = SCSI_ASC_UNRECOVERED_READ_ERROR; + cpl->ascq = SCSI_ASCQ_SDBP_INCOMING_BUFFER_OVERFLOW; break; default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } -void ps3_nvme_error_to_scsi_status(PS3NvmeCmdStatus_s status, ps3_nvme_scsi_status *cpl) +void ps3_nvme_error_to_scsi_status(struct PS3NvmeCmdStatus status, + struct ps3_nvme_scsi_status *cpl) { - U8 sct = status.sct; - U8 sc = status.sc; + unsigned char sct = status.sct; + unsigned char sc = status.sc; switch (sct) { case NVME_SCT_GENERIC: @@ -354,36 +362,36 @@ void ps3_nvme_error_to_scsi_status(PS3NvmeCmdStatus_s status, ps3_nvme_scsi_stat break; case NVME_SCT_VENDOR_SPECIFIC: default: - cpl->status = SCSI_STATUS_CHECK_CONDITION; + cpl->status = SCSI_STATUS_CHECK_CONDITION; cpl->senseKey = SENSE_KEY_ILLEGAL_REQUEST; - cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; - cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; + cpl->asc = SCSI_ASC_NO_ADDITIONAL_SENSE; + cpl->ascq = SCSI_ASCQ_CAUSE_NOT_REPORTABLE; break; } } void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd) { - PS3NvmeCmdStatus_s status; - ps3_nvme_scsi_status cpl; + struct PS3NvmeCmdStatus status; + struct ps3_nvme_scsi_status cpl; status.cmdStatus = cmd->reply_word.retStatus; - LOG_FILE_ERROR("trace_id:0x%llx host_no:%d tag:%d nvme status:" - "sc:%d sct:%d crd:%d more:%d dnr:%d p:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, status.sc, status.sct, status.crd, - status.m, status.dnr, status.p); + LOG_FILE_ERROR("trace_id:0x%llx host_no:%d tag:%d nvme status:\n" + "\tsc:%d sct:%d crd:%d more:%d dnr:%d p:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + status.sc, status.sct, status.crd, status.m, status.dnr, + status.p); - memset(&cpl, 0, sizeof(ps3_nvme_scsi_status)); + memset(&cpl, 0, sizeof(struct ps3_nvme_scsi_status)); ps3_nvme_error_to_scsi_status(status, &cpl); memset(cmd->resp_frame->sasRespFrame.data, 0, PS3_SENSE_BUFFER_SIZE); scsi_build_sense_buffer(0, cmd->resp_frame->sasRespFrame.data, - cpl.senseKey, cpl.asc, cpl.ascq); + cpl.senseKey, cpl.asc, cpl.ascq); if (cmd->reply_word.mode == PS3_REPLY_WORD_MODE_DIRECT_OK && - cpl.senseKey == SENSE_KEY_MEDIUM_ERROR) { - memset(&cmd->resp_frame->sasRespFrame.data[3], 0xff, PS3_MEDIUM_ERROR_LEN); + cpl.senseKey == SENSE_KEY_MEDIUM_ERROR) { + memset(&cmd->resp_frame->sasRespFrame.data[3], 0xff, + PS3_MEDIUM_ERROR_LEN); } cmd->resp_frame->sasRespFrame.status = cpl.status; - } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h index 35206918ee8a..5a9883e8664c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_nvme_resp_to_scsi.h @@ -1,13 +1,13 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #include "ps3_cmd_channel.h" -typedef struct ps3_nvme_scsi_status { - U8 status; - U8 senseKey; - U8 asc; - U8 ascq; -} ps3_nvme_scsi_status; - -void ps3_nvme_error_to_scsi_status(PS3NvmeCmdStatus_s status, ps3_nvme_scsi_status *cpl); +struct ps3_nvme_scsi_status { + unsigned char status; + unsigned char senseKey; + unsigned char asc; + unsigned char ascq; +}; -void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd); \ No newline at end of file +void ps3_nvme_error_to_scsi_status(struct PS3NvmeCmdStatus status, + struct ps3_nvme_scsi_status *cpl); +void ps3_nvme_resp_to_scsi_status(struct ps3_cmd *cmd); diff --git a/drivers/scsi/linkdata/ps3stor/ps3_pci.c b/drivers/scsi/linkdata/ps3stor/ps3_pci.c index 689527f62f8c..fc633bb2c057 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_pci.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_pci.c @@ -1,461 +1,452 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_instance_manager.h" #include "ps3_pci.h" #define PS3_VALID_MEMORY_BAR_INDEX 2 #ifdef _WINDOWS -#define PS3_CHECK_BAR_64BIT(bar) ((bar)&0x4) -#define PS3_CHECK_BAR_MEMORYSPACE(bar) (!((bar)&0x1)) -#define PS3_BAR_BASE_ADDR_MARSK (0xFFFFFFF0) -#define PS3_GET_BAR_BASE_ADDR(addr) (U64)((addr) & PS3_BAR_BASE_ADDR_MARSK) - -static S32 ps3_pci_map_reg(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config); -static S32 ps3_pci_info_get(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config); +#define PS3_CHECK_BAR_64BIT(bar) ((bar) & 0x4) +#define PS3_CHECK_BAR_MEMORYSPACE(bar) (!((bar) & 0x1)) +#define PS3_BAR_BASE_ADDR_MARSK (0xFFFFFFF0) +#define PS3_GET_BAR_BASE_ADDR(addr) \ + ((unsigned long long)((addr) & PS3_BAR_BASE_ADDR_MARSK)) + +static int ps3_pci_map_reg(struct ps3_instance *instance, + PPORT_CONFIGURATION_INFORMATION config); +static int ps3_pci_info_get(struct ps3_instance *instance, + PPORT_CONFIGURATION_INFORMATION config); static void ps3_pci_unmap_reg(struct ps3_instance *instance); -static void ps3_pci_irq_type_get(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); -static U16 ps3_pci_msix_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); -static U16 ps3_pci_msi_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config); - -S32 ps3_pci_init(struct ps3_instance *instance, void *config) +static void ps3_pci_irq_type_get(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config); +static unsigned short ps3_pci_msix_vec_count(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config); +static unsigned short ps3_pci_msi_vec_count(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config); +int ps3_pci_init(struct ps3_instance *instance, void *config) { - S32 ret = PS3_SUCCESS; - PPORT_CONFIGURATION_INFORMATION config_info = (PPORT_CONFIGURATION_INFORMATION)config; + int ret = PS3_SUCCESS; + PPORT_CONFIGURATION_INFORMATION config_info = + (PPORT_CONFIGURATION_INFORMATION)config; - ret = ps3_pci_info_get(instance, config_info); - if (ret != PS3_SUCCESS) { - goto l_out; - } + ret = ps3_pci_info_get(instance, config_info); + if (ret != PS3_SUCCESS) + goto l_out; - ret = ps3_pci_map_reg(instance, config_info); - if (ret != PS3_SUCCESS) { - goto l_out; - } + ret = ps3_pci_map_reg(instance, config_info); + if (ret != PS3_SUCCESS) + goto l_out; l_out: - return ret; + return ret; } void ps3_pci_exit(struct ps3_instance *instance) { - ps3_pci_unmap_reg(instance); + ps3_pci_unmap_reg(instance); } -static S32 ps3_pci_info_get( - struct ps3_instance *instance, - PPORT_CONFIGURATION_INFORMATION config -) +static int ps3_pci_info_get(struct ps3_instance *instance, + PPORT_CONFIGURATION_INFORMATION config) { - PCI_COMMON_CONFIG pci_config = { 0 }; - ULong len = 0; - ULong base_addr = 0; -#ifdef PS3_HARDWARE_ASIC - U32 check_count = ps3_hba_check_time_query() * 10; -#endif + PCI_COMMON_CONFIG pci_config = { 0 }; + unsigned long len = 0; + unsigned long base_addr = 0; + + if (config->AdapterInterfaceType != PCIBus) { + LOG_ERROR("there is not pcibus, type:%d\n", + config->AdapterInterfaceType); + return -PS3_FAILED; + } + + len = StorPortGetBusData(instance, PCIConfiguration, + config->SystemIoBusNumber, + (unsigned long)config->SlotNumber, + (void *)&pci_config, sizeof(pci_config)); + + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + return -PS3_FAILED; + } + + instance->pci_dev_context.slot_number = + (unsigned long long)config->SlotNumber; + instance->pci_dev_context.device_id = pci_config.DeviceID; + instance->pci_dev_context.vendor_id = pci_config.VendorID; + instance->pci_dev_context.sub_vendor_id = + pci_config.u.type0.SubVendorID; + instance->pci_dev_context.sub_device_id = + pci_config.u.type0.SubSystemID; + base_addr = + pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX]; + if (!PS3_CHECK_BAR_MEMORYSPACE(base_addr)) { + LOG_ERROR("Bar%d is not memory space\n", + PS3_VALID_MEMORY_BAR_INDEX); + return -PS3_FAILED; + } + + if (PS3_CHECK_BAR_64BIT(base_addr)) { + instance->pci_dev_context.bar_base_addr = + PS3_GET_BAR_BASE_ADDR(base_addr); + base_addr = + pci_config.u.type0 + .BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX + 1]; + instance->pci_dev_context.bar_base_addr |= + ((unsigned long long)base_addr) << 32; + } else { + instance->pci_dev_context.bar_base_addr = + PS3_GET_BAR_BASE_ADDR(base_addr); + } + + ps3_pci_irq_type_get(instance, &pci_config); + + if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSIX) { + instance->pci_dev_context.irq_vec_count = + ps3_pci_msix_vec_count(instance, &pci_config); + } else if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSI) { + instance->pci_dev_context.irq_vec_count = + ps3_pci_msi_vec_count(instance, &pci_config); + } else { + instance->pci_dev_context.irq_vec_count = 1; + } + + LOG_INFO( + "vid:%x, devid:%x, sub_vid:%x, sub_devid:%x, bar_base:0x%llx, irq_type:%d, vec_count:%d\n", + instance->pci_dev_context.vendor_id, + instance->pci_dev_context.device_id, + instance->pci_dev_context.sub_vendor_id, + instance->pci_dev_context.sub_device_id, + instance->pci_dev_context.bar_base_addr, + instance->pci_dev_context.pci_irq_type, + instance->pci_dev_context.irq_vec_count); + + return PS3_SUCCESS; +}; - if (config->AdapterInterfaceType != PCIBus) { - LOG_ERROR("there is not pcibus, type:%d\n", config->AdapterInterfaceType); - return -PS3_FAILED; - } - - len = StorPortGetBusData(instance, - PCIConfiguration, - config->SystemIoBusNumber, - (ULong)config->SlotNumber, - (void*)&pci_config, - sizeof(pci_config)); - - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - return -PS3_FAILED; - } - -#ifdef PS3_HARDWARE_ASIC - while(pci_config.DeviceID == PCI_DEVICE_ID_PS3_RAID_FPGA && - check_count > 0) { - - check_count--; - ps3_msleep(100); - - len = StorPortGetBusData(instance, - PCIConfiguration, - config->SystemIoBusNumber, - (ULong)config->SlotNumber, - (void*)&pci_config, - sizeof(pci_config)); - - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - return -PS3_FAILED; +static int ps3_pci_map_reg(struct ps3_instance *instance, + PPORT_CONFIGURATION_INFORMATION config) +{ + int ret = -PS3_FAILED; + unsigned long i = 0; + + if (config->NumberOfAccessRanges <= 0) { + LOG_ERROR("valid access range is 0\n"); + goto l_out; + } + + if (config->AdapterInterfaceType != PCIBus) { + LOG_ERROR("adapter interface type is not PCIBus\n"); + goto l_out; + } + + for (i = 0; i < config->NumberOfAccessRanges; i++) { + LOG_DEBUG("Bar%llu:0x%llx, memory:%d, len:0x%x, ex:0x%llx\n", i, + (*(config->AccessRanges))[i].RangeStart.QuadPart, + (*(config->AccessRanges))[i].RangeInMemory, + (*(config->AccessRanges))[i].RangeLength, + instance->pci_dev_context.bar_base_addr); + if ((unsigned long long)(*(config->AccessRanges))[i] + .RangeStart.QuadPart != + instance->pci_dev_context.bar_base_addr) { + continue; } - LOG_INFO("get real device id is[0x%x] \n", pci_config.DeviceID); - }; -#endif + if (!(*(config->AccessRanges))[i].RangeInMemory) { + LOG_INFO( + "access range number continue:%d, is not memery\n", + i); + continue; + } - instance->pci_dev_context.slot_number = (U64)config->SlotNumber; - instance->pci_dev_context.device_id = pci_config.DeviceID; - instance->pci_dev_context.vendor_id = pci_config.VendorID; - instance->pci_dev_context.sub_vendor_id = pci_config.u.type0.SubVendorID; - instance->pci_dev_context.sub_device_id = pci_config.u.type0.SubSystemID; - - base_addr = pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX]; - if (!PS3_CHECK_BAR_MEMORYSPACE(base_addr)) { - LOG_ERROR("Bar%d is not memory space\n", PS3_VALID_MEMORY_BAR_INDEX); - return -PS3_FAILED; - } - - if (PS3_CHECK_BAR_64BIT(base_addr)) { - instance->pci_dev_context.bar_base_addr = - PS3_GET_BAR_BASE_ADDR(base_addr); - base_addr = pci_config.u.type0.BaseAddresses[PS3_VALID_MEMORY_BAR_INDEX + 1]; - instance->pci_dev_context.bar_base_addr |= ((U64)base_addr) << 32; - } - else { - instance->pci_dev_context.bar_base_addr = - PS3_GET_BAR_BASE_ADDR(base_addr); - } - - ps3_pci_irq_type_get(instance, &pci_config); - - if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSIX) { - instance->pci_dev_context.irq_vec_count = ps3_pci_msix_vec_count(instance, &pci_config); - } - else if (instance->pci_dev_context.pci_irq_type == PS3_PCI_IRQ_MSI) { - instance->pci_dev_context.irq_vec_count = ps3_pci_msi_vec_count(instance, &pci_config); - } - else { - instance->pci_dev_context.irq_vec_count = 1; - } - - LOG_INFO("vid:%x, devid:%x, sub_vid:%x, sub_devid:%x, bar_base:0x%llx, irq_type:%d, vec_count:%d\n", - instance->pci_dev_context.vendor_id, - instance->pci_dev_context.device_id, - instance->pci_dev_context.sub_vendor_id, - instance->pci_dev_context.sub_device_id, - instance->pci_dev_context.bar_base_addr, - instance->pci_dev_context.pci_irq_type, - instance->pci_dev_context.irq_vec_count); - - return PS3_SUCCESS; -}; + instance->reg_set = (struct Ps3Fifo *)StorPortGetDeviceBase( + instance, config->AdapterInterfaceType, + config->SystemIoBusNumber, + (*(config->AccessRanges))[i].RangeStart, + (*(config->AccessRanges))[i].RangeLength, 0); -static S32 ps3_pci_map_reg(struct ps3_instance *instance, PPORT_CONFIGURATION_INFORMATION config) -{ - S32 ret = -PS3_FAILED; - ULong i = 0; - - if (config->NumberOfAccessRanges <= 0) { - LOG_ERROR("valid access range is 0\n"); - goto l_out; - } - - if (config->AdapterInterfaceType != PCIBus) { - LOG_ERROR("adapter interface type is not PCIBus\n"); - goto l_out; - } - - for (i = 0; i < config->NumberOfAccessRanges; i++) { - - LOG_DEBUG("Bar%llu:0x%llx, memory:%d, len:0x%x, ex:0x%llx\n", i, - (*(config->AccessRanges))[i].RangeStart.QuadPart, (*(config->AccessRanges))[i].RangeInMemory, - (*(config->AccessRanges))[i].RangeLength, - instance->pci_dev_context.bar_base_addr); - if ((U64)(*(config->AccessRanges))[i].RangeStart.QuadPart != instance->pci_dev_context.bar_base_addr) { - continue; - } - - if (!(*(config->AccessRanges))[i].RangeInMemory) { - LOG_INFO("access range number continue:%d, is not memery\n", i); - continue; - } - - instance->reg_set = (Ps3Fifo_s*)StorPortGetDeviceBase(instance, - config->AdapterInterfaceType, - config->SystemIoBusNumber, - (*(config->AccessRanges))[i].RangeStart, - (*(config->AccessRanges))[i].RangeLength, - 0); - - if (instance->reg_set != NULL) { - ret = PS3_SUCCESS; - } - - break; - } + if (instance->reg_set != NULL) + ret = PS3_SUCCESS; + + break; + } l_out: - LOG_INFO("map reg:%d,reg:%p\n", ret, instance->reg_set); - return ret; + LOG_INFO("map reg:%d,reg:%p\n", ret, instance->reg_set); + return ret; } static void ps3_pci_unmap_reg(struct ps3_instance *instance) { - if (instance->reg_set != NULL) { - StorPortFreeDeviceBase(instance, instance->reg_set); - instance->reg_set = NULL; - } + if (instance->reg_set != NULL) { + StorPortFreeDeviceBase(instance, instance->reg_set); + instance->reg_set = NULL; + } } -static S32 __ps3_pci_find_capability(PPCI_COMMON_CONFIG pci_config, S32 cap_id) +static int __ps3_pci_find_capability(PPCI_COMMON_CONFIG pci_config, int cap_id) { - S32 pos = 0; - U8 *config_base_addr = (U8*)pci_config; - U8 cap_offset = 0; - PPCI_CAPABILITIES_HEADER cap_header = NULL; - - if (PCI_CONFIGURATION_TYPE(pci_config)) { - LOG_ERROR("there is not agent device\n"); - goto l_out; - } - - if ((pci_config->Status & PCI_STATUS_CAPABILITIES_LIST) == 0) { - LOG_ERROR("capability pointer invalid\n"); - goto l_out; - } - - cap_offset = pci_config->u.type0.CapabilitiesPtr; - while (cap_offset != 0) { - cap_header = (PPCI_CAPABILITIES_HEADER)(config_base_addr + cap_offset); - if (cap_header->CapabilityID == 0) { - cap_offset = cap_header->Next; - continue; - } - - if (cap_header->CapabilityID == (U8)cap_id) { - pos = cap_offset; - break; - - } - cap_offset = cap_header->Next; - }; + int pos = 0; + unsigned char *config_base_addr = (unsigned char *)pci_config; + unsigned char cap_offset = 0; + PPCI_CAPABILITIES_HEADER cap_header = NULL; + + if (PCI_CONFIGURATION_TYPE(pci_config)) { + LOG_ERROR("there is not agent device\n"); + goto l_out; + } + + if ((pci_config->Status & PCI_STATUS_CAPABILITIES_LIST) == 0) { + LOG_ERROR("capability pointer invalid\n"); + goto l_out; + } + + cap_offset = pci_config->u.type0.CapabilitiesPtr; + while (cap_offset != 0) { + cap_header = (PPCI_CAPABILITIES_HEADER)(config_base_addr + + cap_offset); + if (cap_header->CapabilityID == 0) { + cap_offset = cap_header->Next; + continue; + } + + if (cap_header->CapabilityID == (unsigned char)cap_id) { + pos = cap_offset; + break; + } + cap_offset = cap_header->Next; + }; l_out: - return pos; + return pos; } -static void ps3_pci_irq_type_get(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) +static void ps3_pci_irq_type_get(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config) { - U8 *config_base_addr = (U8*)pci_config; - U16 data_u16 = 0; - S32 pos = 0; - - instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_LEGACY; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); - if ( pos != 0) { - data_u16 = *( (U16*)(config_base_addr + pos + PCI_MSIX_FLAGS) ); - - for (size_t i = 0; i < 4; i++) - { - U8 tmp = *((U8*)(config_base_addr + pos + i)); - LOG_DEBUG("%d:%d:%x\n", pos, i, tmp); - } - - if ((data_u16 & PCI_MSIX_FLAGS_ENABLE) == PCI_MSIX_FLAGS_ENABLE) { - instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_MSIX; - goto l_out; - } - } - - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); - if (pos != 0) { - data_u16 = *((U16*)(config_base_addr + pos + PCI_MSI_FLAGS)); - if ( (data_u16 & PCI_MSI_FLAGS_ENABLE) == PCI_MSI_FLAGS_ENABLE) { - instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_MSI; - goto l_out; - } - } + unsigned char *config_base_addr = (unsigned char *)pci_config; + unsigned short data_u16 = 0; + int pos = 0; + + instance->pci_dev_context.pci_irq_type = PS3_PCI_IRQ_LEGACY; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); + if (pos != 0) { + data_u16 = *((unsigned short *)(config_base_addr + pos + + PCI_MSIX_FLAGS)); + + for (size_t i = 0; i < 4; i++) { + unsigned char tmp = *( + (unsigned char *)(config_base_addr + pos + i)); + + LOG_DEBUG("%d:%d:%x\n", pos, i, tmp); + } + + if ((data_u16 & PCI_MSIX_FLAGS_ENABLE) == + PCI_MSIX_FLAGS_ENABLE) { + instance->pci_dev_context.pci_irq_type = + PS3_PCI_IRQ_MSIX; + goto l_out; + } + } + + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); + if (pos != 0) { + data_u16 = *((unsigned short *)(config_base_addr + pos + + PCI_MSI_FLAGS)); + if ((data_u16 & PCI_MSI_FLAGS_ENABLE) == PCI_MSI_FLAGS_ENABLE) { + instance->pci_dev_context.pci_irq_type = + PS3_PCI_IRQ_MSI; + goto l_out; + } + } l_out: - return; + return; } -void ps3_pci_intx(struct ps3_instance *instance, U8 enable) +void ps3_pci_intx(struct ps3_instance *instance, unsigned char enable) { - U16 pci_command = 0; - U16 pci_command_new = 0; - if (ps3_pci_read_config_word(instance, PCI_COMMAND, &pci_command) != PS3_SUCCESS) { - goto l_out; - } - - if (enable) { - pci_command_new = pci_command & ~PCI_COMMAND_INTX_DISABLE; - } - else { - pci_command_new = pci_command | PCI_COMMAND_INTX_DISABLE; - } - - if (pci_command_new != pci_command) { - ps3_pci_write_config_word(instance, PCI_COMMAND, pci_command_new); - } + unsigned short pci_command = 0; + unsigned short pci_command_new = 0; + + if (ps3_pci_read_config_word(instance, PCI_COMMAND, &pci_command) != + PS3_SUCCESS) { + goto l_out; + } + + if (enable) + pci_command_new = pci_command & ~PCI_COMMAND_INTX_DISABLE; + else + pci_command_new = pci_command | PCI_COMMAND_INTX_DISABLE; + + if (pci_command_new != pci_command) { + ps3_pci_write_config_word(instance, PCI_COMMAND, + pci_command_new); + } l_out: - return; + return; } -static U16 ps3_pci_msix_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) +static unsigned short ps3_pci_msix_vec_count(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config) { - U8 *config_base_addr = (U8*)pci_config; - S32 pos = 0; - U16 msix_vec_count = 0; - U16 data_u16 = 0; + unsigned char *config_base_addr = (unsigned char *)pci_config; + int pos = 0; + unsigned short msix_vec_count = 0; + unsigned short data_u16 = 0; - (void)instance; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); - if (pos != 0) { - data_u16 = *((U16*)(config_base_addr + pos + PCI_MSIX_FLAGS)); - } + (void)instance; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSIX); + if (pos != 0) + data_u16 = *((unsigned short *)(config_base_addr + pos + + PCI_MSIX_FLAGS)); - msix_vec_count = ((data_u16 & PCI_MSIX_FLAGS_QSIZE) + 1); + msix_vec_count = ((data_u16 & PCI_MSIX_FLAGS_QSIZE) + 1); - return msix_vec_count; + return msix_vec_count; } -static U16 ps3_pci_msi_vec_count(struct ps3_instance *instance, PPCI_COMMON_CONFIG pci_config) +static unsigned short ps3_pci_msi_vec_count(struct ps3_instance *instance, + PPCI_COMMON_CONFIG pci_config) { - U8 *config_base_addr = (U8*)pci_config; - S32 pos = 0; - U16 msi_vec_count = 0; - U16 data_u16 = 0; + unsigned char *config_base_addr = (unsigned char *)pci_config; + int pos = 0; + unsigned short msi_vec_count = 0; + unsigned short data_u16 = 0; - (void)instance; - pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); - if (pos != 0) { - data_u16 = *((U16*)(config_base_addr + pos + PCI_MSI_FLAGS)); - } + (void)instance; + pos = __ps3_pci_find_capability(pci_config, PCI_CAP_ID_MSI); + if (pos != 0) + data_u16 = *((unsigned short *)(config_base_addr + pos + + PCI_MSI_FLAGS)); - msi_vec_count = 1 << ((data_u16 & PCI_MSI_FLAGS_QMASK) >> 1); + msi_vec_count = 1 << ((data_u16 & PCI_MSI_FLAGS_QMASK) >> 1); - return data_u16; + return data_u16; } #endif -S32 ps3_pci_find_capability(struct ps3_instance *instance, S32 cap_id) +int ps3_pci_find_capability(struct ps3_instance *instance, int cap_id) { - S32 pos = 0; + int pos = 0; #ifdef _WINDOWS - PCI_COMMON_CONFIG pci_config = { 0 }; - U32 len = 0; + PCI_COMMON_CONFIG pci_config = { 0 }; + unsigned int len = 0; - len = (U32)StorPortGetBusData(instance, - PCIConfiguration, - (ULong)instance->bus_number, - (ULong)instance->pci_dev_context.slot_number, - (void*)&pci_config, - (ULong)sizeof(pci_config)); + len = (unsigned int)StorPortGetBusData( + instance, PCIConfiguration, (unsigned long)instance->bus_number, + (unsigned long)instance->pci_dev_context.slot_number, + (void *)&pci_config, (unsigned long)sizeof(pci_config)); - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - goto l_out; - } + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + goto l_out; + } - pos = __ps3_pci_find_capability(&pci_config, cap_id); + pos = __ps3_pci_find_capability(&pci_config, cap_id); l_out: #else pos = pci_find_capability(instance->pdev, cap_id); #endif - return pos; + return pos; } -S32 ps3_pci_read_config_word(struct ps3_instance *instance, U32 offset, U16 *val) +int ps3_pci_read_config_word(struct ps3_instance *instance, unsigned int offset, + unsigned short *val) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; #ifdef _WINDOWS - PCI_COMMON_CONFIG pci_config = { 0 }; - U32 len = 0; - U8 *config_base_addr = (U8*)&pci_config; + PCI_COMMON_CONFIG pci_config = { 0 }; + unsigned int len = 0; + unsigned char *config_base_addr = (unsigned char *)&pci_config; - len = (U32)StorPortGetBusData(instance, - PCIConfiguration, - (ULong)instance->bus_number, - (ULong)instance->pci_dev_context.slot_number, - (void*)&pci_config, - (ULong)sizeof(pci_config)); + len = (unsigned int)StorPortGetBusData( + instance, PCIConfiguration, (unsigned long)instance->bus_number, + (unsigned long)instance->pci_dev_context.slot_number, + (void *)&pci_config, (unsigned long)sizeof(pci_config)); - if (len == 0 || len == 2) { - LOG_ERROR("get bus data failed,cfg length:%d\n", len); - goto l_out; - } + if (len == 0 || len == 2) { + LOG_ERROR("get bus data failed,cfg length:%d\n", len); + goto l_out; + } - *val = *( (U16*)(config_base_addr + offset) ); - ret = PS3_SUCCESS; + *val = *((unsigned short *)(config_base_addr + offset)); + ret = PS3_SUCCESS; l_out: #else ret = pci_read_config_word(instance->pdev, offset, val); #endif - LOG_INFO("read config word :%d\n", ret); - return ret; + LOG_INFO("read config word :%d\n", ret); + return ret; } -S32 ps3_pci_write_config_word(struct ps3_instance *instance, U32 offset, U16 val) +int ps3_pci_write_config_word(struct ps3_instance *instance, + unsigned int offset, unsigned short val) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; #ifdef _WINDOWS - U32 len = 0; - len = (U32)StorPortSetBusDataByOffset(instance, - PCIConfiguration, - (ULong)instance->bus_number, - (ULong)instance->pci_dev_context.slot_number, - (void*)&val, - (ULong)offset, - (ULong)sizeof(U16) - ); - - if (len == sizeof(U16)) { - ret = PS3_SUCCESS; - } + unsigned int len = 0; + + len = (unsigned int)StorPortSetBusDataByOffset( + instance, PCIConfiguration, (unsigned long)instance->bus_number, + (unsigned long)instance->pci_dev_context.slot_number, + (void *)&val, (unsigned long)offset, + (unsigned long)sizeof(unsigned short)); + + if (len == sizeof(unsigned short)) + ret = PS3_SUCCESS; #else - ret = pci_write_config_word(instance->pdev, offset, - val); + ret = pci_write_config_word(instance->pdev, offset, val); #endif - LOG_INFO("write config word :%d\n", ret); - return ret; + LOG_INFO("write config word :%d\n", ret); + return ret; } -void ps3_reg_write_u64(struct ps3_instance *instance, U64 val, void *reg) +void ps3_reg_write_u64(struct ps3_instance *instance, unsigned long long val, + void *reg) { - (void)instance; #ifndef _WINDOWS #if defined(writeq) && defined(CONFIG_64BIT) - writeq(val, reg); + (void)instance; + writeq(val, reg); #else - ULong flags; - ps3_spin_lock_irqsave(&instance->req_queue_lock, &flags); - writel((U32)(val & 0xffffffff), reg); - writel((U32)(val >> 32), reg + 0x4UL); - ps3_spin_unlock_irqrestore(&instance->req_queue_lock, flags); + unsigned long flags; + + ps3_spin_lock_irqsave(&instance->req_queue_lock, &flags); + writel((unsigned int)(val & 0xffffffff), reg); + writel((unsigned int)(val >> 32), reg + 0x4UL); + ps3_spin_unlock_irqrestore(&instance->req_queue_lock, flags); #endif #else - StorPortWriteRegisterUlong64(instance, reg, val); + StorPortWriteRegisterUlong64(instance, reg, val); #endif - } -U64 ps3_reg_read_u64(struct ps3_instance *instance, void *reg) +unsigned long long ps3_reg_read_u64(struct ps3_instance *instance, void *reg) { - U64 value = 0; - (void)instance; + unsigned long long value = 0; + (void)instance; #ifndef _WINDOWS #if defined(readq) && defined(CONFIG_64BIT) - value = readq(reg); + value = readq(reg); #else - value = (((U64)readl(reg + 0x4UL) << 32) | - (U64)readl(reg)); + value = (((unsigned long long)readl(reg + 0x4UL) << 32) | + (unsigned long long)readl(reg)); #endif #else - value = StorPortReadRegisterUlong64(instance, reg); + value = StorPortReadRegisterUlong64(instance, reg); #endif - return value; + return value; } -void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, ULong reg_bar) +void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, unsigned long reg_bar) { resource_size_t base_addr = 0; base_addr = pci_resource_start(pdev, reg_bar); - return ioremap(base_addr,PS3_REGISTER_SET_SIZE); -} \ No newline at end of file + return ioremap(base_addr, PS3_REGISTER_SET_SIZE); +} diff --git a/drivers/scsi/linkdata/ps3stor/ps3_pci.h b/drivers/scsi/linkdata/ps3stor/ps3_pci.h index c00d0d5ea7fe..fe555e1f8ff4 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_pci.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_pci.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_PCI_H_ #define _PS3_PCI_H_ @@ -8,61 +8,59 @@ #define PCI_CAP_ID_MSIX PCI_CAPABILITY_ID_MSIX #define PCI_CAP_ID_MSI PCI_CAPABILITY_ID_MSI -#define PCI_MSIX_FLAGS_ENABLE 0x8000 -#define PCI_MSIX_FLAGS 2 -#define PCI_MSI_FLAGS 2 -#define PCI_MSI_FLAGS_ENABLE 0x0001 -#define PCI_COMMAND_INTX_DISABLE 0x400 -#define PCI_COMMAND 0x04 -#define PCI_STATUS 0x06 -#define PCI_STATUS_INTERRUPT 0x08 -#define PCI_MSIX_FLAGS_QSIZE 0x07FF -#define PCI_MSI_FLAGS_QMASK 0x000e - -#else -#include "ps3_types.h" +#define PCI_MSIX_FLAGS_ENABLE 0x8000 +#define PCI_MSIX_FLAGS 2 +#define PCI_MSI_FLAGS 2 +#define PCI_MSI_FLAGS_ENABLE 0x0001 +#define PCI_COMMAND_INTX_DISABLE 0x400 +#define PCI_COMMAND 0x04 +#define PCI_STATUS 0x06 +#define PCI_STATUS_INTERRUPT 0x08 +#define PCI_MSIX_FLAGS_QSIZE 0x07FF +#define PCI_MSI_FLAGS_QMASK 0x000e #endif #ifndef _WINDOWS #if defined PS3_HARDWARE_ASIC #include "ps3_ioc_manager.h" #endif -#endif +#endif struct ps3_instance; #ifdef _WINDOWS struct ps3_pci_context { - U64 slot_number; - U16 vendor_id; - U16 device_id; - U16 sub_vendor_id; - U16 sub_device_id; - - U64 bar_base_addr; - U16 irq_vec_count; - U16 valid_irq_count; - U8 pci_irq_type; + unsigned long long slot_number; + unsigned short vendor_id; + unsigned short device_id; + unsigned short sub_vendor_id; + unsigned short sub_device_id; + unsigned long long bar_base_addr; + unsigned short irq_vec_count; + unsigned short valid_irq_count; + unsigned char pci_irq_type; }; -S32 ps3_pci_init(struct ps3_instance *instance, void *config); +int ps3_pci_init(struct ps3_instance *instance, void *config); void ps3_pci_exit(struct ps3_instance *instance); -void ps3_pci_intx(struct ps3_instance *instance, U8 enable); +void ps3_pci_intx(struct ps3_instance *instance, unsigned char enable); #endif +int ps3_pci_find_capability(struct ps3_instance *instance, int cap_id); -S32 ps3_pci_find_capability(struct ps3_instance *instance, S32 cap_id); - -S32 ps3_pci_read_config_word(struct ps3_instance *instance, U32 offset, U16 *val); +int ps3_pci_read_config_word(struct ps3_instance *instance, unsigned int offset, + unsigned short *val); -S32 ps3_pci_write_config_word(struct ps3_instance *instance, U32 offset, U16 val); +int ps3_pci_write_config_word(struct ps3_instance *instance, + unsigned int offset, unsigned short val); -void ps3_reg_write_u64(struct ps3_instance *instance, U64 val, void *reg); +void ps3_reg_write_u64(struct ps3_instance *instance, unsigned long long val, + void *reg); -U64 ps3_reg_read_u64(struct ps3_instance *instance, void *reg); +unsigned long long ps3_reg_read_u64(struct ps3_instance *instance, void *reg); -void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, ULong reg_bar); +void __iomem *ps3_reg_set_ioremap(struct pci_dev *pdev, unsigned long reg_bar); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c index 9bf53834108d..6768864e5619 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.c @@ -1,5 +1,4 @@ - - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_platform_utils.h" #include "ps3_instance_manager.h" #include "ps3_mgr_channel.h" @@ -7,94 +6,84 @@ #ifndef _WINDOWS #include #endif +#include "ps3_kernel_version.h" + #ifdef _WINDOWS -S32 ps3_dma_free( - struct ps3_instance *instance, - size_t length, - void *buffer -) +int ps3_dma_free(struct ps3_instance *instance, size_t length, void *buffer) { - S32 ret = PS3_SUCCESS; - ULong status; - - if (buffer == NULL || length == 0) { - ret = -PS3_FAILED; - goto l_out; - } - - status = StorPortFreeContiguousMemorySpecifyCache(instance, - buffer, - length, - MmCached); - - if (status != STOR_STATUS_SUCCESS) { - ret = -PS3_FAILED; - } + int ret = PS3_SUCCESS; + unsigned long status; + + if (buffer == NULL || length == 0) { + ret = -PS3_FAILED; + goto l_out; + } + + status = StorPortFreeContiguousMemorySpecifyCache(instance, buffer, + length, MmCached); + + if (status != STOR_STATUS_SUCCESS) + ret = -PS3_FAILED; l_out: - return ret; + return ret; } -S32 ps3_dma_alloc( - struct ps3_instance *instance, - size_t length, - void **buffer, - U64 *phy_addr -) +int ps3_dma_alloc(struct ps3_instance *instance, size_t length, void **buffer, + unsigned long long *phy_addr) { - S32 ret = PS3_SUCCESS; - ULong len; - ULong status; - PHYSICAL_ADDRESS minPhysicalAddress; - PHYSICAL_ADDRESS maxPhysicalAddress; - PHYSICAL_ADDRESS boundaryPhysicalAddress; - STOR_PHYSICAL_ADDRESS PhysicalAddress; - - minPhysicalAddress.QuadPart = 0; - maxPhysicalAddress.QuadPart = 0xFFFFFFFFFFFF; - boundaryPhysicalAddress.QuadPart = 0; - - status = StorPortAllocateContiguousMemorySpecifyCacheNode(instance, - length, - minPhysicalAddress, - maxPhysicalAddress, - boundaryPhysicalAddress, - MmCached, - MM_ANY_NODE_OK, - buffer); - - if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("alloc dma buffer failed, length:%d, status:0x%x\n", length, status); - ret = -PS3_FAILED; - goto l_out; - } - - PhysicalAddress = StorPortGetPhysicalAddress(instance, NULL, *buffer, &len); - *phy_addr = (U64)PhysicalAddress.QuadPart; - if (PhysicalAddress.QuadPart == 0) { - LOG_ERROR("dma buffer remap fail\n"); - ps3_dma_free(instance, length, *buffer); - *buffer = NULL; - ret = -PS3_FAILED; - } + int ret = PS3_SUCCESS; + unsigned long len; + unsigned long status; + PHYSICAL_ADDRESS minPhysicalAddress; + PHYSICAL_ADDRESS maxPhysicalAddress; + PHYSICAL_ADDRESS boundaryPhysicalAddress; + STOR_PHYSICAL_ADDRESS PhysicalAddress; + + minPhysicalAddress.QuadPart = 0; + maxPhysicalAddress.QuadPart = 0xFFFFFFFFFFFF; + boundaryPhysicalAddress.QuadPart = 0; + + status = StorPortAllocateContiguousMemorySpecifyCacheNode( + instance, length, minPhysicalAddress, maxPhysicalAddress, + boundaryPhysicalAddress, MmCached, MM_ANY_NODE_OK, buffer); + + if (status != STOR_STATUS_SUCCESS) { + LOG_ERROR("alloc dma buffer failed, length:%d, status:0x%x\n", + length, status); + ret = -PS3_FAILED; + goto l_out; + } + + PhysicalAddress = + StorPortGetPhysicalAddress(instance, NULL, *buffer, &len); + *phy_addr = (unsigned long long)PhysicalAddress.QuadPart; + if (PhysicalAddress.QuadPart == 0) { + LOG_ERROR("dma buffer remap fail\n"); + ps3_dma_free(instance, length, *buffer); + *buffer = NULL; + ret = -PS3_FAILED; + } l_out: - return ret; + return ret; } #endif -void *ps3_kcalloc(struct ps3_instance *instance, U32 blocks, U32 block_size) +void *ps3_kcalloc(struct ps3_instance *instance, unsigned int blocks, + unsigned int block_size) { - void *ret = NULL; + void *ret = NULL; #ifndef _WINDOWS (void)instance; - ret = kcalloc(blocks, block_size, GFP_KERNEL); + ret = kcalloc(blocks, block_size, GFP_KERNEL); #else - ULong status = StorPortAllocatePool(instance, - blocks * block_size, 'd3sp', &ret); + unsigned long status = StorPortAllocatePool( + instance, blocks * block_size, 'd3sp', &ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", PS3_HOST(instance), status); + LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", + PS3_HOST(instance), status); ret = NULL; } else { memset(ret, 0, blocks * block_size); @@ -103,31 +92,32 @@ void *ps3_kcalloc(struct ps3_instance *instance, U32 blocks, U32 block_size) #endif if (ret == NULL) { - LOG_ERROR("host_no:%u, memory:%u %u alloc failed\n", PS3_HOST(instance), blocks, block_size); + LOG_ERROR("host_no:%u, memory:%u %u alloc failed\n", + PS3_HOST(instance), blocks, block_size); } - return ret; + return ret; } void ps3_kfree(struct ps3_instance *instance, void *buffer) { #ifndef _WINDOWS (void)instance; - if(buffer != NULL){ - kfree(buffer); - } + if (buffer != NULL) + kfree(buffer); #else - ULong status = StorPortFreePool(instance, buffer); - if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", PS3_HOST(instance), status); - } + unsigned long status = StorPortFreePool(instance, buffer); -#endif + if (status != STOR_STATUS_SUCCESS) { + LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", + PS3_HOST(instance), status); + } - return; +#endif } -void *ps3_kzalloc(struct ps3_instance *instance, U32 size) { +void *ps3_kzalloc(struct ps3_instance *instance, unsigned int size) +{ return ps3_kcalloc(instance, 1, size); } @@ -137,28 +127,29 @@ void ps3_vfree(struct ps3_instance *instance, void *buffer) (void)instance; vfree(buffer); #else - ULong status = StorPortFreePool(instance, buffer); + unsigned long status = StorPortFreePool(instance, buffer); + if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", PS3_HOST(instance), status); + LOG_ERROR("host_no:%u, memory free failed, status0x%x\n", + PS3_HOST(instance), status); } #endif - - return; } -void *ps3_vzalloc(struct ps3_instance *instance, U32 size) +void *ps3_vzalloc(struct ps3_instance *instance, unsigned int size) { void *ret = NULL; #ifndef _WINDOWS (void)instance; ret = vzalloc(size); #else - ULong status = StorPortAllocatePool(instance, - size, 'd3sp', &ret); + unsigned long status = + StorPortAllocatePool(instance, size, 'd3sp', &ret); if (status != STOR_STATUS_SUCCESS) { - LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", PS3_HOST(instance), status); + LOG_ERROR("host_no:%d, memory alloc failed, status0x%x\n", + PS3_HOST(instance), status); ret = NULL; } else { memset(ret, 0, size); @@ -167,38 +158,39 @@ void *ps3_vzalloc(struct ps3_instance *instance, U32 size) #endif if (ret == NULL) { - LOG_ERROR("host_no:%u, memory:%u alloc failed\n", PS3_HOST(instance), size); + LOG_ERROR("host_no:%u, memory:%u alloc failed\n", + PS3_HOST(instance), size); } return ret; } -S32 ps3_wait_for_completion_timeout(void *sync_done, ULong time_out) +int ps3_wait_for_completion_timeout(void *sync_done, unsigned long time_out) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; #ifdef _WINDOWS NTSTATUS wait_ret = STATUS_SUCCESS; LARGE_INTEGER win_timeout = { 0 }; + if (time_out > 0) { - win_timeout.QuadPart = (S64)(time_out * (-10000000LL)); - wait_ret = KeWaitForSingleObject(sync_done, Executive, - KernelMode, FALSE, &win_timeout); - } - else { + win_timeout.QuadPart = (long long)(time_out * (-10000000LL)); + wait_ret = KeWaitForSingleObject( + sync_done, Executive, KernelMode, FALSE, &win_timeout); + } else { wait_ret = KeWaitForSingleObject(sync_done, Executive, - KernelMode, FALSE, NULL); + KernelMode, FALSE, NULL); } - if (wait_ret == STATUS_TIMEOUT) { + if (wait_ret == STATUS_TIMEOUT) ret = -PS3_TIMEOUT; - } #else - U16 timeout = 0; + unsigned short timeout = 0; + if (time_out > 0) { - timeout = wait_for_completion_timeout((struct completion *)sync_done, time_out * HZ); - if (timeout == 0) { + timeout = wait_for_completion_timeout( + (struct completion *)sync_done, time_out * HZ); + if (timeout == 0) ret = -PS3_TIMEOUT; - } } else { wait_for_completion((struct completion *)sync_done); } @@ -206,49 +198,56 @@ S32 ps3_wait_for_completion_timeout(void *sync_done, ULong time_out) return ret; } -S32 ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, struct ps3_cmd *cmd, ULong timeout) { - S32 ret = PS3_SUCCESS; - ULong time_out; +int ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned long timeout) +{ + int ret = PS3_SUCCESS; + unsigned long time_out; #ifdef _WINDOWS (void)instance; - time_out = max((ULong)cmd->time_out, timeout); + time_out = max_t(unsigned long, cmd->time_out, timeout); ret = ps3_wait_for_completion_timeout(&cmd->sync_done, time_out); #else if (cmd->time_out == 0 && cmd->is_interrupt) { ps3_wait_cmd_for_completion_interrupt(instance, cmd); } else { - time_out = max((ULong)cmd->time_out, timeout); - ret = ps3_wait_for_completion_timeout(&cmd->sync_done, time_out); + time_out = max_t(unsigned long, cmd->time_out, timeout); + ret = ps3_wait_for_completion_timeout(&cmd->sync_done, + time_out); } #endif - return ret; + return ret; } -S32 ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev) +int ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev) { #ifdef _WINDOWS - return ps3_scsi_device_get_win(instance, sdev); + return ps3_scsi_device_get_win(instance, sdev); #else (void)instance; - return scsi_device_get(sdev); + return scsi_device_get(sdev); #endif } -void ps3_scsi_device_put(struct ps3_instance *instance, struct scsi_device *sdev) +void ps3_scsi_device_put(struct ps3_instance *instance, + struct scsi_device *sdev) { #ifdef _WINDOWS - ps3_scsi_device_put_win(instance, sdev); + ps3_scsi_device_put_win(instance, sdev); #else (void)instance; - scsi_device_put(sdev); + scsi_device_put(sdev); #endif } #ifndef _WINDOWS -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) +#if defined(PS3_SCSI_DEVICE_LOOKUP) struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, - U32 channel, U32 id, U32 lun) + unsigned int channel, + unsigned int id, + unsigned int lun) { struct scsi_device *sdev = NULL; @@ -256,7 +255,7 @@ struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, if (sdev->sdev_state == SDEV_DEL) continue; if (sdev->channel == channel && sdev->id == id && - sdev->lun == lun) + sdev->lun == lun) return sdev; } @@ -264,7 +263,9 @@ struct scsi_device *__ps3_scsi_device_lookup_check(struct Scsi_Host *shost, } struct scsi_device *ps3_scsi_device_lookup_check(struct Scsi_Host *shost, - U32 channel, U32 id, U32 lun) + unsigned int channel, + unsigned int id, + unsigned int lun) { struct scsi_device *sdev = NULL; unsigned long flags = 0; @@ -282,115 +283,125 @@ struct scsi_device *ps3_scsi_device_lookup_check(struct Scsi_Host *shost, #endif -struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun) +struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char lun) { #ifdef _WINDOWS - (void)lun; - struct scsi_device *sdev = ps3_scsi_device_lookup_win(instance, channel, (U8)target_id); - if (sdev != NULL && sdev->unit_start == 1) { - return sdev; - } - return NULL; + (void)lun; + struct scsi_device *sdev = ps3_scsi_device_lookup_win( + instance, channel, (unsigned char)target_id); + if (sdev != NULL && sdev->unit_start == 1) + return sdev; + return NULL; #else -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,10,0) - return ps3_scsi_device_lookup_check(instance->host, channel, target_id, lun); +#if defined(PS3_SCSI_DEVICE_LOOKUP) + return ps3_scsi_device_lookup_check(instance->host, channel, target_id, + lun); #else return scsi_device_lookup(instance->host, channel, target_id, lun); #endif #endif } -void ps3_scsi_remove_device(struct ps3_instance *instance, struct scsi_device *sdev) +void ps3_scsi_remove_device(struct ps3_instance *instance, + struct scsi_device *sdev) { #ifdef _WINDOWS - ps3_scsi_remove_device_win(instance, sdev); + ps3_scsi_remove_device_win(instance, sdev); #else (void)instance; - scsi_remove_device(sdev); + scsi_remove_device(sdev); #endif } -S32 ps3_scsi_add_device(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun) +int ps3_scsi_add_device(struct ps3_instance *instance, unsigned char channel, + unsigned short target_id, unsigned char lun) { #ifdef _WINDOWS - (void)lun; - return ps3_scsi_add_device_win(instance, channel, (U8)target_id); + (void)lun; + return ps3_scsi_add_device_win(instance, channel, + (unsigned char)target_id); #else - return scsi_add_device(instance->host, channel, target_id, lun); + return scsi_add_device(instance->host, channel, target_id, lun); #endif } -U64 ps3_now_ms_get(void) +unsigned long long ps3_now_ms_get(void) { #ifdef _WINDOWS - LARGE_INTEGER timestamp; - KeQuerySystemTime(×tamp); - return timestamp.QuadPart / 10000; + LARGE_INTEGER timestamp; + + KeQuerySystemTime(×tamp); + return timestamp.QuadPart / 10000; #else return ktime_to_ms(ktime_get_real()); #endif } -U64 ps3_1970_now_ms_get(void) +unsigned long long ps3_1970_now_ms_get(void) { #ifdef _WINDOWS - U64 timestamp; - LARGE_INTEGER timestamp1970; - TIME_FIELDS timefiled; - - timefiled.Year = 1970; - timefiled.Month = 1; - timefiled.Day = 1; - timefiled.Hour = 0; - timefiled.Minute = 0; - timefiled.Second = 0; - timefiled.Milliseconds = 0; - - RtlTimeFieldsToTime(&timefiled, ×tamp1970); - timestamp = ps3_now_ms_get(); - return timestamp - (timestamp1970.QuadPart / 10000); + unsigned long long timestamp; + LARGE_INTEGER timestamp1970; + TIME_FIELDS timefiled; + + timefiled.Year = 1970; + timefiled.Month = 1; + timefiled.Day = 1; + timefiled.Hour = 0; + timefiled.Minute = 0; + timefiled.Second = 0; + timefiled.Milliseconds = 0; + + RtlTimeFieldsToTime(&timefiled, ×tamp1970); + timestamp = ps3_now_ms_get(); + return timestamp - (timestamp1970.QuadPart / 10000); #else - return ps3_now_ms_get(); + return ps3_now_ms_get(); #endif } #ifdef _WINDOWS -S32 ps3_now_format_get(char *buff, S32 buf_len) +int ps3_now_format_get(char *buff, int buf_len) { #ifdef _WINDOWS - LARGE_INTEGER timestamp; - KeQuerySystemTime(×tamp); - LARGE_INTEGER localtime; - TIME_FIELDS timefiled; - - ExSystemTimeToLocalTime(×tamp, &localtime); - RtlTimeToTimeFields(&localtime, &timefiled); - - return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d.%03d", - timefiled.Year, timefiled.Month, timefiled.Day, - timefiled.Hour, timefiled.Minute, timefiled.Second, - timefiled.Milliseconds); + LARGE_INTEGER timestamp; + + KeQuerySystemTime(×tamp); + LARGE_INTEGER localtime; + TIME_FIELDS timefiled; + + ExSystemTimeToLocalTime(×tamp, &localtime); + RtlTimeToTimeFields(&localtime, &timefiled); + + return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d.%03d", + timefiled.Year, timefiled.Month, timefiled.Day, + timefiled.Hour, timefiled.Minute, timefiled.Second, + timefiled.Milliseconds); #else - struct timeval tv; - struct tm td; + struct timeval tv; + struct tm td; - do_gettimeofday(&tv); - time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); + do_gettimeofday(&tv); + time_to_tm(tv.tv_sec, -sys_tz.tz_minuteswest * 60, &td); - return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", - td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, - td.tm_hour, td.tm_min, td.tm_sec); + return snprintf(buff, buf_len, "%04ld-%02d-%02d_%02d:%02d:%02d", + td.tm_year + 1900, td.tm_mon + 1, td.tm_mday, + td.tm_hour, td.tm_min, td.tm_sec); #endif } #endif -U64 ps3_tick_count_get(void) +unsigned long long ps3_tick_count_get(void) { #ifdef _WINDOWS - LARGE_INTEGER tick_count; - LARGE_INTEGER tick_frequency; + LARGE_INTEGER tick_count; + LARGE_INTEGER tick_frequency; - tick_count = KeQueryPerformanceCounter(&tick_frequency); - return (U64)(tick_count.QuadPart * 1000000 / tick_frequency.QuadPart); + tick_count = KeQueryPerformanceCounter(&tick_frequency); + return (unsigned long long)(tick_count.QuadPart * 1000000 / + tick_frequency.QuadPart); #else - return (U64)ktime_to_us(ktime_get_real()); + return (unsigned long long)ktime_to_us(ktime_get_real()); #endif } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h index 2efd0de9b7e0..c9202182f6b1 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_platform_utils.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_PLATFORM_UTILS_H_ #define _PS3_PLATFORM_UTILS_H_ @@ -9,7 +9,9 @@ #include #include #include - +#include "linux/kernel.h" +#include +#include #endif #include "ps3_err_def.h" @@ -21,93 +23,108 @@ struct ps3_cmd; #define scsi_cmnd_cdb(scmnd) ((scmnd)->cmnd) #define scsi_device_private_data(scmnd) (PS3_SDEV_PRI_DATA((scmnd)->device)) #ifdef _WINDOWS -#define scsi_host_data(scmnd) (struct ps3_instance*)((scmnd)->instance) +#define scsi_host_data(scmnd) ((struct ps3_instance *)((scmnd)->instance)) #else -#define scsi_host_data(scmnd) (struct ps3_instance*)((scmnd)->device->host->hostdata) +#define scsi_host_data(scmnd) \ + ((struct ps3_instance *)((scmnd)->device->host->hostdata)) #endif #ifdef _WINDOWS -#define ps3_container_of(ptr, type, member) \ - ((type*)((char*)ptr - offsetof(type,member))) +#define ps3_container_of(ptr, type, member) \ + ((type *)((char *)ptr - offsetof(type, member))) #else #define ps3_container_of container_of #endif #define MAX_MDELAY (1) +#ifndef PS3_FALSE +#define PS3_FALSE (0) +#endif +#ifndef PS3_TRUE +#define PS3_TRUE (1) +#endif +#ifndef PS3_MAX +#define PS3_MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef PS3_MIN +#define PS3_MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif +#ifndef PS3_DESC +#define PS3_DESC(a) 1 +#endif -#ifdef _WINDOWS -typedef struct { - FAST_MUTEX mutex; -}ps3_mutex, *pps3_mutex; +static inline unsigned char ps3_cancel_work_sync(struct work_struct *work) +{ +#if defined(PS3_WORK_FUNC_CHECK) + if (work->func != NULL) + return cancel_work_sync(work); + return PS3_FALSE; #else - -typedef struct mutex ps3_mutex; - + return cancel_work_sync(work); #endif +} -static inline void ps3_mutex_init(ps3_mutex *mutex_lock) +static inline void ps3_mutex_init(struct mutex *mutex_lock) { #ifdef _WINDOWS - ExInitializeFastMutex(&mutex_lock->mutex); + ExInitializeFastMutex(&mutex_lock->mutex); #else mutex_init(mutex_lock); #endif } -static inline void ps3_mutex_destroy(ps3_mutex *mutex_lock) +static inline void ps3_mutex_destroy(struct mutex *mutex_lock) { #ifdef _WINDOWS - (void)mutex_lock; + (void)mutex_lock; #else mutex_destroy(mutex_lock); #endif - return; } -static inline S32 ps3_mutex_lock(ps3_mutex *mtx_lock) +static inline int ps3_mutex_lock(struct mutex *mtx_lock) { - #ifdef _WINDOWS - if (KeGetCurrentIrql() <= APC_LEVEL) { - ExAcquireFastMutex(&mtx_lock->mutex); + if (KeGetCurrentIrql() <= APC_LEVEL) { + ExAcquireFastMutex(&mtx_lock->mutex); - return PS3_SUCCESS; - } - return -PS3_FAILED; + return PS3_SUCCESS; + } + return -PS3_FAILED; #else mutex_lock(mtx_lock); return PS3_SUCCESS; #endif } -static inline S32 ps3_mutex_trylock(ps3_mutex *mutex_lock) +static inline int ps3_mutex_trylock(struct mutex *mutex_lock) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; #ifdef _WINDOWS - if (KeGetCurrentIrql() > APC_LEVEL) { - ret = -PS3_FAILED; - goto l_out; - } + if (KeGetCurrentIrql() > APC_LEVEL) { + ret = -PS3_FAILED; + goto l_out; + } - if (!ExTryToAcquireFastMutex(&mutex_lock->mutex)) { - ret = -PS3_FAILED; - goto l_out; - } + if (!ExTryToAcquireFastMutex(&mutex_lock->mutex)) { + ret = -PS3_FAILED; + goto l_out; + } l_out: #else ret = mutex_trylock(mutex_lock); #endif - return ret; + return ret; } -static inline S32 ps3_mutex_unlock(ps3_mutex *mutex_lock) +static inline int ps3_mutex_unlock(struct mutex *mutex_lock) { #ifdef _WINDOWS - if (KeGetCurrentIrql() <= APC_LEVEL) { - ExReleaseFastMutex(&mutex_lock->mutex); + if (KeGetCurrentIrql() <= APC_LEVEL) { + ExReleaseFastMutex(&mutex_lock->mutex); - return PS3_SUCCESS; - } + return PS3_SUCCESS; + } - return -PS3_FAILED; + return -PS3_FAILED; #else mutex_unlock(mutex_lock); return PS3_SUCCESS; @@ -115,123 +132,121 @@ static inline S32 ps3_mutex_unlock(ps3_mutex *mutex_lock) #endif } +static inline int ps3_atomic_read(atomic_t *value) +{ #ifdef _WINDOWS -typedef struct { - volatile S32 value; -}ps3_atomic32, *pps3_atomic32; - -typedef struct { - volatile S64 value; -}ps3_atomic64, *pps3_atomic64; -#else -typedef atomic_t ps3_atomic32; -typedef atomic64_t ps3_atomic64; -#endif - -static inline S32 ps3_atomic_read(ps3_atomic32 *value) { -#ifdef _WINDOWS - return value->value; + return value->value; #else return atomic_read(value); #endif } -static inline S32 ps3_atomic_dec(ps3_atomic32 *value) { +static inline int ps3_atomic_dec(atomic_t *value) +{ #ifdef _WINDOWS - return (S32)InterlockedDecrement((LONG*)(&value->value)); + return (int)InterlockedDecrement((LONG *)(&value->value)); #else atomic_dec(value); return PS3_SUCCESS; #endif } -static inline S32 ps3_atomic_add(S32 i, ps3_atomic32 *value) { +static inline int ps3_atomic_add(int i, atomic_t *value) +{ #ifdef _WINDOWS - return (S32)_InlineInterlockedAdd((LONG*)&value->value, (LONG)i); + return (int)_InlineInterlockedAdd((LONG *)&value->value, (LONG)i); #else atomic_add(i, value); return PS3_SUCCESS; #endif } -static inline S32 ps3_atomic_sub(S32 i, ps3_atomic32 *value) { +static inline int ps3_atomic_sub(int i, atomic_t *value) +{ #ifdef _WINDOWS - return (S32)_InlineInterlockedAdd((LONG*)&value->value, (LONG)-i); + return (int)_InlineInterlockedAdd((LONG *)&value->value, (LONG)-i); #else atomic_sub(i, value); return PS3_SUCCESS; #endif } -static inline S32 ps3_atomic_cmpxchg(ps3_atomic32 *value, S32 old, S32 cur) +static inline int ps3_atomic_cmpxchg(atomic_t *value, int old, int cur) { #ifdef _WINDOWS - return (S32)InterlockedCompareExchange((LONG*)&value->value, (LONG)cur, (LONG)old); + return (int)InterlockedCompareExchange((LONG *)&value->value, (LONG)cur, + (LONG)old); #else return atomic_cmpxchg(value, cur, old); #endif } -static inline Bool ps3_atomic_add_unless(ps3_atomic32 *value, S32 a, S32 u) { +static inline unsigned char ps3_atomic_add_unless(atomic_t *value, int a, int u) +{ #ifdef _WINDOWS - S32 c = 0; - S32 old = 0; - c = value->value; - while (c != u && - (old = ps3_atomic_cmpxchg(value, c, c + a)) != c) { - c = old; - } + int c = 0; + int old = 0; - return c != u; + c = value->value; + while (c != u && (old = ps3_atomic_cmpxchg(value, c, c + a)) != c) + c = old; + + return c != u; #else return atomic_add_unless(value, a, u); #endif } -static inline S32 ps3_atomic_inc(ps3_atomic32 *value) { +static inline int ps3_atomic_inc(atomic_t *value) +{ #ifdef _WINDOWS - return (S32)InterlockedIncrement((LONG*)(&value->value)); + return (int)InterlockedIncrement((LONG *)(&value->value)); #else atomic_inc(value); return PS3_SUCCESS; #endif } -static inline S32 ps3_atomic_inc_return(ps3_atomic32 *value) { +static inline int ps3_atomic_inc_return(atomic_t *value) +{ #ifdef _WINDOWS - return (S32)InterlockedIncrement((LONG*)(&value->value)); + return (int)InterlockedIncrement((LONG *)(&value->value)); #else return atomic_inc_return(value); #endif } -static inline S32 ps3_atomic_dec_return(ps3_atomic32 *value) { +static inline int ps3_atomic_dec_return(atomic_t *value) +{ #ifdef _WINDOWS - return (S32)InterlockedDecrement((LONG*)(&value->value)); + return (int)InterlockedDecrement((LONG *)(&value->value)); #else return atomic_dec_return(value); #endif } -static inline S64 ps3_atomic64_inc(ps3_atomic64 *value) { +static inline long long ps3_atomic64_inc(atomic64_t *value) +{ #ifdef _WINDOWS - return (S64)InterlockedIncrement64((LONG64*)(&value->value)); + return (long long)InterlockedIncrement64((LONG64 *)(&value->value)); #else atomic64_inc(value); return PS3_SUCCESS; #endif } -static inline S64 ps3_atomic64_inc_return(ps3_atomic64 *value) { +static inline long long ps3_atomic64_inc_return(atomic64_t *value) +{ #ifdef _WINDOWS - return (S64)InterlockedIncrement64((LONG64*)(&value->value)); + return (long long)InterlockedIncrement64((LONG64 *)(&value->value)); #else return atomic64_inc_return(value); #endif } -static inline S64 ps3_atomic64_read(ps3_atomic64 *value) { +static inline long long ps3_atomic64_read(atomic64_t *value) +{ #ifdef _WINDOWS return value->value; #else @@ -239,7 +254,8 @@ static inline S64 ps3_atomic64_read(ps3_atomic64 *value) { #endif } -static inline void ps3_atomic64_set(ps3_atomic64 *value, S64 i) { +static inline void ps3_atomic64_set(atomic64_t *value, long long i) +{ #ifdef _WINDOWS value->value = i; #else @@ -247,7 +263,8 @@ static inline void ps3_atomic64_set(ps3_atomic64 *value, S64 i) { #endif } -static inline void ps3_atomic_set(ps3_atomic32 *value, S32 i) { +static inline void ps3_atomic_set(atomic_t *value, int i) +{ #ifdef _WINDOWS value->value = i; #else @@ -255,279 +272,267 @@ static inline void ps3_atomic_set(ps3_atomic32 *value, S32 i) { #endif } -static inline S64 ps3_atomic64_add(S64 i, ps3_atomic64 *value) { +static inline long long ps3_atomic64_add(long long i, atomic64_t *value) +{ #ifdef _WINDOWS - return (S64)_InlineInterlockedAdd64((LONG64*)&value->value, (LONG64)i); + return (long long)_InlineInterlockedAdd64((LONG64 *)&value->value, + (LONG64)i); #else atomic64_add(i, value); return PS3_SUCCESS; #endif } -static inline S64 ps3_atomic64_dec(ps3_atomic64 *value) { +static inline long long ps3_atomic64_dec(atomic64_t *value) +{ #ifdef _WINDOWS - return (S64)InterlockedDecrement64((LONG64*)&value->value); + return (long long)InterlockedDecrement64((LONG64 *)&value->value); #else atomic64_dec(value); return PS3_SUCCESS; #endif } -#ifdef _WINDOWS -typedef struct { - KSPIN_LOCK lock; -}ps3_spinlock, *pps3_spinlock; -#else -typedef spinlock_t ps3_spinlock; -#endif - -static inline void ps3_spin_lock_init(ps3_spinlock *lock) +static inline void ps3_spin_lock_init(spinlock_t *lock) { #ifdef _WINDOWS - KeInitializeSpinLock(&lock->lock); + KeInitializeSpinLock(&lock->lock); #else spin_lock_init(lock); #endif } -static inline void ps3_spin_lock(ps3_spinlock *lock, ULong*flag) +static inline void ps3_spin_lock(spinlock_t *lock, unsigned long *flag) { #ifdef _WINDOWS - KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); + KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); #else (void)flag; - spin_lock(lock); + spin_lock(lock); #endif } -static inline void ps3_spin_lock_irqsave(ps3_spinlock *lock, ULong *flag) +static inline void ps3_spin_lock_irqsave(spinlock_t *lock, unsigned long *flag) { #ifdef _WINDOWS - KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); + KeAcquireSpinLock(&lock->lock, (PKIRQL)flag); #else - spin_lock_irqsave(lock, *flag); + spin_lock_irqsave(lock, *flag); #endif } -static inline void ps3_spin_unlock(ps3_spinlock *lock, ULong flag) +static inline void ps3_spin_unlock(spinlock_t *lock, unsigned long flag) { #ifdef _WINDOWS - KeReleaseSpinLock(&lock->lock, (KIRQL)flag); + KeReleaseSpinLock(&lock->lock, (KIRQL)flag); #else (void)flag; - spin_unlock(lock); + spin_unlock(lock); #endif } -static inline void ps3_spin_unlock_irqrestore(ps3_spinlock *lock, ULong flag) +static inline void ps3_spin_unlock_irqrestore(spinlock_t *lock, + unsigned long flag) { #ifdef _WINDOWS - KeReleaseSpinLock(&lock->lock, (KIRQL)flag); + KeReleaseSpinLock(&lock->lock, (KIRQL)flag); #else - spin_unlock_irqrestore(lock, flag); + spin_unlock_irqrestore(lock, flag); #endif } -S32 ps3_wait_for_completion_timeout(void *sync_done, ULong Timeout); -S32 ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, - struct ps3_cmd *cmd, ULong timeout); - -#ifdef _WINDOWS -typedef LIST_ENTRY ps3_list_head; -#else -typedef struct list_head ps3_list_head; -#endif +int ps3_wait_for_completion_timeout(void *sync_done, unsigned long Timeout); +int ps3_wait_cmd_for_completion_timeout(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned long timeout); #ifdef _WINDOWS -#define complete(x) KeSetEvent(x, IO_NO_INCREMENT, FALSE); -#define init_completion(x) KeInitializeEvent(x, SynchronizationEvent, FALSE); +#define complete(x) KeSetEvent(x, IO_NO_INCREMENT, FALSE) +#define init_completion(x) KeInitializeEvent(x, SynchronizationEvent, FALSE) -static inline int list_empty(const ps3_list_head* head) +static inline int list_empty(const struct list_head *head) { - return head->Blink == head; + return head->Blink == head; } -#define list_entry(ptr, type, member) \ - CONTAINING_RECORD(ptr, type, member) +#define list_entry(ptr, type, member) CONTAINING_RECORD(ptr, type, member) -#define list_for_each(pos, head) \ +#define list_for_each(pos, head) \ for (pos = (head)->Blink; pos != (head); pos = pos->Blink) -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->Blink, type, member) - -#define list_next_entry(pos, type, member) \ - list_entry((pos)->member.Blink, type, member) - -#define list_for_each_entry(pos, type, head, member) \ - for (pos = list_first_entry(head, type, member); \ - &pos->member != (head); \ - pos = list_next_entry(pos, type, member)) - -#define list_for_each_entry_safe(pos, type, tmp, head, member) \ - for (pos = list_first_entry(head, type, member), \ - tmp = list_next_entry(pos, type, member); \ - &pos->member != (head); \ - pos = tmp, tmp = list_next_entry(tmp, type, member)) - -static inline void INIT_LIST_HEAD(ps3_list_head* list) +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->Blink, type, member) +#define list_next_entry(pos, type, member) \ + list_entry((pos)->member.Blink, type, member) +#define list_for_each_entry(pos, type, head, member) \ + for (pos = list_first_entry(head, type, member); \ + &pos->member != (head); pos = list_next_entry(pos, type, member)) +#define list_for_each_entry_safe(pos, type, tmp, head, member) \ + for (pos = list_first_entry(head, type, member), \ + tmp = list_next_entry(pos, type, member); \ + &pos->member != (head); \ + pos = tmp, tmp = list_next_entry(tmp, type, member)) + +static inline void INIT_LIST_HEAD(struct list_head *list) { - InitializeListHead((PLIST_ENTRY)list); + InitializeListHead((PLIST_ENTRY)list); } -static inline void list_del(ps3_list_head* entry) +static inline void list_del(struct list_head *entry) { - RemoveEntryList((PLIST_ENTRY)entry); + RemoveEntryList((PLIST_ENTRY)entry); } -static inline void list_del_init(ps3_list_head* entry) +static inline void list_del_init(struct list_head *entry) { - list_del(entry); - INIT_LIST_HEAD(entry); + list_del(entry); + INIT_LIST_HEAD(entry); } -static inline void list_add_tail(ps3_list_head* entry, ps3_list_head* head) +static inline void list_add_tail(struct list_head *entry, + struct list_head *head) { - InsertTailList((PLIST_ENTRY)head, (PLIST_ENTRY)entry); + InsertTailList((PLIST_ENTRY)head, (PLIST_ENTRY)entry); } -static inline ps3_list_head* list_remove_head(ps3_list_head* head) +static inline struct list_head *list_remove_head(struct list_head *head) { - return (ps3_list_head*)RemoveHeadList((PLIST_ENTRY)head); + return (struct list_head *)RemoveHeadList((PLIST_ENTRY)head); } -inline S32 kstrtou16(const S8 *s, U32 base, U16 *res) +inline int kstrtou16(const char *s, unsigned int base, unsigned short *res) { - ULong tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); - if (ret != STATUS_SUCCESS) { - goto l_out; - } + unsigned long tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); + + if (ret != STATUS_SUCCESS) + goto l_out; - if (tmp != (U64)(U16)tmp) { - ret = -34; - goto l_out; - } + if (tmp != (unsigned long long)(unsigned short)tmp) { + ret = -34; + goto l_out; + } - *res = (U16)tmp; + *res = (unsigned short)tmp; l_out: - return ret; + return ret; } -inline S32 kstrtoint(const S8 *s, U32 base, S32* res) +inline int kstrtoint(const char *s, unsigned int base, int *res) { - ULong tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); - if (ret != STATUS_SUCCESS) { + unsigned long tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); - } + if (ret != STATUS_SUCCESS) + goto l_out; - if (tmp != (U64)(int)tmp) { - ret = -34; - goto l_out; - } + if (tmp != (unsigned long long)(int)tmp) { + ret = -34; + goto l_out; + } - *res = (int)tmp; + *res = (int)tmp; l_out: - return ret; + return ret; } -inline S32 kstrtouint(const S8 *s, U32 base, U32* res) +inline int kstrtouint(const char *s, unsigned int base, unsigned int *res) { - ULong tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); - if (ret != STATUS_SUCCESS) { - goto l_out; - } + unsigned long tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); - if (tmp != (U64)(U32)tmp) { - ret = -34; - goto l_out; - } + if (ret != STATUS_SUCCESS) + goto l_out; + + if (tmp != (unsigned long long)(unsigned int)tmp) { + ret = -34; + goto l_out; + } - *res = (unsigned int)tmp; + *res = (unsigned int)tmp; l_out: - return ret; + return ret; } -inline S32 kstrtou64(const S8 *s, U64 base, U64* res) +inline int kstrtou64(const char *s, unsigned long long base, + unsigned long long *res) { - ULong tmp = 0; - int ret = RtlCharToInteger(s, base, &tmp); - if (ret != STATUS_SUCCESS) { - goto l_out; - } + unsigned long tmp = 0; + int ret = RtlCharToInteger(s, base, &tmp); - if (tmp != (U64)tmp) { - ret = -34; - goto l_out; - } + if (ret != STATUS_SUCCESS) + goto l_out; - *res = (ULong)tmp; + if (tmp != (unsigned long long)tmp) { + ret = -34; + goto l_out; + } + + *res = (unsigned long)tmp; l_out: - return ret; + return ret; } -S32 ps3_dma_free( - struct ps3_instance *instance, - size_t length, - void *buffer -); +int ps3_dma_free(struct ps3_instance *instance, size_t length, void *buffer); -S32 ps3_dma_alloc( - struct ps3_instance *instance, - size_t length, - void **buffer, - U64 *phy_addr -); +int ps3_dma_alloc(struct ps3_instance *instance, size_t length, void **buffer, + unsigned long long *phy_addr); #endif -static inline void ps3_msleep(U32 ms) +static inline void ps3_msleep(unsigned int ms) { #ifdef _WINDOWS - StorPortStallExecution((ULong)ms*1000); + StorPortStallExecution((unsigned long)ms * 1000); #else msleep(ms); #endif } -static inline void ps3_mdelay(U32 ms) +static inline void ps3_mdelay(unsigned int ms) { #ifndef _WINDOWS - U32 count = (ms/MAX_MDELAY); - U32 remain = (ms%MAX_MDELAY); + unsigned int count = (ms / MAX_MDELAY); + unsigned int remain = (ms % MAX_MDELAY); + do { - udelay(1000*MAX_MDELAY); + udelay(1000 * MAX_MDELAY); count--; - } while(count); + } while (count); - if(remain != 0){ + if (remain != 0) udelay(remain * 1000); - } #else - StorPortStallExecution((ULong)ms*1000); + StorPortStallExecution((unsigned long)ms * 1000); #endif } -void *ps3_kcalloc(struct ps3_instance *instance, U32 blocks, U32 block_size); +void *ps3_kcalloc(struct ps3_instance *instance, unsigned int blocks, + unsigned int block_size); void ps3_kfree(struct ps3_instance *instance, void *buffer); -void *ps3_kzalloc(struct ps3_instance *instance, U32 size); +void *ps3_kzalloc(struct ps3_instance *instance, unsigned int size); void ps3_vfree(struct ps3_instance *instance, void *buffer); -void *ps3_vzalloc(struct ps3_instance *instance, U32 size); - -int ps3_scsi_device_get(struct ps3_instance *instance, struct scsi_device *sdev); -void ps3_scsi_device_put(struct ps3_instance *instance, struct scsi_device *sdev); -struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun); -void ps3_scsi_remove_device(struct ps3_instance *instance, struct scsi_device *sdev); -S32 ps3_scsi_add_device(struct ps3_instance *instance, U8 channel, U16 target_id, U8 lun); - -U64 ps3_now_ms_get(void); -#ifdef _WINDOWS -S32 ps3_now_format_get(char *buff, S32 buf_len); -#endif -U64 ps3_1970_now_ms_get(void); -U64 ps3_tick_count_get(void); +void *ps3_vzalloc(struct ps3_instance *instance, unsigned int size); + +int ps3_scsi_device_get(struct ps3_instance *instance, + struct scsi_device *sdev); +void ps3_scsi_device_put(struct ps3_instance *instance, + struct scsi_device *sdev); +struct scsi_device *ps3_scsi_device_lookup(struct ps3_instance *instance, + unsigned char channel, + unsigned short target_id, + unsigned char lun); +void ps3_scsi_remove_device(struct ps3_instance *instance, + struct scsi_device *sdev); +int ps3_scsi_add_device(struct ps3_instance *instance, unsigned char channel, + unsigned short target_id, unsigned char lun); + +unsigned long long ps3_now_ms_get(void); +#ifdef _WINDOWS +int ps3_now_format_get(char *buff, int buf_len); +#endif +unsigned long long ps3_1970_now_ms_get(void); +unsigned long long ps3_tick_count_get(void); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_qos.c b/drivers/scsi/linkdata/ps3stor/ps3_qos.c index eba1220f8159..893793749fbc 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_qos.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_qos.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include #include #include @@ -6,7 +7,6 @@ #include #include "ps3_ioc_manager.h" #include "ps3_util.h" -#include "ps3_types.h" #include "ps3_instance_manager.h" #include "ps3_htp_def.h" #include "ps3_scsih.h" @@ -19,6 +19,7 @@ #include "ps3_cmd_statistics.h" #include "ps3_scsih_raid_engine.h" #include "ps3_ioc_state.h" +#include "ps3_kernel_version.h" #define PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr) ((qos_pd_mgr)->vd_id > 0) @@ -28,14 +29,16 @@ #define PS3_QOS_VD_SDD_DELAY_THD_MS 1 -static inline Bool ps3_tfifo_depth_get(struct ps3_instance *instance, - U64 *depth) +static inline unsigned char ps3_tfifo_depth_get(struct ps3_instance *instance, + unsigned long long *depth) { - Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3TfifoDepth, *depth); + unsigned char ret = PS3_TRUE; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3TfifoDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3TfifoDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -47,15 +50,17 @@ static inline Bool ps3_tfifo_depth_get(struct ps3_instance *instance, return ret; } -static inline Bool ps3_cmdq_depth_get(struct ps3_instance *instance, - U64 *depth) +static inline unsigned char ps3_cmdq_depth_get(struct ps3_instance *instance, + unsigned long long *depth) { - Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3CmdQueueDepth, *depth); + unsigned char ret = PS3_TRUE; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3CmdQueueDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3CmdQueueDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -67,15 +72,17 @@ static inline Bool ps3_cmdq_depth_get(struct ps3_instance *instance, return ret; } -static inline Bool ps3_mgrq_depth_get(struct ps3_instance *instance, - U64 *depth) +static inline unsigned char ps3_mgrq_depth_get(struct ps3_instance *instance, + unsigned long long *depth) { - Bool ret = PS3_TRUE; - PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, ps3MgrQueueDepth, *depth); + unsigned char ret = PS3_TRUE; + + PS3_IOC_REG_READ_SAFE_WITH_RETRY(instance, reg_f.Excl_reg, + ps3MgrQueueDepth, *depth); if (*depth == U64_MAX) { LOG_INFO("host_no:%u read reg ps3MgrQueueDepth failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); *depth = 0; ret = PS3_FALSE; goto l_out; @@ -87,38 +94,53 @@ static inline Bool ps3_mgrq_depth_get(struct ps3_instance *instance, return ret; } -static inline struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_get(struct ps3_instance *instance, U16 disk_id) +static inline struct ps3_qos_pd_mgr * +ps3_qos_pd_mgr_get(struct ps3_instance *instance, unsigned short disk_id) { - return &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; + return &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; } -static inline bool ps3_is_nvme_direct_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_cmd *cmd) +static inline bool ps3_is_nvme_direct_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_cmd *cmd) { return (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD && - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK); + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK); } -static void ps3_qos_update_pd_quota(struct ps3_cmd *cmd) +static void ps3_qos_update_pd_quota(struct ps3_cmd *cmd, + unsigned char in_reply) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 i = 0; - U16 disk_id = 0; - S32 pd_used_quota = 0; - ps3_atomic32 *pd_rsc = NULL; + unsigned short i = 0; + unsigned short disk_id = 0; + int pd_used_quota = 0; + atomic_t *pd_rsc = NULL; + struct ps3_qos_pd_reply_info *qos_reply_info = + &cmd->instance->qos_context.pd_ctx.reply_info[cmd->cmd_word.isrSN]; for (i = 0; i < cmd->target_pd_count; i++) { if (cmd->target_pd[i].get_quota) { disk_id = cmd->target_pd[i].flat_disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) pd_rsc = &qos_pd_mgr->direct_used_quota; - } else { + else pd_rsc = &qos_pd_mgr->pd_used_quota; - } pd_used_quota = ps3_atomic_dec_return(pd_rsc); - LOG_DEBUG("update pd quota. host_no:%u t_id:0x%llx CFID:%u direct:%u pid:%u used_quota:%d\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->cmd_word.direct, - disk_id, pd_used_quota); + + if (in_reply && qos_reply_info->processed_pd_state[disk_id] == 0) { + qos_reply_info->processed_pd_state[disk_id] = 1; + qos_reply_info->processed_pd_id + [qos_reply_info->processed_pd_cnt] = disk_id; + qos_reply_info->processed_pd_cnt++; + } + + LOG_DEBUG( + "update pd quota. host_no:%u t_id:0x%llx CFID:%u\n" + "\tdirect:%u pid:%u used_quota:%d\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->index, cmd->cmd_word.direct, disk_id, + pd_used_quota); break; } } @@ -126,24 +148,26 @@ static void ps3_qos_update_pd_quota(struct ps3_cmd *cmd) static inline struct ps3_qos_vd_mgr *ps3_qos_vd_mgr_get(struct ps3_cmd *cmd) { - U16 disk_id = 0; - U16 flat_disk_id = 0; + unsigned short disk_id = 0; + unsigned short flat_disk_id = 0; struct ps3_instance *instance = cmd->instance; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { disk_id = PS3_VDID(&cmd->io_attr.vd_entry->diskPos); - flat_disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); + flat_disk_id = + get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); return &instance->qos_context.vd_ctx.qos_vd_mgrs[flat_disk_id]; } else { - return &instance->qos_context.vd_ctx.qos_vd_mgrs[instance->qos_context.max_vd_count]; + return &instance->qos_context.vd_ctx + .qos_vd_mgrs[instance->qos_context.max_vd_count]; } } -static inline struct ps3_qos_vd_mgr *ps3_qos_vd_mgr_get_by_id(struct ps3_instance *instance, - U16 disk_id) +static inline struct ps3_qos_vd_mgr * +ps3_qos_vd_mgr_get_by_id(struct ps3_instance *instance, unsigned short disk_id) { struct ps3_qos_vd_context *qos_vd_ctx = NULL; - U16 flat_disk_id = 0; + unsigned short flat_disk_id = 0; qos_vd_ctx = &instance->qos_context.vd_ctx; flat_disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), disk_id); @@ -155,88 +179,96 @@ static void ps3_qos_update_vd_quota(struct ps3_cmd *cmd) struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { - qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); + qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); ps3_atomic_inc(&qos_vd_mgr->vd_quota); } } -Bool ps3_qos_enable(struct ps3_instance *instance) +static inline unsigned char ps3_qos_enable(struct ps3_instance *instance) { return instance->qos_context.qos_switch; } -static void ps3_qos_cmd_resend_fail(struct ps3_cmd *cmd, S32 ret) +static void ps3_qos_cmd_resend_fail(struct ps3_cmd *cmd, int ret) { struct ps3_scsi_priv_data *pri_data = NULL; struct ps3_instance *instance = cmd->instance; struct scsi_cmnd *s_cmd = cmd->scmd; - if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) { + if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_RESET); - } else { + else s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - } if (cmd->is_got_r1x == 1) { pri_data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; ps3_r1x_write_unlock(&pri_data->lock_mgr, cmd); } - LOG_INFO_IN_IRQ(instance, "t_id:0x%llx hno:%u tag:%d cmd send err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + LOG_INFO_IN_IRQ(instance, + "t_id:0x%llx hno:%u tag:%d cmd send err ret:%d\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; PS3_DEV_IO_START_ERR_INC(instance, cmd); PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd); - PS3_VD_OUTSTAND_DEC(cmd->instance, s_cmd); + PS3_VD_OUTSTAND_DEC(cmd->instance, cmd); PS3_DEV_BUSY_DEC(s_cmd); ps3_scsi_cmd_free(cmd); SCMD_IO_DONE(s_cmd); } -struct qos_wait_queue *ps3_qos_cmd_waitq_get(struct ps3_qos_tg_context *qos_tg_ctx, struct ps3_cmd *cmd) +static struct qos_wait_queue * +ps3_qos_cmd_waitq_get(struct ps3_qos_tg_context *qos_tg_ctx, + struct ps3_cmd *cmd) { struct qos_wait_queue *wait_q = NULL; - U16 disk_id = 0; + unsigned short disk_id = 0; struct ps3_qos_context *qos_ctx = NULL; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { wait_q = &qos_tg_ctx->mgr_cmd_wait_q; } else { if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - disk_id = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + disk_id = get_offset_of_vdid( + PS3_VDID_OFFSET(cmd->instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); wait_q = &qos_tg_ctx->vd_cmd_waitqs[disk_id]; } else { qos_ctx = &cmd->instance->qos_context; - wait_q = &qos_tg_ctx->vd_cmd_waitqs[qos_ctx->max_vd_count]; + wait_q = + &qos_tg_ctx + ->vd_cmd_waitqs[qos_ctx->max_vd_count]; } } return wait_q; } -static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd) +static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd, + unsigned char in_reply) { - struct ps3_qos_tg_context *qos_tg_ctx = &cmd->instance->qos_context.tg_ctx; + struct ps3_qos_tg_context *qos_tg_ctx = + &cmd->instance->qos_context.tg_ctx; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { - if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_share_used) >= 0) { + if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_share_used) >= 0) { ps3_atomic_inc(&qos_tg_ctx->share_free_cnt); } else { ps3_atomic_inc(&qos_tg_ctx->mgr_share_used); ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); } } else { - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, in_reply); if (cmd->cmd_word.direct != PS3_CMDWORD_DIRECT_OK) { qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); - if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) ps3_atomic_inc(&qos_vd_mgr->vd_quota); - } - if (ps3_atomic_dec_return(&qos_vd_mgr->share_cmd_used) >= 0) { + if (ps3_atomic_dec_return( + &qos_vd_mgr->share_cmd_used) >= 0) { ps3_atomic_inc(&qos_tg_ctx->share_free_cnt); } else { ps3_atomic_inc(&qos_vd_mgr->share_cmd_used); @@ -245,13 +277,15 @@ static void ps3_hba_qos_cmd_update(struct ps3_cmd *cmd) } } LOG_DEBUG("qos cmd update. host_no:%u dev_t:%u share:%u\n", - PS3_HOST(cmd->instance), cmd->io_attr.dev_type, - ps3_atomic_read(&qos_tg_ctx->share_free_cnt)); + PS3_HOST(cmd->instance), cmd->io_attr.dev_type, + ps3_atomic_read(&qos_tg_ctx->share_free_cnt)); } -static inline Bool ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_ctx) +static inline unsigned char +ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_ctx) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; + if (ps3_atomic_dec_return(&qos_tg_ctx->share_free_cnt) >= 0) { can_get = PS3_TRUE; } else { @@ -262,11 +296,12 @@ static inline Bool ps3_qos_share_cmdword_dec(struct ps3_qos_tg_context *qos_tg_c return can_get; } -static Bool ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, - struct ps3_cmd *cmd, struct qos_wait_queue *wait_q) +static unsigned char +ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, + struct ps3_cmd *cmd, struct qos_wait_queue *wait_q) { - Bool can_get = PS3_FALSE; - ULong flag = 0; + unsigned char can_get = PS3_FALSE; + unsigned long flag = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; can_get = ps3_qos_share_cmdword_dec(qos_tg_ctx); @@ -277,7 +312,8 @@ static Bool ps3_qos_share_cmdword_get(struct ps3_qos_tg_context *qos_tg_ctx, qos_tg_ctx->total_wait_cmd_cnt++; cmd->qos_waitq_flag = PS3_QOS_CMD_IN_FRAME; ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); - LOG_DEBUG("insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", + LOG_DEBUG( + "insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->io_attr.disk_id, wait_q->count); PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_TAG_QUEUE); @@ -309,9 +345,9 @@ static bool ps3_qos_mgr_cmdword_get(struct ps3_cmd *cmd) return can_get; } -Bool ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) +static unsigned char ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); @@ -325,55 +361,56 @@ Bool ps3_qos_vd_cmdword_get(struct ps3_cmd *cmd) return can_get; } -Bool ps3_qos_exclusive_cmdword_get(struct ps3_cmd *cmd) +static unsigned char ps3_qos_exclusive_cmdword_get(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; - if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { + if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) can_get = ps3_qos_mgr_cmdword_get(cmd); - } else { + else can_get = ps3_qos_vd_cmdword_get(cmd); - } return can_get; } -Bool ps3_qos_tg_decision(struct ps3_cmd *cmd) +static unsigned char ps3_qos_tg_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; struct ps3_instance *instance = cmd->instance; - ULong flag = 0; + unsigned long flag = 0; struct qos_wait_queue *cmd_wait_q = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; PS3_QOS_STAT_START(instance, cmd, PS3_QOS_TAG_PRO); cmd_wait_q = ps3_qos_cmd_waitq_get(qos_tg_ctx, cmd); if (cmd_wait_q->count == 0) { - can_get = ps3_qos_exclusive_cmdword_get(cmd); - if (can_get){ + can_get = ps3_qos_exclusive_cmdword_get(cmd); + if (can_get) goto out; - } } if (likely(qos_tg_ctx->total_wait_cmd_cnt == 0)) { - can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); + can_get = + ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); } else { - INJECT_START(PS3_ERR_IJ_QOS_WAIT_TAG_WAITQ_CLEAR, cmd->instance) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_TAG_WAITQ_CLEAR, cmd->instance); ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); - if (qos_tg_ctx->total_wait_cmd_cnt > 0){ + if (qos_tg_ctx->total_wait_cmd_cnt > 0) { list_add_tail(&cmd->qos_list, &cmd_wait_q->wait_list); cmd_wait_q->count++; qos_tg_ctx->total_wait_cmd_cnt++; cmd->qos_waitq_flag = PS3_QOS_CMD_IN_FRAME; ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); can_get = PS3_FALSE; - LOG_DEBUG("insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - cmd->io_attr.disk_id, cmd_wait_q->count); + LOG_DEBUG( + "insert qos tag waitq.host_no:%u:t_id:0x%llx CFID:%u diskid:%u waitq:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + cmd->io_attr.disk_id, cmd_wait_q->count); PS3_QOS_STAT_START(instance, cmd, PS3_QOS_TAG_QUEUE); } else { ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); - can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, cmd_wait_q); + can_get = ps3_qos_share_cmdword_get(qos_tg_ctx, cmd, + cmd_wait_q); } } out: @@ -383,7 +420,7 @@ Bool ps3_qos_tg_decision(struct ps3_cmd *cmd) static inline bool ps3_qos_pd_quota_add(struct qos_wait_queue *waitq) { - Bool can_get = PS3_TRUE; + unsigned char can_get = PS3_TRUE; if (ps3_atomic_inc_return(waitq->used_rsc) > *waitq->free_rsc) { ps3_atomic_dec(waitq->used_rsc); @@ -393,70 +430,89 @@ static inline bool ps3_qos_pd_quota_add(struct qos_wait_queue *waitq) return can_get; } -static void ps3_qos_pd_in_q(struct ps3_cmd *cmd, struct qos_wait_queue *waitq, - U16 pd_idx) { - ULong flag = 0; +static unsigned char ps3_qos_pd_in_q(struct ps3_cmd *cmd, struct qos_wait_queue *waitq, + unsigned short pd_idx) +{ + unsigned long flag = 0; + unsigned char in_q = PS3_TRUE; + ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); - list_add_tail(&cmd->qos_list, &waitq->wait_list); - waitq->count++; - (*waitq->total_waited_cnt)++; - cmd->qos_waitq_flag = PS3_QOS_CMD_IN_PD; - cmd->first_over_quota_pd_idx = pd_idx; + if (unlikely((*waitq->total_waited_cnt == 0) && + (ps3_atomic_read(waitq->used_rsc) < *waitq->free_rsc))) { + in_q = !ps3_qos_pd_quota_add(waitq); + } + + if (in_q) { + list_add_tail(&cmd->qos_list, &waitq->wait_list); + waitq->count++; + (*waitq->total_waited_cnt)++; + cmd->qos_waitq_flag = PS3_QOS_CMD_IN_PD; + cmd->first_over_quota_pd_idx = pd_idx; + } ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); - PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_QUEUE); + + if (in_q) { + PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_QUEUE); + } + + return in_q; } -static struct qos_wait_queue* ps3_qos_pd_waitq_get(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd) +static struct qos_wait_queue * +ps3_qos_pd_waitq_get(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_cmd *cmd) { - U16 que_id = 0; + unsigned short que_id = 0; struct ps3_instance *instance = NULL; instance = cmd->instance; if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - que_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + que_id = get_offset_of_vdid( + PS3_VDID_OFFSET(instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); } else { - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) que_id = 0; - } else { + else que_id = instance->qos_context.max_vd_count; - } } return &qos_pd_mgr->waitqs[que_id]; } -static Bool ps3_qos_pd_quota_get(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd, U16 pd_idx, struct qos_wait_queue *waitq) +static unsigned char ps3_qos_pd_quota_get(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_cmd *cmd, + unsigned short pd_idx, + struct qos_wait_queue *waitq) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; can_get = ps3_qos_pd_quota_add(waitq); - if (!can_get) { - ps3_qos_pd_in_q(cmd, waitq, pd_idx); - LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); + INJECT_START(PS3_ERR_IJ_QOS_JBOD_IN_PD_Q_BLOCK, cmd->instance); + if (!can_get && ps3_qos_pd_in_q(cmd, waitq, pd_idx)) { + LOG_DEBUG( + "insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); } else { cmd->target_pd[pd_idx].get_quota = PS3_TRUE; + can_get = PS3_TRUE; } - return can_get; + return can_get; } static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd, U16 pd_idx) + struct ps3_cmd *cmd, unsigned short pd_idx) { bool can_get = PS3_FALSE; - ULong flag = 0; + unsigned long flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); if (likely((*waitq->total_waited_cnt) == 0)) { can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, waitq); } else { - INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR, cmd->instance) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR, cmd->instance); ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); if ((*waitq->total_waited_cnt) > 0) { list_add_tail(&cmd->qos_list, &waitq->wait_list); @@ -466,13 +522,17 @@ static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, cmd->first_over_quota_pd_idx = pd_idx; ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - waitq->id, waitq->count, qos_pd_mgr->disk_id, pd_idx); - PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_QUEUE); + LOG_DEBUG( + "insert qos pd quota waitq.host_no:%u:t_id:0x%llx CFID:%u waitq[%u,%u] did[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->index, waitq->id, waitq->count, + qos_pd_mgr->disk_id, pd_idx); + PS3_QOS_STAT_START(cmd->instance, cmd, + PS3_QOS_PD_QUEUE); } else { ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); - can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, waitq); + can_get = ps3_qos_pd_quota_get(qos_pd_mgr, cmd, pd_idx, + waitq); } } @@ -480,17 +540,18 @@ static bool ps3_qos_pd_quota_req(struct ps3_qos_pd_mgr *qos_pd_mgr, } static bool ps3_qos_pd_quota_check(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { bool can_get = PS3_FALSE; - ULong flag = 0; + unsigned long flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); if (likely((*waitq->total_waited_cnt) == 0)) { can_get = ps3_qos_pd_quota_add(waitq); } else { - INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR_2, cmd->instance) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_PD_WAITQ_CLEAR_2, + cmd->instance); ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); if ((*waitq->total_waited_cnt) > 0) { ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); @@ -506,20 +567,22 @@ static bool ps3_qos_pd_quota_check(struct ps3_qos_pd_mgr *qos_pd_mgr, static inline bool ps3_qos_vd_quota_dec(struct ps3_qos_vd_mgr *qos_vd_mgr) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; + if (ps3_atomic_dec_return(&qos_vd_mgr->vd_quota) >= 0) { - can_get = PS3_TRUE; + can_get = PS3_TRUE; } else { ps3_atomic_inc(&qos_vd_mgr->vd_quota); - can_get = PS3_FALSE; + can_get = PS3_FALSE; } - return can_get; + return can_get; } -static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, struct ps3_cmd *cmd) +static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, + struct ps3_cmd *cmd) { - ULong flag = 0; + unsigned long flag = 0; struct qos_wait_queue *wait_q = NULL; wait_q = &qos_vd_mgr->vd_quota_wait_q; @@ -529,35 +592,37 @@ static void ps3_qos_insert_vd_quota_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, str cmd->qos_waitq_flag = PS3_QOS_CMD_IN_VD; ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_QUEUE); - LOG_DEBUG("insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u diskid:%u waitq:%u\n", + LOG_DEBUG( + "insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u diskid:%u waitq:%u\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->io_attr.disk_id, wait_q->count); } -static bool ps3_qos_vd_quota_get_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, struct ps3_cmd *cmd) +static bool ps3_qos_vd_quota_get_waitq(struct ps3_qos_vd_mgr *qos_vd_mgr, + struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; + can_get = ps3_qos_vd_quota_dec(qos_vd_mgr); - if (!can_get) { + if (!can_get) ps3_qos_insert_vd_quota_waitq(qos_vd_mgr, cmd); - } - return can_get; + return can_get; } static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) { bool can_get = PS3_FALSE; - ULong flag = 0; + unsigned long flag = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct qos_wait_queue *wait_q = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(cmd); wait_q = &qos_vd_mgr->vd_quota_wait_q; - if (likely(wait_q->count == 0)){ + if (likely(wait_q->count == 0)) { can_get = ps3_qos_vd_quota_get_waitq(qos_vd_mgr, cmd); } else { - INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_WAITQ_CLEAR, cmd->instance) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_WAITQ_CLEAR, cmd->instance); ps3_spin_lock_irqsave(wait_q->rsc_lock, &flag); if (wait_q->count > 0) { list_add_tail(&cmd->qos_list, &wait_q->wait_list); @@ -565,11 +630,14 @@ static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) cmd->qos_waitq_flag = PS3_QOS_CMD_IN_VD; ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG("insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u " - "diskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - cmd->io_attr.disk_id, wait_q->count); - PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_QUEUE); + LOG_DEBUG( + "insert qos vd quota waitq.host_no:%u:tid:0x%llx CFID:%u\n" + "\tdiskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->index, cmd->io_attr.disk_id, + wait_q->count); + PS3_QOS_STAT_START(cmd->instance, cmd, + PS3_QOS_VD_QUEUE); } else { ps3_spin_unlock_irqrestore(wait_q->rsc_lock, flag); can_get = ps3_qos_vd_quota_get_waitq(qos_vd_mgr, cmd); @@ -579,28 +647,32 @@ static bool ps3_qos_vd_quota_check(struct ps3_cmd *cmd) return can_get; } -static inline Bool ps3_qos_pd_notify_judge(struct ps3_qos_pd_mgr *qos_pd_mgr) +static inline unsigned char +ps3_qos_pd_notify_judge(struct ps3_qos_pd_mgr *qos_pd_mgr) { - Bool can_notify = PS3_FALSE; + unsigned char can_notify = PS3_FALSE; can_notify = qos_pd_mgr->total_wait_cmd_cnt && - (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < qos_pd_mgr->pd_quota); + (ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < + qos_pd_mgr->pd_quota); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr) || can_notify) { goto _out; } else { can_notify = qos_pd_mgr->total_waited_direct_cmd && - (ps3_atomic_read(&qos_pd_mgr->direct_used_quota) < qos_pd_mgr->direct_quota); + (ps3_atomic_read(&qos_pd_mgr->direct_used_quota) < + qos_pd_mgr->direct_quota); } _out: - INJECT_START(PS3_ERR_IJ_QOS_NOT_AWAKE_PD, &can_notify) - return can_notify; + INJECT_START(PS3_ERR_IJ_QOS_NOT_AWAKE_PD, &can_notify); + return can_notify; } -static Bool ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, +static unsigned char +ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, struct ps3_qos_pd_mgr *qos_pd_mgr) { struct workqueue_struct *workq = NULL; - Bool notified = PS3_FALSE; + unsigned char notified = PS3_FALSE; if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { if (ps3_qos_pd_notify_judge(qos_pd_mgr)) { @@ -615,7 +687,7 @@ static Bool ps3_qos_single_pd_notify(struct ps3_qos_pd_context *qos_pd_ctx, static void ps3_qos_pd_notify(struct ps3_instance *instance) { - U16 id = 0; + unsigned short id = 0; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; @@ -626,15 +698,36 @@ static void ps3_qos_pd_notify(struct ps3_instance *instance) } } -static Bool ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, +static void ps3_qos_pd_notify_in_reply(struct ps3_instance *instance, + unsigned short isr_sn) +{ + unsigned short i = 0; + unsigned short pd_id = 0; + struct ps3_qos_pd_context *qos_pd_ctx = NULL; + struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; + struct ps3_qos_pd_reply_info *pd_reply_info = NULL; + + qos_pd_ctx = &instance->qos_context.pd_ctx; + pd_reply_info = &instance->qos_context.pd_ctx.reply_info[isr_sn]; + for (i = 0; i < pd_reply_info->processed_pd_cnt; i++) { + pd_id = pd_reply_info->processed_pd_id[i]; + qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); + ps3_qos_single_pd_notify(qos_pd_ctx, qos_pd_mgr); + pd_reply_info->processed_pd_state[pd_id] = 0; + } + pd_reply_info->processed_pd_cnt = 0; +} + +static unsigned char +ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, struct ps3_qos_vd_mgr *qos_vd_mgr) { struct workqueue_struct *workq = NULL; - Bool notify = PS3_FALSE; + unsigned char notify = PS3_FALSE; if (qos_vd_mgr->valid) { if (qos_vd_mgr->vd_quota_wait_q.count > 0 && - ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { + ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { workq = qos_vd_ctx->work_queues[qos_vd_mgr->workq_id]; queue_work(workq, &qos_vd_mgr->resend_work); notify = PS3_TRUE; @@ -644,37 +737,37 @@ static Bool ps3_qos_single_vd_notify(struct ps3_qos_vd_context *qos_vd_ctx, return notify; } -static U8 ps3_qos_vd_notify(struct ps3_instance *instance) +static unsigned char ps3_qos_vd_notify(struct ps3_instance *instance) { - U8 notify = PS3_FALSE; - U16 id = 0; + unsigned char notify = PS3_FALSE; + unsigned short id = 0; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_ctx = &instance->qos_context.vd_ctx; for (id = 1; id <= instance->qos_context.max_vd_count; id++) { qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[id]; - if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) { + if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) notify = PS3_TRUE; - } } return notify; } -static Bool ps3_qos_tag_rsc_available(struct ps3_instance *instance) +static unsigned char ps3_qos_tag_rsc_available(struct ps3_instance *instance) { - Bool rsc_avail = PS3_FALSE; - U16 i = 0; + unsigned char rsc_avail = PS3_FALSE; + unsigned short i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; + if (ps3_atomic_read(&qos_tg_ctx->share_free_cnt) > 0) { rsc_avail = PS3_TRUE; goto _lout; } if (qos_tg_ctx->mgr_cmd_wait_q.count > 0 && - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { rsc_avail = PS3_TRUE; goto _lout; } @@ -682,7 +775,7 @@ static Bool ps3_qos_tag_rsc_available(struct ps3_instance *instance) for (i = 1; i <= instance->qos_context.max_vd_count; i++) { qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[i]; if (ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0 && - qos_tg_ctx->vd_cmd_waitqs[i].count > 0) { + qos_tg_ctx->vd_cmd_waitqs[i].count > 0) { rsc_avail = PS3_TRUE; break; } @@ -693,13 +786,13 @@ static Bool ps3_qos_tag_rsc_available(struct ps3_instance *instance) return rsc_avail; } -static Bool ps3_qos_tg_notify(struct ps3_instance *instance) +static unsigned char ps3_qos_tg_notify(struct ps3_instance *instance) { - Bool notified = PS3_FALSE; + unsigned char notified = PS3_FALSE; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; if (qos_tg_ctx->total_wait_cmd_cnt > 0 && - ps3_qos_tag_rsc_available(instance)) { + ps3_qos_tag_rsc_available(instance)) { queue_work(qos_tg_ctx->work_queue, &qos_tg_ctx->resend_work); notified = PS3_TRUE; } @@ -707,55 +800,66 @@ static Bool ps3_qos_tg_notify(struct ps3_instance *instance) return notified; } -Bool ps3_qos_all_pd_rc_get(struct ps3_cmd *cmd) +static unsigned char ps3_qos_all_pd_rc_get(struct ps3_cmd *cmd) { cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = PS3_TRUE; PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_PD_QUEUE); - LOG_DEBUG("resend cmd judge:host_no:%u t_id:0x%llx cmd:%u cmd_t:%u dev_t:%u ret[%u,%u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, cmd->cmd_word.type, cmd->io_attr.dev_type, - cmd->first_over_quota_pd_idx, 1); + LOG_DEBUG( + "resend cmd judge:host_no:%u t_id:0x%llx cmd:%u cmd_t:%u dev_t:%u ret[%u,%u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + cmd->cmd_word.type, cmd->io_attr.dev_type, + cmd->first_over_quota_pd_idx, 1); return PS3_TRUE; } -static void ps3_vd_quota_waitq_clean( struct ps3_qos_vd_mgr *qos_vd_mgr, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) +static void ps3_vd_quota_waitq_clean(struct ps3_qos_vd_mgr *qos_vd_mgr, + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; ps3_spin_lock_irqsave(qos_vd_mgr->vd_quota_wait_q.rsc_lock, &flag); if (qos_vd_mgr->vd_quota_wait_q.count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, qos_list) { + list_for_each_entry_safe( + cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, + qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data(cmd->scmd)) { + priv_data == scsi_device_private_data(cmd->scmd)) { list_del(&cmd->qos_list); qos_vd_mgr->vd_quota_wait_q.count--; - LOG_DEBUG("qos clean vd quota waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", - PS3_HOST(qos_vd_mgr->instance), cmd->trace_id, cmd->index, qos_vd_mgr->id); - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + LOG_DEBUG( + "qos clean vd quota waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", + PS3_HOST(qos_vd_mgr->instance), + cmd->trace_id, cmd->index, + qos_vd_mgr->id); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi( + cmd->scmd, cmd, resp_status, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(qos_vd_mgr->vd_quota_wait_q.rsc_lock, flag); LOG_FILE_INFO("clean qos device vd quota waitq host_no:%u diskid:%u\n", - PS3_HOST(qos_vd_mgr->instance), qos_vd_mgr->id); + PS3_HOST(qos_vd_mgr->instance), qos_vd_mgr->id); } static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) { struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; - ULong flag = 0; - S32 ret = PS3_SUCCESS; - Bool waitq_cleared = PS3_FALSE; + unsigned long flag = 0; + int ret = PS3_SUCCESS; + unsigned char waitq_cleared = PS3_FALSE; struct ps3_instance *instance = qos_vd_mgr->instance; ps3_spin_lock_irqsave(qos_vd_mgr->vd_quota_wait_q.rsc_lock, &flag); - if (qos_vd_mgr->vd_quota_wait_q.count > 0 - && ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { - list_for_each_entry_safe(cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, qos_list) { + if (qos_vd_mgr->vd_quota_wait_q.count > 0 && + ps3_atomic_read(&qos_vd_mgr->vd_quota) > 0) { + list_for_each_entry_safe( + cmd, cmd_next, &qos_vd_mgr->vd_quota_wait_q.wait_list, + qos_list) { if (ps3_atomic_dec_return(&qos_vd_mgr->vd_quota) < 0) { ps3_atomic_inc(&qos_vd_mgr->vd_quota); break; @@ -764,26 +868,29 @@ static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) qos_vd_mgr->vd_quota_wait_q.count--; PS3_QOS_STAT_END(instance, cmd, PS3_QOS_VD_QUEUE); if (ps3_qos_tg_decision(cmd)) { - ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + ret = ps3_scsi_cmd_send(instance, cmd, + PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { - ps3_qos_cmd_update(instance, cmd); + ps3_qos_cmd_update(instance, cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG("qos vd quota waitq resend:host_no:%u vid:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), qos_vd_mgr->id, cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "qos vd quota waitq resend:host_no:%u vid:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), + qos_vd_mgr->id, cmd->trace_id, + cmd->index, cmd->cmd_word.type); } } } - if (qos_vd_mgr->vd_quota_wait_q.count == 0) { + if (qos_vd_mgr->vd_quota_wait_q.count == 0) waitq_cleared = PS3_TRUE; - } } ps3_spin_unlock_irqrestore(qos_vd_mgr->vd_quota_wait_q.rsc_lock, flag); if (waitq_cleared) { LOG_DEBUG("qos vd quota waitq cleared.host_no:%u vd:%u\n", - PS3_HOST(instance), qos_vd_mgr->id); + PS3_HOST(instance), qos_vd_mgr->id); } qos_vd_mgr->last_sched_jiffies = jiffies; @@ -793,33 +900,37 @@ static void ps3_qos_vd_quota_waitq_resend(struct ps3_qos_vd_mgr *qos_vd_mgr) static void ps3_qos_vd_resend_work(struct work_struct *work) { struct ps3_qos_vd_mgr *qos_vd_mgr = - ps3_container_of(work, struct ps3_qos_vd_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_vd_mgr, resend_work); ps3_qos_vd_quota_waitq_resend(qos_vd_mgr); } static void ps3_qos_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq, S32 resp_status) + struct qos_wait_queue *waitq, int resp_status) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; + ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); while (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); - LOG_DEBUG("qos clean pd waitq. hno:%u t_id:0x%llx CFID:%d pid:%u que_id:%u\n", - PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, cmd->index, - qos_pd_mgr->disk_id, waitq->id); + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, + qos_list); + LOG_DEBUG( + "qos clean pd waitq. hno:%u t_id:0x%llx CFID:%d pid:%u que_id:%u\n", + PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, + cmd->index, qos_pd_mgr->disk_id, waitq->id); list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, + PS3_FALSE); } ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); } -void ps3_pd_quota_waitq_clear_all(struct ps3_qos_pd_mgr *qos_pd_mgr, - S32 resp_status) +static void ps3_pd_quota_waitq_clear_all(struct ps3_qos_pd_mgr *qos_pd_mgr, + int resp_status) { - U16 i = 0; + unsigned short i = 0; struct qos_wait_queue *waitq = NULL; for (i = 0; i < qos_pd_mgr->waitq_cnt; i++) { @@ -828,120 +939,130 @@ void ps3_pd_quota_waitq_clear_all(struct ps3_qos_pd_mgr *qos_pd_mgr, } LOG_DEBUG("clear all qos pd quota waitq host_no:%u did:%u vid:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, + qos_pd_mgr->vd_id); } -void ps3_pd_quota_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, - U16 que_id, S32 resp_status) +static void ps3_pd_quota_waitq_clean(struct ps3_qos_pd_mgr *qos_pd_mgr, + unsigned short que_id, int resp_status) { struct qos_wait_queue *waitq = NULL; - if (que_id == 0) { + + if (que_id == 0) { ps3_pd_quota_waitq_clear_all(qos_pd_mgr, resp_status); } else { - waitq = &qos_pd_mgr->waitqs[que_id]; + waitq = &qos_pd_mgr->waitqs[que_id]; ps3_qos_waitq_clean(qos_pd_mgr, waitq, resp_status); } LOG_DEBUG("clean qos pd quota waitq host_no:%u did:%u vid:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, + qos_pd_mgr->vd_id); } -static Bool ps3_hba_qos_pd_resend_check(struct ps3_cmd *cmd) +static unsigned char ps3_hba_qos_pd_resend_check(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) { - if (!ps3_qos_vd_quota_check(cmd)) { + if (!ps3_qos_vd_quota_check(cmd)) goto _out; - } } can_get = ps3_qos_tg_decision(cmd); _out: return can_get; } -static Bool ps3_qos_pd_resend_check(struct ps3_instance *instance, struct ps3_cmd *cmd) +static unsigned char ps3_qos_pd_resend_check(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; if (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { - cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = PS3_TRUE; + cmd->target_pd[cmd->first_over_quota_pd_idx].get_quota = + PS3_TRUE; PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_PD_QUEUE); can_get = PS3_TRUE; } else { - if (!ps3_qos_all_pd_rc_get(cmd)) { + if (!ps3_qos_all_pd_rc_get(cmd)) goto _out; - } can_get = instance->qos_context.opts.qos_pd_resend_check(cmd); } _out: return can_get; } -static Bool ps3_qos_vd_seq_check(struct ps3_cmd *cmd) +static unsigned char ps3_qos_vd_seq_check(struct ps3_cmd *cmd) { struct PS3VDEntry *vd_entry = NULL; - U16 vd_id = 0; - Bool seq_changed = PS3_FALSE; + unsigned short vd_id = 0; + unsigned char seq_changed = PS3_FALSE; INJECT_START(PS3_ERR_IJ_QOS_FORCE_VD_SEQ_CHANGE, cmd); if (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) { vd_id = PS3_VDID(&cmd->io_attr.vd_entry->diskPos); - vd_entry = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, vd_id); - if (!vd_entry || vd_entry->virtDiskSeq != - cmd->req_frame->hwReq.reqHead.virtDiskSeq) { + vd_entry = + ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, vd_id); + if (!vd_entry || + vd_entry->virtDiskSeq != + cmd->req_frame->hwReq.reqHead.virtDiskSeq) { seq_changed = PS3_TRUE; - LOG_DEBUG("qos pd waitq vd seq check:host_no:%u" - "t_id:0x%llx CFID:%u seq[%u %u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - cmd->req_frame->hwReq.reqHead.virtDiskSeq, - (!vd_entry) ? 0 : vd_entry->virtDiskSeq); - ps3_qos_update_pd_quota(cmd); + LOG_DEBUG("qos pd waitq vd seq check:host_no:%u\n" + "\tt_id:0x%llx CFID:%u seq[%u %u]\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->index, + cmd->req_frame->hwReq.reqHead.virtDiskSeq, + (!vd_entry) ? 0 : vd_entry->virtDiskSeq); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, - SCSI_STATUS_TASK_ABORTED, PS3_FALSE); + SCSI_STATUS_TASK_ABORTED, + PS3_FALSE); } } return seq_changed; } -static U32 ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq, S32 count) +static unsigned int ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct qos_wait_queue *waitq, + int count) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = qos_pd_mgr->instance; - U32 can_send = 0; - U32 que_cnt = 0; - S32 avail_rsc = 0; - S32 used_rsc = ps3_atomic_read(waitq->used_rsc); + unsigned int can_send = 0; + unsigned int que_cnt = 0; + int avail_rsc = 0; + int used_rsc = ps3_atomic_read(waitq->used_rsc); - if (used_rsc < *waitq->free_rsc) { + if (used_rsc < *waitq->free_rsc) avail_rsc = *waitq->free_rsc - used_rsc; - } can_send = PS3_MIN(avail_rsc, count); que_cnt = waitq->count; - while(can_send > 0 && waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + while (can_send > 0 && waitq->count > 0) { + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, + qos_list); list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - if (ps3_qos_vd_seq_check(cmd)) { + if (ps3_qos_vd_seq_check(cmd)) continue; - } can_send--; ps3_atomic_inc(waitq->used_rsc); if (ps3_qos_pd_resend_check(instance, cmd)) { ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { - ps3_qos_cmd_update(instance, cmd); + ps3_qos_cmd_update(instance, cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG("qos pd quota waitq resend:host_no:%u qid:%u pid:%u" - "t_id:0x%llx CFID:%u resend[%u %u]\n", - PS3_HOST(instance), waitq->id, qos_pd_mgr->disk_id, - cmd->trace_id, cmd->index, waitq->has_resend, waitq->can_resend); + LOG_DEBUG( + "qos pd quota waitq resend:host_no:%u qid:%u pid:%u\n" + "\tt_id:0x%llx CFID:%u resend[%u %u]\n", + PS3_HOST(instance), waitq->id, + qos_pd_mgr->disk_id, cmd->trace_id, + cmd->index, waitq->has_resend, + waitq->can_resend); } } } @@ -950,24 +1071,25 @@ static U32 ps3_qos_pd_resend_cmd(struct ps3_qos_pd_mgr *qos_pd_mgr, } static void ps3_qos_pd_waitq_resend(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct qos_wait_queue *waitq ) + struct qos_wait_queue *waitq) { - ULong flag = 0; - Bool waitq_cleared = PS3_FALSE; + unsigned long flag = 0; + unsigned char waitq_cleared = PS3_FALSE; + if (waitq->count > 0) { ps3_spin_lock_irqsave(waitq->rsc_lock, &flag); - if (ps3_atomic_read(waitq->used_rsc) < *waitq->free_rsc) { + if (ps3_atomic_read(waitq->used_rsc) < *waitq->free_rsc) ps3_qos_pd_resend_cmd(qos_pd_mgr, waitq, waitq->count); - } - if (*waitq->total_waited_cnt == 0) { + if (*waitq->total_waited_cnt == 0) waitq_cleared = PS3_TRUE; - } ps3_spin_unlock_irqrestore(waitq->rsc_lock, flag); if (waitq_cleared) { - LOG_DEBUG("qos pd quota waitq is cleard. host_no:%u did:%u qid:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, waitq->id); + LOG_DEBUG( + "qos pd quota waitq is cleard. host_no:%u did:%u qid:%u\n", + PS3_HOST(qos_pd_mgr->instance), + qos_pd_mgr->disk_id, waitq->id); } } } @@ -976,50 +1098,50 @@ static void ps3_qos_pd_jbod_resend(struct ps3_qos_pd_mgr *qos_pd_mgr) { struct ps3_instance *instance = qos_pd_mgr->instance; struct qos_wait_queue *waitq = NULL; - U16 que_id = 0; + unsigned short que_id = 0; if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { - waitq = &qos_pd_mgr->waitqs[0]; + waitq = &qos_pd_mgr->waitqs[0]; ps3_qos_pd_waitq_resend(qos_pd_mgr, waitq); } que_id = instance->qos_context.max_vd_count; - waitq = &qos_pd_mgr->waitqs[que_id]; + waitq = &qos_pd_mgr->waitqs[que_id]; ps3_qos_pd_waitq_resend(qos_pd_mgr, waitq); } -void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) +static void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) { - U16 min_waitq_cnt = 0; - U16 i = 0; + unsigned short min_waitq_cnt = 0; + unsigned short i = 0; struct qos_wait_queue *waitq = NULL; - ULong min_cmd_jiffies = 0; + unsigned long min_cmd_jiffies = 0; struct ps3_cmd *cmd = NULL; - U16 poll_que_id = 1; + unsigned short poll_que_id = 1; - if (qos_pd_mgr->poll_que_id != qos_pd_mgr->poll_start_que_id) { + if (qos_pd_mgr->poll_que_id != qos_pd_mgr->poll_start_que_id) return; - } waitq = &qos_pd_mgr->waitqs[qos_pd_mgr->poll_que_id]; - if (waitq->has_resend > 0) { + if (waitq->has_resend > 0) return; - } for (i = 1; i < qos_pd_mgr->waitq_cnt - 1; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + cmd = list_first_entry(&waitq->wait_list, + struct ps3_cmd, qos_list); if (min_waitq_cnt == 0) { min_waitq_cnt = waitq->count; min_cmd_jiffies = cmd->scmd->jiffies_at_alloc; } else { - if (min_waitq_cnt > waitq->count) { + if (min_waitq_cnt > waitq->count) min_waitq_cnt = waitq->count; - } - if (min_cmd_jiffies > cmd->scmd->jiffies_at_alloc) { - min_cmd_jiffies = cmd->scmd->jiffies_at_alloc; + if (min_cmd_jiffies > + cmd->scmd->jiffies_at_alloc) { + min_cmd_jiffies = + cmd->scmd->jiffies_at_alloc; poll_que_id = i; } } @@ -1029,8 +1151,10 @@ void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) for (i = 1; i < qos_pd_mgr->waitq_cnt - 1; i++) { waitq = &qos_pd_mgr->waitqs[i]; if (waitq->count > 0) { - waitq->can_resend = waitq->count/min_waitq_cnt > 0 ? - waitq->count/min_waitq_cnt : 1; + waitq->can_resend = + waitq->count / min_waitq_cnt > 0 ? + waitq->count / min_waitq_cnt : + 1; waitq->has_resend = 0; } } @@ -1039,69 +1163,80 @@ void ps3_qos_pd_waitq_ratio_update(struct ps3_qos_pd_mgr *qos_pd_mgr) qos_pd_mgr->poll_start_que_id = poll_que_id; LOG_DEBUG("qos pd ratio update:host_no:%u pid:%u first:%u\n", - PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, poll_que_id); + PS3_HOST(qos_pd_mgr->instance), qos_pd_mgr->disk_id, + poll_que_id); } static void ps3_qos_pd_vd_member_resend(struct ps3_qos_pd_mgr *qos_pd_mgr) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_instance *instance = qos_pd_mgr->instance; struct qos_wait_queue *waitq = NULL; - ULong timeout_jiffies = 0; - Bool waitq_cleared = PS3_FALSE; - Bool vd_expired = PS3_FALSE; - U32 pd_wait_count = 0; + unsigned long timeout_jiffies = 0; + unsigned char waitq_cleared = PS3_FALSE; + unsigned char vd_expired = PS3_FALSE; + unsigned int pd_wait_count = 0; ps3_spin_lock_irqsave(&qos_pd_mgr->rc_lock, &flag); - pd_wait_count = qos_pd_mgr->waitqs[instance->qos_context.max_vd_count].count; + pd_wait_count = + qos_pd_mgr->waitqs[instance->qos_context.max_vd_count].count; while ((ps3_atomic_read(&qos_pd_mgr->pd_used_quota) < - qos_pd_mgr->pd_quota) && qos_pd_mgr->total_wait_cmd_cnt > pd_wait_count) { + qos_pd_mgr->pd_quota) && + qos_pd_mgr->total_wait_cmd_cnt > pd_wait_count) { ps3_qos_pd_waitq_ratio_update(qos_pd_mgr); waitq = &qos_pd_mgr->waitqs[qos_pd_mgr->poll_que_id]; - if (waitq->count == 0) { + if (waitq->count == 0) goto _next_waitq; - } if (waitq->has_resend > 0) { if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_SAS_HDD || - qos_pd_mgr->dev_type == PS3_DEV_TYPE_SATA_HDD) { - timeout_jiffies = waitq->last_sched_jiffies + - msecs_to_jiffies(PS3_QOS_VD_HDD_DELAY_THD_MS); + qos_pd_mgr->dev_type == PS3_DEV_TYPE_SATA_HDD) { + timeout_jiffies = + waitq->last_sched_jiffies + + msecs_to_jiffies( + PS3_QOS_VD_HDD_DELAY_THD_MS); } else { - timeout_jiffies = waitq->last_sched_jiffies + - msecs_to_jiffies(PS3_QOS_VD_SDD_DELAY_THD_MS); + timeout_jiffies = + waitq->last_sched_jiffies + + msecs_to_jiffies( + PS3_QOS_VD_SDD_DELAY_THD_MS); } vd_expired = time_after(jiffies, timeout_jiffies); - INJECT_START(PS3_ERR_IJ_QOS_PD_RESEND_NOT_EXPIRED, &vd_expired) + INJECT_START(PS3_ERR_IJ_QOS_PD_RESEND_NOT_EXPIRED, + &vd_expired); if (vd_expired) { - LOG_DEBUG("go to next vd waitq for delay:host_no:%u qid:%u pid:%u", - PS3_HOST(instance), waitq->id, qos_pd_mgr->disk_id); + LOG_DEBUG( + "go to next vd waitq for delay:host_no:%u qid:%u pid:%u", + PS3_HOST(instance), waitq->id, + qos_pd_mgr->disk_id); goto _next_waitq; } } waitq->last_sched_jiffies = jiffies; - waitq->has_resend += ps3_qos_pd_resend_cmd(qos_pd_mgr, waitq, waitq->can_resend - waitq->has_resend); - if (waitq->has_resend >= waitq->can_resend) { + waitq->has_resend += ps3_qos_pd_resend_cmd( + qos_pd_mgr, waitq, + waitq->can_resend - waitq->has_resend); + if (waitq->has_resend >= waitq->can_resend) goto _next_waitq; - } continue; _next_waitq: - waitq->has_resend = 0; - if (++qos_pd_mgr->poll_que_id == instance->qos_context.max_vd_count) { + waitq->has_resend = 0; + if (++qos_pd_mgr->poll_que_id == + instance->qos_context.max_vd_count) { qos_pd_mgr->poll_que_id = 1; } } - if (qos_pd_mgr->total_wait_cmd_cnt == 0) { + if (qos_pd_mgr->total_wait_cmd_cnt == 0) waitq_cleared = PS3_TRUE; - } ps3_spin_unlock_irqrestore(&qos_pd_mgr->rc_lock, flag); if (waitq_cleared) { - LOG_DEBUG("qos pd quota waitq is cleard. host_no:%u diskid:%u\n", - PS3_HOST(instance), qos_pd_mgr->disk_id); + LOG_DEBUG( + "qos pd quota waitq is cleard. host_no:%u diskid:%u\n", + PS3_HOST(instance), qos_pd_mgr->disk_id); } } @@ -1111,61 +1246,62 @@ static void ps3_qos_pd_resend_work(struct work_struct *work) ps3_container_of(work, struct ps3_qos_pd_mgr, resend_work); ps3_qos_pd_jbod_resend(qos_pd_mgr); - INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_SEND, qos_pd_mgr) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_VD_SEND, qos_pd_mgr); ps3_qos_pd_vd_member_resend(qos_pd_mgr); qos_pd_mgr->last_sched_jiffies = jiffies; - - return; } static void ps3_poll_vd_cmd_waitq(struct ps3_qos_tg_context *qos_tg_ctx) { struct qos_wait_queue *waitq = NULL; - U32 free_cnt = 0; - U8 vd_id = 0; - S32 ret = PS3_SUCCESS; + unsigned int free_cnt = 0; + unsigned char vd_id = 0; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; - U32 sent_count = 0; + unsigned int sent_count = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_instance *instance = qos_tg_ctx->instance; - U32 mgrq_cnt = qos_tg_ctx->mgr_cmd_wait_q.count; + unsigned int mgrq_cnt = qos_tg_ctx->mgr_cmd_wait_q.count; - INJECT_START(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, instance) + INJECT_START(PS3_ERR_IJ_QOS_SET_SHARE_COUNT, instance); free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); vd_id = qos_tg_ctx->poll_vd_id; - while (free_cnt > sent_count && qos_tg_ctx->total_wait_cmd_cnt > mgrq_cnt) { + while (free_cnt > sent_count && + qos_tg_ctx->total_wait_cmd_cnt > mgrq_cnt) { waitq = &qos_tg_ctx->vd_cmd_waitqs[vd_id]; if (waitq->count > 0) { - qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[vd_id]; - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + qos_vd_mgr = + &instance->qos_context.vd_ctx.qos_vd_mgrs[vd_id]; + cmd = list_first_entry(&waitq->wait_list, + struct ps3_cmd, qos_list); list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; waitq->count--; qos_tg_ctx->total_wait_cmd_cnt--; PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); - if (ps3_qos_vd_seq_check(cmd)) { + if (ps3_qos_vd_seq_check(cmd)) continue; - } ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); } else { ps3_atomic_inc(&qos_vd_mgr->share_cmd_used); ++sent_count; - LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, cmd->cmd_word.type); } } - if (++vd_id > instance->qos_context.max_vd_count) { + if (++vd_id > instance->qos_context.max_vd_count) vd_id = 1; - } } ps3_atomic_sub(sent_count, &qos_tg_ctx->share_free_cnt); LOG_DEBUG("resend vd cmd waitq. host_no:%u poll_vd_id:%u sent:%u\n", - PS3_HOST(instance), vd_id, sent_count); + PS3_HOST(instance), vd_id, sent_count); qos_tg_ctx->poll_vd_id = vd_id; } @@ -1176,13 +1312,14 @@ static void ps3_mgr_cmd_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *wait_q = NULL; struct ps3_instance *instance = qos_tg_ctx->instance; - S32 ret = PS3_SUCCESS; - U32 free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); - U32 sent_count = 0; + int ret = PS3_SUCCESS; + unsigned int free_cnt = ps3_atomic_read(&qos_tg_ctx->share_free_cnt); + unsigned int sent_count = 0; wait_q = &qos_tg_ctx->mgr_cmd_wait_q; if (wait_q->count > 0 && free_cnt > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, + qos_list) { list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; wait_q->count--; @@ -1192,12 +1329,13 @@ static void ps3_mgr_cmd_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_cmd_resend_fail(cmd, ret); } else { - LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, cmd->cmd_word.type); ps3_atomic_inc(&qos_tg_ctx->mgr_share_used); - if(++sent_count == free_cnt) { + if (++sent_count == free_cnt) break; - } } } @@ -1213,19 +1351,21 @@ static void ps3_qos_tg_share_resend(struct ps3_qos_tg_context *qos_tg_ctx) static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) { - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - struct qos_wait_queue *waitq = NULL; - struct ps3_cmd *cmd = NULL; - struct ps3_cmd *cmd_next = NULL; - S32 ret = PS3_SUCCESS; - U8 id = 0; - struct ps3_instance *instance = qos_tg_ctx->instance; - - waitq = &qos_tg_ctx->mgr_cmd_wait_q; - if (waitq->count > 0 && - ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { - if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_free_cnt) < 0) { + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct qos_wait_queue *waitq = NULL; + struct ps3_cmd *cmd = NULL; + struct ps3_cmd *cmd_next = NULL; + int ret = PS3_SUCCESS; + unsigned char id = 0; + struct ps3_instance *instance = qos_tg_ctx->instance; + + waitq = &qos_tg_ctx->mgr_cmd_wait_q; + if (waitq->count > 0 && + ps3_atomic_read(&qos_tg_ctx->mgr_free_cnt) > 0) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, + qos_list) { + if (ps3_atomic_dec_return(&qos_tg_ctx->mgr_free_cnt) < + 0) { ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); break; } @@ -1239,8 +1379,10 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) ps3_qos_cmd_resend_fail(cmd, ret); ps3_atomic_inc(&qos_tg_ctx->mgr_free_cnt); } else { - LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, cmd->cmd_word.type); } } } @@ -1249,30 +1391,41 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) waitq = &qos_tg_ctx->vd_cmd_waitqs[id]; qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[id]; if (waitq->count > 0 && - ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0) { - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { - if (ps3_atomic_dec_return(&qos_vd_mgr->exclusive_cmd_cnt) < 0) { - ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_read(&qos_vd_mgr->exclusive_cmd_cnt) > 0) { + list_for_each_entry_safe(cmd, cmd_next, + &waitq->wait_list, qos_list) { + if (ps3_atomic_dec_return( + &qos_vd_mgr->exclusive_cmd_cnt) < + 0) { + ps3_atomic_inc( + &qos_vd_mgr->exclusive_cmd_cnt); break; } list_del(&cmd->qos_list); cmd->qos_waitq_flag = 0; waitq->count--; qos_tg_ctx->total_wait_cmd_cnt--; - PS3_QOS_STAT_END(instance, cmd, PS3_QOS_TAG_QUEUE); + PS3_QOS_STAT_END(instance, cmd, + PS3_QOS_TAG_QUEUE); if (ps3_qos_vd_seq_check(cmd)) { - ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_inc( + &qos_vd_mgr->exclusive_cmd_cnt); continue; } - ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); + ret = ps3_scsi_cmd_send(instance, cmd, + PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); - ps3_atomic_inc(&qos_vd_mgr->exclusive_cmd_cnt); + ps3_atomic_inc( + &qos_vd_mgr->exclusive_cmd_cnt); } else { - LOG_DEBUG("qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "qos cmd waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), + cmd->trace_id, cmd->index, + cmd->cmd_word.type); } } } @@ -1281,76 +1434,79 @@ static void ps3_qos_tg_exclusive_resend(struct ps3_qos_tg_context *qos_tg_ctx) static void ps3_qos_tg_waitq_resend(struct ps3_qos_tg_context *qos_tg_ctx) { - ULong flag = 0; - Bool waitq_cleard = PS3_FALSE; + unsigned long flag = 0; + unsigned char waitq_cleard = PS3_FALSE; struct ps3_instance *instance = qos_tg_ctx->instance; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); ps3_qos_tg_share_resend(qos_tg_ctx); ps3_qos_tg_exclusive_resend(qos_tg_ctx); - if (qos_tg_ctx->total_wait_cmd_cnt == 0) { + if (qos_tg_ctx->total_wait_cmd_cnt == 0) waitq_cleard = PS3_TRUE; - } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); if (waitq_cleard) { LOG_DEBUG("hno:%u resend all tag waited cmds\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - if (!ps3_qos_vd_notify(instance)) { + if (!ps3_qos_vd_notify(instance)) ps3_qos_pd_notify(instance); - } qos_tg_ctx->last_sched_jiffies = jiffies; } static void ps3_qos_tg_resend_work(struct work_struct *work) { struct ps3_qos_tg_context *qos_tg_ctx = - ps3_container_of(work, struct ps3_qos_tg_context, resend_work); + ps3_container_of(work, struct ps3_qos_tg_context, resend_work); ps3_qos_tg_waitq_resend(qos_tg_ctx); } -U32 g_ps3_qos_cmdq_depth = PS3_QOS_CMDQ_DEPTH; -U32 g_ps3_qos_mgrq_depth = PS3_QOS_MGRQ_DEPTH; -U32 g_ps3_qos_hdd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; -U32 g_ps3_qos_ssd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; -U32 g_ps3_qos_sas_pd_quota = PS3_QOS_SAS_PD_QUOTA; -U32 g_ps3_qos_nvme_pd_quota = PS3_QOS_NVME_DIRECT_QUOTA; -U32 g_ps3_qos_nvme_member_quota = PS3_QOS_NVME_MEMBER_QUOTA; -U32 g_ps3_qos_hba_nvme_normal_quota = PS3_QOS_HBA_NVME_NORMAL_QUOTA; -U32 g_ps3_qos_raid_nvme_normal_quota = PS3_QOS_RAID_NVME_NORMAL_QUOTA; -U32 g_ps3_qos_vd_quota = PS3_QOS_FUNC1_JBOD_VD_QUOTA; -U32 g_ps3_qos_max_cmds = PS3_QOS_HBA_MAX_CMD; -U32 g_ps3_qos_jbod_exclusive = PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT; -U32 g_ps3_qos_vd_exclusive = PS3_QOS_VD_EXCLUSIVE_CMD_COUNT; -U32 g_ps3_qos_mgr_exclusive = QOS_MGR_EXCLUSIVE_CMD_COUNT; +unsigned int g_ps3_qos_cmdq_depth = PS3_QOS_CMDQ_DEPTH; +unsigned int g_ps3_qos_mgrq_depth = PS3_QOS_MGRQ_DEPTH; +unsigned int g_ps3_qos_hdd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; +unsigned int g_ps3_qos_ssd_pd_quota = PS3_QOS_DEFAULT_PD_QUOTA; +unsigned int g_ps3_qos_sas_pd_quota = PS3_QOS_SAS_PD_QUOTA; +unsigned int g_ps3_qos_nvme_pd_quota = PS3_QOS_NVME_DIRECT_QUOTA; +unsigned int g_ps3_qos_nvme_member_quota = PS3_QOS_NVME_MEMBER_QUOTA; +unsigned int g_ps3_qos_hba_nvme_normal_quota = PS3_QOS_HBA_NVME_NORMAL_QUOTA; +unsigned int g_ps3_qos_raid_nvme_normal_quota = PS3_QOS_RAID_NVME_NORMAL_QUOTA; +unsigned int g_ps3_qos_vd_quota = PS3_QOS_FUNC1_JBOD_VD_QUOTA; +unsigned int g_ps3_qos_max_cmds = PS3_QOS_HBA_MAX_CMD; +unsigned int g_ps3_qos_jbod_exclusive = PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT; +unsigned int g_ps3_qos_vd_exclusive = PS3_QOS_VD_EXCLUSIVE_CMD_COUNT; +unsigned int g_ps3_qos_mgr_exclusive = QOS_MGR_EXCLUSIVE_CMD_COUNT; #define PS3_QOS_MAX_WORKQ_NAME_LENGTH 32 -static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) +static int ps3_qos_pd_context_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; - U16 k = 0; + int ret = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; + unsigned short k = 0; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; - U16 max_pd_count = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; + unsigned short max_pd_count = 0; struct qos_wait_queue *waitq = NULL; - U32 cpu_num = 0; + unsigned int cpu_num = 0; qos_pd_ctx = &instance->qos_context.pd_ctx; if (ps3_is_last_func(instance)) { cpu_num = num_online_cpus(); if (instance->irq_context.is_balance_current_perf_mode) { - INJECT_START(PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, instance); - if (cpu_num > instance->irq_context.high_iops_msix_vectors - + PS3_QOS_FUNC1_PD_WORKQ_COUNT) { + INJECT_START(PS3_ERR_IJ_SET_HIGH_IOPS_CHANNEL_IN_QOS, + instance); + if (cpu_num > + instance->irq_context.high_iops_msix_vectors + + PS3_QOS_FUNC1_PD_WORKQ_COUNT) { qos_pd_ctx->workq_count = - cpu_num - instance->irq_context.high_iops_msix_vectors; + cpu_num - + instance->irq_context + .high_iops_msix_vectors; } else { - qos_pd_ctx->workq_count = PS3_QOS_FUNC1_PD_WORKQ_COUNT; + qos_pd_ctx->workq_count = + PS3_QOS_FUNC1_PD_WORKQ_COUNT; } } else { qos_pd_ctx->workq_count = PS3_QOS_FUNC1_PD_WORKQ_COUNT; @@ -1360,16 +1516,17 @@ static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) } max_pd_count = instance->qos_context.max_pd_count; - qos_pd_ctx->qos_pd_mgrs = (struct ps3_qos_pd_mgr *)ps3_vzalloc(instance, - (max_pd_count + 1) * sizeof(struct ps3_qos_pd_mgr)); - INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_2, instance) - if (qos_pd_ctx->qos_pd_mgrs == NULL ) { + qos_pd_ctx->qos_pd_mgrs = (struct ps3_qos_pd_mgr *)ps3_vzalloc( + instance, (max_pd_count + 1) * sizeof(struct ps3_qos_pd_mgr)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_2, instance); + if (qos_pd_ctx->qos_pd_mgrs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_pd_mgrs\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _out; } - memset(qos_pd_ctx->qos_pd_mgrs, 0, sizeof(struct ps3_qos_pd_mgr) * (max_pd_count + 1)); + memset(qos_pd_ctx->qos_pd_mgrs, 0, + sizeof(struct ps3_qos_pd_mgr) * (max_pd_count + 1)); for (i = 1; i <= max_pd_count; i++) { qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; INIT_WORK(&qos_pd_mgr->resend_work, ps3_qos_pd_resend_work); @@ -1387,14 +1544,16 @@ static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) qos_pd_mgr->instance = instance; qos_pd_mgr->total_wait_cmd_cnt = 0; qos_pd_mgr->total_waited_direct_cmd = 0; - qos_pd_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; - qos_pd_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, - qos_pd_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); - INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_3, qos_pd_ctx) + qos_pd_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; + qos_pd_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( + instance, + qos_pd_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_3, qos_pd_ctx); if (qos_pd_mgr->waitqs == NULL) { - LOG_ERROR("hno:%u:Failed to kcalloc memory for pd waitqs\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; + LOG_ERROR( + "hno:%u:Failed to kcalloc memory for pd waitqs\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; goto _release_pd_waitq; } @@ -1405,44 +1564,102 @@ static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) waitq->can_resend = 0; waitq->has_resend = 0; INIT_LIST_HEAD(&waitq->wait_list); - if (j == 0) { + if (j == 0) { waitq->free_rsc = &qos_pd_mgr->direct_quota; - waitq->used_rsc = &qos_pd_mgr->direct_used_quota; + waitq->used_rsc = + &qos_pd_mgr->direct_used_quota; waitq->rsc_lock = &qos_pd_mgr->direct_rsc_lock; - waitq->total_waited_cnt = &qos_pd_mgr->total_waited_direct_cmd; + waitq->total_waited_cnt = + &qos_pd_mgr->total_waited_direct_cmd; } else { waitq->free_rsc = &qos_pd_mgr->pd_quota; waitq->used_rsc = &qos_pd_mgr->pd_used_quota; waitq->rsc_lock = &qos_pd_mgr->rc_lock; - waitq->total_waited_cnt = &qos_pd_mgr->total_wait_cmd_cnt; + waitq->total_waited_cnt = + &qos_pd_mgr->total_wait_cmd_cnt; } } } - qos_pd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc(instance, - (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); - INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_4, instance) + qos_pd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc( + instance, + (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_4, instance); if (qos_pd_ctx->work_queues == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for work_queues\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _release_pd_mgr; } - memset(qos_pd_ctx->work_queues, 0, (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + memset(qos_pd_ctx->work_queues, 0, + (qos_pd_ctx->workq_count) * sizeof(struct workqueue_struct *)); for (j = 0; j < qos_pd_ctx->workq_count; j++) { - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "pd_wq_f%u_%u", - ps3_get_pci_function(instance->pdev), j); - qos_pd_ctx->work_queues[j] = create_singlethread_workqueue(workq_name); - INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_1, qos_pd_ctx) + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, + "pd_wq_f%u_%u", ps3_get_pci_function(instance->pdev), + j); + qos_pd_ctx->work_queues[j] = + create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_1, qos_pd_ctx); if (qos_pd_ctx->work_queues[j] == NULL) { LOG_ERROR("qos pd workq:%u create failed\n", j); ret = -PS3_FAILED; - goto _destroy_created_workqueue; + goto _destroy_created_workqueue; } } + qos_pd_ctx->reply_info = + (struct ps3_qos_pd_reply_info *)ps3_vzalloc(instance, + instance->irq_context.valid_msix_vector_count * + sizeof(struct ps3_qos_pd_reply_info)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_5, instance); + if (qos_pd_ctx->reply_info == NULL) { + LOG_ERROR("hno:%u:Failed to alloc memory for reply_info\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto _destroy_created_workqueue; + } + + for (i = 0; i < instance->irq_context.valid_msix_vector_count; i++) { + qos_pd_ctx->reply_info[i].processed_pd_state = + (unsigned char *)ps3_vzalloc(instance, + PS3_MAX_PD_COUNT(instance) + 1); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_6, instance); + if (qos_pd_ctx->reply_info[i].processed_pd_state == NULL) { + LOG_ERROR("hno:%u:Failed to alloc memory for processed_pd_state\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto __destroy_reply_info; + } + + qos_pd_ctx->reply_info[i].processed_pd_id = + (unsigned short *)ps3_vzalloc(instance, + (PS3_MAX_PD_COUNT(instance) + 1) * sizeof(unsigned short)); + INJECT_START(PS3_ERR_IJ_QOS_PD_INIT_FAIL_7, instance); + if (qos_pd_ctx->reply_info[i].processed_pd_id == NULL) { + LOG_ERROR("hno:%u:Failed to alloc memory for processed_pd_id\n", + PS3_HOST(instance)); + ret = -PS3_FAILED; + goto __destroy_reply_info; + } + + } + LOG_INFO("hno:%u: qos pd context init success\n", PS3_HOST(instance)); goto _out; +__destroy_reply_info: + for (k = 0; k < instance->irq_context.valid_msix_vector_count; k++) { + if (qos_pd_ctx->reply_info[i].processed_pd_state != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[i].processed_pd_state); + qos_pd_ctx->reply_info[i].processed_pd_state = NULL; + } + + if (qos_pd_ctx->reply_info[i].processed_pd_id != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[i].processed_pd_id); + qos_pd_ctx->reply_info[i].processed_pd_id = NULL; + } + } + ps3_vfree(instance, qos_pd_ctx->reply_info); + qos_pd_ctx->reply_info = NULL; _destroy_created_workqueue: for (k = 0; k < j; k++) { destroy_workqueue(qos_pd_ctx->work_queues[k]); @@ -1451,7 +1668,7 @@ static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) ps3_vfree(instance, qos_pd_ctx->work_queues); qos_pd_ctx->work_queues = NULL; _release_pd_waitq: - for (k = 1; k < i; k++) { + for (k = 1; k < i; k++) { qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[k]; if (qos_pd_mgr->waitqs) { ps3_vfree(instance, qos_pd_mgr->waitqs); @@ -1467,7 +1684,7 @@ static S32 ps3_qos_pd_context_init(struct ps3_instance *instance) static void ps3_qos_pd_context_exit(struct ps3_instance *instance) { - U16 i = 0; + unsigned short i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_pd_context *qos_pd_ctx = NULL; struct workqueue_struct *wq = NULL; @@ -1476,7 +1693,7 @@ static void ps3_qos_pd_context_exit(struct ps3_instance *instance) if (qos_pd_ctx->qos_pd_mgrs != NULL) { for (i = 1; i <= instance->qos_context.max_pd_count; i++) { qos_pd_mgr = &qos_pd_ctx->qos_pd_mgrs[i]; - cancel_work_sync(&qos_pd_mgr->resend_work); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); ps3_vfree(instance, qos_pd_mgr->waitqs); qos_pd_mgr->waitqs = NULL; } @@ -1494,18 +1711,32 @@ static void ps3_qos_pd_context_exit(struct ps3_instance *instance) ps3_vfree(instance, qos_pd_ctx->work_queues); qos_pd_ctx->work_queues = NULL; } + + for (i = 0; i < instance->irq_context.valid_msix_vector_count; i++) { + if (qos_pd_ctx->reply_info[i].processed_pd_state != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[i].processed_pd_state); + qos_pd_ctx->reply_info[i].processed_pd_state = NULL; + } + + if (qos_pd_ctx->reply_info[i].processed_pd_id != NULL) { + ps3_vfree(instance, qos_pd_ctx->reply_info[i].processed_pd_id); + qos_pd_ctx->reply_info[i].processed_pd_id = NULL; + } + } + ps3_vfree(instance, qos_pd_ctx->reply_info); + qos_pd_ctx->reply_info = NULL; } -static S32 ps3_qos_vd_context_init(struct ps3_instance *instance) +static int ps3_qos_vd_context_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; + int ret = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; - U16 max_vd_count = 0; - U16 jbod_vd_quota = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; + unsigned short max_vd_count = 0; + unsigned short jbod_vd_quota = 0; qos_vd_ctx = &instance->qos_context.vd_ctx; if (ps3_is_last_func(instance)) { @@ -1516,19 +1747,21 @@ static S32 ps3_qos_vd_context_init(struct ps3_instance *instance) qos_vd_ctx->jbod_exclusive_cnt = 0; } - jbod_vd_quota = instance->qos_context.tg_ctx.share + qos_vd_ctx->jbod_exclusive_cnt; + jbod_vd_quota = instance->qos_context.tg_ctx.share + + qos_vd_ctx->jbod_exclusive_cnt; max_vd_count = instance->qos_context.max_vd_count; - qos_vd_ctx->qos_vd_mgrs = (struct ps3_qos_vd_mgr *)ps3_vzalloc(instance, - (max_vd_count + 1) * sizeof(struct ps3_qos_vd_mgr)); - INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_1, instance) - if (qos_vd_ctx->qos_vd_mgrs == NULL ) { + qos_vd_ctx->qos_vd_mgrs = (struct ps3_qos_vd_mgr *)ps3_vzalloc( + instance, (max_vd_count + 1) * sizeof(struct ps3_qos_vd_mgr)); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_1, instance); + if (qos_vd_ctx->qos_vd_mgrs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_vd_mgrs\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _out; } - memset(qos_vd_ctx->qos_vd_mgrs, 0, sizeof(struct ps3_qos_vd_mgr) * (max_vd_count + 1)); + memset(qos_vd_ctx->qos_vd_mgrs, 0, + sizeof(struct ps3_qos_vd_mgr) * (max_vd_count + 1)); for (i = 1; i <= max_vd_count; i++) { qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; qos_vd_mgr->instance = instance; @@ -1539,36 +1772,42 @@ static S32 ps3_qos_vd_context_init(struct ps3_instance *instance) INIT_WORK(&qos_vd_mgr->resend_work, ps3_qos_vd_resend_work); qos_vd_mgr->workq_id = 0; qos_vd_mgr->id = i; - if (i == max_vd_count) { + if (i == max_vd_count) { ps3_atomic_set(&qos_vd_mgr->vd_quota, jbod_vd_quota); - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, qos_vd_ctx->jbod_exclusive_cnt); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, + qos_vd_ctx->jbod_exclusive_cnt); qos_vd_mgr->valid = PS3_TRUE; } else { - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, qos_vd_ctx->vd_exclusive_cnt); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, + qos_vd_ctx->vd_exclusive_cnt); } ps3_atomic_set(&qos_vd_mgr->share_cmd_used, 0); } qos_vd_ctx->workq_count = 1; - qos_vd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc(instance, - (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); - INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_2, instance) + qos_vd_ctx->work_queues = (struct workqueue_struct **)ps3_vzalloc( + instance, + (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_2, instance); if (qos_vd_ctx->work_queues == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for work_queues\n", PS3_HOST(instance)); - ret = -PS3_FAILED; + ret = -PS3_FAILED; goto _release_vd_mgr; } - memset(qos_vd_ctx->work_queues, 0, (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); + memset(qos_vd_ctx->work_queues, 0, + (qos_vd_ctx->workq_count) * sizeof(struct workqueue_struct *)); for (i = 0; i < qos_vd_ctx->workq_count; i++) { - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_vd_wq_f%u_%u", + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, + "vd_wq_f%u_%u", ps3_get_pci_function(instance->pdev), i); - qos_vd_ctx->work_queues[i] = create_singlethread_workqueue(workq_name); - INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_3, instance) + qos_vd_ctx->work_queues[i] = + create_singlethread_workqueue(workq_name); + INJECT_START(PS3_ERR_IJ_QOS_VD_INIT_FAIL_3, instance); if (qos_vd_ctx->work_queues[i] == NULL) { LOG_ERROR("qos vd workq:%u create failed\n", i); ret = -PS3_FAILED; - goto _destroy_created_workqueue; + goto _destroy_created_workqueue; } } @@ -1591,7 +1830,7 @@ static S32 ps3_qos_vd_context_init(struct ps3_instance *instance) static void ps3_qos_vd_context_exit(struct ps3_instance *instance) { - U16 i = 0; + unsigned short i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_vd_context *qos_vd_ctx = NULL; struct workqueue_struct *wq = NULL; @@ -1600,7 +1839,7 @@ static void ps3_qos_vd_context_exit(struct ps3_instance *instance) if (qos_vd_ctx->qos_vd_mgrs != NULL) { for (i = 1; i <= instance->qos_context.max_vd_count; i++) { qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; - cancel_work_sync(&qos_vd_mgr->resend_work); + ps3_cancel_work_sync(&qos_vd_mgr->resend_work); } ps3_vfree(instance, qos_vd_ctx->qos_vd_mgrs); qos_vd_ctx->qos_vd_mgrs = NULL; @@ -1617,23 +1856,23 @@ static void ps3_qos_vd_context_exit(struct ps3_instance *instance) } } -static S32 ps3_qos_tg_context_init(struct ps3_instance *instance) +static int ps3_qos_tg_context_init(struct ps3_instance *instance) { struct ps3_qos_tg_context *qos_tg_ctx = NULL; - S32 ret = PS3_SUCCESS; - U64 tfifo_depth = 0; - U16 i = 0; + int ret = PS3_SUCCESS; + unsigned long long tfifo_depth = 0; + unsigned short i = 0; struct qos_wait_queue *wait_q = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; - U32 tag_exclusive = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; + unsigned int tag_exclusive = 0; ps3_tfifo_depth_get(instance, &tfifo_depth); - INJECT_START(PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, &tfifo_depth) + INJECT_START(PS3_ERR_IJ_QOS_FORCE_TFIFO_ZERO_DEPTH, &tfifo_depth); if (tfifo_depth == 0) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:tfifo_depth is invalid func:%u\n", - PS3_HOST(instance), - ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), + ps3_get_pci_function(instance->pdev)); goto out; } qos_tg_ctx = &instance->qos_context.tg_ctx; @@ -1642,24 +1881,32 @@ static S32 ps3_qos_tg_context_init(struct ps3_instance *instance) qos_tg_ctx->high_pri_exclusive_cnt = QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT; qos_tg_ctx->mgr_exclusive_cnt = g_ps3_qos_mgr_exclusive; if (!ps3_ioc_multi_func_support(instance)) { - tag_exclusive = qos_tg_ctx->mgr_exclusive_cnt + qos_tg_ctx->high_pri_exclusive_cnt + - g_ps3_qos_jbod_exclusive + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive; + tag_exclusive = + qos_tg_ctx->mgr_exclusive_cnt + + qos_tg_ctx->high_pri_exclusive_cnt + + g_ps3_qos_jbod_exclusive + + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive; } else { - qos_tg_ctx->high_pri_exclusive_cnt = qos_tg_ctx->high_pri_exclusive_cnt >> 1; - qos_tg_ctx->mgr_exclusive_cnt = qos_tg_ctx->mgr_exclusive_cnt >> 1; - tag_exclusive = qos_tg_ctx->high_pri_exclusive_cnt + qos_tg_ctx->mgr_exclusive_cnt; + qos_tg_ctx->high_pri_exclusive_cnt = + qos_tg_ctx->high_pri_exclusive_cnt >> 1; + qos_tg_ctx->mgr_exclusive_cnt = + qos_tg_ctx->mgr_exclusive_cnt >> 1; + tag_exclusive = qos_tg_ctx->high_pri_exclusive_cnt + + qos_tg_ctx->mgr_exclusive_cnt; if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1) { - tag_exclusive += (g_ps3_qos_jbod_exclusive + instance->ctrl_info.maxVdCount * g_ps3_qos_vd_exclusive); + tag_exclusive += (g_ps3_qos_jbod_exclusive + + instance->ctrl_info.maxVdCount * + g_ps3_qos_vd_exclusive); } } - if (tfifo_depth > tag_exclusive) { + if (tfifo_depth > tag_exclusive) qos_tg_ctx->share = tfifo_depth - tag_exclusive; - } else { + else qos_tg_ctx->share = tag_exclusive; - } - ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, qos_tg_ctx->mgr_exclusive_cnt); + ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, + qos_tg_ctx->mgr_exclusive_cnt); ps3_atomic_set(&qos_tg_ctx->share_free_cnt, qos_tg_ctx->share); ps3_atomic_set(&qos_tg_ctx->mgr_share_used, 0); ps3_spin_lock_init(&qos_tg_ctx->lock); @@ -1667,33 +1914,38 @@ static S32 ps3_qos_tg_context_init(struct ps3_instance *instance) wait_q = &qos_tg_ctx->mgr_cmd_wait_q; INIT_LIST_HEAD(&wait_q->wait_list); - qos_tg_ctx->vd_cmd_waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, - (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); - INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_1, qos_tg_ctx) + qos_tg_ctx->vd_cmd_waitqs = (struct qos_wait_queue *)ps3_vzalloc( + instance, (instance->qos_context.max_vd_count + 1) * + sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_1, qos_tg_ctx); if (qos_tg_ctx->vd_cmd_waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for qos_context\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto out; } - memset(qos_tg_ctx->vd_cmd_waitqs, 0, (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); + memset(qos_tg_ctx->vd_cmd_waitqs, 0, + (instance->qos_context.max_vd_count + 1) * + sizeof(struct qos_wait_queue)); for (i = 1; i < instance->qos_context.max_vd_count + 1; i++) { - wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; + wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; INIT_LIST_HEAD(&wait_q->wait_list); } INIT_WORK(&qos_tg_ctx->resend_work, ps3_qos_tg_resend_work); - snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_tag_wq_f%u", ps3_get_pci_function(instance->pdev)); + snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "qos_tag_wq_f%u", + ps3_get_pci_function(instance->pdev)); qos_tg_ctx->work_queue = create_singlethread_workqueue(workq_name); - INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_2, qos_tg_ctx) + INJECT_START(PS3_ERR_IJ_QOS_TAG_INIT_FAIL_2, qos_tg_ctx); if (qos_tg_ctx->work_queue == NULL) { LOG_ERROR("qos tag workq:%u create failed\n", i); ret = -PS3_FAILED; - goto release_vd_cmd_waitqs; + goto release_vd_cmd_waitqs; } LOG_INFO("hno:%u func:%u: qos tg context init success tfifo:%llu\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev), tfifo_depth); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev), + tfifo_depth); goto out; release_vd_cmd_waitqs: ps3_vfree(instance, qos_tg_ctx->vd_cmd_waitqs); @@ -1708,7 +1960,7 @@ static void ps3_qos_tg_context_exit(struct ps3_instance *instance) qos_tg_ctx = &instance->qos_context.tg_ctx; if (qos_tg_ctx->work_queue != NULL) { - cancel_work_sync(&qos_tg_ctx->resend_work); + ps3_cancel_work_sync(&qos_tg_ctx->resend_work); flush_workqueue(qos_tg_ctx->work_queue); destroy_workqueue(qos_tg_ctx->work_queue); qos_tg_ctx->work_queue = NULL; @@ -1720,24 +1972,21 @@ static void ps3_qos_tg_context_exit(struct ps3_instance *instance) } } -S32 ps3_hba_qos_init(struct ps3_instance *instance) +int ps3_hba_qos_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ret = ps3_qos_tg_context_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _out; - } ret = ps3_qos_vd_context_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _tg_ctx_exit; - } ret = ps3_qos_pd_context_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _vd_ctx_exit; - } goto _out; _vd_ctx_exit: @@ -1757,13 +2006,13 @@ void ps3_hba_qos_exit(struct ps3_instance *instance) LOG_INFO("hba qos exit. host_no:%u\n", PS3_HOST(instance)); } -static Bool ps3_qos_vd_member_insert(struct ps3_cmd *cmd) +static unsigned char ps3_qos_vd_member_insert(struct ps3_cmd *cmd) { - U8 i = 0; - U16 disk_id = 0; + unsigned char i = 0; + unsigned short disk_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - Bool in_queue = PS3_FALSE; + unsigned char in_queue = PS3_FALSE; for (i = 0; i < cmd->target_pd_count; i++) { disk_id = cmd->target_pd[i].flat_disk_id; @@ -1771,9 +2020,11 @@ static Bool ps3_qos_vd_member_insert(struct ps3_cmd *cmd) ps3_atomic_inc(&qos_pd_mgr->processing_cnt); INJECT_START(PS3_ERR_IJ_QOS_VD_MEMBER_CLEARING, qos_pd_mgr); if (unlikely(qos_pd_mgr->clearing)) { - LOG_DEBUG("qos vd member is clearing .host_no:%u:t_id:0x%llx CFID:%u did[%u %u]\n", - PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, cmd->index, - qos_pd_mgr->disk_id, qos_pd_mgr->vd_id); + LOG_DEBUG( + "qos vd member is clearing .host_no:%u:t_id:0x%llx CFID:%u did[%u %u]\n", + PS3_HOST(qos_pd_mgr->instance), cmd->trace_id, + cmd->index, qos_pd_mgr->disk_id, + qos_pd_mgr->vd_id); ps3_atomic_dec(&qos_pd_mgr->processing_cnt); } else { in_queue = PS3_TRUE; @@ -1783,25 +2034,30 @@ static Bool ps3_qos_vd_member_insert(struct ps3_cmd *cmd) if (in_queue) { waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); - ps3_qos_pd_in_q(cmd, waitq, i); + INJECT_START(PS3_ERR_IJ_QOS_VD_IN_PD_Q_BLOCK, cmd->instance); + if(!ps3_qos_pd_in_q(cmd, waitq, i)) { + cmd->target_pd[i].get_quota = PS3_TRUE; + in_queue = PS3_FALSE; + } + ps3_atomic_dec(&qos_pd_mgr->processing_cnt); - LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx" - " CFID:%u waitq[%u,%u] did[%u %u]\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, - waitq->id, waitq->count, qos_pd_mgr->disk_id, i); + LOG_DEBUG("insert qos pd quota waitq.host_no:%u:t_id:0x%llx\n" + "\tCFID:%u waitq[%u,%u] did[%u %u] ret:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + waitq->id, waitq->count, qos_pd_mgr->disk_id, i, in_queue); } return in_queue; } -static Bool ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) +static unsigned char ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 disk_id = 0; - U16 i = 0; + unsigned short disk_id = 0; + unsigned short i = 0; struct scsi_device *sdev = NULL; - S32 pd_quota = 0; + int pd_quota = 0; PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_PD_PRO); if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { @@ -1816,23 +2072,20 @@ static Bool ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) } } - if (cmd->target_pd_count == 0) { + if (cmd->target_pd_count == 0) can_get = PS3_TRUE; - } if (!can_get) { - if (!ps3_qos_vd_member_insert(cmd)) { + if (!ps3_qos_vd_member_insert(cmd)) can_get = PS3_TRUE; - } } - } else { + } else { disk_id = cmd->io_attr.disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); - if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) { + if (ps3_is_nvme_direct_cmd(qos_pd_mgr, cmd)) pd_quota = qos_pd_mgr->direct_quota; - } else { + else pd_quota = qos_pd_mgr->pd_quota; - } sdev = cmd->scmd->device; if (pd_quota >= sdev->queue_depth) { can_get = PS3_TRUE; @@ -1845,62 +2098,62 @@ static Bool ps3_qos_pd_quota_decision(struct ps3_cmd *cmd) return can_get; } -static Bool ps3_qos_vd_quota_decision(struct ps3_cmd *cmd) +static unsigned char ps3_qos_vd_quota_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_TRUE; + unsigned char can_get = PS3_TRUE; PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_VD_PRO); - if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD){ + if (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) can_get = ps3_qos_vd_quota_check(cmd); - } PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_VD_PRO); return can_get; } -static inline Bool ps3_qos_dev_valid(struct ps3_cmd *cmd) +static inline unsigned char ps3_qos_dev_valid(struct ps3_cmd *cmd) { - Bool valid = PS3_TRUE; - struct ps3_scsi_priv_data* priv_data = NULL; + unsigned char valid = PS3_TRUE; + struct ps3_scsi_priv_data *priv_data = NULL; priv_data = scsi_device_private_data(cmd->scmd); if (priv_data->dev_deling) { LOG_INFO_LIM("qos dev is deling. host_no:%u chanel:%u id:%u\n", - PS3_HOST(cmd->instance), - PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device)); + PS3_HOST(cmd->instance), + PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device)); valid = PS3_FALSE; } return valid; } -static S32 ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) +static int ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance) + INJECT_START(PS3_ERR_IJ_FORCE_TASK_MGR_BUSY, instance); if (instance->task_manager_host_busy) { LOG_INFO_LIM("hno:%u task_manager_host_busy\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_INS_UNLOAD, instance) + INJECT_START(PS3_ERR_IJ_FORCE_INS_UNLOAD, instance); if (instance->is_probe_finish && !instance->state_machine.is_load) { - LOG_INFO_LIM("hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state not is_load\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - if (!ps3_qos_dev_valid(cmd)){ + if (!ps3_qos_dev_valid(cmd)) ret = -PS3_FAILED; - } - INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance) + INJECT_START(PS3_ERR_IJ_FORCE_INSTANCE_UNNORMAL, instance); if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { - LOG_INFO_LIM("hno:%u instance state is not normal\n", PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state is not normal\n", + PS3_HOST(instance)); ret = -PS3_RECOVERED; goto l_out; } @@ -1908,62 +2161,64 @@ static S32 ps3_qos_pre_check(struct ps3_instance *instance, struct ps3_cmd *cmd) return ret; } -Bool ps3_hba_qos_decision(struct ps3_cmd *cmd) +static unsigned char ps3_hba_qos_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; + if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { - can_get = ps3_qos_pd_quota_decision(cmd); - if (!can_get || - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { + can_get = ps3_qos_pd_quota_decision(cmd); + if (!can_get || + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { goto _out; } - can_get = ps3_qos_vd_quota_decision(cmd); - if (!can_get) { + can_get = ps3_qos_vd_quota_decision(cmd); + if (!can_get) goto _out; - } } - can_get = ps3_qos_tg_decision(cmd); + can_get = ps3_qos_tg_decision(cmd); _out: return can_get; } -void ps3_hba_qos_waitq_notify(struct ps3_instance *instance) +static void ps3_hba_qos_waitq_notify(struct ps3_instance *instance, + unsigned short isr_sn) { if (!ps3_qos_tg_notify(instance)) { - if (!ps3_qos_vd_notify(instance)) { - ps3_qos_pd_notify(instance); - } + if (!ps3_qos_vd_notify(instance)) + ps3_qos_pd_notify_in_reply(instance, isr_sn); } } -static Bool ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) +static unsigned char ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) { - ULong lock_flag_pd = 0; - U16 disk_id = 0; - Bool found = PS3_FALSE; + unsigned long lock_flag_pd = 0; + unsigned short disk_id = 0; + unsigned char found = PS3_FALSE; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct qos_wait_queue *waitq = NULL; - U16 index = 0; + unsigned short index = 0; - for (index = cmd->first_over_quota_pd_idx; - index < cmd->target_pd_count; index++) { + for (index = cmd->first_over_quota_pd_idx; index < cmd->target_pd_count; + index++) { disk_id = cmd->target_pd[index].flat_disk_id; qos_pd_mgr = ps3_qos_pd_mgr_get(cmd->instance, disk_id); waitq = ps3_qos_pd_waitq_get(qos_pd_mgr, cmd); ps3_spin_lock_irqsave(waitq->rsc_lock, &lock_flag_pd); if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD && - index == cmd->first_over_quota_pd_idx) { + index == cmd->first_over_quota_pd_idx) { list_del(&cmd->qos_list); waitq->count--; (*waitq->total_waited_cnt)--; - ps3_spin_unlock_irqrestore(waitq->rsc_lock, lock_flag_pd); + ps3_spin_unlock_irqrestore(waitq->rsc_lock, + lock_flag_pd); found = PS3_TRUE; break; } ps3_spin_unlock_irqrestore(waitq->rsc_lock, lock_flag_pd); - LOG_INFO("abort pd waitq. t_id:0x%llx did[%u,%u] qid:%u found:%u\n", + LOG_INFO( + "abort pd waitq. t_id:0x%llx did[%u,%u] qid:%u found:%u\n", cmd->trace_id, index, disk_id, waitq->id, found); } @@ -1972,8 +2227,8 @@ static Bool ps3_pd_quota_waiq_abort(struct ps3_cmd *cmd) static bool ps3_vd_quota_waiq_abort(struct ps3_cmd *aborted_cmd) { - ULong flag = 0; - Bool found = PS3_FALSE; + unsigned long flag = 0; + unsigned char found = PS3_FALSE; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; qos_vd_mgr = ps3_qos_vd_mgr_get(aborted_cmd); @@ -1988,11 +2243,11 @@ static bool ps3_vd_quota_waiq_abort(struct ps3_cmd *aborted_cmd) return found; } -bool ps3_cmd_waitq_abort(struct ps3_cmd *aborted_cmd) +static bool ps3_cmd_waitq_abort(struct ps3_cmd *aborted_cmd) { - ULong lock_flag_mgr = 0; + unsigned long lock_flag_mgr = 0; struct ps3_instance *instance = NULL; - Bool found = PS3_FALSE; + unsigned char found = PS3_FALSE; struct qos_wait_queue *cmd_wait_q = NULL; struct ps3_qos_tg_context *qos_tg_ctx = NULL; @@ -2011,25 +2266,24 @@ bool ps3_cmd_waitq_abort(struct ps3_cmd *aborted_cmd) return found; } -static Bool ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) +static unsigned char ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) { - Bool found = PS3_FALSE; - if (cmd->qos_waitq_flag == 0) { + unsigned char found = PS3_FALSE; + + if (cmd->qos_waitq_flag == 0) goto out; - } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD) { found = ps3_pd_quota_waiq_abort(cmd); - if (found) { + if (found) goto out; - } } if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_VD) { found = ps3_vd_quota_waiq_abort(cmd); if (found) { - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); goto out; } } @@ -2039,16 +2293,17 @@ static Bool ps3_hba_qos_waitq_abort(struct ps3_cmd *cmd) found = ps3_cmd_waitq_abort(cmd); if (found) { ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); } } out: return found; } -static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, U16 disk_id, int result) +static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, + unsigned short disk_id, int result) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; @@ -2056,70 +2311,86 @@ static void ps3_vd_cmd_waitq_clean(struct ps3_instance *instance, U16 disk_id, i ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { - LOG_DEBUG("qos clean vd cmd waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, disk_id); + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, + qos_list) { + LOG_DEBUG( + "qos clean vd cmd waitq. hno:%u t_id:0x%llx cmd:%d vd_id:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, + PS3_FALSE); } } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); } static void ps3_jbod_cmd_waitq_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, int result) + struct ps3_scsi_priv_data *priv_data, + int result) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; - struct qos_wait_queue *wait_q = &qos_tg_ctx->vd_cmd_waitqs - [instance->qos_context.max_vd_count]; - U16 disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + struct qos_wait_queue *wait_q = + &qos_tg_ctx->vd_cmd_waitqs[instance->qos_context.max_vd_count]; + unsigned short disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, + qos_list) { if (scsi_device_private_data(cmd->scmd) == priv_data) { - LOG_DEBUG("qos clean jbod cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - priv_data->dev_type, disk_id); + LOG_DEBUG( + "qos clean jbod cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, priv_data->dev_type, + disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, + result, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); } -static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, int result) +static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, + int result) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; struct qos_wait_queue *wait_q = &qos_tg_ctx->mgr_cmd_wait_q; - U16 disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; + unsigned short disk_id = priv_data->disk_pos.diskDev.ps3Dev.virtDiskID; ps3_spin_lock_irqsave(&qos_tg_ctx->lock, &flag); if (wait_q->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, qos_list) { - if (cmd->scmd && scsi_device_private_data(cmd->scmd) == priv_data) { - LOG_DEBUG("qos clean mgr cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, - priv_data->dev_type, disk_id); + list_for_each_entry_safe(cmd, cmd_next, &wait_q->wait_list, + qos_list) { + if (cmd->scmd && + scsi_device_private_data(cmd->scmd) == priv_data) { + LOG_DEBUG( + "qos clean mgr cmd waitq. hno:%u t_id:0x%llx cmd:%d dev_t:%u diskid:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, priv_data->dev_type, + disk_id); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, result, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, + result, PS3_FALSE); } } } @@ -2127,71 +2398,77 @@ static void ps3_mgr_cmd_waitq_clean(struct ps3_instance *instance, struct ps3_sc } static void ps3_hba_qos_vd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - U16 vd_id = 0; - U16 pd_id = 0; + unsigned short vd_id = 0; + unsigned short pd_id = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&priv_data->disk_pos)); - qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, PS3_VDID(&priv_data->disk_pos)); + vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&priv_data->disk_pos)); + qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, + PS3_VDID(&priv_data->disk_pos)); for (pd_id = 1; pd_id <= instance->qos_context.max_pd_count; pd_id++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && - qos_pd_mgr->vd_id == vd_id) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, resp_status); - cancel_work_sync(&qos_pd_mgr->resend_work); + qos_pd_mgr->vd_id == vd_id) { + ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, + resp_status); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); } } ps3_vd_quota_waitq_clean(qos_vd_mgr, NULL, resp_status); - cancel_work_sync(&qos_vd_mgr->resend_work); + ps3_cancel_work_sync(&qos_vd_mgr->resend_work); ps3_vd_cmd_waitq_clean(instance, vd_id, resp_status); ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", - PS3_HOST(instance), priv_data->dev_type, vd_id); + PS3_HOST(instance), priv_data->dev_type, vd_id); } -#define PS3_QOS_JBOD_VD_MGR(instance) \ - (&instance->qos_context.vd_ctx.qos_vd_mgrs[instance->qos_context.max_vd_count]) +#define PS3_QOS_JBOD_VD_MGR(instance) \ + (&instance->qos_context.vd_ctx \ + .qos_vd_mgrs[instance->qos_context.max_vd_count]) -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) -void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) +#if defined(PS3_SUPPORT_LINX80) +void ps3_linx80_vd_member_change(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry) { - U16 pd_id = 0; + unsigned short pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - if (!PS3_QOS_INITED(instance)) { + + if (!PS3_QOS_INITED(instance)) goto _out; - } pd_id = PS3_PDID(&pd_entry->disk_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); - if (ps3_atomic_read(&qos_pd_mgr->valid) != PS3_TRUE) { + if (ps3_atomic_read(&qos_pd_mgr->valid) != PS3_TRUE) goto _out; - } ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, PS3_STATUS_VD_MEMBER_OFFLINE); - cancel_work_sync(&qos_pd_mgr->resend_work); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); LOG_INFO("linx80 update pd qos rsc. host_no:%u pd_id:%u dev_type:%u\n", - PS3_HOST(instance), pd_id, pd_entry->dev_type); + PS3_HOST(instance), pd_id, pd_entry->dev_type); _out: return; } #endif static void ps3_hba_qos_pd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - U16 disk_id = 0; + unsigned short disk_id = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; disk_id = PS3_PDID(&priv_data->disk_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, disk_id); ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, resp_status); - cancel_work_sync(&qos_pd_mgr->resend_work); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); qos_vd_mgr = PS3_QOS_JBOD_VD_MGR(instance); ps3_vd_quota_waitq_clean(qos_vd_mgr, priv_data, resp_status); @@ -2199,139 +2476,143 @@ static void ps3_hba_qos_pd_clean(struct ps3_instance *instance, ps3_mgr_cmd_waitq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean pd. host_no:%u diskid:%u\n", - PS3_HOST(instance), disk_id); + PS3_HOST(instance), disk_id); } static void ps3_qos_wait_io_end(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; + LOG_DEBUG("host_no:%u wait cmd in qos flighting start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); for (i = 0; i < instance->cmd_context.max_scsi_cmd_count; i++) { cmd = instance->cmd_context.cmd_buf[i]; - while (cmd->qos_processing) { + while (cmd->qos_processing) ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - } } LOG_DEBUG("host_no:%u wait cmd in qos flighting end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, - S32 resp_status) +void ps3_qos_device_clean(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, int resp_status) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } ps3_qos_wait_io_end(instance); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { - instance->qos_context.opts.qos_vd_clean(instance, priv_data, resp_status); + instance->qos_context.opts.qos_vd_clean(instance, priv_data, + resp_status); } else { - instance->qos_context.opts.qos_pd_clean(instance, priv_data, resp_status); + instance->qos_context.opts.qos_pd_clean(instance, priv_data, + resp_status); } } static inline void ps3_qos_dev_end(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data) + struct ps3_scsi_priv_data *priv_data) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct scsi_cmnd *scmd = NULL; struct scsi_device *sdev = NULL; - U32 softChan = PS3_CHANNEL(&priv_data->disk_pos); - U32 devID = PS3_TARGET(&priv_data->disk_pos); + unsigned int softChan = PS3_CHANNEL(&priv_data->disk_pos); + unsigned int devID = PS3_TARGET(&priv_data->disk_pos); LOG_DEBUG("host_no:%u dev wait cmd in qos flighting start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); for (i = 0; i < instance->cmd_context.max_scsi_cmd_count; i++) { cmd = instance->cmd_context.cmd_buf[i]; - if (likely(!cmd->qos_processing)) { + if (likely(!cmd->qos_processing)) continue; - } scmd = cmd->scmd; - if (scmd == NULL) { + if (scmd == NULL) continue; - } sdev = scmd->device; - if (sdev == NULL) { + if (sdev == NULL) continue; - } if (PS3_SDEV_CHANNEL(sdev) == softChan && - PS3_SDEV_TARGET(sdev) == devID) { + PS3_SDEV_TARGET(sdev) == devID) { LOG_DEBUG("cmd is flighting. host_no:%u CFID:%u\n", - PS3_HOST(instance), cmd->index); - while (cmd->qos_processing) { + PS3_HOST(instance), cmd->index); + while (cmd->qos_processing) ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - } } } LOG_DEBUG("host_no:%u dev wait cmd in qos flighting end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_qos_disk_del(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data) +void ps3_qos_disk_del(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 disk_id = 0; - S32 resp_status = PS3_STATUS_DEVICE_NOT_FOUND; + unsigned short disk_id = 0; + int resp_status = PS3_STATUS_DEVICE_NOT_FOUND; - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } priv_data->dev_deling = PS3_TRUE; - wmb(); + wmb(); /* in order to force CPU ordering */ disk_id = PS3_PDID(&priv_data->disk_pos); LOG_FILE_INFO("qos disk del. host_no:%u dev_t:%u diskid:%u\n", - PS3_HOST(instance), priv_data->dev_type, disk_id); + PS3_HOST(instance), priv_data->dev_type, disk_id); if (priv_data->dev_type == PS3_DEV_TYPE_VD) { ps3_qos_dev_end(instance, priv_data); - instance->qos_context.opts.qos_vd_clean(instance, priv_data, resp_status); + instance->qos_context.opts.qos_vd_clean(instance, priv_data, + resp_status); } else { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, disk_id); ps3_qos_dev_end(instance, priv_data); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { resp_status = PS3_STATUS_VD_MEMBER_OFFLINE; qos_pd_mgr->clearing = PS3_TRUE; - wmb(); - LOG_INFO("host_no:%u wait cmd in qos vd member flighting count:%d did:%u\n", + wmb(); /* in order to force CPU ordering */ + LOG_INFO( + "host_no:%u wait cmd in qos vd member flighting count:%d did:%u\n", PS3_HOST(instance), - ps3_atomic_read(&qos_pd_mgr->processing_cnt), disk_id); - while (ps3_atomic_read(&qos_pd_mgr->processing_cnt) > 0) { + ps3_atomic_read(&qos_pd_mgr->processing_cnt), + disk_id); + while (ps3_atomic_read(&qos_pd_mgr->processing_cnt) > + 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); } } - instance->qos_context.opts.qos_pd_clean(instance, priv_data, resp_status); + instance->qos_context.opts.qos_pd_clean(instance, priv_data, + resp_status); } } -void ps3_qos_vd_member_del(struct ps3_instance *instance, struct PS3DiskDevPos *dev_pos) +void ps3_qos_vd_member_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 disk_id = 0; + unsigned short disk_id = 0; disk_id = PS3_PDID(dev_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, disk_id); - LOG_INFO("qos disk del. host_no:%u did:%u vid:%u\n", - PS3_HOST(instance), disk_id, qos_pd_mgr->vd_id); + LOG_INFO("qos disk del. host_no:%u did:%u vid:%u\n", PS3_HOST(instance), + disk_id, qos_pd_mgr->vd_id); if (PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, PS3_STATUS_VD_MEMBER_OFFLINE); + ps3_pd_quota_waitq_clean(qos_pd_mgr, 0, + PS3_STATUS_VD_MEMBER_OFFLINE); } } -void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) +static void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) { - ULong flag = 0; - U16 i = 0; + unsigned long flag = 0; + unsigned short i = 0; struct ps3_qos_tg_context *qos_tg_ctx = &instance->qos_context.tg_ctx; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct qos_wait_queue *wait_q = NULL; struct ps3_cmd *cmd = NULL; @@ -2339,7 +2620,7 @@ void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { ps3_pd_quota_waitq_clear_all(qos_pd_mgr, resp_status); - cancel_work_sync(&qos_pd_mgr->resend_work); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); } } @@ -2347,7 +2628,7 @@ void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[i]; if (qos_vd_mgr->valid) { ps3_vd_quota_waitq_clean(qos_vd_mgr, NULL, resp_status); - cancel_work_sync(&qos_vd_mgr->resend_work); + ps3_cancel_work_sync(&qos_vd_mgr->resend_work); } } @@ -2355,40 +2636,49 @@ void ps3_hba_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) for (i = 1; i <= instance->qos_context.max_vd_count; i++) { wait_q = &qos_tg_ctx->vd_cmd_waitqs[i]; while (wait_q->count > 0) { - cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, qos_list); - LOG_DEBUG("qos clear tg vd waitq. hno:%u qid:%u t_id:0x%llx cmd:%d\n", - PS3_HOST(instance), i, cmd->trace_id, cmd->index); + cmd = list_first_entry(&wait_q->wait_list, + struct ps3_cmd, qos_list); + LOG_DEBUG( + "qos clear tg vd waitq. hno:%u qid:%u t_id:0x%llx cmd:%d\n", + PS3_HOST(instance), i, cmd->trace_id, + cmd->index); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; ps3_qos_update_vd_quota(cmd); - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, + PS3_FALSE); } } wait_q = &qos_tg_ctx->mgr_cmd_wait_q; while (wait_q->count > 0) { - cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, qos_list); + cmd = list_first_entry(&wait_q->wait_list, struct ps3_cmd, + qos_list); LOG_DEBUG("qos clear tg mgr waitq. hno:%u t_id:0x%llx cmd:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index); + PS3_HOST(instance), cmd->trace_id, cmd->index); list_del(&cmd->qos_list); wait_q->count--; qos_tg_ctx->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, + PS3_FALSE); } ps3_spin_unlock_irqrestore(&qos_tg_ctx->lock, flag); - cancel_work_sync(&qos_tg_ctx->resend_work); + ps3_cancel_work_sync(&qos_tg_ctx->resend_work); LOG_INFO("host_no:%u:clear all qos waitq\n", PS3_HOST(instance)); } -static inline U16 ps3_qos_pd_workq_id_get(struct ps3_qos_pd_context *qos_pd_ctx) +static inline unsigned short +ps3_qos_pd_workq_id_get(struct ps3_qos_pd_context *qos_pd_ctx) { - return ps3_atomic_inc_return(&qos_pd_ctx->workq_id_cnt) % qos_pd_ctx->workq_count; + return ps3_atomic_inc_return(&qos_pd_ctx->workq_id_cnt) % + qos_pd_ctx->workq_count; } -void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry) +void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_pd_entry *pd_entry) { struct ps3_qos_pd_context *pd_ctx = NULL; struct PS3QosInfo *qos_cfg_info = NULL; @@ -2398,108 +2688,127 @@ void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry qos_pd_mgr->direct_quota = pd_entry->direct_quota; qos_pd_mgr->dev_type = pd_entry->dev_type; switch (pd_entry->dev_type) { - case PS3_DEV_TYPE_SAS_HDD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = qos_cfg_info->sasHddQuota > 0 ? - qos_cfg_info->sasHddQuota : g_ps3_qos_sas_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SAS_SSD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = qos_cfg_info->sasSsdQuota > 0 ? - qos_cfg_info->sasSsdQuota : g_ps3_qos_sas_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SATA_HDD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = qos_cfg_info->sataHddQuota > 0 ? - qos_cfg_info->sataHddQuota : g_ps3_qos_hdd_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_SATA_SSD: - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = qos_cfg_info->sataSsdQuota > 0 ? - qos_cfg_info->sataSsdQuota : g_ps3_qos_ssd_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - break; - case PS3_DEV_TYPE_NVME_SSD: - pd_ctx = &qos_pd_mgr->instance->qos_context.pd_ctx; - if (qos_pd_mgr->pd_quota == 0) { - qos_pd_mgr->pd_quota = qos_cfg_info->nvmeNormalQuota > 0 ? - qos_cfg_info->nvmeNormalQuota : pd_ctx->nvme_normal_quota; - } - if (qos_pd_mgr->direct_quota == 0) { - qos_pd_mgr->direct_quota = qos_cfg_info->nvmeDirectQuota > 0 ? - qos_cfg_info->nvmeDirectQuota : g_ps3_qos_nvme_pd_quota; - } - qos_pd_mgr->pd_init_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); - break; + case PS3_DEV_TYPE_SAS_HDD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = + qos_cfg_info->sasHddQuota > 0 ? + qos_cfg_info->sasHddQuota : + g_ps3_qos_sas_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SAS_SSD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = + qos_cfg_info->sasSsdQuota > 0 ? + qos_cfg_info->sasSsdQuota : + g_ps3_qos_sas_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SATA_HDD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = + qos_cfg_info->sataHddQuota > 0 ? + qos_cfg_info->sataHddQuota : + g_ps3_qos_hdd_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_SATA_SSD: + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = + qos_cfg_info->sataSsdQuota > 0 ? + qos_cfg_info->sataSsdQuota : + g_ps3_qos_ssd_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); + break; + case PS3_DEV_TYPE_NVME_SSD: + pd_ctx = &qos_pd_mgr->instance->qos_context.pd_ctx; + if (qos_pd_mgr->pd_quota == 0) { + qos_pd_mgr->pd_quota = + qos_cfg_info->nvmeNormalQuota > 0 ? + qos_cfg_info->nvmeNormalQuota : + pd_ctx->nvme_normal_quota; + } + if (qos_pd_mgr->direct_quota == 0) { + qos_pd_mgr->direct_quota = + qos_cfg_info->nvmeDirectQuota > 0 ? + qos_cfg_info->nvmeDirectQuota : + g_ps3_qos_nvme_pd_quota; + } + qos_pd_mgr->pd_init_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - + (qos_pd_mgr->direct_quota / 10); + break; } - LOG_DEBUG("qos pd rsc init. hno:%u type:%u normal_quota:%u direct_quota:%u\n", - PS3_HOST(qos_pd_mgr->instance), pd_entry->dev_type, - pd_entry->normal_quota, pd_entry->direct_quota); + LOG_DEBUG( + "qos pd rsc init. hno:%u type:%u normal_quota:%u direct_quota:%u\n", + PS3_HOST(qos_pd_mgr->instance), pd_entry->dev_type, + pd_entry->normal_quota, pd_entry->direct_quota); } void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, - struct ps3_instance *instance, S32 reason) + struct ps3_instance *instance, int reason) { - S32 *quota = NULL; - ULong flag = 0; + int *quota = NULL; + unsigned long flag = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - if (!PS3_QOS_INITED(instance) || - (PS3_SDEV_PRI_DATA(sdev) == NULL) || - (PS3_SDEV_PRI_DATA(sdev)->dev_type == PS3_DEV_TYPE_VD)) { + if (!PS3_QOS_INITED(instance) || (PS3_SDEV_PRI_DATA(sdev) == NULL) || + (PS3_SDEV_PRI_DATA(sdev)->dev_type == PS3_DEV_TYPE_VD)) { goto l_out; } - qos_pd_mgr = ps3_qos_pd_mgr_get(instance, PS3_PDID(&PS3_SDEV_PRI_DATA(sdev)->disk_pos)); + qos_pd_mgr = ps3_qos_pd_mgr_get( + instance, PS3_PDID(&PS3_SDEV_PRI_DATA(sdev)->disk_pos)); switch (PS3_SDEV_PRI_DATA(sdev)->dev_type) { - case PS3_DEV_TYPE_SAS_HDD: - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SATA_HDD: - case PS3_DEV_TYPE_SATA_SSD: - quota = &qos_pd_mgr->pd_quota; - break; - case PS3_DEV_TYPE_NVME_SSD: - quota = &qos_pd_mgr->direct_quota; - break; - default: - goto l_out; - } - if ((*quota > sdev->queue_depth && reason == PS3_QOS_QUOTA_ADJUST_QFULL) || - ((*quota == qos_pd_mgr->adjust_max_quota || - time_after(sdev->last_queue_full_time + sdev->queue_ramp_up_period, jiffies) || - time_after(sdev->last_queue_ramp_up + sdev->queue_ramp_up_period, jiffies)) - && reason == PS3_QOS_QUOTA_ADJUST_UP)) { + case PS3_DEV_TYPE_SAS_HDD: + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SATA_HDD: + case PS3_DEV_TYPE_SATA_SSD: + quota = &qos_pd_mgr->pd_quota; + break; + case PS3_DEV_TYPE_NVME_SSD: + quota = &qos_pd_mgr->direct_quota; + break; + default: + goto l_out; + } + if ((*quota > sdev->queue_depth && + reason == PS3_QOS_QUOTA_ADJUST_QFULL) || + ((*quota == qos_pd_mgr->adjust_max_quota || + time_after(sdev->last_queue_full_time + sdev->queue_ramp_up_period, + jiffies) || + time_after(sdev->last_queue_ramp_up + sdev->queue_ramp_up_period, + jiffies)) && + reason == PS3_QOS_QUOTA_ADJUST_UP)) { goto l_out; } if (reason == PS3_QOS_QUOTA_ADJUST_UP) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); - if (*quota < qos_pd_mgr->adjust_max_quota) { + if (*quota < qos_pd_mgr->adjust_max_quota) (*quota)++; - } } else if (reason == PS3_QOS_QUOTA_ADJUST_QFULL) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); - if (*quota > qos_pd_mgr->adjust_min_quota) { + if (*quota > qos_pd_mgr->adjust_min_quota) (*quota)--; - } } else if (reason == PS3_QOS_QUOTA_ADJUST_DEFULAT) { ps3_spin_lock_irqsave(&qos_pd_mgr->adjust_quota_lock, &flag); *quota = qos_pd_mgr->adjust_max_quota; @@ -2507,125 +2816,144 @@ void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, goto l_out; } ps3_spin_unlock_irqrestore(&qos_pd_mgr->adjust_quota_lock, flag); - LOG_INFO_IN_IRQ(instance,"hno:%u dev[%u:%u] qos quota change to [%d] reason [%d]\n", + LOG_INFO_IN_IRQ( + instance, + "hno:%u dev[%u:%u] qos quota change to [%d] reason [%d]\n", PS3_HOST(instance), sdev->channel, sdev->id, *quota, reason); l_out: return; } - struct ps3_qos_pd_mgr* ps3_qos_pd_mgr_init(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry) +struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_init(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry) { - U16 pd_id = 0; + unsigned short pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - if (!PS3_QOS_INITED(instance)) { + + if (!PS3_QOS_INITED(instance)) goto _out; - } pd_id = PS3_PDID(&pd_entry->disk_pos); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); - + if ((ps3_atomic_add_unless(&qos_pd_mgr->valid, 1, 1) != 0) || -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) - ((ps3_sas_is_support_smp(instance)) && (!ps3_check_pd_is_vd_member(pd_entry->config_flag))) || - (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { +#if defined(PS3_SUPPORT_LINX80) + ((ps3_sas_is_support_smp(instance)) && + (!ps3_check_pd_is_vd_member(pd_entry->config_flag))) || + (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { #else - (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { + (pd_entry->config_flag == MIC_PD_STATE_JBOD)) { #endif - if (pd_entry->config_flag == MIC_PD_STATE_JBOD) { + if (pd_entry->config_flag == MIC_PD_STATE_JBOD) ps3_qos_vd_member_del(instance, &pd_entry->disk_pos); - } - + ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); qos_pd_mgr->disk_id = pd_id; qos_pd_mgr->vd_id = 0; - qos_pd_mgr->workq_id = ps3_qos_pd_workq_id_get(&instance->qos_context.pd_ctx); + qos_pd_mgr->workq_id = + ps3_qos_pd_workq_id_get(&instance->qos_context.pd_ctx); qos_pd_mgr->clearing = PS3_FALSE; - LOG_INFO_IN_IRQ(instance, "host_no:%u pd_id:%u dev_type:%u device qos init\n", + LOG_INFO_IN_IRQ( + instance, + "host_no:%u pd_id:%u dev_type:%u device qos init\n", PS3_HOST(instance), pd_id, qos_pd_mgr->dev_type); } _out: return qos_pd_mgr; } -void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, U16 pd_id) +void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, unsigned short pd_id) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - if (!PS3_QOS_INITED(instance)) { + + if (!PS3_QOS_INITED(instance)) return; - } qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); qos_pd_mgr->clearing = PS3_FALSE; } void ps3_qos_vd_attr_change(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry) + struct PS3VDEntry *vd_entry_old, + struct PS3VDEntry *vd_entry) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 change_type = PS3_QOS_VD_TYPE_CHANGE_INVALID; - U16 i = 0; - U16 j = 0; - U16 pd_id = 0; + unsigned short change_type = PS3_QOS_VD_TYPE_CHANGE_INVALID; + unsigned short i = 0; + unsigned short j = 0; + unsigned short pd_id = 0; - if (!PS3_QOS_INITED(instance) || vd_entry->isNvme) { + if (!PS3_QOS_INITED(instance) || vd_entry->isNvme) goto l_out; - } - if (!vd_entry->isSsd) { + if (!vd_entry->isSsd) change_type = PS3_QOS_VD_TYPE_CHANGE_TO_HDD; - } else { + else change_type = PS3_QOS_VD_TYPE_CHANGE_TO_SSD; - } for (i = 0; i < vd_entry->spanCount; i++) { for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; + pd_id = vd_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.phyDiskID; if (pd_id <= PS3_MAX_PD_COUNT(instance)) { - qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); + qos_pd_mgr = + ps3_qos_pd_mgr_get(instance, pd_id); switch (change_type) { - case PS3_QOS_VD_TYPE_CHANGE_TO_SSD: - qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; - break; - case PS3_QOS_VD_TYPE_CHANGE_TO_HDD: - if (vd_entry_old != NULL) { - qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; - } else { - qos_pd_mgr->pd_quota = qos_pd_mgr->adjust_max_quota; - } - break; - default: - break; + case PS3_QOS_VD_TYPE_CHANGE_TO_SSD: + qos_pd_mgr->pd_quota = + qos_pd_mgr->adjust_max_quota; + break; + case PS3_QOS_VD_TYPE_CHANGE_TO_HDD: + if (vd_entry_old != NULL) { + qos_pd_mgr->pd_quota = + instance->cmd_context + .max_scsi_cmd_count; + } else { + qos_pd_mgr->pd_quota = + qos_pd_mgr + ->adjust_max_quota; + } + break; + default: + break; } } } } - LOG_INFO_IN_IRQ(instance, "host_no:%u qos vd[%u:%u:%u] attr change:%u complete\n", - PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), - PS3_TARGET(&vd_entry->diskPos), PS3_VDID(&vd_entry->diskPos), change_type); + LOG_INFO_IN_IRQ(instance, + "host_no:%u qos vd[%u:%u:%u] attr change:%u complete\n", + PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), + PS3_TARGET(&vd_entry->diskPos), + PS3_VDID(&vd_entry->diskPos), change_type); l_out: return; } -void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry, - struct scsi_device *sdev, Bool is_vd_member) +void ps3_qos_vd_member_change(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry, + struct scsi_device *sdev, + unsigned char is_vd_member) { - U16 pd_id = 0; + unsigned short pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - if (!PS3_QOS_INITED(instance)) { + + if (!PS3_QOS_INITED(instance)) goto _out; - } pd_id = PS3_PDID(&pd_entry->disk_pos); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); priv_data = PS3_SDEV_PRI_DATA(sdev); if (priv_data != NULL) { - if (is_vd_member) { - ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_DEVICE_NOT_FOUND); + if (is_vd_member) { + ps3_hba_qos_pd_clean(instance, priv_data, + PS3_STATUS_DEVICE_NOT_FOUND); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); - } else { - ps3_hba_qos_pd_clean(instance, priv_data, PS3_STATUS_VD_MEMBER_OFFLINE); + } else { + ps3_hba_qos_pd_clean(instance, priv_data, + PS3_STATUS_VD_MEMBER_OFFLINE); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); @@ -2634,202 +2962,221 @@ void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry } else { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } - LOG_INFO("update pd qos rsc. host_no:%u pd_id:%u dev_type:%u is_vd_member:%u\n", + LOG_INFO( + "update pd qos rsc. host_no:%u pd_id:%u dev_type:%u is_vd_member:%u\n", PS3_HOST(instance), pd_id, pd_entry->dev_type, is_vd_member); _out: return; } -void ps3_hba_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry) +static void ps3_hba_qos_vd_init(struct ps3_instance *instance, + struct PS3VDEntry *vd_entry) { struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - U16 vd_id = 0; + unsigned short vd_id = 0; vd_id = PS3_VDID(&vd_entry->diskPos); qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, vd_id); - ps3_atomic_set(&qos_vd_mgr->vd_quota, g_ps3_qos_hdd_pd_quota * vd_entry->physDrvCnt); + ps3_atomic_set(&qos_vd_mgr->vd_quota, + g_ps3_qos_hdd_pd_quota * vd_entry->physDrvCnt); qos_vd_mgr->vd_entry = vd_entry; qos_vd_mgr->valid = PS3_TRUE; } static void ps3_qos_r1x_member_init(struct ps3_qos_pd_mgr *qos_pd_mgr, - struct ps3_pd_entry *pd_entry, U16 judge_type) + struct ps3_pd_entry *pd_entry, + unsigned short judge_type) { switch (judge_type) { - case PS3_IS_SSD_ODD_R1X_VD: - if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { - qos_pd_mgr->direct_quota = qos_pd_mgr->pd_init_quota >> 1; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->direct_quota - (qos_pd_mgr->direct_quota / 10); - } else { - qos_pd_mgr->pd_quota = qos_pd_mgr->pd_init_quota >> 1; - qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; - qos_pd_mgr->adjust_min_quota = qos_pd_mgr->pd_quota - (qos_pd_mgr->pd_quota / 10); - } - break; - case PS3_IS_SSD_EVEN_R1X_VD: - case PS3_IS_VALID_R1X_VD: - if (qos_pd_mgr->vd_id > 0) { - ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); - } - break; - case PS3_IS_HDD_R1X_VD: - default: - break; + case PS3_IS_SSD_ODD_R1X_VD: + if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { + qos_pd_mgr->direct_quota = + qos_pd_mgr->pd_init_quota >> 1; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->direct_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->direct_quota - + (qos_pd_mgr->direct_quota / 10); + } else { + qos_pd_mgr->pd_quota = qos_pd_mgr->pd_init_quota >> 1; + qos_pd_mgr->adjust_max_quota = qos_pd_mgr->pd_quota; + qos_pd_mgr->adjust_min_quota = + qos_pd_mgr->pd_quota - + (qos_pd_mgr->pd_quota / 10); + } + break; + case PS3_IS_SSD_EVEN_R1X_VD: + case PS3_IS_VALID_R1X_VD: + if (qos_pd_mgr->vd_id > 0) + ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); + break; + case PS3_IS_HDD_R1X_VD: + default: + break; } } void ps3_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry) { struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - U16 vd_id = 0; - U16 pd_id = 0; + unsigned short vd_id = 0; + unsigned short pd_id = 0; struct ps3_pd_entry *pd_entry = NULL; - U16 i, j = 0; - U16 judge_type = PS3_IS_VALID_R1X_VD; + unsigned short i, j = 0; + unsigned short judge_type = PS3_IS_VALID_R1X_VD; - if(!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), - PS3_VDID(&vd_entry->diskPos)); + PS3_VDID(&vd_entry->diskPos)); judge_type = ps3_odd_r1x_judge(vd_entry); for (i = 0; i < vd_entry->spanCount; i++) { for (j = 0; j < vd_entry->span[i].spanPdNum; j++) { - pd_id = vd_entry->span[i].extent[j].phyDiskID.ps3Dev.phyDiskID; - if (pd_id <= PS3_MAX_PD_COUNT(instance)) { - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, pd_id); - if (pd_entry) { - qos_pd_mgr = ps3_qos_pd_mgr_init(instance, pd_entry); - if (unlikely(qos_pd_mgr->dev_type != pd_entry->dev_type)) { - ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); - if (!vd_entry->isSsd) { - qos_pd_mgr->pd_quota = instance->cmd_context.max_scsi_cmd_count; - } + pd_id = vd_entry->span[i] + .extent[j] + .phyDiskID.ps3Dev.phyDiskID; + if (pd_id > PS3_MAX_PD_COUNT(instance)) + continue; + pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + instance, pd_id); + if (pd_entry) { + qos_pd_mgr = ps3_qos_pd_mgr_init( + instance, pd_entry); + if (PS3_NEED_UPDATE_PD_QUOTAS(qos_pd_mgr, pd_entry)) { + ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); + if (!vd_entry->isSsd) { + qos_pd_mgr->pd_quota = + instance->cmd_context + .max_scsi_cmd_count; } - - ps3_qos_r1x_member_init(qos_pd_mgr, pd_entry, judge_type); - if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { - if (qos_pd_mgr->pd_quota > qos_pd_mgr->direct_quota) { - qos_pd_mgr->pd_quota = qos_pd_mgr->direct_quota; - } + } + + ps3_qos_r1x_member_init(qos_pd_mgr, + pd_entry, + judge_type); + if (qos_pd_mgr->dev_type == PS3_DEV_TYPE_NVME_SSD) { + if (qos_pd_mgr->pd_quota > + qos_pd_mgr->direct_quota) { + qos_pd_mgr->pd_quota = + qos_pd_mgr + ->direct_quota; } - qos_pd_mgr->vd_id = vd_id; } + qos_pd_mgr->vd_id = vd_id; } } } - if (instance->qos_context.opts.qos_vd_init) { + if (instance->qos_context.opts.qos_vd_init) instance->qos_context.opts.qos_vd_init(instance, vd_entry); - } - LOG_INFO_IN_IRQ(instance, "host_no:%u disk_pos[%u:%u:%u] device qos init\n", - PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), - PS3_TARGET(&vd_entry->diskPos), vd_id); + LOG_INFO_IN_IRQ(instance, + "host_no:%u disk_pos[%u:%u:%u] device qos init\n", + PS3_HOST(instance), PS3_CHANNEL(&vd_entry->diskPos), + PS3_TARGET(&vd_entry->diskPos), vd_id); } -void ps3_hba_qos_vd_reset(struct ps3_instance *instance, U16 disk_id) +static void ps3_hba_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id) { struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; + qos_vd_mgr = ps3_qos_vd_mgr_get_by_id(instance, disk_id); qos_vd_mgr->valid = PS3_FALSE; } -void ps3_qos_vd_reset(struct ps3_instance *instance, U16 disk_id) +void ps3_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } - if (instance->qos_context.opts.qos_vd_reset) { + if (instance->qos_context.opts.qos_vd_reset) instance->qos_context.opts.qos_vd_reset(instance, disk_id); - } } static void ps3_qos_pd_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_pd_context *qos_pd_ctx = NULL; - U16 i = 0; + unsigned short i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - ULong timeout_jiffies = 0; + unsigned long timeout_jiffies = 0; qos_pd_ctx = &instance->qos_context.pd_ctx; for (i = 1; i <= instance->qos_context.max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); - timeout_jiffies = qos_pd_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_pd_mgr->last_sched_jiffies + + PS3_QOS_WAITQ_TIMEOUT * HZ; if (time_after(jiffies, timeout_jiffies)) { if (ps3_qos_single_pd_notify(qos_pd_ctx, qos_pd_mgr)) { - LOG_INFO("awake qos pd quota waitq by poll. host_no:%u vid:%u pid:%u\n", - PS3_HOST(instance), qos_pd_mgr->vd_id, qos_pd_mgr->disk_id); + LOG_INFO( + "awake qos pd quota waitq by poll. host_no:%u vid:%u pid:%u\n", + PS3_HOST(instance), qos_pd_mgr->vd_id, + qos_pd_mgr->disk_id); + qos_pd_mgr->wdt_awake++; } } - } } -static Bool ps3_qos_vd_notify_timeout(struct ps3_instance *instance) +static unsigned char ps3_qos_vd_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_vd_context *qos_vd_ctx = NULL; - U16 i = 0; + unsigned short i = 0; struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; - ULong timeout_jiffies = 0; - Bool notified = PS3_FALSE; + unsigned long timeout_jiffies = 0; + unsigned char notified = PS3_FALSE; for (i = 1; i <= instance->qos_context.max_vd_count; i++) { qos_vd_ctx = &instance->qos_context.vd_ctx; qos_vd_mgr = &qos_vd_ctx->qos_vd_mgrs[i]; - timeout_jiffies = qos_vd_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = qos_vd_mgr->last_sched_jiffies + + PS3_QOS_WAITQ_TIMEOUT * HZ; if (time_after(jiffies, timeout_jiffies)) { - if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) { + if (ps3_qos_single_vd_notify(qos_vd_ctx, qos_vd_mgr)) { notified = PS3_TRUE; - LOG_INFO("awake qos vd quota waitq by poll. host_no:%u vid:%u\n", - PS3_HOST(instance), qos_vd_mgr->id); + LOG_INFO( + "awake qos vd quota waitq by poll. host_no:%u vid:%u\n", + PS3_HOST(instance), qos_vd_mgr->id); } - } - } return notified; } -static Bool ps3_qos_tg_notify_timeout(struct ps3_instance *instance) +static unsigned char ps3_qos_tg_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_tg_context *qos_tg_ctx = NULL; - Bool notified = PS3_FALSE; - ULong timeout_jiffies = 0; + unsigned char notified = PS3_FALSE; + unsigned long timeout_jiffies = 0; qos_tg_ctx = &instance->qos_context.tg_ctx; - timeout_jiffies = qos_tg_ctx->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = + qos_tg_ctx->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (qos_tg_ctx->total_wait_cmd_cnt && - ps3_qos_tag_rsc_available(instance) && - time_after(jiffies, timeout_jiffies)) { + ps3_qos_tag_rsc_available(instance) && + time_after(jiffies, timeout_jiffies)) { queue_work(qos_tg_ctx->work_queue, &qos_tg_ctx->resend_work); notified = PS3_TRUE; LOG_INFO("awake qos cmd waitq by poll. host_no:%u\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } return notified; } -void ps3_hba_qos_waitq_poll(struct ps3_instance *instance) +static void ps3_hba_qos_waitq_poll(struct ps3_instance *instance) { if (!ps3_qos_tg_notify_timeout(instance)) { - if (!ps3_qos_vd_notify_timeout(instance)) { + if (!ps3_qos_vd_notify_timeout(instance)) ps3_qos_pd_notify_timeout(instance); - } } } void ps3_qos_waitq_poll(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } if (++instance->qos_context.poll_count == PS3_QOS_POLL_INTERVAL) { instance->qos_context.poll_count = 0; @@ -2843,21 +3190,25 @@ static void ps3_hba_qos_reset(struct ps3_instance *instance) struct ps3_qos_vd_mgr *qos_vd_mgr = NULL; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_tg_context *qos_tg_ctx = NULL; - U16 i = 0; + unsigned short i = 0; struct ps3_pd_entry *pd_entry = NULL; qos_tg_ctx = &instance->qos_context.tg_ctx; - ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, qos_tg_ctx->mgr_exclusive_cnt); + ps3_atomic_set(&qos_tg_ctx->mgr_free_cnt, + qos_tg_ctx->mgr_exclusive_cnt); ps3_atomic_set(&qos_tg_ctx->mgr_share_used, 0); ps3_atomic_set(&qos_tg_ctx->share_free_cnt, qos_tg_ctx->share); for (i = 1; i <= qos_ctx->max_vd_count; i++) { qos_vd_mgr = &instance->qos_context.vd_ctx.qos_vd_mgrs[i]; if (i == qos_ctx->max_vd_count) { - ps3_atomic_set(&qos_vd_mgr->vd_quota, g_ps3_qos_vd_quota); - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, g_ps3_qos_jbod_exclusive); + ps3_atomic_set(&qos_vd_mgr->vd_quota, + g_ps3_qos_vd_quota); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, + g_ps3_qos_jbod_exclusive); } else { - ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, g_ps3_qos_vd_exclusive); + ps3_atomic_set(&qos_vd_mgr->exclusive_cmd_cnt, + g_ps3_qos_vd_exclusive); } ps3_atomic_set(&qos_vd_mgr->share_cmd_used, 0); } @@ -2866,72 +3217,73 @@ static void ps3_hba_qos_reset(struct ps3_instance *instance) for (i = 1; i <= qos_ctx->max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, i); - if (pd_entry != NULL) { + pd_entry = + ps3_dev_mgr_lookup_pd_info_by_id(instance, i); + if (pd_entry != NULL) ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); - } } } } void ps3_qos_close(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } ps3_qos_wait_io_end(instance); - instance->qos_context.opts.qos_waitq_clear(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR)); + instance->qos_context.opts.qos_waitq_clear( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR)); LOG_INFO("qos close. host_no:%u\n", PS3_HOST(instance)); } void ps3_qos_open(struct ps3_instance *instance) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } instance->qos_context.opts.qos_reset(instance); } -static U8 ps3_qos_waitq_flag_get(struct ps3_qos_softq_mgr *softq_mgr) +static unsigned char ps3_qos_waitq_flag_get(struct ps3_qos_softq_mgr *softq_mgr) { - U8 waitq_flag = 0; - switch (softq_mgr->id) { - case PS3_QOS_MGRQ: - waitq_flag = PS3_QOS_CMD_IN_MGR; - break; - case PS3_QOS_CMDQ_0: - waitq_flag = PS3_QOS_CMD_IN_CMDQ0; - break; - case PS3_QOS_CMDQ_1: - waitq_flag = PS3_QOS_CMD_IN_CMDQ1; - break; - case PS3_QOS_CMDQ_2: - waitq_flag = PS3_QOS_CMD_IN_CMDQ2; - break; - case PS3_QOS_CMDQ_3: - waitq_flag = PS3_QOS_CMD_IN_CMDQ3; - break; - default: - LOG_ERROR_IN_IRQ(softq_mgr->instance, "invalid softq id. host_no:%u id:%u\n", - PS3_HOST(softq_mgr->instance), softq_mgr->id); - } - - return waitq_flag; -} + unsigned char waitq_flag = 0; -static Bool ps3_qos_cq_rc_get(struct ps3_cmd *cmd, - struct ps3_qos_softq_mgr *softq_mgr, struct qos_wait_queue *wait_q) -{ - Bool can_get = PS3_FALSE; - ULong flag = 0; - if (ps3_atomic_dec_return(&softq_mgr->free_cnt) >= 0) { + switch (softq_mgr->id) { + case PS3_QOS_MGRQ: + waitq_flag = PS3_QOS_CMD_IN_MGR; + break; + case PS3_QOS_CMDQ_0: + waitq_flag = PS3_QOS_CMD_IN_CMDQ0; + break; + case PS3_QOS_CMDQ_1: + waitq_flag = PS3_QOS_CMD_IN_CMDQ1; + break; + case PS3_QOS_CMDQ_2: + waitq_flag = PS3_QOS_CMD_IN_CMDQ2; + break; + case PS3_QOS_CMDQ_3: + waitq_flag = PS3_QOS_CMD_IN_CMDQ3; + break; + default: + LOG_ERROR_IN_IRQ(softq_mgr->instance, + "invalid softq id. host_no:%u id:%u\n", + PS3_HOST(softq_mgr->instance), softq_mgr->id); + } + + return waitq_flag; +} + +static unsigned char ps3_qos_cq_rc_get(struct ps3_cmd *cmd, + struct ps3_qos_softq_mgr *softq_mgr, + struct qos_wait_queue *wait_q) +{ + unsigned char can_get = PS3_FALSE; + unsigned long flag = 0; + + if (ps3_atomic_dec_return(&softq_mgr->free_cnt) >= 0) can_get = PS3_TRUE; - } else { + else ps3_atomic_inc(&softq_mgr->free_cnt); - } if (!can_get) { ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); @@ -2940,26 +3292,28 @@ static Bool ps3_qos_cq_rc_get(struct ps3_cmd *cmd, softq_mgr->total_wait_cmd_cnt++; cmd->qos_waitq_flag = ps3_qos_waitq_flag_get(softq_mgr); ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); - LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx " - "CFID:%u que_id:%u diskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, - cmd->io_attr.disk_id, wait_q->count); + LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx\n" + "\tCFID:%u que_id:%u diskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + softq_mgr->id, cmd->io_attr.disk_id, wait_q->count); } return can_get; } -static struct qos_wait_queue* ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, - struct ps3_qos_softq_mgr *softq_mgr) +static struct qos_wait_queue * +ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, struct ps3_qos_softq_mgr *softq_mgr) { - U16 waitq_id = 0; + unsigned short waitq_id = 0; struct qos_wait_queue *waitq = NULL; + if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - waitq_id = get_offset_of_vdid(PS3_VDID_OFFSET(cmd->instance), - PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); + waitq_id = get_offset_of_vdid( + PS3_VDID_OFFSET(cmd->instance), + PS3_VDID(&cmd->io_attr.vd_entry->diskPos)); } else { - waitq_id = cmd->instance->qos_context.max_vd_count; + waitq_id = cmd->instance->qos_context.max_vd_count; } waitq = &softq_mgr->waitqs[waitq_id]; } else { @@ -2969,18 +3323,19 @@ static struct qos_wait_queue* ps3_qos_cq_waitq_get(struct ps3_cmd *cmd, return waitq; } -static Bool ps3_qos_cq_rc_check(struct ps3_cmd *cmd, - struct ps3_qos_softq_mgr *softq_mgr) +static unsigned char ps3_qos_cq_rc_check(struct ps3_cmd *cmd, + struct ps3_qos_softq_mgr *softq_mgr) { - Bool can_get = PS3_FALSE; - ULong flag = 0; + unsigned char can_get = PS3_FALSE; + unsigned long flag = 0; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_cq_waitq_get(cmd, softq_mgr); if (likely(softq_mgr->total_wait_cmd_cnt == 0)) { can_get = ps3_qos_cq_rc_get(cmd, softq_mgr, waitq); } else { - INJECT_START(PS3_ERR_IJ_QOS_WAIT_SOFT_WAITQ_CLEAR, cmd->instance) + INJECT_START(PS3_ERR_IJ_QOS_WAIT_SOFT_WAITQ_CLEAR, + cmd->instance); ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); if (softq_mgr->total_wait_cmd_cnt > 0) { list_add_tail(&cmd->qos_list, &waitq->wait_list); @@ -2989,10 +3344,12 @@ static Bool ps3_qos_cq_rc_check(struct ps3_cmd *cmd, cmd->qos_waitq_flag = ps3_qos_waitq_flag_get(softq_mgr); ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); can_get = PS3_FALSE; - LOG_DEBUG("insert qos cq waitq.host_no:%u:t_id:0x%llx CFID:%u " - "que_id:%u diskid:%u waitq:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, - cmd->io_attr.disk_id, waitq->count); + LOG_DEBUG( + "insert qos cq waitq.host_no:%u:t_id:0x%llx CFID:%u\n" + "\tque_id:%u diskid:%u waitq:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->index, softq_mgr->id, cmd->io_attr.disk_id, + waitq->count); } else { ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); can_get = ps3_qos_cq_rc_get(cmd, softq_mgr, waitq); @@ -3002,36 +3359,36 @@ static Bool ps3_qos_cq_rc_check(struct ps3_cmd *cmd, return can_get; } -static inline struct ps3_qos_softq_mgr *ps3_qos_cmdq_mgr_get(struct ps3_instance *instance, U16 index) +static inline struct ps3_qos_softq_mgr * +ps3_qos_cmdq_mgr_get(struct ps3_instance *instance, unsigned short index) { return &instance->qos_context.cq_ctx.cmdqs[index]; } static void ps3_qos_update_target_cmdq(struct ps3_cmd *cmd) { - U8 que_id = 0; - U8 qmask = 0; + unsigned char que_id = 0; + unsigned char qmask = 0; cmd->cmdq_count = 0; qmask = cmd->cmd_word.qMask; while (que_id < cmd->instance->ctrl_info.vdQueueNum) { if (qmask & (1 << que_id)) { cmd->cmdq_info[cmd->cmdq_count].que_id = que_id; - if (++cmd->cmdq_count == PS3_QOS_MAX_CMDQ_ONE_CMD) { + if (++cmd->cmdq_count == PS3_QOS_MAX_CMDQ_ONE_CMD) break; - } } que_id++; } } -static Bool ps3_qos_cq_decision(struct ps3_cmd *cmd) +static unsigned char ps3_qos_cq_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_TRUE; + unsigned char can_get = PS3_TRUE; struct ps3_instance *instance = cmd->instance; struct ps3_qos_softq_mgr *softq_mgr = NULL; - U16 cmdq_index = 0; - U8 i = 0; + unsigned short cmdq_index = 0; + unsigned char i = 0; if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_MGR_PRO); @@ -3039,7 +3396,8 @@ static Bool ps3_qos_cq_decision(struct ps3_cmd *cmd) can_get = ps3_qos_cq_rc_check(cmd, softq_mgr); PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_MGR_PRO); if (!can_get) { - PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_MGR_QUEUE); + PS3_QOS_STAT_START(cmd->instance, cmd, + PS3_QOS_MGR_QUEUE); } } else { PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_CMD_PRO); @@ -3050,84 +3408,90 @@ static Bool ps3_qos_cq_decision(struct ps3_cmd *cmd) can_get = ps3_qos_cq_rc_check(cmd, softq_mgr); if (can_get) { cmd->cmdq_info[i].get_rc = PS3_TRUE; - } else { + } else { can_get = PS3_FALSE; break; } } PS3_QOS_STAT_END(cmd->instance, cmd, PS3_QOS_CMD_PRO); if (!can_get) { - PS3_QOS_STAT_START(cmd->instance, cmd, PS3_QOS_CMD_QUEUE); + PS3_QOS_STAT_START(cmd->instance, cmd, + PS3_QOS_CMD_QUEUE); } } - return can_get; + return can_get; } -Bool ps3_raid_qos_decision(struct ps3_cmd *cmd) +static unsigned char ps3_raid_qos_decision(struct ps3_cmd *cmd) { - Bool can_get = PS3_FALSE; + unsigned char can_get = PS3_FALSE; + if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { - can_get = ps3_qos_pd_quota_decision(cmd); - if (!can_get || - cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { + can_get = ps3_qos_pd_quota_decision(cmd); + if (!can_get || + cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) { goto _out; } } - can_get = ps3_qos_cq_decision(cmd); + can_get = ps3_qos_cq_decision(cmd); _out: return can_get; } static void ps3_qos_update_cmdq_rc(struct ps3_cmd *cmd) { - U8 i = 0; - U8 index = 0; + unsigned char i = 0; + unsigned char index = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; - S32 cmdq_free = 0; + int cmdq_free = 0; for (i = 0; i < cmd->cmdq_count; i++) { index = cmd->cmdq_info[i].que_id; softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, index); cmdq_free = ps3_atomic_inc_return(&softq_mgr->free_cnt); - LOG_DEBUG("update cmdq rc. host_no:%u t_id:0x%llx CFID:%u rc[%u,%d] dev_t:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, cmdq_free, - cmd->io_attr.dev_type); + LOG_DEBUG( + "update cmdq rc. host_no:%u t_id:0x%llx CFID:%u rc[%u,%d] dev_t:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + softq_mgr->id, cmdq_free, cmd->io_attr.dev_type); } } static void ps3_qos_update_mgrq_rc(struct ps3_cmd *cmd) { - struct ps3_qos_cq_context *qos_cq_ctx = &cmd->instance->qos_context.cq_ctx; - S32 free_cnt = 0; + struct ps3_qos_cq_context *qos_cq_ctx = + &cmd->instance->qos_context.cq_ctx; + int free_cnt = 0; free_cnt = ps3_atomic_inc_return(&qos_cq_ctx->mgrq.free_cnt); LOG_DEBUG("update mgrq rc. host_no:%u t_id:0x%llx CFID:%u rc:%d\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, free_cnt); + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, free_cnt); } -static void ps3_raid_qos_cmd_update(struct ps3_cmd *cmd) +static void ps3_raid_qos_cmd_update(struct ps3_cmd *cmd, + unsigned char in_reply) { if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_MGR) { ps3_qos_update_mgrq_rc(cmd); } else { - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, in_reply); ps3_qos_update_cmdq_rc(cmd); } } -void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) +static void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) { - S32 ret = PS3_SUCCESS; - ULong flag = 0; + int ret = PS3_SUCCESS; + unsigned long flag = 0; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = softq_mgr->instance; struct qos_wait_queue *waitq = &softq_mgr->waitqs[0]; - Bool waitq_cleared = PS3_FALSE; + unsigned char waitq_cleared = PS3_FALSE; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); while (waitq->count > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, + qos_list); if (ps3_atomic_dec_return(&softq_mgr->free_cnt) < 0) { ps3_atomic_inc(&softq_mgr->free_cnt); break; @@ -3138,23 +3502,24 @@ void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) PS3_QOS_STAT_END(instance, cmd, PS3_QOS_MGR_QUEUE); ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { - ps3_raid_qos_cmd_update(cmd); + ps3_raid_qos_cmd_update(cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG("raid qos mgr waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, cmd->cmd_word.type); + LOG_DEBUG( + "raid qos mgr waitq resend:host_no:%u t_id:0x%llx CFID:%u type:%u\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + cmd->cmd_word.type); } } - if (softq_mgr->total_wait_cmd_cnt == 0) { + if (softq_mgr->total_wait_cmd_cnt == 0) waitq_cleared = PS3_TRUE; - } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); if (waitq_cleared) { LOG_DEBUG("hno:%u resend all mgrq waited cmds\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } softq_mgr->last_sched_jiffies = jiffies; } @@ -3162,30 +3527,29 @@ void ps3_qos_mgrq_resend(struct ps3_qos_softq_mgr *softq_mgr) static void ps3_qos_mgrq_resend_work(struct work_struct *work) { struct ps3_qos_softq_mgr *softq_mgr = - ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); ps3_qos_mgrq_resend(softq_mgr); - return; } -static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) +static int ps3_qos_mgrq_init(struct ps3_instance *instance, + struct ps3_qos_softq_mgr *softq_mgr) { - S32 ret = PS3_SUCCESS; - U32 mgrq_depth = 0; - U32 high_mgr_cmd = 0; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; + int ret = PS3_SUCCESS; + unsigned int mgrq_depth = 0; + unsigned int high_mgr_cmd = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; - if (!ps3_ioc_multi_func_support(instance)) { + if (!ps3_ioc_multi_func_support(instance)) high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT; - } else { + else high_mgr_cmd = PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1; - } mgrq_depth = instance->qos_context.cq_ctx.mgrq_depth; if (mgrq_depth <= high_mgr_cmd) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:mgrq_depth is too small func:%u depth:%u\n", - PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), - mgrq_depth); + PS3_HOST(softq_mgr->instance), + ps3_get_pci_function(instance->pdev), mgrq_depth); goto _out; } @@ -3194,12 +3558,13 @@ static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq ps3_spin_lock_init(&softq_mgr->rc_lock); ps3_atomic_set(&softq_mgr->free_cnt, mgrq_depth - high_mgr_cmd); softq_mgr->waitq_cnt = 1; - softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, sizeof(struct qos_wait_queue)); - INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_1, softq_mgr) + softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( + instance, sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_1, softq_mgr); if (softq_mgr->waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for waitqs\n", - PS3_HOST(softq_mgr->instance)); - ret = -PS3_FAILED; + PS3_HOST(softq_mgr->instance)); + ret = -PS3_FAILED; goto _out; } INIT_LIST_HEAD(&softq_mgr->waitqs[0].wait_list); @@ -3208,9 +3573,9 @@ static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq softq_mgr->total_wait_cmd_cnt = 0; softq_mgr->last_sched_jiffies = 0; snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "mgrq_wq_f%u", - ps3_get_pci_function(instance->pdev)); + ps3_get_pci_function(instance->pdev)); softq_mgr->work_queue = create_singlethread_workqueue(workq_name); - INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_2, softq_mgr) + INJECT_START(PS3_ERR_IJ_QOS_MGRQ_INIT_FAIL_2, softq_mgr); if (softq_mgr->work_queue == NULL) { LOG_ERROR("qos mgr workq create failed\n"); ret = -PS3_FAILED; @@ -3218,8 +3583,8 @@ static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq } LOG_INFO("hno:%u:mgrq init success func:%u depth:%u\n", - PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), - mgrq_depth); + PS3_HOST(softq_mgr->instance), + ps3_get_pci_function(instance->pdev), mgrq_depth); goto _out; _release_waitq: ps3_vfree(instance, softq_mgr->waitqs); @@ -3228,11 +3593,12 @@ static S32 ps3_qos_mgrq_init(struct ps3_instance *instance, struct ps3_qos_softq return ret; } -static Bool ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) +static unsigned char ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) { - Bool notified = PS3_FALSE; + unsigned char notified = PS3_FALSE; + if (softq_mgr->total_wait_cmd_cnt > 0 && - ps3_atomic_read(&softq_mgr->free_cnt) > 0) { + ps3_atomic_read(&softq_mgr->free_cnt) > 0) { queue_work(softq_mgr->work_queue, &softq_mgr->resend_work); notified = PS3_TRUE; } @@ -3240,10 +3606,10 @@ static Bool ps3_qos_softq_notify(struct ps3_qos_softq_mgr *softq_mgr) return notified; } -static Bool ps3_qos_cq_notify(struct ps3_instance *instance) +static unsigned char ps3_qos_cq_notify(struct ps3_instance *instance) { - U8 i = 0; - Bool notified = PS3_FALSE; + unsigned char i = 0; + unsigned char notified = PS3_FALSE; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; struct ps3_qos_softq_mgr *softq_mgr = NULL; @@ -3252,24 +3618,25 @@ static Bool ps3_qos_cq_notify(struct ps3_instance *instance) for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { softq_mgr = ps3_qos_cmdq_mgr_get(instance, i); - if (ps3_qos_softq_notify(softq_mgr)) { + if (ps3_qos_softq_notify(softq_mgr)) notified = PS3_TRUE; - } } return notified; } -void ps3_raid_qos_waitq_notify(struct ps3_instance *instance) +static void ps3_raid_qos_waitq_notify(struct ps3_instance *instance, + unsigned short isr_sn) { - if (!ps3_qos_cq_notify(instance)) { - ps3_qos_pd_notify(instance); - } + if (!ps3_qos_cq_notify(instance)) + ps3_qos_pd_notify_in_reply(instance, isr_sn); } -static Bool ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, struct ps3_cmd *cmd) +static unsigned char +ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, + struct ps3_cmd *cmd) { - Bool can_get = PS3_TRUE; + unsigned char can_get = PS3_TRUE; struct ps3_instance *instance = NULL; struct ps3_qos_softq_mgr *next_softq_mgr = NULL; @@ -3279,54 +3646,57 @@ static Bool ps3_qos_cmdq_resend_judge(struct ps3_qos_softq_mgr *softq_mgr, struc } else { if (cmd->cmdq_info[0].que_id == softq_mgr->id) { cmd->cmdq_info[0].get_rc = PS3_TRUE; - next_softq_mgr = ps3_qos_cmdq_mgr_get(instance, cmd->cmdq_info[1].que_id); + next_softq_mgr = ps3_qos_cmdq_mgr_get( + instance, cmd->cmdq_info[1].que_id); can_get = ps3_qos_cq_rc_check(cmd, next_softq_mgr); - if (can_get) { + if (can_get) cmd->cmdq_info[1].get_rc = PS3_TRUE; - } } else { cmd->cmdq_info[1].get_rc = PS3_TRUE; } } - if (can_get) { + if (can_get) PS3_QOS_STAT_END(instance, cmd, PS3_QOS_CMD_QUEUE); - } - LOG_DEBUG("raid resend cmdq judge:host_no:%u t_id:0x%llx CFID:%u cmdq_id:%u ret:%u\n", - PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, softq_mgr->id, can_get); + LOG_DEBUG( + "raid resend cmdq judge:host_no:%u t_id:0x%llx CFID:%u cmdq_id:%u ret:%u\n", + PS3_HOST(cmd->instance), cmd->trace_id, cmd->index, + softq_mgr->id, can_get); return can_get; } static void ps3_qos_resend_multi_cmd(struct ps3_qos_softq_mgr *softq_mgr, - struct qos_wait_queue *waitq, S32 count) + struct qos_wait_queue *waitq, int count) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = softq_mgr->instance; - U32 can_send = 0; + unsigned int can_send = 0; can_send = PS3_MIN(ps3_atomic_read(&softq_mgr->free_cnt), count); - while(waitq->count > 0 && can_send > 0) { - cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, qos_list); + while (waitq->count > 0 && can_send > 0) { + cmd = list_first_entry(&waitq->wait_list, struct ps3_cmd, + qos_list); list_del(&cmd->qos_list); softq_mgr->total_wait_cmd_cnt--; waitq->count--; - if (ps3_qos_vd_seq_check(cmd)) { + if (ps3_qos_vd_seq_check(cmd)) continue; - } can_send--; ps3_atomic_dec(&softq_mgr->free_cnt); if (ps3_qos_cmdq_resend_judge(softq_mgr, cmd)) { ret = ps3_scsi_cmd_send(instance, cmd, PS3_FALSE); if (unlikely(ret != PS3_SUCCESS)) { - ps3_raid_qos_cmd_update(cmd); + ps3_raid_qos_cmd_update(cmd, PS3_FALSE); ps3_qos_cmd_resend_fail(cmd, ret); } else { cmd->qos_waitq_flag = 0; - LOG_DEBUG("raid qos cmdq waitq resend:host_no:%u t_id:0x%llx CFID:%u qid:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, waitq->id); + LOG_DEBUG( + "raid qos cmdq waitq resend:host_no:%u t_id:0x%llx CFID:%u qid:%u\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index, waitq->id); } } } @@ -3334,21 +3704,21 @@ static void ps3_qos_resend_multi_cmd(struct ps3_qos_softq_mgr *softq_mgr, static void ps3_qos_cmdq_resend(struct ps3_qos_softq_mgr *softq_mgr) { - ULong flag = 0; + unsigned long flag = 0; struct ps3_instance *instance = softq_mgr->instance; struct qos_wait_queue *waitq = NULL; - U16 cur_que_id = softq_mgr->poll_que_id; + unsigned short cur_que_id = softq_mgr->poll_que_id; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); - while (ps3_atomic_read(&softq_mgr->free_cnt) > 0 - && softq_mgr->total_wait_cmd_cnt > 0) { + while (ps3_atomic_read(&softq_mgr->free_cnt) > 0 && + softq_mgr->total_wait_cmd_cnt > 0) { waitq = &softq_mgr->waitqs[cur_que_id]; if (waitq->count > 0) { - ps3_qos_resend_multi_cmd(softq_mgr, waitq, softq_mgr->poll_cmd_cnt); + ps3_qos_resend_multi_cmd(softq_mgr, waitq, + softq_mgr->poll_cmd_cnt); } - if (++cur_que_id > instance->qos_context.max_vd_count) { + if (++cur_que_id > instance->qos_context.max_vd_count) cur_que_id = 1; - } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); softq_mgr->poll_que_id = cur_que_id; @@ -3359,36 +3729,38 @@ static void ps3_qos_cmdq_resend(struct ps3_qos_softq_mgr *softq_mgr) static void ps3_qos_cmdq_resend_work(struct work_struct *work) { struct ps3_qos_softq_mgr *softq_mgr = - ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); + ps3_container_of(work, struct ps3_qos_softq_mgr, resend_work); ps3_qos_cmdq_resend(softq_mgr); - return; } -static S32 ps3_qos_cmdq_init(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) +static int ps3_qos_cmdq_init(struct ps3_instance *instance, + struct ps3_qos_softq_mgr *softq_mgr) { - S32 ret = PS3_SUCCESS; - U16 i = 0; + int ret = PS3_SUCCESS; + unsigned short i = 0; struct qos_wait_queue *waitq = NULL; - char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = {0}; - U32 cmdq_depth = 0; + char workq_name[PS3_QOS_MAX_WORKQ_NAME_LENGTH] = { 0 }; + unsigned int cmdq_depth = 0; cmdq_depth = instance->qos_context.cq_ctx.cmdq_depth; softq_mgr->instance = instance; ps3_spin_lock_init(&softq_mgr->rc_lock); ps3_atomic_set(&softq_mgr->free_cnt, cmdq_depth); softq_mgr->waitq_cnt = instance->qos_context.max_vd_count + 1; - softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc(instance, - softq_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); - INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_1, softq_mgr) + softq_mgr->waitqs = (struct qos_wait_queue *)ps3_vzalloc( + instance, softq_mgr->waitq_cnt * sizeof(struct qos_wait_queue)); + INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_1, softq_mgr); if (softq_mgr->waitqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for waitqs\n", - PS3_HOST(instance)); - ret = -PS3_FAILED; + PS3_HOST(instance)); + ret = -PS3_FAILED; goto _out; } - memset(softq_mgr->waitqs, 0, (instance->qos_context.max_vd_count + 1) * sizeof(struct qos_wait_queue)); + memset(softq_mgr->waitqs, 0, + (instance->qos_context.max_vd_count + 1) * + sizeof(struct qos_wait_queue)); for (i = 1; i < softq_mgr->waitq_cnt; i++) { - waitq = &softq_mgr->waitqs[i]; + waitq = &softq_mgr->waitqs[i]; waitq->id = i; INIT_LIST_HEAD(&waitq->wait_list); waitq->count = 0; @@ -3400,9 +3772,9 @@ static S32 ps3_qos_cmdq_init(struct ps3_instance *instance, struct ps3_qos_softq softq_mgr->total_wait_cmd_cnt = 0; softq_mgr->last_sched_jiffies = 0; snprintf(workq_name, PS3_QOS_MAX_WORKQ_NAME_LENGTH, "cmdq_wq_f%u_%u", - ps3_get_pci_function(instance->pdev), softq_mgr->id); + ps3_get_pci_function(instance->pdev), softq_mgr->id); softq_mgr->work_queue = create_singlethread_workqueue(workq_name); - INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_2, softq_mgr) + INJECT_START(PS3_ERR_IJ_QOS_CMDQ_INIT_FAIL_2, softq_mgr); if (softq_mgr->work_queue == NULL) { LOG_ERROR("qos mgr workq create failed\n"); ret = -PS3_FAILED; @@ -3410,8 +3782,9 @@ static S32 ps3_qos_cmdq_init(struct ps3_instance *instance, struct ps3_qos_softq } LOG_INFO("hno:%u:cmdq init success func:%u depth:%u id:%u\n", - PS3_HOST(softq_mgr->instance), ps3_get_pci_function(instance->pdev), - cmdq_depth, softq_mgr->id); + PS3_HOST(softq_mgr->instance), + ps3_get_pci_function(instance->pdev), cmdq_depth, + softq_mgr->id); goto _out; _release_waitq: ps3_vfree(instance, softq_mgr->waitqs); @@ -3420,43 +3793,45 @@ static S32 ps3_qos_cmdq_init(struct ps3_instance *instance, struct ps3_qos_softq return ret; } -static void ps3_qos_softq_exit(struct ps3_instance *instance, struct ps3_qos_softq_mgr *softq_mgr) +static void ps3_qos_softq_exit(struct ps3_instance *instance, + struct ps3_qos_softq_mgr *softq_mgr) { - cancel_work_sync(&softq_mgr->resend_work); + ps3_cancel_work_sync(&softq_mgr->resend_work); flush_workqueue(softq_mgr->work_queue); destroy_workqueue(softq_mgr->work_queue); ps3_vfree(instance, softq_mgr->waitqs); softq_mgr->waitqs = NULL; } -static S32 ps3_qos_cq_context_init(struct ps3_instance *instance) +static int ps3_qos_cq_context_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 i = 0; - U16 j = 0; + int ret = PS3_SUCCESS; + unsigned short i = 0; + unsigned short j = 0; struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *softq_mgr = NULL; - U64 mgrq_depth = 0; - U64 cmdq_depth = 0; + unsigned long long mgrq_depth = 0; + unsigned long long cmdq_depth = 0; qos_cq_ctx = &instance->qos_context.cq_ctx; ps3_mgrq_depth_get(instance, &mgrq_depth); - INJECT_START(PS3_ERR_IJ_QOS_FORCE_MGRQ_ZERO_DEPTH, &mgrq_depth) + INJECT_START(PS3_ERR_IJ_QOS_FORCE_MGRQ_ZERO_DEPTH, &mgrq_depth); if (mgrq_depth == 0) { ret = -PS3_FAILED; LOG_ERROR("hno:%u:mgrq_depth is invalid func:%u\n", - PS3_HOST(instance),ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), + ps3_get_pci_function(instance->pdev)); goto _out; } qos_cq_ctx->mgrq_depth = mgrq_depth; ps3_cmdq_depth_get(instance, &cmdq_depth); - INJECT_START(PS3_ERR_IJ_QOS_FORCE_CMDQ_ZERO_DEPTH, &cmdq_depth) + INJECT_START(PS3_ERR_IJ_QOS_FORCE_CMDQ_ZERO_DEPTH, &cmdq_depth); if (cmdq_depth == 0) { - ret = -PS3_FAILED; + ret = -PS3_FAILED; LOG_ERROR("hno:%u:cmdq_depth is invalid func:%u\n", - PS3_HOST(instance), - ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), + ps3_get_pci_function(instance->pdev)); goto _out; } qos_cq_ctx->cmdq_depth = cmdq_depth; @@ -3467,11 +3842,12 @@ static S32 ps3_qos_cq_context_init(struct ps3_instance *instance) } qos_cq_ctx->cmdq_cnt = instance->ctrl_info.vdQueueNum; - qos_cq_ctx->cmdqs = (struct ps3_qos_softq_mgr *)ps3_vzalloc(instance, - qos_cq_ctx->cmdq_cnt * sizeof(struct ps3_qos_softq_mgr)); + qos_cq_ctx->cmdqs = (struct ps3_qos_softq_mgr *)ps3_vzalloc( + instance, + qos_cq_ctx->cmdq_cnt * sizeof(struct ps3_qos_softq_mgr)); if (qos_cq_ctx->cmdqs == NULL) { LOG_ERROR("hno:%u:Failed to kcalloc memory for cmdqs\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto _mgrq_exit; } @@ -3486,7 +3862,7 @@ static S32 ps3_qos_cq_context_init(struct ps3_instance *instance) } LOG_INFO("hno:%u: qos cq context init success cmdq_cnt:%u\n", - PS3_HOST(instance), qos_cq_ctx->cmdq_cnt); + PS3_HOST(instance), qos_cq_ctx->cmdq_cnt); goto _out; _cmdq_exit: for (j = 0; j < i; j++) { @@ -3504,7 +3880,7 @@ static S32 ps3_qos_cq_context_init(struct ps3_instance *instance) static void ps3_qos_cq_context_exit(struct ps3_instance *instance) { struct ps3_qos_cq_context *qos_cq_ctx = NULL; - U16 i = 0; + unsigned short i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; qos_cq_ctx = &instance->qos_context.cq_ctx; @@ -3521,19 +3897,17 @@ static void ps3_qos_cq_context_exit(struct ps3_instance *instance) LOG_INFO("hno:%u: qos cq context exit success\n", PS3_HOST(instance)); } -S32 ps3_raid_qos_init(struct ps3_instance *instance) +int ps3_raid_qos_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ret = ps3_qos_cq_context_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _out; - } ret = ps3_qos_pd_context_init(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _cq_ctx_exit; - } goto _out; _cq_ctx_exit: @@ -3542,11 +3916,12 @@ S32 ps3_raid_qos_init(struct ps3_instance *instance) return ret; } -static Bool ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, - struct ps3_cmd *cmd, U8 waitq_flag) +static unsigned char ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, + struct ps3_cmd *cmd, + unsigned char waitq_flag) { - ULong lock_flag = 0; - Bool found = PS3_FALSE; + unsigned long lock_flag = 0; + unsigned char found = PS3_FALSE; struct qos_wait_queue *waitq = NULL; waitq = ps3_qos_cq_waitq_get(cmd, softq_mgr); @@ -3564,63 +3939,65 @@ static Bool ps3_qos_softq_abort(struct ps3_qos_softq_mgr *softq_mgr, static void ps3_qos_peer_cmdq_rc_update(struct ps3_cmd *cmd) { - U8 i = 0; + unsigned char i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; + for (i = 0; i < cmd->cmdq_count; i++) { if (cmd->cmdq_info[i].get_rc) { - softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, cmd->cmdq_info[i].que_id); + softq_mgr = ps3_qos_cmdq_mgr_get( + cmd->instance, cmd->cmdq_info[i].que_id); ps3_atomic_inc(&softq_mgr->free_cnt); } } } -static Bool ps3_qos_cmdq_abort(struct ps3_cmd *cmd) +static unsigned char ps3_qos_cmdq_abort(struct ps3_cmd *cmd) { - U8 i = 0; - U8 waitq_flag = 0; - Bool found = PS3_FALSE; + unsigned char i = 0; + unsigned char waitq_flag = 0; + unsigned char found = PS3_FALSE; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; for (i = 0; i < cmd->cmdq_count; i++) { - qos_softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, cmd->cmdq_info[i].que_id); + qos_softq_mgr = ps3_qos_cmdq_mgr_get(cmd->instance, + cmd->cmdq_info[i].que_id); waitq_flag = ps3_qos_waitq_flag_get(qos_softq_mgr); if (cmd->qos_waitq_flag == waitq_flag) { - found = ps3_qos_softq_abort(qos_softq_mgr, cmd, waitq_flag); - if (found) { + found = ps3_qos_softq_abort(qos_softq_mgr, cmd, + waitq_flag); + if (found) break; - } } } return found; } -Bool ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) +static unsigned char ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) { - Bool found = PS3_FALSE; + unsigned char found = PS3_FALSE; struct ps3_qos_softq_mgr *softq_mgr = NULL; - if (cmd->qos_waitq_flag == 0) { + if (cmd->qos_waitq_flag == 0) goto _out; - } if (PS3_CMD_TYPE_IS_RW(cmd->cmd_word.type)) { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_PD) { found = ps3_pd_quota_waiq_abort(cmd); - if (found) { + if (found) goto _out; - } } found = ps3_qos_cmdq_abort(cmd); if (found) { - ps3_qos_update_pd_quota(cmd); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); ps3_qos_peer_cmdq_rc_update(cmd); } } else { if (cmd->qos_waitq_flag == PS3_QOS_CMD_IN_MGR) { softq_mgr = &cmd->instance->qos_context.cq_ctx.mgrq; - found = ps3_qos_softq_abort(softq_mgr, cmd, PS3_QOS_CMD_IN_MGR); + found = ps3_qos_softq_abort(softq_mgr, cmd, + PS3_QOS_CMD_IN_MGR); } } @@ -3629,45 +4006,51 @@ Bool ps3_raid_qos_waitq_abort(struct ps3_cmd *cmd) } static void ps3_qos_mgrq_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) + struct ps3_scsi_priv_data *priv_data, + int resp_status) { struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - ULong flag = 0; + unsigned long flag = 0; softq_mgr = &instance->qos_context.cq_ctx.mgrq; waitq = &softq_mgr->waitqs[0]; ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); if (waitq->count > 0) { - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { + list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, + qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data(cmd->scmd)) { - LOG_DEBUG("qos clean mgrq. hno:%u t_id:0x%llx CFID:%d\n", - PS3_HOST(instance), cmd->trace_id, cmd->index); + priv_data == scsi_device_private_data(cmd->scmd)) { + LOG_DEBUG( + "qos clean mgrq. hno:%u t_id:0x%llx CFID:%d\n", + PS3_HOST(instance), cmd->trace_id, + cmd->index); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi( + cmd->scmd, cmd, resp_status, PS3_FALSE); } } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); - if (priv_data == NULL) { - cancel_work_sync(&softq_mgr->resend_work); - } + if (priv_data == NULL) + ps3_cancel_work_sync(&softq_mgr->resend_work); } -static void ps3_qos_cmdq_clean(struct ps3_instance *instance, U16 disk_id, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) +static void ps3_qos_cmdq_clean(struct ps3_instance *instance, + unsigned short disk_id, + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - U8 i = 0; + unsigned char i = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - ULong flag = 0; + unsigned long flag = 0; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { @@ -3675,16 +4058,24 @@ static void ps3_qos_cmdq_clean(struct ps3_instance *instance, U16 disk_id, waitq = &softq_mgr->waitqs[disk_id]; if (waitq->count > 0) { ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { + list_for_each_entry_safe(cmd, cmd_next, + &waitq->wait_list, qos_list) { if (priv_data == NULL || - priv_data == scsi_device_private_data(cmd->scmd)) { - LOG_DEBUG("qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, softq_mgr->id); + priv_data == scsi_device_private_data( + cmd->scmd)) { + LOG_DEBUG( + "qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", + PS3_HOST(instance), + cmd->trace_id, cmd->index, + softq_mgr->id); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, + cmd, + resp_status, + PS3_FALSE); } } ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); @@ -3692,15 +4083,15 @@ static void ps3_qos_cmdq_clean(struct ps3_instance *instance, U16 disk_id, } } -static void ps3_qos_cmdq_clear(struct ps3_instance *instance, S32 resp_status) +static void ps3_qos_cmdq_clear(struct ps3_instance *instance, int resp_status) { - U16 i = 0; - U16 j = 0; + unsigned short i = 0; + unsigned short j = 0; struct ps3_qos_softq_mgr *softq_mgr = NULL; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct qos_wait_queue *waitq = NULL; - ULong flag = 0; + unsigned long flag = 0; struct ps3_qos_cq_context *qos_cq_ctx = &instance->qos_context.cq_ctx; for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { @@ -3708,28 +4099,39 @@ static void ps3_qos_cmdq_clear(struct ps3_instance *instance, S32 resp_status) for (j = 1; j <= instance->qos_context.max_vd_count; j++) { waitq = &softq_mgr->waitqs[j]; if (waitq->count > 0) { - ps3_spin_lock_irqsave(&softq_mgr->rc_lock, &flag); - list_for_each_entry_safe(cmd, cmd_next, &waitq->wait_list, qos_list) { - LOG_DEBUG("qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, softq_mgr->id); + ps3_spin_lock_irqsave(&softq_mgr->rc_lock, + &flag); + list_for_each_entry_safe(cmd, cmd_next, + &waitq->wait_list, + qos_list) { + LOG_DEBUG( + "qos clean cmdq. hno:%u t_id:0x%llx CFID:%d cmdq:%u\n", + PS3_HOST(instance), + cmd->trace_id, cmd->index, + softq_mgr->id); list_del(&cmd->qos_list); waitq->count--; softq_mgr->total_wait_cmd_cnt--; - ps3_qos_update_pd_quota(cmd); - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, resp_status, PS3_FALSE); + ps3_qos_update_pd_quota(cmd, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi(cmd->scmd, + cmd, + resp_status, + PS3_FALSE); } - ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, flag); + ps3_spin_unlock_irqrestore(&softq_mgr->rc_lock, + flag); } } - cancel_work_sync(&softq_mgr->resend_work); + ps3_cancel_work_sync(&softq_mgr->resend_work); } } static void ps3_raid_qos_pd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - U16 pd_id = 0; - U16 vd_id = 0; + unsigned short pd_id = 0; + unsigned short vd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; pd_id = PS3_PDID(&priv_data->disk_pos); @@ -3742,22 +4144,26 @@ static void ps3_raid_qos_pd_clean(struct ps3_instance *instance, ps3_qos_mgrq_clean(instance, priv_data, resp_status); } - LOG_INFO("qos clean vd. host_no:%u did:%u vid:%u\n", - PS3_HOST(instance), pd_id, vd_id); + LOG_INFO("qos clean vd. host_no:%u did:%u vid:%u\n", PS3_HOST(instance), + pd_id, vd_id); } static void ps3_raid_qos_vd_clean(struct ps3_instance *instance, - struct ps3_scsi_priv_data *priv_data, S32 resp_status) + struct ps3_scsi_priv_data *priv_data, + int resp_status) { - U16 vd_id = 0; - U16 pd_id = 0; + unsigned short vd_id = 0; + unsigned short pd_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; - vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), PS3_VDID(&priv_data->disk_pos)); + vd_id = get_offset_of_vdid(PS3_VDID_OFFSET(instance), + PS3_VDID(&priv_data->disk_pos)); for (pd_id = 1; pd_id <= instance->qos_context.max_pd_count; pd_id++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, pd_id); - if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { - ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, resp_status); + if (ps3_atomic_read(&qos_pd_mgr->valid) == 1 && + PS3_QOS_PD_IS_VD_MEMBER(qos_pd_mgr)) { + ps3_pd_quota_waitq_clean(qos_pd_mgr, vd_id, + resp_status); } } @@ -3765,19 +4171,20 @@ static void ps3_raid_qos_vd_clean(struct ps3_instance *instance, ps3_qos_mgrq_clean(instance, priv_data, resp_status); LOG_FILE_INFO("qos clean vd. host_no:%u type:%u disk_id:%u\n", - PS3_HOST(instance), priv_data->dev_type, vd_id); + PS3_HOST(instance), priv_data->dev_type, vd_id); } -void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) +static void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, + int resp_status) { - U16 i = 0; + unsigned short i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; for (i = 1; i <= instance->qos_context.max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { ps3_pd_quota_waitq_clear_all(qos_pd_mgr, resp_status); - cancel_work_sync(&qos_pd_mgr->resend_work); + ps3_cancel_work_sync(&qos_pd_mgr->resend_work); } } @@ -3785,53 +4192,53 @@ void ps3_raid_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status ps3_qos_mgrq_clean(instance, NULL, resp_status); - LOG_INFO("host_no:%u:clear all qos waitq\n", - PS3_HOST(instance)); + LOG_INFO("host_no:%u:clear all qos waitq\n", PS3_HOST(instance)); } -static Bool ps3_qos_softq_notify_timeout(struct ps3_qos_softq_mgr *qos_softq_mgr) +static unsigned char +ps3_qos_softq_notify_timeout(struct ps3_qos_softq_mgr *qos_softq_mgr) { - Bool notified = PS3_FALSE; - ULong timeout_jiffies = 0; + unsigned char notified = PS3_FALSE; + unsigned long timeout_jiffies = 0; - timeout_jiffies = qos_softq_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; + timeout_jiffies = + qos_softq_mgr->last_sched_jiffies + PS3_QOS_WAITQ_TIMEOUT * HZ; if (qos_softq_mgr->total_wait_cmd_cnt && - ps3_atomic_read(&qos_softq_mgr->free_cnt) > 0 && - time_after(jiffies, timeout_jiffies)) { - queue_work(qos_softq_mgr->work_queue, &qos_softq_mgr->resend_work); + ps3_atomic_read(&qos_softq_mgr->free_cnt) > 0 && + time_after(jiffies, timeout_jiffies)) { + queue_work(qos_softq_mgr->work_queue, + &qos_softq_mgr->resend_work); notified = PS3_TRUE; LOG_INFO("awake qos softq by poll. host_no:%u q_id:%u\n", - PS3_HOST(qos_softq_mgr->instance), qos_softq_mgr->id); + PS3_HOST(qos_softq_mgr->instance), qos_softq_mgr->id); } return notified; } -static Bool ps3_qos_cq_notify_timeout(struct ps3_instance *instance) +static unsigned char ps3_qos_cq_notify_timeout(struct ps3_instance *instance) { struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - Bool notified = PS3_FALSE; - U8 i = 0; + unsigned char notified = PS3_FALSE; + unsigned char i = 0; qos_cq_ctx = &instance->qos_context.cq_ctx; ps3_qos_softq_notify_timeout(&qos_cq_ctx->mgrq); for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - if (ps3_qos_softq_notify_timeout(qos_softq_mgr)) { + if (ps3_qos_softq_notify_timeout(qos_softq_mgr)) notified = PS3_TRUE; - } } return notified; } -void ps3_raid_qos_waitq_poll(struct ps3_instance *instance) +static void ps3_raid_qos_waitq_poll(struct ps3_instance *instance) { - if (!ps3_qos_cq_notify_timeout(instance)) { + if (!ps3_qos_cq_notify_timeout(instance)) ps3_qos_pd_notify_timeout(instance); - } } static void ps3_raid_qos_reset(struct ps3_instance *instance) @@ -3840,31 +4247,33 @@ static void ps3_raid_qos_reset(struct ps3_instance *instance) struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_cq_context *qos_cq_ctx = NULL; struct ps3_qos_softq_mgr *qos_softq_mgr = NULL; - U16 i = 0; + unsigned short i = 0; struct ps3_pd_entry *pd_entry = NULL; qos_cq_ctx = &instance->qos_context.cq_ctx; qos_softq_mgr = &qos_cq_ctx->mgrq; ps3_atomic_set(&qos_softq_mgr->free_cnt, - qos_ctx->cq_ctx.mgrq_depth - (PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1)); + qos_ctx->cq_ctx.mgrq_depth - + (PS3_QOS_HIGH_PRI_MGR_CMD_COUNT >> 1)); for (i = 0; i < qos_cq_ctx->cmdq_cnt; i++) { qos_softq_mgr = &qos_cq_ctx->cmdqs[i]; - ps3_atomic_set(&qos_softq_mgr->free_cnt, qos_ctx->cq_ctx.cmdq_depth); + ps3_atomic_set(&qos_softq_mgr->free_cnt, + qos_ctx->cq_ctx.cmdq_depth); } qos_ctx->pd_ctx.nvme_normal_quota = g_ps3_qos_raid_nvme_normal_quota; for (i = 1; i <= qos_ctx->max_pd_count; i++) { qos_pd_mgr = ps3_qos_pd_mgr_get(instance, i); if (ps3_atomic_read(&qos_pd_mgr->valid) == 1) { - pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(instance, i); - if (pd_entry != NULL) { + pd_entry = + ps3_dev_mgr_lookup_pd_info_by_id(instance, i); + if (pd_entry != NULL) ps3_qos_pd_rsc_init(qos_pd_mgr, pd_entry); - } } } } -static Bool ps3_raid_qos_pd_resend_check(struct ps3_cmd *cmd) +static unsigned char ps3_raid_qos_pd_resend_check(struct ps3_cmd *cmd) { return ps3_qos_cq_decision(cmd); } @@ -3884,17 +4293,20 @@ void ps3_hba_qos_prepare(struct ps3_instance *instance) instance->qos_context.opts.qos_decision = ps3_hba_qos_decision; instance->qos_context.opts.qos_cmd_update = ps3_hba_qos_cmd_update; instance->qos_context.opts.qos_waitq_notify = ps3_hba_qos_waitq_notify; - instance->qos_context.opts.qos_pd_resend_check = ps3_hba_qos_pd_resend_check; + instance->qos_context.opts.qos_pd_resend_check = + ps3_hba_qos_pd_resend_check; instance->qos_context.opts.qos_waitq_abort = ps3_hba_qos_waitq_abort; instance->qos_context.opts.qos_vd_clean = ps3_hba_qos_vd_clean; instance->qos_context.opts.qos_pd_clean = ps3_hba_qos_pd_clean; instance->qos_context.opts.qos_waitq_poll = ps3_hba_qos_waitq_poll; - instance->qos_context.opts.qos_waitq_clear = ps3_hba_qos_waitq_clear_all; + instance->qos_context.opts.qos_waitq_clear = + ps3_hba_qos_waitq_clear_all; instance->qos_context.opts.qos_reset = ps3_hba_qos_reset; instance->qos_context.opts.qos_vd_init = ps3_hba_qos_vd_init; instance->qos_context.opts.qos_vd_reset = ps3_hba_qos_vd_reset; instance->qos_context.qos_switch = 1; - instance->qos_context.pd_ctx.nvme_normal_quota = g_ps3_qos_hba_nvme_normal_quota; + instance->qos_context.pd_ctx.nvme_normal_quota = + g_ps3_qos_hba_nvme_normal_quota; } void ps3_raid_qos_prepare(struct ps3_instance *instance) @@ -3904,36 +4316,37 @@ void ps3_raid_qos_prepare(struct ps3_instance *instance) instance->qos_context.opts.qos_decision = ps3_raid_qos_decision; instance->qos_context.opts.qos_cmd_update = ps3_raid_qos_cmd_update; instance->qos_context.opts.qos_waitq_notify = ps3_raid_qos_waitq_notify; - instance->qos_context.opts.qos_pd_resend_check = ps3_raid_qos_pd_resend_check; + instance->qos_context.opts.qos_pd_resend_check = + ps3_raid_qos_pd_resend_check; instance->qos_context.opts.qos_waitq_abort = ps3_raid_qos_waitq_abort; instance->qos_context.opts.qos_vd_clean = ps3_raid_qos_vd_clean; instance->qos_context.opts.qos_pd_clean = ps3_raid_qos_pd_clean; instance->qos_context.opts.qos_waitq_poll = ps3_raid_qos_waitq_poll; - instance->qos_context.opts.qos_waitq_clear = ps3_raid_qos_waitq_clear_all; + instance->qos_context.opts.qos_waitq_clear = + ps3_raid_qos_waitq_clear_all; instance->qos_context.opts.qos_reset = ps3_raid_qos_reset; instance->qos_context.opts.qos_vd_init = NULL; instance->qos_context.opts.qos_vd_reset = NULL; instance->qos_context.qos_switch = 1; - instance->qos_context.pd_ctx.nvme_normal_quota = g_ps3_qos_raid_nvme_normal_quota; + instance->qos_context.pd_ctx.nvme_normal_quota = + g_ps3_qos_raid_nvme_normal_quota; } -S32 ps3_qos_decision(struct ps3_cmd *cmd) +int ps3_qos_decision(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - Bool can_get = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned char can_get = PS3_TRUE; struct ps3_instance *instance = NULL; cmd->qos_processing = PS3_TRUE; - wmb(); + wmb(); /* in order to force CPU ordering */ instance = cmd->instance; - if (!ps3_qos_enable(cmd->instance) || !PS3_QOS_INITED(instance)) { + if (!ps3_qos_enable(cmd->instance) || !PS3_QOS_INITED(instance)) goto _exit; - } ret = ps3_qos_pre_check(instance, cmd); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto _exit; - } can_get = instance->qos_context.opts.qos_decision(cmd); if (!can_get) { @@ -3945,36 +4358,38 @@ S32 ps3_qos_decision(struct ps3_cmd *cmd) return ret; } -void ps3_qos_cmd_update(struct ps3_instance *instance, struct ps3_cmd *cmd) +void ps3_qos_cmd_update(struct ps3_instance *instance, + struct ps3_cmd *cmd, unsigned char in_reply) { - if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) { + if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) return; - } - instance->qos_context.opts.qos_cmd_update(cmd); + instance->qos_context.opts.qos_cmd_update(cmd, in_reply); } -void ps3_qos_waitq_notify(struct ps3_instance *instance) +void ps3_qos_waitq_notify(struct ps3_instance *instance, + unsigned short isr_sn) { - - if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) { + if (!ps3_qos_enable(instance) || !PS3_QOS_INITED(instance)) return; - } - instance->qos_context.opts.qos_waitq_notify(instance); + INJECT_START(PS3_ERR_IJ_REPLY_BLOCK, instance); + instance->qos_context.opts.qos_waitq_notify(instance, isr_sn); } -Bool ps3_qos_waitq_abort(struct ps3_cmd *cmd) +unsigned char ps3_qos_waitq_abort(struct ps3_cmd *cmd) { - Bool found = PS3_FALSE; - if (!PS3_QOS_INITED(cmd->instance)) { + unsigned char found = PS3_FALSE; + + if (!PS3_QOS_INITED(cmd->instance)) goto out; - } found = cmd->instance->qos_context.opts.qos_waitq_abort(cmd); - LOG_INFO("task abort cmd in qos waitq t_id:0x%llx CFID:%u flag:%u ret:%u\n", + LOG_INFO( + "task abort cmd in qos waitq t_id:0x%llx CFID:%u flag:%u ret:%u\n", cmd->trace_id, cmd->index, cmd->qos_waitq_flag, found); if (found) { - ps3_scsih_drv_io_reply_scsi(cmd->scmd, cmd, SCSI_STATUS_TASK_ABORTED, PS3_FALSE); + ps3_scsih_drv_io_reply_scsi( + cmd->scmd, cmd, SCSI_STATUS_TASK_ABORTED, PS3_FALSE); } out: return found; @@ -3982,36 +4397,36 @@ Bool ps3_qos_waitq_abort(struct ps3_cmd *cmd) void ps3_qos_hard_reset(struct ps3_instance *instance) { - S32 resp_status = 0; - if (ps3_pci_err_recovery_get(instance)) { + int resp_status = 0; + + if (ps3_pci_err_recovery_get(instance)) resp_status = PS3_STATUS_PCI_RECOVERY; - } else { + else resp_status = PS3_STATUS_HOST_RESET; - } ps3_qos_waitq_clear_all(instance, resp_status); } -void ps3_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status) +void ps3_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status) { - if (!PS3_QOS_INITED(instance)) { + if (!PS3_QOS_INITED(instance)) return; - } ps3_qos_wait_io_end(instance); instance->qos_context.opts.qos_waitq_clear(instance, resp_status); } -S32 ps3_qos_init(struct ps3_instance *instance) +int ps3_qos_init(struct ps3_instance *instance) { struct ps3_qos_context *qos_ctx = &instance->qos_context; - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; qos_ctx->max_vd_count = instance->ctrl_info.maxVdCount + 1; qos_ctx->max_pd_count = instance->ctrl_info.maxPdCount; qos_ctx->inited = 0; - LOG_INFO("hno:%u ps3 qos info:tfifo:%u sas_pd_quota[%u %u] sata_pd_quota[%u %u] nvme_quota[%u %u %u]\n", + LOG_INFO( + "hno:%u ps3 qos info:tfifo:%u sas_pd_quota[%u %u] sata_pd_quota[%u %u] nvme_quota[%u %u %u]\n", PS3_HOST(instance), instance->ctrl_info.qosInfo.tfifoDepth, instance->ctrl_info.qosInfo.sasHddQuota, instance->ctrl_info.qosInfo.sasSsdQuota, @@ -4024,8 +4439,10 @@ S32 ps3_qos_init(struct ps3_instance *instance) if (qos_ctx->opts.qos_init) { if (qos_ctx->opts.qos_init(instance) == PS3_SUCCESS) { qos_ctx->inited = 1; - LOG_INFO("hno:%u:ps3 qos init success, vd_count:%u pd_count:%u\n", - PS3_HOST(instance), qos_ctx->max_vd_count, qos_ctx->max_pd_count); + LOG_INFO( + "hno:%u:ps3 qos init success, vd_count:%u pd_count:%u\n", + PS3_HOST(instance), qos_ctx->max_vd_count, + qos_ctx->max_pd_count); } else { ret = -PS3_FAILED; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_qos.h b/drivers/scsi/linkdata/ps3stor/ps3_qos.h index bd1db94a6233..4b25a6ba8dbb 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_qos.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_qos.h @@ -1,39 +1,46 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_QOS_H_ #define _PS3_QOS_H_ - + #include "ps3_platform_utils.h" #include "ps3_htp.h" #include "ps3_cmd_channel.h" - +#include "ps3_kernel_version.h" + #define QOS_HIGH_PRI_EXCLUSIVE_CMD_COUNT 32 #define QOS_MGR_EXCLUSIVE_CMD_COUNT 64 #define PS3_QOS_DEFAULT_PD_QUOTA 40 #define PS3_QOS_SAS_PD_QUOTA 125 -#define PS3_QOS_NVME_MEMBER_QUOTA 127 +#define PS3_QOS_NVME_MEMBER_QUOTA 127 #define PS3_QOS_NVME_DIRECT_QUOTA 127 #define PS3_QOS_HBA_NVME_NORMAL_QUOTA 126 #define PS3_QOS_RAID_NVME_NORMAL_QUOTA 252 #define PS3_QOS_FUNC1_JBOD_VD_QUOTA 768 #define PS3_QOS_VD_EXCLUSIVE_CMD_COUNT 40 #define PS3_QOS_JBOD_EXCLUSIVE_CMD_COUNT 128 -#define PS3_QOS_POLL_INTERVAL 2 -#define PS3_QOS_WAITQ_TIMEOUT 5 +#define PS3_QOS_POLL_INTERVAL 2 +#define PS3_QOS_WAITQ_TIMEOUT 5 #define PS3_QOS_HBA_MAX_CMD 944 #define PS3_QOS_CS_FUNC0_SHARE_CMD 80 #define PS3_QOS_CS_FUNC0_JBOD_VD_QUOTA 80 -#define PS3_QOS_NOTIFY_CMD_COUNT 32 +#define PS3_QOS_NOTIFY_CMD_COUNT 32 #define PS3_QOS_FUNC0_PD_WORKQ_COUNT 1 #define PS3_QOS_FUNC1_PD_WORKQ_COUNT 4 #define PS3_QOS_POLL_CMD_COUNT 16 -#define PS3_CMD_NEED_QOS(cmd) \ - ((cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_NORMAL || \ - (cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) +#define PS3_CMD_NEED_QOS(cmd) \ + ((cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_NORMAL || \ + (cmd)->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) #define PS3_QOS_INITED(instance) ((instance)->qos_context.inited) - -enum ps3_qos_fifo_type { + +#define PS3_NEED_UPDATE_PD_QUOTAS(pd_mgr, pd_entry) \ + ( ((pd_mgr)->dev_type != (pd_entry)->dev_type) || \ + ((pd_mgr)->pd_quota != (pd_entry)->normal_quota) || \ + ((pd_mgr)->direct_quota != (pd_entry)->direct_quota) \ + ) + +enum ps3_qos_fifo_type { PS3_QOS_CMDQ_0, PS3_QOS_CMDQ_1, PS3_QOS_CMDQ_2, @@ -43,7 +50,7 @@ enum ps3_qos_fifo_type { PS3_QOS_FIFO_TYPE_MAX }; -enum ps3_qos_cmd_flag { +enum ps3_qos_cmd_flag { PS3_QOS_CMD_INIT = 0, PS3_QOS_CMD_IN_PD, PS3_QOS_CMD_IN_VD, @@ -55,167 +62,185 @@ enum ps3_qos_cmd_flag { PS3_QOS_CMD_IN_CMDQ3 }; -enum ps3_qos_quota_adjust_flag { +enum ps3_qos_quota_adjust_flag { PS3_QOS_QUOTA_ADJUST_DEFULAT = 0, PS3_QOS_QUOTA_ADJUST_QFULL, PS3_QOS_QUOTA_ADJUST_UP, PS3_QOS_QUOTA_ADJUST_INVALID }; -enum ps3_qos_vd_change_type { +enum ps3_qos_vd_change_type { PS3_QOS_VD_TYPE_CHANGE_TO_HDD, PS3_QOS_VD_TYPE_CHANGE_TO_SSD, PS3_QOS_VD_TYPE_CHANGE_INVALID }; struct qos_wait_queue { - ps3_list_head wait_list; - U32 count; - U16 id; - ps3_spinlock *rsc_lock; - S32 *free_rsc; - ps3_atomic32 *used_rsc; - U32 *total_waited_cnt; - U16 can_resend; - U16 has_resend; - ULong last_sched_jiffies; + struct list_head wait_list; + unsigned int count; + unsigned short id; + spinlock_t *rsc_lock; + int *free_rsc; + atomic_t *used_rsc; + unsigned int *total_waited_cnt; + unsigned short can_resend; + unsigned short has_resend; + unsigned long last_sched_jiffies; }; struct ps3_qos_vd_mgr { - Bool valid; - U16 id; - U8 workq_id; - ps3_atomic32 vd_quota; - ps3_spinlock rsc_lock; - struct qos_wait_queue vd_quota_wait_q; - ps3_atomic32 exclusive_cmd_cnt; - ps3_atomic32 share_cmd_used; + unsigned char valid; + unsigned short id; + unsigned char workq_id; + atomic_t vd_quota; + spinlock_t rsc_lock; + struct qos_wait_queue vd_quota_wait_q; + atomic_t exclusive_cmd_cnt; + atomic_t share_cmd_used; struct PS3VDEntry *vd_entry; struct ps3_instance *instance; - struct work_struct resend_work; - U64 last_sched_jiffies; + struct work_struct resend_work; + unsigned long long last_sched_jiffies; }; struct ps3_qos_pd_mgr { - ps3_atomic32 valid; - U8 workq_id; - U8 dev_type; - Bool clearing; - U16 disk_id; - U16 vd_id; - S32 pd_quota; - ps3_atomic32 pd_used_quota; + atomic_t valid; + unsigned char workq_id; + unsigned char dev_type; + unsigned char clearing; + unsigned short disk_id; + unsigned short vd_id; + int pd_quota; + atomic_t pd_used_quota; struct ps3_instance *instance; - struct work_struct resend_work; - U64 last_sched_jiffies; + struct work_struct resend_work; + unsigned long long last_sched_jiffies; struct qos_wait_queue *waitqs; - U16 waitq_cnt; - U32 total_wait_cmd_cnt; - ps3_spinlock rc_lock; - U16 poll_que_id; - U16 poll_start_que_id; - U16 poll_cmd_cnt; - ps3_spinlock direct_rsc_lock; - S32 direct_quota; - ps3_atomic32 direct_used_quota; - U32 total_waited_direct_cmd; - ps3_atomic32 processing_cnt; - ps3_spinlock adjust_quota_lock; - S32 adjust_max_quota; - S32 adjust_min_quota; - S32 pd_init_quota; + unsigned short waitq_cnt; + unsigned int total_wait_cmd_cnt; + spinlock_t rc_lock; + unsigned short poll_que_id; + unsigned short poll_start_que_id; + unsigned short poll_cmd_cnt; + spinlock_t direct_rsc_lock; + int direct_quota; + atomic_t direct_used_quota; + unsigned int total_waited_direct_cmd; + atomic_t processing_cnt; + spinlock_t adjust_quota_lock; + int adjust_max_quota; + int adjust_min_quota; + int pd_init_quota; + unsigned int wdt_awake; +}; + +struct ps3_qos_pd_reply_info { + unsigned char *processed_pd_state; + unsigned short *processed_pd_id; + unsigned short processed_pd_cnt; }; struct ps3_qos_pd_context { - struct ps3_qos_pd_mgr *qos_pd_mgrs; - struct workqueue_struct **work_queues; - U16 sas_sata_hdd_quota; - U16 sas_sata_ssd_quota; - U16 nvme_normal_quota; - U16 nvme_direct_quota; - ps3_atomic32 workq_id_cnt; - U8 workq_count; + struct ps3_qos_pd_mgr *qos_pd_mgrs; + struct workqueue_struct **work_queues; + unsigned short sas_sata_hdd_quota; + unsigned short sas_sata_ssd_quota; + unsigned short nvme_normal_quota; + unsigned short nvme_direct_quota; + atomic_t workq_id_cnt; + unsigned char workq_count; + struct ps3_qos_pd_reply_info *reply_info; }; struct ps3_qos_vd_context { - struct ps3_qos_vd_mgr *qos_vd_mgrs; - struct workqueue_struct **work_queues; - U16 jbod_exclusive_cnt; - U16 vd_exclusive_cnt; - U8 workq_count; - Bool inited; + struct ps3_qos_vd_mgr *qos_vd_mgrs; + struct workqueue_struct **work_queues; + unsigned short jbod_exclusive_cnt; + unsigned short vd_exclusive_cnt; + unsigned char workq_count; + unsigned char inited; }; struct ps3_qos_tg_context { - U32 share; - U32 mgr_exclusive_cnt; - U16 high_pri_exclusive_cnt; - ps3_atomic32 mgr_free_cnt; - ps3_atomic32 mgr_share_used; - ps3_atomic32 share_free_cnt; - struct qos_wait_queue mgr_cmd_wait_q; - struct qos_wait_queue *vd_cmd_waitqs; - U32 total_wait_cmd_cnt; - U8 poll_vd_id; - ps3_spinlock lock; + unsigned int share; + unsigned int mgr_exclusive_cnt; + unsigned short high_pri_exclusive_cnt; + atomic_t mgr_free_cnt; + atomic_t mgr_share_used; + atomic_t share_free_cnt; + struct qos_wait_queue mgr_cmd_wait_q; + struct qos_wait_queue *vd_cmd_waitqs; + unsigned int total_wait_cmd_cnt; + unsigned char poll_vd_id; + spinlock_t lock; struct ps3_instance *instance; - struct workqueue_struct *work_queue; - struct work_struct resend_work; - U64 last_sched_jiffies; + struct workqueue_struct *work_queue; + struct work_struct resend_work; + unsigned long long last_sched_jiffies; }; struct ps3_qos_ops { - S32 (*qos_init)(struct ps3_instance *instance); + int (*qos_init)(struct ps3_instance *instance); void (*qos_exit)(struct ps3_instance *instance); - void (*qos_vd_init)(struct ps3_instance *instance, struct PS3VDEntry *vd_entry); - void (*qos_vd_reset)(struct ps3_instance *instance, U16 disk_id); - Bool (*qos_decision)(struct ps3_cmd *cmd); - void (*qos_cmd_update)(struct ps3_cmd *cmd); - void (*qos_waitq_notify)(struct ps3_instance *instance); - Bool (*qos_pd_resend_check)(struct ps3_cmd *cmd); - Bool (*qos_waitq_abort)(struct ps3_cmd *cmd); - void (*qos_vd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, S32 ret_code); - void (*qos_pd_clean)(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data, S32 ret_code); - void (*qos_waitq_clear)(struct ps3_instance *instance, S32 ret_code); + void (*qos_vd_init)(struct ps3_instance *instance, + struct PS3VDEntry *vd_entry); + void (*qos_vd_reset)(struct ps3_instance *instance, + unsigned short disk_id); + unsigned char (*qos_decision)(struct ps3_cmd *cmd); + void (*qos_cmd_update)(struct ps3_cmd *cmd, unsigned char in_reply); + void (*qos_waitq_notify)(struct ps3_instance *instance, unsigned short isr_sn); + unsigned char (*qos_pd_resend_check)(struct ps3_cmd *cmd); + unsigned char (*qos_waitq_abort)(struct ps3_cmd *cmd); + void (*qos_vd_clean)(struct ps3_instance *instance, + struct ps3_scsi_priv_data *pri_data, int ret_code); + void (*qos_pd_clean)(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data, + int ret_code); + void (*qos_waitq_clear)(struct ps3_instance *instance, int ret_code); void (*qos_waitq_poll)(struct ps3_instance *instance); - void (*qos_reset)(struct ps3_instance *instance); + void (*qos_reset)(struct ps3_instance *instance); }; -Bool inline ps3_qos_enable(struct ps3_instance *instance); - -S32 ps3_hba_qos_init(struct ps3_instance *instance); +int ps3_hba_qos_init(struct ps3_instance *instance); void ps3_hba_qos_exit(struct ps3_instance *instance); -void ps3_qos_vd_init(struct ps3_instance *instance, struct PS3VDEntry *vd_entry); +void ps3_qos_vd_init(struct ps3_instance *instance, + struct PS3VDEntry *vd_entry); -void ps3_qos_vd_reset(struct ps3_instance *instance, U16 disk_id); +void ps3_qos_vd_reset(struct ps3_instance *instance, unsigned short disk_id); -struct ps3_qos_pd_mgr* ps3_qos_pd_mgr_init(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry); +struct ps3_qos_pd_mgr *ps3_qos_pd_mgr_init(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry); -void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, U16 pd_id); +void ps3_qos_pd_mgr_reset(struct ps3_instance *instance, unsigned short pd_id); -void ps3_qos_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry, - struct scsi_device *sdev, Bool is_vd_member); +void ps3_qos_vd_member_change(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry, + struct scsi_device *sdev, + unsigned char is_vd_member); -S32 ps3_qos_decision(struct ps3_cmd *cmd); +int ps3_qos_decision(struct ps3_cmd *cmd); -void ps3_qos_cmd_update(struct ps3_instance *instance, struct ps3_cmd *cmd); +void ps3_qos_cmd_update(struct ps3_instance *instance, + struct ps3_cmd *cmd, unsigned char in_reply); -void ps3_qos_waitq_notify(struct ps3_instance *instance); +void ps3_qos_waitq_notify(struct ps3_instance *instance, unsigned short isr_sn); -Bool ps3_qos_waitq_abort(struct ps3_cmd *aborted_cmd); +unsigned char ps3_qos_waitq_abort(struct ps3_cmd *aborted_cmd); -void ps3_qos_device_clean(struct ps3_instance *instance, struct ps3_scsi_priv_data *pri_data, - S32 ret_code); +void ps3_qos_device_clean(struct ps3_instance *instance, + struct ps3_scsi_priv_data *pri_data, int ret_code); -void ps3_qos_disk_del(struct ps3_instance *instance, struct ps3_scsi_priv_data *priv_data); +void ps3_qos_disk_del(struct ps3_instance *instance, + struct ps3_scsi_priv_data *priv_data); -void ps3_qos_vd_member_del(struct ps3_instance *instance, struct PS3DiskDevPos *dev_pos); +void ps3_qos_vd_member_del(struct ps3_instance *instance, + struct PS3DiskDevPos *dev_pos); void ps3_qos_hard_reset(struct ps3_instance *instance); -void ps3_qos_waitq_clear_all(struct ps3_instance *instance, S32 resp_status); +void ps3_qos_waitq_clear_all(struct ps3_instance *instance, int resp_status); void ps3_qos_waitq_poll(struct ps3_instance *instance); @@ -232,59 +257,62 @@ void ps3_raid_qos_prepare(struct ps3_instance *instance); #define PS3_QOS_MGRQ_DEPTH 1024 #define PS3_QOS_HIGH_PRI_MGR_CMD_COUNT 32 struct ps3_qos_softq_mgr { - U16 id; + unsigned short id; struct ps3_instance *instance; - ps3_spinlock rc_lock; - ps3_atomic32 free_cnt; + spinlock_t rc_lock; + atomic_t free_cnt; struct qos_wait_queue *waitqs; - U16 waitq_cnt; - U32 total_wait_cmd_cnt; - struct workqueue_struct *work_queue; - struct work_struct resend_work; - U64 last_sched_jiffies; - U16 poll_cmd_cnt; - U16 poll_que_id; + unsigned short waitq_cnt; + unsigned int total_wait_cmd_cnt; + struct workqueue_struct *work_queue; + struct work_struct resend_work; + unsigned long long last_sched_jiffies; + unsigned short poll_cmd_cnt; + unsigned short poll_que_id; }; struct ps3_qos_cq_context { struct ps3_qos_softq_mgr mgrq; struct ps3_qos_softq_mgr *cmdqs; - U8 cmdq_cnt; - U32 mgrq_depth; - U32 cmdq_depth; + unsigned char cmdq_cnt; + unsigned int mgrq_depth; + unsigned int cmdq_depth; }; -struct ps3_qos_context { +struct ps3_qos_context { struct ps3_qos_ops opts; struct ps3_qos_pd_context pd_ctx; struct ps3_qos_vd_context vd_ctx; struct ps3_qos_tg_context tg_ctx; struct ps3_qos_cq_context cq_ctx; - U16 max_vd_count; - U16 max_pd_count; - U8 poll_count; - U8 qos_switch; - U8 inited; + unsigned short max_vd_count; + unsigned short max_pd_count; + unsigned char poll_count; + unsigned char qos_switch; + unsigned char inited; }; -S32 ps3_raid_qos_init(struct ps3_instance *instance); +int ps3_raid_qos_init(struct ps3_instance *instance); void ps3_raid_qos_exit(struct ps3_instance *instance); -S32 ps3_qos_init(struct ps3_instance *instance); +int ps3_qos_init(struct ps3_instance *instance); void ps3_qos_exit(struct ps3_instance *instance); void ps3_qos_adjust_pd_rsc(struct scsi_device *sdev, - struct ps3_instance *instance, S32 reason); + struct ps3_instance *instance, int reason); void ps3_qos_vd_attr_change(struct ps3_instance *instance, - struct PS3VDEntry *vd_entry_old, struct PS3VDEntry *vd_entry); + struct PS3VDEntry *vd_entry_old, + struct PS3VDEntry *vd_entry); -void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, struct ps3_pd_entry *pd_entry); +void ps3_qos_pd_rsc_init(struct ps3_qos_pd_mgr *qos_pd_mgr, + struct ps3_pd_entry *pd_entry); -#if (LINUX_VERSION_CODE > KERNEL_VERSION(4,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)) -void ps3_linx80_vd_member_change(struct ps3_instance *instance, struct ps3_pd_entry *pd_entry); +#if defined(PS3_SUPPORT_LINX80) +void ps3_linx80_vd_member_change(struct ps3_instance *instance, + struct ps3_pd_entry *pd_entry); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c index 3dba5820cb36..8c0a870d3326 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -12,7 +13,7 @@ #include "ps3_driver_log.h" #include "ps3_rb_tree.h" #include "ps3_inner_data.h" -#include "ps3_meta.h" +#include "ps3_htp_meta.h" #include "ps3_cmd_channel.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_r1x_write_lock.h" @@ -24,7 +25,7 @@ #include "ps3_scsi_cmd_err.h" #include "ps3_module_para.h" -enum{ +enum { PS3_CONFLICT_QUEUE_EMPTY = 0, PS3_CONFLICT_QUEUE_CONFLICT = 1, PS3_CONFLICT_QUEUE_NO_CONFLICT = 2, @@ -32,93 +33,102 @@ enum{ #define PS3_R1X_RESEND_COUNT (32) -#define LOCK_BLOCK_SIZE_SHIFT 3 -#define HASH_TABLE_SIZE_SHIFT 12 -#define HASH_TABLE_SIZE (1 << HASH_TABLE_SIZE_SHIFT) -#define HASH_TABLE_SIZE_MASK (HASH_TABLE_SIZE - 1) -#define SZBLOCK_SIZE_SHIFT 10 -#define SZBLOCK_SIZE ((U32)(1 << SZBLOCK_SIZE_SHIFT)) -#define SZBLOCK_SIZE_MASK (SZBLOCK_SIZE - 1) -#define VD_QUE_DEPTH 512 -#define CMD_SIZE_MAX 4096 +#define LOCK_BLOCK_SIZE_SHIFT 3 +#define HASH_TABLE_SIZE_SHIFT 12 +#define HASH_TABLE_SIZE (1 << HASH_TABLE_SIZE_SHIFT) +#define HASH_TABLE_SIZE_MASK (HASH_TABLE_SIZE - 1) +#define SZBLOCK_SIZE_SHIFT 10 +#define SZBLOCK_SIZE ((unsigned int)(1 << SZBLOCK_SIZE_SHIFT)) +#define SZBLOCK_SIZE_MASK (SZBLOCK_SIZE - 1) +#define VD_QUE_DEPTH 512 +#define CMD_SIZE_MAX 4096 -#define PS3_R1X_BIT_CNT ((SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT) * HASH_TABLE_SIZE) -#define PS3_R1X_BIT_MAP_SIZE (PS3_R1X_BIT_CNT >> 3) +#define PS3_R1X_BIT_CNT \ + ((SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT) * HASH_TABLE_SIZE) +#define PS3_R1X_BIT_MAP_SIZE (PS3_R1X_BIT_CNT >> 3) -#define SECTOR_SIZE_4K 4096 -#define SECTOR_512_4K_SHIFT 3 -#define SZ_BLOCK_SPLIT_MAX ((4096 >> SZBLOCK_SIZE_SHIFT) + 2) +#define SECTOR_SIZE_4K 4096 +#define SECTOR_512_4K_SHIFT 3 +#define SZ_BLOCK_SPLIT_MAX ((4096 >> SZBLOCK_SIZE_SHIFT) + 2) -#define RW_R1X_HASHIDX(lba) (((lba) >> SZBLOCK_SIZE_SHIFT) & HASH_TABLE_SIZE_MASK) -#define RW_R1X_HASHIDX_HASH(mgr, lba) ps3_private_r1x_hash((mgr), ((lba) >> SZBLOCK_SIZE_SHIFT)) +#define RW_R1X_HASHIDX(lba) \ + (((lba) >> SZBLOCK_SIZE_SHIFT) & HASH_TABLE_SIZE_MASK) +#define RW_R1X_HASHIDX_HASH(mgr, lba) \ + ps3_private_r1x_hash((mgr), ((lba) >> SZBLOCK_SIZE_SHIFT)) -#define PS3_LBA(lba_hi, lba_lo) ((((U64)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) +#define PS3_LBA(lba_hi, lba_lo) \ + ((((unsigned long long)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) #define PS3_SZ_BLOCK_CNT (2560) -enum{ - PS3_R1X_IO_CONFLICT = 1, - PS3_R1X_HASH_CONFILICT = 2, - PS3_R1X_BIT_NOT_ENOUGH = 3, +enum { + PS3_R1X_IO_CONFLICT = 1, + PS3_R1X_HASH_CONFILICT = 2, + PS3_R1X_BIT_NOT_ENOUGH = 3, }; -#define PS3_R1X_LOCK_TRACE(fmt, ...) LOG_DEBUG(fmt "\n", ##__VA_ARGS__); -#define PS3_R1X_LOCK_INFO(fmt, ...) LOG_INFO(fmt "\n", ##__VA_ARGS__); -#define PS3_R1X_LOCK_WARN(fmt, ...) LOG_WARN(fmt "\n", ##__VA_ARGS__); -#define PS3_R1X_LOCK_ERROR(fmt, ...) LOG_ERROR(fmt "\n", ##__VA_ARGS__); +#define PS3_R1X_LOCK_TRACE(fmt, ...) LOG_DEBUG(fmt "\n", ##__VA_ARGS__) +#define PS3_R1X_LOCK_INFO(fmt, ...) LOG_INFO(fmt "\n", ##__VA_ARGS__) +#define PS3_R1X_LOCK_WARN(fmt, ...) LOG_WARN(fmt "\n", ##__VA_ARGS__) +#define PS3_R1X_LOCK_ERROR(fmt, ...) LOG_ERROR(fmt "\n", ##__VA_ARGS__) -#define PS3_R1X_TIMEOUT(cmd, tmo) (time_after(jiffies, \ - (cmd)->scmd->jiffies_at_alloc + (tmo))) +#define PS3_R1X_TIMEOUT(cmd, tmo) \ + (time_after(jiffies, (cmd)->scmd->jiffies_at_alloc + (tmo))) -U32 g_ps3_r1x_lock_flag = PS3_R1X_HASHRANGE_LOCK; -U32 g_ps3_r1x_lock_enable = 1; +unsigned int g_ps3_r1x_lock_flag = PS3_R1X_HASHRANGE_LOCK; +#ifdef PS3_UT +unsigned int g_ps3_r1x_lock_enable = 1; +#else +unsigned int g_ps3_r1x_lock_enable = 0; +#endif -static S32 ps3_r1x_hash_bit_lock_of_conflict_queue( - struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd); +static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd); #if PS3_DESC("-----------------------hash bit互斥方案------------------------") -#define LOCK_BLOCK_SIZE (1 << LOCK_BLOCK_SIZE_SHIFT) -#define LOCK_BLOCK_SIZE_MASK (LOCK_BLOCK_SIZE - 1) -#define RW_BIT_TO_BYTE(bit) ((bit) >> 3) -#define RW_BYTE_TO_BIT(byte) ((bit) << 3) -#define RW_BIT_BYTE_MASK 7 -#define RW_R1X_SZBLOCKIDX(lba) (lba >> SZBLOCK_SIZE_SHIFT) -#define RW_SZBLOCK_IDX_INVALUD 0xFFFFFFFFFFFF -#define RW_BITMAP_IDX_INVALUD 0xFFFF -#define RW_R1X_GET_BITMAP(bit_buff,idx) (bit_buff[idx]) -#define RW_BIT_64_MASK 63 -#define RW_BYTE_TO_U64(n) (n >> 3) - -struct ps3_r1x_hash_bit_item{ - U64 sz_block_idx : 48; - U64 bitmap_idx : 16; +#define LOCK_BLOCK_SIZE (1 << LOCK_BLOCK_SIZE_SHIFT) +#define LOCK_BLOCK_SIZE_MASK (LOCK_BLOCK_SIZE - 1) +#define RW_BIT_TO_BYTE(bit) ((bit) >> 3) +#define RW_BYTE_TO_BIT(byte) ((bit) << 3) +#define RW_BIT_BYTE_MASK 7 +#define RW_R1X_SZBLOCKIDX(lba) (lba >> SZBLOCK_SIZE_SHIFT) +#define RW_SZBLOCK_IDX_INVALID 0xFFFFFFFFFFFF +#define RW_BITMAP_IDX_INVALID 0xFFFF +#define RW_R1X_GET_BITMAP(bit_buff, idx) (bit_buff[idx]) +#define RW_BIT_64_MASK 63 +#define RW_BYTE_TO_U64(n) (n >> 3) + +struct ps3_r1x_hash_bit_item { + unsigned long long sz_block_idx : 48; + unsigned long long bitmap_idx : 16; }; -struct ps3_r1x_bit_block_mgr -{ - U8* bit_buff; - U8 bit_block_size; - U8 resv[7]; +struct ps3_r1x_bit_block_mgr { + unsigned char *bit_buff; + unsigned char bit_block_size; + unsigned char resv[7]; }; -struct ps3_r1x_hash_bit_mgr{ - struct ps3_r1x_hash_bit_item hash_item[HASH_TABLE_SIZE]; - struct ps3_r1x_bit_block_mgr bitmap_mgr; +struct ps3_r1x_hash_bit_mgr { + struct ps3_r1x_hash_bit_item hash_item[HASH_TABLE_SIZE]; + struct ps3_r1x_bit_block_mgr bitmap_mgr; }; -static U16 ps3_private_r1x_hash(struct ps3_r1x_lock_mgr *mgr, ULong hashval) +static unsigned short ps3_private_r1x_hash(struct ps3_r1x_lock_mgr *mgr, + unsigned long hashval) { - ULong tmp; - tmp = (hashval * (ULong)mgr) ^ (GOLDEN_RATIO_PRIME + hashval) / - L1_CACHE_BYTES; + unsigned long tmp; + + tmp = (hashval * (unsigned long)mgr) ^ + (GOLDEN_RATIO_PRIME + hashval) / L1_CACHE_BYTES; tmp = tmp ^ ((tmp ^ GOLDEN_RATIO_PRIME) >> HASH_TABLE_SIZE_SHIFT); return tmp & HASH_TABLE_SIZE_MASK; } static inline void ps3_r1x_conflict_queue_del(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) + struct ps3_cmd *cmd) { - ULong flag = 0; + unsigned long flag = 0; if (cmd->is_inserted_c_q == 1) { ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); @@ -130,13 +140,12 @@ static inline void ps3_r1x_conflict_queue_del(struct ps3_r1x_lock_mgr *mgr, } void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, - S32 ret_code) + int ret_code) { - ULong flag = 0; + unsigned long flag = 0; - if(unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) { + if (unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) return; - } ps3_spin_lock_irqsave(&pri_data->lock_mgr.mgr_lock, &flag); if (pri_data->lock_mgr.force_ret_code == SCSI_STATUS_GOOD) { @@ -146,60 +155,64 @@ void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, ps3_spin_unlock_irqrestore(&pri_data->lock_mgr.mgr_lock, flag); LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean begin\n", - PS3_CHANNEL(&pri_data->disk_pos), - PS3_TARGET(&pri_data->disk_pos)); - wmb(); + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); + wmb(); /* in order to force CPU ordering */ while (pri_data->lock_mgr.force_ret_code != SCSI_STATUS_GOOD) { ps3_msleep(100); - rmb(); + rmb(); /* in order to force CPU ordering */ } LOG_FILE_INFO("dev[%u:%u], wait r1x conflict queue clean end\n", - PS3_CHANNEL(&pri_data->disk_pos), - PS3_TARGET(&pri_data->disk_pos)); + PS3_CHANNEL(&pri_data->disk_pos), + PS3_TARGET(&pri_data->disk_pos)); } void ps3_r1x_conflict_queue_target_reset(struct ps3_instance *instance, - U16 target_id) + unsigned short target_id) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - U8 i = 0; + unsigned char i = 0; struct ps3_scsi_priv_data *pri_data = NULL; for (i = 0; i < channel_info->channelNum; i++) { if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD || - channel_info->channels[i].maxDevNum <= target_id) { + channel_info->channels[i].maxDevNum <= target_id) { continue; } ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - pri_data = ps3_dev_mgr_lookup_vd_pri_data(instance, i, target_id); - ps3_r1x_conflict_queue_clean(pri_data, SCSI_STATUS_TASK_ABORTED); + pri_data = + ps3_dev_mgr_lookup_vd_pri_data(instance, i, target_id); + ps3_r1x_conflict_queue_clean(pri_data, + SCSI_STATUS_TASK_ABORTED); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); } } void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, - S32 ret_code, Bool is_remove) + int ret_code, unsigned char is_remove) { struct PS3ChannelInfo *channel_info = &instance->ctrl_info.channelInfo; - U16 maxDevNum = 0; - U8 i = 0; - U16 j = 0; + unsigned short maxDevNum = 0; + unsigned char i = 0; + unsigned short j = 0; struct ps3_scsi_priv_data *pri_data = NULL; for (i = 0; i < channel_info->channelNum; i++) { - if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD) { + if (channel_info->channels[i].channelType != PS3_DISK_TYPE_VD) continue; - } maxDevNum = channel_info->channels[i].maxDevNum; for (j = 0; j < maxDevNum; j++) { ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - pri_data = ps3_dev_mgr_lookup_vd_pri_data(instance, i, j); - if(unlikely(pri_data == NULL) || pri_data->lock_mgr.hash_mgr == NULL) { - ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); + pri_data = + ps3_dev_mgr_lookup_vd_pri_data(instance, i, j); + if (unlikely(pri_data == NULL) || + pri_data->lock_mgr.hash_mgr == NULL) { + ps3_mutex_unlock( + &instance->dev_context.dev_priv_lock); continue; } pri_data->lock_mgr.dev_deling = is_remove; @@ -210,9 +223,10 @@ void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, } } -Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd) +unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, + struct scsi_cmnd *scmd) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; struct ps3_scsi_priv_data *data = NULL; if (cmd->is_inserted_c_q == 0) { @@ -220,11 +234,10 @@ Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd) goto l_out; } - LOG_INFO("task abort cmd:%d is in conflict queue !\n", - cmd->index); + LOG_INFO("task abort cmd:%d is in conflict queue !\n", cmd->index); data = (struct ps3_scsi_priv_data *)scmd->device->hostdata; - if(unlikely(data == NULL)){ + if (unlikely(data == NULL)) { ret = PS3_FALSE; goto l_out; } @@ -234,46 +247,45 @@ Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd) while (cmd->is_inserted_c_q == 1) { ps3_msleep(100); - rmb(); + rmb(); /* in order to force CPU ordering */ } if (cmd->is_r1x_aborting == 0) { ret = PS3_TRUE; while (cmd->cmd_state.state != PS3_CMD_STATE_INIT) { ps3_msleep(10); - rmb(); + rmb(); /* in order to force CPU ordering */ } } else { ret = PS3_FALSE; } LOG_INFO("task abort cmd:%d in conflict queue aborting ret:%d\n", - cmd->index, ret); + cmd->index, ret); l_out: return ret; } -static void ps3_conflict_queue_clean_bitmap(struct ps3_r1x_hash_bit_mgr* mgr) +static void ps3_conflict_queue_clean_bitmap(struct ps3_r1x_hash_bit_mgr *mgr) { - U32 i = 0; + unsigned int i = 0; LOG_FILE_INFO("ready clean conflict queue bitmap\n"); - for (i = 0; i < HASH_TABLE_SIZE; i++) { - mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALUD; - } + for (i = 0; i < HASH_TABLE_SIZE; i++) + mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; memset(mgr->bitmap_mgr.bit_buff, 0, PS3_R1X_BIT_MAP_SIZE); } static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) { - ULong flag = 0; - ps3_list_head conflict_cmd_list_tmp; + unsigned long flag = 0; + struct list_head conflict_cmd_list_tmp; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct scsi_cmnd *s_cmd = NULL; - S32 ret_result = SCSI_STATUS_GOOD; + int ret_result = SCSI_STATUS_GOOD; INIT_LIST_HEAD(&conflict_cmd_list_tmp); ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); @@ -282,23 +294,22 @@ static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) if (!list_empty(&mgr->conflict_cmd_list)) { list_for_each_entry_safe(cmd, cmd_next, - &mgr->conflict_cmd_list, cmd_list) { + &mgr->conflict_cmd_list, cmd_list) { list_move_tail(&cmd->cmd_list, &conflict_cmd_list_tmp); } } - ps3_conflict_queue_clean_bitmap((struct ps3_r1x_hash_bit_mgr*) - mgr->hash_mgr_conflict); + ps3_conflict_queue_clean_bitmap( + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict); mgr->cmd_count_in_q = 0; ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - list_for_each_entry_safe(cmd, cmd_next, - &conflict_cmd_list_tmp, cmd_list) { - + list_for_each_entry_safe(cmd, cmd_next, &conflict_cmd_list_tmp, + cmd_list) { LOG_DEBUG("conflict queue cmd:%d t_id:0x%llx return:0x%x\n", - cmd->index, cmd->trace_id, ret_result); + cmd->index, cmd->trace_id, ret_result); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; @@ -310,15 +321,15 @@ static void ps3_conflict_queue_return_all(struct ps3_r1x_lock_mgr *mgr) SCMD_IO_DONE(s_cmd); } - if (ret_result != SCSI_STATUS_GOOD) { + if (ret_result != SCSI_STATUS_GOOD) mgr->force_ret_code = SCSI_STATUS_GOOD; - } } -static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static int ps3_conflict_queue_resend(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *pri_data = NULL; struct scsi_cmnd *s_cmd = cmd->scmd; static unsigned long j; @@ -326,7 +337,7 @@ static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, ret = instance->ioc_adpter->io_cmd_build(cmd); if (ret == -PS3_IO_CONFLICT_IN_Q) { LOG_DEBUG("t_id:0x%llx hno:%u tag:%d cmd build err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), cmd->index, ret); + cmd->trace_id, PS3_HOST(instance), cmd->index, ret); goto l_out; } @@ -335,13 +346,15 @@ static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, if (ret == -PS3_IN_QOS_Q) { ret = PS3_SUCCESS; LOG_DEBUG("insert qos waitq. hno:%u t_id:0x%llx tag:%u\n", - PS3_HOST(instance), cmd->trace_id, cmd->index); + PS3_HOST(instance), cmd->trace_id, cmd->index); goto l_out; } if (ret != PS3_SUCCESS) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "t_id:0x%llx hno:%u tag:%d cmd build NOK ret:%d\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); goto l_cmd_release; } @@ -350,11 +363,15 @@ static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, if (unlikely(ret != PS3_SUCCESS)) { if (ret == -PS3_RECOVERED || ret == -PS3_RETRY) { ps3_errcode_to_scsi_status(instance, s_cmd, - SCSI_STATUS_BUSY, NULL, 0, cmd); + SCSI_STATUS_BUSY, NULL, 0, + cmd); } else { - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); } - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "t_id:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", cmd->trace_id, PS3_HOST(instance), cmd->index, ret); PS3_DEV_IO_START_ERR_INC(instance, cmd); goto l_cmd_release; @@ -371,38 +388,40 @@ static S32 ps3_conflict_queue_resend(struct ps3_instance *instance, return ret; } -static S32 ps3_conflict_queue_send_wk(void *data) +static int ps3_conflict_queue_send_wk(void *data) { struct scsi_device *sdev = (struct scsi_device *)data; - struct ps3_r1x_lock_mgr *mgr =&PS3_SDEV_PRI_DATA(sdev)->lock_mgr; + struct ps3_r1x_lock_mgr *mgr = &PS3_SDEV_PRI_DATA(sdev)->lock_mgr; struct ps3_instance *instance = - (struct ps3_instance*)sdev->host->hostdata; + (struct ps3_instance *)sdev->host->hostdata; struct ps3_cmd *cmd = NULL; struct ps3_cmd *cmd_next = NULL; struct scsi_cmnd *s_cmd = NULL; - ULong flag = 0; - S32 ret = PS3_SUCCESS; - U32 cur_total_count = 0; - U32 cmd_count = 0; - U8 try_count = 0; + unsigned long flag = 0; + int ret = PS3_SUCCESS; + unsigned int cur_total_count = 0; + unsigned int cmd_count = 0; + unsigned char try_count = 0; LOG_INFO("hno:%u vd[%u:%u] conflict queue thread enter\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); while (true) { wait_for_completion_interruptible(&mgr->thread_sync); if (mgr->thread_stop || kthread_should_stop()) { LOG_INFO("hno:%u r1x conflict thread, ready stop\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (mgr->force_ret_code != SCSI_STATUS_GOOD) { - LOG_INFO("hno:%u r1x conflict thread, return all cmd with:0x%x\n", + LOG_INFO( + "hno:%u r1x conflict thread, return all cmd with:0x%x\n", PS3_HOST(instance), mgr->force_ret_code); ps3_conflict_queue_return_all(mgr); - LOG_INFO("hno:%u r1x conflict thread, return all cmd with:0x%x end\n", + LOG_INFO( + "hno:%u r1x conflict thread, return all cmd with:0x%x end\n", PS3_HOST(instance), mgr->force_ret_code); continue; } @@ -414,13 +433,12 @@ static S32 ps3_conflict_queue_send_wk(void *data) try_count = 0; list_for_each_entry_safe(cmd, cmd_next, - &mgr->conflict_cmd_list, cmd_list) { - + &mgr->conflict_cmd_list, cmd_list) { if (cmd->is_r1x_aborting == 1) { ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; cmd->is_r1x_aborting = 0; - wmb(); + wmb(); /* in order to force CPU ordering */ ps3_r1x_conflict_queue_del(mgr, cmd); PS3_IO_OUTSTAND_DEC(instance, s_cmd); PS3_IO_BACK_ERR_INC(instance, s_cmd); @@ -429,21 +447,27 @@ static S32 ps3_conflict_queue_send_wk(void *data) SCMD_IO_DONE(s_cmd); PS3_IJ_SLEEP(2000, PS3_ERR_IJ_R1X_ABORT); ps3_scsi_cmd_free(cmd); - LOG_INFO("hno:%u cmd:%d out r1x conflict queue by abort\n", + LOG_INFO( + "hno:%u cmd:%d out r1x conflict queue by abort\n", PS3_HOST(instance), cmd->index); continue; } LOG_DEBUG("hno:%u cmd:%d t_id:0x%llx ready resend\n", - PS3_HOST(instance), cmd->index, cmd->trace_id); + PS3_HOST(instance), cmd->index, + cmd->trace_id); ret = ps3_conflict_queue_resend(instance, mgr, cmd); if (ret == PS3_SUCCESS) { - LOG_DEBUG("hno:%u cmd:%d t_id[%llx] out r1x conflict queue by send success\n", - PS3_HOST(instance), cmd->index, cmd->trace_id); - } else if(ret == -PS3_IO_CONFLICT_IN_Q) { + LOG_DEBUG( + "hno:%u cmd:%d t_id[%llx] out r1x conflict queue by send success\n", + PS3_HOST(instance), cmd->index, + cmd->trace_id); + } else if (ret == -PS3_IO_CONFLICT_IN_Q) { } else { - LOG_INFO("hno:%u cmd:%d tid:0x%llx out r1x conflict queue by send failed\n", - PS3_HOST(instance), cmd->index, cmd->trace_id); + LOG_INFO( + "hno:%u cmd:%d tid:0x%llx out r1x conflict queue by send failed\n", + PS3_HOST(instance), cmd->index, + cmd->trace_id); ps3_scsi_dma_unmap(cmd); s_cmd = cmd->scmd; PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); @@ -453,10 +477,10 @@ static S32 ps3_conflict_queue_send_wk(void *data) SCMD_IO_DONE(s_cmd); } LOG_DEBUG("hno:%u cmd:%d t_id:0x%llx resend ret:%d\n", - PS3_HOST(instance), cmd->index, cmd->trace_id, ret); - if (++cmd_count == cur_total_count) { + PS3_HOST(instance), cmd->index, cmd->trace_id, + ret); + if (++cmd_count == cur_total_count) break; - } if (++try_count == PS3_R1X_RESEND_COUNT) { cond_resched(); @@ -471,8 +495,8 @@ static S32 ps3_conflict_queue_send_wk(void *data) PS3_BUG(); } ps3_conflict_queue_clean_bitmap( - (struct ps3_r1x_hash_bit_mgr*) - mgr->hash_mgr_conflict); + (struct ps3_r1x_hash_bit_mgr *) + mgr->hash_mgr_conflict); } ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); INJECT_START(PS3_ERR_IJ_R1X_CONFLICTQ_PROCESS_FINISH, instance); @@ -480,146 +504,167 @@ static S32 ps3_conflict_queue_send_wk(void *data) l_out: LOG_FILE_INFO("hno:%u vd[%u:%u] conflict queue thread exit\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); return 0; } -static inline void ps3_r1x_bitmap_set(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, - U16 bitmap_idx, U32 bit_start, U32 bit_cnt) +static inline void ps3_r1x_bitmap_set(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, + unsigned short bitmap_idx, + unsigned int bit_start, + unsigned int bit_cnt) { - U32 i = 0; - ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for(; i < bit_cnt; ++i){ - setBitNonAtomic(bit_start+i, addr); - } + unsigned int i = 0; + unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( + pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for (; i < bit_cnt; ++i) + setBitNonAtomic(bit_start + i, addr); } -static inline void ps3_r1x_bitmap_clean(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, - U16 bitmap_idx, U32 bit_start, U32 bit_cnt) +static inline void +ps3_r1x_bitmap_clean(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, + unsigned short bitmap_idx, unsigned int bit_start, + unsigned int bit_cnt) { - U32 i = 0; - ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for(; i < bit_cnt; ++i){ - clearBitNonAtomic(bit_start+i, addr); - } + unsigned int i = 0; + unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( + pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for (; i < bit_cnt; ++i) + clearBitNonAtomic(bit_start + i, addr); } -static inline S32 ps3_r1x_bitmap_check(struct ps3_r1x_hash_bit_mgr* pHashbitMgr, - U16 bitmap_idx, U32 bit_start, U32 bit_cnt) +static inline int ps3_r1x_bitmap_check(struct ps3_r1x_hash_bit_mgr *pHashbitMgr, + unsigned short bitmap_idx, + unsigned int bit_start, + unsigned int bit_cnt) { - U32 i = 0; - ULong* addr = (ULong*)(void*)&RW_R1X_GET_BITMAP(pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); - for(; i < bit_cnt; ++i){ - if(unlikely(testBitNonAtomic(bit_start+i, addr))){ - return -PS3_R1X_IO_CONFLICT; - } - } - return PS3_SUCCESS; + unsigned int i = 0; + unsigned long *addr = (unsigned long *)(void *)&RW_R1X_GET_BITMAP( + pHashbitMgr->bitmap_mgr.bit_buff, bitmap_idx); + for (; i < bit_cnt; ++i) { + if (unlikely(testBitNonAtomic(bit_start + i, addr))) + return -PS3_R1X_IO_CONFLICT; + } + return PS3_SUCCESS; } -static inline U32 calc_block_num(U64 lba, U32 len, U32 block_shift, U32 block_mask) +static inline unsigned int calc_block_num(unsigned long long lba, + unsigned int len, + unsigned int block_shift, + unsigned int block_mask) { - U64 start_align = lba; - U32 block_num = 0; - U32 remain_len = 0; - - if (lba & block_mask) { - block_num += 1; - start_align = ((lba >> block_shift) + 1) << block_shift; - } - - if(start_align < lba + len){ - remain_len = len - ((U32)(start_align - lba)); - block_num += remain_len >> block_shift; - if(remain_len & block_mask){ - block_num += 1; - } - } - - return block_num; + unsigned long long start_align = lba; + unsigned int block_num = 0; + unsigned int remain_len = 0; + + if (lba & block_mask) { + block_num += 1; + start_align = ((lba >> block_shift) + 1) << block_shift; + } + + if (start_align < lba + len) { + remain_len = len - ((unsigned int)(start_align - lba)); + block_num += remain_len >> block_shift; + if (remain_len & block_mask) + block_num += 1; + } + + return block_num; } -struct ps3_write_r1x_hash_tmp{ - struct ps3_r1x_hash_bit_item* hash_item; - U32 bit_start; - U32 bit_cnt; - Bool is_new; - U8 resv[7]; +struct ps3_write_r1x_hash_tmp { + struct ps3_r1x_hash_bit_item *hash_item; + unsigned int bit_start; + unsigned int bit_cnt; + unsigned char is_new; + unsigned char resv[7]; }; -S32 ps3_r1x_hash_bit_check(struct ps3_r1x_hash_bit_mgr* hash_mgr, - U64 lba, U32 len, - struct ps3_write_r1x_hash_tmp* hash_tmp, U16 hash_idx) +static int ps3_r1x_hash_bit_check(struct ps3_r1x_hash_bit_mgr *hash_mgr, + unsigned long long lba, unsigned int len, + struct ps3_write_r1x_hash_tmp *hash_tmp, + unsigned short hash_idx) { - U64 sz_block_idx = 0; - U32 offset = 0; - struct ps3_r1x_hash_bit_item* hash_item = NULL; - S32 ret = PS3_SUCCESS; - U32 bit_start = 0; - U32 bit_cnt = 0; - - hash_item = &hash_mgr->hash_item[hash_idx]; - sz_block_idx = RW_R1X_SZBLOCKIDX(lba); - offset = (U32)(lba & SZBLOCK_SIZE_MASK); - bit_start = offset >> LOCK_BLOCK_SIZE_SHIFT; - bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); - hash_tmp->hash_item = hash_item; - hash_tmp->is_new = PS3_FALSE; - hash_tmp->bit_start = bit_start; - hash_tmp->bit_cnt = bit_cnt; - - PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, hash item=%p, bit check.", - lba, len, hash_idx, hash_item); - if(hash_item->sz_block_idx == RW_SZBLOCK_IDX_INVALUD) { - hash_item->sz_block_idx = sz_block_idx; - hash_tmp->is_new = PS3_TRUE; - PS3_R1X_LOCK_TRACE("lba=%llu, len=%u, hash_idx=%u, bit_idx=%u, hash item=%p, new hash item.", - lba, len, hash_idx, (U16)hash_item->bitmap_idx, hash_item); - } else { - if(hash_item->sz_block_idx == sz_block_idx) { - ret = ps3_r1x_bitmap_check(hash_mgr,(U16)hash_item->bitmap_idx, bit_start, bit_cnt); - } else { - PS3_R1X_LOCK_TRACE("hash item=%p, oldSzBlock=%llu, newSzBlock=%llu, hash conflict.", - hash_item, (U64)hash_item->sz_block_idx, sz_block_idx); - ret = -PS3_R1X_HASH_CONFILICT; - } - } - - return ret; + unsigned long long sz_block_idx = 0; + unsigned int offset = 0; + struct ps3_r1x_hash_bit_item *hash_item = NULL; + int ret = PS3_SUCCESS; + unsigned int bit_start = 0; + unsigned int bit_cnt = 0; + + hash_item = &hash_mgr->hash_item[hash_idx]; + sz_block_idx = RW_R1X_SZBLOCKIDX(lba); + offset = (unsigned int)(lba & SZBLOCK_SIZE_MASK); + bit_start = offset >> LOCK_BLOCK_SIZE_SHIFT; + bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, + LOCK_BLOCK_SIZE_MASK); + hash_tmp->hash_item = hash_item; + hash_tmp->is_new = PS3_FALSE; + hash_tmp->bit_start = bit_start; + hash_tmp->bit_cnt = bit_cnt; + + PS3_R1X_LOCK_TRACE( + "lba=%llu, len=%u, hash_idx=%u, hash item=%p, bit check.", lba, + len, hash_idx, hash_item); + if (hash_item->sz_block_idx == RW_SZBLOCK_IDX_INVALID) { + hash_item->sz_block_idx = sz_block_idx; + hash_tmp->is_new = PS3_TRUE; + PS3_R1X_LOCK_TRACE( + "lba=%llu, len=%u, hash_idx=%u, bit_idx=%u, hash item=%p, new hash item.", + lba, len, hash_idx, + (unsigned short)hash_item->bitmap_idx, hash_item); + } else { + if (hash_item->sz_block_idx == sz_block_idx) { + ret = ps3_r1x_bitmap_check( + hash_mgr, (unsigned short)hash_item->bitmap_idx, + bit_start, bit_cnt); + } else { + PS3_R1X_LOCK_TRACE( + "hash item=%p, oldSzBlock=%llu, newSzBlock=%llu, hash conflict.", + hash_item, + (unsigned long long)hash_item->sz_block_idx, + sz_block_idx); + ret = -PS3_R1X_HASH_CONFILICT; + } + } + + return ret; } -static Bool ps3_r1x_hash_bit_check_conflict_queue( - struct ps3_r1x_lock_mgr *mgr, U64 lba, U32 len, U32 left) +static unsigned char +ps3_r1x_hash_bit_check_conflict_queue(struct ps3_r1x_lock_mgr *mgr, + unsigned long long lba, unsigned int len, + unsigned int left) { - Bool is_conflict = PS3_TRUE; - S32 ret = PS3_SUCCESS; - U32 i = 0; - U8 item_cnt = 0; + unsigned char is_conflict = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned int i = 0; + unsigned char item_cnt = 0; - struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; + struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; - struct ps3_r1x_hash_bit_mgr* hash_mgr = - (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; + struct ps3_r1x_hash_bit_mgr *hash_mgr = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; - LOG_DEBUG("lba=%llu, len=%u, left=%u, " - "check if conflict with conflict queue.\n", - lba, len, left); + LOG_DEBUG("lba=%llu, len=%u, left=%u,\n" + "\tcheck if conflict with conflict queue.\n", + lba, len, left); - do{ + do { len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if(PS3_SUCCESS != ret) { + if (ret != PS3_SUCCESS) { is_conflict = PS3_TRUE; goto exit_fail; } left -= len; lba += len; len = SZBLOCK_SIZE; - }while(left > 0); + } while (left > 0); is_conflict = PS3_FALSE; @@ -629,89 +674,93 @@ static Bool ps3_r1x_hash_bit_check_conflict_queue( hash_tmp = &tmp_array[i]; if (hash_tmp->is_new) { hash_tmp->hash_item->sz_block_idx = - RW_SZBLOCK_IDX_INVALUD; + RW_SZBLOCK_IDX_INVALID; } } return is_conflict; } -void ps3_r1x_conflict_queue_hash_bit_lock( - struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static void ps3_r1x_conflict_queue_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - U32 i = 0; - U8 item_cnt = 0; - U32 shift = 0; - U64 lba = 0; - U32 len = 0; - U32 left = 0; - - struct ps3_r1x_hash_bit_mgr* hash_mgr_conflict = - (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; - struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; + unsigned int i = 0; + unsigned char item_cnt = 0; + unsigned int shift = 0; + unsigned long long lba = 0; + unsigned int len = 0; + unsigned int left = 0; + + struct ps3_r1x_hash_bit_mgr *hash_mgr_conflict = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; + struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : SECTOR_512_4K_SHIFT; + 0 : + SECTOR_512_4K_SHIFT; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; left = cmd->io_attr.num_blocks << shift; len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do{ + do { len = PS3_MIN(len, left); hash_tmp = &tmp_array[item_cnt]; - hash_tmp->hash_item = &hash_mgr_conflict->hash_item[ - RW_R1X_HASHIDX(lba)]; + hash_tmp->hash_item = + &hash_mgr_conflict->hash_item[RW_R1X_HASHIDX(lba)]; hash_tmp->hash_item->sz_block_idx = RW_R1X_SZBLOCKIDX(lba); hash_tmp->is_new = PS3_TRUE; - hash_tmp->bit_start = ((U32)(lba & SZBLOCK_SIZE_MASK)) >> + hash_tmp->bit_start = + ((unsigned int)(lba & SZBLOCK_SIZE_MASK)) >> LOCK_BLOCK_SIZE_SHIFT; - hash_tmp->bit_cnt = calc_block_num(lba, len, - LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); + hash_tmp->bit_cnt = calc_block_num( + lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); item_cnt += 1; left -= len; lba += len; len = SZBLOCK_SIZE; - } while(left > 0); + } while (left > 0); - for(i = 0; i < item_cnt; ++i){ + for (i = 0; i < item_cnt; ++i) { hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set(hash_mgr_conflict, - (U16)hash_tmp->hash_item->bitmap_idx, + ps3_r1x_bitmap_set( + hash_mgr_conflict, + (unsigned short)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, hash_tmp->bit_cnt); } - return; } -S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static int ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U32 i = 0; - U8 item_cnt = 0; - U8 item_cnt_conflict = 0; - U32 shift = 0; - U64 lba = 0; - U32 len = 0; - U32 left = 0; - struct ps3_r1x_hash_bit_mgr* hash_mgr = - (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; - struct ps3_r1x_hash_bit_mgr* hash_mgr_conflict = - (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr_conflict; - struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; + int ret = PS3_SUCCESS; + unsigned int i = 0; + unsigned char item_cnt = 0; + unsigned char item_cnt_conflict = 0; + unsigned int shift = 0; + unsigned long long lba = 0; + unsigned int len = 0; + unsigned int left = 0; + struct ps3_r1x_hash_bit_mgr *hash_mgr = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; + struct ps3_r1x_hash_bit_mgr *hash_mgr_conflict = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr_conflict; + struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; struct ps3_write_r1x_hash_tmp tmp_array_conflict[SZ_BLOCK_SPLIT_MAX]; - ULong flag = 0; - Bool is_conflict_q_empty = PS3_FALSE; + unsigned long flag = 0; + unsigned char is_conflict_q_empty = PS3_FALSE; - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? - 0 : SECTOR_512_4K_SHIFT; + 0 : + SECTOR_512_4K_SHIFT; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; len = cmd->io_attr.num_blocks << shift; left = len; @@ -729,56 +778,55 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); if (is_conflict_q_empty) { - do{ + do { PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if(PS3_SUCCESS != ret) { + if (ret != PS3_SUCCESS) goto exit_fail; - } left -= len; lba += len; len = SZBLOCK_SIZE; - } while(left > 0); + } while (left > 0); } else { - do{ + do { PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], - RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if(PS3_SUCCESS != ret) { + if (ret != PS3_SUCCESS) goto exit_fail; - } - ret = ps3_r1x_hash_bit_check(hash_mgr_conflict, lba, len, + ret = ps3_r1x_hash_bit_check( + hash_mgr_conflict, lba, len, &tmp_array_conflict[item_cnt_conflict], RW_R1X_HASHIDX(lba)); item_cnt_conflict += 1; - if(PS3_SUCCESS != ret) { + if (ret != PS3_SUCCESS) goto exit_fail; - } left -= len; lba += len; len = SZBLOCK_SIZE; - } while(left > 0); + } while (left > 0); - for(i = 0; i < item_cnt_conflict; ++i){ + for (i = 0; i < item_cnt_conflict; ++i) { hash_tmp = &tmp_array_conflict[i]; - if(PS3_TRUE == hash_tmp->is_new){ + if (hash_tmp->is_new == PS3_TRUE) { hash_tmp->hash_item->sz_block_idx = - RW_SZBLOCK_IDX_INVALUD; + RW_SZBLOCK_IDX_INVALID; } } } - for(i = 0; i < item_cnt; ++i){ + for (i = 0; i < item_cnt; ++i) { hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set(hash_mgr, - (U16)hash_tmp->hash_item->bitmap_idx, + ps3_r1x_bitmap_set( + hash_mgr, + (unsigned short)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, hash_tmp->bit_cnt); } @@ -787,7 +835,8 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) cmd->szblock_cnt = item_cnt; cmd->is_got_r1x = 1; - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); @@ -795,26 +844,27 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) goto l_out; exit_fail: - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock faild, ret=%d" - "(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock failed, ret=%d\n" + "\t(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, ret, -PS3_R1X_IO_CONFLICT, - -PS3_R1X_HASH_CONFILICT,-PS3_R1X_BIT_NOT_ENOUGH); + -PS3_R1X_HASH_CONFILICT, -PS3_R1X_BIT_NOT_ENOUGH); cmd->szblock_cnt = 0; - for(i = 0; i < item_cnt; ++i){ + for (i = 0; i < item_cnt; ++i) { hash_tmp = &tmp_array[i]; - if(PS3_TRUE == hash_tmp->is_new){ + if (hash_tmp->is_new == PS3_TRUE) { hash_tmp->hash_item->sz_block_idx = - RW_SZBLOCK_IDX_INVALUD; + RW_SZBLOCK_IDX_INVALID; } } - for(i = 0; i < item_cnt_conflict; ++i){ + for (i = 0; i < item_cnt_conflict; ++i) { hash_tmp = &tmp_array_conflict[i]; - if(PS3_TRUE == hash_tmp->is_new){ + if (hash_tmp->is_new == PS3_TRUE) { hash_tmp->hash_item->sz_block_idx = - RW_SZBLOCK_IDX_INVALUD; + RW_SZBLOCK_IDX_INVALID; } } @@ -828,11 +878,10 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ret = -PS3_IO_CONFLICT_IN_Q; } else { - if (is_conflict_q_empty) { + if (is_conflict_q_empty) ret = -PS3_IO_REQUEUE; - } else { + else ret = -PS3_IO_CONFLICT; - } } } else { ret = -PS3_IO_CONFLICT; @@ -840,8 +889,9 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock faild, fanal ret=%d" - "(%d: conflict requeue, %d: conflict in queue, %d: conflict busy).\n", + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock failed, fanal ret=%d\n" + "\t(%d: conflict requeue, %d: conflict in queue, %d: conflict busy).\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, ret, -PS3_IO_REQUEUE, -PS3_IO_CONFLICT_IN_Q, -PS3_IO_CONFLICT); @@ -850,51 +900,59 @@ S32 ps3_r1x_hash_bit_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) return ret; } -static S32 ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, - struct ps3_cmd *cmd) +static int ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U32 i = 0; - U8 item_cnt = 0; - U32 shift = 0; - U64 lba = 0; - U32 len = 0; - U32 left = 0; - struct ps3_r1x_hash_bit_mgr* hash_mgr = (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; - struct ps3_write_r1x_hash_tmp* hash_tmp = NULL; + int ret = PS3_SUCCESS; + unsigned int i = 0; + unsigned char item_cnt = 0; + unsigned int shift = 0; + unsigned long long lba = 0; + unsigned int len = 0; + unsigned int left = 0; + struct ps3_r1x_hash_bit_mgr *hash_mgr = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; + struct ps3_write_r1x_hash_tmp *hash_tmp = NULL; struct ps3_write_r1x_hash_tmp tmp_array[SZ_BLOCK_SPLIT_MAX]; - ULong flag = 0; + unsigned long flag = 0; - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, try lock.\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks, cmd); - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT;; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift;; + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? + 0 : + SECTOR_512_4K_SHIFT; + ; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; + ; len = cmd->io_attr.num_blocks << shift; left = len; ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do{ + do { PS3_BUG_ON(item_cnt >= SZ_BLOCK_SPLIT_MAX); len = PS3_MIN(len, left); ret = ps3_r1x_hash_bit_check(hash_mgr, lba, len, - &tmp_array[item_cnt], RW_R1X_HASHIDX(lba)); + &tmp_array[item_cnt], + RW_R1X_HASHIDX(lba)); item_cnt += 1; - if(PS3_SUCCESS != ret) { + if (ret != PS3_SUCCESS) goto exit_fail; - } left -= len; lba += len; len = SZBLOCK_SIZE; - }while(left > 0); + } while (left > 0); - for(i = 0; i < item_cnt; ++i){ + for (i = 0; i < item_cnt; ++i) { hash_tmp = &tmp_array[i]; - ps3_r1x_bitmap_set(hash_mgr, - (U16)hash_tmp->hash_item->bitmap_idx, hash_tmp->bit_start, - hash_tmp->bit_cnt); + ps3_r1x_bitmap_set( + hash_mgr, + (unsigned short)hash_tmp->hash_item->bitmap_idx, + hash_tmp->bit_start, hash_tmp->bit_cnt); } ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); @@ -902,7 +960,8 @@ static S32 ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, cmd->szblock_cnt = item_cnt; cmd->is_got_r1x = 1; - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.\n", cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); @@ -910,11 +969,11 @@ static S32 ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, exit_fail: - for(i = 0; i < item_cnt; ++i){ + for (i = 0; i < item_cnt; ++i) { hash_tmp = &tmp_array[i]; - if(PS3_TRUE == hash_tmp->is_new){ + if (hash_tmp->is_new == PS3_TRUE) { hash_tmp->hash_item->sz_block_idx = - RW_SZBLOCK_IDX_INVALUD; + RW_SZBLOCK_IDX_INVALID; } } @@ -923,79 +982,91 @@ static S32 ps3_r1x_hash_bit_lock_of_conflict_queue(struct ps3_r1x_lock_mgr *mgr, cmd->szblock_cnt = 0; ret = -PS3_IO_CONFLICT_IN_Q; - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, relock faild, ret=%d" - "(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks,ret, - -PS3_R1X_IO_CONFLICT,-PS3_R1X_HASH_CONFILICT,-PS3_R1X_BIT_NOT_ENOUGH); + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, relock failed, ret=%d\n" + "\t(%d: io conflict, %d: hash conflict, %d: bitmap not enough).\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks, ret, -PS3_R1X_IO_CONFLICT, + -PS3_R1X_HASH_CONFILICT, -PS3_R1X_BIT_NOT_ENOUGH); return ret; } -void ps3_r1x_hash_bit_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static void ps3_r1x_hash_bit_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - struct ps3_r1x_hash_bit_item* hash_item = NULL; - U32 bit_start = 0; - U32 bit_cnt = 0; - U64* bit_map = NULL; - U32 i = 0; - BOOL is_clean = PS3_TRUE; - U32 shift = 0; - U64 lba = 0; - U32 len = 0; - U32 left = 0; - U64 conflict_check_lba = 0; - U32 conflict_check_len = 0; - U32 conflict_check_left = 0; - struct ps3_r1x_hash_bit_mgr* hash_mgr = (struct ps3_r1x_hash_bit_mgr*)mgr->hash_mgr; - struct ps3_r1x_bit_block_mgr* bit_map_mgr = &hash_mgr->bitmap_mgr; - ULong flag = 0; - U8 ret_check = PS3_CONFLICT_QUEUE_EMPTY; - - PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, unlock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, cmd); - - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; - left = cmd->io_attr.num_blocks << shift; - len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); + struct ps3_r1x_hash_bit_item *hash_item = NULL; + unsigned int bit_start = 0; + unsigned int bit_cnt = 0; + unsigned long long *bit_map = NULL; + unsigned int i = 0; + int is_clean = PS3_TRUE; + unsigned int shift = 0; + unsigned long long lba = 0; + unsigned int len = 0; + unsigned int left = 0; + unsigned long long conflict_check_lba = 0; + unsigned int conflict_check_len = 0; + unsigned int conflict_check_left = 0; + struct ps3_r1x_hash_bit_mgr *hash_mgr = + (struct ps3_r1x_hash_bit_mgr *)mgr->hash_mgr; + struct ps3_r1x_bit_block_mgr *bit_map_mgr = &hash_mgr->bitmap_mgr; + unsigned long flag = 0; + unsigned char ret_check = PS3_CONFLICT_QUEUE_EMPTY; + + PS3_R1X_LOCK_TRACE( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, cmd=%p, unlock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks, cmd); + + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? + 0 : + SECTOR_512_4K_SHIFT; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; + left = cmd->io_attr.num_blocks << shift; + len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); conflict_check_lba = lba; conflict_check_len = len; conflict_check_left = left; - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); - do{ - hash_item = &hash_mgr->hash_item[RW_R1X_HASHIDX(lba)]; - len = PS3_MIN(len, left); - bit_start = (lba & SZBLOCK_SIZE_MASK) >> LOCK_BLOCK_SIZE_SHIFT; - bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, LOCK_BLOCK_SIZE_MASK); - ps3_r1x_bitmap_clean(hash_mgr, (U16)hash_item->bitmap_idx, bit_start, bit_cnt); - - is_clean = PS3_TRUE; - bit_map = (U64*)(void*)&RW_R1X_GET_BITMAP(bit_map_mgr->bit_buff, hash_item->bitmap_idx); - for(i = 0; i < bit_map_mgr->bit_block_size; ++i){ - if(bit_map[i] != 0){ - is_clean = PS3_FALSE; - } - } - - if(PS3_TRUE == is_clean){ - PS3_R1X_LOCK_TRACE("t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu," - "szblock_cnt=%u, cmd=%p, release hash item.", - cmd->trace_id, lba, len, (U64)hash_item->sz_block_idx, - (unsigned long int)hash_item->bitmap_idx, - cmd->szblock_cnt, cmd); - hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALUD; - } - - left -= len; - lba += len; - len = SZBLOCK_SIZE; - }while(left > 0); + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + do { + hash_item = &hash_mgr->hash_item[RW_R1X_HASHIDX(lba)]; + len = PS3_MIN(len, left); + bit_start = (lba & SZBLOCK_SIZE_MASK) >> LOCK_BLOCK_SIZE_SHIFT; + bit_cnt = calc_block_num(lba, len, LOCK_BLOCK_SIZE_SHIFT, + LOCK_BLOCK_SIZE_MASK); + ps3_r1x_bitmap_clean(hash_mgr, + (unsigned short)hash_item->bitmap_idx, + bit_start, bit_cnt); + + is_clean = PS3_TRUE; + bit_map = (unsigned long long *)(void *)&RW_R1X_GET_BITMAP( + bit_map_mgr->bit_buff, hash_item->bitmap_idx); + for (i = 0; i < bit_map_mgr->bit_block_size; ++i) { + if (bit_map[i] != 0) + is_clean = PS3_FALSE; + } + + if (is_clean == PS3_TRUE) { + PS3_R1X_LOCK_TRACE( + "t_id:0x%llx lba=%llu, len=%u, szBlockIdx=%llu, bitIdx=%lu,\n" + "\tszblock_cnt=%u, cmd=%p, release hash item.", + cmd->trace_id, lba, len, + (unsigned long long)hash_item->sz_block_idx, + (unsigned long)hash_item->bitmap_idx, + cmd->szblock_cnt, cmd); + hash_item->sz_block_idx = RW_SZBLOCK_IDX_INVALID; + } + + left -= len; + lba += len; + len = SZBLOCK_SIZE; + } while (left > 0); if (!list_empty(&mgr->conflict_cmd_list)) { - if (ps3_r1x_hash_bit_check_conflict_queue(mgr, - conflict_check_lba, conflict_check_len, - conflict_check_left)) { + if (ps3_r1x_hash_bit_check_conflict_queue( + mgr, conflict_check_lba, conflict_check_len, + conflict_check_left)) { ret_check = PS3_CONFLICT_QUEUE_CONFLICT; } else { ret_check = PS3_CONFLICT_QUEUE_NO_CONFLICT; @@ -1005,387 +1076,427 @@ void ps3_r1x_hash_bit_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); if (ret_check != PS3_CONFLICT_QUEUE_EMPTY) { - LOG_FILE_INFO("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u," - " conflict queue check ret:%d.\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, - cmd->io_attr.num_blocks, ret_check); + LOG_FILE_INFO("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u,\n" + "\tconflict queue check ret:%d.\n", + cmd->trace_id, cmd->io_attr.lba_hi, + cmd->io_attr.lba_lo, cmd->io_attr.num_blocks, + ret_check); - if (ret_check == PS3_CONFLICT_QUEUE_CONFLICT) { + if (ret_check == PS3_CONFLICT_QUEUE_CONFLICT) complete(&mgr->thread_sync); - } } - return; } -static void* ps3_r1x_lock_hash_bit_init(struct ps3_instance *instance) +static void *ps3_r1x_lock_hash_bit_init(struct ps3_instance *instance) { - U32 bit_map_size = 0; - U16 sz_block_bit_cnt = 0; - U16 bitmap_block_size = 0; - U16 bitmap_block_cnt = 0; - U32 total_size = 0; - struct ps3_r1x_hash_bit_mgr* mgr = NULL; - U8* buff = NULL; - U32 i = 0; - (void)instance; - (void)bitmap_block_cnt; + unsigned int bit_map_size = 0; + unsigned short sz_block_bit_cnt = 0; + unsigned short bitmap_block_size = 0; + unsigned short bitmap_block_cnt = 0; + unsigned int total_size = 0; + struct ps3_r1x_hash_bit_mgr *mgr = NULL; + unsigned char *buff = NULL; + unsigned int i = 0; + (void)instance; + (void)bitmap_block_cnt; if (SZBLOCK_SIZE & LOCK_BLOCK_SIZE_MASK) { - LOG_FILE_ERROR("hno: %u, SZBLOCK_SIZE check NOK\n", PS3_HOST(instance)); + LOG_FILE_ERROR("hno: %u, SZBLOCK_SIZE check NOK\n", + PS3_HOST(instance)); goto exit; } - bit_map_size = PS3_R1X_BIT_MAP_SIZE; - sz_block_bit_cnt = SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT; + bit_map_size = PS3_R1X_BIT_MAP_SIZE; + sz_block_bit_cnt = SZBLOCK_SIZE >> LOCK_BLOCK_SIZE_SHIFT; if (sz_block_bit_cnt & RW_BIT_64_MASK) { - LOG_FILE_ERROR("hno: %u, sz_block_bit_cnt check NOK\n", PS3_HOST(instance)); + LOG_FILE_ERROR("hno: %u, sz_block_bit_cnt check NOK\n", + PS3_HOST(instance)); + goto exit; + } + total_size = sizeof(struct ps3_r1x_hash_bit_mgr) + bit_map_size; + buff = (unsigned char *)(void *)ps3_vzalloc(instance, total_size); + if (buff == NULL) { + PS3_R1X_LOCK_ERROR( + "r1x vd alloc write lock mgr failed. totoalSize=%u", + total_size); goto exit; } - total_size = sizeof(struct ps3_r1x_hash_bit_mgr) + bit_map_size; - buff = (U8*)(void*)ps3_vzalloc(instance, total_size); - if(NULL == buff) { - PS3_R1X_LOCK_ERROR("r1x vd alloc write lock mgr faild. totoalSize=%u", total_size); - goto exit; - } - - bitmap_block_size = RW_BIT_TO_BYTE(sz_block_bit_cnt); - mgr = (struct ps3_r1x_hash_bit_mgr*)(void*)buff; - for (i = 0; i < HASH_TABLE_SIZE; ++i) { - mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALUD; - if (RW_BITMAP_IDX_INVALUD < (i * bitmap_block_size)) { - LOG_ERROR("hno: %u, bitmap_block_size check NOK\n", PS3_HOST(instance)); + + bitmap_block_size = RW_BIT_TO_BYTE(sz_block_bit_cnt); + mgr = (struct ps3_r1x_hash_bit_mgr *)(void *)buff; + for (i = 0; i < HASH_TABLE_SIZE; ++i) { + mgr->hash_item[i].sz_block_idx = RW_SZBLOCK_IDX_INVALID; + if (RW_BITMAP_IDX_INVALID < (i * bitmap_block_size)) { + LOG_ERROR("hno: %u, bitmap_block_size check NOK\n", + PS3_HOST(instance)); PS3_BUG(); ps3_vfree(instance, buff); mgr = NULL; goto exit; } - mgr->hash_item[i].bitmap_idx = i*bitmap_block_size; - } - mgr->bitmap_mgr.bit_block_size = (U8)RW_BYTE_TO_U64(bitmap_block_size); - buff += sizeof(struct ps3_r1x_hash_bit_mgr); - mgr->bitmap_mgr.bit_buff = (U8*)(void*)buff; - buff += bit_map_size; - - LOG_FILE_INFO("r1x vd init write lock mgr success,totoalSize=%u, hashTableSize=%u, " - "bitmapSize=%u(bytes), bitmap_block_cnt=%u, bitmap_block_size=%u.\n", - total_size, HASH_TABLE_SIZE, - bit_map_size, bitmap_block_cnt, bitmap_block_size); + mgr->hash_item[i].bitmap_idx = i * bitmap_block_size; + } + mgr->bitmap_mgr.bit_block_size = + (unsigned char)RW_BYTE_TO_U64(bitmap_block_size); + buff += sizeof(struct ps3_r1x_hash_bit_mgr); + mgr->bitmap_mgr.bit_buff = (unsigned char *)(void *)buff; + buff += bit_map_size; + + LOG_FILE_INFO( + "r1x vd init write lock mgr success,totoalSize=%u, hashTableSize=%u,\n" + "\tbitmapSize=%u(bytes), bitmap_block_cnt=%u, bitmap_block_size=%u.\n", + total_size, HASH_TABLE_SIZE, bit_map_size, bitmap_block_cnt, + bitmap_block_size); exit: - return mgr; + return mgr; } #endif #if PS3_DESC("-----------------------hash range互斥方案------------------------") -struct ps3_renge_extent -{ - U64 start; - U64 end; +struct ps3_renge_extent { + unsigned long long start; + unsigned long long end; }; -struct ps3_range_tree_node -{ - Ps3RbNode_s rbNode; - struct ps3_renge_extent extent; +struct ps3_range_tree_node { + struct Ps3RbNode rbNode; + struct ps3_renge_extent extent; }; -struct ps3_range_tree_root -{ - Ps3RbRoot_s rbRoot; +struct ps3_range_tree_root { + struct Ps3RbRoot rbRoot; }; -struct ps3_r1x_hash_range_mgr -{ - struct ps3_range_tree_root hash_item[HASH_TABLE_SIZE]; +struct ps3_r1x_hash_range_mgr { + struct ps3_range_tree_root hash_item[HASH_TABLE_SIZE]; }; -#define RANGETEE_EXTENT(rbNodePtr) ((ps3_container_of(rbNodePtr, struct ps3_range_tree_node, rbNode))->extent) +#define RANGETEE_EXTENT(rbNodePtr) \ + ((ps3_container_of(rbNodePtr, struct ps3_range_tree_node, rbNode)) \ + ->extent) -S32 ps3_range_check_and_insert(struct ps3_range_tree_root *range_root, struct ps3_range_tree_node* range_node) +static int ps3_range_check_and_insert(struct ps3_range_tree_root *range_root, + struct ps3_range_tree_node *range_node) { - S32 ret = PS3_SUCCESS; - Ps3RbNode_s *node = &range_node->rbNode; - Ps3RbNode_s *parent = NULL; - Ps3RbNode_s **pp_linker = NULL; - struct ps3_renge_extent* ext = &range_node->extent; - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, check.", range_root->rbRoot.pRoot, - node, ext->start, ext->end); - - pp_linker = &range_root->rbRoot.pRoot; - while (*pp_linker != NULL){ - parent = *pp_linker; - if (ext->start > RANGETEE_EXTENT(parent).end) { - pp_linker = &parent->pRight; - } else if (ext->end < RANGETEE_EXTENT(parent).start) { - pp_linker = &parent->pLeft; - } else { - ret = -PS3_R1X_IO_CONFLICT; - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, confilct.", range_root->rbRoot.pRoot, - node, ext->start, ext->end); - goto exit; - } - } - - node->pParentColor = ((uintptr_t)(void*)parent); - node->pLeft = NULL; - node->pRight = NULL; - (*pp_linker) = node; - ps3RbtColorAfterAdd(&range_root->rbRoot, node); - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, add.", range_root->rbRoot.pRoot, - node, ext->start, ext->end); + int ret = PS3_SUCCESS; + struct Ps3RbNode *node = &range_node->rbNode; + struct Ps3RbNode *parent = NULL; + struct Ps3RbNode **pp_linker = NULL; + struct ps3_renge_extent *ext = &range_node->extent; + + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, check.", + range_root->rbRoot.pRoot, node, ext->start, + ext->end); + + pp_linker = &range_root->rbRoot.pRoot; + while (*pp_linker != NULL) { + parent = *pp_linker; + if (ext->start > RANGETEE_EXTENT(parent).end) { + pp_linker = &parent->pRight; + } else if (ext->end < RANGETEE_EXTENT(parent).start) { + pp_linker = &parent->pLeft; + } else { + ret = -PS3_R1X_IO_CONFLICT; + PS3_R1X_LOCK_TRACE( + "root=%p, rbNode=%p, lba=%llu, endLba=%llu, confilct.", + range_root->rbRoot.pRoot, node, ext->start, + ext->end); + goto exit; + } + } + + node->pParentColor = ((uintptr_t)(void *)parent); + node->pLeft = NULL; + node->pRight = NULL; + (*pp_linker) = node; + ps3RbtColorAfterAdd(&range_root->rbRoot, node); + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, add.", + range_root->rbRoot.pRoot, node, ext->start, + ext->end); exit: - return ret; + return ret; } -static inline void ps3_range_del_node(struct ps3_range_tree_root *range_root, struct ps3_range_tree_node* del_node) +static inline void ps3_range_del_node(struct ps3_range_tree_root *range_root, + struct ps3_range_tree_node *del_node) { - PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, del.", range_root->rbRoot.pRoot, - &del_node->rbNode, del_node->extent.start, del_node->extent.end); - if(unlikely(PS3_SUCCESS != ps3RbtDelNode(&range_root->rbRoot, &del_node->rbNode))){ - LOG_FILE_ERROR("startLba=%llu, endLba=%llu, del range node failed.\n", - del_node->extent.start, del_node->extent.end); - PS3_BUG(); - } + PS3_R1X_LOCK_TRACE("root=%p, rbNode=%p, lba=%llu, endLba=%llu, del.", + range_root->rbRoot.pRoot, &del_node->rbNode, + del_node->extent.start, del_node->extent.end); + if (unlikely(PS3_SUCCESS != + ps3RbtDelNode(&range_root->rbRoot, &del_node->rbNode))) { + LOG_FILE_ERROR( + "startLba=%llu, endLba=%llu, del range node failed.\n", + del_node->extent.start, del_node->extent.end); + PS3_BUG(); + } } -S32 ps3_r1x_hash_range_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static int ps3_r1x_hash_range_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U64 hash_idx = 0; - U8 node_num = 0; - U32 shift = 0; - U64 lba = 0; - U32 len = 0; - U32 left = 0; - struct ps3_r1x_hash_range_mgr* hash_range_mgr = (struct ps3_r1x_hash_range_mgr*)mgr->hash_mgr; - struct ps3_range_tree_node* range_node = (struct ps3_range_tree_node*)cmd->node_buff; - struct ps3_range_tree_node* del_node = NULL; - ULong flag = 0; - - PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, try lock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); - - shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? 0 : SECTOR_512_4K_SHIFT;; - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift;; - len = cmd->io_attr.num_blocks << shift; - left = len; - - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); - - len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); - do{ - range_node = &((struct ps3_range_tree_node*)cmd->node_buff)[node_num]; - len = PS3_MIN(len, left); - range_node->extent.start = lba; - range_node->extent.end = lba + len - 1; - ps3RbNodeInit(&range_node->rbNode); - hash_idx = RW_R1X_HASHIDX_HASH(mgr, lba); - - ret = ps3_range_check_and_insert(&hash_range_mgr->hash_item[hash_idx], range_node); - if(unlikely(PS3_SUCCESS != ret)){ - goto exit_fail; - } - - left -= len; - lba += len; - len = SZBLOCK_SIZE; - node_num++; - }while(left > 0); - - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - - cmd->szblock_cnt = node_num; - cmd->is_got_r1x = 1; - - PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); - return ret; + int ret = PS3_SUCCESS; + unsigned long long hash_idx = 0; + unsigned char node_num = 0; + unsigned int shift = 0; + unsigned long long lba = 0; + unsigned int len = 0; + unsigned int left = 0; + struct ps3_r1x_hash_range_mgr *hash_range_mgr = + (struct ps3_r1x_hash_range_mgr *)mgr->hash_mgr; + struct ps3_range_tree_node *range_node = + (struct ps3_range_tree_node *)cmd->node_buff; + struct ps3_range_tree_node *del_node = NULL; + unsigned long flag = 0; + + PS3_R1X_LOCK_TRACE( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, try lock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks); + + shift = cmd->io_attr.vd_entry->sectorSize != SECTOR_SIZE_4K ? + 0 : + SECTOR_512_4K_SHIFT; + ; + lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) << shift; + ; + len = cmd->io_attr.num_blocks << shift; + left = len; + + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + + len = SZBLOCK_SIZE - (lba & SZBLOCK_SIZE_MASK); + do { + range_node = &( + (struct ps3_range_tree_node *)cmd->node_buff)[node_num]; + len = PS3_MIN(len, left); + range_node->extent.start = lba; + range_node->extent.end = lba + len - 1; + ps3RbNodeInit(&range_node->rbNode); + hash_idx = RW_R1X_HASHIDX_HASH(mgr, lba); + + ret = ps3_range_check_and_insert( + &hash_range_mgr->hash_item[hash_idx], range_node); + if (unlikely(ret != PS3_SUCCESS)) + goto exit_fail; + + left -= len; + lba += len; + len = SZBLOCK_SIZE; + node_num++; + } while (left > 0); + + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + cmd->szblock_cnt = node_num; + cmd->is_got_r1x = 1; + + PS3_R1X_LOCK_TRACE( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, lock success.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks); + return ret; exit_fail: - cmd->szblock_cnt = 0; - del_node = (struct ps3_range_tree_node*)cmd->node_buff; - for(; del_node != range_node; del_node++){ - hash_idx = RW_R1X_HASHIDX_HASH(mgr, del_node->extent.start); - ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], del_node); - } - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - - LOG_DEBUG("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, io conflict, lock faild.\n", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); - ret = -PS3_IO_REQUEUE; - return ret; + cmd->szblock_cnt = 0; + del_node = (struct ps3_range_tree_node *)cmd->node_buff; + for (; del_node != range_node; del_node++) { + hash_idx = RW_R1X_HASHIDX_HASH(mgr, del_node->extent.start); + ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], + del_node); + } + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + + LOG_DEBUG( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, io conflict, lock failed.\n", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks); + ret = -PS3_IO_REQUEUE; + return ret; } -void ps3_r1x_hash_range_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static void ps3_r1x_hash_range_unlock(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - U32 i = 0; - U64 hash_idx = 0; - struct ps3_range_tree_node* range_node = NULL; - struct ps3_r1x_hash_range_mgr* hash_range_mgr = (struct ps3_r1x_hash_range_mgr*)mgr->hash_mgr; - ULong flag = 0; - - PS3_R1X_LOCK_TRACE("t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, unlock.", - cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); + unsigned int i = 0; + unsigned long long hash_idx = 0; + struct ps3_range_tree_node *range_node = NULL; + struct ps3_r1x_hash_range_mgr *hash_range_mgr = + (struct ps3_r1x_hash_range_mgr *)mgr->hash_mgr; + unsigned long flag = 0; + + PS3_R1X_LOCK_TRACE( + "t_id:0x%llx lba_high=%u, lba_low=%u, len=%u, unlock.", + cmd->trace_id, cmd->io_attr.lba_hi, cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks); - ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); + ps3_spin_lock_irqsave(&mgr->mgr_lock, &flag); - for(i = 0; i < cmd->szblock_cnt; ++i){ - range_node = &((struct ps3_range_tree_node*)cmd->node_buff)[i]; - hash_idx = RW_R1X_HASHIDX_HASH(mgr, range_node->extent.start); - ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], range_node); - } - ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); + for (i = 0; i < cmd->szblock_cnt; ++i) { + range_node = &((struct ps3_range_tree_node *)cmd->node_buff)[i]; + hash_idx = RW_R1X_HASHIDX_HASH(mgr, range_node->extent.start); + ps3_range_del_node(&hash_range_mgr->hash_item[hash_idx], + range_node); + } + ps3_spin_unlock_irqrestore(&mgr->mgr_lock, flag); - return; } -static void* ps3_r1x_hash_range_init(struct ps3_instance *instance) +static void *ps3_r1x_hash_range_init(struct ps3_instance *instance) { - U32 total_size = 0; - U32 i = 0; - struct ps3_r1x_hash_range_mgr* mgr = NULL; - - total_size = sizeof(struct ps3_r1x_hash_range_mgr); - mgr = (struct ps3_r1x_hash_range_mgr*)(void*)ps3_vzalloc(instance, total_size); - if(NULL == mgr) { - PS3_R1X_LOCK_ERROR("r1x vd write lock alloc hash range mgr faild. totoalSize=%u", total_size); - goto exit; - } - - for(i = 0; i < HASH_TABLE_SIZE; ++i){ - mgr->hash_item[i].rbRoot.pRoot = NULL; - } - - LOG_FILE_INFO("r1x vd write lock init hash range mgr success." - "totoalSize=%u, hashTableSize=%u\n", - total_size, HASH_TABLE_SIZE); + unsigned int total_size = 0; + unsigned int i = 0; + struct ps3_r1x_hash_range_mgr *mgr = NULL; + + total_size = sizeof(struct ps3_r1x_hash_range_mgr); + mgr = (struct ps3_r1x_hash_range_mgr *)(void *)ps3_vzalloc(instance, + total_size); + if (mgr == NULL) { + PS3_R1X_LOCK_ERROR( + "r1x vd write lock alloc hash range mgr failed. totoalSize=%u", + total_size); + goto exit; + } + + for (i = 0; i < HASH_TABLE_SIZE; ++i) + mgr->hash_item[i].rbRoot.pRoot = NULL; + + LOG_FILE_INFO("r1x vd write lock init hash range mgr success.\n" + "\ttotoalSize=%u, hashTableSize=%u\n", + total_size, HASH_TABLE_SIZE); exit: - return mgr; + return mgr; } #endif #if PS3_DESC("-----------------------对外接口------------------------") -U32 ps3_r1x_get_node_Buff_size(void) +unsigned int ps3_r1x_get_node_Buff_size(void) { - return sizeof(struct ps3_range_tree_node) * SZ_BLOCK_SPLIT_MAX; + return sizeof(struct ps3_range_tree_node) * SZ_BLOCK_SPLIT_MAX; } -typedef S32 (*PS3_R1X_LOCK_FUNC)(struct ps3_r1x_lock_mgr*, void*); -typedef void (*PS3_R1X_UNLOCK_FUNC)(struct ps3_r1x_lock_mgr*, void*); - -S32 ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, - struct scsi_device *sdev, U8 raid_level) +int ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, + struct scsi_device *sdev, + unsigned char raid_level) { - S32 ret = PS3_SUCCESS; - struct ps3_r1x_lock_mgr *mgr =&PS3_SDEV_PRI_DATA(sdev)->lock_mgr; - - mgr->hash_mgr = NULL; - mgr->try_lock = NULL; - mgr->unlock = NULL; - - if(RAID1 != raid_level && RAID1E != raid_level && RAID10 != raid_level){ - goto exit; - } - - ps3_spin_lock_init(&mgr->mgr_lock); - - if (PS3_R1X_HASHBIT_LOCK == g_ps3_r1x_lock_flag) { - mgr->hash_mgr = ps3_r1x_lock_hash_bit_init(instance); - mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_bit_lock; - mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_bit_lock_of_conflict_queue; - mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void*)ps3_r1x_hash_bit_unlock; - } else if(PS3_R1X_HASHRANGE_LOCK == g_ps3_r1x_lock_flag) { - LOG_DEBUG("hno:%u vd[%u:%u] use rb tree r1x\n", + int ret = PS3_SUCCESS; + struct ps3_r1x_lock_mgr *mgr = &PS3_SDEV_PRI_DATA(sdev)->lock_mgr; + + mgr->hash_mgr = NULL; + mgr->try_lock = NULL; + mgr->unlock = NULL; + + if (raid_level != RAID1 && raid_level != RAID1E && + raid_level != RAID10) { + goto exit; + } + + ps3_spin_lock_init(&mgr->mgr_lock); + + if (g_ps3_r1x_lock_flag == PS3_R1X_HASHBIT_LOCK) { + mgr->hash_mgr = ps3_r1x_lock_hash_bit_init(instance); + mgr->try_lock = (int (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_bit_lock; + mgr->resend_try_lock = + (int (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_bit_lock_of_conflict_queue; + mgr->unlock = (void (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_bit_unlock; + } else if (g_ps3_r1x_lock_flag == PS3_R1X_HASHRANGE_LOCK) { + LOG_DEBUG("hno:%u vd[%u:%u] use rb tree r1x\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + mgr->hash_mgr = ps3_r1x_hash_range_init(instance); + mgr->try_lock = (int (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_range_lock; + mgr->resend_try_lock = + (int (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_range_lock; + mgr->unlock = (void (*)(struct ps3_r1x_lock_mgr *, void *))( + void *)ps3_r1x_hash_range_unlock; + } + INJECT_START(PS3_ERR_IJ_FORCE_HASH_MGR_NULL, &mgr->hash_mgr); + if (unlikely(mgr->hash_mgr == NULL)) { + LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr init failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + goto l_err; + } + + mgr->hash_mgr_conflict = ps3_r1x_lock_hash_bit_init(instance); + INJECT_START(PS3_ERR_IJ_FORCE_MGR_CONFLICT_NULL, + &mgr->hash_mgr_conflict); + if (unlikely(mgr->hash_mgr_conflict == NULL)) { + LOG_ERROR( + "hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), PS3_SDEV_TARGET(sdev)); - mgr->hash_mgr = ps3_r1x_hash_range_init(instance); - mgr->try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_range_lock; - mgr->resend_try_lock = (PS3_R1X_LOCK_FUNC)(void*)ps3_r1x_hash_range_lock; - mgr->unlock = (PS3_R1X_UNLOCK_FUNC)(void*)ps3_r1x_hash_range_unlock; - } - INJECT_START(PS3_ERR_IJ_FORCE_HASH_MGR_NULL, &mgr->hash_mgr); - if (unlikely(NULL == mgr->hash_mgr)) { - LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr init failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); goto l_err; - } - - mgr->hash_mgr_conflict = ps3_r1x_lock_hash_bit_init(instance); - INJECT_START(PS3_ERR_IJ_FORCE_MGR_CONFLICT_NULL, &mgr->hash_mgr_conflict); - if (unlikely(NULL == mgr->hash_mgr_conflict)) { - LOG_ERROR("hno:%u vd[%u:%u] r1x hash mgr conflict init failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); - goto l_err; - } - - mgr->thread_stop = PS3_FALSE; - mgr->dev_deling = PS3_FALSE; - mgr->force_ret_code = SCSI_STATUS_GOOD; - - INIT_LIST_HEAD(&mgr->conflict_cmd_list); - mgr->cmd_count_in_q = 0; - init_completion(&mgr->thread_sync); - - mgr->conflict_send_th = kthread_run(ps3_conflict_queue_send_wk, sdev, "r1x_send"); + } + + mgr->thread_stop = PS3_FALSE; + mgr->dev_deling = PS3_FALSE; + mgr->force_ret_code = SCSI_STATUS_GOOD; + + INIT_LIST_HEAD(&mgr->conflict_cmd_list); + mgr->cmd_count_in_q = 0; + init_completion(&mgr->thread_sync); + + mgr->conflict_send_th = + kthread_run(ps3_conflict_queue_send_wk, sdev, "r1x_send"); INJECT_START(PS3_ERR_IJ_FORCE_SEND_TH_NULL, mgr); - if (IS_ERR(mgr->conflict_send_th)) { - LOG_ERROR("hno:%u vd[%u:%u] r1x conflict send thread creat failed\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), - PS3_SDEV_TARGET(sdev)); - goto l_err; - } - - goto exit; + if (IS_ERR(mgr->conflict_send_th)) { + LOG_ERROR( + "hno:%u vd[%u:%u] r1x conflict send thread creat failed\n", + PS3_HOST(instance), PS3_SDEV_CHANNEL(sdev), + PS3_SDEV_TARGET(sdev)); + goto l_err; + } + + goto exit; l_err: - ps3_r1x_lock_destory_for_vd(instance, mgr); - ret = -PS3_FAILED; + ps3_r1x_lock_destroy_for_vd(instance, mgr); + ret = -PS3_FAILED; exit: - return ret; + return ret; } -static S32 ps3_kthread_stop(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr) +static int ps3_kthread_stop(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; (void)instance; mgr->thread_stop = PS3_TRUE; complete(&mgr->thread_sync); - LOG_FILE_INFO("hno:%u r1x conflict destory, begin stop\n", - PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u r1x conflict destroy, begin stop\n", + PS3_HOST(instance)); ret = kthread_stop(mgr->conflict_send_th); - LOG_FILE_INFO("hno:%u r1x conflict destory, stoped\n", - PS3_HOST(instance)); + LOG_FILE_INFO("hno:%u r1x conflict destroy, stopped\n", + PS3_HOST(instance)); return ret; } -void ps3_r1x_lock_destory_for_vd(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr) +void ps3_r1x_lock_destroy_for_vd(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr) { - if (mgr->conflict_send_th != NULL) { + if (mgr->conflict_send_th != NULL) ps3_kthread_stop(instance, mgr); - } - if(mgr->hash_mgr_conflict != NULL){ + if (mgr->hash_mgr_conflict != NULL) ps3_vfree(instance, mgr->hash_mgr_conflict); - } - if(mgr->hash_mgr != NULL){ + if (mgr->hash_mgr != NULL) ps3_vfree(instance, mgr->hash_mgr); - } mgr->hash_mgr = NULL; mgr->try_lock = NULL; mgr->unlock = NULL; LOG_FILE_INFO("r1x vd deinit write lock mgr success."); - return; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h index e60d514de42f..100d57187526 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_r1x_write_lock.h @@ -1,65 +1,62 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PS3_R1X_WRITE_LOCK_H__ #define __PS3_R1X_WRITE_LOCK_H__ -#include "ps3_types.h" #include "ps3_cmd_channel.h" enum { - PS3_R1X_HASHBIT_LOCK = 0, - PS3_R1X_HASHRANGE_LOCK = 1, + PS3_R1X_HASHBIT_LOCK = 0, + PS3_R1X_HASHRANGE_LOCK = 1, }; -extern U32 g_ps3_r1x_lock_flag; -extern U32 g_ps3_r1x_lock_enable; +extern unsigned int g_ps3_r1x_lock_flag; +extern unsigned int g_ps3_r1x_lock_enable; -U32 ps3_r1x_get_node_Buff_size(void); +unsigned int ps3_r1x_get_node_Buff_size(void); -static inline S32 ps3_r1x_write_lock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static inline int ps3_r1x_write_lock(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - if (mgr->hash_mgr == NULL) { + if (mgr->hash_mgr == NULL) return PS3_SUCCESS; - } - if (0 == g_ps3_r1x_lock_enable) { + if (g_ps3_r1x_lock_enable == 0) return PS3_SUCCESS; - } - if (!cmd->io_attr.is_confilct_check) { + if (!cmd->io_attr.is_confilct_check) return PS3_SUCCESS; - } - if (cmd->is_inserted_c_q == 0) { + if (cmd->is_inserted_c_q == 0) return mgr->try_lock(mgr, cmd); - } else { + else return mgr->resend_try_lock(mgr, cmd); - } } -static inline void ps3_r1x_write_unlock(struct ps3_r1x_lock_mgr *mgr, struct ps3_cmd *cmd) +static inline void ps3_r1x_write_unlock(struct ps3_r1x_lock_mgr *mgr, + struct ps3_cmd *cmd) { - if(cmd->szblock_cnt == 0){ + if (cmd->szblock_cnt == 0) return; - } mgr->unlock(mgr, cmd); cmd->szblock_cnt = 0; } -S32 ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, - struct scsi_device *sdev, U8 raid_level); - -void ps3_r1x_lock_destory_for_vd(struct ps3_instance *instance, - struct ps3_r1x_lock_mgr *mgr); +int ps3_r1x_lock_prepare_for_vd(struct ps3_instance *instance, + struct scsi_device *sdev, + unsigned char raid_level); +void ps3_r1x_lock_destroy_for_vd(struct ps3_instance *instance, + struct ps3_r1x_lock_mgr *mgr); void ps3_r1x_conflict_queue_clean(struct ps3_scsi_priv_data *pri_data, - S32 ret_code); + int ret_code); -Bool ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, struct scsi_cmnd *scmd); +unsigned char ps3_r1x_conflict_queue_abort(struct ps3_cmd *cmd, + struct scsi_cmnd *scmd); void ps3_r1x_conflict_queue_target_reset(struct ps3_instance *instance, - U16 target_id); + unsigned short target_id); void ps3_r1x_conflict_queue_clean_all(struct ps3_instance *instance, - S32 ret_code, Bool is_remove); + int ret_code, unsigned char is_remove); -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c index 1a515e1e1b41..35d87a617e65 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.c @@ -1,731 +1,588 @@ - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_rb_tree.h" - -static void rbtNodeSetParent(Ps3RbNode_s *pNode, - Ps3RbNode_s *pParent) +static void rbtNodeSetParent(struct Ps3RbNode *pNode, struct Ps3RbNode *pParent) { - pNode->pParentColor = - ((pNode->pParentColor & 3ULL) | ((uintptr_t)(void*)pParent)); + pNode->pParentColor = + ((pNode->pParentColor & 3ULL) | ((uintptr_t)(void *)pParent)); } -static void rbtNodeSetColor(Ps3RbNode_s *pNode, U32 color) +static void rbtNodeSetColor(struct Ps3RbNode *pNode, unsigned int color) { - pNode->pParentColor = ((pNode->pParentColor & ~1ULL) | color); + pNode->pParentColor = ((pNode->pParentColor & ~1ULL) | color); } -static void rbtRotateLeft(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) +static void rbtRotateLeft(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) { - Ps3RbNode_s *pRight = pNode->pRight; - Ps3RbNode_s *pParent = RBT_PARENT(pNode); - - pNode->pRight = pRight->pLeft; - if (NULL != pNode->pRight) - { - rbtNodeSetParent(pRight->pLeft, pNode); - } - - pRight->pLeft = pNode; - rbtNodeSetParent(pRight, pParent); - - if (NULL != pParent) - { - if (pNode == pParent->pLeft) - { - pParent->pLeft = pRight; - } - else - { - pParent->pRight = pRight; - } - } - else - { - pRoot->pRoot = pRight; - } - - rbtNodeSetParent(pNode, pRight); + struct Ps3RbNode *pRight = pNode->pRight; + struct Ps3RbNode *pParent = RBT_PARENT(pNode); + + pNode->pRight = pRight->pLeft; + if (pNode->pRight != NULL) + rbtNodeSetParent(pRight->pLeft, pNode); + + pRight->pLeft = pNode; + rbtNodeSetParent(pRight, pParent); + + if (pParent != NULL) { + if (pNode == pParent->pLeft) + pParent->pLeft = pRight; + else + pParent->pRight = pRight; + } else { + pRoot->pRoot = pRight; + } + + rbtNodeSetParent(pNode, pRight); } -static void rbtRotateRight(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) +static void rbtRotateRight(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) { - Ps3RbNode_s *pLeft = pNode->pLeft; - Ps3RbNode_s *pParent = RBT_PARENT(pNode); - - pNode->pLeft = pLeft->pRight; - if (NULL != pNode->pLeft) - { - rbtNodeSetParent(pLeft->pRight, pNode); - } - - pLeft->pRight = pNode; - rbtNodeSetParent(pLeft, pParent); - - if (NULL != pParent) - { - if (pNode == pParent->pRight) - { - pParent->pRight = pLeft; - } - else - { - pParent->pLeft = pLeft; - } - } - else - { - pRoot->pRoot = pLeft; - } - - rbtNodeSetParent(pNode, pLeft); + struct Ps3RbNode *pLeft = pNode->pLeft; + struct Ps3RbNode *pParent = RBT_PARENT(pNode); + + pNode->pLeft = pLeft->pRight; + if (pNode->pLeft != NULL) + rbtNodeSetParent(pLeft->pRight, pNode); + + pLeft->pRight = pNode; + rbtNodeSetParent(pLeft, pParent); + + if (pParent != NULL) { + if (pNode == pParent->pRight) + pParent->pRight = pLeft; + else + pParent->pLeft = pLeft; + } else { + pRoot->pRoot = pLeft; + } + + rbtNodeSetParent(pNode, pLeft); } -static void rbtColorAfterDel(Ps3RbRoot_s *pRoot, - Ps3RbNode_s *pNode, Ps3RbNode_s *pParent) +static void rbtColorAfterDel(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, + struct Ps3RbNode *pParent) { - Ps3RbNode_s *pOther = NULL; - Ps3RbNode_s *pOLeft = NULL; - Ps3RbNode_s *pORight = NULL; - - while (((NULL == pNode) || RBT_IS_BLACK(pNode)) && - (pNode != pRoot->pRoot)) - { - if (pParent->pLeft == pNode) - { - pOther = pParent->pRight; - - if (RBT_IS_RED(pOther)) - { - RBT_SET_BLACK(pOther); - RBT_SET_RED(pParent); - rbtRotateLeft(pRoot, pParent); - pOther = pParent->pRight; - } - - if (((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) && - ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight))) - { - RBT_SET_RED(pOther); - pNode = pParent; - pParent = RBT_PARENT(pNode); - - continue ; - } - - if ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight)) - { - pOLeft = pOther->pLeft; - if (NULL != pOLeft) - { - RBT_SET_BLACK(pOLeft); - } - - RBT_SET_RED(pOther); - rbtRotateRight(pRoot, pOther); - pOther = pParent->pRight; - } - - rbtNodeSetColor(pOther, RBT_COLOR(pParent)); - RBT_SET_BLACK(pParent); - - if (NULL != pOther->pRight) - { - RBT_SET_BLACK(pOther->pRight); - } - - rbtRotateLeft(pRoot, pParent); - pNode = pRoot->pRoot; - - break; - } - - pOther = pParent->pLeft; - - if (RBT_IS_RED(pOther)) - { - RBT_SET_BLACK(pOther); - RBT_SET_RED(pParent); - - rbtRotateRight(pRoot, pParent); - pOther = pParent->pLeft; - } - - if (((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) && - ((NULL == pOther->pRight) || RBT_IS_BLACK(pOther->pRight))) - { - RBT_SET_RED(pOther); - pNode = pParent; - pParent = RBT_PARENT(pNode); - - continue ; - } - - if ((NULL == pOther->pLeft) || RBT_IS_BLACK(pOther->pLeft)) - { - pORight = pOther->pRight; - if (NULL != pORight) - { - RBT_SET_BLACK(pORight); - } - - RBT_SET_RED(pOther); - rbtRotateLeft(pRoot, pOther); - pOther = pParent->pLeft; - } - - rbtNodeSetColor(pOther, RBT_COLOR(pParent)); - RBT_SET_BLACK(pParent); - - if (NULL != pOther->pLeft) - { - RBT_SET_BLACK(pOther->pLeft); - } - - rbtRotateRight(pRoot, pParent); - pNode = pRoot->pRoot; - - break; - } - - if (NULL != pNode) - { - RBT_SET_BLACK(pNode); - } + struct Ps3RbNode *pOther = NULL; + struct Ps3RbNode *pOLeft = NULL; + struct Ps3RbNode *pORight = NULL; + + while (((pNode == NULL) || RBT_IS_BLACK(pNode)) && + (pNode != pRoot->pRoot)) { + if (pParent->pLeft == pNode) { + pOther = pParent->pRight; + if (RBT_IS_RED(pOther)) { + RBT_SET_BLACK(pOther); + RBT_SET_RED(pParent); + rbtRotateLeft(pRoot, pParent); + pOther = pParent->pRight; + } + if (((pOther->pLeft == NULL) || + RBT_IS_BLACK(pOther->pLeft)) && + ((pOther->pRight == NULL) || + RBT_IS_BLACK(pOther->pRight))) { + RBT_SET_RED(pOther); + pNode = pParent; + pParent = RBT_PARENT(pNode); + + continue; + } + if ((pOther->pRight == NULL) || + RBT_IS_BLACK(pOther->pRight)) { + pOLeft = pOther->pLeft; + if (pOLeft != NULL) + RBT_SET_BLACK(pOLeft); + + RBT_SET_RED(pOther); + rbtRotateRight(pRoot, pOther); + pOther = pParent->pRight; + } + + rbtNodeSetColor(pOther, RBT_COLOR(pParent)); + RBT_SET_BLACK(pParent); + + if (pOther->pRight != NULL) + RBT_SET_BLACK(pOther->pRight); + + rbtRotateLeft(pRoot, pParent); + pNode = pRoot->pRoot; + + break; + } + pOther = pParent->pLeft; + if (RBT_IS_RED(pOther)) { + RBT_SET_BLACK(pOther); + RBT_SET_RED(pParent); + + rbtRotateRight(pRoot, pParent); + pOther = pParent->pLeft; + } + if (((pOther->pLeft == NULL) || RBT_IS_BLACK(pOther->pLeft)) && + ((pOther->pRight == NULL) || + RBT_IS_BLACK(pOther->pRight))) { + RBT_SET_RED(pOther); + pNode = pParent; + pParent = RBT_PARENT(pNode); + + continue; + } + if ((pOther->pLeft == NULL) || RBT_IS_BLACK(pOther->pLeft)) { + pORight = pOther->pRight; + if (pORight != NULL) + RBT_SET_BLACK(pORight); + + RBT_SET_RED(pOther); + rbtRotateLeft(pRoot, pOther); + pOther = pParent->pLeft; + } + + rbtNodeSetColor(pOther, RBT_COLOR(pParent)); + RBT_SET_BLACK(pParent); + + if (pOther->pLeft != NULL) + RBT_SET_BLACK(pOther->pLeft); + + rbtRotateRight(pRoot, pParent); + pNode = pRoot->pRoot; + + break; + } + + if (pNode != NULL) + RBT_SET_BLACK(pNode); } -void rbtDelNodeDo(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) +static void rbtDelNodeDo(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) { - Ps3RbNode_s *pParent = NULL; - Ps3RbNode_s *pChild = NULL; - Ps3RbNode_s *pOld = NULL; - U32 color = 0; - - if (NULL == pNode->pLeft) - { - pChild = pNode->pRight; - } - else if (NULL == pNode->pRight) - { - pChild = pNode->pLeft; - } - else - { - pOld = pNode; - - pNode = pNode->pRight; - while (NULL != pNode->pLeft) - { - pNode = pNode->pLeft; - } - - pChild = pNode->pRight; - pParent = RBT_PARENT(pNode); - color = RBT_COLOR(pNode); - - if (NULL != pChild) - { - rbtNodeSetParent(pChild, pParent); - } - - if (pParent == pOld) - { - pParent->pRight = pChild; - pParent = pNode; - } - else - { - pParent->pLeft = pChild; - } - - pNode->pParentColor = pOld->pParentColor; - pNode->pRight = pOld->pRight; - pNode->pLeft = pOld->pLeft; - - if (NULL != RBT_PARENT(pOld)) - { - if (RBT_PARENT(pOld)->pLeft == pOld) - { - RBT_PARENT(pOld)->pLeft = pNode; - } - else - { - RBT_PARENT(pOld)->pRight = pNode; - } - } - else - { - pRoot->pRoot = pNode; - } - - rbtNodeSetParent(pOld->pLeft, pNode); - if (NULL != pOld->pRight) - { - rbtNodeSetParent(pOld->pRight, pNode); - } - - goto l_color; - } - - pParent = RBT_PARENT(pNode); - color = RBT_COLOR(pNode); - - if (NULL != pChild) - { - rbtNodeSetParent(pChild, pParent); - } - - if (NULL != pParent) - { - if (pParent->pLeft == pNode) - { - pParent->pLeft = pChild; - } - else - { - pParent->pRight = pChild; - } - } - else - { - pRoot->pRoot = pChild; - } + struct Ps3RbNode *pParent = NULL; + struct Ps3RbNode *pChild = NULL; + struct Ps3RbNode *pOld = NULL; + unsigned int color = 0; + + if (pNode->pLeft == NULL) { + pChild = pNode->pRight; + } else if (pNode->pRight == NULL) { + pChild = pNode->pLeft; + } else { + pOld = pNode; + + pNode = pNode->pRight; + while (pNode->pLeft != NULL) + pNode = pNode->pLeft; + + pChild = pNode->pRight; + pParent = RBT_PARENT(pNode); + color = RBT_COLOR(pNode); + + if (pChild != NULL) + rbtNodeSetParent(pChild, pParent); + + if (pParent == pOld) { + pParent->pRight = pChild; + pParent = pNode; + } else { + pParent->pLeft = pChild; + } + + pNode->pParentColor = pOld->pParentColor; + pNode->pRight = pOld->pRight; + pNode->pLeft = pOld->pLeft; + + if (RBT_PARENT(pOld) != NULL) { + if (RBT_PARENT(pOld)->pLeft == pOld) + RBT_PARENT(pOld)->pLeft = pNode; + else + RBT_PARENT(pOld)->pRight = pNode; + } else { + pRoot->pRoot = pNode; + } + + rbtNodeSetParent(pOld->pLeft, pNode); + if (pOld->pRight != NULL) + rbtNodeSetParent(pOld->pRight, pNode); + + goto l_color; + } + + pParent = RBT_PARENT(pNode); + color = RBT_COLOR(pNode); + + if (pChild != NULL) + rbtNodeSetParent(pChild, pParent); + + if (pParent != NULL) { + if (pParent->pLeft == pNode) + pParent->pLeft = pChild; + else + pParent->pRight = pChild; + } else { + pRoot->pRoot = pChild; + } l_color: - if (color == RBT_BLACK) - { - rbtColorAfterDel(pRoot, pChild, pParent); - } + if (color == RBT_BLACK) + rbtColorAfterDel(pRoot, pChild, pParent); } -static Ps3RbNode_s* rbtFindNodeDo(Ps3RbRoot_s *pRoot, void *pKey, - Ps3RbTreeOps_s *pOps, Bool intent_addnode, Ps3RbNode_s **ppParent, - Ps3RbNode_s ***pppLinker) +static struct Ps3RbNode *rbtFindNodeDo(struct Ps3RbRoot *pRoot, void *pKey, + struct Ps3RbTreeOps *pOps, + unsigned char intent_addnode, + struct Ps3RbNode **ppParent, + struct Ps3RbNode ***pppLinker) { - Ps3RbNode_s *pNode = NULL; - Ps3RbNode_s *pParent = NULL; - Ps3RbNode_s **ppLinker = NULL; - void *pKeyCur = NULL; - Ps3Cmp_e cmprc = PS3_EQ; - - BUG_ON(NULL == pOps->cmpkey); - BUG_ON((NULL == pOps->getkey) && - (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); - - ppLinker = &pRoot->pRoot; - while (NULL != (*ppLinker)) - { - pParent = (*ppLinker); - - pKeyCur = ps3RbNodeGetKey(pParent, pOps); - cmprc = pOps->cmpkey(pKey, pKeyCur); - if (PS3_LT == cmprc) - { - ppLinker = &pParent->pLeft; - } - else if (PS3_GT == cmprc) - { - ppLinker = &pParent->pRight; - } - else if ((PS3_TRUE == intent_addnode) && - testBitNonAtomic(RBTBF_CONFLICT_ENABLE, (volatile ULong *)&pOps->flags)) - { - ppLinker = &pParent->pLeft; - } - else - { - pNode = pParent; - break ; - } - } - - if (NULL != pppLinker) - { - (*pppLinker) = ppLinker; - } - - if (NULL != ppParent) - { - if (NULL != pNode) - { - (*ppParent) = RBT_PARENT(pNode); - } - else - { - (*ppParent) = pParent; - } - } - - return pNode; + struct Ps3RbNode *pNode = NULL; + struct Ps3RbNode *pParent = NULL; + struct Ps3RbNode **ppLinker = NULL; + void *pKeyCur = NULL; + enum Ps3Cmp cmprc = PS3_EQ; + + BUG_ON(pOps->cmpkey == NULL); + BUG_ON((pOps->getkey == NULL) && + (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, + (unsigned long *)&pOps->flags))); + + ppLinker = &pRoot->pRoot; + while (NULL != (*ppLinker)) { + pParent = (*ppLinker); + + pKeyCur = ps3RbNodeGetKey(pParent, pOps); + cmprc = pOps->cmpkey(pKey, pKeyCur); + if (cmprc == PS3_LT) { + ppLinker = &pParent->pLeft; + } else if (cmprc == PS3_GT) { + ppLinker = &pParent->pRight; + } else if ((intent_addnode == PS3_TRUE) && + testBitNonAtomic( + RBTBF_CONFLICT_ENABLE, + (unsigned long *)&pOps->flags)) { + ppLinker = &pParent->pLeft; + } else { + pNode = pParent; + break; + } + } + + if (pppLinker != NULL) + (*pppLinker) = ppLinker; + + if (ppParent != NULL) { + if (pNode != NULL) + (*ppParent) = RBT_PARENT(pNode); + else + (*ppParent) = pParent; + } + + return pNode; } -void ps3RbtColorAfterAdd(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) +void ps3RbtColorAfterAdd(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) { - Ps3RbNode_s *pGparent = NULL; - Ps3RbNode_s *pParent = NULL; - Ps3RbNode_s *pUncle = NULL; - Ps3RbNode_s *pTmp = NULL; - - while (1) - { - pParent = RBT_PARENT(pNode); - if ((NULL == pParent) || RBT_IS_BLACK(pParent)) - { - break ; - } - - pGparent = RBT_PARENT(pParent); - if (pParent == pGparent->pLeft) - { - pUncle = pGparent->pRight; - if ((NULL != pUncle) && RBT_IS_RED(pUncle)) - { - RBT_SET_BLACK(pUncle); - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - - pNode = pGparent; - continue ; - } - - if (pParent->pRight == pNode) - { - rbtRotateLeft(pRoot, pParent); - - pTmp = pParent; - pParent = pNode; - pNode = pTmp; - } - - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - rbtRotateRight(pRoot, pGparent); - } - else - { - pUncle = pGparent->pLeft; - if ((NULL != pUncle) && RBT_IS_RED(pUncle)) - { - RBT_SET_BLACK(pUncle); - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - - pNode = pGparent; - continue ; - } - - if (pParent->pLeft == pNode) - { - rbtRotateRight(pRoot, pParent); - - pTmp = pParent; - pParent = pNode; - pNode = pTmp; - } - - RBT_SET_BLACK(pParent); - RBT_SET_RED(pGparent); - rbtRotateLeft(pRoot, pGparent); - } - } - - RBT_SET_BLACK(pRoot->pRoot); + struct Ps3RbNode *pGparent = NULL; + struct Ps3RbNode *pParent = NULL; + struct Ps3RbNode *pUncle = NULL; + struct Ps3RbNode *pTmp = NULL; + + while (1) { + pParent = RBT_PARENT(pNode); + if ((pParent == NULL) || RBT_IS_BLACK(pParent)) + break; + + pGparent = RBT_PARENT(pParent); + if (pParent == pGparent->pLeft) { + pUncle = pGparent->pRight; + if ((pUncle != NULL) && RBT_IS_RED(pUncle)) { + RBT_SET_BLACK(pUncle); + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + + pNode = pGparent; + continue; + } + + if (pParent->pRight == pNode) { + rbtRotateLeft(pRoot, pParent); + + pTmp = pParent; + pParent = pNode; + pNode = pTmp; + } + + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + rbtRotateRight(pRoot, pGparent); + } else { + pUncle = pGparent->pLeft; + if ((pUncle != NULL) && RBT_IS_RED(pUncle)) { + RBT_SET_BLACK(pUncle); + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + + pNode = pGparent; + continue; + } + + if (pParent->pLeft == pNode) { + rbtRotateRight(pRoot, pParent); + + pTmp = pParent; + pParent = pNode; + pNode = pTmp; + } + + RBT_SET_BLACK(pParent); + RBT_SET_RED(pGparent); + rbtRotateLeft(pRoot, pGparent); + } + } + + RBT_SET_BLACK(pRoot->pRoot); } -Ps3RbNode_s* ps3RbtHeadNode(Ps3RbRoot_s *pRoot) +struct Ps3RbNode *ps3RbtHeadNode(struct Ps3RbRoot *pRoot) { - Ps3RbNode_s *pNode = NULL; + struct Ps3RbNode *pNode = NULL; - pNode = pRoot->pRoot; - if (NULL == pNode) - { - goto end; - } + pNode = pRoot->pRoot; + if (pNode == NULL) + goto end; - while (NULL != pNode->pLeft) - { - pNode = pNode->pLeft; - } + while (pNode->pLeft != NULL) + pNode = pNode->pLeft; end: - return pNode; + return pNode; } -Ps3RbNode_s* ps3RbtTailNode(Ps3RbRoot_s *pRoot) +struct Ps3RbNode *ps3RbtTailNode(struct Ps3RbRoot *pRoot) { - Ps3RbNode_s *pNode = NULL; + struct Ps3RbNode *pNode = NULL; - pNode = pRoot->pRoot; - if (NULL == pNode) - { - goto end; - } + pNode = pRoot->pRoot; + if (pNode == NULL) + goto end; - while (NULL != pNode->pRight) - { - pNode = pNode->pRight; - } + while (pNode->pRight != NULL) + pNode = pNode->pRight; end: - return pNode; + return pNode; } -Ps3RbNode_s* ps3RbtPrevNode(Ps3RbNode_s *pNode) +struct Ps3RbNode *ps3RbtPrevNode(struct Ps3RbNode *pNode) { - Ps3RbNode_s *pParent = NULL; - - if (NULL == pNode) - { - goto end; - } - - if (NULL != pNode->pLeft) - { - pNode = pNode->pLeft; - while (NULL != pNode->pRight) - { - pNode = pNode->pRight; - } - - return pNode; - } - - while (1) - { - pParent = RBT_PARENT(pNode); - if ((NULL == pParent) || (pNode != pParent->pLeft)) - { - goto end; - } - - pNode = pParent; - } + struct Ps3RbNode *pParent = NULL; + + if (pNode == NULL) + goto end; + + if (pNode->pLeft != NULL) { + pNode = pNode->pLeft; + while (pNode->pRight != NULL) + pNode = pNode->pRight; + + return pNode; + } + while (1) { + pParent = RBT_PARENT(pNode); + if ((pParent == NULL) || (pNode != pParent->pLeft)) + goto end; + + pNode = pParent; + } end: - return pParent; + return pParent; } -Ps3RbNode_s* ps3RbtNextNode(Ps3RbNode_s *pNode) +struct Ps3RbNode *ps3RbtNextNode(struct Ps3RbNode *pNode) { - Ps3RbNode_s *pParent = NULL; - - if (NULL == pNode) - { - goto end; - } - - if (NULL != pNode->pRight) - { - pNode = pNode->pRight; - while (NULL != pNode->pLeft) - { - pNode = pNode->pLeft; - } - - return pNode; - } - - while (1) - { - pParent = RBT_PARENT(pNode); - if ((NULL == pParent) || (pNode != pParent->pRight)) - { - goto end; - } - - pNode = pParent; - } + struct Ps3RbNode *pParent = NULL; + + if (pNode == NULL) + goto end; + + if (pNode->pRight != NULL) { + pNode = pNode->pRight; + while (pNode->pLeft != NULL) + pNode = pNode->pLeft; + + return pNode; + } + + while (1) { + pParent = RBT_PARENT(pNode); + if ((pParent == NULL) || (pNode != pParent->pRight)) + goto end; + + pNode = pParent; + } end: - return pParent; + return pParent; } -void ps3RbtReplaceNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNew, - Ps3RbNode_s *pVictim) +void ps3RbtReplaceNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNew, + struct Ps3RbNode *pVictim) { - Ps3RbNode_s *pParent = RBT_PARENT(pVictim); - - if (NULL != pParent) - { - if (pVictim == pParent->pLeft) - { - pParent->pLeft = pNew; - } - else - { - pParent->pRight = pNew; - } - } - else - { - pRoot->pRoot = pNew; - } - - if (NULL != pVictim->pLeft) - { - rbtNodeSetParent(pVictim->pLeft, pNew); - } - - if (NULL != pVictim->pRight) - { - rbtNodeSetParent(pVictim->pRight, pNew); - } - - (*pNew) = (*pVictim); + struct Ps3RbNode *pParent = RBT_PARENT(pVictim); + + if (pParent != NULL) { + if (pVictim == pParent->pLeft) + pParent->pLeft = pNew; + else + pParent->pRight = pNew; + } else { + pRoot->pRoot = pNew; + } + + if (pVictim->pLeft != NULL) + rbtNodeSetParent(pVictim->pLeft, pNew); + + if (pVictim->pRight != NULL) + rbtNodeSetParent(pVictim->pRight, pNew); + + (*pNew) = (*pVictim); } -S32 ps3RbtDelNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode) +int ps3RbtDelNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode) { - S32 rc = 0; + int rc = 0; - if (RBT_NODE_IS_EMPTY(pNode)) - { - rc = -PS3_FAILED; - goto end; - } + if (RBT_NODE_IS_EMPTY(pNode)) { + rc = -PS3_FAILED; + goto end; + } - rbtDelNodeDo(pRoot, pNode); - ps3RbNodeInit(pNode); + rbtDelNodeDo(pRoot, pNode); + ps3RbNodeInit(pNode); end: - return rc; + return rc; } -S32 ps3RbtAddNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode, - Ps3RbTreeOps_s *pOps) +int ps3RbtAddNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, + struct Ps3RbTreeOps *pOps) { - Ps3RbNode_s *pParent = NULL; - Ps3RbNode_s **ppLinker = NULL; - void *pKey = NULL; - S32 rc = 0; - - BUG_ON((NULL == pOps->getkey) && - (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags))); - - if (!RBT_NODE_IS_EMPTY(pNode)) - { - rc = -PS3_FAILED; - goto end; - } - - pKey = ps3RbNodeGetKey(pNode, pOps); - if (NULL != rbtFindNodeDo(pRoot, pKey, pOps, PS3_TRUE, &pParent, - &ppLinker)) - { - rc = -PS3_FAILED; - goto end; - } - - ps3RbNodeLink(pNode, pParent, ppLinker); - ps3RbtColorAfterAdd(pRoot, pNode); + struct Ps3RbNode *pParent = NULL; + struct Ps3RbNode **ppLinker = NULL; + void *pKey = NULL; + int rc = 0; + + BUG_ON((pOps->getkey == NULL) && + (!testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, + (unsigned long *)&pOps->flags))); + + if (!RBT_NODE_IS_EMPTY(pNode)) { + rc = -PS3_FAILED; + goto end; + } + + pKey = ps3RbNodeGetKey(pNode, pOps); + if (NULL != + rbtFindNodeDo(pRoot, pKey, pOps, PS3_TRUE, &pParent, &ppLinker)) { + rc = -PS3_FAILED; + goto end; + } + + ps3RbNodeLink(pNode, pParent, ppLinker); + ps3RbtColorAfterAdd(pRoot, pNode); end: - return rc; + return rc; } -Ps3RbNode_s* ps3RbtFindNode(Ps3RbRoot_s *pRoot, void *pKey, - Ps3RbTreeOps_s *pOps) +struct Ps3RbNode *ps3RbtFindNode(struct Ps3RbRoot *pRoot, void *pKey, + struct Ps3RbTreeOps *pOps) { - Ps3RbNode_s *pNode = NULL; + struct Ps3RbNode *pNode = NULL; - if (NULL == pKey) - { - pNode = ps3RbtHeadNode(pRoot); - goto end; - } + if (pKey == NULL) { + pNode = ps3RbtHeadNode(pRoot); + goto end; + } - pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, NULL, NULL); + pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, NULL, NULL); end: - return pNode; + return pNode; } -Ps3RbNode_s* ps3RbtFindNextNode(Ps3RbRoot_s *pRoot, void *pKey, - Ps3RbTreeOps_s *pOps) +struct Ps3RbNode *ps3RbtFindNextNode(struct Ps3RbRoot *pRoot, void *pKey, + struct Ps3RbTreeOps *pOps) { - Ps3RbNode_s *pNode = NULL; - Ps3RbNode_s *pParent = NULL; - Ps3RbNode_s **ppLinker = NULL; - void *pKeyCur = NULL; - - if (NULL == pKey) - { - pNode = ps3RbtHeadNode(pRoot); - goto end; - } - - pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, &pParent, - &ppLinker); - if (NULL != pNode) - { - pNode = ps3RbtNextNode(pNode); - - if (!testBitNonAtomic(RBTBF_CONFLICT_ENABLE, (volatile ULong *)&pOps->flags)) - { - goto end; - } - - while (NULL != pNode) - { - pKeyCur = ps3RbNodeGetKey(pNode, pOps); - if (PS3_EQ != pOps->cmpkey(pKey, pKeyCur)) - { - break; - } - - pNode = ps3RbtNextNode(pNode); - } - - goto end; - } - - if (NULL == pParent) - { - goto end; - } - - if (ppLinker == &pParent->pLeft) - { - pNode = pParent; - goto end; - } - - pNode = ps3RbtNextNode(pParent); + struct Ps3RbNode *pNode = NULL; + struct Ps3RbNode *pParent = NULL; + struct Ps3RbNode **ppLinker = NULL; + void *pKeyCur = NULL; + + if (pKey == NULL) { + pNode = ps3RbtHeadNode(pRoot); + goto end; + } + + pNode = rbtFindNodeDo(pRoot, pKey, pOps, PS3_FALSE, &pParent, + &ppLinker); + if (pNode != NULL) { + pNode = ps3RbtNextNode(pNode); + + if (!testBitNonAtomic(RBTBF_CONFLICT_ENABLE, + (unsigned long *)&pOps->flags)) { + goto end; + } + + while (pNode != NULL) { + pKeyCur = ps3RbNodeGetKey(pNode, pOps); + if (pOps->cmpkey(pKey, pKeyCur) != PS3_EQ) + break; + + pNode = ps3RbtNextNode(pNode); + } + + goto end; + } + + if (pParent == NULL) + goto end; + + if (ppLinker == &pParent->pLeft) { + pNode = pParent; + goto end; + } + + pNode = ps3RbtNextNode(pParent); end: - return pNode; + return pNode; } -void ps3RbtClean(Ps3RbRoot_s *pRoot) +void ps3RbtClean(struct Ps3RbRoot *pRoot) { - Ps3RbNode_s *pNode = NULL; + struct Ps3RbNode *pNode = NULL; - pNode = ps3RbtHeadNode(pRoot); - while (NULL != pNode) - { - (void)ps3RbtDelNode(pRoot, pNode); + pNode = ps3RbtHeadNode(pRoot); + while (pNode != NULL) { + (void)ps3RbtDelNode(pRoot, pNode); - pNode = ps3RbtHeadNode(pRoot); - } + pNode = ps3RbtHeadNode(pRoot); + } } -S32 ps3RbtTraverse(Ps3RbRoot_s *pRoot, ps3RbtreeVisitFunc visit, - void *p_ctxt) +int ps3RbtTraverse(struct Ps3RbRoot *pRoot, + int (*visit)(struct Ps3RbNode *pNode, void *pCtxt), + void *p_ctxt) { - Ps3RbNode_s *pNode = NULL; - Ps3RbNode_s *pNext = NULL; - S32 rc = 0; + struct Ps3RbNode *pNode = NULL; + struct Ps3RbNode *pNext = NULL; + int rc = 0; - BUG_ON(NULL == visit); + BUG_ON(visit == NULL); - RBT_FOR_EACH_SAFE(pNode, pNext, pRoot) - { - rc = visit(pNode, p_ctxt); - if (rc < 0) - { - goto end; - } - } + RBT_FOR_EACH_SAFE(pNode, pNext, pRoot) + { + rc = visit(pNode, p_ctxt); + if (rc < 0) + goto end; + } end: - return rc; + return rc; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h index 44697aad5850..8642441cdefa 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_rb_tree.h @@ -1,341 +1,325 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __PS3_RBTREE_H__ #define __PS3_RBTREE_H__ #ifndef _WINDOWS #include #include +#include #endif #include "ps3_driver_log.h" -#include "ps3_define.h" #include "ps3_err_def.h" -static inline void setBitNonAtomic(U32 nr, volatile ULong *addr) +static inline void setBitNonAtomic(unsigned int nr, + unsigned long *addr) { - ULong mask = BIT_MASK(nr); - ULong *p = ((ULong *)addr) + BIT_WORD(nr); - - *p |= mask; + set_bit(nr, addr); } -static inline void clearBitNonAtomic(U32 nr, volatile ULong *addr) +static inline void clearBitNonAtomic(unsigned int nr, + unsigned long *addr) { - ULong mask = BIT_MASK(nr); - ULong *p = ((ULong *)addr) + BIT_WORD(nr); - - *p &= ~mask; + clear_bit(nr, addr); } -static inline S32 testBitNonAtomic(U32 nr, const volatile ULong *addr) +static inline int testBitNonAtomic(unsigned int nr, + const unsigned long *addr) { - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); + return test_bit(nr, addr); } -typedef struct Ps3RbNode -{ - __attribute__((__aligned__(8))) - U64 pParentColor; - - struct - { - struct Ps3RbNode *pLeft; - struct Ps3RbNode *pRight; - }; -} Ps3RbNode_s; - -typedef struct Ps3RbRoot -{ - Ps3RbNode_s *pRoot; -} Ps3RbRoot_s; +struct Ps3RbNode { + __aligned(8) unsigned long long pParentColor; -#define PS3_RBROOT_INITNIL {NULL} + struct { + struct Ps3RbNode *pLeft; + struct Ps3RbNode *pRight; + }; +}; -typedef enum Ps3Cmp -{ - PS3_EQ = 0, - PS3_GT = 1, - PS3_LT = 2, - PS3_CMPNR = 3, -} Ps3Cmp_e; +struct Ps3RbRoot { + struct Ps3RbNode *pRoot; +}; -typedef Ps3Cmp_e (*ps3CmpKeyFunc)(void *pKey1, void *pKey2); +#define PS3_RBROOT_INITNIL \ + { \ + NULL \ + } -typedef void* (*ps3RbtreeGetKeyFunc)(Ps3RbNode_s *pNode, void *pCtxt); +enum Ps3Cmp { + PS3_EQ = 0, + PS3_GT = 1, + PS3_LT = 2, + PS3_CMPNR = 3, +}; -typedef S32 (*ps3RbtreeVisitFunc)(Ps3RbNode_s *pNode, void *pCtxt); - -typedef enum Ps3RbtreebFlag -{ - RBTBF_KEYOFFSET_ENABLE = 0, - RBTBF_CONFLICT_ENABLE, -} Ps3RbtreebFlag_e; +enum Ps3RbtreebFlag { + RBTBF_KEYOFFSET_ENABLE = 0, + RBTBF_CONFLICT_ENABLE, +}; -typedef struct Ps3RbTreeOps -{ - ps3CmpKeyFunc cmpkey; +struct Ps3RbTreeOps { + enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2); - union - { - ps3RbtreeGetKeyFunc getkey; - U64 keyoffset; - }; + union { + void *(*getkey)(struct Ps3RbNode *pNode, void *pCtxt); + unsigned long long keyoffset; + }; - U32 flags; - void *pCtxt; -} Ps3RbTreeOps_s; + unsigned int flags; + void *pCtxt; +}; -typedef struct Ps3RbTree -{ - Ps3RbRoot_s root; - U32 nodenr; - Ps3RbTreeOps_s ops; -} Ps3RbTree_s; +struct Ps3RbTree { + struct Ps3RbRoot root; + unsigned int nodenr; + struct Ps3RbTreeOps ops; +}; -static inline void ps3RbNodeInit(Ps3RbNode_s *pNode) +static inline void ps3RbNodeInit(struct Ps3RbNode *pNode) { - pNode->pParentColor = ((uintptr_t)(void*)pNode); + pNode->pParentColor = ((uintptr_t)(void *)pNode); } -static inline void ps3RbNodeLink(Ps3RbNode_s *pNode, - Ps3RbNode_s *pParent, Ps3RbNode_s **ppLinker) +static inline void ps3RbNodeLink(struct Ps3RbNode *pNode, + struct Ps3RbNode *pParent, + struct Ps3RbNode **ppLinker) { - pNode->pParentColor = ((uintptr_t)(void*)pParent); - pNode->pLeft = NULL; - pNode->pRight = NULL; + pNode->pParentColor = ((uintptr_t)(void *)pParent); + pNode->pLeft = NULL; + pNode->pRight = NULL; - (*ppLinker) = pNode; + (*ppLinker) = pNode; } -static inline void* ps3RbNodeGetKey(Ps3RbNode_s *pNode, - Ps3RbTreeOps_s *pOps) +static inline void *ps3RbNodeGetKey(struct Ps3RbNode *pNode, + struct Ps3RbTreeOps *pOps) { - if (testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&pOps->flags)) - { - return (void *)((U8 *)pNode + pOps->keyoffset); - } + if (testBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, + (unsigned long *)&pOps->flags)) { + return (void *)((unsigned char *)pNode + pOps->keyoffset); + } - return pOps->getkey(pNode, pOps->pCtxt); + return pOps->getkey(pNode, pOps->pCtxt); } -static inline void ps3RbRootInit(Ps3RbRoot_s *pRoot) +static inline void ps3RbRootInit(struct Ps3RbRoot *pRoot) { - pRoot->pRoot = NULL; + pRoot->pRoot = NULL; } -static inline void ps3RbRootFini(Ps3RbRoot_s *pRoot) +static inline void ps3RbRootFini(struct Ps3RbRoot *pRoot) { BUG_ON(pRoot->pRoot != NULL); } -void ps3RbtColorAfterAdd(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode); +void ps3RbtColorAfterAdd(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode); -Ps3RbNode_s* ps3RbtHeadNode(Ps3RbRoot_s *pRoot); +struct Ps3RbNode *ps3RbtHeadNode(struct Ps3RbRoot *pRoot); -Ps3RbNode_s* ps3RbtTailNode(Ps3RbRoot_s *pRoot); +struct Ps3RbNode *ps3RbtTailNode(struct Ps3RbRoot *pRoot); -Ps3RbNode_s* ps3RbtPrevNode(Ps3RbNode_s *pNode); +struct Ps3RbNode *ps3RbtPrevNode(struct Ps3RbNode *pNode); -Ps3RbNode_s* ps3RbtNextNode(Ps3RbNode_s *pNode); +struct Ps3RbNode *ps3RbtNextNode(struct Ps3RbNode *pNode); -void ps3RbtReplaceNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNew, - Ps3RbNode_s *pVictim); +void ps3RbtReplaceNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNew, + struct Ps3RbNode *pVictim); -S32 ps3RbtDelNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode); +int ps3RbtDelNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode); -S32 ps3RbtAddNode(Ps3RbRoot_s *pRoot, Ps3RbNode_s *pNode, - Ps3RbTreeOps_s *pOps); +int ps3RbtAddNode(struct Ps3RbRoot *pRoot, struct Ps3RbNode *pNode, + struct Ps3RbTreeOps *pOps); -Ps3RbNode_s* ps3RbtFindNode(Ps3RbRoot_s *pRoot, void *pKey, - Ps3RbTreeOps_s *pOps); +struct Ps3RbNode *ps3RbtFindNode(struct Ps3RbRoot *pRoot, void *pKey, + struct Ps3RbTreeOps *pOps); -Ps3RbNode_s* ps3RbtFindNextNode(Ps3RbRoot_s *pRoot, void *pKey, - Ps3RbTreeOps_s *pOps); +struct Ps3RbNode *ps3RbtFindNextNode(struct Ps3RbRoot *pRoot, void *pKey, + struct Ps3RbTreeOps *pOps); -void ps3RbtClean(Ps3RbRoot_s *pRoot); +void ps3RbtClean(struct Ps3RbRoot *pRoot); -S32 ps3RbtTraverse(Ps3RbRoot_s *pRoot, ps3RbtreeVisitFunc visit, - void *pCtxt); +int ps3RbtTraverse(struct Ps3RbRoot *pRoot, + int (*visit)(struct Ps3RbNode *pNode, void *pCtxt), + void *pCtxt); -static inline Bool ps3RbtIsEmpty(Ps3RbRoot_s *pRoot) +static inline unsigned char ps3RbtIsEmpty(struct Ps3RbRoot *pRoot) { - return (Bool)(pRoot->pRoot == NULL); + return (unsigned char)(pRoot->pRoot == NULL); } -static inline S32 ps3RbTreeInit(Ps3RbTree_s *pTree, - Ps3RbTreeOps_s *pOps) +static inline int ps3RbTreeInit(struct Ps3RbTree *pTree, + struct Ps3RbTreeOps *pOps) { - S32 rc = 0; + int rc = 0; - ps3RbRootInit(&pTree->root); - pTree->nodenr = 0; + ps3RbRootInit(&pTree->root); + pTree->nodenr = 0; - memset(&pTree->ops, 0, sizeof(Ps3RbTreeOps_s)); - if (NULL != pOps) - { - pTree->ops = (*pOps); - } + memset(&pTree->ops, 0, sizeof(struct Ps3RbTreeOps)); + if (pOps != NULL) + pTree->ops = (*pOps); - return rc; + return rc; } -static inline S32 ps3RbTreeInitGetKey(Ps3RbTree_s *pTree, - ps3CmpKeyFunc cmpkey, ps3RbtreeGetKeyFunc getkey, void *pCtxt) +static inline int +ps3RbTreeInitGetKey(struct Ps3RbTree *pTree, + enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2), + void *(*getkey)(struct Ps3RbNode *pNode, void *pCtxt), + void *pCtxt) { - Ps3RbTreeOps_s ops; + struct Ps3RbTreeOps ops; - memset(&ops, 0, sizeof(Ps3RbTreeOps_s)); - ops.cmpkey = cmpkey; - ops.getkey = getkey; - ops.pCtxt = pCtxt; + memset(&ops, 0, sizeof(struct Ps3RbTreeOps)); + ops.cmpkey = cmpkey; + ops.getkey = getkey; + ops.pCtxt = pCtxt; - return ps3RbTreeInit(pTree, &ops); + return ps3RbTreeInit(pTree, &ops); } -static inline S32 ps3RbTreeInitKeyOffset(Ps3RbTree_s *pTree, - ps3CmpKeyFunc cmpkey, U64 keyoffset, void *pCtxt) +static inline int +ps3RbTreeInitKeyOffset(struct Ps3RbTree *pTree, + enum Ps3Cmp (*cmpkey)(void *pKey1, void *pKey2), + unsigned long long keyoffset, void *pCtxt) { - Ps3RbTreeOps_s ops; + struct Ps3RbTreeOps ops; - memset(&ops, 0, sizeof(Ps3RbTreeOps_s)); - ops.cmpkey = cmpkey; - ops.keyoffset = keyoffset; - ops.pCtxt = pCtxt; - setBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, (volatile ULong *)&ops.flags); + memset(&ops, 0, sizeof(struct Ps3RbTreeOps)); + ops.cmpkey = cmpkey; + ops.keyoffset = keyoffset; + ops.pCtxt = pCtxt; + setBitNonAtomic(RBTBF_KEYOFFSET_ENABLE, + (unsigned long *)&ops.flags); - return ps3RbTreeInit(pTree, &ops); + return ps3RbTreeInit(pTree, &ops); } -static inline void ps3RbTreeFini(Ps3RbTree_s *pTree) +static inline void ps3RbTreeFini(struct Ps3RbTree *pTree) { BUG_ON(pTree->nodenr != 0); ps3RbRootFini(&pTree->root); } -static inline Ps3RbNode_s* ps3RbTreeHeadNode(Ps3RbTree_s *pTree) +static inline struct Ps3RbNode *ps3RbTreeHeadNode(struct Ps3RbTree *pTree) { - return ps3RbtHeadNode(&pTree->root); + return ps3RbtHeadNode(&pTree->root); } -static inline Ps3RbNode_s* ps3RbTreeTailNode(Ps3RbTree_s *pTree) +static inline struct Ps3RbNode *ps3RbTreeTailNode(struct Ps3RbTree *pTree) { - return ps3RbtTailNode(&pTree->root); + return ps3RbtTailNode(&pTree->root); } -static inline Ps3RbNode_s* ps3RbTreePrevNode(Ps3RbNode_s *pNode) +static inline struct Ps3RbNode *ps3RbTreePrevNode(struct Ps3RbNode *pNode) { - return ps3RbtPrevNode(pNode); + return ps3RbtPrevNode(pNode); } -static inline Ps3RbNode_s* ps3RbTreeNextNode(Ps3RbNode_s *pNode) +static inline struct Ps3RbNode *ps3RbTreeNextNode(struct Ps3RbNode *pNode) { - return ps3RbtNextNode(pNode); + return ps3RbtNextNode(pNode); } -static inline void ps3RbTreeReplaceNode(Ps3RbTree_s *pTree, - Ps3RbNode_s *pNew, Ps3RbNode_s *pVictim) +static inline void ps3RbTreeReplaceNode(struct Ps3RbTree *pTree, + struct Ps3RbNode *pNew, + struct Ps3RbNode *pVictim) { - ps3RbtReplaceNode(&pTree->root, pNew, pVictim); + ps3RbtReplaceNode(&pTree->root, pNew, pVictim); } -static inline S32 ps3RbTreeDelNode(Ps3RbTree_s *pTree, - Ps3RbNode_s *pNode) +static inline int ps3RbTreeDelNode(struct Ps3RbTree *pTree, + struct Ps3RbNode *pNode) { - S32 rc = 0; + int rc = 0; - rc = ps3RbtDelNode(&pTree->root, pNode); - if (rc >= 0) - { - pTree->nodenr--; - } + rc = ps3RbtDelNode(&pTree->root, pNode); + if (rc >= 0) + pTree->nodenr--; - return rc; + return rc; } -static inline S32 ps3RbTreeAddNode(Ps3RbTree_s *pTree, - Ps3RbNode_s *pNode) +static inline int ps3RbTreeAddNode(struct Ps3RbTree *pTree, + struct Ps3RbNode *pNode) { - S32 rc = 0; + int rc = 0; - rc = ps3RbtAddNode(&pTree->root, pNode, &pTree->ops); - if (rc >= 0) - { - pTree->nodenr++; - } + rc = ps3RbtAddNode(&pTree->root, pNode, &pTree->ops); + if (rc >= 0) + pTree->nodenr++; - return rc; + return rc; } -static inline Ps3RbNode_s* ps3RbTreeFindNode(Ps3RbTree_s *pTree, - void *pKey) +static inline struct Ps3RbNode *ps3RbTreeFindNode(struct Ps3RbTree *pTree, + void *pKey) { - return ps3RbtFindNode(&pTree->root, pKey, &pTree->ops); + return ps3RbtFindNode(&pTree->root, pKey, &pTree->ops); } -static inline Ps3RbNode_s* ps3RbTreeFindNextNode(Ps3RbTree_s *pTree, - void *pKey) +static inline struct Ps3RbNode *ps3RbTreeFindNextNode(struct Ps3RbTree *pTree, + void *pKey) { - return ps3RbtFindNextNode(&pTree->root, pKey, &pTree->ops); + return ps3RbtFindNextNode(&pTree->root, pKey, &pTree->ops); } -static inline void ps3RbTreeClean(Ps3RbTree_s *pTree) +static inline void ps3RbTreeClean(struct Ps3RbTree *pTree) { - ps3RbtClean(&pTree->root); - pTree->nodenr = 0; + ps3RbtClean(&pTree->root); + pTree->nodenr = 0; } -static inline S32 ps3RbTreeTraverse(Ps3RbTree_s *pTree, - ps3RbtreeVisitFunc visit, void *pCtxt) +static inline int ps3RbTreeTraverse(struct Ps3RbTree *pTree, + int (*visit)(struct Ps3RbNode *pNode, + void *pCtxt), + void *pCtxt) { - return ps3RbtTraverse(&pTree->root, visit, pCtxt); + return ps3RbtTraverse(&pTree->root, visit, pCtxt); } -static inline Bool ps3RbTreeIsEmpty(Ps3RbTree_s *pTree) +static inline unsigned char ps3RbTreeIsEmpty(struct Ps3RbTree *pTree) { - return (Bool)(pTree->root.pRoot == NULL); + return (unsigned char)(pTree->root.pRoot == NULL); } -static inline U32 ps3RbTreeNodeNr(Ps3RbTree_s *pTree) +static inline unsigned int ps3RbTreeNodeNr(struct Ps3RbTree *pTree) { - return pTree->nodenr; + return pTree->nodenr; } -#define RBT_RED (0) -#define RBT_BLACK (1) - -#define RBT_PARENT(_n) ((Ps3RbNode_s*)(uintptr_t)((_n)->pParentColor & ~3ULL)) -#define RBT_COLOR(_n) ((_n)->pParentColor & 1ULL) - -#define RBT_IS_RED(_n) (!RBT_COLOR(_n)) -#define RBT_IS_BLACK(_n) RBT_COLOR(_n) -#define RBT_SET_RED(_n) \ - do { (_n)->pParentColor &= ~1ULL; } while (0) -#define RBT_SET_BLACK(_n) \ - do { (_n)->pParentColor |= 1ULL; } while (0) - -#define RBT_ROOT_IS_EMPTY(_r) ((_r)->pRoot == NULL) -#define RBT_TREE_IS_EMPTY(_t) RBT_ROOT_IS_EMPTY(&(_t)->root) -#define RBT_NODE_IS_EMPTY(_n) (RBT_PARENT(_n) == (_n)) -#define RBT_NODE_CLEAR(_n) do { ps3RbNodeInit(_n); } while (0) - -#define RBT_FOR_EACH(_p_node, _p_root) \ - for (_p_node = ps3RbtHeadNode(_p_root); \ - _p_node != NULL; \ - _p_node = ps3RbtNextNode(_p_node)) - -#define RBT_FOR_EACH_SAFE(_p_node, _p_next, _p_root) \ - for (_p_node = ps3RbtHeadNode(_p_root), \ - _p_next = ps3RbtNextNode(_p_node); \ - _p_node != NULL; \ - _p_node = _p_next, \ - _p_next = ps3RbtNextNode(_p_node)) - -#define RBTREE_FOR_EACH(_p_node, _p_tree) \ - RBT_FOR_EACH((_p_node), &(_p_tree)->root) - -#define RBTREE_FOR_EACH_SAFE(_p_node, _p_next, _p_tree) \ - RBT_FOR_EACH_SAFE((_p_node), (_p_next), &(_p_tree)->root) +#define RBT_RED (0) +#define RBT_BLACK (1) + +#define RBT_PARENT(_n) \ + ((struct Ps3RbNode *)(uintptr_t)((_n)->pParentColor & ~3ULL)) +#define RBT_COLOR(_n) ((_n)->pParentColor & 1ULL) + +#define RBT_IS_RED(_n) (!RBT_COLOR(_n)) +#define RBT_IS_BLACK(_n) RBT_COLOR(_n) +#define RBT_SET_RED(_n) ((_n)->pParentColor &= ~1ULL) +#define RBT_SET_BLACK(_n) ((_n)->pParentColor |= 1ULL) +#define RBT_ROOT_IS_EMPTY(_r) ((_r)->pRoot == NULL) +#define RBT_TREE_IS_EMPTY(_t) RBT_ROOT_IS_EMPTY(&(_t)->root) +#define RBT_NODE_IS_EMPTY(_n) (RBT_PARENT(_n) == (_n)) +#define RBT_NODE_CLEAR(_n) (ps3RbNodeInit(_n)) +#define RBT_FOR_EACH(_p_node, _p_root) \ + for (_p_node = ps3RbtHeadNode(_p_root); _p_node != NULL; \ + _p_node = ps3RbtNextNode(_p_node)) + +#define RBT_FOR_EACH_SAFE(_p_node, _p_next, _p_root) \ + for (_p_node = ps3RbtHeadNode(_p_root), \ + _p_next = ps3RbtNextNode(_p_node); \ + _p_node != NULL; \ + _p_node = _p_next, _p_next = ps3RbtNextNode(_p_node)) + +#define RBTREE_FOR_EACH(_p_node, _p_tree) \ + RBT_FOR_EACH((_p_node), &(_p_tree)->root) + +#define RBTREE_FOR_EACH_SAFE(_p_node, _p_next, _p_tree) \ + RBT_FOR_EACH_SAFE((_p_node), (_p_next), &(_p_tree)->root) #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_recovery.c b/drivers/scsi/linkdata/ps3stor/ps3_recovery.c index ab5bc3bbabac..5103707c602b 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_recovery.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_recovery.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #include "ps3_recovery.h" #ifndef _WINDOWS @@ -23,66 +23,72 @@ #include "ps3_ioctl.h" #include "ps3_dump.h" #include "ps3_cli_debug.h" -S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance); +#include "ps3_kernel_version.h" + +int ps3_recovery_cancel_work_sync(struct ps3_instance *instance); #ifndef _WINDOWS -static void ps3_recovery_work(struct work_struct* work); +static void ps3_recovery_work(struct work_struct *work); #else static void ps3_recovery_work(void *work); #endif -static S32 ps3_hard_recovery_handle(struct ps3_instance *instance); -static S32 ps3_soft_recovery_handle(struct ps3_instance *instance); -static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance); -static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance); -static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cmds); -static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, U8 reset_flag); -static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance); +static int ps3_hard_recovery_handle(struct ps3_instance *instance); +static int ps3_soft_recovery_handle(struct ps3_instance *instance); +static int ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance); +static int ps3_recovery_ready_to_running(struct ps3_instance *instance); +static void ps3_can_queue_reset(struct ps3_instance *instance, + unsigned int cur_max_fw_cmds); +static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, + unsigned char reset_flag); +static int +ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance); enum { PS3_RECOVERY_INTER_ERR_SUCCESS = 0, - PS3_RECOVERY_INTER_ERR_INTERRUPT = 1, - PS3_RECOVERY_INTER_ERR_FAILED = 2, - PS3_RECOVERY_INTER_ERR_NEED_RECOVERY = 3, - PS3_RECOVERY_INTER_ERR_PCIE_ERR = 4, - PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME = 5, + PS3_RECOVERY_INTER_ERR_INTERRUPT = 1, + PS3_RECOVERY_INTER_ERR_FAILED = 2, + PS3_RECOVERY_INTER_ERR_NEED_RECOVERY = 3, + PS3_RECOVERY_INTER_ERR_PCIE_ERR = 4, + PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME = 5, }; -static inline void ps3_wait_watchdog_dect_recovery( - struct ps3_instance *instance) +static inline void +ps3_wait_watchdog_dect_recovery(struct ps3_instance *instance) { - U16 wait_step = 100; - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + unsigned short wait_step = 100; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; - while(!instance->watchdog_context.is_halt && - instance->watchdog_context.watchdog_queue != NULL) { + while (!instance->watchdog_context.is_halt && + instance->watchdog_context.watchdog_queue != NULL) { ps3_msleep(wait_step); - if (printed && ((++cur_cnt) * wait_step > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * wait_step > + PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait watchdog recovery.\n", PS3_HOST(instance)); + LOG_WARN("host:%u wait watchdog recovery.\n", + PS3_HOST(instance)); } } } -struct ps3_recovery_context *ps3_recovery_context_alloc(void) +static struct ps3_recovery_context *ps3_recovery_context_alloc(void) { struct ps3_recovery_context *context; - context = (struct ps3_recovery_context *)kzalloc(sizeof(struct ps3_recovery_context), GFP_KERNEL); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, &context) + context = (struct ps3_recovery_context *)kzalloc(sizeof(struct ps3_recovery_context), + GFP_KERNEL); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_ALLOC_FAIL, &context); if (!context) return NULL; return context; } -void ps3_recovery_context_free(struct ps3_recovery_context *context) +static void ps3_recovery_context_free(struct ps3_recovery_context *context) { - if (context != NULL) { + if (context != NULL) kfree(context); - } - return; } -void ps3_recovery_context_delete(struct ps3_recovery_context *context) +static void ps3_recovery_context_delete(struct ps3_recovery_context *context) { if (context != NULL) { if (context->recovery_wq) { @@ -92,34 +98,39 @@ void ps3_recovery_context_delete(struct ps3_recovery_context *context) kfree(context); context = NULL; } - return; } #ifndef _WINDOWS -static void ps3_recovery_irq_service(struct work_struct* work) +static void ps3_recovery_irq_service(struct work_struct *work) { struct ps3_instance *instance = - ps3_container_of(work, struct ps3_instance, - recovery_irq_work); - S32 ret = PS3_SUCCESS; - U32 count = 0; - LOG_INFO("hno:%u recovery irq triggered\n", - PS3_HOST(instance)); + ps3_container_of(work, struct ps3_instance, recovery_irq_work); + int ret = PS3_SUCCESS; + unsigned int count = 0; + + LOG_INFO("hno:%u recovery irq triggered\n", PS3_HOST(instance)); - if ((instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE || - instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY) - &&(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + if ((instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_DECIDE || + instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_RECOVERY) && + (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { goto l_out; } - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_NULL) { + ps3_mutex_lock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_NULL) { instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_DECIDE; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { + ps3_mutex_unlock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); + while ((ret = ps3_hard_recovery_request(instance, PS3_FALSE)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { ret = -PS3_FAILED; break; @@ -127,40 +138,40 @@ static void ps3_recovery_irq_service(struct work_struct* work) ps3_mdelay(10); } if (ret == PS3_SUCCESS) { - LOG_INFO("hno[%u], recovery success!\n", - PS3_HOST(instance)); - }else{ + LOG_INFO("hno[%u], recovery success!\n", PS3_HOST(instance)); + } else { LOG_ERROR("hno[%u], recovery request NOK, %s!\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state))); } l_out: return; } -S32 ps3_recovery_irq_start(struct ps3_instance *instance) +int ps3_recovery_irq_start(struct ps3_instance *instance) { - S8 request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENTH]; - struct work_struct* recovery_irq_work = &instance->recovery_irq_work; + char request_irq_queue_name[PS3_RECOVERY_IRQ_NAME_MAX_LENGTH]; + struct work_struct *recovery_irq_work = &instance->recovery_irq_work; - INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE, instance) + INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE, instance); if (instance->recovery_irq_queue != NULL) { LOG_DEBUG("hno:%u watchdog for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENTH); + memset(request_irq_queue_name, 0, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH); INIT_WORK(recovery_irq_work, ps3_recovery_irq_service); - snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENTH, - "ps3_irq_recovery_start_service_host%d", instance->host->host_no); + snprintf(request_irq_queue_name, PS3_RECOVERY_IRQ_NAME_MAX_LENGTH, + "ps3_irq_recov%d", instance->host->host_no); instance->recovery_irq_queue = create_singlethread_workqueue(request_irq_queue_name); if (instance->recovery_irq_queue == NULL) { LOG_ERROR("hno:%u watchdog work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_FAILED; } instance->recovery_irq_enable = PS3_TRUE; @@ -168,55 +179,53 @@ S32 ps3_recovery_irq_start(struct ps3_instance *instance) return PS3_SUCCESS; } -irqreturn_t ps3_recovery_irq_handler(S32 virq, void *dev_id) +irqreturn_t ps3_recovery_irq_handler(int virq, void *dev_id) { struct ps3_irq_recovery *irq = (struct ps3_irq_recovery *)dev_id; struct ps3_instance *instance = irq->instance; - if (instance->ioc_adpter->ioc_heartbeat_detect == NULL) { + if (instance->ioc_adpter->ioc_heartbeat_detect == NULL) goto l_out; - } - - if (instance->ioc_adpter->ioc_heartbeat_detect(instance) == PS3_TRUE - && !ps3_pci_err_recovery_get(instance) - && instance->recovery_irq_enable) { + if (instance->ioc_adpter->ioc_heartbeat_detect(instance) == PS3_TRUE && + !ps3_pci_err_recovery_get(instance) && + instance->recovery_irq_enable) { - LOG_DEBUG("hno:%u recovery irq recieved, virq: %d, dev_id: 0x%llx\n", - PS3_HOST(instance), virq, (U64)dev_id); + LOG_DEBUG( + "hno:%u recovery irq received, virq: %d, dev_id: 0x%llx\n", + PS3_HOST(instance), virq, + (unsigned long long)(uintptr_t)dev_id); if (!work_busy(&instance->recovery_irq_work)) { - queue_work(instance->recovery_irq_queue, &instance->recovery_irq_work); + queue_work(instance->recovery_irq_queue, + &instance->recovery_irq_work); } } l_out: return IRQ_HANDLED; } -void ps3_recovery_irq_queue_destory(struct ps3_instance *instance) +static void ps3_recovery_irq_queue_destroy(struct ps3_instance *instance) { if (instance->recovery_irq_queue) { flush_workqueue(instance->recovery_irq_queue); destroy_workqueue(instance->recovery_irq_queue); instance->recovery_irq_queue = NULL; } - return; } -void ps3_recovery_work_queue_destory(struct ps3_instance *instance) +void ps3_recovery_work_queue_destroy(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; - struct workqueue_struct* wq = context->recovery_wq; + struct workqueue_struct *wq = context->recovery_wq; if (!ps3_is_latest_func(instance)) { - LOG_DEBUG("hno:%u not latest func\n", - PS3_HOST(instance)); - goto l_out; + LOG_DEBUG("hno:%u not latest func\n", PS3_HOST(instance)); + goto l_out; } context->recovery_wq = NULL; - if (wq == NULL) { + if (wq == NULL) return; - } flush_workqueue(wq); destroy_workqueue(wq); @@ -227,28 +236,36 @@ void ps3_recovery_work_queue_destory(struct ps3_instance *instance) void ps3_recovery_function_init(struct ps3_instance *instance) { instance->recovery_function.halt_handle_cb = NULL; - instance->recovery_function.hardreset_handle_init_running_cb = ps3_hardreset_handle_init_running; - instance->recovery_function.hardreset_handle_post_cb = ps3_hardreset_handle_post; - instance->recovery_function.hardreset_handle_pre_cb = ps3_hardreset_handle_pre; - instance->recovery_function.hardreset_handle_wait_ready_cb = ps3_hardreset_handle_wait_ready; - instance->recovery_function.hardreset_handle_finish_cb = ps3_hardreset_handle_finish; - instance->recovery_function.hardreset_handle_offline_cb = ps3_hardreset_handle_offline; + instance->recovery_function.hardreset_handle_init_running_cb = + ps3_hardreset_handle_init_running; + instance->recovery_function.hardreset_handle_post_cb = + ps3_hardreset_handle_post; + instance->recovery_function.hardreset_handle_pre_cb = + ps3_hardreset_handle_pre; + instance->recovery_function.hardreset_handle_wait_ready_cb = + ps3_hardreset_handle_wait_ready; + instance->recovery_function.hardreset_handle_finish_cb = + ps3_hardreset_handle_finish; + instance->recovery_function.hardreset_handle_offline_cb = + ps3_hardreset_handle_offline; instance->recovery_function.recovery_handle_cb = NULL; - instance->recovery_function.softreset_handle_post_cb = ps3_softreset_handle_post; - instance->recovery_function.softreset_handle_pre_cb = ps3_softreset_handle_pre; + instance->recovery_function.softreset_handle_post_cb = + ps3_softreset_handle_post; + instance->recovery_function.softreset_handle_pre_cb = + ps3_softreset_handle_pre; - return; } -S32 ps3_recovery_context_init(struct ps3_instance *instance) +int ps3_recovery_context_init(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_recovery_context *context = NULL; ps3_recovery_function_init(instance); if (instance->peer_instance != NULL) { - instance->recovery_context = instance->peer_instance->recovery_context; + instance->recovery_context = + instance->peer_instance->recovery_context; goto l_recovery_irq_init; } @@ -256,18 +273,19 @@ S32 ps3_recovery_context_init(struct ps3_instance *instance) INJECT_START(PS3_ERR_RECOVERY_CONTEXT_ALLOC_FAILED, &context); if (context == NULL) { LOG_ERROR("hno:%u, alloc recovery context failed !\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } LOG_DEBUG("recovery context add!\n"); snprintf(context->recovery_wq_name, 20, "ps3_rec_th_%d", - instance->host->host_no); + instance->host->host_no); context->recovery_wq = create_singlethread_workqueue(context->recovery_wq_name); if (context->recovery_wq == NULL) { - LOG_ERROR("hno:%u create recovery_wq NOK !\n", PS3_HOST(instance)); + LOG_ERROR("hno:%u create recovery_wq NOK !\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -287,15 +305,14 @@ S32 ps3_recovery_context_init(struct ps3_instance *instance) l_recovery_irq_init: if (ps3_recovery_irq_start(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u recovery irq NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u recovery irq NOK\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_recovery_start_failed; } return ret; l_recovery_start_failed: - ps3_recovery_irq_queue_destory(instance); + ps3_recovery_irq_queue_destroy(instance); ps3_mutex_destroy(&context->ps3_watchdog_recovery_mutex); ps3_mutex_destroy(&context->free_cmd_lock); instance->recovery_context = NULL; @@ -307,9 +324,9 @@ S32 ps3_recovery_context_init(struct ps3_instance *instance) void ps3_recovery_clean(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; - if(context == NULL) { + + if (context == NULL) goto l_out; - } if (!ps3_is_latest_func(instance)) { instance->recovery_context = NULL; @@ -321,50 +338,48 @@ void ps3_recovery_clean(struct ps3_instance *instance) ps3_recovery_context_free(instance->recovery_context); instance->recovery_context = NULL; l_out: - return ; + return; } -void ps3_recovery_destory(struct ps3_instance *instance) +void ps3_recovery_destroy(struct ps3_instance *instance) { #ifndef _WINDOWS ps3_recovery_cancel_work_sync(instance); - ps3_recovery_work_queue_destory(instance); + ps3_recovery_work_queue_destroy(instance); #else struct ps3_recovery_context *context = instance->recovery_context; + ps3_worker_exit(&context->recovery_work); #endif - return ; } void ps3_recovery_context_exit(struct ps3_instance *instance) { - ps3_recovery_irq_queue_destory(instance); + ps3_recovery_irq_queue_destroy(instance); if (instance->peer_instance == NULL && - instance->recovery_context != NULL) { - ps3_recovery_destory(instance); + instance->recovery_context != NULL) { + ps3_recovery_destroy(instance); ps3_recovery_clean(instance); } - return ; } -S32 ps3_recovery_state_transfer(struct ps3_instance *instance, - U32 dest_state) +static int ps3_recovery_state_transfer(struct ps3_instance *instance, + unsigned int dest_state) { - U32 recovery_origin_state; + unsigned int recovery_origin_state; ps3_mutex_lock(&instance->state_machine.lock); recovery_origin_state = instance->recovery_context->recovery_state; - if (recovery_origin_state == dest_state) { + if (recovery_origin_state == dest_state) goto l_fail; - } - switch(recovery_origin_state) { + switch (recovery_origin_state) { case PS3_SOFT_RECOVERY_PROBE_PROCESS: if (dest_state == PS3_SOFT_RECOVERY_SHALLOW || - dest_state == PS3_SOFT_RECOVERY_DEEP || - dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY || - dest_state == PS3_HARD_RECOVERY_DECIDE) { + dest_state == PS3_SOFT_RECOVERY_DEEP || + dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY || + dest_state == PS3_HARD_RECOVERY_DECIDE) { goto l_success; } else { goto l_fail; @@ -374,8 +389,8 @@ S32 ps3_recovery_state_transfer(struct ps3_instance *instance, case PS3_SOFT_RECOVERY_DEEP: case PS3_SOFT_RECOVERY_IOC_RECOVERY: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW)|| - (dest_state == PS3_SOFT_RECOVERY_FINISH)) { + (dest_state == PS3_HARD_RECOVERY_SHALLOW) || + (dest_state == PS3_SOFT_RECOVERY_FINISH)) { goto l_success; } else { goto l_fail; @@ -383,10 +398,10 @@ S32 ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_SOFT_RECOVERY_FINISH: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || - (dest_state == PS3_SOFT_RECOVERY_DEEP) || - (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { + (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || + (dest_state == PS3_SOFT_RECOVERY_DEEP) || + (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || + (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { goto l_success; } else { goto l_fail; @@ -394,7 +409,7 @@ S32 ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_HARD_RECOVERY_DECIDE: if (dest_state == PS3_HARD_RECOVERY_SHALLOW || - dest_state == PS3_HARD_RECOVERY_FINISH) { + dest_state == PS3_HARD_RECOVERY_FINISH) { goto l_success; } else { goto l_fail; @@ -402,21 +417,20 @@ S32 ps3_recovery_state_transfer(struct ps3_instance *instance, break; case PS3_HARD_RECOVERY_FINISH: if ((dest_state == PS3_HARD_RECOVERY_DECIDE) || - (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || - (dest_state == PS3_SOFT_RECOVERY_DEEP) || - (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || - (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { + (dest_state == PS3_SOFT_RECOVERY_SHALLOW) || + (dest_state == PS3_SOFT_RECOVERY_DEEP) || + (dest_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) || + (dest_state == PS3_HARD_RECOVERY_SHALLOW)) { goto l_success; } else { goto l_fail; } break; case PS3_HARD_RECOVERY_SHALLOW: - if (dest_state == PS3_HARD_RECOVERY_FINISH) { + if (dest_state == PS3_HARD_RECOVERY_FINISH) goto l_success; - } else { + else goto l_fail; - } break; default: goto l_fail; @@ -424,28 +438,26 @@ S32 ps3_recovery_state_transfer(struct ps3_instance *instance, l_fail: ps3_mutex_unlock(&instance->state_machine.lock); - LOG_ERROR("hno:%u recovery state transfer NOK!" - "[cur_state:%d][dest_state:%d]\n", - PS3_HOST(instance), - recovery_origin_state,dest_state); + LOG_ERROR("hno:%u recovery state transfer NOK! [cur_state:%d][dest_state:%d]\n", + PS3_HOST(instance), recovery_origin_state, dest_state); return -PS3_FAILED; l_success: instance->recovery_context->recovery_state = dest_state; ps3_mutex_unlock(&instance->state_machine.lock); LOG_FILE_INFO("hno:%u recovery state transfer from %d to %d!\n", - PS3_HOST(instance), - recovery_origin_state,dest_state); + PS3_HOST(instance), recovery_origin_state, dest_state); return PS3_SUCCESS; } #ifndef _WINDOWS -static S32 ps3_recovery_work_start(struct ps3_instance *instance) +static int ps3_recovery_work_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; - INJECT_START(PS3_ERR_IJ_FORCE_START_DESTORY_RECOVERY, instance) + + INJECT_START(PS3_ERR_IJ_FORCE_START_DESTROY_RECOVERY, instance); if (unlikely(context->recovery_wq == NULL)) { ret = -PS3_FAILED; @@ -458,31 +470,36 @@ static S32 ps3_recovery_work_start(struct ps3_instance *instance) l_out: return ret; } - static inline void ps3_wait_hard_reset_finish(struct ps3_instance *instance) +static inline void ps3_wait_hard_reset_finish(struct ps3_instance *instance) { - while(ps3_atomic_read(&instance->recovery_context->hardreset_ref) != 0){ + while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) != + 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); } - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - do{ + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + do { ps3_msleep(100); - if (likely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + if (likely(instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { continue; } else { - cancel_work_sync(&instance->recovery_context->recovery_work); + ps3_cancel_work_sync(&instance->recovery_context + ->recovery_work); break; } - }while(1); + } while (1); } else { - cancel_work_sync(&instance->recovery_context->recovery_work); + ps3_cancel_work_sync(&instance->recovery_context->recovery_work); } } -S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance) +int ps3_recovery_cancel_work_sync(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; + if (unlikely(context->recovery_wq == NULL)) { ret = -PS3_FAILED; goto l_out; @@ -494,34 +511,44 @@ S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance) return ret; } -static S32 ps3_recovery_start(struct ps3_instance *instance) +static int ps3_recovery_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + + INJECT_START(PS3_ERR_IJ_RECOVERY_STATE_SHALLOW, instance) ps3_mutex_lock(&instance->state_machine.lock); - INJECT_START(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, instance) - if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ + INJECT_START(PS3_ERR_IJ_FORCE_START_DUL_RECOVERY, instance); + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW) { LOG_ERROR("hno:%u hard recovery work proc,exit!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - INJECT_START(PS3_ERR_IJ_FORCE_DESTORY_RECOVERY, instance) + INJECT_START(PS3_ERR_IJ_FORCE_DESTROY_RECOVERY, instance); if (unlikely(instance->recovery_context->recovery_wq == NULL)) { ret = -PS3_FAILED; + ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); LOG_ERROR("hno:%u recovery work sync NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - cancel_work_sync(&instance->recovery_context->recovery_work); + ps3_cancel_work_sync(&instance->recovery_context->recovery_work); ps3_mutex_lock(&instance->state_machine.lock); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) - if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { - LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance); + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + if (ps3_instance_no_lock_state_transfer( + instance, PS3_INSTANCE_STATE_RECOVERY) != + PS3_SUCCESS) { + LOG_ERROR( + "hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", PS3_HOST(instance)); + instance->recovery_context->recovery_state = + PS3_HARD_RECOVERY_FINISH; ret = -PS3_FAILED; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; @@ -531,13 +558,22 @@ static S32 ps3_recovery_start(struct ps3_instance *instance) if (instance->peer_instance != NULL) { ps3_mutex_lock(&instance->peer_instance->state_machine.lock); - if(instance->peer_instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, instance->peer_instance) - if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { - LOG_ERROR("hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", + if (instance->peer_instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_STATE_DEAD, + instance->peer_instance); + if (ps3_instance_no_lock_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_RECOVERY) != + PS3_SUCCESS) { + LOG_ERROR( + "hno:%u transfer to PS3_INSTANCE_STATE_RECOVERY NOK!\n", PS3_HOST(instance->peer_instance)); + instance->recovery_context->recovery_state = + PS3_HARD_RECOVERY_FINISH; ret = -PS3_FAILED; - ps3_mutex_unlock(&instance->peer_instance->state_machine.lock); + ps3_mutex_unlock(&instance->peer_instance + ->state_machine.lock); goto l_out; } } @@ -547,19 +583,21 @@ static S32 ps3_recovery_start(struct ps3_instance *instance) ret = ps3_recovery_work_start(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u recovery work start NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } l_out: return ret; } #else -static S32 ps3_recovery_start(struct ps3_instance *instance) +static int ps3_recovery_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - struct ps3_recovery_context* context = instance->recovery_context; + int ret = PS3_SUCCESS; + struct ps3_recovery_context *context = instance->recovery_context; + if (ps3_worker_start(&context->recovery_work) != PS3_SUCCESS) { - LOG_ERROR("trace_id[0x%llx], hno:%u recovery start worker failed\n", + LOG_ERROR( + "trace_id[0x%llx], hno:%u recovery start worker failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; @@ -569,45 +607,47 @@ static S32 ps3_recovery_start(struct ps3_instance *instance) } #endif -static Bool ps3_recovery_is_state_halt(struct ps3_instance *instance) +static unsigned char ps3_recovery_is_state_halt(struct ps3_instance *instance) { - Bool ret = PS3_FALSE; - struct ps3_instance_state_machine *state_machine - = &instance->state_machine; - U32 cur_state = 0; - U32 ioc_state = instance->ioc_adpter->ioc_state_get(instance); + unsigned char ret = PS3_FALSE; + struct ps3_instance_state_machine *state_machine = + &instance->state_machine; + unsigned int cur_state = 0; + unsigned int ioc_state = instance->ioc_adpter->ioc_state_get(instance); cur_state = ps3_atomic_read(&state_machine->state); if (cur_state == PS3_INSTANCE_STATE_DEAD) { - LOG2_INFO_LIM("hno:%u ioc_state:%s, " - "drv_state:PS3_INSTANCE_STATE_DEAD, stop recovery!\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state)); + LOG2_INFO_LIM( + "hno:%u ioc_state:%s, drv_state:PS3_INSTANCE_STATE_DEAD, stop recovery!\n", + PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); ret = PS3_TRUE; goto l_out; } + INJECT_START(PS3_ERR_IJ_RECOVERY_HALT_BREAK, instance) if (ioc_state == PS3_FW_STATE_HALT && - instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { + instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_DECIDE) { ps3_atomic_set(&state_machine->state, PS3_INSTANCE_STATE_DEAD); - LOG2_INFO_LIM("hno:%u ioc_state:PS3_FW_STATE_HALT, stop recovery!\n", + LOG2_INFO_LIM( + "hno:%u ioc_state:PS3_FW_STATE_HALT, stop recovery!\n", PS3_HOST(instance)); - while(1) { + while (1) ps3_msleep(10); - } ret = PS3_TRUE; goto l_out; } + INJECT_START(PS3_ERR_IJ_RECOVERY_HALT_BREAK_1, instance) if (PS3_IOC_STATE_HALT_SUPPORT(instance) && - instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_DECIDE) { + instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_DECIDE) { instance->ioc_adpter->ioc_force_to_halt(instance); ps3_atomic_set(&state_machine->state, PS3_INSTANCE_STATE_DEAD); LOG_WARN("hno:%u IOC support HALT, enter HALT!\n", - PS3_HOST(instance)); - while(1) { + PS3_HOST(instance)); + while (1) ps3_msleep(10); - } ret = PS3_TRUE; } l_out: @@ -615,74 +655,100 @@ static Bool ps3_recovery_is_state_halt(struct ps3_instance *instance) return ret; } -static inline S32 ps3_hard_recovery_request_decide( - struct ps3_instance *instance, U32 cur_state, U32 peer_cur_state) +static inline int +ps3_hard_recovery_request_decide(struct ps3_instance *instance, + unsigned int cur_state, + unsigned int peer_cur_state) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { LOG_INFO("hno:%u instance state during hard recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } if ((cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (cur_state == PS3_INSTANCE_STATE_DEAD) || - (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || - (cur_state == PS3_INSTANCE_STATE_INIT)) { + (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (cur_state == PS3_INSTANCE_STATE_DEAD) || + (cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || + (cur_state == PS3_INSTANCE_STATE_INIT)) { if (instance->is_need_event) { - if(instance->event_context.event_abort_cmd != NULL){ - complete(&instance->event_context.event_abort_cmd->sync_done); - } else if (instance->dev_context.vdpending_abort_cmd != NULL){ - complete(&instance->dev_context.vdpending_abort_cmd->sync_done); - } else if (instance->webSubscribe_context.web_abort_cmd != NULL){ - complete(&instance->webSubscribe_context.web_abort_cmd->sync_done); - } + if (instance->event_context.event_abort_cmd != NULL) { + complete(&instance->event_context + .event_abort_cmd->sync_done); + } else if (instance->dev_context.vdpending_abort_cmd != + NULL) { + complete(&instance->dev_context + .vdpending_abort_cmd + ->sync_done); + } else if (instance->webSubscribe_context + .web_abort_cmd != NULL) { + complete(&instance->webSubscribe_context + .web_abort_cmd->sync_done); + } } if (instance->peer_instance == NULL) { - instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_DECIDE; + instance->recovery_context->recovery_state = + PS3_HARD_RECOVERY_DECIDE; LOG_INFO("hno:%u instance state to recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } } else { LOG_INFO("hno:%u instance state during hard recovery!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } if (instance->peer_instance != NULL) { - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL,\ - &peer_cur_state) + INJECT_START( + PS3_ERR_IJ_FORCE_RECOVERY_DECIDE_PEER_INSTANCE_FAIL, + &peer_cur_state); if ((peer_cur_state == PS3_INSTANCE_STATE_OPERATIONAL) || - (peer_cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || - (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || - (peer_cur_state == PS3_INSTANCE_STATE_DEAD) || - (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || - (peer_cur_state == PS3_INSTANCE_STATE_INIT)) { + (peer_cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) || + (peer_cur_state == PS3_INSTANCE_STATE_PRE_OPERATIONAL) || + (peer_cur_state == PS3_INSTANCE_STATE_DEAD) || + (peer_cur_state == PS3_INSTANCE_STATE_PCIE_RECOVERY) || + (peer_cur_state == PS3_INSTANCE_STATE_INIT)) { if (instance->peer_instance->is_need_event) { - if(instance->peer_instance->event_context.event_abort_cmd != NULL){ - complete(&instance->peer_instance->event_context.event_abort_cmd->sync_done); - } else if (instance->peer_instance->dev_context.vdpending_abort_cmd != NULL){ - complete(&instance->peer_instance->dev_context.vdpending_abort_cmd->sync_done); - } else if (instance->webSubscribe_context.web_abort_cmd != NULL){ - complete(&instance->webSubscribe_context.web_abort_cmd->sync_done); - } + if (instance->peer_instance->event_context + .event_abort_cmd != NULL) { + complete(&instance->peer_instance + ->event_context + .event_abort_cmd + ->sync_done); + } else if (instance->peer_instance->dev_context + .vdpending_abort_cmd != + NULL) { + complete(&instance->peer_instance + ->dev_context + .vdpending_abort_cmd + ->sync_done); + } else if (instance->webSubscribe_context + .web_abort_cmd != NULL) { + complete(&instance->webSubscribe_context + .web_abort_cmd + ->sync_done); + } } - instance->peer_instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_DECIDE; + instance->peer_instance->recovery_context + ->recovery_state = PS3_HARD_RECOVERY_DECIDE; LOG_INFO("hno:%u instance state to recovery!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } else { - LOG_INFO("hno:%u instance state during hard recovery!\n", + LOG_INFO( + "hno:%u instance state during hard recovery!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; } @@ -691,125 +757,161 @@ static inline S32 ps3_hard_recovery_request_decide( return ret; } -static S32 ps3_hard_recovery_request_prepare(struct ps3_instance *instance) +static int ps3_hard_recovery_request_prepare(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 ioc_state = 0; - struct ps3_instance_state_machine *state_machine - = &instance->state_machine; - U32 cur_state = 0; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int ioc_state = 0; + struct ps3_instance_state_machine *state_machine = + &instance->state_machine; + unsigned int cur_state = 0; struct ps3_instance_state_machine *state_machine_peer = NULL; - U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; - INJECT_START(PS3_ERR_IJ_PCIE_FROZEN, instance) - if (instance->reg_set == NULL) { + unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + + INJECT_START(PS3_ERR_IJ_PCIE_FROZEN, instance); + if (instance->reg_set == NULL) return ret; - } ioc_state = instance->ioc_adpter->ioc_state_get(instance); ps3_mutex_lock(&state_machine->lock); cur_state = ps3_atomic_read(&state_machine->state); - LOG_INFO("hno:%u hard recovery request:%s, %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u hard recovery request:%s, %s\n", PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), + namePS3InstanceState(cur_state)); if (instance->peer_instance != NULL) { state_machine_peer = &instance->peer_instance->state_machine; - INJECT_START(PS3_ERR_IJ_PEER_PCIE_FROZEN, instance->peer_instance) - if (instance->peer_instance->reg_set == NULL) { + INJECT_START(PS3_ERR_IJ_PEER_PCIE_FROZEN, + instance->peer_instance); + if (instance->peer_instance->reg_set == NULL) goto l_clean; - } - ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance->peer_instance); + ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get( + instance->peer_instance); ps3_mutex_lock(&state_machine_peer->lock); peer_cur_state = ps3_atomic_read(&state_machine_peer->state); LOG_INFO("hno:%u hard recovery request:%s, %s\n", - PS3_HOST(instance->peer_instance), - ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance->peer_instance), + ps3_ioc_state_print(ioc_state), + namePS3InstanceState(peer_cur_state)); } - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + ps3_mutex_lock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_INFO("hno:%u heartbeat hard recovery start\n", - PS3_HOST(instance)); - instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; + PS3_HOST(instance)); + instance->recovery_context->heartbeat_recovery = + PS3_HEARTBEAT_HARDRESET_RECOVERY; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); goto l_out; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); l_out: - if (instance->peer_instance != NULL) { + if (instance->peer_instance != NULL) ps3_mutex_unlock(&state_machine_peer->lock); - } l_clean: ps3_mutex_unlock(&state_machine->lock); return ret; } -S32 ps3_hard_recovery_request(struct ps3_instance *instance) +int ps3_hard_recovery_request(struct ps3_instance *instance, + unsigned char is_host_reset) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_instance *instance_recovery = NULL; - LOG_WARN("hno:%u ps3 hard recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), + LOG_WARN( + "hno:%u ps3 hard recovery request start, IOC outstanding: %d!!\n", + PS3_HOST(instance), ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); - - INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) + mb(); /* in order to force CPU ordering */ + + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, + &instance->recovery_context->instance_change); if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } - INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) - INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_3, instance); + if (!ps3_host_reset_state_check(instance, is_host_reset)) { + LOG_WARN_LIM("hno[%u], recovery request during host reset\n", + PS3_HOST(instance)); + ret = -PS3_RETRY; + goto l_out; + } + + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance); while (instance->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - - INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY, instance) - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY, instance); + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; goto l_out; } - - INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) + + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, + &instance->recovery_context->instance_change); if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_PENDING; } - INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance); ps3_atomic_dec(&instance->recovery_context->hardreset_ref); ps3_msleep(10); - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { - ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { + ps3_atomic_inc( + &instance->recovery_context->hardreset_ref); + mb(); /* in order to force CPU ordering */ + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; break; } ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); + mb(); /* in order to force CPU ordering */ } - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; } - LOG_INFO("hno:%u peer_instance[%p], hard recovery request Function[%d]\n", - PS3_HOST(instance), instance->peer_instance, ps3_get_pci_function(instance->pdev)); + LOG_INFO( + "hno:%u peer_instance[%p], hard recovery request Function[%d]\n", + PS3_HOST(instance), instance->peer_instance, + ps3_get_pci_function(instance->pdev)); if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0 || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && instance->peer_instance == NULL)) { + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && + instance->peer_instance == NULL)) { instance_recovery = instance; } else { instance_recovery = instance->peer_instance; @@ -817,14 +919,15 @@ S32 ps3_hard_recovery_request(struct ps3_instance *instance) if (ps3_recovery_is_state_halt(instance_recovery)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = -PS3_FAILED; goto l_out; } - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery)) || \ - (!ps3_hard_reset_enable_query())) { - LOG_ERROR("hno:%u soc feature unsupport Hard reset[%d] or unable[%d]!!\n", + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery)) || + (!ps3_hard_reset_enable_query())) { + LOG_ERROR( + "hno:%u soc feature unsupport Hard reset[%d] or unable[%d]!!\n", PS3_HOST(instance_recovery), PS3_IOC_HARD_RECOVERY_SUPPORT(instance_recovery), ps3_hard_reset_enable_query()); @@ -833,138 +936,160 @@ S32 ps3_hard_recovery_request(struct ps3_instance *instance) } ret = ps3_hard_recovery_request_prepare(instance_recovery); - if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { + if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) ret = PS3_SUCCESS; - } else if(ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + else if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) ret = ps3_recovery_start(instance_recovery); - } else { + else ret = -PS3_FAILED; - } - INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, &ret) + + INJECT_START(PS3_ERR_IJ_WATCHDOG_IRQ_QUEUE_1, &ret); l_out: LOG_INFO("hno:%u hard recovery request end, ret:%d!\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); ps3_atomic_dec(&instance->recovery_context->hardreset_ref); return ret; } -static inline S32 ps3_ioc_soft_recovery_request_decide( - struct ps3_instance *instance, U32 ioc_state) +static inline int +ps3_ioc_soft_recovery_request_decide(struct ps3_instance *instance, + unsigned int ioc_state) { - U32 ioc_recovery_count = 0; - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - struct ps3_instance_state_machine *state_machine - = &instance->state_machine; - S32 recovery_state = 0; + unsigned int ioc_recovery_count = 0; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + struct ps3_instance_state_machine *state_machine = + &instance->state_machine; + int recovery_state = 0; recovery_state = instance->recovery_context->recovery_state; - if(recovery_state == PS3_HARD_RECOVERY_SHALLOW|| - recovery_state == PS3_HARD_RECOVERY_DECIDE){ - LOG_INFO("hno:%u instance state %s,recovery_state %d,hard reset doing, IOC soft return!\n", + if (recovery_state == PS3_HARD_RECOVERY_SHALLOW || + recovery_state == PS3_HARD_RECOVERY_DECIDE) { + LOG_INFO( + "hno:%u instance state %s,recovery_state %d,hard reset doing, IOC soft return!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&state_machine->state)), + namePS3InstanceState( + ps3_atomic_read(&state_machine->state)), recovery_state); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; - }else if(recovery_state == PS3_SOFT_RECOVERY_SHALLOW || - recovery_state == PS3_SOFT_RECOVERY_DEEP || - recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ - LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", + } else if (recovery_state == PS3_SOFT_RECOVERY_SHALLOW || + recovery_state == PS3_SOFT_RECOVERY_DEEP || + recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { + LOG_INFO( + "hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&state_machine->state)), + namePS3InstanceState( + ps3_atomic_read(&state_machine->state)), recovery_state); goto l_out; } if (!ps3_ioc_recovery_count_get(instance, &ioc_recovery_count)) { - LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s," - " save_recovery_count:%d, ioc_recovery_count:%d\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), - instance->recovery_context->ioc_recovery_count, ioc_recovery_count); + LOG_INFO( + "hno:%u entry IOC soft recovery request decide!,ioc_state:%s,\n" + "\tsave_recovery_count:%d, ioc_recovery_count:%d\n", + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), + instance->recovery_context->ioc_recovery_count, + ioc_recovery_count); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s," - " save_recovery_count:%d, ioc_recovery_count:%d\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), - instance->recovery_context->ioc_recovery_count, ioc_recovery_count); + LOG_INFO("hno:%u entry IOC soft recovery request decide!,ioc_state:%s,\n" + "\tsave_recovery_count:%d, ioc_recovery_count:%d\n", + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), + instance->recovery_context->ioc_recovery_count, + ioc_recovery_count); - if (instance->recovery_context->ioc_recovery_count == ioc_recovery_count) { + if (instance->recovery_context->ioc_recovery_count == + ioc_recovery_count) { goto l_out; } - if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_no_lock_state_transfer( + instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != + PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_no_lock_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } - instance->recovery_context->recovery_state - = PS3_SOFT_RECOVERY_IOC_RECOVERY; + instance->recovery_context->recovery_state = + PS3_SOFT_RECOVERY_IOC_RECOVERY; ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; l_out: return ret; } -static inline S32 ps3_soft_recovery_request_decide( - struct ps3_instance *instance, U32 ioc_state) +static inline int +ps3_soft_recovery_request_decide(struct ps3_instance *instance, + unsigned int ioc_state) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - struct ps3_instance_state_machine *state_machine - = &instance->state_machine; - S32 recovery_state = instance->recovery_context->recovery_state; - if( recovery_state == PS3_HARD_RECOVERY_SHALLOW || - recovery_state == PS3_HARD_RECOVERY_DECIDE){ - LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + struct ps3_instance_state_machine *state_machine = + &instance->state_machine; + int recovery_state = instance->recovery_context->recovery_state; + + if (recovery_state == PS3_HARD_RECOVERY_SHALLOW || + recovery_state == PS3_HARD_RECOVERY_DECIDE) { + LOG_INFO( + "hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&state_machine->state)), + namePS3InstanceState( + ps3_atomic_read(&state_machine->state)), recovery_state); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; - }else if(recovery_state == PS3_SOFT_RECOVERY_SHALLOW || - recovery_state == PS3_SOFT_RECOVERY_DEEP || - recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ - LOG_INFO("hno:%u instance state %s,recovery_state %d,repeat request!\n", + } else if (recovery_state == PS3_SOFT_RECOVERY_SHALLOW || + recovery_state == PS3_SOFT_RECOVERY_DEEP || + recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { + LOG_INFO( + "hno:%u instance state %s,recovery_state %d,repeat request!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&state_machine->state)), + namePS3InstanceState( + ps3_atomic_read(&state_machine->state)), recovery_state); goto l_out; } if (ioc_state == PS3_FW_STATE_RUNNING) { - if(ps3_instance_no_lock_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_no_lock_state_transfer( + instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != + PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - if(ps3_instance_no_lock_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_no_lock_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY) != + PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } - instance->recovery_context->recovery_state - = PS3_SOFT_RECOVERY_SHALLOW; + instance->recovery_context->recovery_state = + PS3_SOFT_RECOVERY_SHALLOW; LOG_INFO("hno:%u instance state to soft recovery shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } @@ -972,62 +1097,72 @@ static inline S32 ps3_soft_recovery_request_decide( return ret; } -static S32 ps3_recovery_request_prepare(struct ps3_instance *instance) +static int ps3_recovery_request_prepare(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 ioc_state = 0; - struct ps3_instance_state_machine *state_machine - = &instance->state_machine; - U32 cur_state = 0; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int ioc_state = 0; + struct ps3_instance_state_machine *state_machine = + &instance->state_machine; + unsigned int cur_state = 0; struct ps3_instance_state_machine *state_machine_peer = NULL; - U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; ps3_mutex_lock(&state_machine->lock); ioc_state = instance->ioc_adpter->ioc_state_get(instance); cur_state = ps3_atomic_read(&state_machine->state); INJECT_START(PS3_ERR_IJ_CHANGE_FW_TO_HALT_IN_PREPARE, &ioc_state); - LOG_INFO("hno:%u recovery request:%s, %s\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state)); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, instance) + LOG_INFO("hno:%u recovery request:%s, %s\n", PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), + namePS3InstanceState(cur_state)); + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PCIE_ERR, instance); if (ps3_pci_err_recovery_get(instance) || - (instance->peer_instance != NULL && ps3_pci_err_recovery_get(instance->peer_instance))) { + (instance->peer_instance != NULL && + ps3_pci_err_recovery_get(instance->peer_instance))) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE) { - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + ps3_mutex_lock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_DECIDE) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_INFO("hno:%u heartbeat recovery start\n", - PS3_HOST(instance)); - instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RECOVERY; + PS3_HOST(instance)); + instance->recovery_context->heartbeat_recovery = + PS3_HEARTBEAT_HARDRESET_RECOVERY; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); goto l_out; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_IOC_HALT, instance); if (ioc_state == PS3_FW_STATE_HALT) { ps3_instance_state_transfer_to_dead_nolock(instance); if (instance->peer_instance != NULL) { - ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); + ps3_instance_state_transfer_to_dead_nolock( + instance->peer_instance); } - LOG_ERROR("hno:%u IOC state has halt, instance state to dead!\n", + LOG_ERROR( + "hno:%u IOC state has halt, instance state to dead!\n", PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT || - cur_state == PS3_INSTANCE_STATE_SUSPEND) { - LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", + cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_SUSPEND) { + LOG_ERROR( + "hno:%u instance state is %s, and ioc_state is %s!\n", PS3_HOST(instance), namePS3InstanceState(cur_state), ps3_ioc_state_print(ioc_state)); ret = PS3_RECOVERY_INTER_ERR_FAILED; @@ -1036,35 +1171,43 @@ static S32 ps3_recovery_request_prepare(struct ps3_instance *instance) if (instance->peer_instance != NULL) { state_machine_peer = &instance->peer_instance->state_machine; - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_PCIE_ERR, + instance); if (ps3_pci_err_recovery_get(instance->peer_instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out; } ps3_mutex_lock(&state_machine_peer->lock); - ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get(instance); + ioc_state = instance->peer_instance->ioc_adpter->ioc_state_get( + instance); peer_cur_state = ps3_atomic_read(&state_machine->state); LOG_INFO("hno:%u recovery request:%s, %s\n", - PS3_HOST(instance->peer_instance), - ps3_ioc_state_print(ioc_state), namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance->peer_instance), + ps3_ioc_state_print(ioc_state), + namePS3InstanceState(peer_cur_state)); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PREPARE_PEER_IOC_HALT, + instance); if (ioc_state == PS3_FW_STATE_HALT) { - ps3_instance_state_transfer_to_dead_nolock(instance->peer_instance); + ps3_instance_state_transfer_to_dead_nolock( + instance->peer_instance); ps3_instance_state_transfer_to_dead_nolock(instance); - LOG_ERROR("hno:%u ioc state has halt, instance state to dead!\n", + LOG_ERROR( + "hno:%u ioc state has halt, instance state to dead!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out_peer; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_STATE_DEAD, instance); if (peer_cur_state == PS3_INSTANCE_STATE_DEAD || - peer_cur_state == PS3_INSTANCE_STATE_QUIT || - peer_cur_state == PS3_INSTANCE_STATE_SUSPEND) { - LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", - PS3_HOST(instance->peer_instance), namePS3InstanceState(peer_cur_state), + peer_cur_state == PS3_INSTANCE_STATE_QUIT || + peer_cur_state == PS3_INSTANCE_STATE_SUSPEND) { + LOG_ERROR( + "hno:%u instance state is %s, and ioc_state is %s!\n", + PS3_HOST(instance->peer_instance), + namePS3InstanceState(peer_cur_state), ps3_ioc_state_print(ioc_state)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out_peer; @@ -1072,109 +1215,144 @@ static S32 ps3_recovery_request_prepare(struct ps3_instance *instance) } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { - LOG_ERROR("hno:%u instance state is %s, and ioc_state is %s!\n", - PS3_HOST(instance), namePS3InstanceState(peer_cur_state), + ioc_state == PS3_FW_STATE_CRITICAL) { + LOG_ERROR( + "hno:%u instance state is %s, and ioc_state is %s!\n", + PS3_HOST(instance), + namePS3InstanceState(peer_cur_state), ps3_ioc_state_print(ioc_state)); - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); goto l_out_peer; } - if(cur_state != PS3_INSTANCE_STATE_OPERATIONAL || - peer_cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { - LOG_INFO("hno:%u instance state is %s:%s! no need repeat recovery requeset\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), namePS3InstanceState(cur_state)); + if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL || + peer_cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { + LOG_INFO( + "hno:%u instance state is %s:%s! no need repeat recovery requeset\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + namePS3InstanceState(cur_state)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; goto l_out_peer; } ret = ps3_ioc_soft_recovery_request_decide(instance, ioc_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { goto l_out_peer; - }else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { + } else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { goto l_hardreset; } ret = ps3_soft_recovery_request_decide(instance, ioc_state); if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY || - ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_SUCCESS || + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { goto l_out_peer; - }else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { + } else if (ret == PS3_RECOVERY_INTER_ERR_FAILED) { goto l_hardreset; } LOG_ERROR("hno:%u UNEXPECT!!! hard recovery!,ioc_state:%s, %s:%s\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state), namePS3InstanceState(cur_state), namePS3InstanceState(peer_cur_state)); + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), + namePS3InstanceState(cur_state), + namePS3InstanceState(peer_cur_state)); l_hardreset: - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); l_out_peer: - if (instance->peer_instance != NULL) { + if (instance->peer_instance != NULL) ps3_mutex_unlock(&state_machine_peer->lock); - } l_out: ps3_mutex_unlock(&state_machine->lock); return ret; } -S32 ps3_recovery_request(struct ps3_instance *instance) +int ps3_recovery_request(struct ps3_instance *instance, + unsigned char is_host_reset) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_instance *instance_recovery = NULL; - LOG_WARN("hno:%u ps3 recovery request start, IOC outstanding: %d!!\n", PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); + LOG_WARN("hno:%u ps3 recovery request start, IOC outstanding: %d!!\n", + PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.cmd_outstanding)); ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); - INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, &instance->recovery_context->instance_change) + mb(); /* in order to force CPU ordering */ + INJECT_START(PS3_ERR_IJ_ADD_INSTANCE, + &instance->recovery_context->instance_change); if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } - INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance) - INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance) + + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_3, instance); + if (!ps3_host_reset_state_check(instance, is_host_reset)) { + LOG_WARN("hno[%u], recovery request during host reset\n", + PS3_HOST(instance)); + ret = -PS3_RETRY; + goto l_out; + } + + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_PROBE, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_REQ_WAIT_FUNC1_REMOVE, instance); while (instance->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; goto l_out; } - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_INIT) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_PENDING; + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_INIT) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_PENDING; } - INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, &instance->recovery_context->instance_change) + INJECT_START(PS3_ERR_IJ_REMOVE_INSTANCE, + &instance->recovery_context->instance_change); if (instance->recovery_context->instance_change) { - LOG_INFO("hno:%u peer instance is change\n", PS3_HOST(instance)); + LOG_INFO("hno:%u peer instance is change\n", + PS3_HOST(instance)); ret = -PS3_RETRY; goto l_out; } ps3_atomic_dec(&instance->recovery_context->hardreset_ref); ps3_msleep(10); - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { - ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_CONTINUE) { + ps3_atomic_inc( + &instance->recovery_context->hardreset_ref); + mb(); /* in order to force CPU ordering */ + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; break; } ps3_atomic_inc(&instance->recovery_context->hardreset_ref); - mb(); - } - INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance) - if (instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_INIT; - } - LOG_INFO("hno:%u peer_instance[%p], hard recovery request Function[%d]\n", - PS3_HOST(instance), instance->peer_instance, ps3_get_pci_function(instance->pdev)); - INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, instance) + mb(); /* in order to force CPU ordering */ + } + INJECT_START(PS3_ERR_IJ_FORCE_DUL_RECOVERY_PENDING, instance); + if (instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_INIT; + } + LOG_INFO( + "hno:%u peer_instance[%p], hard recovery request Function[%d]\n", + PS3_HOST(instance), instance->peer_instance, + ps3_get_pci_function(instance->pdev)); + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_3, instance); if (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_0 || - (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && instance->peer_instance == NULL)) { + (ps3_get_pci_function(instance->pdev) == PS3_FUNC_ID_1 && + instance->peer_instance == NULL)) { instance_recovery = instance; } else { instance_recovery = instance->peer_instance; @@ -1182,30 +1360,32 @@ S32 ps3_recovery_request(struct ps3_instance *instance) if (ps3_pci_err_recovery_get(instance_recovery)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = PS3_SUCCESS; goto l_out; } if (ps3_recovery_is_state_halt(instance_recovery)) { LOG_INFO_LIM("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery)); + PS3_HOST(instance_recovery)); ret = -PS3_FAILED; goto l_out; } if (instance_recovery->peer_instance != NULL) { - if (ps3_pci_err_recovery_get(instance_recovery->peer_instance)) { + if (ps3_pci_err_recovery_get( + instance_recovery->peer_instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance_recovery->peer_instance)); + PS3_HOST(instance_recovery->peer_instance)); ret = PS3_SUCCESS; goto l_out; } if (instance_recovery->peer_instance->reg_set == NULL || - ps3_recovery_is_state_halt(instance_recovery->peer_instance)) { + ps3_recovery_is_state_halt( + instance_recovery->peer_instance)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance_recovery->peer_instance)); + PS3_HOST(instance_recovery->peer_instance)); ret = -PS3_FAILED; goto l_out; } @@ -1213,154 +1393,169 @@ S32 ps3_recovery_request(struct ps3_instance *instance) ret = ps3_recovery_request_prepare(instance_recovery); if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { ret = PS3_SUCCESS; - } else if(ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + } else if (ret == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { ret = ps3_recovery_start(instance_recovery); } else { ret = -PS3_FAILED; } l_out: - LOG_INFO("hno:%u recovery request end, ret:%d!\n", - PS3_HOST(instance), ret); + LOG_INFO("hno:%u recovery request end, ret:%d!\n", PS3_HOST(instance), + ret); ps3_atomic_dec(&instance->recovery_context->hardreset_ref); return ret; } -static Bool ps3_recovery_reg(struct ps3_instance *instance) +static unsigned char ps3_recovery_reg(struct ps3_instance *instance) { - Bool ret = PS3_FALSE; - HilReg0Ps3RegisterFPs3FeatureSupport_u *ps3_feature_support = NULL; - HilReg0Ps3RegisterFPs3FirmwareVersion_u *pver = NULL; - U32 cur_max_fw_cmds = 0; - U32 fw_cur_state = PS3_FW_STATE_UNDEFINED; - U64 value = 0; - U64 ver = 0; + unsigned char ret = PS3_FALSE; + union HilReg0Ps3RegisterFPs3FeatureSupport *ps3_feature_support = NULL; + union HilReg0Ps3RegisterFPs3FirmwareVersion *pver = NULL; + unsigned int cur_max_fw_cmds = 0; + unsigned int fw_cur_state = PS3_FW_STATE_UNDEFINED; + unsigned long long value = 0; + unsigned long long ver = 0; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, value); - if (value == U64_MAX) { + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FeatureSupport, + value); + if (value == U64_MAX) goto l_out; - } - ps3_feature_support = (HilReg0Ps3RegisterFPs3FeatureSupport_u *)&value; - PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, ps3FirmwareVersion, ver); - if (ver == U64_MAX) { + ps3_feature_support = + (union HilReg0Ps3RegisterFPs3FeatureSupport *)&value; + PS3_IOC_REG_READ_WITH_CHECK(instance, reg_f.Excl_reg, + ps3FirmwareVersion, ver); + if (ver == U64_MAX) goto l_out; - } - pver = (HilReg0Ps3RegisterFPs3FirmwareVersion_u *)&ver; - if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &cur_max_fw_cmds)) { + pver = (union HilReg0Ps3RegisterFPs3FirmwareVersion *)&ver; + if (!ps3_ioc_mgr_max_fw_cmd_get(instance, &cur_max_fw_cmds)) goto l_out; - } fw_cur_state = instance->ioc_adpter->ioc_state_get(instance); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, &fw_cur_state) - if (fw_cur_state != PS3_FW_STATE_RUNNING) { - goto l_out; - } - instance->is_ioc_halt_support = (ps3_feature_support->reg.fwHaltSupport == 1); - instance->dump_context.is_dump_support = (ps3_feature_support->reg.dumpCrashSupport == 1); - instance->is_shallow_soft_recovery_support = (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); - instance->is_deep_soft_recovery_support = (ps3_feature_support->reg.deepSoftRecoverySupport == 1); - instance->is_hard_recovery_support = (ps3_feature_support->reg.hardRecoverySupport == 1); - instance->ioc_fw_version = (U64)pver->reg.ps3FmVer; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_REG_FAILED, &fw_cur_state); + if (fw_cur_state != PS3_FW_STATE_RUNNING) + goto l_out; + instance->is_ioc_halt_support = + (ps3_feature_support->reg.fwHaltSupport == 1); + instance->dump_context.is_dump_support = + (ps3_feature_support->reg.dumpCrashSupport == 1); + instance->is_shallow_soft_recovery_support = + (ps3_feature_support->reg.shallowSoftRecoverySupport == 1); + instance->is_deep_soft_recovery_support = + (ps3_feature_support->reg.deepSoftRecoverySupport == 1); + instance->is_hard_recovery_support = + (ps3_feature_support->reg.hardRecoverySupport == 1); + instance->ioc_fw_version = (unsigned long long)pver->reg.ps3FmVer; ps3_can_queue_reset(instance, cur_max_fw_cmds); ret = PS3_TRUE; l_out: return ret; } -static S32 ps3_recovery_finish(struct ps3_instance *instance) +static int ps3_recovery_finish(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - if (!ps3_recovery_reg(instance)) { - LOG_WARN("hno:%u recovery reg NOK\n",PS3_HOST(instance)); - } + int ret = PS3_SUCCESS; + + if (!ps3_recovery_reg(instance)) + LOG_WARN("hno:%u recovery reg NOK\n", PS3_HOST(instance)); return ret; } -static S32 ps3_recovery_complete(struct ps3_instance *instance) +static int ps3_recovery_complete(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_13, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_7, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); ret = -PS3_IN_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) goto l_out; - } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_14, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_14, instance); if (ps3_recovery_finish(instance) != PS3_SUCCESS) { ps3_instance_state_transfer_to_dead(instance); LOG_ERROR("hno:%u recovery finish process failed, to DEAD\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } l_out: - return ret; + return ret; } static void ps3_hard_recovery(struct ps3_instance *instance) { struct ps3_recovery_context *context = instance->recovery_context; + if (ps3_hard_recovery_handle(instance) != PS3_SUCCESS) { context->recovery_result = -PS3_FAILED; LOG_ERROR("hno:%u hard recovery failed!\n", - PS3_HOST(instance)); - }else{ + PS3_HOST(instance)); + } else { context->recovery_result = PS3_SUCCESS; LOG_WARN("hno:%u hard recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_lock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_NULL; - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock( + &instance->recovery_context->ps3_watchdog_recovery_mutex); - return; } #ifndef _WINDOWS -static void ps3_recovery_work(struct work_struct* work) +static void ps3_recovery_work(struct work_struct *work) { - struct ps3_recovery_context *context = - ps3_container_of(work, struct ps3_recovery_context, recovery_work); + struct ps3_recovery_context *context = ps3_container_of( + work, struct ps3_recovery_context, recovery_work); struct ps3_instance *instance = context->work_instance; #else static void ps3_recovery_work(void *ins) { - struct ps3_instance *instance = (struct ps3_instance*)ins; + struct ps3_instance *instance = (struct ps3_instance *)ins; struct ps3_recovery_context *context = instance->recovery_context; #endif - U32 cur_state = ps3_atomic_read(&instance->state_machine.state); - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int cur_state = + ps3_atomic_read(&instance->state_machine.state); + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u recovery work start, %s recovery state[%d]\n", - PS3_HOST(instance), namePS3InstanceState(cur_state), context->recovery_state); + PS3_HOST(instance), namePS3InstanceState(cur_state), + context->recovery_state); if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); + - if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE){ - ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); - }else{ - ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + ps3_recovery_state_transfer(instance, + PS3_HARD_RECOVERY_FINISH); + } else { + ps3_recovery_state_transfer(instance, + PS3_SOFT_RECOVERY_FINISH); } - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_lock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_NULL; - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + PS3_HEARTBEAT_NULL; + ps3_mutex_unlock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); goto l_out; } context->recovery_result = PS3_SUCCESS; if (cur_state == PS3_INSTANCE_STATE_SOFT_RECOVERY) { ps3_mutex_lock(&instance->state_machine.lock); - if (context->recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY){ + if (context->recovery_state == PS3_SOFT_RECOVERY_IOC_RECOVERY) { ps3_mutex_unlock(&instance->state_machine.lock); goto l_soft_reset; } @@ -1376,39 +1571,55 @@ static void ps3_recovery_work(void *ins) } LOG_ERROR("hno:%u nothing to do %s,recovery_state %d!\n", - PS3_HOST(instance),namePS3InstanceState(cur_state),context->recovery_state); + PS3_HOST(instance), namePS3InstanceState(cur_state), + context->recovery_state); ps3_mutex_unlock(&instance->state_machine.lock); - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { if (instance->peer_instance == NULL || - instance->peer_instance->recovery_context == NULL) { + instance->peer_instance->recovery_context == NULL) { context->recovery_result = -PS3_FAILED; - LOG_ERROR("hno:%u hard recovery NOK,recovery_state %d!\n", - PS3_HOST(instance),context->recovery_state); - ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); + LOG_ERROR( + "hno:%u hard recovery NOK,recovery_state %d!\n", + PS3_HOST(instance), + context->recovery_state); + ps3_recovery_state_transfer( + instance, PS3_HARD_RECOVERY_FINISH); goto l_out; } } if (instance->peer_instance != NULL && - ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { context->recovery_result = -PS3_FAILED; - LOG_ERROR("hno:%u hard recovery NOK,recovery_state %d!\n", - PS3_HOST(instance->peer_instance),context->recovery_state); - ps3_recovery_state_transfer(instance->peer_instance, PS3_HARD_RECOVERY_FINISH); + LOG_ERROR( + "hno:%u hard recovery NOK,recovery_state %d!\n", + PS3_HOST(instance->peer_instance), + context->recovery_state); + ps3_recovery_state_transfer(instance->peer_instance, + PS3_HARD_RECOVERY_FINISH); goto l_out; } } else if (cur_state == PS3_INSTANCE_STATE_RECOVERY) { goto l_hard_reset; } else { - LOG_ERROR("hno:%u nothing to do %s,recovery_state %d, cur_state:%s!\n", - PS3_HOST(instance),namePS3InstanceState(cur_state),context->recovery_state, - namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); - if(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE){ - ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); - }else{ - ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); + LOG_ERROR( + "hno:%u nothing to do %s,recovery_state %d, cur_state:%s!\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + context->recovery_state, + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state))); + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + ps3_recovery_state_transfer(instance, + PS3_HARD_RECOVERY_FINISH); + } else { + ps3_recovery_state_transfer(instance, + PS3_SOFT_RECOVERY_FINISH); } goto l_out; } @@ -1418,24 +1629,25 @@ static void ps3_recovery_work(void *ins) if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { context->recovery_result = PS3_SUCCESS; LOG_INFO("hno:%u soft recovery interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); - } else if(ret == PS3_RECOVERY_INTER_ERR_SUCCESS){ + } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { context->recovery_result = PS3_SUCCESS; ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); LOG_WARN("hno:%u soft recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } else { LOG_INFO("hno:%u soft recovery to hard recovery!\n", - PS3_HOST(instance)); - if(ps3_soft_recovery_fail_to_hard_recovery(instance) != PS3_SUCCESS){ + PS3_HOST(instance)); + if (ps3_soft_recovery_fail_to_hard_recovery(instance) != + PS3_SUCCESS) { context->recovery_result = -PS3_FAILED; LOG_ERROR("hno:%u soft to hard recovery failed!\n", - PS3_HOST(instance)); - }else{ + PS3_HOST(instance)); + } else { context->recovery_result = PS3_SUCCESS; LOG_INFO("hno:%u soft to hard recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } } goto l_out; @@ -1445,75 +1657,77 @@ static void ps3_recovery_work(void *ins) l_out: if (ps3_pci_err_recovery_get(instance)) { - LOG_INFO("hno:%u recovery is interrupted by pci err recovery.\n", + LOG_INFO( + "hno:%u recovery is interrupted by pci err recovery.\n", PS3_HOST(instance)); ps3_instance_state_transfer_to_pcie_recovery(instance); if (instance->peer_instance != NULL) { - ps3_instance_state_transfer_to_pcie_recovery(instance->peer_instance); + ps3_instance_state_transfer_to_pcie_recovery( + instance->peer_instance); } } - return; } -static S32 ps3_soft_recovery_cmd_reply_check(struct ps3_instance *instance) +static int ps3_soft_recovery_cmd_reply_check(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 i = 0; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - U32 no_reply_count = 0; + unsigned int no_reply_count = 0; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ - LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + LOG_WARN("hno:%u soft reset proc is interrupt!\n", + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - if (cmd->cmd_state.reset_flag != PS3_CMD_FLAG_SOFTRESET) { + if (cmd->cmd_state.reset_flag != PS3_CMD_FLAG_SOFTRESET) continue; - } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) continue; - } - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD && - ps3_cmd_resp_status(cmd) != U32_MAX) { + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NO_REPLY_WORD && + ps3_cmd_resp_status(cmd) != U32_MAX) { continue; } if (cmd == instance->event_context.event_cmd || - cmd == instance->dev_context.vd_pending_cmd || - cmd == instance->webSubscribe_context.webSubscribe_cmd) { + cmd == instance->dev_context.vd_pending_cmd || + cmd == instance->webSubscribe_context.webSubscribe_cmd) { continue; } no_reply_count++; - LOG_DEBUG("hno:%u no reply cmd,CFID[%d], %s,max_scsi_cmd_count %u, max_cmd_count %u\n", - PS3_HOST(instance), i, namePS3CmdState(cmd->cmd_state.state), + LOG_DEBUG( + "hno:%u no reply cmd,CFID[%d], %s,max_scsi_cmd_count %u, max_cmd_count %u\n", + PS3_HOST(instance), i, + namePS3CmdState(cmd->cmd_state.state), context->max_scsi_cmd_count, context->max_cmd_count); } - if (no_reply_count > 0) { + if (no_reply_count > 0) ret = PS3_RECOVERY_INTER_ERR_FAILED; - } l_out: return ret; } -static S32 ps3_soft_recovery_cmd_reply_polling_check( - struct ps3_instance *instance, U32 wait_seconds) +static int +ps3_soft_recovery_cmd_reply_polling_check(struct ps3_instance *instance, + unsigned int wait_seconds) { - S32 ret = PS3_RECOVERY_INTER_ERR_FAILED; - const U32 interval_check_ms = 20; - U32 msecs = U32_MAX; - U32 i = 0; + int ret = PS3_RECOVERY_INTER_ERR_FAILED; + const unsigned int interval_check_ms = 20; + unsigned int msecs = U32_MAX; + unsigned int i = 0; if (wait_seconds != 0) { #ifndef _WINDOWS @@ -1530,9 +1744,9 @@ static S32 ps3_soft_recovery_cmd_reply_polling_check( } ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); break; @@ -1541,16 +1755,16 @@ static S32 ps3_soft_recovery_cmd_reply_polling_check( if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u host in pci err recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; break; } ret = ps3_soft_recovery_cmd_reply_check(instance); if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS || - ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { + ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u no mgr cmd pending\n", - PS3_HOST(instance)); + PS3_HOST(instance)); break; } @@ -1560,15 +1774,15 @@ static S32 ps3_soft_recovery_cmd_reply_polling_check( return ret; } -static S32 ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) +static int ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } @@ -1579,74 +1793,81 @@ static S32 ps3_soft_recovery_to_pre_operational(struct ps3_instance *instance) ret = ps3_ioc_state_transfer_wait_to_running(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u soft recovery to running failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ret = ps3_soft_recovery_cmd_reply_polling_check(instance, PS3_SOFT_RESET_WAIT_TIMEOUT); + ret = ps3_soft_recovery_cmd_reply_polling_check( + instance, PS3_SOFT_RESET_WAIT_TIMEOUT); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u pending mgr cmd no reply all!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft recovery to pre-operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static S32 ps3_hard_recovery_pre_operational_to_operational(struct ps3_instance *instance) +static int +ps3_hard_recovery_pre_operational_to_operational(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - if (!ps3_ioc_recovery_count_get(instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get( + instance, + &instance->recovery_context->ioc_recovery_count)) { LOG_ERROR("hno:%u get recovery count NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } LOG_INFO("hno:%u pre-operational to operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static S32 ps3_soft_recovery_pre_operational_to_operational(struct ps3_instance *instance) +static int +ps3_soft_recovery_pre_operational_to_operational(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - if (!ps3_ioc_recovery_count_get(instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get( + instance, + &instance->recovery_context->ioc_recovery_count)) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO("hno:%u pre-operational to operational success!,reset count:%d\n", - PS3_HOST(instance), instance->recovery_context->ioc_recovery_count); + LOG_INFO( + "hno:%u pre-operational to operational success!,reset count:%d\n", + PS3_HOST(instance), + instance->recovery_context->ioc_recovery_count); l_out: return ret; } -static S32 ps3_cmd_resubscribe(struct ps3_instance *instance) +static int ps3_cmd_resubscribe(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; @@ -1655,15 +1876,15 @@ static S32 ps3_cmd_resubscribe(struct ps3_instance *instance) ret = ps3_soft_reset_event_resubscribe(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u event unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; @@ -1673,83 +1894,95 @@ static S32 ps3_cmd_resubscribe(struct ps3_instance *instance) ret = ps3_dev_mgr_vd_info_resubscribe(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u vd pending unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ - LOG_WARN("hno:%u soft reset proc is interrupt!\n", - PS3_HOST(instance)); - ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; - ps3_mutex_unlock(&instance->state_machine.lock); - goto l_out; - } - ps3_mutex_unlock(&instance->state_machine.lock); - - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { - ret = ps3_soft_reset_web_resubscribe(instance); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u web unsubscribe failed!\n", - PS3_HOST(instance)); - ret = PS3_RECOVERY_INTER_ERR_FAILED; - goto l_out; - } - } - - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ps3_mutex_lock(&instance->state_machine.lock); + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { + LOG_WARN("hno:%u soft reset proc is interrupt!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; + ps3_mutex_unlock(&instance->state_machine.lock); + goto l_out; + } + ps3_mutex_unlock(&instance->state_machine.lock); + + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { + ret = ps3_soft_reset_web_resubscribe(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u web unsubscribe failed!\n", + PS3_HOST(instance)); + ret = PS3_RECOVERY_INTER_ERR_FAILED; + goto l_out; + } + } + + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; l_out: - return ret; + return ret; } -static S32 ps3_soft_recovery_complete(struct ps3_instance *instance) +static int ps3_soft_recovery_complete(struct ps3_instance *instance) { - S32 ret = ps3_soft_recovery_to_pre_operational(instance); + int ret = ps3_soft_recovery_to_pre_operational(instance); + if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u ioc soft reset failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to pre operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.softreset_handle_pre_cb != NULL) { - ret = instance->peer_instance->recovery_function.softreset_handle_pre_cb(instance->peer_instance); + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function.softreset_handle_pre_cb != + NULL) { + ret = instance->peer_instance->recovery_function + .softreset_handle_pre_cb(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u softreset handle pre cb failed\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } - if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { - LOG_ERROR("hno:%u transfer to pre operational failed!\n", + if (ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != + PS3_SUCCESS) { + LOG_ERROR( + "hno:%u transfer to pre operational failed!\n", PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } } - ret = ps3_soft_recovery_pre_operational_to_operational(instance); + ret = ps3_soft_recovery_pre_operational_to_operational(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u ioc soft reset failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.softreset_handle_post_cb != NULL) { - ret = instance->peer_instance->recovery_function.softreset_handle_post_cb(instance->peer_instance); + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function + .softreset_handle_post_cb != NULL) { + ret = instance->peer_instance->recovery_function + .softreset_handle_post_cb( + instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u softreset handle post cb failed\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } } @@ -1758,53 +1991,65 @@ static S32 ps3_soft_recovery_complete(struct ps3_instance *instance) return ret; } -static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance) +static int +ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance) { - S32 ret = -PS3_FAILED; - U32 cur_state = ps3_atomic_read(&instance->state_machine.state); - S32 ret_peer = PS3_SUCCESS; - U32 peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; + int ret = -PS3_FAILED; + unsigned int cur_state = + ps3_atomic_read(&instance->state_machine.state); + int ret_peer = PS3_SUCCESS; + unsigned int peer_cur_state = PS3_INSTANCE_STATE_OPERATIONAL; PS3_IJ_SLEEP(10000, PS3_ERR_IJ_SOFT_TO_HARD); ps3_mutex_lock(&instance->state_machine.lock); if (instance->peer_instance != NULL) { ps3_mutex_lock(&instance->peer_instance->state_machine.lock); - peer_cur_state = ps3_atomic_read(&instance->peer_instance->state_machine.state); + peer_cur_state = ps3_atomic_read( + &instance->peer_instance->state_machine.state); } - ret = ps3_hard_recovery_request_decide(instance, cur_state, peer_cur_state); - if (instance->peer_instance != NULL) { + ret = ps3_hard_recovery_request_decide(instance, cur_state, + peer_cur_state); + if (instance->peer_instance != NULL) ps3_mutex_unlock(&instance->peer_instance->state_machine.lock); - } ps3_mutex_unlock(&instance->state_machine.lock); if (ret != PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { LOG_WARN("hno:%u decide no need to hard recovery\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } - ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, - PS3_INSTANCE_STATE_RECOVERY); + ret = ps3_instance_state_transfer(instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY, + PS3_INSTANCE_STATE_RECOVERY); if (ret != PS3_SUCCESS) { - ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (ret != PS3_SUCCESS) { - ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_OPERATIONAL, + ret = ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (instance->peer_instance != NULL) { - ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_SOFT_RECOVERY, + ret_peer = ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_SOFT_RECOVERY, PS3_INSTANCE_STATE_RECOVERY); if (ret_peer != PS3_SUCCESS) { - ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret_peer = ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } if (ret_peer != PS3_SUCCESS) { - ret_peer = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_OPERATIONAL, + ret_peer = ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_OPERATIONAL, PS3_INSTANCE_STATE_RECOVERY); } } @@ -1813,168 +2058,188 @@ static S32 ps3_soft_recovery_fail_to_hard_recovery(struct ps3_instance *instance ps3_need_wait_hard_reset_request(instance); ret = ps3_hard_recovery_handle(instance); } else { - LOG_ERROR("hno:%u transfer to recovery failed!, cur_state:%s\n", + LOG_ERROR( + "hno:%u transfer to recovery failed!, cur_state:%s\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state))); ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); } if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u hard reset failed!\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u hard reset failed!\n", PS3_HOST(instance)); } else { LOG_INFO("hno:%u hard reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } l_out: return ret; } -static S32 ps3_ioc_soft_recovery(struct ps3_instance *instance) +static int ps3_ioc_soft_recovery(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ret = ps3_soft_recovery_complete(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u IOC soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("hno:%u IOC soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_sucess; + PS3_HOST(instance)); + goto l_reset_success; } else { - LOG_ERROR("hno:%u IOC self soft reset failed! need to hard reset\n", + LOG_ERROR( + "hno:%u IOC self soft reset failed! need to hard reset\n", PS3_HOST(instance)); goto l_out; } -l_reset_sucess: - ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL); +l_reset_success: + ret = ps3_instance_state_transfer(instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } ret = ps3_cmd_resubscribe(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_recovery_complete(instance); - if(ret != PS3_SUCCESS){ - LOG_INFO("hno:%u IOC soft reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state)),ret); + if (ret != PS3_SUCCESS) { + LOG_INFO( + "hno:%u IOC soft reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state)), + ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - ret = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = ps3_cmd_resubscribe(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } ret = ps3_recovery_complete(instance->peer_instance); - if(ret != PS3_SUCCESS){ - LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + if (ret != PS3_SUCCESS) { + LOG_INFO( + "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", PS3_HOST(instance->peer_instance), - namePS3InstanceState(ps3_atomic_read(&instance->peer_instance->state_machine.state)),ret); + namePS3InstanceState(ps3_atomic_read( + &instance->peer_instance->state_machine + .state)), + ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_FINISH); - ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -static S32 ps3_host_shallow_soft_recovery(struct ps3_instance *instance) +static int ps3_host_shallow_soft_recovery(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance)) { + int ret = PS3_SUCCESS; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + + if (PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance) == PS3_FALSE) { LOG_ERROR("hno:%u soc feature unsupport soft reset Shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (instance->peer_instance != NULL) { - if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT(instance->peer_instance)) { - LOG_ERROR("hno:%u soc feature unsupport soft reset Shallow!\n", + if (PS3_FALSE == PS3_IOC_SHALLOW_SOFT_RECOVERY_SUPPORT( + instance->peer_instance)) { + LOG_ERROR( + "hno:%u soc feature unsupport soft reset Shallow!\n", PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } } ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u shallow soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); if (instance->ioc_adpter->ioc_shallow_soft_reset != NULL) { - ps3_recovery_state_transfer(instance, PS3_SOFT_RECOVERY_SHALLOW); + ps3_recovery_state_transfer(instance, + PS3_SOFT_RECOVERY_SHALLOW); ret = instance->ioc_adpter->ioc_shallow_soft_reset(instance); } else { LOG_ERROR("hno:%u driver unsupport soft reset shallow!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u shallow soft reset entry complete prcoess!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = ps3_soft_recovery_complete(instance); } else { LOG_ERROR("hno:%u shallow soft reset fail!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } LOG_INFO("hno:%u shallow soft reset finished!:ret:%d, err_code:%d\n", - PS3_HOST(instance), ret, err_code); + PS3_HOST(instance), ret, err_code); l_out: return err_code; } -static S32 ps3_host_deep_soft_recovery(struct ps3_instance *instance) +static int ps3_host_deep_soft_recovery(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance)) { - LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", - PS3_HOST(instance)); - err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; - goto l_out; + int ret = PS3_SUCCESS; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + + if (PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance) == PS3_FALSE) { + LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", + PS3_HOST(instance)); + err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; + goto l_out; } if (instance->peer_instance != NULL) { - if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT(instance->peer_instance)) { - LOG_ERROR("hno:%u soc feature unsupport soft reset Deep!\n", + if (PS3_FALSE == PS3_IOC_DEEP_SOFT_RECOVERY_SUPPORT( + instance->peer_instance)) { + LOG_ERROR( + "hno:%u soc feature unsupport soft reset Deep!\n", PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; @@ -1982,32 +2247,35 @@ static S32 ps3_host_deep_soft_recovery(struct ps3_instance *instance) } ps3_mutex_lock(&instance->state_machine.lock); - if(PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)){ + if (PS3_IS_INTERRUPT_SOFT_RECOVERY(instance)) { LOG_WARN("hno:%u deep soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; ps3_mutex_unlock(&instance->state_machine.lock); goto l_out; } ps3_mutex_unlock(&instance->state_machine.lock); - ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_SOFT_RECOVERY); + ps3_instance_state_transfer(instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_SOFT_RECOVERY); if (ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_SOFT_RECOVERY) { + PS3_INSTANCE_STATE_SOFT_RECOVERY) { LOG_ERROR("hno:%u soft reovery has been interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } if (instance->peer_instance != NULL) { - ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_SOFT_RECOVERY); + ps3_instance_state_transfer(instance->peer_instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_SOFT_RECOVERY); - if (ps3_atomic_read(&instance->peer_instance->state_machine.state) != - PS3_INSTANCE_STATE_SOFT_RECOVERY) { + if (ps3_atomic_read( + &instance->peer_instance->state_machine.state) != + PS3_INSTANCE_STATE_SOFT_RECOVERY) { LOG_ERROR("hno:%u soft reovery has been interrupt!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2018,72 +2286,75 @@ static S32 ps3_host_deep_soft_recovery(struct ps3_instance *instance) ret = instance->ioc_adpter->ioc_deep_soft_reset(instance); } else { LOG_ERROR("hno:%u driver unsupport soft reset deep!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; goto l_out; } if (ret == PS3_SUCCESS) { LOG_INFO("hno:%u deep soft reset entry complete prcoess!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = ps3_soft_recovery_complete(instance); } else { LOG_ERROR("hno:%u deep soft reset fail!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; } LOG_INFO("hno:%u deep soft reset finished!:ret:%d, err_code:%d\n", - PS3_HOST(instance), ret, err_code); + PS3_HOST(instance), ret, err_code); l_out: return err_code; } -static inline S32 ps3_wait_event_vdpending_cmd_complete(struct ps3_instance *instance) +static inline int +ps3_wait_event_vdpending_cmd_complete(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 count = 0; + int ret = PS3_SUCCESS; + unsigned int count = 0; + - const U32 retry_max = PS3_WAIT_EVENT_CMD_LOOP_COUNT; + const unsigned int retry_max = PS3_WAIT_EVENT_CMD_LOOP_COUNT; - while(instance->event_context.abort_eventcmd != 0 || - instance->dev_context.abort_vdpending_cmd != 0 || - instance->webSubscribe_context.abort_webcmd != 0){ + while (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0 || + ps3_atomic_read(&instance->dev_context.abort_vdpending_cmd) != 0 || + ps3_atomic_read(&instance->webSubscribe_context.abort_webcmd) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - if(count++ > retry_max){ + if (count++ > retry_max) { LOG_INFO("hno:%u wait event proc over:%d ms,failed\n", - PS3_HOST(instance), - retry_max*PS3_LOOP_TIME_INTERVAL_100MS); - ret = -PS3_FAILED; + PS3_HOST(instance), + retry_max * PS3_LOOP_TIME_INTERVAL_100MS); + ret = -PS3_FAILED; break; } } return ret; } -static S32 ps3_soft_recovery_handle(struct ps3_instance *instance) +static int ps3_soft_recovery_handle(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; struct ps3_recovery_context *context = instance->recovery_context; if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci error recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if(ps3_wait_event_vdpending_cmd_complete(instance) != PS3_SUCCESS){ + if (ps3_wait_event_vdpending_cmd_complete(instance) != PS3_SUCCESS) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { if (ps3_pci_err_recovery_get(instance->peer_instance)) { LOG_WARN("hno:%u pci error recovery resetting\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } - if(ps3_wait_event_vdpending_cmd_complete(instance->peer_instance) != PS3_SUCCESS){ + if (ps3_wait_event_vdpending_cmd_complete( + instance->peer_instance) != PS3_SUCCESS) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } @@ -2099,86 +2370,99 @@ static S32 ps3_soft_recovery_handle(struct ps3_instance *instance) ret = ps3_host_shallow_soft_recovery(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u shallow soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_WARN("hno:%u shallow soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_sucess; + PS3_HOST(instance)); + goto l_reset_success; } else { - LOG_WARN("hno:%u shallow soft reset fail, need to deep recovery!\n", + LOG_WARN( + "hno:%u shallow soft reset fail, need to deep recovery!\n", PS3_HOST(instance)); } ret = ps3_host_deep_soft_recovery(instance); if (ret == PS3_RECOVERY_INTER_ERR_INTERRUPT) { LOG_WARN("hno:%u deep soft reset proc is interrupt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } else if (ret == PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("hno:%u deep soft reset success!\n", - PS3_HOST(instance)); - goto l_reset_sucess; + PS3_HOST(instance)); + goto l_reset_success; } else { - LOG_INFO("hno:%u deep soft reset fail, need to hard recovery!\n", + LOG_INFO( + "hno:%u deep soft reset fail, need to hard recovery!\n", PS3_HOST(instance)); goto l_out; } -l_reset_sucess: - ret = ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL); +l_reset_success: + ret = ps3_instance_state_transfer(instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = ps3_cmd_resubscribe(instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = ps3_recovery_complete(instance); - if(ret != PS3_SUCCESS){ - LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state)),ret); + if (ret != PS3_SUCCESS) { + LOG_INFO( + "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state)), + ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } if (instance->peer_instance != NULL) { - ret = ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + ret = ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, PS3_INSTANCE_STATE_OPERATIONAL); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); ret = ps3_cmd_resubscribe(instance->peer_instance); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u cmd unsubscribe failed!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); goto l_out; } ret = ps3_recovery_complete(instance->peer_instance); - if(ret != PS3_SUCCESS){ - LOG_INFO("hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", + if (ret != PS3_SUCCESS) { + LOG_INFO( + "hno:%u soft reset opeational but complete failed! cur_state:%s,ret %d\n", PS3_HOST(instance->peer_instance), - namePS3InstanceState(ps3_atomic_read(&instance->peer_instance->state_machine.state)),ret); + namePS3InstanceState(ps3_atomic_read( + &instance->peer_instance->state_machine + .state)), + ret); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } } LOG_INFO("hno:%u soft reset success and finished!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_SUCCESS; return ret; @@ -2186,71 +2470,77 @@ static S32 ps3_soft_recovery_handle(struct ps3_instance *instance) return ret; } -static S32 ps3_hard_recovery_to_ready(struct ps3_instance *instance) +static int ps3_hard_recovery_to_ready(struct ps3_instance *instance) { - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 ioc_state = 0; - S32 ret = PS3_SUCCESS; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int ioc_state = 0; + int ret = PS3_SUCCESS; INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_3, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_2, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if ((ret = ps3_ioc_hard_reset_to_ready(instance)) != PS3_SUCCESS) { + ret = ps3_ioc_hard_reset_to_ready(instance); + if (ret != PS3_SUCCESS) { ioc_state = instance->ioc_adpter->ioc_state_get(instance); LOG_ERROR("hno:%u hard reset to ready NOK,%s!\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state)); - if (ret == -PS3_IN_PCIE_ERR) { + PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); + if (ret == -PS3_IN_PCIE_ERR) err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; - } else { + else err_code = PS3_RECOVERY_INTER_ERR_NEED_RECOVERY; - } goto l_out; } if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY, - PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { + PS3_INSTANCE_STATE_READY) != + PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; } l_out: return err_code; } -static S32 ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) +static int ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) { - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - S32 ret = PS3_SUCCESS; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_SUCCESS; INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_7, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_4, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) goto l_out; - } - if ((ret = ps3_recovery_ready_to_running(instance)) != PS3_SUCCESS) { + ret = ps3_recovery_ready_to_running(instance); + if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset to running NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); if (ret == -PS3_IN_PCIE_ERR) { err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, + instance); + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2263,17 +2553,19 @@ static S32 ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) #ifndef _WINDOWS ps3_irqpolls_enable(instance); #endif - if (instance->is_need_event && ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { - ps3_web_cmd_clear(instance); - } - if (instance->is_need_event) { - ps3_dev_mgr_vd_info_clear(instance); + if (instance->is_need_event && + ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { + ps3_web_cmd_clear(instance); } - INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance) + if (instance->is_need_event) + ps3_dev_mgr_vd_info_clear(instance); + INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL, instance); if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_PRE_OPERATIONAL) != PS3_SUCCESS) { + PS3_INSTANCE_STATE_PRE_OPERATIONAL) != + PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to pre-operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2283,32 +2575,34 @@ static S32 ps3_hard_recovery_to_pre_operational(struct ps3_instance *instance) return err_code; } -static S32 ps3_hard_recovery_to_operational(struct ps3_instance *instance) +static int ps3_hard_recovery_to_operational(struct ps3_instance *instance) { - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - S32 ret; - ULong flags = 0; - struct ps3_cmd *cmd = NULL; - Bool need_subscribe = PS3_FALSE; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret; + unsigned long flags = 0; + struct ps3_cmd *cmd = NULL; + unsigned char need_subscribe = PS3_FALSE; INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_10, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR_6, instance) if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) goto l_out; - } - if (ps3_hard_recovery_pre_operational_to_operational(instance) != PS3_SUCCESS) { - LOG_ERROR("hno:%u pre operational NOK!\n", - PS3_HOST(instance)); - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + if (ps3_hard_recovery_pre_operational_to_operational(instance) != + PS3_SUCCESS) { + LOG_ERROR("hno:%u pre operational NOK!\n", PS3_HOST(instance)); + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -2317,37 +2611,39 @@ static S32 ps3_hard_recovery_to_operational(struct ps3_instance *instance) goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_OPE_FAIL, instance) - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_OPERATIONAL) != PS3_SUCCESS) { + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_OPE_FAIL, instance); + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_OPERATIONAL) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to operational NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } - INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_INT, instance) - INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_PROC, instance) - INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_SUBCRIBE, instance) + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_INT, instance); + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_PROC, instance); + INJECT_START(PS3_ERR_IJ_HARD_SUBC_WAIT_EVENT_SUBCRIBE, instance); if (!instance->is_need_event) { - LOG_INFO("hno:%u not need event\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u not need event\n", PS3_HOST(instance)); goto l_out; } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); cmd = instance->event_context.event_cmd; if (cmd == NULL) { LOG_WARN_IN_IRQ(instance, "hno:%u Event is not register yet\n", - PS3_HOST(instance)); + PS3_HOST(instance)); need_subscribe = PS3_TRUE; goto l_subscribe; } - if (instance->event_context.subwork == 0) { - if (instance->hardreset_event != 0) { - instance->hardreset_event = 0; - LOG_INFO_IN_IRQ(instance, "hno:%u event cmd free, CFID:%d\n", - PS3_HOST(instance), cmd->index); + if (ps3_atomic_read(&instance->event_context.subwork) == 0) { + if (ps3_atomic_read(&instance->hardreset_event) != 0) { + ps3_atomic_set(&instance->hardreset_event, 0); + LOG_INFO_IN_IRQ(instance, + "hno:%u event cmd free, CFID:%d\n", + PS3_HOST(instance), cmd->index); instance->event_context.event_cmd = NULL; ps3_mgr_cmd_free(instance, cmd); need_subscribe = PS3_TRUE; @@ -2355,34 +2651,42 @@ static S32 ps3_hard_recovery_to_operational(struct ps3_instance *instance) } l_subscribe: - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_11, instance) - if(need_subscribe == PS3_TRUE) { - instance->event_req_info.eventTypeMapProcResult = instance->event_req_info.eventTypeMap; + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_11, instance); + if (need_subscribe == PS3_TRUE) { + instance->event_req_info.eventTypeMapProcResult = + instance->event_req_info.eventTypeMap; ret = ps3_event_subscribe(instance); + INJECT_START(PS3_ERR_IJ_OP_EVENT_SUB_FAILED, &ret) if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + ps3_spin_unlock_irqrestore( + &instance->recovery_context->recovery_lock, + flags); LOG_WARN("hno:%u IOC event subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); ret = ps3_dev_mgr_vd_info_subscribe(instance); + INJECT_START(PS3_ERR_IJ_OP_PENDING_SUB_FAILED, &ret) if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_WARN("hno:%u vd info subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } - if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == 1) { + if (ps3_atomic_read(&instance->webSubscribe_context.is_subscribe) == + 1) { ret = ps3_web_subscribe(instance); + INJECT_START(PS3_ERR_IJ_OP_WEB_SUB_FAILED, &ret) if (ret != PS3_SUCCESS && ret != -PS3_IN_UNLOAD) { err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_WARN("hno:%u web subscribe NOK ret[%d]\n", - PS3_HOST(instance), ret); + PS3_HOST(instance), ret); goto l_out; } } @@ -2395,24 +2699,26 @@ static inline void ps3_hard_reset_unnormal_handle(struct ps3_instance *instance) ps3_recovery_ready_to_force_cmd_stop(instance); ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY); - instance ->is_half_hard_reset = PS3_TRUE; + PS3_INSTANCE_STATE_RECOVERY); + instance->is_half_hard_reset = PS3_TRUE; if (!instance->state_machine.is_load || - instance->state_machine.is_suspend) { + instance->state_machine.is_suspend) { ps3_ioc_notify_unload(instance); } } -static inline S32 ps3_hard_reset_error_code_decide(struct ps3_instance *instance) +static inline int +ps3_hard_reset_error_code_decide(struct ps3_instance *instance) { - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + if (PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) { err_code = PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME; goto l_out; } - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) && \ - instance->peer_instance == NULL) { + if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) && + instance->peer_instance == NULL) { err_code = PS3_RECOVERY_INTER_ERR_FAILED; } @@ -2420,35 +2726,40 @@ static inline S32 ps3_hard_reset_error_code_decide(struct ps3_instance *instance return err_code; } -static inline S32 ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) +static inline int +ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *instance) { - if (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { - LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," - " finish[%d], flag[%d], is_load[%d]\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed, - instance->state_machine.is_load); - if (((PS3_IS_INSTANCE_PROBE(instance) || PS3_IS_INSTANCE_RESUME(instance)) && \ - instance->state_machine.is_load) || \ - PS3_IS_INSTANCE_REMOVE(instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove,\n" + "\tfinish[%d], flag[%d], is_load[%d]\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed, + instance->state_machine.is_load); + if (((PS3_IS_INSTANCE_PROBE(instance) || + PS3_IS_INSTANCE_RESUME(instance)) && + instance->state_machine.is_load) || + PS3_IS_INSTANCE_REMOVE(instance)) { ps3_hard_reset_unnormal_handle(instance); ps3_instance_state_transfer_to_dead(instance); } else if (PS3_IS_INSTANCE_SUSPEND(instance)) { ps3_hard_reset_unnormal_handle(instance); } } - if (instance->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - LOG_WARN("host_no[%u], reset while probe or in shutdown/remove," - " finish[%d], flag[%d], is_load[%d]\n", - PS3_HOST(instance->peer_instance), instance->peer_instance->is_probe_finish, - instance->peer_instance->is_probe_failed, - instance->peer_instance->state_machine.is_load); - if (((PS3_IS_INSTANCE_PROBE(instance->peer_instance) || PS3_IS_INSTANCE_RESUME(instance->peer_instance)) && \ - instance->peer_instance->state_machine.is_load) || \ - PS3_IS_INSTANCE_REMOVE(instance->peer_instance)) { + if (instance->peer_instance != NULL && + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + LOG_WARN("host_no[%u], reset while probe or in shutdown/remove,\n" + "\tfinish[%d], flag[%d], is_load[%d]\n", + PS3_HOST(instance->peer_instance), + instance->peer_instance->is_probe_finish, + instance->peer_instance->is_probe_failed, + instance->peer_instance->state_machine.is_load); + if (((PS3_IS_INSTANCE_PROBE(instance->peer_instance) || + PS3_IS_INSTANCE_RESUME(instance->peer_instance)) && + instance->peer_instance->state_machine.is_load) || + PS3_IS_INSTANCE_REMOVE(instance->peer_instance)) { ps3_hard_reset_unnormal_handle(instance->peer_instance); - ps3_instance_state_transfer_to_dead(instance->peer_instance); + ps3_instance_state_transfer_to_dead( + instance->peer_instance); } else if (PS3_IS_INSTANCE_SUSPEND(instance->peer_instance)) { ps3_hard_reset_unnormal_handle(instance->peer_instance); } @@ -2458,83 +2769,93 @@ static inline S32 ps3_hard_reset_multi_unnormal_handle(struct ps3_instance *inst static void ps3_recovery_wait_reg_access_done(struct ps3_instance *instance) { - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; LOG_DEBUG("hno:%u recovery wait reg access done start\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_wait_scsi_cmd_done(instance, PS3_TRUE); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); while (ps3_atomic_read(&instance->reg_op_count) != 0) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_20MS); - if (printed && ((++cur_cnt) * PS3_LOOP_TIME_INTERVAL_20MS > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * PS3_LOOP_TIME_INTERVAL_20MS > + PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait reg access done.\n", PS3_HOST(instance)); + LOG_WARN("host:%u wait reg access done.\n", + PS3_HOST(instance)); } } LOG_DEBUG("hno:%u recovery wait reg access done end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); } -void ps3_hard_recovery_state_finish(struct ps3_instance *instance) { +static void ps3_hard_recovery_state_finish(struct ps3_instance *instance) +{ ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_START) { - instance->recovery_context->host_reset_state = PS3_HOST_RESET_HARD_RESET_DONE; + if (instance->recovery_context->host_reset_state == + PS3_HOST_RESET_START) { + instance->recovery_context->host_reset_state = + PS3_HOST_RESET_HARD_RESET_DONE; } ps3_mutex_unlock(&instance->state_machine.lock); ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_FINISH); - INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ, instance) + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ, instance); } -static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) +static int ps3_hard_recovery_handle(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U32 retries = 0; - U32 cur_state = 0; - U32 ioc_state = 0; - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 wait_count = 0; - ULong flags = 0; - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned int retries = 0; + unsigned int cur_state = 0; + unsigned int ioc_state = 0; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int wait_count = 0; + unsigned long flags = 0; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_1, instance); INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_0, instance) + INJECT_START(PS3_ERR_IJ_RECOVERY_PCIE_ERR, instance) if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } - if (((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) - || (!ps3_hard_reset_enable_query())) - && (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY)) { - LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", + if (((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || + (!ps3_hard_reset_enable_query())) && + (instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_RECOVERY)) { + LOG_ERROR( + "hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); goto l_offline; } - INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_INT, instance) - INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_PROC, instance) - INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_SUBCRIBE, instance) - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - if (instance->event_context.abort_eventcmd != 0) { - instance->event_context.abort_eventcmd = 0; - } + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_INT, instance); + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_PROC, instance); + INJECT_START(PS3_ERR_IJ_FLAG_WAIT_EVENT_SUBCRIBE, instance); + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); - if (instance->hardreset_event == 0) { - instance->hardreset_event = 1; - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); - INJECT_START(PS3_ERR_IJ_HOST_RESET_WAIT_DECIDE, instance) + if (ps3_atomic_read(&instance->hardreset_event) == 0) + ps3_atomic_set(&instance->hardreset_event, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); + INJECT_START(PS3_ERR_IJ_HOST_RESET_WAIT_DECIDE, instance); ps3_recovery_state_transfer(instance, PS3_HARD_RECOVERY_SHALLOW); - INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_PROBE, instance) - INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_REMOVE, instance) - if (instance->is_scan_host_finish - && !instance->is_probe_finish) { + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_HOST_RESET_2, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_PROBE, instance); + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC1_REMOVE, instance); + if (instance->is_scan_host_finish && !instance->is_probe_finish) { LOG_INFO("hno:%u recovery wait until probe finish/failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { - if (instance->is_probe_finish || instance->is_probe_failed) { + if (instance->is_probe_finish || + instance->is_probe_failed) { break; } @@ -2542,66 +2863,79 @@ static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) ps3_msleep(PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS); } - LOG_INFO("hno:%u probe finish(%d)/failed(%d), continue recovery\n", - PS3_HOST(instance), instance->is_probe_finish, instance->is_probe_failed); + LOG_INFO( + "hno:%u probe finish(%d)/failed(%d), continue recovery\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed); } ps3_wait_watchdog_dect_recovery(instance); - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.hardreset_handle_pre_cb != NULL) { - ret = instance->peer_instance->recovery_function.hardreset_handle_pre_cb(instance->peer_instance); + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function.hardreset_handle_pre_cb != + NULL) { + ret = instance->peer_instance->recovery_function + .hardreset_handle_pre_cb(instance->peer_instance); if (ret != PS3_SUCCESS) { LOG_WARN("hno:%u hardreset handle pre cb NOK\n", - PS3_HOST(instance)); - if (ret == -PS3_IN_PCIE_ERR) { + PS3_HOST(instance)); + if (ret == -PS3_IN_PCIE_ERR) goto l_out; - } else { + else goto l_offline; - } } } - while(ps3_use_hard_reset_max_retry() > retries) { + while (ps3_use_hard_reset_max_retry() > retries) { LOG_DEBUG("hno:%u request IOC state to fault! retries:%d\n", - PS3_HOST(instance), retries); - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY && - retries != 0) { - instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_RETRY; - } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + PS3_HOST(instance), retries); + ps3_mutex_lock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_RECOVERY && + retries != 0) { + instance->recovery_context->heartbeat_recovery = + PS3_HEARTBEAT_HARDRESET_RETRY; + } + ps3_mutex_unlock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); instance->dump_context.is_hard_recovered = PS3_TRUE; - if (instance->recovery_context->heartbeat_recovery != PS3_HEARTBEAT_HARDRESET_RECOVERY) { - ret = instance->ioc_adpter->ioc_force_to_fault(instance); + if (instance->recovery_context->heartbeat_recovery != + PS3_HEARTBEAT_HARDRESET_RECOVERY) { + ret = instance->ioc_adpter->ioc_force_to_fault( + instance); if (ret != PS3_SUCCESS) { - LOG_WARN("hno:%u hardreset handle force to fault NOK\n", + LOG_WARN( + "hno:%u hardreset handle force to fault NOK\n", PS3_HOST(instance)); - if (ret == -PS3_IN_PCIE_ERR) { + if (ret == -PS3_IN_PCIE_ERR) goto l_out; - } } } else { ps3_recovery_wait_reg_access_done(instance); if (instance->peer_instance != NULL) { - ps3_recovery_wait_reg_access_done(instance->peer_instance); + ps3_recovery_wait_reg_access_done( + instance->peer_instance); } } ioc_state = instance->ioc_adpter->ioc_state_get(instance); LOG_DEBUG("hno:%u IOC state is %s! retries:%d\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), retries); + PS3_HOST(instance), ps3_ioc_state_print(ioc_state), + retries); - while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && ((++cur_cnt) * 10 > + PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait err scsi process\n", PS3_HOST(instance)); + LOG_WARN("host:%u wait err scsi process\n", + PS3_HOST(instance)); } } instance->ioc_adpter->irq_disable(instance); - INJECT_START(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, instance) + INJECT_START(PS3_ERR_IJ_WAIT_IOCTL_IN_RECOVERY, instance); #ifndef _WINDOWS ps3_irqs_sync(instance); #endif @@ -2610,191 +2944,249 @@ static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_4, instance); err_code = ps3_hard_recovery_to_ready(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u IOC state to ready failed! retries:%d\n", + LOG_INFO( + "hno:%u IOC state to ready failed! retries:%d\n", PS3_HOST(instance), retries); if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == + PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } LOG_INFO("hno:%u IOC state to ready success! retries:%d\n", - PS3_HOST(instance), retries); + PS3_HOST(instance), retries); - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.hardreset_handle_wait_ready_cb != NULL) { - err_code = instance->peer_instance->recovery_function.hardreset_handle_wait_ready_cb( \ - instance->peer_instance); + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function + .hardreset_handle_wait_ready_cb != NULL) { + err_code = instance->peer_instance->recovery_function + .hardreset_handle_wait_ready_cb( + instance->peer_instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u ioc state to ready failed! retries:%d\n", + LOG_INFO( + "hno:%u ioc state to ready failed! retries:%d\n", PS3_HOST(instance), retries); - if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + if (err_code == + PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == + PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO("hno:%u ioc state to ready success! retries:%d\n", + LOG_INFO( + "hno:%u ioc state to ready success! retries:%d\n", PS3_HOST(instance), retries); } - INJECT_START(PS3_ERR_IJ_FWSTATE_REMOVE, instance) + INJECT_START(PS3_ERR_IJ_FWSTATE_REMOVE, instance); err_code = ps3_hard_reset_multi_unnormal_handle(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_INFO("driver loading or unloading err_code:%d\n", - err_code); - if (err_code == PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME) { + err_code); + if (err_code == PS3_RECOVERY_INTER_ERR_SUSPEND_RESUME) goto l_out; - } else { + else goto l_offline; - } } INJECT_START(PS3_ERR_IJ_FORCE_WAIT_CLI_CMD, instance); INJECT_START(PS3_ERR_IJ_WATCHDOG_WAIT_RUNNING, instance); err_code = ps3_hard_recovery_to_pre_operational(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", + LOG_INFO( + "hno:%u IOC state to pre-operatioal failed! retries:%d\n", PS3_HOST(instance), retries); - INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, instance->peer_instance) + INJECT_START( + PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_DEAD_FAIL1, + instance->peer_instance); if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - if(instance->peer_instance != NULL) { - if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { - LOG_WARN("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance->peer_instance)); + if (instance->peer_instance != NULL) { + if (ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != + PS3_SUCCESS) { + LOG_WARN( + "hno:%u transfer to recovery NOK!\n", + PS3_HOST( + instance->peer_instance)); goto l_offline; } } retries++; continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == + PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO("hno:%u IOC state to pre-operatioal success! retries:%d\n", + LOG_INFO( + "hno:%u IOC state to pre-operatioal success! retries:%d\n", PS3_HOST(instance), retries); - - INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, instance) - if (instance->peer_instance != NULL && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) && \ - instance->peer_instance->recovery_function.hardreset_handle_init_running_cb != NULL) { - if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ - err_code = instance->peer_instance->recovery_function.hardreset_handle_init_running_cb( \ - instance->peer_instance); - if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u IOC state to pre-operatioal failed! retries:%d\n", + INJECT_START(PS3_ERR_IJ_RECOVERY_WAIT_FUNC0_RUNNING_1, instance); + if (instance->peer_instance != NULL && + !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance) && + instance->peer_instance->recovery_function + .hardreset_handle_init_running_cb != NULL) { + if (ps3_atomic_read(&instance->peer_instance + ->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { + err_code = + instance->peer_instance + ->recovery_function + .hardreset_handle_init_running_cb( + instance->peer_instance); + if (err_code == + PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO( + "hno:%u IOC state to pre-operatioal success! retries:%d\n", PS3_HOST(instance), retries); - if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - INJECT_START(PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, instance->peer_instance) - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_PRE_OPERATIONAL, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { - LOG_WARN("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance->peer_instance)); - goto l_offline; - } - retries++; - continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { - goto l_out; - } else { + goto l_operational; + } + LOG_INFO( + "hno:%u IOC state to pre-operatioal failed! retries:%d\n", + PS3_HOST(instance), retries); + if (err_code == + PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + INJECT_START( + PS3_ERR_IJ_FORCE_TO_PREOPERTIONAL_PEER_DEAD_FAIL, + instance->peer_instance); + if (ps3_instance_state_transfer( + instance, + PS3_INSTANCE_STATE_PRE_OPERATIONAL, + PS3_INSTANCE_STATE_RECOVERY) != + PS3_SUCCESS) { + LOG_WARN( + "hno:%u transfer to recovery NOK!\n", + PS3_HOST( + instance->peer_instance)); goto l_offline; } + retries++; + continue; + } else if (err_code == + PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + goto l_out; + } else { + goto l_offline; } - LOG_INFO("hno:%u IOC state to pre-operatioal success! retries:%d\n", - PS3_HOST(instance), retries); } } - INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, instance) + +l_operational: + INJECT_START(PS3_ERR_IJ_WDT_WAIT_REC_REQ_2, instance); err_code = ps3_hard_recovery_to_operational(instance); if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u IOC state to operatioal failed! retries:%d\n", + LOG_INFO( + "hno:%u IOC state to operatioal failed! retries:%d\n", PS3_HOST(instance), retries); if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { retries++; continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + } else if (err_code == + PS3_RECOVERY_INTER_ERR_PCIE_ERR) { goto l_out; } else { goto l_offline; } } - LOG_INFO("hno:%u IOC state to operatioal success! retries:%d\n", + LOG_INFO( + "hno:%u IOC state to operatioal success! retries:%d\n", PS3_HOST(instance), retries); - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.hardreset_handle_post_cb != NULL) { - if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ - err_code = instance->peer_instance->recovery_function.hardreset_handle_post_cb( \ - instance->peer_instance); - if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { - LOG_INFO("hno:%u IOC state to operatioal failed! retries:%d\n", - PS3_HOST(instance), retries); - if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { - retries++; - continue; - } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { - goto l_out; - } else { - goto l_offline; - } + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function + .hardreset_handle_post_cb != NULL) { + if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL( + instance->peer_instance) && + ps3_atomic_read(&instance->peer_instance + ->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { + err_code = + instance->peer_instance + ->recovery_function + .hardreset_handle_post_cb( + instance->peer_instance); + if (err_code != PS3_RECOVERY_INTER_ERR_SUCCESS) { + LOG_INFO( + "hno:%u IOC state to operatioal failed! retries:%d\n", + PS3_HOST(instance), + retries); + if (err_code == PS3_RECOVERY_INTER_ERR_NEED_RECOVERY) { + retries++; + continue; + } else if (err_code == PS3_RECOVERY_INTER_ERR_PCIE_ERR) { + goto l_out; + } else { + goto l_offline; } - LOG_INFO("hno:%u IOC state to operatioal success! retries:%d\n", - PS3_HOST(instance), retries); } + LOG_INFO( + "hno:%u IOC state to operatioal success! retries:%d\n", + PS3_HOST(instance), retries); } } break; } + INJECT_START(PS3_ERR_IJ_COMPLETE_FAULT, instance) cur_state = ps3_atomic_read(&instance->state_machine.state); if ((cur_state != PS3_INSTANCE_STATE_OPERATIONAL || - ps3_use_hard_reset_max_retry() == retries) && !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { + ps3_use_hard_reset_max_retry() == retries) && + !PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance)) { LOG_ERROR("hno:%u hard reset failed! cur_state:%s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); goto l_offline; } ret = ps3_recovery_complete(instance); - if(ret != PS3_SUCCESS){ - LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state),ret); - if (ret == -PS3_IN_PCIE_ERR) { + if (ret != PS3_SUCCESS) { + LOG_WARN( + "hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + ret); + if (ret == -PS3_IN_PCIE_ERR) goto l_out; - } else { + else goto l_offline; - } } - if (instance->peer_instance == NULL || \ - instance->peer_instance->recovery_function.hardreset_handle_finish_cb == NULL) { + if (instance->peer_instance == NULL || + instance->peer_instance->recovery_function + .hardreset_handle_finish_cb == NULL) { ps3_hard_recovery_state_finish(instance); LOG_INFO("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); } else { - if(!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { - if(ps3_atomic_read(&instance->peer_instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD){ - ret = instance->peer_instance->recovery_function.hardreset_handle_finish_cb( \ - instance->peer_instance); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, &ret) + if (!PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance->peer_instance)) { + if (ps3_atomic_read(&instance->peer_instance + ->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { + ret = instance->peer_instance->recovery_function + .hardreset_handle_finish_cb( + instance->peer_instance); + INJECT_START( + PS3_ERR_IJ_FORCE_RECOVERY_PEER_COMPLETE_FAILED, + &ret); } if (ret != PS3_SUCCESS) { - LOG_WARN("hno:%u hardreset handle running cb NOK\n", + LOG_WARN( + "hno:%u hardreset handle running cb NOK\n", PS3_HOST(instance->peer_instance)); - if (ret == -PS3_IN_PCIE_ERR) { + if (ret == -PS3_IN_PCIE_ERR) goto l_out; - } else { + else goto l_offline; - } } } else { ps3_hard_recovery_state_finish(instance); @@ -2802,43 +3194,49 @@ static S32 ps3_hard_recovery_handle(struct ps3_instance *instance) } ps3_ioc_can_hardreset_set(instance, PS3_IOC_CAN_HARDRESET); if (instance->peer_instance != NULL) { - ps3_ioc_can_hardreset_set(instance->peer_instance, PS3_IOC_CAN_HARDRESET); + ps3_ioc_can_hardreset_set(instance->peer_instance, + PS3_IOC_CAN_HARDRESET); } return ret; l_offline: ps3_instance_state_transfer_to_dead(instance); - if (instance->peer_instance != NULL && \ - instance->peer_instance->recovery_function.hardreset_handle_offline_cb != NULL) { - instance->peer_instance->recovery_function.hardreset_handle_offline_cb( \ - instance->peer_instance); + if (instance->peer_instance != NULL && + instance->peer_instance->recovery_function + .hardreset_handle_offline_cb != NULL) { + instance->peer_instance->recovery_function + .hardreset_handle_offline_cb(instance->peer_instance); } l_out: ps3_hard_recovery_state_finish(instance); if (ps3_pci_err_recovery_get(instance)) { - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_lock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); instance->recovery_context->heartbeat_recovery = - PS3_HEARTBEAT_NULL; - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + PS3_HEARTBEAT_NULL; + ps3_mutex_unlock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); } LOG_WARN("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; return ret; } -static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) +static int ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); - while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && + ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u cmd stop wait err scsi process\n", PS3_HOST(instance)); + LOG_WARN("host:%u cmd stop wait err scsi process\n", + PS3_HOST(instance)); } } @@ -2846,63 +3244,66 @@ static S32 ps3_recovery_ready_to_force_cmd_stop(struct ps3_instance *instance) ps3_cmd_force_stop(instance); - LOG2_DEBUG("hno:%u force cmd stop end\n", - PS3_HOST(instance)); + LOG2_DEBUG("hno:%u force cmd stop end\n", PS3_HOST(instance)); return ret; } -static S32 ps3_recovery_ready_to_running(struct ps3_instance *instance) +static int ps3_recovery_ready_to_running(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + int ret = PS3_SUCCESS; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_HARDRESET); - while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && + ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u to running wait err scsi process\n", PS3_HOST(instance)); + LOG_WARN("host:%u to running wait err scsi process\n", + PS3_HOST(instance)); } } ps3_all_reply_fifo_complete(instance); - + INJECT_START(PS3_ERR_IJ_RECOVERY_BLOCK_BEFORE_RUNNING, instance); ps3_cmd_force_stop(instance); if (!ps3_bit_pos_update(instance)) { - LOG_ERROR("hno:%u update bit pos NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u update bit pos NOK\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } - if ((ret = instance->ioc_adpter->ioc_init_proc(instance)) != PS3_SUCCESS) { - LOG_ERROR("hno:%u init IOC frame NOK\n", - PS3_HOST(instance)); + ret = instance->ioc_adpter->ioc_init_proc(instance); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u init IOC frame NOK\n", PS3_HOST(instance)); goto l_out; } l_out: - LOG_DEBUG("hno:%u ready to running :%d\n", - PS3_HOST(instance), ret); + LOG_DEBUG("hno:%u ready to running :%d\n", PS3_HOST(instance), ret); return ret; } -static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cmds) +static void ps3_can_queue_reset(struct ps3_instance *instance, + unsigned int cur_max_fw_cmds) { - ULong flag = 0; - LOG_INFO("hno:%u IOC cur max fw cmd is %d!\n", - PS3_HOST(instance), cur_max_fw_cmds); + unsigned long flag = 0; + + LOG_INFO("hno:%u IOC cur max fw cmd is %d!\n", PS3_HOST(instance), + cur_max_fw_cmds); if (cur_max_fw_cmds <= instance->cmd_context.max_cmd_count) { - instance->cmd_attr.cur_can_que = cur_max_fw_cmds - + instance->cmd_attr.cur_can_que = + cur_max_fw_cmds - instance->cmd_context.max_mgr_cmd_count - instance->cmd_context.max_r1x_cmd_count; spin_lock_irqsave(instance->host->host_lock, flag); instance->host->can_queue = instance->cmd_attr.cur_can_que; - LOG_INFO_IN_IRQ(instance, + LOG_INFO_IN_IRQ( + instance, "hno:%u IOC cur max fw cmd %d is less than %d, can queue is updated to %d!\n", PS3_HOST(instance), cur_max_fw_cmds, instance->cmd_context.max_cmd_count, @@ -2911,101 +3312,104 @@ static void ps3_can_queue_reset(struct ps3_instance *instance, U32 cur_max_fw_cm } } -static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, U8 reset_flag) +static void ps3_cmd_reset_flag_set(struct ps3_instance *instance, + unsigned char reset_flag) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - ULong flags = 0; + unsigned long flags = 0; - if (context->cmd_buf == NULL) { + if (context->cmd_buf == NULL) return; - } for (i = 0; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &flags); - if (cmd->cmd_state.state != PS3_CMD_STATE_INIT) { + if (cmd->cmd_state.state != PS3_CMD_STATE_INIT) cmd->cmd_state.reset_flag = reset_flag; - } ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, flags); } } -static Bool ps3_is_scsi_task_cmd(struct ps3_cmd *cmd) +static unsigned char ps3_is_scsi_task_cmd(struct ps3_cmd *cmd) { - U8 cmd_type = cmd->req_frame->word[0]; + unsigned char cmd_type = cmd->req_frame->word[0]; - if (cmd_type == PS3_CMD_SCSI_TASK_MANAGEMENT) { + if (cmd_type == PS3_CMD_SCSI_TASK_MANAGEMENT) return PS3_TRUE; - } else { + else return PS3_FALSE; - } } void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) { - S32 i = 0; + int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *peer_cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; struct scsi_cmnd *s_cmd = NULL; struct ps3_scsi_priv_data *data = NULL; - U16 count = 0; + unsigned short count = 0; #ifndef _WINDOWS - S32 ret_code = 0 ; + int ret_code = 0; - if (ps3_pci_err_recovery_get(instance)) { + if (ps3_pci_err_recovery_get(instance)) ret_code = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - } else { + else ret_code = ps3_get_requeue_or_reset(); - } #endif ps3_mutex_lock(&instance->recovery_context->free_cmd_lock); for (i = 0; i < instance->cmd_attr.cur_can_que; i++) { cmd = context->cmd_buf[i]; if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || - (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { + (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { continue; } LOG_INFO("hno:%u force stop scsi CFID[%d] [%u]\n", - PS3_HOST(instance), i, cmd->cmd_state.state); + PS3_HOST(instance), i, cmd->cmd_state.state); s_cmd = cmd->scmd; count++; PS3_IO_OUTSTAND_DEC(instance, s_cmd); - PS3_VD_OUTSTAND_DEC(instance, s_cmd); + PS3_VD_OUTSTAND_DEC(instance, cmd); PS3_DEV_IO_OUTSTAND_DEC(instance, cmd); - PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); - ps3_qos_cmd_update(instance, cmd); + PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, + PS3_REPLY_WORD_FLAG_FAIL); + ps3_qos_cmd_update(instance, cmd, PS3_FALSE); #ifndef _WINDOWS PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); s_cmd->result = ret_code; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#if defined(PS3_SUPPORT_CMD_SCP) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); - if (likely(cmd && cmd->scmd && cmd->scmd->device && cmd->scmd->device->hostdata)) { - data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; + if (likely(cmd && cmd->scmd && cmd->scmd->device && + cmd->scmd->device->hostdata)) { + data = (struct ps3_scsi_priv_data *) + cmd->scmd->device->hostdata; if (likely(data != NULL) && - data->lock_mgr.hash_mgr != NULL) { + data->lock_mgr.hash_mgr != NULL) { ps3_r1x_write_unlock(&data->lock_mgr, cmd); } } else { - LOG_WARN("hno:%u force stop scsi has Null pointer CFID[%u]\n", + LOG_WARN( + "hno:%u force stop scsi has Null pointer CFID[%u]\n", PS3_HOST(instance), i); } peer_cmd = cmd->r1x_peer_cmd; ps3_scsi_cmd_free(cmd); if (peer_cmd != NULL) { - LOG_DEBUG("hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", + LOG_DEBUG( + "hno:%u force stop r1x scsi CFID[%d] and CFID[%d]\n", PS3_HOST(instance), i, peer_cmd->index); - PS3_IOC_DRV2IOC_BACK_INC(peer_cmd->instance, peer_cmd, PS3_REPLY_WORD_FLAG_FAIL); + PS3_IOC_DRV2IOC_BACK_INC(peer_cmd->instance, peer_cmd, + PS3_REPLY_WORD_FLAG_FAIL); ps3_r1x_peer_cmd_free_nolock(peer_cmd); } SCMD_IO_DONE(s_cmd); @@ -3013,140 +3417,159 @@ void ps3_scsi_cmd_force_stop(struct ps3_instance *instance) PS3_IO_BACK_ERR_INC(cmd->instance, s_cmd, cmd->index); scsi_cmnd_hoststatus_set(s_cmd, DID_RESET); data = scsi_device_private_data(s_cmd); - if(likely(data != NULL) && data->lock_mgr.hash_mgr != NULL){ + if (likely(data != NULL) && data->lock_mgr.hash_mgr != NULL) ps3_r1x_write_unlock(&data->lock_mgr, cmd); - } ps3_scsi_cmd_done(cmd); #endif } ps3_mutex_unlock(&instance->recovery_context->free_cmd_lock); LOG_WARN("hno:%u force stop scsi cmd count[%u] during hard recovery\n", - PS3_HOST(instance), count); + PS3_HOST(instance), count); - return; } void ps3_mgr_cmd_force_stop(struct ps3_instance *instance) { - U32 i = 0; + unsigned int i = 0; struct ps3_cmd *cmd = NULL; struct ps3_cmd *abort_cmd = NULL; struct ps3_cmd_context *context = &instance->cmd_context; - ULong cmd_lock_flags = 0; + unsigned long cmd_lock_flags = 0; for (i = context->max_scsi_cmd_count; i < context->max_cmd_count; i++) { cmd = context->cmd_buf[i]; ps3_spin_lock_irqsave(&cmd->cmd_state.lock, &cmd_lock_flags); if ((cmd->cmd_state.state == PS3_CMD_STATE_INIT) || - (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { - LOG_FILE_WARN("hno:%u init or complete CFID:%d\n", PS3_HOST(instance), i); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + (cmd->cmd_state.state == PS3_CMD_STATE_COMPLETE)) { + LOG_FILE_WARN("hno:%u init or complete CFID:%d\n", + PS3_HOST(instance), i); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); continue; } if (cmd->cmd_state.state == PS3_CMD_STATE_DEAD) { - LOG_FILE_WARN("hno:%u force free CFID:%d\n", PS3_HOST(instance), i); - PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); - - if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL){ - LOG_FILE_WARN("hno:%u force free CFID:%d ioctl buff\n", PS3_HOST(instance), i); + LOG_FILE_WARN("hno:%u force free CFID:%d\n", + PS3_HOST(instance), i); + PS3_MGR_CMD_BACK_INC(instance, cmd, + PS3_REPLY_WORD_FLAG_FAIL); + if (PS3_MGR_CMD_TYPE(cmd) == PS3_CMD_IOCTL) { + LOG_FILE_WARN( + "hno:%u force free CFID:%d ioctl buff\n", + PS3_HOST(instance), i); ps3_ioctl_buff_release(cmd); } - if (cmd == instance->event_context.event_cmd) { + if (cmd == instance->event_context.event_cmd) instance->event_context.event_cmd = NULL; - } ps3_mgr_cmd_free_nolock(instance, cmd); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); continue; } - if (cmd->req_frame->mgrReq.reqHead.noReplyWord == PS3_CMD_WORD_NO_REPLY_WORD) { - LOG_FILE_WARN("hno:%u force complete no reply word CFID:%d\n", + if (cmd->req_frame->mgrReq.reqHead.noReplyWord == + PS3_CMD_WORD_NO_REPLY_WORD) { + LOG_FILE_WARN( + "hno:%u force complete no reply word CFID:%d\n", PS3_HOST(instance), i); if (ps3_is_scsi_task_cmd(cmd)) { - cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; + cmd->resp_frame->normalRespFrame.respStatus = + SCSI_STATUS_GOOD; } else { - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_BUSY; } - PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + PS3_MGR_CMD_BACK_INC(instance, cmd, + PS3_REPLY_WORD_FLAG_FAIL); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); continue; } if (ps3_is_scsi_task_cmd(cmd)) { - cmd->resp_frame->normalRespFrame.respStatus = SCSI_STATUS_GOOD; - PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = + SCSI_STATUS_GOOD; + PS3_MGR_CMD_BACK_INC(instance, cmd, + PS3_REPLY_WORD_FLAG_FAIL); cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; complete(&cmd->sync_done); - LOG_FILE_WARN("hno:%u force complete task mgr CFID:%d\n", + LOG_FILE_WARN( + "hno:%u force complete task mgr CFID:%d\n", PS3_HOST(instance), i); - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); continue; } if (cmd->req_frame->mgrReq.syncFlag == 1) { - PS3_MGR_CMD_BACK_INC(instance, cmd, PS3_REPLY_WORD_FLAG_FAIL); - cmd->resp_frame->normalRespFrame.respStatus = PS3_DRV_MGR_BUSY; + PS3_MGR_CMD_BACK_INC(instance, cmd, + PS3_REPLY_WORD_FLAG_FAIL); + cmd->resp_frame->normalRespFrame.respStatus = + PS3_DRV_MGR_BUSY; cmd->cmd_state.state = PS3_CMD_STATE_COMPLETE; - LOG_FILE_WARN("hno:%u force complete sync mgr CFID:%d\n", + LOG_FILE_WARN( + "hno:%u force complete sync mgr CFID:%d\n", PS3_HOST(instance), i); complete(&cmd->sync_done); } else { if (instance->is_need_event) { - if (cmd == instance->event_context.event_cmd || + if (cmd == instance->event_context.event_cmd || cmd == instance->dev_context.vd_pending_cmd || - cmd == instance->webSubscribe_context.webSubscribe_cmd) { - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); - LOG_INFO("trace_id[0x%llx], hno:%u Event cmd:%d ignore!\n", - cmd->trace_id, PS3_HOST(instance), cmd->index); - continue; - } - } + cmd == instance->webSubscribe_context + .webSubscribe_cmd) { + ps3_spin_unlock_irqrestore( + &cmd->cmd_state.lock, + cmd_lock_flags); + LOG_INFO( + "trace_id[0x%llx], hno:%u Event cmd:%d ignore!\n", + cmd->trace_id, + PS3_HOST(instance), cmd->index); + continue; + } + } } - ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, cmd_lock_flags); + ps3_spin_unlock_irqrestore(&cmd->cmd_state.lock, + cmd_lock_flags); } if (instance->is_need_event) { - if(instance->event_context.event_abort_cmd != NULL){ + if (instance->event_context.event_abort_cmd != NULL) { abort_cmd = instance->event_context.event_abort_cmd; instance->event_context.event_abort_cmd = NULL; } - if(abort_cmd != NULL){ + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } - if(instance->dev_context.vdpending_abort_cmd != NULL){ + if (instance->dev_context.vdpending_abort_cmd != NULL) { abort_cmd = instance->dev_context.vdpending_abort_cmd; instance->dev_context.vdpending_abort_cmd = NULL; } - if(abort_cmd != NULL){ + if (abort_cmd != NULL) ps3_task_cmd_free(instance, abort_cmd); - } - if(instance->webSubscribe_context.web_abort_cmd != NULL){ - abort_cmd = instance->webSubscribe_context.web_abort_cmd; - instance->webSubscribe_context.web_abort_cmd = NULL; - } - if(abort_cmd != NULL){ - ps3_task_cmd_free(instance, abort_cmd); - } + if (instance->webSubscribe_context.web_abort_cmd != NULL) { + abort_cmd = + instance->webSubscribe_context.web_abort_cmd; + instance->webSubscribe_context.web_abort_cmd = NULL; + } + if (abort_cmd != NULL) + ps3_task_cmd_free(instance, abort_cmd); } } void ps3_cmd_force_stop(struct ps3_instance *instance) { - S32 ret_code = 0; + int ret_code = 0; struct ps3_cmd_context *context = &instance->cmd_context; - if (context->cmd_buf == NULL) { + + if (context->cmd_buf == NULL) return; - } - if (ps3_pci_err_recovery_get(instance)) { + if (ps3_pci_err_recovery_get(instance)) ret_code = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - } else { + else ret_code = ps3_get_requeue_or_reset(); - } ps3_r1x_conflict_queue_clean_all(instance, ret_code, PS3_FALSE); @@ -3158,32 +3581,32 @@ void ps3_cmd_force_stop(struct ps3_instance *instance) ps3_mgr_cmd_force_stop(instance); } -Bool ps3_is_need_hard_reset(struct ps3_instance *instance) +unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance) { - Bool need_hardreset = PS3_FALSE; - Bool is_support_halt = PS3_FALSE; - U32 hard_reset_enable = 0; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - if (!ps3_feature_support_reg_get(instance)) { + unsigned char need_hardreset = PS3_FALSE; + unsigned char is_support_halt = PS3_FALSE; + unsigned int hard_reset_enable = 0; + int cur_state = PS3_INSTANCE_STATE_INIT; + + if (!ps3_feature_support_reg_get(instance)) goto l_out; - } is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); LOG_INFO("hno:%u instance state not support hardreset!\n", - PS3_HOST(instance)); - if(is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)){ + PS3_HOST(instance)); + + if (is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_INFO("hno:%u instance state while support halt!\n", - PS3_HOST(instance)); - while (1) { + PS3_HOST(instance)); + while (1) ps3_msleep(10); - } } - if(PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance)) { + if (PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance)) { need_hardreset = PS3_TRUE; goto l_out; } @@ -3192,11 +3615,11 @@ Bool ps3_is_need_hard_reset(struct ps3_instance *instance) cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno[%u], ready to hard reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); - if((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) - || (!hard_reset_enable)){ + PS3_HOST(instance), namePS3InstanceState(cur_state)); + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || + (!hard_reset_enable)) { LOG_INFO("hno:%u instance state not support hardreset!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_instance_state_transfer_to_dead(instance); } else { need_hardreset = PS3_TRUE; @@ -3206,20 +3629,25 @@ Bool ps3_is_need_hard_reset(struct ps3_instance *instance) return need_hardreset; } -S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) +int ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + if (instance->peer_instance != NULL && - instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context->parall_hardreset_state != + PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep( + PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { - ret = ps3_hard_recovery_request(instance); - if (ret != PS3_SUCCESS){ + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); + if (ret != PS3_SUCCESS) { LOG_WARN("hno:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } } @@ -3228,48 +3656,56 @@ S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance) l_out: return ret; } -S32 ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) +int ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; LOG_WARN("hno[%u], ready to hard reset\n", PS3_HOST(instance)); - if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ + if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW) { goto l_out; } if (instance->peer_instance != NULL && - instance->recovery_context->parall_hardreset_state == PS3_PARALLEL_HARDRESET_STATE_PENDING) { - instance->recovery_context->parall_hardreset_state = PS3_PARALLEL_HARDRESET_STATE_CONTINUE; - while (instance->recovery_context->parall_hardreset_state != PS3_PARALLEL_HARDRESET_STATE_INIT) { - ps3_msleep(PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); + instance->recovery_context->parall_hardreset_state == + PS3_PARALLEL_HARDRESET_STATE_PENDING) { + instance->recovery_context->parall_hardreset_state = + PS3_PARALLEL_HARDRESET_STATE_CONTINUE; + while (instance->recovery_context->parall_hardreset_state != + PS3_PARALLEL_HARDRESET_STATE_INIT) { + ps3_msleep( + PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL); } } else { - ret = ps3_hard_recovery_request_with_retry(instance); - if (ret != PS3_SUCCESS){ + ret = ps3_hard_recovery_request_with_retry(instance, PS3_FALSE); + if (ret != PS3_SUCCESS) { LOG_WARN("hno:%u hard recovery request NOK\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } } ps3_recovery_cancel_work_sync(instance); - if (instance->ioc_adpter->ioc_state_get(instance) != PS3_FW_STATE_READY) { + if (instance->ioc_adpter->ioc_state_get(instance) != + PS3_FW_STATE_READY) { ret = -PS3_FAILED; } - LOG_WARN("device[%d] hard reset success,exit init proc %d.\n", instance->pdev->dev.id, ret); + LOG_WARN("device[%d] hard reset success,exit init proc %d.\n", + instance->pdev->dev.id, ret); return ret; l_out: - if (ps3_recovery_is_state_halt(instance)) { + if (ps3_recovery_is_state_halt(instance)) { LOG_WARN("hno:%u driver_state:DEAD or HALT now !!!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_end; } - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) - || (!ps3_hard_reset_enable_query())) { - LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || + (!ps3_hard_reset_enable_query())) { + LOG_ERROR( + "hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); ret = -PS3_FAILED; @@ -3279,65 +3715,70 @@ S32 ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance) ret = instance->ioc_adpter->ioc_force_to_fault(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] doorbell fault NOK.\n", instance->pdev->dev.id); + LOG_ERROR("device[%d] doorbell fault NOK.\n", + instance->pdev->dev.id); } if (!instance->ioc_adpter->ioc_hard_reset) { ret = -PS3_FAILED; - LOG_ERROR("device[%d] ioc_hard_reset is null.\n", instance->pdev->dev.id); + LOG_ERROR("device[%d] ioc_hard_reset is null.\n", + instance->pdev->dev.id); goto l_end; } ret = instance->ioc_adpter->ioc_hard_reset(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", instance->pdev->dev.id); + LOG_ERROR("device[%d] hard reset NOK,exit init proc.\n", + instance->pdev->dev.id); goto l_end; } - LOG_WARN("device[%d] hard reset success,exit init proc.\n", instance->pdev->dev.id); + LOG_WARN("device[%d] hard reset success,exit init proc.\n", + instance->pdev->dev.id); ret = -PS3_FAILED; l_end: return ret; } -S32 ps3_hardreset_handle_pre(struct ps3_instance *instance) +int ps3_hardreset_handle_pre(struct ps3_instance *instance) { - U32 wait_count = 0; - ULong flags = 0; + unsigned int wait_count = 0; + unsigned long flags = 0; LOG_DEBUG("hno:%u functoin[%d], hardreset handle pre start\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_1, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_1, instance); if (ps3_pci_err_recovery_get(instance)) { LOG_WARN("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); return -PS3_IN_PCIE_ERR; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, instance) - if(!PS3_IS_INSTANCE_PROBE_INIT(instance)) { - - if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) - || (!ps3_hard_reset_enable_query())) { - LOG_ERROR("hno:%u soc feature unsupport Hard reset! need to be offline!\n", + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_NOT_SUPPORT, instance); + if (!PS3_IS_INSTANCE_PROBE_INIT(instance)) { + if ((!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)) || + (!ps3_hard_reset_enable_query())) { + LOG_ERROR( + "hno:%u soc feature unsupport Hard reset! need to be offline!\n", PS3_HOST(instance)); return -PS3_FAILED; } } - ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, &flags); - if (instance->event_context.abort_eventcmd != 0) { - instance->event_context.abort_eventcmd = 0; - } + ps3_spin_lock_irqsave(&instance->recovery_context->recovery_lock, + &flags); + if (ps3_atomic_read(&instance->event_context.abort_eventcmd) != 0) + ps3_atomic_set(&instance->event_context.abort_eventcmd, 0); - if (instance->hardreset_event == 0) { - instance->hardreset_event = 1; - } - ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, flags); + if (ps3_atomic_read(&instance->hardreset_event) == 0) + ps3_atomic_set(&instance->hardreset_event, 1); + ps3_spin_unlock_irqrestore(&instance->recovery_context->recovery_lock, + flags); - if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish - && !instance->is_probe_finish) { + if (PS3_IS_INSTANCE_PROBE(instance) && instance->is_scan_host_finish && + !instance->is_probe_finish) { LOG_INFO("hno:%u recovery wait until probe finish/failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); while (wait_count < PS3_RECOVERY_WAIT_PROBE_FINISH_LOOP_COUNT) { - if (instance->is_probe_finish || instance->is_probe_failed) { + if (instance->is_probe_finish || + instance->is_probe_failed) { break; } @@ -3345,39 +3786,44 @@ S32 ps3_hardreset_handle_pre(struct ps3_instance *instance) ps3_msleep(PS3_RECOVERY_WAIT_LOOP_TIME_INTERVAL_20MS); } - LOG_INFO("hno:%u probe finish(%d)/failed(%d), continue recovery\n", - PS3_HOST(instance), instance->is_probe_finish, instance->is_probe_failed); + LOG_INFO( + "hno:%u probe finish(%d)/failed(%d), continue recovery\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed); } ps3_wait_watchdog_dect_recovery(instance); LOG_DEBUG("hno:%u functoin[%d], hardreset handle pre end\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); return PS3_SUCCESS; } -S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) +int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) { - S32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; - U32 ioc_state = 0; - S32 ret = PS3_SUCCESS; - U16 cur_cnt = 0; - Bool printed = PS3_TRUE; + int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int ioc_state = 0; + int ret = PS3_SUCCESS; + unsigned short cur_cnt = 0; + unsigned char printed = PS3_TRUE; LOG_DEBUG("hno:%u function[%d], hardreset handle wait ready start.\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); instance->dump_context.is_hard_recovered = PS3_TRUE; ioc_state = instance->ioc_adpter->ioc_state_get(instance); - LOG_DEBUG("hno:%u ioc state is %s! function:%d\n", - PS3_HOST(instance), ps3_ioc_state_print(ioc_state), ps3_get_pci_function(instance->pdev)); + LOG_DEBUG("hno:%u ioc state is %s! function:%d\n", PS3_HOST(instance), + ps3_ioc_state_print(ioc_state), + ps3_get_pci_function(instance->pdev)); - while(ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { + while (ps3_atomic_read(&instance->is_err_scsi_processing) > 0) { ps3_msleep(10); - if (printed && ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { + if (printed && + ((++cur_cnt) * 10 > PS3_RECOVERY_WHILE_PRINT_REACH_TIME)) { printed = PS3_FALSE; - LOG_WARN("host:%u wait ready wait err scsi process\n", PS3_HOST(instance)); + LOG_WARN("host:%u wait ready wait err scsi process\n", + PS3_HOST(instance)); } } instance->ioc_adpter->irq_disable(instance); @@ -3385,25 +3831,29 @@ S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) ps3_irqs_sync(instance); #endif - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_6, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_6, instance); if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno:%u pci recovery resetting\n", PS3_HOST(instance)); + LOG_WARN("hno:%u pci recovery resetting\n", + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; goto l_out; } INJECT_START(PS3_ERR_IJ_HARD_WAIT_READY_FAILED_F1, instance); - if ((ret = ps3_ioc_state_transfer_to_ready(instance)) != PS3_SUCCESS) { + ret = ps3_ioc_state_transfer_to_ready(instance); + if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset to ready NOK,%s!\n", - PS3_HOST(instance), - ps3_ioc_state_print(ioc_state)); + PS3_HOST(instance), ps3_ioc_state_print(ioc_state)); if (ret == -PS3_IN_PCIE_ERR) { err_code = PS3_RECOVERY_INTER_ERR_PCIE_ERR; } else { - if (ps3_instance_state_transfer(instance->peer_instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY) != PS3_SUCCESS) { + if (ps3_instance_state_transfer( + instance->peer_instance, + PS3_INSTANCE_STATE_READY, + PS3_INSTANCE_STATE_RECOVERY) != + PS3_SUCCESS) { LOG_WARN("hno:%u transfer to recovery NOK!\n", - PS3_HOST(instance->peer_instance)); + PS3_HOST(instance->peer_instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; goto l_out; } @@ -3411,164 +3861,188 @@ S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance) } goto l_out; } - if (instance->state_machine.is_load || \ - instance->state_machine.is_suspend) { - if (ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_RECOVERY,\ - PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { + if (instance->state_machine.is_load || + instance->state_machine.is_suspend) { + if (ps3_instance_state_transfer( + instance, PS3_INSTANCE_STATE_RECOVERY, + PS3_INSTANCE_STATE_READY) != PS3_SUCCESS) { LOG_ERROR("hno:%u transfer to ready NOK!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); err_code = PS3_RECOVERY_INTER_ERR_INTERRUPT; } } l_out: LOG_DEBUG("hno:%u function[%d], hardreset handle wait ready end.\n", - PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); + PS3_HOST(instance), ps3_get_pci_function(instance->pdev)); return err_code; } -S32 ps3_hardreset_handle_init_running(struct ps3_instance *instance) +int ps3_hardreset_handle_init_running(struct ps3_instance *instance) { - U32 err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; + unsigned int err_code = PS3_RECOVERY_INTER_ERR_SUCCESS; if (!instance->is_probe_finish || instance->is_probe_failed || - !instance->state_machine.is_load) { + !instance->state_machine.is_load) { ps3_recovery_ready_to_force_cmd_stop(instance); - LOG_ERROR("hno:%u reset while probe or in shutdown/remove," - " finish[%d], failed[%d], is_load[%d]\n", - PS3_HOST(instance), instance->is_probe_finish, - instance->is_probe_failed, - instance->state_machine.is_load); + LOG_ERROR("hno:%u reset while probe or in shutdown/remove,\n" + "\tfinish[%d], failed[%d], is_load[%d]\n", + PS3_HOST(instance), instance->is_probe_finish, + instance->is_probe_failed, + instance->state_machine.is_load); ps3_instance_state_transfer(instance, PS3_INSTANCE_STATE_READY, - PS3_INSTANCE_STATE_RECOVERY); - instance ->is_half_hard_reset = PS3_TRUE; - if (!instance->state_machine.is_load) { + PS3_INSTANCE_STATE_RECOVERY); + instance->is_half_hard_reset = PS3_TRUE; + if (!instance->state_machine.is_load) ps3_ioc_notify_unload(instance); - } goto l_out; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_9, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_9, instance); err_code = ps3_hard_recovery_to_pre_operational(instance); l_out: return err_code; } -S32 ps3_hardreset_handle_post(struct ps3_instance *instance) +int ps3_hardreset_handle_post(struct ps3_instance *instance) { - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_12, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_12, instance); return ps3_hard_recovery_to_operational(instance); } -S32 ps3_hardreset_handle_finish(struct ps3_instance *instance) +int ps3_hardreset_handle_finish(struct ps3_instance *instance) { - U32 cur_state = 0; - S32 ret = PS3_SUCCESS; + unsigned int cur_state = 0; + int ret = PS3_SUCCESS; cur_state = ps3_atomic_read(&instance->state_machine.state); - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, &cur_state) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_FINISH_STATE_NOOPERATIONAL, + &cur_state); if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL) { ps3_instance_state_transfer_to_dead(instance); LOG_ERROR("hno:%u hard reset NOK! cur_state:%s\n", - PS3_HOST(instance), - namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); return -PS3_FAILED; } - INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_15, instance) + INJECT_START(PS3_ERR_IJ_FORCE_RECOVERY_PRE_PCIE_ERR_15, instance); ret = ps3_recovery_complete(instance); - if(ret != PS3_SUCCESS){ - LOG_WARN("hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", - PS3_HOST(instance), namePS3InstanceState(cur_state),ret); + if (ret != PS3_SUCCESS) { + LOG_WARN( + "hno:%u hard reset opeational but complete failed! cur_state:%s,ret %d\n", + PS3_HOST(instance), namePS3InstanceState(cur_state), + ret); return ret; } ps3_hard_recovery_state_finish(instance); LOG_INFO("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); return PS3_SUCCESS; } -S32 ps3_hardreset_handle_offline(struct ps3_instance *instance) +int ps3_hardreset_handle_offline(struct ps3_instance *instance) { - U32 cur_state = 0; + unsigned int cur_state = 0; + ps3_instance_state_transfer_to_dead(instance); cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u hard reset finish! cur_state:%s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); return PS3_SUCCESS; } -S32 ps3_softreset_handle_pre(struct ps3_instance *instance) +int ps3_softreset_handle_pre(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; ps3_cmd_reset_flag_set(instance, PS3_CMD_FLAG_SOFTRESET); ret = ps3_ioc_state_transfer_wait_to_running(instance); if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u soft recovery to running failed!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - ret = ps3_soft_recovery_cmd_reply_polling_check(instance, PS3_SOFT_RESET_WAIT_TIMEOUT); + ret = ps3_soft_recovery_cmd_reply_polling_check( + instance, PS3_SOFT_RESET_WAIT_TIMEOUT); if (ret != PS3_RECOVERY_INTER_ERR_SUCCESS) { LOG_ERROR("hno:%u pending mgr cmd no reply all!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } ret = PS3_RECOVERY_INTER_ERR_SUCCESS; LOG_INFO("hno:%u soft recovery to pre-operational success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); l_out: return ret; } -S32 ps3_softreset_handle_post(struct ps3_instance *instance) +int ps3_softreset_handle_post(struct ps3_instance *instance) { - S32 ret = PS3_RECOVERY_INTER_ERR_SUCCESS; + int ret = PS3_RECOVERY_INTER_ERR_SUCCESS; - if (!ps3_ioc_recovery_count_get(instance, - &instance->recovery_context->ioc_recovery_count)) { + if (!ps3_ioc_recovery_count_get( + instance, + &instance->recovery_context->ioc_recovery_count)) { ret = PS3_RECOVERY_INTER_ERR_FAILED; goto l_out; } - LOG_INFO("hno:%u pre-operational to operational success!,reset count:%d\n", - PS3_HOST(instance), instance->recovery_context->ioc_recovery_count); + LOG_INFO( + "hno:%u pre-operational to operational success!,reset count:%d\n", + PS3_HOST(instance), + instance->recovery_context->ioc_recovery_count); l_out: return ret; } -S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance) +int ps3_hard_recovery_request_with_retry(struct ps3_instance *instance, + unsigned char is_host_reset) { - S32 ret = PS3_SUCCESS; - U32 count = 0; + int ret = PS3_SUCCESS; + unsigned int count = 0; - while ((ret = ps3_hard_recovery_request(instance)) == -PS3_RETRY) { + while ((ret = ps3_hard_recovery_request(instance, is_host_reset)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { ret = -PS3_FAILED; break; } + + while (1) { + if (ps3_host_reset_state_check(instance, is_host_reset)) + break; + ps3_msleep(1000); + } + ps3_mdelay(10); } return ret; } -S32 ps3_recovery_request_with_retry(struct ps3_instance *instance) + +int ps3_recovery_request_with_retry(struct ps3_instance *instance, + unsigned char is_host_reset) { - S32 ret = PS3_SUCCESS; - U32 count = 0; + int ret = PS3_SUCCESS; + unsigned int count = 0; - while ((ret = ps3_recovery_request(instance)) == -PS3_RETRY) { + while ((ret = ps3_recovery_request(instance, is_host_reset)) == -PS3_RETRY) { if (count++ == ps3_use_hard_reset_max_retry()) { ret = -PS3_FAILED; break; } + + while (1) { + if (ps3_host_reset_state_check(instance, is_host_reset)) + break; + ps3_msleep(1000); + } + ps3_mdelay(10); } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_recovery.h b/drivers/scsi/linkdata/ps3stor/ps3_recovery.h index d7e569f5e2a2..283300e6f40c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_recovery.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_recovery.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_RECOVERY_H_ #define _PS3_RECOVERY_H_ @@ -27,9 +27,9 @@ enum { }; enum { - PS3_HOST_RESET_INIT = 0, - PS3_HOST_RESET_START = 1, - PS3_HOST_RESET_HARD_RESET_DONE = 2, + PS3_HOST_RESET_INIT = 0, + PS3_HOST_RESET_START = 1, + PS3_HOST_RESET_HARD_RESET_DONE = 2, }; enum { PS3_PARALLEL_HARDRESET_STATE_INIT = 0, @@ -38,76 +38,83 @@ enum { }; #define PS3_PARALLEL_HARDRESET_STATE_WAIT_INIT_INTERVAL (5) #define PS3_RECOVERY_CONTEXT_MAX_NUM (8) -#define PS3_RECOVERY_IRQ_NAME_MAX_LENTH (48) +#define PS3_RECOVERY_IRQ_NAME_MAX_LENGTH (32) #define PS3_RECOVERY_WHILE_PRINT_REACH_TIME (10 * 1000) enum { - PS3_HEARTBEAT_NULL = 0, - PS3_HEARTBEAT_HARDRESET_DECIDE = 1, + PS3_HEARTBEAT_NULL = 0, + PS3_HEARTBEAT_HARDRESET_DECIDE = 1, PS3_HEARTBEAT_HARDRESET_RECOVERY = 2, PS3_HEARTBEAT_HARDRESET_RETRY = 3, }; enum { - PS3_IOC_CANNOT_HARDRESET = 0, - PS3_IOC_CAN_HARDRESET = 1, + PS3_IOC_CANNOT_HARDRESET = 0, + PS3_IOC_CAN_HARDRESET = 1, }; -struct ps3_recovery_context -{ - ps3_mutex free_cmd_lock; - ps3_spinlock recovery_lock; - ps3_spinlock ps3_hardreset_lock; - U32 ioc_recovery_count; - U8 recovery_state; - U8 reserved1; - U8 host_reset_state; - U8 heartbeat_recovery; +struct ps3_recovery_context { + struct mutex free_cmd_lock; + spinlock_t recovery_lock; + spinlock_t ps3_hardreset_lock; + unsigned int ioc_recovery_count; + unsigned char recovery_state; + unsigned char reserved1; + unsigned char host_reset_state; + unsigned char heartbeat_recovery; #ifndef _WINDOWS struct workqueue_struct *recovery_wq; - S8 recovery_wq_name[20]; + char recovery_wq_name[20]; struct work_struct recovery_work; #else struct ps3_worker recovery_work; #endif struct ps3_instance *instance[2]; - struct ps3_instance *work_instance; - S32 recovery_result; - U32 hardreset_count; - U8 parall_hardreset_state; - U8 instance_change; - U8 reserved[6]; - ps3_atomic32 hardreset_ref; - ps3_mutex ps3_watchdog_recovery_mutex; + struct ps3_instance *work_instance; + int recovery_result; + unsigned int hardreset_count; + unsigned char parall_hardreset_state; + unsigned char instance_change; + unsigned char reserved[6]; + atomic_t hardreset_ref; + struct mutex ps3_watchdog_recovery_mutex; }; -#define PS3_IS_INTERRUPT_SOFT_RECOVERY(instance) \ +#define PS3_IS_INTERRUPT_SOFT_RECOVERY(instance) \ (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) -#define PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) (PS3_IS_INSTANCE_PROBE(instance) || \ - PS3_IS_INSTANCE_REMOVE(instance) || PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) +#define PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) \ + (PS3_IS_INSTANCE_PROBE(instance) || \ + PS3_IS_INSTANCE_REMOVE(instance) || \ + PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance)) + +#define PS3_IS_INSTANCE_PROBE(instance) \ + (!(instance)->state_machine.is_suspend && \ + !((instance)->is_probe_finish || (instance)->is_probe_failed)) -#define PS3_IS_INSTANCE_PROBE(instance) (!(instance)->state_machine.is_suspend && !((instance)->is_probe_finish || \ - (instance)->is_probe_failed)) +#define PS3_IS_INSTANCE_REMOVE(instance) \ + (!(instance)->state_machine.is_suspend && \ + ((instance)->is_probe_finish || (instance)->is_probe_failed) && \ + !(instance)->state_machine.is_load) -#define PS3_IS_INSTANCE_REMOVE(instance) (!(instance)->state_machine.is_suspend && ((instance)->is_probe_finish || \ - (instance)->is_probe_failed) && !(instance)->state_machine.is_load) +#define PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance) \ + (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ + ((instance)->peer_instance != NULL && \ + PS3_IS_INSTANCE_NOT_LOAD_NORMAL((instance)->peer_instance))) -#define PS3_INSTANCE_ABNORMAL_FORCE_HARD_RECOVERY(instance) (PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ - ((instance)->peer_instance != NULL && PS3_IS_INSTANCE_NOT_LOAD_NORMAL((instance)->peer_instance))) +#define PS3_IS_INSTANCE_PROBE_INIT(instance) \ + (!((instance)->is_probe_finish || (instance)->is_probe_failed) && \ + !(instance)->state_machine.is_load) -#define PS3_IS_INSTANCE_PROBE_INIT(instance) (!((instance)->is_probe_finish || (instance)->is_probe_failed) && \ - !(instance)->state_machine.is_load) +#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) \ + (PS3_IS_INSTANCE_SUSPEND(instance) || PS3_IS_INSTANCE_RESUME(instance)) -#define PS3_IS_INSTANCE_SUSPEND_OR_RESUME(instance) (PS3_IS_INSTANCE_SUSPEND(instance) || \ - PS3_IS_INSTANCE_RESUME(instance)) +#define PS3_IS_INSTANCE_SUSPEND(instance) \ + ((instance)->state_machine.is_suspend && (instance)->is_suspend) -#define PS3_IS_INSTANCE_SUSPEND(instance) ((instance)->state_machine.is_suspend && \ - (instance)->is_suspend) - -#define PS3_IS_INSTANCE_RESUME(instance) ((instance)->state_machine.is_suspend && \ - (instance)->is_resume) +#define PS3_IS_INSTANCE_RESUME(instance) \ + ((instance)->state_machine.is_suspend && (instance)->is_resume) -S32 ps3_recovery_context_init(struct ps3_instance *instance); +int ps3_recovery_context_init(struct ps3_instance *instance); void ps3_recovery_function_init(struct ps3_instance *instance); @@ -115,44 +122,48 @@ void ps3_recovery_context_exit(struct ps3_instance *instance); void ps3_recovery_clean(struct ps3_instance *instance); -void ps3_recovery_destory(struct ps3_instance *instance); +void ps3_recovery_destroy(struct ps3_instance *instance); -S32 ps3_recovery_request(struct ps3_instance *instance); +int ps3_recovery_request(struct ps3_instance *instance, + unsigned char is_host_reset); -S32 ps3_hard_recovery_request(struct ps3_instance *instance); +int ps3_hard_recovery_request(struct ps3_instance *instance, + unsigned char is_host_reset); void ps3_scsi_cmd_force_stop(struct ps3_instance *instance); void ps3_mgr_cmd_force_stop(struct ps3_instance *instance); -S32 ps3_recovery_cancel_work_sync(struct ps3_instance *instance); +int ps3_recovery_cancel_work_sync(struct ps3_instance *instance); #ifndef _WINDOWS -S32 ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance); -S32 ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance); -Bool ps3_is_need_hard_reset(struct ps3_instance *instance); +int ps3_hard_reset_to_ready_with_doorbell(struct ps3_instance *instance); +int ps3_init_fail_hard_reset_with_doorbell(struct ps3_instance *instance); +unsigned char ps3_is_need_hard_reset(struct ps3_instance *instance); -void ps3_recovery_work_queue_destory(struct ps3_instance *instance); +void ps3_recovery_work_queue_destroy(struct ps3_instance *instance); #endif -S32 ps3_hardreset_handle_pre(struct ps3_instance *instance); +int ps3_hardreset_handle_pre(struct ps3_instance *instance); -S32 ps3_hardreset_handle_wait_ready(struct ps3_instance *instance); +int ps3_hardreset_handle_wait_ready(struct ps3_instance *instance); -S32 ps3_hardreset_handle_init_running(struct ps3_instance *instance); +int ps3_hardreset_handle_init_running(struct ps3_instance *instance); -S32 ps3_hardreset_handle_post(struct ps3_instance *instance); +int ps3_hardreset_handle_post(struct ps3_instance *instance); -S32 ps3_hardreset_handle_finish(struct ps3_instance *instance); +int ps3_hardreset_handle_finish(struct ps3_instance *instance); -S32 ps3_hardreset_handle_offline(struct ps3_instance *instance); +int ps3_hardreset_handle_offline(struct ps3_instance *instance); -S32 ps3_softreset_handle_pre(struct ps3_instance *instance); +int ps3_softreset_handle_pre(struct ps3_instance *instance); -S32 ps3_softreset_handle_post(struct ps3_instance *instance); -S32 ps3_hard_recovery_request_with_retry(struct ps3_instance *instance); -S32 ps3_recovery_request_with_retry(struct ps3_instance *instance); -irqreturn_t ps3_recovery_irq_handler(S32 virq, void *dev_id); -S32 ps3_recovery_irq_start(struct ps3_instance *instance); +int ps3_softreset_handle_post(struct ps3_instance *instance); +int ps3_hard_recovery_request_with_retry(struct ps3_instance *instance, + unsigned char is_host_reset); +int ps3_recovery_request_with_retry(struct ps3_instance *instance, + unsigned char is_host_reset); +irqreturn_t ps3_recovery_irq_handler(int virq, void *dev_id); +int ps3_recovery_irq_start(struct ps3_instance *instance); void ps3_cmd_force_stop(struct ps3_instance *instance); -#endif +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c index f4edd1f353bf..664fad0a8c99 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include @@ -9,9 +10,10 @@ #include "ps3_driver_log.h" #include "ps3_device_manager_sas.h" -static struct scsi_transport_template *ps3_sas_transport_template = NULL; -extern struct ps3_sas_node* ps3_sas_find_node_by_sas_addr( - struct ps3_instance *instance, U64 sas_addr); +static struct scsi_transport_template *ps3_sas_transport_template; +extern struct ps3_sas_node * +ps3_sas_find_node_by_sas_addr(struct ps3_instance *instance, + unsigned long long sas_addr); struct scsi_transport_template *ps3_sas_transport_get(void) { return ps3_sas_transport_template; @@ -20,21 +22,24 @@ struct scsi_transport_template *ps3_sas_transport_get(void) static inline struct ps3_instance *phy_to_ps3_instance(struct sas_phy *phy) { struct Scsi_Host *s_host = dev_to_shost(phy->dev.parent); + return (struct ps3_instance *)s_host->hostdata; } static inline struct ps3_instance *rphy_to_ps3_instance(struct sas_rphy *rphy) { struct Scsi_Host *s_host = dev_to_shost(rphy->dev.parent); + return (struct ps3_instance *)s_host->hostdata; } -static inline S32 ps3_sas_request_pre_check(struct ps3_instance *instance) +static inline int ps3_sas_request_pre_check(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (!instance->state_machine.is_load) { - LOG_WARN("hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_WARN("hno:%u instance state not is_load\n", + PS3_HOST(instance)); ret = -EFAULT; goto l_out; } @@ -45,8 +50,7 @@ static inline S32 ps3_sas_request_pre_check(struct ps3_instance *instance) } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN("hno[%u] host in pci recovery\n", - PS3_HOST(instance)); + LOG_WARN("hno[%u] host in pci recovery\n", PS3_HOST(instance)); ret = -EFAULT; goto l_out; } @@ -55,19 +59,18 @@ static inline S32 ps3_sas_request_pre_check(struct ps3_instance *instance) return ret; } -static inline S32 ps3_sas_smp_pre_check(struct ps3_instance *instance) +static inline int ps3_sas_smp_pre_check(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ret = ps3_sas_request_pre_check(instance); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } LOG_INFO("hno:%u ready get semaphore\n", PS3_HOST(instance)); - if (down_interruptible(&instance->sas_dev_context.ps3_sas_smp_semaphore)) { - LOG_WARN("hno:%u smp concurrency full\n", - PS3_HOST(instance)); + if (down_interruptible( + &instance->sas_dev_context.ps3_sas_smp_semaphore)) { + LOG_WARN("hno:%u smp concurrency full\n", PS3_HOST(instance)); ret = -EFAULT; } LOG_INFO("hno:%u got semaphore\n", PS3_HOST(instance)); @@ -77,9 +80,11 @@ static inline S32 ps3_sas_smp_pre_check(struct ps3_instance *instance) } static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, - struct sas_phy *phy, U8 encl_id) + struct sas_phy *phy, + unsigned char encl_id) { - PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; + struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; + mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -88,8 +93,8 @@ static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, mgrReq->reqHead.control = 0; mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = - offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> + PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(sizeof(struct PS3LinkErrInfo)); mgrReq->sgl[0].addr = cpu_to_le64(cmd->ext_buf_phys); @@ -102,11 +107,11 @@ static inline void ps3_sas_linkerror_reqframe_build(struct ps3_cmd *cmd, mgrReq->value.sasMgr.startPhyID = phy->identify.phy_identifier; } -S32 ps3_sas_linkerrors_get(struct sas_phy *phy) +int ps3_sas_linkerrors_get(struct sas_phy *phy) { - S32 ret = 0; - S32 send_result = PS3_SUCCESS; - U8 encl_id = PS3_SAS_INVALID_ID; + int ret = 0; + int send_result = PS3_SUCCESS; + unsigned char encl_id = PS3_SAS_INVALID_ID; struct ps3_cmd *cmd = NULL; struct PS3LinkErrInfo *erroInfo = NULL; struct ps3_instance *instance = phy_to_ps3_instance(phy); @@ -118,27 +123,27 @@ S32 ps3_sas_linkerrors_get(struct sas_phy *phy) } encl_id = ps3_sas_encl_id_get(instance, phy->identify.sas_address); - INJECT_START(PS3_ERR_IJ_SAS_ENCL_ID_GET_FAILED, &encl_id) + INJECT_START(PS3_ERR_IJ_SAS_ENCL_ID_GET_FAILED, &encl_id); if (encl_id == PS3_SAS_INVALID_ID) { LOG_ERROR("hno:%u cannot foud PS3 node by sas_addr[%016llx]\n", - PS3_HOST(instance), phy->identify.sas_address); + PS3_HOST(instance), phy->identify.sas_address); ret = -EINVAL; goto l_no_free_cmd; } ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { - LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp linkerror pre check NOK\n", + LOG_WARN_LIM( + "sas_addr[%016llx], hno:%u smp linkerror pre check NOK\n", phy->identify.sas_address, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENXIO; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -147,36 +152,36 @@ S32 ps3_sas_linkerrors_get(struct sas_phy *phy) cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] get mgr cmd succeed\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, phy->identify.sas_address); + LOG_DEBUG( + "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] get mgr cmd succeed\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, + phy->identify.sas_address); ps3_sas_linkerror_reqframe_build(cmd, phy, encl_id); ps3_mgr_cmd_word_build(cmd); - INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -EFAULT; } else { erroInfo = (struct PS3LinkErrInfo *)cmd->ext_buf; - phy->invalid_dword_count = le32_to_cpu(erroInfo->invalidDwordCount); + phy->invalid_dword_count = + le32_to_cpu(erroInfo->invalidDwordCount); phy->running_disparity_error_count = le32_to_cpu(erroInfo->runningDisparityErrCount); phy->loss_of_dword_sync_count = @@ -187,7 +192,7 @@ S32 ps3_sas_linkerrors_get(struct sas_phy *phy) } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: @@ -196,13 +201,14 @@ S32 ps3_sas_linkerrors_get(struct sas_phy *phy) return ret; } -S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) +int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) { - S32 ret = 0; + int ret = 0; struct ps3_instance *instance = rphy_to_ps3_instance(rphy); *identifier = 0; - LOG_DEBUG("hno:%u ----1---ready get encl identifier sas_addr[%016llx]\n", + LOG_DEBUG( + "hno:%u ----1---ready get encl identifier sas_addr[%016llx]\n", PS3_HOST(instance), rphy->identify.sas_address); ret = ps3_sas_smp_pre_check(instance); @@ -212,10 +218,11 @@ S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) } LOG_DEBUG("hno:%u ready get encl identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); - *identifier = ps3_sas_rphy_parent_sas_addr_get(instance, rphy->identify.sas_address); - INJECT_START(PS3_ERR_IJ_RPHY_PARENT_SAS_ADDR_GET_FAILED,identifier) + *identifier = ps3_sas_rphy_parent_sas_addr_get( + instance, rphy->identify.sas_address); + INJECT_START(PS3_ERR_IJ_RPHY_PARENT_SAS_ADDR_GET_FAILED, identifier); if (*identifier == PS3_SAS_INVALID_SAS_ADDR) { ret = -ENXIO; *identifier = 0; @@ -223,18 +230,19 @@ S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier) up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - LOG_DEBUG("hno:%u end get encl identifier sas_addr[%016llx], identifier[%llu]\n", + LOG_DEBUG( + "hno:%u end get encl identifier sas_addr[%016llx], identifier[%llu]\n", PS3_HOST(instance), rphy->identify.sas_address, *identifier); return ret; } -S32 ps3_sas_bay_identifier_get(struct sas_rphy *rphy) +int ps3_sas_bay_identifier_get(struct sas_rphy *rphy) { - U32 solt_id = 0; + unsigned int solt_id = 0; struct ps3_instance *instance = rphy_to_ps3_instance(rphy); LOG_DEBUG("hno:%u ----1---ready get bay identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); if (ps3_sas_smp_pre_check(instance) != PS3_SUCCESS) { solt_id = -ENXIO; @@ -242,25 +250,27 @@ S32 ps3_sas_bay_identifier_get(struct sas_rphy *rphy) } LOG_DEBUG("hno:%u ready get bay identifier sas_addr[%016llx]\n", - PS3_HOST(instance), rphy->identify.sas_address); + PS3_HOST(instance), rphy->identify.sas_address); - if (ps3_sas_rphy_slot_get(instance, rphy->identify.sas_address, &solt_id) - != PS3_SUCCESS) { + if (ps3_sas_rphy_slot_get(instance, rphy->identify.sas_address, + &solt_id) != PS3_SUCCESS) { solt_id = -ENXIO; } up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - LOG_DEBUG("hno:%u end get bay identifier sas_addr[%016llx], slot_id[%d]\n", + LOG_DEBUG( + "hno:%u end get bay identifier sas_addr[%016llx], slot_id[%d]\n", PS3_HOST(instance), rphy->identify.sas_address, solt_id); return solt_id; } static inline void ps3_sas_ctrl_reqframe_build(struct ps3_cmd *cmd, - struct sas_phy *phy, - enum PhyCtrl ctrl_code) + struct sas_phy *phy, + enum PhyCtrl ctrl_code) { - PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; + struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; + mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -271,19 +281,18 @@ static inline void ps3_sas_ctrl_reqframe_build(struct ps3_cmd *cmd, mgrReq->timeout = 0; mgrReq->sgeCount = 0; - mgrReq->value.phySet.sasAddr = - cpu_to_le64(phy->identify.sas_address); + mgrReq->value.phySet.sasAddr = cpu_to_le64(phy->identify.sas_address); mgrReq->value.phySet.phyCtrl = ctrl_code; mgrReq->value.phySet.phyID = phy->identify.phy_identifier; mgrReq->value.phySet.maxLinkRate = phy->maximum_linkrate; mgrReq->value.phySet.minLinkRate = phy->minimum_linkrate; } -static inline S32 __ps3_sas_phy_ctrl(struct sas_phy *phy, - enum PhyCtrl ctrl_code) +static inline int __ps3_sas_phy_ctrl(struct sas_phy *phy, + enum PhyCtrl ctrl_code) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = phy_to_ps3_instance(phy); @@ -295,17 +304,17 @@ static inline S32 __ps3_sas_phy_ctrl(struct sas_phy *phy, ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { - LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp phyctrl pre check NOK\n", + LOG_WARN_LIM( + "sas_addr[%016llx], hno:%u smp phyctrl pre check NOK\n", phy->identify.sas_address, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENXIO; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -313,38 +322,37 @@ static inline S32 __ps3_sas_phy_ctrl(struct sas_phy *phy, cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] ctrl_code[%s] get mgr cmd succeed\n", + LOG_DEBUG( + "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx] ctrl_code[%s] get mgr cmd succeed\n", PS3_HOST(instance), cmd->trace_id, cmd->index, - phy->identify.sas_address, namePhyCtrl((enum PhyCtrl)ctrl_code)); + phy->identify.sas_address, + namePhyCtrl((enum PhyCtrl)ctrl_code)); ps3_sas_ctrl_reqframe_build(cmd, phy, ctrl_code); ps3_mgr_cmd_word_build(cmd); - INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd) + INJECT_START(PS3_ERR_IJ_CMD_POLLING, &cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -EFAULT; } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: up(&instance->sas_dev_context.ps3_sas_smp_semaphore); @@ -352,98 +360,130 @@ static inline S32 __ps3_sas_phy_ctrl(struct sas_phy *phy, return ret; } -S32 ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset) +int ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset) { + int ret = PS3_SUCCESS; enum PhyCtrl ctrl_code = hard_reset ? PS3_SAS_CTRL_RESET_HARD : PS3_SAS_CTRL_RESET; - struct sas_phy tmp_phy = *phy; - tmp_phy.maximum_linkrate = 0; - tmp_phy.minimum_linkrate = 0; + struct sas_phy *tmp_phy = kcalloc(1, sizeof(struct sas_phy), GFP_KERNEL); + + if (tmp_phy == NULL) { + LOG_ERROR("kcalloc sas_phy fail!\n"); + ret = -ENOMEM; + goto l_out; + } + memcpy(tmp_phy, phy, sizeof(struct sas_phy)); + tmp_phy->maximum_linkrate = 0; + tmp_phy->minimum_linkrate = 0; LOG_INFO("enter phy reset, phy sas_addr[%016llx], is_hard[%d]\n", - phy->identify.sas_address, hard_reset); - return __ps3_sas_phy_ctrl(&tmp_phy, ctrl_code); + phy->identify.sas_address, hard_reset); + ret = __ps3_sas_phy_ctrl(tmp_phy, ctrl_code); + kfree(tmp_phy); + tmp_phy = NULL; + +l_out: + return ret; } -S32 ps3_sas_phy_enable(struct sas_phy *phy, int enable) +int ps3_sas_phy_enable(struct sas_phy *phy, int enable) { + int ret = PS3_SUCCESS; enum PhyCtrl ctrl_code = enable ? PS3_SAS_CTRL_RESET : PS3_SAS_CTRL_DISABLE; - struct sas_phy tmp_phy = *phy; - tmp_phy.maximum_linkrate = 0; - tmp_phy.minimum_linkrate = 0; + struct sas_phy *tmp_phy = kcalloc(1, sizeof(struct sas_phy), GFP_KERNEL); + + if (tmp_phy == NULL) { + LOG_ERROR("kcalloc sas_phy fail!\n"); + ret = -ENOMEM; + goto l_out; + } + memcpy(tmp_phy, phy, sizeof(struct sas_phy)); + tmp_phy->maximum_linkrate = 0; + tmp_phy->minimum_linkrate = 0; LOG_INFO("enter phy enable, phy sas_addr[%016llx], is_enable[%d]\n", - phy->identify.sas_address, enable); - return __ps3_sas_phy_ctrl(&tmp_phy, ctrl_code); + phy->identify.sas_address, enable); + ret = __ps3_sas_phy_ctrl(tmp_phy, ctrl_code); + kfree(tmp_phy); + tmp_phy = NULL; + +l_out: + return ret; } -S32 ps3_sas_update_phy_info(struct sas_phy *phy) +static int ps3_sas_update_phy_info(struct sas_phy *phy) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct PS3SasMgr sas_req_param; struct ps3_instance *instance = phy_to_ps3_instance(phy); - struct PS3PhyInfo *phy_info = instance->sas_dev_context.ps3_sas_phy_buff; - ULong flags = 0; + struct PS3PhyInfo *phy_info = + instance->sas_dev_context.ps3_sas_phy_buff; + unsigned long flags = 0; - struct ps3_sas_node* sas_node = ps3_sas_find_node_by_sas_addr( + struct ps3_sas_node *sas_node = ps3_sas_find_node_by_sas_addr( instance, phy->identify.sas_address); memset(&sas_req_param, 0, sizeof(sas_req_param)); sas_req_param.enclID = sas_node->encl_id; - sas_req_param.sasAddr =cpu_to_le64(sas_node->sas_address); + sas_req_param.sasAddr = cpu_to_le64(sas_node->sas_address); sas_req_param.startPhyID = phy->identify.phy_identifier; sas_req_param.phyCount = 1; LOG_DEBUG("hno:%u ready get phys[%d] of encl_id[%d] !\n", - PS3_HOST(instance), phy->identify.phy_identifier, sas_req_param.enclID); + PS3_HOST(instance), phy->identify.phy_identifier, + sas_req_param.enclID); memset(phy_info, 0, PS3_SAS_REQ_BUFF_LEN); ret = ps3_sas_phy_get(instance, &sas_req_param); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u get phy info NOK\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u get phy info NOK\n", PS3_HOST(instance)); goto l_out; } spin_lock_irqsave(&instance->sas_dev_context.ps3_sas_node_lock, flags); - LOG_INFO_IN_IRQ(instance, "hno:%u ready update phy %d of encl_id[%d]!\n", - PS3_HOST(instance), phy->identify.phy_identifier, sas_req_param.enclID); - - ps3_sas_node_phy_update(instance, &sas_node->phys[phy->identify.phy_identifier], &phy_info[0]); - spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, flags); + LOG_INFO_IN_IRQ(instance, + "hno:%u ready update phy %d of encl_id[%d]!\n", + PS3_HOST(instance), phy->identify.phy_identifier, + sas_req_param.enclID); + + ps3_sas_node_phy_update(instance, + &sas_node->phys[phy->identify.phy_identifier], + &phy_info[0]); + spin_unlock_irqrestore(&instance->sas_dev_context.ps3_sas_node_lock, + flags); l_out: return ret; } -S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) +int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) { - S32 ret = PS3_SUCCESS; - U8 tmp_min = 0; - U8 tmp_max = 0; - LOG_INFO("enter link rate set, phy sas_addr[%016llx]," - "minimum_linkrate[%d], maximum_linkrate[%d]\n", - phy->identify.sas_address, rates->minimum_linkrate, - rates->maximum_linkrate); - - if (!rates->minimum_linkrate) { + int ret = PS3_SUCCESS; + unsigned char tmp_min = 0; + unsigned char tmp_max = 0; + + LOG_INFO("enter link rate set, phy sas_addr[%016llx],\n" + "\tminimum_linkrate[%d], maximum_linkrate[%d]\n", + phy->identify.sas_address, rates->minimum_linkrate, + rates->maximum_linkrate); + + if (!rates->minimum_linkrate) rates->minimum_linkrate = phy->minimum_linkrate; - } else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) { + else if (rates->minimum_linkrate < phy->minimum_linkrate_hw) rates->minimum_linkrate = phy->minimum_linkrate_hw; - } - if (!rates->maximum_linkrate) { + if (!rates->maximum_linkrate) rates->maximum_linkrate = phy->maximum_linkrate; - } else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) { + else if (rates->maximum_linkrate > phy->maximum_linkrate_hw) rates->maximum_linkrate = phy->maximum_linkrate_hw; - } if (rates->maximum_linkrate < phy->minimum_linkrate || - rates->minimum_linkrate> phy->maximum_linkrate) { - LOG_ERROR("linkrate set param NOK, %d phy sas_addr[%016llx]," - "rate minimum_linkrate[%d] > cur maximum_linkrate[%d] or" - "rate maximum_linkrate[%d] < cur minimum_linkrate[%d]\n", + rates->minimum_linkrate > phy->maximum_linkrate) { + LOG_ERROR( + "linkrate set param NOK, %d phy sas_addr[%016llx],\n" + "\trate minimum_linkrate[%d] > cur maximum_linkrate[%d] or\n" + "\trate maximum_linkrate[%d] < cur minimum_linkrate[%d]\n", phy->identify.phy_identifier, phy->identify.sas_address, rates->minimum_linkrate, phy->maximum_linkrate, rates->maximum_linkrate, phy->minimum_linkrate); @@ -459,10 +499,10 @@ S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) ret = __ps3_sas_phy_ctrl(phy, PS3_SAS_CTRL_RESET); if (ret != PS3_SUCCESS) { - LOG_ERROR("linkrate NOK, phy sas_addr[%016llx]," - "minimum_linkrate[%d], maximum_linkrate[%d]\n", - phy->identify.sas_address, rates->minimum_linkrate, - rates->maximum_linkrate); + LOG_ERROR("linkrate NOK, phy sas_addr[%016llx],\n" + "\tminimum_linkrate[%d], maximum_linkrate[%d]\n", + phy->identify.sas_address, rates->minimum_linkrate, + rates->maximum_linkrate); phy->minimum_linkrate = tmp_min; phy->maximum_linkrate = tmp_max; @@ -475,9 +515,11 @@ S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates) } static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, - U64 sas_addr, U32 req_data_len) + unsigned long long sas_addr, + unsigned int req_data_len) { - PS3MgrReqFrame_s *mgrReq = &cmd->req_frame->mgrReq; + struct PS3MgrReqFrame *mgrReq = &cmd->req_frame->mgrReq; + mgrReq->reqHead.timeout = cmd->time_out; mgrReq->reqHead.traceID = cmd->trace_id; mgrReq->reqHead.cmdType = PS3_CMD_SAS_MANAGEMENT; @@ -487,8 +529,8 @@ static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, mgrReq->syncFlag = 1; mgrReq->timeout = 0; - mgrReq->sgeOffset = - offsetof(PS3MgrReqFrame_s, sgl) >> PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; + mgrReq->sgeOffset = offsetof(struct PS3MgrReqFrame, sgl) >> + PS3_MGR_CMD_SGL_OFFSET_DWORD_SHIFT; mgrReq->sgeCount = 1; mgrReq->sgl[0].length = cpu_to_le32(cmd->instance->cmd_context.ext_buf_size); @@ -497,17 +539,19 @@ static inline void ps3_sas_smp_reqframe_build(struct ps3_cmd *cmd, mgrReq->sgl[0].ext = 0; mgrReq->value.sasMgr.sasAddr = cpu_to_le64(sas_addr); - mgrReq->value.sasMgr.reqLen = cpu_to_le16(req_data_len - PS3_SMP_CRC_LEN); + mgrReq->value.sasMgr.reqLen = + cpu_to_le16(req_data_len - PS3_SMP_CRC_LEN); } -static inline void show_smp(U8 *data, U16 len) +static inline void show_smp(unsigned char *data, unsigned short len) { - U16 i = 0; - S8 tmp_buf[256] = {0}; - S8 *p_tmp = tmp_buf; + unsigned short i = 0; + char tmp_buf[256] = { 0 }; + char *p_tmp = tmp_buf; + LOG_DEBUG("smp frame data start\n"); while (len != 0) { - memset(tmp_buf, 0, sizeof(S8) * 256); + memset(tmp_buf, 0, sizeof(char) * 256); for (i = 0; i < 32 && len != 0; i++, len--) { snprintf(p_tmp, 4, " %02x", *data++); p_tmp += 3; @@ -519,121 +563,61 @@ static inline void show_smp(U8 *data, U16 len) LOG_DEBUG("smp frame data end\n"); } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,14,0) - -static inline U32 ps3_sas_req_to_ext_buf(struct ps3_instance *instance, - struct request *req, void *ext_buf) +#if defined(PS3_SAS_SMP_RETURN_VOID) +static inline unsigned int ps3_sas_req_to_ext_buf(struct ps3_instance *instance, + struct bsg_buffer *req_buf, + void *ext_buf) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) - struct bio_vec bvec; - struct bvec_iter iter; -#else - struct bio_vec *bvec = NULL; - U32 i = 0; -#endif - - U32 req_len = 0; + unsigned int req_len = 0; - INJECT_START(PS3_ERR_IJ_SAS_REQ_EXT_BUF_INVALLID, req) - if (unlikely(blk_rq_bytes(req) > instance->cmd_context.ext_buf_size)) { - LOG_ERROR("hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", - PS3_HOST(instance), blk_rq_bytes(req), + if (unlikely(req_buf->payload_len > + instance->cmd_context.ext_buf_size)) { + LOG_ERROR( + "hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", + PS3_HOST(instance), req_buf->payload_len, instance->cmd_context.ext_buf_size); goto l_out; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) - bio_for_each_segment(bvec, req->bio, iter) { - memcpy((U8*)ext_buf + req_len, - page_address(bvec.bv_page) + bvec.bv_offset, - bvec.bv_len); - req_len += bvec.bv_len; - } -#else - bio_for_each_segment(bvec, req->bio, i) { - memcpy((U8*)ext_buf + req_len, - page_address(bvec->bv_page) + bvec->bv_offset, - bvec->bv_len); - req_len += bvec->bv_len; - } -#endif - + req_len = sg_copy_to_buffer(req_buf->sg_list, req_buf->sg_cnt, ext_buf, + req_buf->payload_len); l_out: return req_len; } -static inline S32 ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, - struct request *req, void *ext_buf) +static inline unsigned int ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, + struct bsg_buffer *rsp_buf, + void *ext_buf) { - S32 ret = PS3_SUCCESS; - struct request *rsp = req->next_rq; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) - struct bio_vec bvec; - struct bvec_iter iter; -#else - struct bio_vec *bvec = NULL; - U32 i = 0; -#endif - U32 offset = 0; - U16 rsq_data_len = 0; - U16 smp_len = 0; + unsigned short rsq_data_len = 0; + unsigned short smp_len = 0; - INJECT_START(PS3_ERR_IJ_EXT_BUF_TO_RSP_INVALLID, &rsp) - if (rsp == NULL) { - ret = -PS3_FAILED; - LOG_ERROR("hno:%u rsp == NULL\n", PS3_HOST(instance)); - goto l_out; - } + rsq_data_len = + min(rsp_buf->payload_len, instance->cmd_context.ext_buf_size); - rsq_data_len = min(blk_rq_bytes(rsp), instance->cmd_context.ext_buf_size); - - smp_len = ((U8*)ext_buf)[3] * 4 + 4; - rsp->resid_len -= smp_len; + smp_len = ((unsigned char *)ext_buf)[3] * 4 + 4; LOG_DEBUG("hno:%u smp frame len[%d], rsq_data_len[%d]\n", - PS3_HOST(instance), smp_len, rsq_data_len); + PS3_HOST(instance), smp_len, rsq_data_len); rsq_data_len = min(smp_len, rsq_data_len); - show_smp((U8*)ext_buf, rsq_data_len); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) - bio_for_each_segment(bvec, rsp->bio, iter) { - if (rsq_data_len <= bvec.bv_len) { - memcpy(page_address(bvec.bv_page) + bvec.bv_offset, - (U8*)ext_buf + offset, rsq_data_len); - break; - } else { - memcpy(page_address(bvec.bv_page) + bvec.bv_offset, - (U8*)ext_buf + offset, bvec.bv_len); - rsq_data_len -= bvec.bv_len; - } - offset += bvec.bv_len; - } -#else - bio_for_each_segment(bvec, rsp->bio, i) { - if (rsq_data_len <= bvec->bv_len) { - memcpy(page_address(bvec->bv_page) + bvec->bv_offset, - (U8*)ext_buf + offset, rsq_data_len); - break; - } else { - memcpy(page_address(bvec->bv_page) + bvec->bv_offset, - (U8*)ext_buf + offset, bvec->bv_len); - rsq_data_len -= bvec->bv_len; - } - offset += bvec->bv_len; - } -#endif -l_out: - return ret; + show_smp((unsigned char *)ext_buf, rsq_data_len); + + sg_copy_from_buffer(rsp_buf->sg_list, rsp_buf->sg_cnt, ext_buf, + rsp_buf->payload_len); + return rsq_data_len; } -S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, - struct request *req) + +void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, + struct sas_rphy *rphy) { - S32 ret = -PS3_FAILED; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; struct ps3_cmd *cmd = NULL; - U32 req_data_len = 0; - U64 sas_addr = 0; + unsigned int req_data_len = 0; + unsigned int resp_len = 0; + unsigned long long sas_addr = 0; struct ps3_sas_node *ps3_sas_node = NULL; ret = ps3_sas_smp_pre_check(instance); @@ -642,31 +626,28 @@ S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, goto l_out; } - sas_addr = (rphy) ? (rphy->identify.sas_address) : (instance->sas_dev_context.ps3_hba_sas.sas_address); + sas_addr = (rphy) ? (rphy->identify.sas_address) : + (instance->sas_dev_context.ps3_hba_sas.sas_address); ps3_sas_node = ps3_sas_find_node_by_sas_addr(instance, sas_addr); - INJECT_START(PS3_ERR_IJ_SAS_NODE_NOT_FOUND, &ps3_sas_node) if (ps3_sas_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%llx] !\n", - PS3_HOST(instance), sas_addr); - up(&instance->sas_dev_context.ps3_sas_smp_semaphore); - ret = -EFAULT; - goto l_out; + LOG_ERROR("hno:%u cannot find node[%llx] !\n", + PS3_HOST(instance), sas_addr); + up(&instance->sas_dev_context.ps3_sas_smp_semaphore); + ret = -EFAULT; + goto l_out; } - ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); - INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", - sas_addr, PS3_HOST(instance)); + sas_addr, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -EFAULT; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); - INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd) if (cmd == NULL) { - LOG_WARN("hno:%u not get a cmd packet\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u Failed to get a cmd packet\n", + PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -674,114 +655,169 @@ S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - req_data_len = ps3_sas_req_to_ext_buf(instance, req, cmd->ext_buf); + req_data_len = ps3_sas_req_to_ext_buf(instance, &job->request_payload, + cmd->ext_buf); if (req_data_len == 0) { ret = -ENOMEM; ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_out_failed; } - LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, req_data_len); + LOG_DEBUG( + "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, + req_data_len); ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); ps3_mgr_cmd_word_build(cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ENXIO; - if (ret == -PS3_TIMEOUT) { - ret = -ETIMEDOUT; - } goto l_out_failed; } - ret = ps3_sas_ext_buf_to_rsp(instance, req, cmd->ext_buf); - if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u %d smp response NOK CFID[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID); - ret = -EINVAL; - goto l_out_failed; - } + resp_len = ps3_sas_ext_buf_to_rsp(instance, &job->reply_payload, + cmd->ext_buf); LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); l_out_failed: ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - return ret; + bsg_job_done(job, ret, resp_len); } #else - -static inline U32 ps3_sas_req_to_ext_buf(struct ps3_instance *instance, - struct bsg_buffer *req_buf, void *ext_buf) +static inline unsigned int ps3_sas_req_to_ext_buf(struct ps3_instance *instance, + struct request *req, + void *ext_buf) { - U32 req_len = 0; +#if defined(PS3_SYPPORT_BIO_ITER) + struct bio_vec bvec; + struct bvec_iter iter; +#else + struct bio_vec *bvec = NULL; + unsigned int i = 0; +#endif - if (unlikely(req_buf->payload_len > instance->cmd_context.ext_buf_size)) { - LOG_ERROR("hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", - PS3_HOST(instance), req_buf->payload_len, + unsigned int req_len = 0; + + INJECT_START(PS3_ERR_IJ_SAS_REQ_EXT_BUF_INVALLID, req); + if (unlikely(blk_rq_bytes(req) > instance->cmd_context.ext_buf_size)) { + LOG_ERROR( + "hno:%u request is too big!(req_len:%d > ext_buf_len:%d\n", + PS3_HOST(instance), blk_rq_bytes(req), instance->cmd_context.ext_buf_size); goto l_out; } - req_len = sg_copy_to_buffer(req_buf->sg_list, req_buf->sg_cnt, ext_buf, - req_buf->payload_len); +#if defined(PS3_SYPPORT_BIO_ITER) + bio_for_each_segment(bvec, req->bio, iter) { + memcpy((unsigned char *)ext_buf + req_len, + page_address(bvec.bv_page) + bvec.bv_offset, + bvec.bv_len); + req_len += bvec.bv_len; + } +#else + bio_for_each_segment(bvec, req->bio, i) { + memcpy((unsigned char *)ext_buf + req_len, + page_address(bvec->bv_page) + bvec->bv_offset, + bvec->bv_len); + req_len += bvec->bv_len; + } +#endif + l_out: return req_len; } -static inline U32 ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, - struct bsg_buffer *rsp_buf, void *ext_buf) +static inline int ps3_sas_ext_buf_to_rsp(struct ps3_instance *instance, + struct request *req, void *ext_buf) { - U16 rsq_data_len = 0; - U16 smp_len = 0; + int ret = PS3_SUCCESS; + struct request *rsp = req->next_rq; +#if defined(PS3_SYPPORT_BIO_ITER) + struct bio_vec bvec; + struct bvec_iter iter; +#else + struct bio_vec *bvec = NULL; + unsigned int i = 0; +#endif + unsigned int offset = 0; + unsigned short rsq_data_len = 0; + unsigned short smp_len = 0; - rsq_data_len = min(rsp_buf->payload_len, instance->cmd_context.ext_buf_size); + INJECT_START(PS3_ERR_IJ_EXT_BUF_TO_RSP_INVALLID, &rsp); + if (rsp == NULL) { + ret = -PS3_FAILED; + LOG_ERROR("hno:%u rsp == NULL\n", PS3_HOST(instance)); + goto l_out; + } + + rsq_data_len = + min(blk_rq_bytes(rsp), instance->cmd_context.ext_buf_size); - smp_len = ((U8*)ext_buf)[3] * 4 + 4; + smp_len = ((unsigned char *)ext_buf)[3] * 4 + 4; + rsp->resid_len -= smp_len; LOG_DEBUG("hno:%u smp frame len[%d], rsq_data_len[%d]\n", - PS3_HOST(instance), smp_len, rsq_data_len); + PS3_HOST(instance), smp_len, rsq_data_len); rsq_data_len = min(smp_len, rsq_data_len); - show_smp((U8*)ext_buf, rsq_data_len); - - sg_copy_from_buffer(rsp_buf->sg_list, rsp_buf->sg_cnt, ext_buf, - rsp_buf->payload_len); - return rsq_data_len; + show_smp((unsigned char *)ext_buf, rsq_data_len); +#if defined(PS3_SYPPORT_BIO_ITER) + bio_for_each_segment(bvec, rsp->bio, iter) { + if (rsq_data_len <= bvec.bv_len) { + memcpy(page_address(bvec.bv_page) + bvec.bv_offset, + (unsigned char *)ext_buf + offset, rsq_data_len); + break; + } + memcpy(page_address(bvec.bv_page) + bvec.bv_offset, + (unsigned char *)ext_buf + offset, bvec.bv_len); + rsq_data_len -= bvec.bv_len; + offset += bvec.bv_len; + } +#else + bio_for_each_segment(bvec, rsp->bio, i) { + if (rsq_data_len <= bvec->bv_len) { + memcpy(page_address(bvec->bv_page) + bvec->bv_offset, + (unsigned char *)ext_buf + offset, rsq_data_len); + break; + } + memcpy(page_address(bvec->bv_page) + bvec->bv_offset, + (unsigned char *)ext_buf + offset, bvec->bv_len); + rsq_data_len -= bvec->bv_len; + offset += bvec->bv_len; + } +#endif +l_out: + return ret; } - -void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, - struct sas_rphy *rphy) +int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, + struct request *req) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = -PS3_FAILED; + int send_result = PS3_SUCCESS; struct ps3_instance *instance = (struct ps3_instance *)shost->hostdata; struct ps3_cmd *cmd = NULL; - U32 req_data_len = 0; - U32 resp_len = 0; - U64 sas_addr = 0; + unsigned int req_data_len = 0; + unsigned long long sas_addr = 0; struct ps3_sas_node *ps3_sas_node = NULL; ret = ps3_sas_smp_pre_check(instance); @@ -790,27 +826,31 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, goto l_out; } - sas_addr = (rphy) ? (rphy->identify.sas_address) : (instance->sas_dev_context.ps3_hba_sas.sas_address); + sas_addr = (rphy) ? (rphy->identify.sas_address) : + (instance->sas_dev_context.ps3_hba_sas.sas_address); ps3_sas_node = ps3_sas_find_node_by_sas_addr(instance, sas_addr); + INJECT_START(PS3_ERR_IJ_SAS_NODE_NOT_FOUND, &ps3_sas_node); if (ps3_sas_node == NULL) { - LOG_ERROR("hno:%u cannot find node[%llx] !\n", - PS3_HOST(instance), sas_addr); - up(&instance->sas_dev_context.ps3_sas_smp_semaphore); - ret = -EFAULT; - goto l_out; + LOG_ERROR("hno:%u cannot find node[%llx] !\n", + PS3_HOST(instance), sas_addr); + up(&instance->sas_dev_context.ps3_sas_smp_semaphore); + ret = -EFAULT; + goto l_out; } + ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); + INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_sas_request_pre_check(instance) != PS3_SUCCESS) { LOG_WARN_LIM("sas_addr[%016llx], hno:%u smp pre check NOK\n", - sas_addr, PS3_HOST(instance)); + sas_addr, PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -EFAULT; goto l_no_free_cmd; } cmd = ps3_mgr_cmd_alloc(instance); + INJECT_START(PS3_ERR_IJ_MGR_CMD_ALLOC_FAILED, &cmd); if (cmd == NULL) { - LOG_WARN("hno:%u Failed to get a cmd packet\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u not get a cmd packet\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = -ENOMEM; goto l_no_free_cmd; @@ -818,82 +858,89 @@ void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, cmd->time_out = PS3_SAS_TIMEOUT_SEC; cmd->is_interrupt = PS3_DRV_FALSE; - req_data_len = ps3_sas_req_to_ext_buf(instance, &job->request_payload, cmd->ext_buf); + req_data_len = ps3_sas_req_to_ext_buf(instance, req, cmd->ext_buf); if (req_data_len == 0) { ret = -ENOMEM; ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); goto l_out_failed; } - LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, req_data_len); + LOG_DEBUG( + "hno:%u trace_id[0x%llx] CFID [%u], sas_addr[%016llx], len[%u] send smp req\n", + PS3_HOST(instance), cmd->trace_id, cmd->index, sas_addr, + req_data_len); ps3_sas_smp_reqframe_build(cmd, sas_addr, req_data_len); ps3_mgr_cmd_word_build(cmd); send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); if (ret == -PS3_CMD_NO_RESP) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ETIMEDOUT; goto l_no_free_cmd; } if (ret != PS3_SUCCESS) { LOG_ERROR("hno:%u %d respStatus NOK CFID[%d] respStatus[%d]\n", - PS3_HOST(cmd->instance), ret, - cmd->cmd_word.cmdFrameID, - ps3_cmd_resp_status(cmd)); + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID, ps3_cmd_resp_status(cmd)); ret = -ENXIO; + if (ret == -PS3_TIMEOUT) + ret = -ETIMEDOUT; goto l_out_failed; } - resp_len = ps3_sas_ext_buf_to_rsp(instance, &job->reply_payload, cmd->ext_buf); + ret = ps3_sas_ext_buf_to_rsp(instance, req, cmd->ext_buf); + if (ret != PS3_SUCCESS) { + LOG_ERROR("hno:%u %d smp response NOK CFID[%d]\n", + PS3_HOST(cmd->instance), ret, + cmd->cmd_word.cmdFrameID); + ret = -EINVAL; + goto l_out_failed; + } LOG_DEBUG("hno:%u trace_id[0x%llx] CFID [%u], end, ret[%d]\n", - PS3_HOST(instance), cmd->trace_id, cmd->index, ret); + PS3_HOST(instance), cmd->trace_id, cmd->index, ret); l_out_failed: ps3_mgr_cmd_free(instance, cmd); l_no_free_cmd: up(&instance->sas_dev_context.ps3_sas_smp_semaphore); l_out: - bsg_job_done(job, ret, resp_len); + return ret; } #endif -S32 ps3_sas_attach_transport(void) +int ps3_sas_attach_transport(void) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; + static struct sas_function_template ps3_sas_transport_functions = { - .get_linkerrors = ps3_sas_linkerrors_get, + .get_linkerrors = ps3_sas_linkerrors_get, .get_enclosure_identifier = ps3_sas_enclosure_identifier_get, - .get_bay_identifier = ps3_sas_bay_identifier_get, - .phy_reset = ps3_sas_phy_reset, - .phy_enable = ps3_sas_phy_enable, - .set_phy_speed = ps3_sas_linkrates_set, - .smp_handler = ps3_sas_smp_handler, + .get_bay_identifier = ps3_sas_bay_identifier_get, + .phy_reset = ps3_sas_phy_reset, + .phy_enable = ps3_sas_phy_enable, + .set_phy_speed = ps3_sas_linkrates_set, + .smp_handler = ps3_sas_smp_handler, }; ps3_sas_transport_template = sas_attach_transport(&ps3_sas_transport_functions); - if (!ps3_sas_transport_template) { + if (!ps3_sas_transport_template) ret = -PS3_FAILED; - } return ret; } void ps3_sas_release_transport(void) { - if(ps3_sas_transport_template != NULL) { + if (ps3_sas_transport_template != NULL) { sas_release_transport(ps3_sas_transport_template); ps3_sas_transport_template = NULL; } } #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h index 5b305d43933f..1430e8f7b6c2 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_sas_transport.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _WINDOWS #ifndef _PS3_SAS_TRANSPORT_H_ @@ -8,34 +9,35 @@ #include #include "ps3_htp.h" +#include "ps3_kernel_version.h" #define PS3_SAS_TIMEOUT_SEC (40) #define PS3_SMP_CRC_LEN (4) struct scsi_transport_template *ps3_sas_transport_get(void); -S32 ps3_sas_attach_transport(void); +int ps3_sas_attach_transport(void); void ps3_sas_release_transport(void); -S32 ps3_sas_linkerrors_get(struct sas_phy *phy); +int ps3_sas_linkerrors_get(struct sas_phy *phy); -S32 ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier); +int ps3_sas_enclosure_identifier_get(struct sas_rphy *rphy, u64 *identifier); -S32 ps3_sas_bay_identifier_get(struct sas_rphy *rphy); +int ps3_sas_bay_identifier_get(struct sas_rphy *rphy); -S32 ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset); +int ps3_sas_phy_reset(struct sas_phy *phy, int hard_reset); -S32 ps3_sas_phy_enable(struct sas_phy *phy, int enable); +int ps3_sas_phy_enable(struct sas_phy *phy, int enable); -S32 ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates); +int ps3_sas_linkrates_set(struct sas_phy *phy, struct sas_phy_linkrates *rates); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,14,0) -S32 ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, - struct request *req); -#else +#if defined(PS3_SAS_SMP_RETURN_VOID) void ps3_sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, - struct sas_rphy *rphy); + struct sas_rphy *rphy); +#else +int ps3_sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, + struct request *req); #endif #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c index 02517c79d735..ab505a5d1dd1 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.c @@ -1,4 +1,4 @@ - +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -29,20 +29,22 @@ #include "ps3_scsih_cmd_parse.h" #include "ps3_module_para.h" #include "ps3_r1x_write_lock.h" -#include "ps3_nvme_spec.h" +#include "ps3_htp_nvme_spec.h" #include "ps3_nvme_resp_to_scsi.h" #include "ps3_scsi_cmd_err.h" #include "ps3_ioc_manager.h" #include "ps3_mgr_channel.h" static void ps3_scsi_sense_print(struct ps3_instance *instance, - const U8 *sense_buffer, U8 len, S32 CFID); + const unsigned char *sense_buffer, + unsigned char len, int CFID); -static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, S32 err_code, - U32 xfer_cnt, Bool is_sata_jbod_mgr_cmd) +static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, int err_code, + unsigned int xfer_cnt, + unsigned char is_sata_jbod_mgr_cmd) { - S32 host_status = DID_OK; - S32 status = SCSI_STATUS_GOOD; + int host_status = DID_OK; + int status = SCSI_STATUS_GOOD; switch (err_code) { case PS3_STATUS_VD_OFFLINE: @@ -64,53 +66,52 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, S32 err_code, case PS3_STATUS_ACCESS_BLOCK: host_status = DID_OK; #ifndef _WINDOWS -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) +#if defined(PS3_SUPPORT_DRIVER_SENSE) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, - ILLEGAL_REQUEST, 0x20, 0x02); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, + 0x20, 0x02); scsi_set_resid(s_cmd, scsi_bufflen(s_cmd)); break; case PS3_STATUS_REQ_ILLEGAL: host_status = DID_OK; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) +#if defined(PS3_SUPPORT_DRIVER_SENSE) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, - ILLEGAL_REQUEST, 0x20, 0x00); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, + 0x20, 0x00); scsi_set_resid(s_cmd, scsi_bufflen(s_cmd)); #else scsi_build_sense_buffer(s_cmd, 0, ILLEGAL_REQUEST, 0x20, 0x02); #endif break; case PS3_STATUS_HOST_NOT_FOUND: - case PS3_STATUS_PCI_RECOVERY: + case PS3_STATUS_PCI_RECOVERY: host_status = DID_NO_CONNECT; break; case PS3_STATUS_VD_MEMBER_OFFLINE: host_status = DID_IMM_RETRY; break; case PS3_STATUS_HOST_RESET: - #if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) && (RHEL_MINOR == 3)) || \ - ((LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) && \ - (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,14)))) - host_status = DID_REQUEUE; - #else - host_status = DID_RESET; - #endif +#if defined(PS3_DID_REQUEUE) + host_status = DID_REQUEUE; +#else + host_status = DID_RESET; +#endif break; case PS3_STATUS_UNDERRUN: - if ((scsi_bufflen(s_cmd) < xfer_cnt) - && (!is_sata_jbod_mgr_cmd)) { + if ((scsi_bufflen(s_cmd) < xfer_cnt) && + (!is_sata_jbod_mgr_cmd)) { host_status = DID_SOFT_ERROR; scsi_set_resid(s_cmd, 0); } else if (scsi_bufflen(s_cmd) == xfer_cnt) { host_status = DID_OK; } else { if (scsi_bufflen(s_cmd) > xfer_cnt) { - scsi_set_resid(s_cmd, scsi_bufflen(s_cmd) - xfer_cnt); + scsi_set_resid(s_cmd, + scsi_bufflen(s_cmd) - xfer_cnt); } else { scsi_set_resid(s_cmd, 0); } @@ -118,11 +119,14 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, S32 err_code, host_status = DID_SOFT_ERROR; } else if (!xfer_cnt && s_cmd->cmnd[0] == REPORT_LUNS) { host_status = DID_OK; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) - s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); +#if defined(PS3_SUPPORT_DRIVER_SENSE) + s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS( + DRIVER_SENSE); #endif status = SAM_STAT_CHECK_CONDITION; - scsi_build_sense_buffer(0, s_cmd->sense_buffer, ILLEGAL_REQUEST, 0x20, 0x0); + scsi_build_sense_buffer(0, s_cmd->sense_buffer, + ILLEGAL_REQUEST, 0x20, + 0x0); } else { host_status = DID_OK; } @@ -146,11 +150,11 @@ static void ps3_internal_errcode_to_scsi(struct scsi_cmnd *s_cmd, S32 err_code, } static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, S32 err_code, - PS3RespFrame_u *resp_frame) + struct scsi_cmnd *s_cmd, int err_code, + union PS3RespFrame *resp_frame) { - S32 host_status = DID_OK; - S32 status = SCSI_STATUS_GOOD; + int host_status = DID_OK; + int status = SCSI_STATUS_GOOD; switch (err_code) { case SCSI_STATUS_GOOD: @@ -162,9 +166,7 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, status = err_code; break; case SCSI_STATUS_RESERVATION_CONFLICT: -#if ((defined(RHEL_MAJOR) && \ - ((RHEL_MAJOR < 9) || (RHEL_MAJOR == 9 && RHEL_MINOR < 3))) || \ - (!defined(RHEL_MAJOR) && LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 38))) +#if defined(PS3_DID_NEXUS_FAILURE) host_status = DID_NEXUS_FAILURE; #endif status = err_code; @@ -173,13 +175,14 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, host_status = DID_OK; status = err_code; if (resp_frame != NULL) { - memcpy(s_cmd->sense_buffer, resp_frame->normalRespFrame.sense, - SCSI_SENSE_BUFFERSIZE); - ps3_scsi_sense_print(instance, - s_cmd->sense_buffer, - SCSI_SENSE_BUFFERSIZE, SCMD_GET_REQUEST(s_cmd)->tag); + memcpy(s_cmd->sense_buffer, + resp_frame->normalRespFrame.sense, + SCSI_SENSE_BUFFERSIZE); + ps3_scsi_sense_print(instance, s_cmd->sense_buffer, + SCSI_SENSE_BUFFERSIZE, + SCMD_GET_REQUEST(s_cmd)->tag); } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) +#if defined(PS3_SUPPORT_DRIVER_SENSE) s_cmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif break; @@ -192,92 +195,108 @@ static void ps3_standard_errcode_to_scsi(struct ps3_instance *instance, } void ps3_errcode_to_scsi_status(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, U32 err_code, - PS3RespFrame_u *resp_frame, U32 xfer_cnt, struct ps3_cmd *cmd) + struct scsi_cmnd *s_cmd, unsigned int err_code, + union PS3RespFrame *resp_frame, + unsigned int xfer_cnt, struct ps3_cmd *cmd) { - Bool is_sata_jbod_mgr_cmd = 0; - if (cmd != NULL) { + unsigned char is_sata_jbod_mgr_cmd = 0; + + if (cmd != NULL) is_sata_jbod_mgr_cmd = ps3_scsih_is_sata_jbod_mgr_cmd(cmd); - } s_cmd->result = SCSI_STATUS_GOOD; if (err_code < PS3_STATUS_DEVICE_NOT_FOUND) { - ps3_standard_errcode_to_scsi(instance, - s_cmd, err_code, resp_frame); + ps3_standard_errcode_to_scsi(instance, s_cmd, err_code, + resp_frame); } else { - ps3_internal_errcode_to_scsi(s_cmd, err_code, xfer_cnt, is_sata_jbod_mgr_cmd); + ps3_internal_errcode_to_scsi(s_cmd, err_code, xfer_cnt, + is_sata_jbod_mgr_cmd); } } -static inline void ps3_err_scsi_errcode_mapping(struct ps3_cmd *cmd, U16 mode, - Bool is_sas_direct) +static inline void ps3_err_scsi_errcode_mapping(struct ps3_cmd *cmd, + unsigned short mode, + unsigned char is_sas_direct) { - U8 opcode = 0; - U16 sub_opcode = 0; - U32 resp_status = 0; - PS3RespFrame_u *resp_frame = cmd->resp_frame; - U32 xfer_cnt = 0; - Ps3SasDirectRespFrameIU_s *frame = NULL; + unsigned char opcode = 0; + unsigned short sub_opcode = 0; + unsigned int resp_status = 0; + union PS3RespFrame *resp_frame = cmd->resp_frame; + unsigned int xfer_cnt = 0; + struct Ps3SasDirectRespFrameIU *frame = NULL; ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &opcode, &sub_opcode); - LOG_FILE_INFO("tid:0x%llx hno:%u op:0x%x sub_op:0x%x " - "tag:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), - opcode, sub_opcode, cmd->index); - - if (ps3_err_is_resp_from_direct_cmd(mode) - && (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { - resp_status = resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; + LOG_FILE_INFO("tid:0x%llx hno:%u op:0x%x sub_op:0x%x tag:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), opcode, + sub_opcode, cmd->index); + + if (ps3_err_is_resp_from_direct_cmd(mode) && + (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { + resp_status = + resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; } else { - resp_status = resp_frame->normalRespFrame.respStatus & PS3_SCSI_STATUS_MASK; + resp_status = resp_frame->normalRespFrame.respStatus & + PS3_SCSI_STATUS_MASK; } xfer_cnt = ps3_scsih_xfer_cnt_get(cmd); - ps3_errcode_to_scsi_status(cmd->instance, cmd->scmd, resp_status, resp_frame, xfer_cnt, cmd); + ps3_errcode_to_scsi_status(cmd->instance, cmd->scmd, resp_status, + resp_frame, xfer_cnt, cmd); if (is_sas_direct) { frame = &resp_frame->sasRespFrame; - LOG_INFO_IN_IRQ(cmd->instance, - "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x " - "tag:%u data_pres:%u resp_status:0x%x scmd status:0x%x " - "scmd cmd_flags:0x%llx, retries:%d, allowd:%d," - "xfer_cnt:%u scsi_buflen:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->scmd->device->channel, - cmd->scmd->device->id, cmd->io_attr.disk_id, opcode, sub_opcode, - cmd->index, frame->dataPres, frame->status, cmd->scmd->result, - (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, - cmd->scmd->retries, cmd->scmd->allowed, - xfer_cnt, scsi_bufflen(cmd->scmd)); + LOG_INFO_IN_IRQ( + cmd->instance, + "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x\n" + "\ttag:%u data_pres:%u resp_status:0x%x scmd status:0x%x\n" + "\tscmd cmd_flags:0x%llx, retries:%d, allowd:%d,\n" + "\txfer_cnt:%u scsi_buflen:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->scmd->device->channel, cmd->scmd->device->id, + cmd->io_attr.disk_id, opcode, sub_opcode, cmd->index, + frame->dataPres, frame->status, cmd->scmd->result, + (unsigned long long)SCMD_GET_REQUEST(cmd->scmd) + ->cmd_flags, + cmd->scmd->retries, cmd->scmd->allowed, xfer_cnt, + scsi_bufflen(cmd->scmd)); } else { - LOG_INFO_IN_IRQ(cmd->instance, - "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x " - "tag:%u resp_status:0x%x scmd status:0x%x" - "scmd cmd_flags:0x%llx, retries:%d, allowd:%d, " - "xfer_cnt:%u scsi_buflen:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->scmd->device->channel, - cmd->scmd->device->id, cmd->io_attr.disk_id, opcode, sub_opcode, - cmd->index, resp_frame->normalRespFrame.respStatus, cmd->scmd->result, - (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, cmd->scmd->retries, - cmd->scmd->allowed, xfer_cnt, scsi_bufflen(cmd->scmd)); + LOG_INFO_IN_IRQ( + cmd->instance, + "tid:0x%llx hno:%u [%u:%u:%u], op:0x%x sub_op:0x%x\n" + "\ttag:%u resp_status:0x%x scmd status:0x%x\n" + "\tscmd cmd_flags:0x%llx, retries:%d, allowd:%d,\n" + "\txfer_cnt:%u scsi_buflen:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->scmd->device->channel, cmd->scmd->device->id, + cmd->io_attr.disk_id, opcode, sub_opcode, cmd->index, + resp_frame->normalRespFrame.respStatus, + cmd->scmd->result, + (unsigned long long)SCMD_GET_REQUEST(cmd->scmd) + ->cmd_flags, + cmd->scmd->retries, cmd->scmd->allowed, xfer_cnt, + scsi_bufflen(cmd->scmd)); } } -static Bool ps3_err_retry_sys_state_check(struct ps3_instance *instance) +static unsigned char +ps3_err_retry_sys_state_check(struct ps3_instance *instance) { - Bool ret = PS3_DRV_TRUE; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + unsigned char ret = PS3_DRV_TRUE; + int cur_state = PS3_INSTANCE_STATE_INIT; if (!instance->state_machine.is_load) { - LOG_WARN_IN_IRQ(instance, - "hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_WARN_IN_IRQ(instance, "hno:%u instance state not is_load\n", + PS3_HOST(instance)); ret = PS3_DRV_FALSE; goto l_out; } cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { + cur_state == PS3_INSTANCE_STATE_QUIT) { LOG_WARN_IN_IRQ(instance, - "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); + "hno:%u instance state is dead/quit\n", + PS3_HOST(instance)); ret = PS3_DRV_FALSE; goto l_out; } @@ -286,20 +305,21 @@ static Bool ps3_err_retry_sys_state_check(struct ps3_instance *instance) return ret; } -static S32 ps3_is_state_abnormal(struct ps3_instance *instance) +static int ps3_is_state_abnormal(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; static unsigned long j; - if (!ps3_is_instance_state_normal(instance, PS3_TRUE)){ + if (!ps3_is_instance_state_normal(instance, PS3_TRUE)) { ret = -PS3_FAILED; goto l_out; } if (ps3_pci_err_recovery_get(instance)) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u host in pci recovery\n", - PS3_HOST(instance)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u host in pci recovery\n", + PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } @@ -307,74 +327,80 @@ static S32 ps3_is_state_abnormal(struct ps3_instance *instance) return ret; } -static Bool ps3_err_code_is_need_change(const struct ps3_cmd *cmd) +static unsigned char ps3_err_code_is_need_change(const struct ps3_cmd *cmd) { - U32 err_code = 0; - PS3RespFrame_u *resp_frame = cmd->resp_frame; - U16 mode = cmd->reply_word.mode; - Bool ret = PS3_TRUE; - PS3NvmeCmdStatus_s status; - ps3_nvme_scsi_status cpl; + unsigned int err_code = 0; + union PS3RespFrame *resp_frame = cmd->resp_frame; + unsigned short mode = cmd->reply_word.mode; + unsigned char ret = PS3_TRUE; + struct PS3NvmeCmdStatus status; + struct ps3_nvme_scsi_status cpl; if (ps3_err_is_resp_from_direct_cmd(mode)) { if (cmd->reply_word.diskType == PS3_DEV_TYPE_SAS_SATA) { - err_code = resp_frame->sasRespFrame.status & PS3_SCSI_STATUS_MASK; + err_code = resp_frame->sasRespFrame.status & + PS3_SCSI_STATUS_MASK; } else { status.cmdStatus = cmd->reply_word.retStatus; - memset(&cpl, 0, sizeof(ps3_nvme_scsi_status)); + memset(&cpl, 0, sizeof(struct ps3_nvme_scsi_status)); ps3_nvme_error_to_scsi_status(status, &cpl); - err_code = cpl.status; + err_code = cpl.status; } } switch (err_code) { - case SCSI_STATUS_BUSY: - case SCSI_STATUS_TASK_SET_FULL: - case SCSI_STATUS_CONDITION_MET: - case SCSI_STATUS_ACA_ACTIVE: - case PS3_STATUS_OVERRUN: - case PS3_STATUS_UNDERRUN: - ret = PS3_FALSE; - break; - default: - ret = PS3_TRUE; + case SCSI_STATUS_BUSY: + case SCSI_STATUS_TASK_SET_FULL: + case SCSI_STATUS_CONDITION_MET: + case SCSI_STATUS_ACA_ACTIVE: + case PS3_STATUS_OVERRUN: + case PS3_STATUS_UNDERRUN: + ret = PS3_FALSE; + break; + default: + ret = PS3_TRUE; } LOG_DEBUG("tid:0x%llx hno:%u tag:%u status:0x%x %s change\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, err_code, - ret == PS3_TRUE?"need":"no need"); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, err_code, + ret == PS3_TRUE ? "need" : "no need"); return ret; } -static inline Bool ps3_is_need_direct_to_normal(const struct ps3_instance *instance, - const struct ps3_cmd *cmd) +static inline unsigned char +ps3_is_need_direct_to_normal(const struct ps3_instance *instance, + const struct ps3_cmd *cmd) { - return ((instance->ioc_adpter->is_need_direct_to_normal != NULL) - && (instance->ioc_adpter->is_need_direct_to_normal(cmd)) - && (cmd->scmd->allowed != 0)); + return ((instance->ioc_adpter->is_need_direct_to_normal != NULL) && + (instance->ioc_adpter->is_need_direct_to_normal(cmd)) && + (cmd->scmd->allowed != 0)); } -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock); +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, + unsigned char resp_status, + unsigned char cmd_lock); -S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, - U32 id, U32 channel) +int ps3_err_scsi_io_processing(struct ps3_instance *instance, unsigned int id, + unsigned int channel) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd_context *cmd_context = &instance->cmd_context; struct ps3_cmd *cmd = NULL; - U16 idx = 0; + unsigned short idx = 0; struct scsi_cmnd *s_cmd = NULL; static unsigned long j; + ps3_msleep(ps3_task_reset_delay_time_query()); ps3_atomic_inc(&instance->is_err_scsi_processing); - rmb(); + rmb(); /* in order to force CPU ordering */ ret = ps3_is_state_abnormal(instance); if (ret != PS3_SUCCESS) { - LOG_INFO("hno:%u ps3_err_scsi_io_processing [%d:%d] fail, abnormal\n", - PS3_HOST(instance), channel, id); + LOG_INFO( + "hno:%u %s [%d:%d] fail, abnormal\n", + PS3_HOST(instance), __func__, channel, id); ret = -PS3_FAILED; ps3_atomic_dec(&instance->is_err_scsi_processing); goto l_out; @@ -388,30 +414,30 @@ S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, ps3_all_reply_fifo_complete(instance); - for (idx = 0 ; idx < cmd_context->max_scsi_cmd_count; idx++) { + for (idx = 0; idx < cmd_context->max_scsi_cmd_count; idx++) { cmd = ps3_cmd_find(instance, idx); - if(cmd == NULL) { + if (cmd == NULL) { ret = -PS3_FAILED; break; } - if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) { + if (cmd->cmd_state.state == PS3_CMD_STATE_INIT) continue; - } s_cmd = cmd->scmd; - if (s_cmd == NULL) { + if (s_cmd == NULL) continue; - } - if (s_cmd->device == NULL) { + if (s_cmd->device == NULL) continue; - } if (PS3_SDEV_TARGET(s_cmd->device) == id && - PS3_SDEV_CHANNEL(s_cmd->device) == channel) { + PS3_SDEV_CHANNEL(s_cmd->device) == channel) { #ifndef _WINDOWS scsi_print_command(s_cmd); #endif - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u SCSI commands pending to target" - " tid:0x%llx [%u:%u]: frame_id:%d\n", - PS3_HOST(instance), cmd->trace_id, channel, id, cmd->index); + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u SCSI commands pending to target\n" + "\ttid:0x%llx [%u:%u]: frame_id:%d\n", + PS3_HOST(instance), cmd->trace_id, channel, id, + cmd->index); ret = -PS3_FAILED; break; } @@ -428,14 +454,15 @@ S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, } static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, - PS3RespFrame_u *frame) + union PS3RespFrame *frame) { - U32 sense_data_len = 0; + unsigned int sense_data_len = 0; struct scsi_cmnd *scmd = cmd->scmd; struct ps3_instance *instance = cmd->instance; #ifndef _WINDOWS - S32 host_status = DID_OK; - Ps3SasDirectRespFrameIU_s frame_sas = frame->sasRespFrame; + int host_status = DID_OK; + struct Ps3SasDirectRespFrameIU frame_sas = frame->sasRespFrame; + if (scmd == NULL || scmd->sense_buffer == NULL) { LOG_WARN_IN_IRQ(instance, "scmd is null\n"); goto l_out; @@ -448,20 +475,23 @@ static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, goto l_out; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0)) +#if defined(PS3_SUPPORT_DRIVER_SENSE) scmd->result |= PS3_SCSI_RESULT_DRIVER_STATUS(DRIVER_SENSE); #endif - scmd->result |= PS3_SCSI_RESULT_HOST_STATUS(host_status) | frame_sas.status; + scmd->result |= + PS3_SCSI_RESULT_HOST_STATUS(host_status) | frame_sas.status; memset(scmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); - sense_data_len = min_t(U32, SCSI_SENSE_BUFFERSIZE, sizeof(frame_sas.data)); + sense_data_len = min_t(unsigned int, SCSI_SENSE_BUFFERSIZE, + sizeof(frame_sas.data)); if (sense_data_len == 0) { LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); goto l_out; } memcpy(scmd->sense_buffer, frame_sas.data, sense_data_len); ps3_scsi_sense_print(instance, scmd->sense_buffer, - SCSI_SENSE_BUFFERSIZE, SCMD_GET_REQUEST(scmd)->tag); + SCSI_SENSE_BUFFERSIZE, + SCMD_GET_REQUEST(scmd)->tag); #else if (frame == NULL) { LOG_ERROR_IN_IRQ(instance, "direct frame is null, retry\n"); @@ -469,166 +499,197 @@ static void ps3_err_sas_errcode_mapping_with_sense(struct ps3_cmd *cmd, goto l_out; } sense_data_len = min(SCSI_SENSE_BUFFERSIZE, sizeof(frame_sas.data)); - if (sense_data_len == 0) { - LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); - goto l_out; - } + if (sense_data_len == 0) { + LOG_ERROR_IN_IRQ(instance, "sense_data_len len is zero\n"); + goto l_out; + } - ps3_sense_info_set(scmd, frame_sas.data, (U16)sense_data_len); + ps3_sense_info_set(scmd, frame_sas.data, + (unsigned short)sense_data_len); #endif l_out: return; } -static void ps3_err_sas_errcode_mapping(struct ps3_instance *instance, struct ps3_cmd *cmd, U16 mode) +static void ps3_err_sas_errcode_mapping(struct ps3_instance *instance, + struct ps3_cmd *cmd, + unsigned short mode) { struct scsi_cmnd *scmd = cmd->scmd; - U32 channel = 0; - U32 id = 0; - U16 disk_id = 0; - PS3RespFrame_u *frame = cmd->resp_frame; + unsigned int channel = 0; + unsigned int id = 0; + unsigned short disk_id = 0; + union PS3RespFrame *frame = cmd->resp_frame; static unsigned long j; #ifndef _WINDOWS channel = scmd->device->channel; id = scmd->device->id; disk_id = cmd->io_attr.disk_id; #endif - if (ps3_err_is_resp_from_direct_cmd(mode)){ - Ps3SasDirectRespFrameIU_s frame_sas = frame->sasRespFrame; + if (ps3_err_is_resp_from_direct_cmd(mode)) { + struct Ps3SasDirectRespFrameIU frame_sas = frame->sasRespFrame; switch (frame_sas.dataPres) { - case PS3_SAS_PRES_NO_DATA: - case PS3_SAS_PRES_REPSNSE_DATA: + case PS3_SAS_PRES_NO_DATA: + case PS3_SAS_PRES_REPSNSE_DATA: ps3_err_scsi_errcode_mapping(cmd, mode, PS3_TRUE); break; case PS3_SAS_PRES_SENSE_DATA: - LOG_INFO_IN_IRQ(instance, + LOG_INFO_IN_IRQ( + instance, "tid:0x%llx hno:%u [%u:%u:%u], CFID:%u data_pres:%u status:%u\n", - cmd->trace_id, PS3_HOST(instance), channel, - id, disk_id, cmd->index, - frame->sasRespFrame.dataPres, frame->sasRespFrame.status); + cmd->trace_id, PS3_HOST(instance), channel, id, + disk_id, cmd->index, + frame->sasRespFrame.dataPres, + frame->sasRespFrame.status); ps3_err_sas_errcode_mapping_with_sense(cmd, frame); break; default: #ifndef _WINDOWS scmd->result |= PS3_SCSI_RESULT_HOST_STATUS(DID_ERROR); - LOG_INFO_IN_IRQ(instance, - "tid:0x%llx hno:%d tag:%u scmd result:%x \n", + LOG_INFO_IN_IRQ( + instance, + "tid:0x%llx hno:%d tag:%u scmd result:%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, cmd->scmd->result); #else scsi_cmnd_hoststatus_set(scmd, DID_ERROR); - LOG_INFO_IN_IRQ(instance, - "tid:0x%llx hno:%d tag:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + LOG_INFO_IN_IRQ(instance, "tid:0x%llx hno:%d tag:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index); #endif break; } } else { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, \ + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u [chl:%u, id:%u, devid:%u], CFID:%u respStatus:%u\n", cmd->trace_id, PS3_HOST(instance), channel, id, disk_id, cmd->index, frame->normalRespFrame.respStatus); ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); } - return; } static void ps3_err_nvme_errcode_mapping(struct ps3_instance *instance, - struct ps3_cmd *cmd, U16 mode) + struct ps3_cmd *cmd, + unsigned short mode) { ps3_nvme_resp_to_scsi_status(cmd); ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); (void)instance; - LOG_INFO_IN_IRQ(instance, - "tid:0x%llx hno:%d tag:%d scmd result:%x \n", - cmd->trace_id, PS3_HOST(instance), - cmd->index, cmd->scmd->result); + LOG_INFO_IN_IRQ(instance, "tid:0x%llx hno:%d tag:%d scmd result:%x\n", + cmd->trace_id, PS3_HOST(instance), cmd->index, + cmd->scmd->result); } static void ps3_err_protocol_errcode_mapping(struct ps3_instance *instance, - struct ps3_cmd *cmd, struct PS3ReplyWord *reply_word) + struct ps3_cmd *cmd, + struct PS3ReplyWord *reply_word) { - if (reply_word->diskType == PS3_DEV_TYPE_SAS_SATA){ + if (reply_word->diskType == PS3_DEV_TYPE_SAS_SATA) ps3_err_sas_errcode_mapping(instance, cmd, reply_word->mode); - } else { + else ps3_err_nvme_errcode_mapping(instance, cmd, reply_word->mode); - } - return; } -Bool ps3_err_is_resp_from_direct_cmd(U16 mode) +unsigned char ps3_err_is_resp_from_direct_cmd(unsigned short mode) { - return ((mode == PS3_REPLY_WORD_MODE_DIRECT_OK) - || (mode == PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT)); + return ((mode == PS3_REPLY_WORD_MODE_DIRECT_OK) || + (mode == PS3_REPLY_WORD_MODE_DIRECT_ADVICE_TO_DIRECT)); } -S32 ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd) +int ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd) { - U16 mode = cmd->reply_word.mode; - S32 ret = PS3_SUCCESS; + unsigned short mode = cmd->reply_word.mode; + int ret = PS3_SUCCESS; - LOG_FILE_INFO("tid:0x%llx hno:%u scsi cmd fault proc CFID:%u " - "reply_word info: mode:%d retStatus[%02x], rettype:%d disktype:%d\n", + LOG_FILE_INFO( + "tid:0x%llx hno:%u scsi cmd fault proc CFID:%u\n" + "\treply_word info: mode:%d retStatus[%02x], rettype:%d disktype:%d\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, mode, - cmd->reply_word.retStatus, cmd->reply_word.retType, cmd->reply_word.diskType); + cmd->reply_word.retStatus, cmd->reply_word.retType, + cmd->reply_word.diskType); - if(cmd->reply_word.retType == 0) { - if ((cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) - && ps3_err_is_resp_from_direct_cmd(mode)) { + if (cmd->reply_word.retType == 0) { + if ((cmd->io_attr.dev_type != PS3_DEV_TYPE_VD) && + ps3_err_is_resp_from_direct_cmd(mode)) { if (ps3_err_retry_sys_state_check(instance)) { - LOG_FILE_INFO("hno:%u Direct cmd needs retry!" - " [scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", - PS3_HOST(instance), (U64)SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, + LOG_FILE_INFO( + "hno:%u Direct cmd needs retry!\n" + "\t[scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", + PS3_HOST(instance), + (unsigned long long)SCMD_GET_REQUEST( + cmd->scmd) + ->cmd_flags, cmd->scmd->retries, cmd->scmd->allowed); - if ((ps3_is_need_direct_to_normal(instance, cmd)) - && (ps3_err_code_is_need_change(cmd))) { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); + if ((ps3_is_need_direct_to_normal(instance, + cmd)) && + (ps3_err_code_is_need_change(cmd))) { + cmd->scmd->result = + PS3_SCSI_RESULT_HOST_STATUS( + DID_SOFT_ERROR); } else { - ps3_err_protocol_errcode_mapping(instance, cmd, &(cmd->reply_word)); + ps3_err_protocol_errcode_mapping( + instance, cmd, + &(cmd->reply_word)); } } else { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS( + DID_NO_CONNECT); } } else { ps3_err_scsi_errcode_mapping(cmd, mode, PS3_FALSE); } - }else { + } else { if (ps3_err_retry_sys_state_check(instance)) { - LOG_FILE_INFO("hno:%u Hil hardware err,need retry!" - " [scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", - PS3_HOST(instance), SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, + LOG_FILE_INFO( + "hno:%u Hil hardware err,need retry!\n" + "\t[scmd cmd_flags:0x%llx, retries:%d, allowd:%d]\n", + PS3_HOST(instance), + SCMD_GET_REQUEST(cmd->scmd)->cmd_flags, cmd->scmd->retries, cmd->scmd->allowed); - if (cmd->reply_word.retStatus == PS3_NVME_RESP_STATUS_SQ_FULL && - cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_OK) | SCSI_STATUS_TASK_SET_FULL; - cmd->scmd->retries = ((cmd->scmd->retries == 0) ? 1 : cmd->scmd->retries); + if (cmd->reply_word.retStatus == + PS3_NVME_RESP_STATUS_SQ_FULL && + cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + cmd->scmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_OK) | + SCSI_STATUS_TASK_SET_FULL; + cmd->scmd->retries = + ((cmd->scmd->retries == 0) ? + 1 : + cmd->scmd->retries); } else { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); + cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS( + DID_SOFT_ERROR); } } else { - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + cmd->scmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); } } if (cmd->scmd->result == SCSI_STATUS_TASK_SET_FULL) { - ps3_qos_adjust_pd_rsc(cmd->scmd->device, instance, PS3_QOS_QUOTA_ADJUST_QFULL); + ps3_qos_adjust_pd_rsc(cmd->scmd->device, instance, + PS3_QOS_QUOTA_ADJUST_QFULL); } return ret; } -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock) +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, + unsigned char resp_status, + unsigned char cmd_lock) { - struct ps3_instance *instance = cmd->instance; + struct ps3_instance *instance = cmd->instance; struct ps3_scsi_priv_data *data = NULL; if (cmd_lock) { ps3_mutex_lock(&instance->recovery_context->free_cmd_lock); - LOG_INFO("hno:%u tid:0x%llx CFID:%u drv reply scsi independently!\n", + LOG_INFO( + "hno:%u tid:0x%llx CFID:%u drv reply scsi independently!\n", PS3_HOST(instance), cmd->trace_id, cmd->index); } if (likely(cmd->scmd == NULL)) { @@ -637,109 +698,107 @@ void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U } PS3_IO_OUTSTAND_DEC(instance, s_cmd); - PS3_VD_OUTSTAND_DEC(instance, s_cmd); + PS3_VD_OUTSTAND_DEC(instance, cmd); PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); - ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0, cmd); + ps3_errcode_to_scsi_status(cmd->instance, s_cmd, resp_status, NULL, 0, + cmd); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#if defined(PS3_SUPPORT_CMD_SCP) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; - if(likely(data != NULL)){ + if (likely(data != NULL)) ps3_r1x_write_unlock(&data->lock_mgr, cmd); - } if (cmd->r1x_peer_cmd != NULL) { - LOG_DEBUG("host_no:%u task repaly r1x scsi write CFID:%d and CFID:%d\n", - PS3_HOST(instance), cmd->index, cmd->r1x_peer_cmd->index); - if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) { + LOG_DEBUG( + "host_no:%u task repaly r1x scsi write CFID:%d and CFID:%d\n", + PS3_HOST(instance), cmd->index, + cmd->r1x_peer_cmd->index); + if (!ps3_r1x_peer_cmd_free_nolock(cmd->r1x_peer_cmd)) ps3_scsi_cmd_free(cmd->r1x_peer_cmd); - } - if (!ps3_r1x_peer_cmd_free_nolock(cmd)) { + if (!ps3_r1x_peer_cmd_free_nolock(cmd)) ps3_scsi_cmd_free(cmd); - } } else { ps3_scsi_cmd_free(cmd); } SCMD_IO_DONE(s_cmd); l_out: - if (cmd_lock) { + if (cmd_lock) ps3_mutex_unlock(&instance->recovery_context->free_cmd_lock); - } - return ; } -S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) +int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) { #ifdef _WINDOWS (void)scmd; #else - S32 ret = SUCCESS; + int ret = SUCCESS; struct ps3_cmd *aborted_cmd = NULL; struct ps3_cmd *aborted_peer_cmd = NULL; - U16 cmd_frame_id = 0; + unsigned short cmd_frame_id = 0; struct ps3_instance *instance = scsi_host_data(scmd); - struct ps3_scsi_priv_data *scsi_priv_data = scsi_device_private_data(scmd); - U32 cmd_flighting_wait_cnt = 0; + struct ps3_scsi_priv_data *scsi_priv_data = + scsi_device_private_data(scmd); + unsigned int cmd_flighting_wait_cnt = 0; - LOG_WARN("hno:%u enter, ready aborted CFID:%u op:0x%x " - "chl:%u id:%u\n", PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag, - scmd->cmnd[0], ps3_scsi_channel_query(scmd), - ps3_scsi_target_query(scmd)); + LOG_WARN("hno:%u enter, ready aborted CFID:%u op:0x%x chl:%u id:%u\n", + PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag, scmd->cmnd[0], + ps3_scsi_channel_query(scmd), ps3_scsi_target_query(scmd)); - INJECT_START(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, instance) + INJECT_START(PS3_ERR_IJ_SCSI_TASK_PRE_CHECK_FAILED, instance); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { - LOG_WARN("hno:%u pre check NOK!\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pre check NOK!\n", PS3_HOST(instance)); ret = FAILED; goto l_out; } if (!scsi_priv_data->is_taskmgmt_enable) { - LOG_ERROR("hno:%u task mgmt is disable!\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u task mgmt is disable!\n", PS3_HOST(instance)); ret = FAILED; goto l_out; } cmd_frame_id = SCMD_GET_REQUEST(scmd)->tag; - INJECT_START(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_ABORT_PRE1_FORCE_ABORTED_CMD_DONE, scmd); aborted_cmd = ps3_cmd_find(instance, cmd_frame_id); if (aborted_cmd == NULL || aborted_cmd->scmd == NULL) { LOG_INFO("host_no:%u there is no aborted cmd CFID:%u\n", - PS3_HOST(instance), cmd_frame_id); + PS3_HOST(instance), cmd_frame_id); ret = SUCCESS; goto l_out; } - INJECT_START(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, scmd) + INJECT_START(PS3_ERR_IJ_ABORT_PRE2_FORCE_ABORTED_CMD_DONE, scmd); - LOG_FILE_WARN("tid:0x%llx hno:%u task aborted CFID:%u ready \n", - aborted_cmd->trace_id, PS3_HOST(instance), cmd_frame_id); + LOG_FILE_WARN("tid:0x%llx hno:%u task aborted CFID:%u ready\n", + aborted_cmd->trace_id, PS3_HOST(instance), cmd_frame_id); scsi_priv_data->task_manager_busy = 1; - while(aborted_cmd->flighting && - cmd_flighting_wait_cnt < PS3_ABORT_WAIT_CMD_FLIGHT_END) { + while (aborted_cmd->flighting && + cmd_flighting_wait_cnt < PS3_ABORT_WAIT_CMD_FLIGHT_END) { ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); cmd_flighting_wait_cnt++; } if (aborted_cmd->flighting) { ret = FAILED; - LOG_WARN("task abort wait cmd filghting end NOK. hno:%u tid:0x%llx CFID:%u\n", - PS3_HOST(instance), aborted_cmd->trace_id, aborted_cmd->index); + LOG_WARN( + "task abort wait cmd filghting end NOK. hno:%u tid:0x%llx CFID:%u\n", + PS3_HOST(instance), aborted_cmd->trace_id, + aborted_cmd->index); goto l_busy_clean_out; } LOG_DEBUG("hno:%u task abort wait flighting cmd end\n", - PS3_HOST(instance)); + PS3_HOST(instance)); if (ps3_r1x_conflict_queue_abort(aborted_cmd, scmd)) { ret = SUCCESS; @@ -756,14 +815,18 @@ S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC1, aborted_peer_cmd); ps3_mutex_lock(&instance->task_abort_lock); aborted_peer_cmd->is_aborting = 1; - wmb(); + wmb(); /* in order to force CPU ordering */ INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE, aborted_cmd); if (aborted_cmd->r1x_peer_cmd == NULL) { - INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC, aborted_peer_cmd); - INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, aborted_peer_cmd); - INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE, aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC, + aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, + aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_FREE, + aborted_peer_cmd); aborted_peer_cmd->is_aborting = 0; - INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, aborted_peer_cmd); + INJECT_START(PS3_ERR_IJ_WAIT_CMD_ALLOC2, + aborted_peer_cmd); ps3_mutex_unlock(&instance->task_abort_lock); goto l_busy_clean_out; } @@ -772,15 +835,18 @@ S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) INJECT_START(PS3_ERR_IJ_ABORT_BLOCK1, instance); if (!aborted_peer_cmd->is_r1x_scsi_complete) { ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, - aborted_peer_cmd->index, scmd); + aborted_peer_cmd->index, + scmd); ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; aborted_peer_cmd->is_aborting = 0; INJECT_START(PS3_ERR_IJ_ABORT_BLOCK2, instance); if (ret == SUCCESS) { - LOG_INFO("hno:%u task abort peer cmd:%d success !\n", - PS3_HOST(instance), aborted_peer_cmd->index); - aborted_peer_cmd = ps3_cmd_find(instance, + LOG_INFO( + "hno:%u task abort peer cmd:%d success !\n", + PS3_HOST(instance), aborted_peer_cmd->index); + aborted_peer_cmd = ps3_cmd_find( + instance, aborted_peer_cmd->index); if (unlikely(aborted_peer_cmd == NULL)) { ret = FAILED; goto l_busy_clean_out; @@ -793,19 +859,22 @@ S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) } } - ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, - cmd_frame_id, scmd); + ret = ps3_scsi_task_mgr_abort(instance, scsi_priv_data, cmd_frame_id, + scmd); ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; - if(ret == SUCCESS) { - LOG_INFO("hno:%u task abort cmd success !\n", PS3_HOST(instance)); + if (ret == SUCCESS) { + LOG_INFO("hno:%u task abort cmd success !\n", + PS3_HOST(instance)); aborted_cmd = ps3_cmd_find(instance, cmd_frame_id); if (aborted_cmd == NULL) { ret = FAILED; } else { if (unlikely(aborted_cmd->scmd)) { - LOG_WARN("task abort success but scmd is not freed. hno:%u tid:0x%llx CFID:%u\n", - PS3_HOST(instance), aborted_cmd->trace_id, cmd_frame_id); + LOG_WARN( + "task abort success but scmd is not freed. hno:%u tid:0x%llx CFID:%u\n", + PS3_HOST(instance), + aborted_cmd->trace_id, cmd_frame_id); ret = FAILED; } ps3_can_queue_depth_update(instance); @@ -813,15 +882,18 @@ S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd) } l_busy_clean_out: scsi_priv_data->task_manager_busy = 0; - wmb(); + wmb(); /* in order to force CPU ordering */ l_out: - LOG_WARN("hno:%u quit ret:%#x\n",PS3_HOST(instance), ret); + LOG_WARN("hno:%u quit ret:%#x\n", PS3_HOST(instance), ret); return ret; #endif return -PS3_FAILED; } -void ps3_set_task_manager_busy(struct ps3_instance *instance, U32 channel, U32 id, U32 state) +#ifdef PS3_UT +void ps3_set_task_manager_busy(struct ps3_instance *instance, + unsigned int channel, unsigned int id, + unsigned int state) { struct ps3_scsi_priv_data *scsi_priv_data = NULL; @@ -831,7 +903,7 @@ void ps3_set_task_manager_busy(struct ps3_instance *instance, U32 channel, U32 i if (scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted.channel:%u, id:%u!\n", - PS3_HOST(instance), channel, id); + PS3_HOST(instance), channel, id); goto l_out; } scsi_priv_data->task_manager_busy = state; @@ -841,27 +913,28 @@ void ps3_set_task_manager_busy(struct ps3_instance *instance, U32 channel, U32 i l_out: return; } +#endif -S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) +int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) { - S32 ret = PS3_SUCCESS; - S32 send_result = PS3_SUCCESS; + int ret = PS3_SUCCESS; + int send_result = PS3_SUCCESS; struct ps3_instance *instance = scsi_host_data(scmd); struct ps3_scsi_priv_data *scsi_priv_data = NULL; struct ps3_scsi_priv_data pending_priv_data; - struct ps3_cmd * cmd = NULL; + struct ps3_cmd *cmd = NULL; LOG_INFO("hno:%u enter device reset channel:%u id:%u\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), - PS3_SDEV_TARGET(scmd->device)); + PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), + PS3_SDEV_TARGET(scmd->device)); ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL1, scmd->device) + INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL1, scmd->device); scsi_priv_data = scsi_device_private_data(scmd); - if(scsi_priv_data == NULL) { + if (scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); #ifndef _WINDOWS scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); ret = SUCCESS; @@ -872,14 +945,15 @@ S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) } LOG_WARN("hno:%u enter ready reset[%u:%u:%u:%#x], CFID:%d\n", - PS3_HOST(instance), scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, - scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, - scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, - scsi_priv_data->disk_pos.diskMagicNum, SCMD_GET_REQUEST(scmd)->tag); + PS3_HOST(instance), + scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, + scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, + scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID, + scsi_priv_data->disk_pos.diskMagicNum, + SCMD_GET_REQUEST(scmd)->tag); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { - LOG_WARN("hno:%u pre check NOK!\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u pre check NOK!\n", PS3_HOST(instance)); #ifndef _WINDOWS ret = FAILED; #else @@ -890,8 +964,7 @@ S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) } if (!scsi_priv_data->is_taskmgmt_enable) { - LOG_ERROR("hno:%u task mgmt is disable!\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u task mgmt is disable!\n", PS3_HOST(instance)); #ifndef _WINDOWS ret = FAILED; #else @@ -901,37 +974,40 @@ S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) goto l_out; } - LOG_INFO("hno:%u task ready reset[%u:%u:%u] \n",PS3_HOST(instance), - scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, - scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, - scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID); + LOG_INFO("hno:%u task ready reset[%u:%u:%u]\n", PS3_HOST(instance), + scsi_priv_data->disk_pos.diskDev.ps3Dev.softChan, + scsi_priv_data->disk_pos.diskDev.ps3Dev.devID, + scsi_priv_data->disk_pos.diskDev.ps3Dev.phyDiskID); scsi_priv_data->task_manager_busy = 1; ps3_wait_scsi_cmd_done(instance, PS3_TRUE); - LOG_WARN("hno[%u], task reset wait scsi delivering cmd count[%d] !\n", PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.cmd_delivering)); + LOG_WARN("hno[%u], task reset wait scsi delivering cmd count[%d] !\n", + PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.cmd_delivering)); ps3_wait_mgr_cmd_done(instance, PS3_TRUE); - LOG_WARN("hno:%u task reset wait delivering cmd end !\n", PS3_HOST(instance)); + LOG_WARN("hno:%u task reset wait delivering cmd end !\n", + PS3_HOST(instance)); ps3_r1x_conflict_queue_clean(scsi_priv_data, SCSI_STATUS_TASK_ABORTED); - memcpy(&pending_priv_data, scsi_priv_data, sizeof(struct ps3_scsi_priv_data)); + memcpy(&pending_priv_data, scsi_priv_data, + sizeof(struct ps3_scsi_priv_data)); - ps3_qos_device_clean(instance, scsi_priv_data, SCSI_STATUS_TASK_ABORTED); + ps3_qos_device_clean(instance, scsi_priv_data, + SCSI_STATUS_TASK_ABORTED); ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); ps3_atomic_inc(&instance->cmd_statistics.cmd_delivering); INJECT_START(PS3_ERR_IJ_V2_IS_LOAD_FALSE1, instance); if (ps3_mgr_cmd_send_pre_check(instance, PS3_FALSE) != PS3_SUCCESS) { LOG_WARN_LIM("hno:%u mgr reset cmd pre check NOK CFID:%d\n", - PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag); + PS3_HOST(instance), SCMD_GET_REQUEST(scmd)->tag); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = FAILED; goto l_err; } cmd = ps3_scsi_task_mgr_reset_build(instance, &pending_priv_data); if (cmd == NULL) { - LOG_ERROR("hno:%u task reset cmd NOK!\n", - PS3_HOST(instance)); + LOG_ERROR("hno:%u task reset cmd NOK!\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); ret = FAILED; goto l_err; @@ -939,51 +1015,48 @@ S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd) send_result = ps3_cmd_send_sync(instance, cmd); ps3_atomic_dec(&instance->cmd_statistics.cmd_delivering); - if (send_result == PS3_SUCCESS) { + if (send_result == PS3_SUCCESS) send_result = ps3_cmd_wait_sync(instance, cmd); - } ret = ps3_mgr_complete_proc(instance, cmd, send_result); LOG_INFO("host_no:%u reset finish CFID:%u t_id:0x%llx!\n", - PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); + PS3_HOST(instance), ps3_cmd_frame_id(cmd), cmd->trace_id); - if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) { + if ((ret != -PS3_CMD_NO_RESP) && (cmd != NULL)) ps3_task_cmd_free(instance, cmd); - } ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; if (ret == SUCCESS) { LOG_INFO("hno:%u target reset success !\n", PS3_HOST(instance)); ret = ps3_err_scsi_io_processing(instance, scmd->device->id, - scmd->device->channel); - INJECT_START(PS3_ERR_IJ_HT_ABNORMAL1, &ret) + scmd->device->channel); + INJECT_START(PS3_ERR_IJ_HT_ABNORMAL1, &ret); ret = (ret == PS3_SUCCESS) ? SUCCESS : FAILED; ps3_can_queue_depth_update(instance); } l_err: ps3_mutex_lock(&instance->dev_context.dev_priv_lock); - INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL2, scmd->device) + INJECT_START(PS3_ERR_IJ_PRIV_DATA_NULL2, scmd->device); scsi_priv_data = scsi_device_private_data(scmd); if (scsi_priv_data == NULL) { ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); LOG_ERROR("hno:%u device has been deleted!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } scsi_priv_data->task_manager_busy = 0; ps3_mutex_unlock(&instance->dev_context.dev_priv_lock); l_out: - LOG_WARN("hno:%u quit ret:%#x\n",PS3_HOST(instance), ret); + LOG_WARN("hno:%u quit ret:%#x\n", PS3_HOST(instance), ret); return ret; } -S32 ps3_device_reset_handler(struct scsi_cmnd *scmd) +int ps3_device_reset_handler(struct scsi_cmnd *scmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_instance *instance = scsi_host_data(scmd); - LOG_INFO("hno:%u ready device[%u:%u] reset!\n", - PS3_HOST(instance), PS3_SDEV_CHANNEL(scmd->device), - PS3_SDEV_TARGET(scmd->device)); + LOG_INFO("hno:%u ready device[%u:%u] reset!\n", PS3_HOST(instance), + PS3_SDEV_CHANNEL(scmd->device), PS3_SDEV_TARGET(scmd->device)); ps3_mutex_lock(&instance->task_mgr_reset_lock); instance->task_manager_host_busy = PS3_TRUE; @@ -994,95 +1067,98 @@ S32 ps3_device_reset_handler(struct scsi_cmnd *scmd) return ret; } -static S32 ps3_hard_reset_pre_check(struct ps3_instance *instance) +static int ps3_hard_reset_pre_check(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; - Bool is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); - U32 hard_reset_enable = ps3_hard_reset_enable_query(); + int ret = PS3_SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; + unsigned char is_support_halt = PS3_IOC_STATE_HALT_SUPPORT(instance); + unsigned int hard_reset_enable = ps3_hard_reset_enable_query(); cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno:%u ready to host reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); - - if(is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)){ + PS3_HOST(instance), namePS3InstanceState(cur_state)); + if (is_support_halt && (cur_state != PS3_INSTANCE_STATE_DEAD)) { ps3_atomic_set(&instance->state_machine.state, - PS3_INSTANCE_STATE_DEAD); + PS3_INSTANCE_STATE_DEAD); instance->ioc_adpter->ioc_force_to_halt(instance); LOG_INFO("host_no:%u instance state while support halt!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = -PS3_FAILED; } - if ((cur_state = ps3_atomic_read(&instance->state_machine.state)) == - PS3_INSTANCE_STATE_DEAD && (!hard_reset_enable || is_support_halt - || (!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)))) { + cur_state = ps3_atomic_read(&instance->state_machine.state); + if (cur_state == PS3_INSTANCE_STATE_DEAD && + (!hard_reset_enable || is_support_halt || + (!PS3_IOC_HARD_RECOVERY_SUPPORT(instance)))) { LOG_INFO("hno:%u host reset, instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } - LOG_INFO("hno:%u host reset, instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u host reset, instance state: %s\n", PS3_HOST(instance), + namePS3InstanceState(cur_state)); return ret; } -static S32 ps3_host_reset_pre_check(struct ps3_instance *instance) +static int ps3_host_reset_pre_check(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - S32 cur_state = ps3_atomic_read(&instance->state_machine.state); + int ret = PS3_SUCCESS; + int cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_WARN("hno:%u ready to host reset,instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); if (PS3_DEVICE_IS_SWITCH(instance->dev_id) && - !instance->is_scan_host_finish) { - LOG_INFO("host_no:%u instance deviceId:%u is probe, exit failed!\n", + !instance->is_scan_host_finish) { + LOG_INFO( + "host_no:%u instance deviceId:%u is probe, exit failed!\n", PS3_HOST(instance), instance->dev_id); ret = -PS3_FAILED; goto l_out; } - if (cur_state == PS3_INSTANCE_STATE_QUIT || cur_state == PS3_INSTANCE_STATE_DEAD || - !instance->state_machine.can_hostreset) { + if (cur_state == PS3_INSTANCE_STATE_QUIT || + cur_state == PS3_INSTANCE_STATE_DEAD || + !instance->state_machine.can_hostreset) { LOG_ERROR("hno:%u cannot perform host reset due to %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = -PS3_FAILED; } else { LOG_INFO("hno:%u host reset, instance state: %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); } l_out: return ret; } -S32 ps3_wait_for_outstanding_complete(struct ps3_instance *instance) +static int ps3_wait_for_outstanding_complete(struct ps3_instance *instance) { - U32 i = 0; - U32 ioc_state = PS3_FW_STATE_UNDEFINED; - S32 ret = -PS3_FAILED; - U32 waittime_for_io_completion = PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE; - U32 interval = 1000; - U32 count = 0; + unsigned int i = 0; + unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; + int ret = -PS3_FAILED; + unsigned int waittime_for_io_completion = + PS3_WAIT_FOR_OUTSTANDING_IO_COMPLETE; + unsigned int interval = 1000; + unsigned int count = 0; for (i = 0; i < waittime_for_io_completion * 10 / interval; i++) { if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { LOG_ERROR_LIM("host_no:%u get ioc state NOK\n", - PS3_HOST(instance)); - if (count++ < 3) { + PS3_HOST(instance)); + if (count++ < 3) continue; - } goto l_out; } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { + ioc_state == PS3_FW_STATE_CRITICAL) { LOG_WARN("host_no:%u ioc_state:0x%x\n", - PS3_HOST(instance), ioc_state); + PS3_HOST(instance), ioc_state); goto l_out; } - if(atomic_read(&instance->cmd_statistics.io_outstanding) == 0) { + if (atomic_read(&instance->cmd_statistics.io_outstanding) == + 0) { LOG_WARN("host_no:%u io_outstanding is zero\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; goto l_out; } @@ -1094,13 +1170,29 @@ S32 ps3_wait_for_outstanding_complete(struct ps3_instance *instance) return ret; } -S32 ps3_reset_host(struct ps3_instance *instance) +unsigned char ps3_host_reset_state_check(struct ps3_instance *instance, + unsigned char is_host_reset) +{ + unsigned char ret = PS3_FALSE; + + ps3_mutex_lock(&instance->state_machine.lock); + if ((instance->recovery_context->host_reset_state == PS3_HOST_RESET_INIT) || + is_host_reset) { + ret = PS3_TRUE; + } + ps3_mutex_unlock(&instance->state_machine.lock); + + return ret; +} + +int ps3_reset_host(struct ps3_instance *instance) { - S32 ret = SUCCESS; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + int ret = SUCCESS; + int cur_state = PS3_INSTANCE_STATE_INIT; + LOG_INFO("hno:%u Host reset is requested, IOC outstanding: %d!!\n", - PS3_HOST(instance), - ps3_atomic_read(&instance->cmd_statistics.io_outstanding)); + PS3_HOST(instance), + ps3_atomic_read(&instance->cmd_statistics.io_outstanding)); ps3_atomic_inc(&instance->host_reset_processing); if (ps3_host_reset_pre_check(instance) != PS3_SUCCESS) { ret = FAILED; @@ -1108,49 +1200,52 @@ S32 ps3_reset_host(struct ps3_instance *instance) } do { if (unlikely(ps3_pci_err_recovery_get(instance))) { - LOG_WARN_LIM("hno:%u host in pci recovery during reset request\n", + LOG_WARN_LIM( + "hno:%u host in pci recovery during reset request\n", PS3_HOST(instance)); } else { ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_INIT) { - instance->recovery_context->host_reset_state = PS3_HOST_RESET_START; + if (instance->recovery_context->host_reset_state == + PS3_HOST_RESET_INIT) { + instance->recovery_context->host_reset_state = + PS3_HOST_RESET_START; ps3_mutex_unlock(&instance->state_machine.lock); break; } ps3_mutex_unlock(&instance->state_machine.lock); } ps3_msleep(100); - } while(1); + } while (1); + + while (ps3_atomic_read(&instance->recovery_context->hardreset_ref) > 0) + ps3_msleep(100); ps3_mutex_lock(&instance->state_machine.lock); if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - do{ + do { ps3_mutex_unlock(&instance->state_machine.lock); ps3_msleep(100); ps3_mutex_lock(&instance->state_machine.lock); - if (likely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + if (likely(instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { continue; } else { ps3_mutex_unlock(&instance->state_machine.lock); - cancel_work_sync(&instance->recovery_context->recovery_work); + ps3_cancel_work_sync(&instance->recovery_context->recovery_work); goto wait_hard_reset; } - }while(1); - } else if (instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW){ + } while (1); + } else if (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW) { ps3_mutex_unlock(&instance->state_machine.lock); - cancel_work_sync(&instance->recovery_context->recovery_work); + ps3_cancel_work_sync(&instance->recovery_context->recovery_work); } else { ps3_mutex_unlock(&instance->state_machine.lock); } - ps3_mutex_lock(&instance->state_machine.lock); - if (unlikely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { - instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_FINISH; - } - ps3_mutex_unlock(&instance->state_machine.lock); - if(ps3_wait_for_outstanding_complete(instance) == PS3_SUCCESS) { + if (ps3_wait_for_outstanding_complete(instance) == PS3_SUCCESS) { ret = SUCCESS; goto l_out; } @@ -1160,25 +1255,28 @@ S32 ps3_reset_host(struct ps3_instance *instance) goto l_out; } - if ((ret = ps3_hard_reset_pre_check(instance) ) != PS3_SUCCESS) { + if (ps3_hard_reset_pre_check(instance) != PS3_SUCCESS) { LOG_ERROR("hno:%u hard reset pre check NOK, %s!\n", - PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + PS3_HOST(instance), + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine.state))); ret = FAILED; goto l_wait; } ps3_mutex_lock(&instance->state_machine.lock); - if (instance->recovery_context->host_reset_state == PS3_HOST_RESET_HARD_RESET_DONE) { - instance->recovery_context->host_reset_state = PS3_HOST_RESET_START; + if (instance->recovery_context->host_reset_state == + PS3_HOST_RESET_HARD_RESET_DONE) { + instance->recovery_context->host_reset_state = + PS3_HOST_RESET_START; } ps3_mutex_unlock(&instance->state_machine.lock); - ret = ps3_hard_recovery_request_with_retry(instance); + ret = ps3_hard_recovery_request_with_retry(instance, PS3_TRUE); if (ret != PS3_SUCCESS) { cur_state = ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u recovery request NOK, %s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), namePS3InstanceState(cur_state)); ret = FAILED; goto l_wait; } @@ -1187,71 +1285,76 @@ S32 ps3_reset_host(struct ps3_instance *instance) ret = ps3_instance_wait_for_hard_reset_flag_done(instance); if (ret == PS3_SUCCESS) { cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_INFO("hno:%u recovery success, %s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_INFO("hno:%u recovery success, %s!\n", PS3_HOST(instance), + namePS3InstanceState(cur_state)); ret = SUCCESS; goto l_wait; - } else if(ret == -PS3_RETRY){ + } else if (ret == -PS3_RETRY) { ps3_mutex_lock(&instance->state_machine.lock); - if (unlikely(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { - instance->recovery_context->recovery_state = PS3_HARD_RECOVERY_FINISH; + if (unlikely(instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { + instance->recovery_context->recovery_state = + PS3_HARD_RECOVERY_FINISH; } ps3_mutex_unlock(&instance->state_machine.lock); - ret = ps3_hard_recovery_request_with_retry(instance); + ret = ps3_hard_recovery_request_with_retry(instance, PS3_TRUE); if (ret != PS3_SUCCESS) { - cur_state = ps3_atomic_read(&instance->state_machine.state); + cur_state = + ps3_atomic_read(&instance->state_machine.state); LOG_ERROR("hno:%u recovery request NOK, %s!\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + PS3_HOST(instance), + namePS3InstanceState(cur_state)); ret = FAILED; goto l_wait; } ret = ps3_instance_wait_for_hard_reset_flag_done(instance); if (ret != PS3_SUCCESS) { - cur_state = ps3_atomic_read(&instance->state_machine.state); - LOG_ERROR("hno:%u recovery NOK, %s,host_reset_state:%d!\n", - PS3_HOST(instance),namePS3InstanceState(cur_state), + cur_state = + ps3_atomic_read(&instance->state_machine.state); + LOG_ERROR( + "hno:%u recovery NOK, %s,host_reset_state:%d!\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state), instance->recovery_context->host_reset_state); ret = FAILED; } else { ret = SUCCESS; } - }else { + } else { ret = FAILED; goto l_out; } l_wait: - while(atomic_read(&instance->cmd_statistics.io_outstanding) != 0) { + while (atomic_read(&instance->cmd_statistics.io_outstanding) != 0) ps3_msleep(3000); - } l_out: - if (!instance->state_machine.is_load && - !instance->is_suspend) { + if (!instance->state_machine.is_load && !instance->is_suspend) instance->state_machine.can_hostreset = PS3_FALSE; - } - INJECT_START(PS3_ERR_IJ_BLOCK_HOST_RESET, instance) + INJECT_START(PS3_ERR_IJ_BLOCK_HOST_RESET, instance); cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD && - instance->state_machine.can_hostreset) { - ps3_r1x_conflict_queue_clean_all(instance, - PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), PS3_TRUE); + instance->state_machine.can_hostreset) { + ps3_r1x_conflict_queue_clean_all( + instance, PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT), + PS3_TRUE); ps3_qos_waitq_clear_all(instance, PS3_STATUS_HOST_NOT_FOUND); } ps3_mutex_lock(&instance->state_machine.lock); instance->recovery_context->host_reset_state = PS3_HOST_RESET_INIT; ps3_mutex_unlock(&instance->state_machine.lock); ps3_atomic_dec(&instance->host_reset_processing); - LOG_WARN("hno:%u host reset hard recovery %d!\n", - PS3_HOST(instance), ret); + LOG_WARN("hno:%u host reset hard recovery %d!\n", PS3_HOST(instance), + ret); return ret; } -S32 ps3_err_reset_target(struct scsi_cmnd *scmd) +int ps3_err_reset_target(struct scsi_cmnd *scmd) { #ifndef _WINDOWS LOG_WARN("hno:%u enter target reset channel:%u id:%u\n", - PS3_HOST(scsi_host_data(scmd)), - PS3_SDEV_CHANNEL(scmd->device), PS3_SDEV_TARGET(scmd->device)); + PS3_HOST(scsi_host_data(scmd)), PS3_SDEV_CHANNEL(scmd->device), + PS3_SDEV_TARGET(scmd->device)); return ps3_device_reset_handler(scmd); #else @@ -1260,12 +1363,12 @@ S32 ps3_err_reset_target(struct scsi_cmnd *scmd) #endif } -S32 ps3_err_reset_host(struct scsi_cmnd *scmd) +int ps3_err_reset_host(struct scsi_cmnd *scmd) { - S32 ret = 0; + int ret = 0; #ifndef _WINDOWS struct ps3_instance *instance = - (struct ps3_instance*)scmd->device->host->hostdata; + (struct ps3_instance *)scmd->device->host->hostdata; #else struct ps3_instance *instance = scsi_host_data(scmd); #endif @@ -1274,29 +1377,31 @@ S32 ps3_err_reset_host(struct scsi_cmnd *scmd) return ret; } -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) +#if defined(PS3_RESET_TIMER) enum scsi_timeout_action ps3_err_reset_timer(struct scsi_cmnd *scmd) #else enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) #endif { struct ps3_instance *instance = NULL; - ULong flags = 0; + unsigned long flags = 0; instance = (struct ps3_instance *)scmd->device->host->hostdata; - if (time_after(jiffies, scmd->jiffies_at_alloc + - (SCMD_GET_REQUEST(scmd)->timeout * 2))) { - LOG_FILE_WARN("reset timer not handled [%u:%u:%u:%llu], tag:%d op:0x%x " - "timeout:%u alloc_time:%lu cur_time:%lu\n", + if (time_after(jiffies, + scmd->jiffies_at_alloc + + (SCMD_GET_REQUEST(scmd)->timeout * 2))) { + LOG_FILE_WARN( + "reset timer not handled [%u:%u:%u:%llu], tag:%d op:0x%x\n" + "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", PS3_HOST(instance), scmd->device->channel, - scmd->device->id, (U64)scmd->device->lun, SCMD_GET_REQUEST(scmd)->tag, + scmd->device->id, (unsigned long long)scmd->device->lun, + SCMD_GET_REQUEST(scmd)->tag, scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, - SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, jiffies); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,16,0) + SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, + jiffies); +#if defined(PS3_BLK_EH_NOT_HANDLED) return BLK_EH_NOT_HANDLED; -#elif ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) +#elif defined(PS3_RESET_TIMER) return SCSI_EH_NOT_HANDLED; #else return BLK_EH_DONE; @@ -1304,8 +1409,7 @@ enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) } if (instance->is_support_io_limit && - !instance->fault_context.ioc_busy) { - + !instance->fault_context.ioc_busy) { spin_lock_irqsave(instance->host->host_lock, flags); instance->host->can_queue = instance->cmd_attr.throttle_que_depth; @@ -1315,43 +1419,45 @@ enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd) spin_unlock_irqrestore(instance->host->host_lock, flags); } - LOG_FILE_WARN("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x " - "timeout:%u alloc_time:%lu cur_time:%lu\n", - PS3_HOST(instance), scmd->device->channel, - scmd->device->id, (U64)scmd->device->lun, SCMD_GET_REQUEST(scmd)->tag, - scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, - SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, jiffies); + LOG_FILE_WARN("reset timer [%u:%u:%u:%llu], tag:%d op:0x%x\n" + "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", + PS3_HOST(instance), scmd->device->channel, + scmd->device->id, (unsigned long long)scmd->device->lun, + SCMD_GET_REQUEST(scmd)->tag, + scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff, + SCMD_GET_REQUEST(scmd)->timeout, scmd->jiffies_at_alloc, + jiffies); -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ -(LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) +#if defined(PS3_RESET_TIMER) return SCSI_EH_RESET_TIMER; #else return BLK_EH_RESET_TIMER; #endif } static void ps3_scsi_sense_print(struct ps3_instance *instance, - const U8 *sense_buffer, U8 len, S32 CFID) + const unsigned char *sense_buffer, + unsigned char len, int CFID) { - ps3_scsi_sense_hdr_s sshdr; + struct ps3_scsi_sense_hdr sshdr; + memset(&sshdr, 0, sizeof(sshdr)); (void)instance; - if (sense_buffer == NULL || len == 0) { + if (sense_buffer == NULL || len == 0) goto l_out; - } sshdr.resp_code = (sense_buffer[0] & PS3_SENSE_RESP_CODE_MASK); if ((sshdr.resp_code & PS3_SENSE_RESP_CODE_VALID_MASK) != - PS3_SENSE_RESP_CODE_VALID_MASK) { - LOG_WARN_IN_IRQ(instance, - "CFID:%d sense rcode invalid:0x%x\n", CFID, - sshdr.resp_code); + PS3_SENSE_RESP_CODE_VALID_MASK) { + LOG_WARN_IN_IRQ(instance, "CFID:%d sense rcode invalid:0x%x\n", + CFID, sshdr.resp_code); goto l_out; } if (sshdr.resp_code >= PS3_SENSE_RESP_CODE_DESC_FORMAT) { if (len > 1) - sshdr.sense_key = (sense_buffer[1] & PS3_SENSE_KEY_MASK); + sshdr.sense_key = + (sense_buffer[1] & PS3_SENSE_KEY_MASK); if (len > 2) sshdr.asc = sense_buffer[2]; if (len > 3) @@ -1360,10 +1466,12 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, sshdr.additional_len = sense_buffer[7]; } else { if (len > 2) - sshdr.sense_key = (sense_buffer[2] & PS3_SENSE_KEY_MASK); + sshdr.sense_key = + (sense_buffer[2] & PS3_SENSE_KEY_MASK); if (len > 7) { - len = (len < (sense_buffer[7] + 8)) ? len : - (sense_buffer[7] + 8); + len = (len < (sense_buffer[7] + 8)) ? + len : + (sense_buffer[7] + 8); if (len > 12) sshdr.asc = sense_buffer[12]; if (len > 13) @@ -1371,7 +1479,8 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, } } - LOG_WARN_IN_IRQ(instance, + LOG_WARN_IN_IRQ( + instance, "sense: CFID:%d, rcode:0x%x, key:0x%x, asc:0x%x, ascq:0x%x\n", CFID, sshdr.resp_code, sshdr.sense_key, sshdr.asc, sshdr.ascq); l_out: @@ -1379,9 +1488,7 @@ static void ps3_scsi_sense_print(struct ps3_instance *instance, } void ps3_check_and_wait_host_reset(struct ps3_instance *instance) { - while(ps3_atomic_read(&instance->host_reset_processing) != 0){ + while (ps3_atomic_read(&instance->host_reset_processing) != 0) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } -return; } diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h index 918bc3e123c2..15a27ad64f49 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsi_cmd_err.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_SCSI_CMD_ERR_H_ #define _PS3_SCSI_CMD_ERR_H_ @@ -10,83 +10,90 @@ #include "ps3_htp_def.h" #include "ps3_instance_manager.h" +#include "ps3_kernel_version.h" -#define PS3_SCSI_HOST_SHIFT (16) -#define PS3_SCSI_DRIVER_SHIFT (24) +#define PS3_SCSI_HOST_SHIFT (16) +#define PS3_SCSI_DRIVER_SHIFT (24) -#define PS3_SAS_DATA_PRES_SHIFT (8) -#define PS3_SAS_DATA_PRES_MASK (0x3) -#define PS3_SAS_SENSE_LEN_OFFSET (16) -#define PS3_SAS_RESPDATA_LEN_OFFSET (20) -#define PS3_SAS_SENSE_RESPDATA_LEN_BYTE (4) -#define PS3_SAS_SCSI_STATUS_OFFSET (11) -#define PS3_SAS_RESP_CODE_BYTE (3) +#define PS3_SAS_DATA_PRES_SHIFT (8) +#define PS3_SAS_DATA_PRES_MASK (0x3) +#define PS3_SAS_SENSE_LEN_OFFSET (16) +#define PS3_SAS_RESPDATA_LEN_OFFSET (20) +#define PS3_SAS_SENSE_RESPDATA_LEN_BYTE (4) +#define PS3_SAS_SCSI_STATUS_OFFSET (11) +#define PS3_SAS_RESP_CODE_BYTE (3) -#define PS3_SCSI_STATUS_MASK (0xFF) +#define PS3_SCSI_STATUS_MASK (0xFF) #define PS3_SCSI_RESULT_HOST_STATUS(STATUS) ((STATUS) << PS3_SCSI_HOST_SHIFT) -#define PS3_SCSI_RESULT_DRIVER_STATUS(STATUS) ((STATUS) << PS3_SCSI_DRIVER_SHIFT) +#define PS3_SCSI_RESULT_DRIVER_STATUS(STATUS) \ + ((STATUS) << PS3_SCSI_DRIVER_SHIFT) -#define PS3_SENSE_RESP_CODE_VALID_MASK (0x70) -#define PS3_SENSE_RESP_CODE_DESC_FORMAT (0x72) -#define PS3_SENSE_RESP_CODE_MASK (0x7F) -#define PS3_SENSE_KEY_MASK (0xF) -#define PS3_ABORT_WAIT_CMD_FLIGHT_END 50 -#define PS3_NVME_RESP_STATUS_SQ_FULL (0x102) +#define PS3_SENSE_RESP_CODE_VALID_MASK (0x70) +#define PS3_SENSE_RESP_CODE_DESC_FORMAT (0x72) +#define PS3_SENSE_RESP_CODE_MASK (0x7F) +#define PS3_SENSE_KEY_MASK (0xF) +#define PS3_ABORT_WAIT_CMD_FLIGHT_END 50 +#define PS3_NVME_RESP_STATUS_SQ_FULL (0x102) enum ps3_sas_resp_code { - PS3_SAS_RESP_CODE_TASK_MGR_COMPLETE = 0x0, - PS3_SAS_RESP_CODE_INVALID_FRAME = 0x2, - PS3_SAS_RESP_CODE_TASK_MGR_NOT_SUPPORT = 0x4, - PS3_SAS_RESP_CODE_TASK_MGR_FAILED = 0x5, - PS3_SAS_RESP_CODE_TASK_MGR_SUCCESS = 0x8, - PS3_SAS_RESP_CODE_INCORRECT_LUN = 0x9, - PS3_SAS_RESP_CODE_OVERLAPPED_INIT_PORT = 0xa, + PS3_SAS_RESP_CODE_TASK_MGR_COMPLETE = 0x0, + PS3_SAS_RESP_CODE_INVALID_FRAME = 0x2, + PS3_SAS_RESP_CODE_TASK_MGR_NOT_SUPPORT = 0x4, + PS3_SAS_RESP_CODE_TASK_MGR_FAILED = 0x5, + PS3_SAS_RESP_CODE_TASK_MGR_SUCCESS = 0x8, + PS3_SAS_RESP_CODE_INCORRECT_LUN = 0x9, + PS3_SAS_RESP_CODE_OVERLAPPED_INIT_PORT = 0xa, }; enum ps3_sas_data_pres { - PS3_SAS_PRES_NO_DATA = 0x0, + PS3_SAS_PRES_NO_DATA = 0x0, PS3_SAS_PRES_REPSNSE_DATA = 0x1, - PS3_SAS_PRES_SENSE_DATA = 0x2, - PS3_SAS_PRES_RESERVED = 0x3, + PS3_SAS_PRES_SENSE_DATA = 0x2, + PS3_SAS_PRES_RESERVED = 0x3, +}; + +struct ps3_scsi_sense_hdr { + unsigned char resp_code; + unsigned char sense_key; + unsigned char asc; + unsigned char ascq; + unsigned char byte4; + unsigned char byte5; + unsigned char byte6; + unsigned char additional_len; }; -typedef struct ps3_scsi_sense_hdr { - U8 resp_code; - U8 sense_key; - U8 asc; - U8 ascq; - U8 byte4; - U8 byte5; - U8 byte6; - U8 additional_len; -} ps3_scsi_sense_hdr_s; - -S32 ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, - struct ps3_cmd *cmd); -S32 ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd); -S32 ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd); -S32 ps3_device_reset_handler(struct scsi_cmnd *scmd); -S32 ps3_err_reset_target(struct scsi_cmnd *scmd); -S32 ps3_err_reset_host(struct scsi_cmnd *scmd); -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 9) && (RHEL_MINOR >= 3)) || \ - (LINUX_VERSION_CODE >= KERNEL_VERSION(6,2,0))) +int ps3_err_scsi_cmd_fault_proc(struct ps3_instance *instance, + struct ps3_cmd *cmd); +int ps3_err_scsi_task_mgr_reset(struct scsi_cmnd *scmd); +int ps3_err_scsi_task_mgr_abort(struct scsi_cmnd *scmd); +int ps3_device_reset_handler(struct scsi_cmnd *scmd); +int ps3_err_reset_target(struct scsi_cmnd *scmd); +int ps3_err_reset_host(struct scsi_cmnd *scmd); +#if defined(PS3_RESET_TIMER) enum scsi_timeout_action ps3_err_reset_timer(struct scsi_cmnd *scmd); #else enum blk_eh_timer_return ps3_err_reset_timer(struct scsi_cmnd *scmd); #endif -Bool ps3_err_is_resp_from_direct_cmd(U16 mode); +unsigned char ps3_err_is_resp_from_direct_cmd(unsigned short mode); void ps3_errcode_to_scsi_status(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, U32 err_code, - PS3RespFrame_u *resp_frame, U32 xfer_cnt, struct ps3_cmd *cmd); + struct scsi_cmnd *s_cmd, unsigned int err_code, + union PS3RespFrame *resp_frame, + unsigned int xfer_cnt, struct ps3_cmd *cmd); + +int ps3_err_scsi_io_processing(struct ps3_instance *instance, unsigned int id, + unsigned int channel); -S32 ps3_err_scsi_io_processing(struct ps3_instance *instance, - U32 id, U32 channel); +unsigned char ps3_host_reset_state_check(struct ps3_instance *instance, + unsigned char is_host_reset); -S32 ps3_reset_host(struct ps3_instance *instance); +int ps3_reset_host(struct ps3_instance *instance); -void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, U8 resp_status, Bool cmd_lock); -void ps3_check_and_wait_host_reset(struct ps3_instance *instance); +void ps3_scsih_drv_io_reply_scsi(struct scsi_cmnd *s_cmd, struct ps3_cmd *cmd, + unsigned char resp_status, + unsigned char cmd_lock); +void ps3_check_and_wait_host_reset(struct ps3_instance *instance); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih.c index 041cb5a35759..e2a1ed933de5 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include "ps3_scsih.h" #ifndef _WINDOWS @@ -12,7 +13,6 @@ #endif #include "ps3_htp.h" -#include "ps3_meta.h" #include "ps3_err_def.h" #include "ps3_instance_manager.h" #include "ps3_cmd_channel.h" @@ -27,57 +27,89 @@ #include "ps3_io_trace.h" #include "ps3_htp_sas.h" -static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd); -static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, - U16 disk_id, U64 data_addr, U32 sge_count); -static S32 ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd); -static S32 ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd); -static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd); -static inline U16 ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd); -static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, - U8 channel, U16 id, struct scsi_cmnd *s_cmd); -static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, - PS3FrontEndReqFrame_s *req); +static int ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd); +static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, + unsigned short disk_id, + unsigned long long data_addr, + unsigned int sge_count); +static int ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd); +static int ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd); +static int ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd); +static inline unsigned short +ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd); +static int ps3_vd_access_policy_check(struct ps3_instance *instance, + unsigned char channel, unsigned short id, + struct scsi_cmnd *s_cmd); +static unsigned short +ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, + struct PS3FrontEndReqFrame *req); static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, - U8 req_frame_format); -static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, U8 log_level); -static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd); + unsigned char req_frame_format); +static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, + unsigned char log_level); +static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd); #ifdef _WINDOWS static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd); -static S32 ps3_scsi_remap_sgl(struct ps3_cmd *cmd); +static int ps3_scsi_remap_sgl(struct ps3_cmd *cmd); #endif -#define PS3_CMD_WORD_QUE_CALC(vd_id, lba, map_block, que_num) \ - (((vd_id) + ((lba) / (map_block))) & que_num) +#define PS3_CMD_WORD_QUE_CALC(vd_id, lba, map_block, que_num) \ + (((vd_id) + (PS3_DIV64_32((lba), (map_block)))) & que_num) -#define PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, map_block, num_blocks) \ - (((map_block) - ((lba) % (map_block))) < (num_blocks)) -#define PS3_LBA(lba_hi, lba_lo) \ - ((((U64)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) +#define PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, map_block, num_blocks) \ + (((map_block) - (PS3_MOD64((lba), (map_block)))) < (num_blocks)) +#define PS3_LBA(lba_hi, lba_lo) \ + ((((unsigned long long)(lba_hi)) << PS3_SHIFT_DWORD) | (lba_lo)) #ifndef _WINDOWS #define sg_dma_address_u64(sg) sg_dma_address(sg) + +#ifdef PS3_NCQ_PRIO_SUPPORT +#define PS3_IS_NCQ_PRIO_DISK_ENABLE(cmd) \ + ((cmd)->io_attr.is_ncq_prio_enable) +#endif #endif -#define UNMAP_PARAM_LEN (8) -#define UNMAP_DESCRIPTOR_LEN (16) -#define UNMAP_CDB_VALID_LEN (10) +#define UNMAP_PARAM_LEN (8) +#define UNMAP_DESCRIPTOR_LEN (16) +#define UNMAP_CDB_VALID_LEN (10) static struct disk_type_to_proc_func_table g_req_frame_func_table[] = { - {PS3_DEV_TYPE_VD, ps3_scsih_vd_req_frame_build}, - {PS3_DEV_TYPE_SAS_HDD, ps3_scsih_sas_req_frame_build}, - {PS3_DEV_TYPE_SATA_HDD, ps3_scsih_sata_req_frame_build}, - {PS3_DEV_TYPE_SATA_SSD, ps3_scsih_sata_req_frame_build}, - {PS3_DEV_TYPE_SAS_SSD, ps3_scsih_sas_req_frame_build}, - {PS3_DEV_TYPE_NVME_SSD, ps3_scsih_nvme_req_frame_build}, - {PS3_DEV_TYPE_SES, ps3_scsih_sas_req_frame_build}, - {PS3_DEV_TYPE_VEP, ps3_scsih_sas_req_frame_build} + { PS3_DEV_TYPE_VD, ps3_scsih_vd_req_frame_build }, + { PS3_DEV_TYPE_SAS_HDD, ps3_scsih_sas_req_frame_build }, + { PS3_DEV_TYPE_SATA_HDD, ps3_scsih_sata_req_frame_build }, + { PS3_DEV_TYPE_SATA_SSD, ps3_scsih_sata_req_frame_build }, + { PS3_DEV_TYPE_SAS_SSD, ps3_scsih_sas_req_frame_build }, + { PS3_DEV_TYPE_NVME_SSD, ps3_scsih_nvme_req_frame_build }, + { PS3_DEV_TYPE_SES, ps3_scsih_sas_req_frame_build }, + { PS3_DEV_TYPE_VEP, ps3_scsih_sas_req_frame_build } }; #ifndef _WINDOWS -Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) +#ifdef PS3_NCQ_PRIO_SUPPORT +static inline u8 ps3_scsih_is_io_belongs_to_rt_class(struct ps3_cmd *cmd) +{ + struct request *rq = SCMD_GET_REQUEST(cmd->scmd); + return (IOPRIO_PRIO_CLASS(req_get_ioprio(rq)) == IOPRIO_CLASS_RT); +} +#endif + +static inline unsigned char ps3_scsih_stream_detect_enable(struct ps3_cmd *cmd, + unsigned int type) +{ + unsigned char detect = PS3_FALSE; + const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; + if ((type == PS3_SCSI_CMD_TYPE_READ && vd_entry->isReadNeedSeq) || + (type == PS3_SCSI_CMD_TYPE_WRITE && vd_entry->isWriteNeedSeq)) { + detect = PS3_TRUE; + } + + return detect; +} + +unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) { struct ps3_scsi_priv_data *data = (struct ps3_scsi_priv_data *)cmd->scmd->device->hostdata; @@ -91,20 +123,18 @@ Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) struct ps3_stream_detect *current_sd; u64 lba = 0; u32 len = 0; - Bool is_stream = PS3_FALSE; - U32 typeIndex; - u32 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cmd->scmd->cmnd)); - ULong flag = 0; - S64 value = 0; + unsigned char is_stream = PS3_FALSE; + unsigned int typeIndex; + u32 type = + PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cmd->scmd->cmnd)); + unsigned long flag = 0; + long long value = 0; - if (PS3_IF_QUIT_STREAM_DIRECT_DETECT()) { + if (PS3_IF_QUIT_STREAM_DIRECT_DETECT()) goto l_out; - } - - if((type != PS3_SCSI_CMD_TYPE_READ) && (type != PS3_SCSI_CMD_TYPE_WRITE)){ + if (!ps3_scsih_stream_detect_enable(cmd, type)) goto l_out; - } typeIndex = type - PS3_SCSI_CMD_TYPE_READ; current_ld_sd = &(data->vd_sd[typeIndex]); @@ -115,49 +145,59 @@ Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) ps3_scsih_len_parse(cmd->scmd->cmnd, &len); for (index = 0; index < PS3_IO_MAX_STREAMS_TRACKED; ++index) { stream_num = (*track_stream >> - (index << BITS_PER_INDEX_STREAM_SHIFT)) & - STREAM_MASK; + (index << BITS_PER_INDEX_STREAM_SHIFT)) & + STREAM_MASK; current_sd = ¤t_ld_sd->stream_track[stream_num]; value = current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE; if ((((value >= 0) && - (lba >= current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE) && - (lba <= (current_sd->next_seq_lba + IO_STREAM_DETECT_RANGE * 2))) || - ((current_sd->next_seq_lba) && - (lba >= current_sd->next_seq_lba) && - (lba <= (current_sd->next_seq_lba + 32))))&& - (type == current_sd->rw_type)){ + (lba >= + current_sd->next_seq_lba - IO_STREAM_DETECT_RANGE) && + (lba <= (current_sd->next_seq_lba + + IO_STREAM_DETECT_RANGE * 2))) || + ((current_sd->next_seq_lba) && + (lba >= current_sd->next_seq_lba) && + (lba <= (current_sd->next_seq_lba + 32)))) && + (type == current_sd->rw_type)) { is_stream = PS3_TRUE; - cmd->io_attr.seq_flag = SCSI_RW_SEQ_CMD; - cmd->req_frame->frontendReq.reqHead.isStream1 = PS3_TRUE; - current_sd->next_seq_lba = - lba + len; + cmd->req_frame->frontendReq.reqHead.isStream1 = + PS3_TRUE; + current_sd->next_seq_lba = lba + len; shifted_values_mask = - (1ULL << (index << BITS_PER_INDEX_STREAM_SHIFT)) - 1; + (1ULL + << (index << BITS_PER_INDEX_STREAM_SHIFT)) - + 1; shifted_values = ((*track_stream & shifted_values_mask) - << BITS_PER_INDEX_STREAM); + << BITS_PER_INDEX_STREAM); index_value_mask = - STREAM_MASK << (index << BITS_PER_INDEX_STREAM_SHIFT); + STREAM_MASK + << (index << BITS_PER_INDEX_STREAM_SHIFT); unshifted_values = - *track_stream & ~(shifted_values_mask | - index_value_mask); + *track_stream & + ~(shifted_values_mask | index_value_mask); *track_stream = unshifted_values | shifted_values | stream_num; goto end; } } - stream_num = (*track_stream >> ((PS3_IO_MAX_STREAMS_TRACKED - 1) << - BITS_PER_INDEX_STREAM_SHIFT)) & STREAM_MASK; + stream_num = (*track_stream >> ((PS3_IO_MAX_STREAMS_TRACKED - 1) + << BITS_PER_INDEX_STREAM_SHIFT)) & + STREAM_MASK; current_sd = ¤t_ld_sd->stream_track[stream_num]; current_sd->rw_type = type; current_sd->next_seq_lba = lba + len; - *track_stream = (((*track_stream & ZERO_LAST_STREAM) << 4) | stream_num); - cmd->io_attr.seq_flag = SCSI_RW_RANDOM_CMD; - + *track_stream = + (((*track_stream & ZERO_LAST_STREAM) << 4) | stream_num); end: - ps3_spin_unlock_irqrestore(¤t_ld_sd->ps3_sequence_stream_lock, flag); + ps3_spin_unlock_irqrestore(¤t_ld_sd->ps3_sequence_stream_lock, + flag); l_out: + if (is_stream) + cmd->io_attr.seq_flag = SCSI_RW_SEQ_CMD; + else + cmd->io_attr.seq_flag = SCSI_RW_RANDOM_CMD; + INJECT_START(PS3_ERR_IJ_FORCE_SEQ_CMD, cmd); INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_TRUE, &is_stream); @@ -165,16 +205,19 @@ Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) INJECT_START(PS3_ERR_IJ_FORCE_STREAM_DETECT_FALSE, &is_stream); return is_stream; } -Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) +unsigned char ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) { - struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); - Bool is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = + scsi_device_private_data(cmd->scmd); + unsigned char is_direct = PS3_TRUE; if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.vd_entry->isNvme || !(cmd->io_attr.vd_entry->isSsd && - (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING) && - (cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K))) { + if (cmd->io_attr.vd_entry->isNvme || + !(cmd->io_attr.vd_entry->isSsd && + (ps3_atomic_read(&p_priv_data->rd_io_outstand) > + PS3_VD_IO_16_OUTSTANDING) && + (cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K))) { is_direct = PS3_FALSE; } } @@ -182,15 +225,18 @@ Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd) return is_direct; } -Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) + +unsigned char ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) { - Bool is_direct = PS3_TRUE; - struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); + unsigned char is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = + scsi_device_private_data(cmd->scmd); if (p_priv_data->dev_type == PS3_DEV_TYPE_VD && - cmd->io_attr.vd_entry->isNvme && - ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (ps3_atomic_read(&p_priv_data->rd_io_outstand) > PS3_VD_IO_16_OUTSTANDING && - cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K) { + cmd->io_attr.vd_entry->isNvme && + ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + if (ps3_atomic_read(&p_priv_data->rd_io_outstand) > + PS3_VD_IO_16_OUTSTANDING && + cmd->io_attr.num_blocks > PS3_BLOCK_NUM_OF_32K) { is_direct = PS3_FALSE; } } @@ -198,44 +244,50 @@ Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd) return is_direct; } -static Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, S32 *scsi_result) +static unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, + int *scsi_result) { - Bool ret = PS3_TRUE; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + unsigned char ret = PS3_TRUE; + int cur_state = PS3_INSTANCE_STATE_INIT; *scsi_result = PS3_SUCCESS; if (!instance->state_machine.is_load) { - LOG_INFO_LIM("hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state not is_load\n", + PS3_HOST(instance)); goto l_scsi_done; } PS3_IO_START_INC(instance, s_cmd); cur_state = atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { + cur_state == PS3_INSTANCE_STATE_QUIT) { PS3_IO_BACK_ERR_INC(instance, s_cmd); - LOG_INFO_LIM("hno:%u instance state is dead/quit\n", PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u instance state is dead/quit\n", + PS3_HOST(instance)); goto l_scsi_done; } - if (instance->recovery_context->host_reset_state != PS3_HOST_RESET_INIT) { + if (instance->recovery_context->host_reset_state != + PS3_HOST_RESET_INIT) { *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); - LOG_WARN_LIM("hno:%u host_Reset_state:%d\n", PS3_HOST(instance),instance->recovery_context->host_reset_state); + LOG_WARN_LIM("hno:%u host_Reset_state:%d\n", PS3_HOST(instance), + instance->recovery_context->host_reset_state); goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); - LOG_INFO_LIM("hno:%u cannot request scsi cmd tag:%d due to %s\n", + LOG_INFO_LIM( + "hno:%u cannot request scsi cmd tag:%d due to %s\n", PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, namePS3InstanceState(cur_state)); goto l_out; @@ -245,7 +297,7 @@ static Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, l_scsi_done: PS3_DEV_BUSY_DEC(s_cmd); - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); SCMD_IO_DONE(s_cmd); *scsi_result = PS3_SUCCESS; ret = PS3_FALSE; @@ -254,17 +306,20 @@ static Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, return ret; } -static inline Bool ps3_scsih_is_illegel_vd_io(const struct scsi_cmnd *s_cmd, - struct ps3_instance *instance) +static inline unsigned char +ps3_scsih_is_illegel_vd_io(const struct scsi_cmnd *s_cmd, + struct ps3_instance *instance) { - return(!ps3_dev_id_valid_check(instance, s_cmd->device->channel, - s_cmd->device->id, PS3_DISK_TYPE_VD) || s_cmd->device->lun); + return (!ps3_dev_id_valid_check(instance, s_cmd->device->channel, + s_cmd->device->id, PS3_DISK_TYPE_VD) || + s_cmd->device->lun); } -static Bool ps3_scsih_device_attr_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, S32 *scsi_result) +static unsigned char ps3_scsih_device_attr_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, + int *scsi_result) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; struct ps3_scsi_priv_data *data = NULL; static unsigned long j; *scsi_result = PS3_SUCCESS; @@ -273,14 +328,17 @@ static Bool ps3_scsih_device_attr_check(struct ps3_instance *instance, PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_DEVICE_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM("hno:%u task_manager_host_busy\n", PS3_HOST(instance)); + LOG_INFO_LIM("hno:%u task_manager_host_busy\n", + PS3_HOST(instance)); goto l_out; } - data = (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; + data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; if (unlikely(data == NULL)) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u device_priv_data is null s_cmd result:%d\n", + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u device_priv_data is null s_cmd result:%d\n", PS3_HOST(instance), s_cmd->result); goto l_scsi_done; } @@ -296,30 +354,26 @@ static Bool ps3_scsih_device_attr_check(struct ps3_instance *instance, if (data->dev_type == PS3_DEV_TYPE_VD) { if (unlikely(ps3_scsih_is_illegel_vd_io(s_cmd, instance))) { - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u dev_type:%s id:%u " - "max_vd_count:%u vd id NOK\n", PS3_HOST(instance), + s_cmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u dev_type:%s id:%u max_vd_count:%u vd id NOK\n", + PS3_HOST(instance), namePS3DevType((enum PS3DevType)data->dev_type), - s_cmd->device->id, instance->ctrl_info.maxVdCount); + s_cmd->device->id, + instance->ctrl_info.maxVdCount); goto l_scsi_done; } - if (unlikely(ps3_vd_access_policy_check(instance, s_cmd->device->channel, - s_cmd->device->id, s_cmd) != PS3_SUCCESS)) { + if (unlikely(ps3_vd_access_policy_check( + instance, s_cmd->device->channel, + s_cmd->device->id, + s_cmd) != PS3_SUCCESS)) { goto l_scsi_done; } } -#if 0 - if ((s_cmd->cmnd[0] == SYNCHRONIZE_CACHE) && is_vd_io && - !instance->is_support_sync_cache) { - s_cmd->result = DID_OK << PS3_SHIFT_WORD; - LOG_ERROR("hno:%u SYNCHRONIZE_CACHE cmd, return\n", - PS3_HOST(instance)); - goto l_out; - } -#endif - goto l_out; l_scsi_done: @@ -332,58 +386,65 @@ static Bool ps3_scsih_device_attr_check(struct ps3_instance *instance, return ret; } -static inline U8 ps3_scsih_dev_type_get(const struct scsi_cmnd *s_cmd) +static inline unsigned char +ps3_scsih_dev_type_get(const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = - (struct ps3_scsi_priv_data*)s_cmd->device->hostdata; + (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; return data->dev_type; } -static inline Bool ps3_scsih_is_vd_scsi_rw_cmd(const struct scsi_cmnd *s_cmd) +static inline unsigned char +ps3_scsih_is_vd_scsi_rw_cmd(const struct scsi_cmnd *s_cmd) { return (ps3_scsih_dev_type_get(s_cmd) == PS3_DEV_TYPE_VD) ? - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd) : PS3_DRV_FALSE; + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd) : + PS3_DRV_FALSE; } -static Bool ps3_scsih_qos_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, S32 *scsi_result) +static unsigned char ps3_scsih_qos_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, + int *scsi_result) { - Bool ret = PS3_DRV_TRUE; - S32 vd_io_threshold = instance->cmd_attr.vd_io_threshold; - S32 io_outstand = 0; - S32 vd_io_outstand = 0; + unsigned char ret = PS3_DRV_TRUE; + int vd_io_threshold = instance->cmd_attr.vd_io_threshold; + int io_outstand = 0; + int vd_io_outstand = 0; - if (unlikely(!ps3_stat_outstand_switch_is_open(instance))) { + if (unlikely(!ps3_stat_outstand_switch_is_open(instance))) goto l_out; - } - io_outstand = atomic_inc_return(&instance->cmd_statistics.io_outstanding); + io_outstand = + atomic_inc_return(&instance->cmd_statistics.io_outstanding); if (unlikely(io_outstand > instance->host->can_queue)) { PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_HOST_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM("hno:%u ioc io exceed can_queue:%d io_outstanding:%d\n", - PS3_HOST(instance), instance->host->can_queue, io_outstand); + LOG_INFO_LIM( + "hno:%u ioc io exceed can_queue:%d io_outstanding:%d\n", + PS3_HOST(instance), instance->host->can_queue, + io_outstand); goto l_dec_io_outstand; } if (unlikely(vd_io_threshold && ps3_scsih_is_vd_scsi_rw_cmd(s_cmd))) { - vd_io_outstand = atomic_inc_return(&instance->cmd_statistics.vd_io_outstanding); + vd_io_outstand = atomic_inc_return( + &instance->cmd_statistics.vd_io_outstanding); if (unlikely(vd_io_outstand > vd_io_threshold)) { PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); *scsi_result = SCSI_MLQUEUE_DEVICE_BUSY; ret = PS3_FALSE; - LOG_INFO_LIM("hno:%u vd io exceed vd_io_threshold:%d vd_outstanding:%d\n", - PS3_HOST(instance), vd_io_threshold, vd_io_outstand); + LOG_INFO_LIM( + "hno:%u vd io exceed vd_io_threshold:%d vd_outstanding:%d\n", + PS3_HOST(instance), vd_io_threshold, + vd_io_outstand); goto l_dec_vd_io_outstand; } } - PS3_VD_OUTSTAND_INC(instance, s_cmd); - goto l_out; l_dec_vd_io_outstand: @@ -394,21 +455,20 @@ static Bool ps3_scsih_qos_check(struct ps3_instance *instance, return ret; } -static Bool ps3_scsih_que_cmd_check(struct ps3_instance *instance, - struct scsi_cmnd *s_cmd, S32 *scsi_result) +static unsigned char ps3_scsih_que_cmd_check(struct ps3_instance *instance, + struct scsi_cmnd *s_cmd, + int *scsi_result) { - Bool ret = PS3_TRUE; + unsigned char ret = PS3_TRUE; s_cmd->result = DID_OK; ret = ps3_scsih_sys_state_check(instance, s_cmd, scsi_result); - if (unlikely(!ret)) { + if (unlikely(!ret)) goto l_out; - } ret = ps3_scsih_device_attr_check(instance, s_cmd, scsi_result); - if (unlikely(!ret)) { + if (unlikely(!ret)) goto l_out; - } ret = ps3_scsih_qos_check(instance, s_cmd, scsi_result); @@ -417,32 +477,40 @@ static Bool ps3_scsih_que_cmd_check(struct ps3_instance *instance, } #else -Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, S32 *host_status) +unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, + int *host_status) { - Bool ret = PS3_DRV_TRUE; - S32 cur_state = PS3_INSTANCE_STATE_INIT; + unsigned char ret = PS3_DRV_TRUE; + int cur_state = PS3_INSTANCE_STATE_INIT; static unsigned long j; + if (!instance->state_machine.is_load) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u instance state not is_load\n", PS3_HOST(instance)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u instance state not is_load\n", + PS3_HOST(instance)); *host_status = DID_ERROR; goto l_out; } cur_state = ps3_atomic_read(&instance->state_machine.state); if (cur_state == PS3_INSTANCE_STATE_DEAD || - cur_state == PS3_INSTANCE_STATE_QUIT) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u instance state is dead/quit\n", PS3_HOST(instance)); + cur_state == PS3_INSTANCE_STATE_QUIT) { + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u instance state is dead/quit\n", + PS3_HOST(instance)); *host_status = DID_BAD_TARGET; goto l_out; } if (cur_state != PS3_INSTANCE_STATE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && - cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { + cur_state != PS3_INSTANCE_STATE_PRE_OPERATIONAL && + cur_state != PS3_INSTANCE_STATE_SOFT_RECOVERY) { ret = PS3_DRV_FALSE; *host_status = DID_BUS_BUSY; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u cannot request scsi cmd due to %s\n", - PS3_HOST(instance), namePS3InstanceState(cur_state)); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u cannot request scsi cmd due to %s\n", + PS3_HOST(instance), + namePS3InstanceState(cur_state)); goto l_out; } @@ -450,30 +518,23 @@ Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, S32 *host_status) return ret; } -Bool ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) +unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd) { (void)cmd; return PS3_FALSE; } #endif -#if 0 -static Bool ps3_synchronize_cache_filter(struct scsi_cmnd *s_cmd) -{ - (void)s_cmd; - return PS3_DRV_FALSE; -} -#endif - #ifndef _WINDOWS -S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, - struct scsi_cmnd *s_cmd) +int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_cmd *cmd = NULL; struct ps3_instance *instance = NULL; - struct ps3_scsi_priv_data *data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; + struct ps3_scsi_priv_data *data = + (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; static unsigned long j; + instance = (struct ps3_instance *)s_host->hostdata; if (unlikely(instance == NULL)) { s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); @@ -481,19 +542,19 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, goto l_scsi_done; } - LOG_DEBUG("hno:%u tag:%d op:0x%x cmd_len:%d chl:%u " - "id:%u timeout:%u\n", s_host->host_no, SCMD_GET_REQUEST(s_cmd)->tag, - s_cmd->cmnd[0], s_cmd->cmd_len, s_cmd->device->channel, - s_cmd->device->id, SCMD_GET_REQUEST(s_cmd)->timeout); + LOG_DEBUG("hno:%u tag:%d op:0x%x cmd_len:%d chl:%u id:%u timeout:%u\n", + s_host->host_no, SCMD_GET_REQUEST(s_cmd)->tag, s_cmd->cmnd[0], + s_cmd->cmd_len, s_cmd->device->channel, s_cmd->device->id, + SCMD_GET_REQUEST(s_cmd)->timeout); PS3_DEV_BUSY_INC(s_cmd); - if (unlikely(!ps3_scsih_que_cmd_check(instance, s_cmd, &ret))) { + if (unlikely(!ps3_scsih_que_cmd_check(instance, s_cmd, &ret))) goto l_out; - } INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_DELIVER_CNT, instance); if (unlikely(s_cmd->cmd_len > PS3_FRAME_CDB_BUFLEN)) { - LOG_ERROR("hno:%u cmd len %u check NOK\n", PS3_HOST(instance), s_cmd->cmd_len); + LOG_ERROR("hno:%u cmd len %u check NOK\n", PS3_HOST(instance), + s_cmd->cmd_len); PS3_BUG(); s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_ERROR); goto l_scsi_done; @@ -508,11 +569,12 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, cmd = ps3_scsi_cmd_alloc(instance, SCMD_GET_REQUEST(s_cmd)->tag); if (unlikely(cmd == NULL)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", - PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u tag:%d ps3_cmd_get NOK ret:%d\n", + PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag, ret); PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_IO_OUTSTAND_DEC(instance, s_cmd); - PS3_VD_OUTSTAND_DEC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); ret = SCSI_MLQUEUE_HOST_BUSY; ps3_scsi_cmd_deliver_put(instance); @@ -521,58 +583,63 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, INJECT_START(PS3_ERR_IJ_CMD_BLOCK_BEFORE_SEND_TO_IOC, instance); if (cmd->scmd != NULL) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u cmd is exist\n", - PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u CFID:%u cmd is exist\n", + PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag); PS3_BUG(); s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); goto l_cmd_stat_dec; } cmd->scmd = s_cmd; - + PS3_VD_OUTSTAND_INC(instance, cmd); ret = instance->ioc_adpter->io_cmd_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { switch (ret) { - case -PS3_IO_CONFLICT: - ps3_errcode_to_scsi_status(instance, s_cmd, SCSI_STATUS_BUSY, NULL, 0, cmd); - ret = SCSI_MLQUEUE_DEVICE_BUSY; - goto l_cmd_release; - break; - case -PS3_IO_REQUEUE: - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); - break; - case -PS3_IO_CONFLICT_IN_Q: - LOG_DEBUG("tid:0x%llx hno:%u tag:%d conflict in queue, " - "timeout:%u alloc_time:%lu cur_time:%lu\n", - cmd->trace_id, PS3_HOST(instance), - SCMD_GET_REQUEST(s_cmd)->tag, - SCMD_GET_REQUEST(s_cmd)->timeout, - s_cmd->jiffies_at_alloc, jiffies); - ret = PS3_SUCCESS; - cmd->flighting = PS3_FALSE; - wmb(); - ps3_scsi_cmd_deliver_put(instance); - goto l_out; - break; - case -PS3_IN_QOS_Q: - ret = PS3_SUCCESS; - cmd->flighting = PS3_FALSE; - wmb(); - ps3_scsi_cmd_deliver_put(instance); - goto l_out; - case -PS3_RETRY: - ret = SCSI_MLQUEUE_DEVICE_BUSY; - goto l_cmd_release; - case -PS3_RECOVERED: - case SCSI_MLQUEUE_HOST_BUSY: - ret = SCSI_MLQUEUE_HOST_BUSY; - goto l_cmd_release; - default: - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); - break; + case -PS3_IO_CONFLICT: + ps3_errcode_to_scsi_status(instance, s_cmd, + SCSI_STATUS_BUSY, NULL, 0, + cmd); + ret = SCSI_MLQUEUE_DEVICE_BUSY; + goto l_cmd_release; + case -PS3_IO_REQUEUE: + s_cmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); + break; + case -PS3_IO_CONFLICT_IN_Q: + LOG_DEBUG("tid:0x%llx hno:%u tag:%d conflict in queue,\n" + "\ttimeout:%u alloc_time:%lu cur_time:%lu\n", + cmd->trace_id, PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag, + SCMD_GET_REQUEST(s_cmd)->timeout, + s_cmd->jiffies_at_alloc, jiffies); + ret = PS3_SUCCESS; + cmd->flighting = PS3_FALSE; + wmb(); /* in order to force CPU ordering */ + ps3_scsi_cmd_deliver_put(instance); + goto l_out; + case -PS3_IN_QOS_Q: + ret = PS3_SUCCESS; + cmd->flighting = PS3_FALSE; + wmb(); /* in order to force CPU ordering */ + ps3_scsi_cmd_deliver_put(instance); + goto l_out; + case -PS3_RETRY: + ret = SCSI_MLQUEUE_DEVICE_BUSY; + goto l_cmd_release; + case -PS3_RECOVERED: + case SCSI_MLQUEUE_HOST_BUSY: + ret = SCSI_MLQUEUE_HOST_BUSY; + goto l_cmd_release; + default: + s_cmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + break; } LOG_DEBUG("tid:0x%llx hno:%u tag:%d cmd build err ret:%d\n", - cmd->trace_id, PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); + cmd->trace_id, PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag, ret); ret = PS3_SUCCESS; goto l_cmd_release; } @@ -580,18 +647,20 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, INJECT_START(PS3_ERR_IJ_CMD_SEND_WAIT_RECOVERY_END, instance); ret = ps3_scsi_cmd_send(instance, cmd, PS3_TRUE); if (unlikely(ret != PS3_SUCCESS)) { - ps3_qos_cmd_update(instance, cmd); + ps3_qos_cmd_update(instance, cmd, PS3_FALSE); if (ret == -PS3_RECOVERED) { ret = SCSI_MLQUEUE_HOST_BUSY; } else if (ret == -PS3_RETRY) { ret = SCSI_MLQUEUE_DEVICE_BUSY; } else { - s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); + s_cmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_NO_CONNECT); ret = PS3_SUCCESS; } LOG_ERROR_LIM("tid:0x%llx hno:%u tag:%d cmd send NOK ret:%d\n", - cmd->trace_id, PS3_HOST(instance), SCMD_GET_REQUEST(s_cmd)->tag, ret); - PS3_DEV_IO_START_ERR_INC(instance, cmd); + cmd->trace_id, PS3_HOST(instance), + SCMD_GET_REQUEST(s_cmd)->tag, ret); + PS3_DEV_IO_START_ERR_INC(instance, cmd); goto l_cmd_release; } @@ -599,6 +668,7 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, goto l_out; l_cmd_release: + PS3_VD_OUTSTAND_DEC(instance, cmd); ps3_scsi_dma_unmap(cmd); if (cmd->is_got_r1x == 1) { data = (struct ps3_scsi_priv_data *)s_cmd->device->hostdata; @@ -609,34 +679,32 @@ S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, l_cmd_stat_dec: PS3_IO_BACK_ERR_INC(instance, s_cmd); PS3_IO_OUTSTAND_DEC(instance, s_cmd); - PS3_VD_OUTSTAND_DEC(instance, s_cmd); PS3_DEV_BUSY_DEC(s_cmd); ps3_scsi_cmd_deliver_put(instance); l_scsi_done: - if (ret != SCSI_MLQUEUE_HOST_BUSY && ret != SCSI_MLQUEUE_DEVICE_BUSY) { + if (ret != SCSI_MLQUEUE_HOST_BUSY && ret != SCSI_MLQUEUE_DEVICE_BUSY) SCMD_IO_DONE(s_cmd); - } l_out: return ret; } #endif -static inline Bool ps3_is_need_build_hw_req_frame(const struct ps3_cmd *cmd) +static inline unsigned char +ps3_is_need_build_hw_req_frame(const struct ps3_cmd *cmd) { return ps3_scsih_is_use_hard_cmd(cmd) == PS3_CMDWORD_FORMAT_HARDWARE; } -Bool ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) +unsigned char ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; - switch(cmd->io_attr.vd_entry->raidLevel) { + switch (cmd->io_attr.vd_entry->raidLevel) { case RAID1: case RAID10: case RAID1E: - if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { + if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) ret = PS3_TRUE; - } break; default: ret = PS3_FALSE; @@ -646,11 +714,11 @@ Bool ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd) return ret; } -static Bool direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) +static unsigned char direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) { - Bool ret = PS3_DRV_TRUE; + unsigned char ret = PS3_DRV_TRUE; - switch(cmd->io_attr.vd_entry->raidLevel) { + switch (cmd->io_attr.vd_entry->raidLevel) { case RAID0: case RAID00: break; @@ -659,7 +727,7 @@ static Bool direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) case RAID1E: if (cmd->instance->cmd_context.max_r1x_cmd_count > 0) { if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ || - cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { + cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { ret = PS3_TRUE; } else { ret = PS3_FALSE; @@ -672,9 +740,8 @@ static Bool direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) case RAID6: case RAID50: case RAID60: - if (cmd->io_attr.rw_flag != PS3_SCSI_CMD_TYPE_READ) { + if (cmd->io_attr.rw_flag != PS3_SCSI_CMD_TYPE_READ) ret = PS3_FALSE; - } break; default: ret = PS3_FALSE; @@ -684,48 +751,52 @@ static Bool direct_cmd_is_raidlevel_support(struct ps3_cmd *cmd) return ret; } -static Bool direct_cmd_is_plba_sector_aligned(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd) +static unsigned char +direct_cmd_is_plba_sector_aligned(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd) { const struct PS3VDEntry *vd = cmd->io_attr.vd_entry; - Bool ret = PS3_DRV_FALSE; + unsigned char ret = PS3_DRV_FALSE; if (unlikely(pd->sector_size == 0)) { LOG_FILE_ERROR("pd chl:%u id:%u sector_size is 0\n", - PS3_CHANNEL(&pd->disk_pos), - PS3_TARGET(&pd->disk_pos)); + PS3_CHANNEL(&pd->disk_pos), + PS3_TARGET(&pd->disk_pos)); goto l_out; } #ifndef _WINDOWS - if ((cmd->io_attr.plba << ilog2(vd->sectorSize)) % pd->sector_size) { + if (PS3_MOD64((cmd->io_attr.plba << ilog2(vd->sectorSize)), + pd->sector_size)) { #else if ((cmd->io_attr.plba * vd->sectorSize) % pd->sector_size) { #endif LOG_DEBUG("pd chl:%u id:%u plba:0x%llx pd sector_size:%u\n", - PS3_CHANNEL(&pd->disk_pos), PS3_TARGET(&pd->disk_pos), - cmd->io_attr.plba, pd->sector_size); + PS3_CHANNEL(&pd->disk_pos), PS3_TARGET(&pd->disk_pos), + cmd->io_attr.plba, pd->sector_size); goto l_out; } #ifndef _WINDOWS - if ((cmd->io_attr.num_blocks << ilog2(vd->sectorSize)) % pd->sector_size) { + if ((cmd->io_attr.num_blocks << ilog2(vd->sectorSize)) % + pd->sector_size) { #else if ((cmd->io_attr.num_blocks * vd->sectorSize) % pd->sector_size) { #endif LOG_DEBUG("num_blocks:%u pd sector_size:%u vd sector_size:%u\n", - cmd->io_attr.num_blocks, pd->sector_size, vd->sectorSize); + cmd->io_attr.num_blocks, pd->sector_size, + vd->sectorSize); goto l_out; } ret = PS3_DRV_TRUE; l_out: return ret; } -Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +unsigned char +ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; - if (cmd == NULL || cmd->instance == NULL || - pd_entry == NULL) { + if (cmd == NULL || cmd->instance == NULL || pd_entry == NULL) { LOG_ERROR_LIM("sata direct support judge parameter NOK\n"); goto l_out; } @@ -745,16 +816,17 @@ Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, return ret; } -static inline Bool ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) +static inline unsigned char +ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; - U32 data_len = 0; + unsigned char ret = PS3_FALSE; + unsigned int data_len = 0; data_len = ps3_scsih_datelen_calc(cmd); - if(data_len != scsi_bufflen(cmd->scmd)) { - LOG_INFO("data_len:%u not equal to bufflen:%u\n", - data_len, scsi_bufflen(cmd->scmd)); + if (data_len != scsi_bufflen(cmd->scmd)) { + LOG_INFO("data_len:%u not equal to bufflen:%u\n", data_len, + scsi_bufflen(cmd->scmd)); goto l_out; } ret = PS3_TRUE; @@ -763,15 +835,17 @@ static inline Bool ps3_scsih_datelen_buflen_is_match(const struct ps3_cmd *cmd) return ret; } -static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) +static unsigned int ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) { - U16 sector_size = 0; - U32 num_blocks = 0; - U32 date_len = 0; + unsigned short sector_size = 0; + unsigned int num_blocks = 0; + unsigned int date_len = 0; static unsigned long j; + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->io_attr.vd_entry == NULL) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "host parameter NOK\n"); goto l_out; } sector_size = cmd->io_attr.vd_entry->sectorSize; @@ -780,7 +854,8 @@ static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) sector_size = cmd->io_attr.pd_entry->sector_size; } if (sector_size == 0) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "host parameter NOK\n"); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "host parameter NOK\n"); goto l_out; } num_blocks = cmd->io_attr.num_blocks; @@ -790,25 +865,25 @@ static U32 ps3_scsih_datelen_calc(const struct ps3_cmd *cmd) return date_len; } -Bool ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) +unsigned char ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; if (cmd->scmd->cmd_len == 32) { LOG_DEBUG("read32 or write32 no need direct\n"); goto l_out; } - if(ps3_scsih_datelen_buflen_is_match(cmd) != PS3_TRUE) { + if (ps3_scsih_datelen_buflen_is_match(cmd) != PS3_TRUE) goto l_out; - } if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { if (likely(cmd->io_attr.cdb_opts.protect == 0 && - cmd->io_attr.cdb_opts.fua == 0)) { + cmd->io_attr.cdb_opts.fua == 0)) { ret = PS3_TRUE; } else { - LOG_DEBUG("SATA cdb_opts is 0x%x\n", cmd->io_attr.cdb_opts.option); + LOG_DEBUG("SATA cdb_opts is 0x%x\n", + cmd->io_attr.cdb_opts.option); } } else { LOG_DEBUG("SATA options parse failure\n"); @@ -817,17 +892,19 @@ Bool ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd) return ret; } -static inline Bool ps3_scsih_sas_direct_is_need(const struct ps3_cmd *cmd) +static inline unsigned char +ps3_scsih_sas_direct_is_need(const struct ps3_cmd *cmd) { (void)cmd; return PS3_TRUE; } -static inline Bool ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) +static inline unsigned char ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) { if (ps3_scsih_cdb_opts_parse(cmd) == PS3_SUCCESS) { if (likely(cmd->io_attr.cdb_opts.protect != 0)) { - LOG_DEBUG("NVMe protect is 0x%x\n", cmd->io_attr.cdb_opts.protect); + LOG_DEBUG("NVMe protect is 0x%x\n", + cmd->io_attr.cdb_opts.protect); return PS3_FALSE; } } else { @@ -838,43 +915,46 @@ static inline Bool ps3_scsih_nvme_direct_is_need(struct ps3_cmd *cmd) return (ps3_scsih_datelen_buflen_is_match(cmd) == PS3_TRUE); } -static Bool ps3_scsih_direct_cmd_is_supported_logic(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +static unsigned char +ps3_scsih_direct_cmd_is_supported_logic(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; + if (pd_entry == NULL) { PS3_BUG(); goto l_out; } - switch (pd_entry->dev_type) - { - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SATA_HDD: - ret = ps3_scsih_sata_direct_is_need(cmd); - break; - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SAS_HDD: - ret = ps3_scsih_sas_direct_is_need(cmd); - break; - case PS3_DEV_TYPE_NVME_SSD: - ret = ps3_scsih_nvme_direct_is_need(cmd); - break; - default: - ret = PS3_FALSE; - break; + switch (pd_entry->dev_type) { + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SATA_HDD: + ret = ps3_scsih_sata_direct_is_need(cmd); + break; + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SAS_HDD: + ret = ps3_scsih_sas_direct_is_need(cmd); + break; + case PS3_DEV_TYPE_NVME_SSD: + ret = ps3_scsih_nvme_direct_is_need(cmd); + break; + default: + ret = PS3_FALSE; + break; } l_out: return ret; } -static Bool direct_cmd_is_supported_device(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry) +static unsigned char +direct_cmd_is_supported_device(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; + if (pd_entry == NULL) { LOG_ERROR("tid:0x%llx hno:%u CFID:%d pd entry is NULL\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); PS3_BUG(); return ret; } @@ -882,171 +962,179 @@ static Bool direct_cmd_is_supported_device(struct ps3_cmd *cmd, LOG_DEBUG("Direct is disable\n"); return ret; } - switch (pd_entry->dev_type) - { - case PS3_DEV_TYPE_SATA_SSD: - case PS3_DEV_TYPE_SATA_HDD: - ret = ps3_scsih_sata_direct_is_support(cmd, pd_entry); - break; - case PS3_DEV_TYPE_SAS_SSD: - case PS3_DEV_TYPE_SAS_HDD: - ret = PS3_TRUE; - break; - case PS3_DEV_TYPE_NVME_SSD: - ret = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); - break; - default: - ret = PS3_FALSE; - break; + switch (pd_entry->dev_type) { + case PS3_DEV_TYPE_SATA_SSD: + case PS3_DEV_TYPE_SATA_HDD: + ret = ps3_scsih_sata_direct_is_support(cmd, pd_entry); + break; + case PS3_DEV_TYPE_SAS_SSD: + case PS3_DEV_TYPE_SAS_HDD: + ret = PS3_TRUE; + break; + case PS3_DEV_TYPE_NVME_SSD: + ret = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); + break; + default: + ret = PS3_FALSE; + break; } return ret; } -static inline S32 ps3_scsih_is_valid_vlba(struct ps3_cmd *cmd) +static inline int ps3_scsih_is_valid_vlba(struct ps3_cmd *cmd) { return ((U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo) + - cmd->io_attr.num_blocks) > cmd->io_attr.vd_entry->capacity) ? - -PS3_FAILED : PS3_SUCCESS; + cmd->io_attr.num_blocks) > cmd->io_attr.vd_entry->capacity) ? + -PS3_FAILED : + PS3_SUCCESS; } -static inline Bool ps3_scsih_is_direct_to_normal(const struct ps3_instance *instance, - const struct ps3_cmd *cmd) +static inline unsigned char +ps3_scsih_is_direct_to_normal(const struct ps3_instance *instance, + const struct ps3_cmd *cmd) { return (instance->ioc_adpter->is_need_direct_to_normal != NULL && instance->ioc_adpter->is_need_direct_to_normal(cmd)); } -static inline Bool ps3_scsih_is_sas_jbod_cmd(const struct ps3_cmd *cmd) +static inline unsigned char ps3_scsih_is_sas_jbod_cmd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_HDD || - cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_SSD; + cmd->io_attr.dev_type == PS3_DEV_TYPE_SAS_SSD; } -static inline Bool ps3_scsih_is_sata_jbod_cmd(const struct ps3_cmd *cmd) +static inline unsigned char +ps3_scsih_is_sata_jbod_cmd(const struct ps3_cmd *cmd) { return cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_HDD || - cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_SSD; + cmd->io_attr.dev_type == PS3_DEV_TYPE_SATA_SSD; } -Bool ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd) +unsigned char ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd) { - return (ps3_scsih_is_sata_jbod_cmd(cmd)) - && (!ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd)); + return (ps3_scsih_is_sata_jbod_cmd(cmd)) && + (!ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd)); } -U32 ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd) +unsigned int ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd) { - U32 xfer_cnt = 0; + unsigned int xfer_cnt = 0; - PS3RespFrame_u *resp_frame = cmd->resp_frame; - U16 mode = cmd->reply_word.mode; + union PS3RespFrame *resp_frame = cmd->resp_frame; + unsigned short mode = cmd->reply_word.mode; - if (ps3_err_is_resp_from_direct_cmd(mode) - && (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { + if (ps3_err_is_resp_from_direct_cmd(mode) && + (cmd->io_attr.dev_type != PS3_DEV_TYPE_VD)) { xfer_cnt = resp_frame->sasRespFrame.xfer_cnt; } else { xfer_cnt = resp_frame->normalRespFrame.respDetail.xfer_cnt; } return xfer_cnt; } -static inline Bool ps3_scsih_hdd_vd_direct_check(const struct ps3_cmd *cmd) +static inline unsigned char +ps3_scsih_hdd_vd_direct_check(const struct ps3_cmd *cmd) { - Bool is_direct = PS3_TRUE; - struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); + unsigned char is_direct = PS3_TRUE; + struct ps3_scsi_priv_data *p_priv_data = + scsi_device_private_data(cmd->scmd); if (p_priv_data->dev_type == PS3_DEV_TYPE_VD) { - if (!cmd->io_attr.vd_entry->isNvme && !cmd->io_attr.vd_entry->isSsd) { + if (ps3_is_hdd_vd(cmd->io_attr.vd_entry)) { if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) && - (ps3_atomic_read(&p_priv_data->wr_io_outstand) != PS3_VD_IO_1_OUTSTANDING)) { - is_direct = PS3_FALSE; - } else if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + (PS3_VD_WRITE_OUTSTAND(p_priv_data) > PS3_VD_IO_1_OUTSTANDING)) { + is_direct = PS3_FALSE; + } else if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag) && + ((PS3_VD_READ_OUTSTAND(p_priv_data) > PS3_VD_IO_1_OUTSTANDING) || + cmd->io_attr.vd_entry->isReadNeedSeq)) { is_direct = PS3_FALSE; } } } + return is_direct; } static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U64 lba = 0; + int ret = PS3_SUCCESS; + unsigned long long lba = 0; struct ps3_cmd_attr_context *cmd_attr = &cmd->instance->cmd_attr; - if (!cmd_attr->is_support_direct_cmd) { + if (!cmd_attr->is_support_direct_cmd) goto l_out; - } - if (cmd->io_attr.is_force_normal) { + if (cmd->io_attr.is_force_normal) goto l_out; - } - if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { + if (!ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) goto l_out; - } if ((!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) && - ps3_scsih_is_sas_jbod_cmd(cmd)) { + ps3_scsih_is_sas_jbod_cmd(cmd)) { goto l_out; } if (unlikely(cmd->io_attr.num_blocks == 0)) { LOG_DEBUG("tid:0x%llx hno:%u num blocks is zero\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (unlikely(cmd->io_attr.is_retry_cmd && - ps3_scsih_is_direct_to_normal(cmd->instance, cmd))) { - LOG_FILE_WARN("tid:0x%llx hno:%u is_retry_cmd \n", - cmd->trace_id, PS3_HOST(cmd->instance)); - goto l_out; + ps3_scsih_is_direct_to_normal(cmd->instance, cmd))) { + LOG_FILE_WARN("tid:0x%llx hno:%u is_retry_cmd\n", + cmd->trace_id, PS3_HOST(cmd->instance)); + goto l_out; } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL && - cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd)) { - - LOG_DEBUG("hno[%u], cmd index[%u], tid[0x%llx], detected it is sequential io\n", - PS3_HOST(cmd->instance), cmd->index, cmd->trace_id); - if (cmd->instance->ioc_adpter->scsih_stream_is_direct != NULL && \ - !cmd->instance->ioc_adpter->scsih_stream_is_direct(cmd)) { - goto l_out; + cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd)) { + LOG_DEBUG( + "hno[%u], cmd index[%u], tid[0x%llx], detected it is sequential io\n", + PS3_HOST(cmd->instance), cmd->index, + cmd->trace_id); + if (cmd->instance->ioc_adpter->scsih_stream_is_direct != + NULL && + !cmd->instance->ioc_adpter->scsih_stream_is_direct( + cmd)) { + goto l_out; } } if (unlikely(!cmd->io_attr.vd_entry->isDirectEnable)) { LOG_DEBUG("tid:0x%llx hno:%u direct disable\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (cmd->instance->ioc_adpter->write_direct_enable != NULL && - !cmd->instance->ioc_adpter->write_direct_enable(cmd)) { + !cmd->instance->ioc_adpter->write_direct_enable(cmd)) { LOG_DEBUG("tid:0x%llx hno:%u write direct disable\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (unlikely(ps3_scsih_is_valid_vlba(cmd) != PS3_SUCCESS)) { - LOG_ERROR_LIM("hno:%u tid:%#llx lba:0x%llx " - "num_blks:0x%x vd capacity:%llu cmd out of range\n", + LOG_ERROR_LIM( + "hno:%u tid:%#llx lba:0x%llx\n" + "\tnum_blks:0x%x vd capacity:%llu cmd out of range\n", PS3_HOST(cmd->instance), cmd->trace_id, - U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo), - cmd->io_attr.num_blocks, cmd->io_attr.vd_entry->capacity); + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, + cmd->io_attr.lba_lo), + cmd->io_attr.num_blocks, + cmd->io_attr.vd_entry->capacity); goto l_out; } - if (!direct_cmd_is_raidlevel_support(cmd)) { + if (!direct_cmd_is_raidlevel_support(cmd)) goto l_out; - } - if (!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) { + if (!ps3_scsih_is_protocal_rw(cmd->scmd->cmnd)) goto l_out; - } - if ((cmd->io_attr.vd_entry->raidLevel == RAID1)) { + if (cmd->io_attr.vd_entry->raidLevel == RAID1) { if (cmd->io_attr.vd_entry->mapBlock == 0) { PS3_BUG(); goto l_out; @@ -1054,26 +1142,37 @@ static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) if (cmd->instance->is_raid1_direct_skip_mapblock_check) { LOG_DEBUG("hba raid1, skip MapBlock check\n"); } else { - lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); - if (PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, cmd->io_attr.vd_entry->mapBlock, - cmd->io_attr.num_blocks)) { - LOG_DEBUG("hno:%u map_block:%llu lba:0x%llx num_blks:0x%x not same map block\n", - PS3_HOST(cmd->instance), cmd->io_attr.vd_entry->mapBlock, + lba = PS3_LBA(cmd->io_attr.lba_hi, + cmd->io_attr.lba_lo); + if (PS3_SCSIH_NOT_SAME_MAPBLOCK( + lba, + cmd->io_attr.vd_entry->mapBlock, + cmd->io_attr.num_blocks)) { + LOG_DEBUG( + "hno:%u map_block:%llu lba:0x%llx num_blks:0x%x not same map block\n", + PS3_HOST(cmd->instance), + cmd->io_attr.vd_entry->mapBlock, lba, cmd->io_attr.num_blocks); goto l_out; } } } else { - if ((cmd->instance->is_single_disk_raid0_direct_skip_strip_check) && - (cmd->io_attr.vd_entry->raidLevel == RAID0) && - (cmd->io_attr.vd_entry->physDrvCnt == 1)) { - LOG_DEBUG("hba raid0 with single disk, skip strip check\n"); + if ((cmd->instance + ->is_single_disk_raid0_direct_skip_strip_check) && + (cmd->io_attr.vd_entry->raidLevel == RAID0) && + (cmd->io_attr.vd_entry->physDrvCnt == 1)) { + LOG_DEBUG( + "hba raid0 with single disk, skip strip check\n"); } else { - if ( !ps3_scsih_is_same_strip(cmd->io_attr.vd_entry, - cmd->io_attr.lba_lo, cmd->io_attr.num_blocks) ) { - LOG_DEBUG("not same strip lba:0x%x num_blks:0x%x\n", - cmd->io_attr.lba_lo, cmd->io_attr.num_blocks); + if (!ps3_scsih_is_same_strip( + cmd->io_attr.vd_entry, + cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks)) { + LOG_DEBUG( + "not same strip lba:0x%x num_blks:0x%x\n", + cmd->io_attr.lba_lo, + cmd->io_attr.num_blocks); goto l_out; } } @@ -1081,107 +1180,124 @@ static void ps3_scsih_build_direct_cmd(struct ps3_cmd *cmd) ret = ps3_scsih_vd_rw_io_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { - LOG_DEBUG("cmd index:%u vlba to plba fail\n", cmd->index); + LOG_DEBUG("cmd index:%u vlba to plba fail\n", + cmd->index); goto l_out; } - if (!direct_cmd_is_supported_device(cmd, cmd->io_attr.pd_entry)) { - LOG_DEBUG("tid:0x%llx hno:%u not support to direct for this cmd\n", + if (!direct_cmd_is_supported_device(cmd, + cmd->io_attr.pd_entry)) { + LOG_DEBUG( + "tid:0x%llx hno:%u not support to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic(cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { - LOG_DEBUG("tid:0x%llx hno:%u not need to direct for this cmd\n", + if (ps3_scsih_direct_cmd_is_supported_logic( + cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { + LOG_DEBUG( + "tid:0x%llx hno:%u not need to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } if (!direct_cmd_is_plba_sector_aligned(cmd, - cmd->io_attr.pd_entry)) { + cmd->io_attr.pd_entry)) { goto l_out; } if (ps3_is_r1x_write_cmd(cmd)) { - if (!direct_cmd_is_supported_device(cmd, - cmd->io_attr.peer_pd_entry)) { - LOG_DEBUG("tid:0x%llx hno:%u peer_pd[%u:%u:%u] not " - "support to direct for this cmd\n", - cmd->trace_id, - PS3_HOST(cmd->instance), - PS3_CHANNEL(&cmd->io_attr.peer_pd_entry->disk_pos), - PS3_TARGET(&cmd->io_attr.peer_pd_entry->disk_pos), - PS3_PDID(&cmd->io_attr.peer_pd_entry->disk_pos)); + if (!direct_cmd_is_supported_device( + cmd, cmd->io_attr.peer_pd_entry)) { + LOG_DEBUG( + "tid:0x%llx hno:%u peer_pd[%u:%u:%u] not\n" + "\tsupport to direct for this cmd\n", + cmd->trace_id, PS3_HOST(cmd->instance), + PS3_CHANNEL(&cmd->io_attr.peer_pd_entry + ->disk_pos), + PS3_TARGET(&cmd->io_attr.peer_pd_entry + ->disk_pos), + PS3_PDID(&cmd->io_attr.peer_pd_entry + ->disk_pos)); goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic(cmd, - cmd->io_attr.peer_pd_entry) != PS3_TRUE) { + if (ps3_scsih_direct_cmd_is_supported_logic( + cmd, cmd->io_attr.peer_pd_entry) != + PS3_TRUE) { goto l_out; } - if (!direct_cmd_is_plba_sector_aligned(cmd, - cmd->io_attr.peer_pd_entry)) { + if (!direct_cmd_is_plba_sector_aligned( + cmd, cmd->io_attr.peer_pd_entry)) { goto l_out; } } - if (!ps3_scsih_hdd_vd_direct_check(cmd)) { + if (!ps3_scsih_hdd_vd_direct_check(cmd)) goto l_out; - } - cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_ADVICE; + cmd->io_attr.direct_flag = + (unsigned char)PS3_CMDWORD_DIRECT_ADVICE; } else { - if (!direct_cmd_is_supported_device(cmd, cmd->io_attr.pd_entry)) { +#ifdef PS3_NCQ_PRIO_SUPPORT + if (PS3_IS_NCQ_PRIO_DISK_ENABLE(cmd)) { + LOG_DEBUG("ncq prio is enabled, need to normal\n"); + goto l_out; + } +#endif + if (!direct_cmd_is_supported_device(cmd, + cmd->io_attr.pd_entry)) { goto l_out; } - if (ps3_scsih_direct_cmd_is_supported_logic(cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { - LOG_DEBUG("tid:0x%llx hno:%u not need to direct for this cmd\n", + if (ps3_scsih_direct_cmd_is_supported_logic( + cmd, cmd->io_attr.pd_entry) != PS3_TRUE) { + LOG_DEBUG( + "tid:0x%llx hno:%u not need to direct for this cmd\n", cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_OK; - cmd->io_attr.plba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + cmd->io_attr.direct_flag = (unsigned char)PS3_CMDWORD_DIRECT_OK; + cmd->io_attr.plba = + PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); } l_out: - return ; + return; } -static inline Bool ps3_scsih_is_invalid_dev(U8 type) +static inline unsigned char ps3_scsih_is_invalid_dev(unsigned char type) { return (type <= PS3_DEV_TYPE_UNKNOWN || type >= PS3_DEV_TYPE_COUNT); } static inline void ps3_scsih_use_frontend_prp_check(struct ps3_cmd *cmd) { - if (!cmd->instance->is_use_frontend_prp) { + if (!cmd->instance->is_use_frontend_prp) goto l_out; - } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - if (!cmd->io_attr.vd_entry->isNvme) { + if (!cmd->io_attr.vd_entry->isNvme) goto l_out; - } } else { - if (cmd->io_attr.pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD) { + if (cmd->io_attr.pd_entry->dev_type != PS3_DEV_TYPE_NVME_SSD) goto l_out; - } } - cmd->io_attr.is_use_frontend_prp = ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); + cmd->io_attr.is_use_frontend_prp = + ps3_scsih_is_protocal_rw(cmd->scmd->cmnd); l_out: - return ; + return; } -static Bool ps3_unmap_check_block_valid(struct ps3_cmd *cmd) +static unsigned char ps3_unmap_check_block_valid(struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; - U8 umap_xbuf[32] = {0}; - U32 *p_umap_unmblk = &cmd->io_attr.num_blocks; - U16 payload_len = 0; - U16 desc_len = 0; + unsigned char ret = PS3_FALSE; + unsigned char umap_xbuf[32] = { 0 }; + unsigned int *p_umap_unmblk = &cmd->io_attr.num_blocks; + unsigned short payload_len = 0; + unsigned short desc_len = 0; if (cmd->scmd->cmnd[0] != UNMAP) { ret = PS3_TRUE; @@ -1191,15 +1307,16 @@ static Bool ps3_unmap_check_block_valid(struct ps3_cmd *cmd) payload_len = ps3_get_unaligned_be16(&cmd->scmd->cmnd[7]); if (unlikely(payload_len != scsi_bufflen(cmd->scmd))) { LOG_DEBUG("hno:%u. unmap: buf len:%u != cdb:%u\n", - PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), - payload_len); + PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), + payload_len); goto l_out; } - if (unlikely(scsi_bufflen(cmd->scmd) > (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN))) { + if (unlikely(scsi_bufflen(cmd->scmd) > + (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN))) { LOG_DEBUG("hno:%u. unmap: buf len:%u > %u\n", - PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), - (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN)); + PS3_HOST(cmd->instance), scsi_bufflen(cmd->scmd), + (UNMAP_PARAM_LEN + UNMAP_DESCRIPTOR_LEN)); goto l_out; } @@ -1207,25 +1324,26 @@ static Bool ps3_unmap_check_block_valid(struct ps3_cmd *cmd) if (ps3_get_unaligned_be16(&umap_xbuf[0]) != (payload_len - 2)) { LOG_DEBUG("hno:%u. unmap data len: :%u > payload:%u\n", - PS3_HOST(cmd->instance), ps3_get_unaligned_be16(&umap_xbuf[0]), - payload_len - 2); + PS3_HOST(cmd->instance), + ps3_get_unaligned_be16(&umap_xbuf[0]), + payload_len - 2); goto l_out; } desc_len = ps3_get_unaligned_be16(&umap_xbuf[2]); if ((desc_len >> 4) > cmd->io_attr.vd_entry->umapBlkDescCnt) { LOG_DEBUG("hno:%u. unmap: desc len:%u > desc cnt:%u*16\n", - PS3_HOST(cmd->instance), desc_len, - cmd->io_attr.vd_entry->umapBlkDescCnt); + PS3_HOST(cmd->instance), desc_len, + cmd->io_attr.vd_entry->umapBlkDescCnt); goto l_out; } ps3_scsih_unmap_desc_parse(&umap_xbuf[UNMAP_PARAM_LEN], p_umap_unmblk, - &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi); + &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi); if (*p_umap_unmblk > cmd->io_attr.vd_entry->umapNumblk) { LOG_DEBUG("hno:%u. unmap: numblk:%u > limit %u\n", - PS3_HOST(cmd->instance), *p_umap_unmblk, - cmd->io_attr.vd_entry->umapNumblk); + PS3_HOST(cmd->instance), *p_umap_unmblk, + cmd->io_attr.vd_entry->umapNumblk); goto l_out; } @@ -1234,12 +1352,12 @@ static Bool ps3_unmap_check_block_valid(struct ps3_cmd *cmd) return ret; } -static inline void ps3_req_frame_head_init(PS3ReqFrameHead_s *req_head) +static inline void ps3_req_frame_head_init(struct PS3ReqFrameHead *req_head) { req_head->cmdType = 0; req_head->cmdSubType = 0; req_head->cmdFrameID = 0; - req_head->control= 0; + req_head->control = 0; req_head->devID.diskID = 0; req_head->timeout = 0; req_head->virtDiskSeq = 0; @@ -1250,9 +1368,9 @@ static inline void ps3_req_frame_head_init(PS3ReqFrameHead_s *req_head) req_head->traceID = 0; } -static inline U32 ps3_hw_vd_max_io_size_get(U8 enum_size) +static inline unsigned int ps3_hw_vd_max_io_size_get(unsigned char enum_size) { - U32 max_size = PS3_HW_VD_MAX_IO_SIZE_1M; + unsigned int max_size = PS3_HW_VD_MAX_IO_SIZE_1M; switch (enum_size) { case PS3_ENUM_HW_VD_MAX_IO_SIZE_1M: @@ -1262,31 +1380,33 @@ static inline U32 ps3_hw_vd_max_io_size_get(U8 enum_size) return max_size; } -static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) +static int ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - S32 dma_map_ret = 0; - Bool is_need_split = PS3_FALSE; + int ret = PS3_SUCCESS; + int dma_map_ret = 0; + unsigned char is_need_split = PS3_FALSE; struct ps3_scsi_priv_data *data = scsi_device_private_data(cmd->scmd); - U32 hw_vd_max_num_blk = 0; - U32 hw_vd_max_io_size = 0; + unsigned int hw_vd_max_num_blk = 0; + unsigned int hw_vd_max_io_size = 0; cmd->io_attr.dev_type = data->dev_type; if (cmd->is_inserted_c_q == 0) { dma_map_ret = ps3_scsi_dma_map(cmd); if (unlikely(dma_map_ret < 0)) { LOG_WARN_LIM("hno:%u. cfid[%u] dma_map NOK:%d\n", - PS3_HOST(cmd->instance), cmd->index, dma_map_ret); + PS3_HOST(cmd->instance), cmd->index, + dma_map_ret); ret = -PS3_ENOMEM; goto l_out; } } if (unlikely(ps3_scsih_is_invalid_dev(cmd->io_attr.dev_type))) { - LOG_ERROR_LIM("hno:%u get dev type NOK :%d dev_type:%s\n", + LOG_ERROR_LIM( + "hno:%u get dev type NOK :%d dev_type:%s\n", PS3_HOST(cmd->instance), cmd->index, namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type)); - ret = -PS3_DEV_TYPE_UNKOWN; + ret = -PS3_DEV_UNKNOWN; goto l_out; } @@ -1296,36 +1416,47 @@ static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) #ifndef _WINDOWS cmd->io_attr.is_retry_cmd = (cmd->scmd->retries != 0); #endif - cmd->io_attr.direct_flag = (U8)PS3_CMDWORD_DIRECT_NORMAL; - cmd->io_attr.rw_type = ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(cmd->scmd)); + cmd->io_attr.direct_flag = (unsigned char)PS3_CMDWORD_DIRECT_NORMAL; + cmd->io_attr.rw_type = + ps3_scsih_cdb_rw_type_get(scsi_cmnd_cdb(cmd->scmd)); if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag)) { - ps3_scsih_cdb_parse(scsi_cmnd_cdb(cmd->scmd), &cmd->io_attr.num_blocks, - &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi, &is_need_split); + ps3_scsih_cdb_parse(scsi_cmnd_cdb(cmd->scmd), + &cmd->io_attr.num_blocks, + &cmd->io_attr.lba_lo, &cmd->io_attr.lba_hi, + &is_need_split); } if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { - cmd->io_attr.vd_entry = ps3_dev_mgr_lookup_vd_info_by_id(cmd->instance, - cmd->io_attr.disk_id); + cmd->io_attr.vd_entry = ps3_dev_mgr_lookup_vd_info_by_id( + cmd->instance, cmd->io_attr.disk_id); if (unlikely(cmd->io_attr.vd_entry == NULL)) { ret = -PS3_ENODEV; goto l_out; } - if (unlikely(cmd->io_attr.num_blocks > cmd->io_attr.vd_entry->maxIOSize)) { + if (unlikely(cmd->io_attr.num_blocks > + cmd->io_attr.vd_entry->maxIOSize)) { LOG_DEBUG("hno:%u. numblk:%u > maxio:%u\n", - PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, - cmd->io_attr.vd_entry->maxIOSize); + PS3_HOST(cmd->instance), + cmd->io_attr.num_blocks, + cmd->io_attr.vd_entry->maxIOSize); cmd->io_attr.is_force_normal = PS3_TRUE; } - hw_vd_max_io_size = ps3_hw_vd_max_io_size_get(cmd->instance->ctrl_info.hwVdMaxIOSize); - hw_vd_max_num_blk = hw_vd_max_io_size >> ps3_blocksize_to_shift(cmd->io_attr.vd_entry->sectorSize); + hw_vd_max_io_size = ps3_hw_vd_max_io_size_get( + cmd->instance->ctrl_info.hwVdMaxIOSize); + hw_vd_max_num_blk = hw_vd_max_io_size >> + ps3_blocksize_to_shift( + cmd->io_attr.vd_entry->sectorSize); if (unlikely(cmd->io_attr.num_blocks > hw_vd_max_num_blk && - cmd->io_attr.num_blocks > cmd->io_attr.vd_entry->maxIOSize)) { - LOG_DEBUG("hno:%u. numblk:%u > max size, hw max numblk:%u maxIOSize:%u\n", - PS3_HOST(cmd->instance), cmd->io_attr.num_blocks, - hw_vd_max_num_blk, cmd->io_attr.vd_entry->maxIOSize); + cmd->io_attr.num_blocks > + cmd->io_attr.vd_entry->maxIOSize)) { + LOG_DEBUG( + "hno:%u. numblk:%u > max size, hw max numblk:%u maxIOSize:%u\n", + PS3_HOST(cmd->instance), + cmd->io_attr.num_blocks, hw_vd_max_num_blk, + cmd->io_attr.vd_entry->maxIOSize); goto l_skip_r1x_write_lock; } @@ -1335,16 +1466,19 @@ static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) } ret = ps3_r1x_write_lock(&data->lock_mgr, cmd); - if(unlikely(ret != PS3_SUCCESS)){ + if (unlikely(ret != PS3_SUCCESS)) goto l_out; - } } else { - cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(cmd->instance, - cmd->io_attr.disk_id); + cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + cmd->instance, cmd->io_attr.disk_id); if (unlikely(cmd->io_attr.pd_entry == NULL)) { ret = -PS3_ENODEV; goto l_out; } + +#ifdef PS3_NCQ_PRIO_SUPPORT + cmd->io_attr.is_ncq_prio_enable = data->ncq_prio_enable; +#endif } l_skip_r1x_write_lock: @@ -1359,11 +1493,11 @@ static S32 ps3_scsih_cmd_build_prepare(struct ps3_cmd *cmd) return ret; } -static S32 ps3_scsih_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; - U32 table_size = ARRAY_SIZE(g_req_frame_func_table); - U32 i = 0; + int ret = -PS3_FAILED; + unsigned int table_size = ARRAY_SIZE(g_req_frame_func_table); + unsigned int i = 0; #ifdef _WINDOWS ps3_scsi_need_remap_check(cmd); if (cmd->scmd->is_remap_databuff) { @@ -1385,9 +1519,9 @@ static S32 ps3_scsih_req_frame_build(struct ps3_cmd *cmd) } static void ps3_scsih_vd_cmd_word_devid_build(struct ps3_cmd *cmd, - const struct PS3VDEntry *vd_info) + const struct PS3VDEntry *vd_info) { - cmd->cmd_word.virtDiskID = (U8)PS3_VDID(&vd_info->diskPos); + cmd->cmd_word.virtDiskID = (unsigned char)PS3_VDID(&vd_info->diskPos); switch (cmd->io_attr.direct_flag) { case PS3_CMDWORD_DIRECT_OK: @@ -1402,25 +1536,21 @@ static void ps3_scsih_vd_cmd_word_devid_build(struct ps3_cmd *cmd, break; } - return; } -static Bool ps3_is_no_calc_mapblocks(const struct PS3VDEntry *vd_info, - const struct ps3_cmd *cmd) +static unsigned char ps3_is_no_calc_mapblocks(const struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; - (void)vd_info; + unsigned char ret = PS3_FALSE; if (ps3_scsih_is_sync_cache(scsi_cmnd_cdb(cmd->scmd))) { LOG_DEBUG("hno:%u is SYNCHRONIZE_CACHE\n", - PS3_HOST(cmd->instance)); + PS3_HOST(cmd->instance)); ret = PS3_FALSE; goto l_out; } if (ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) == PS3_FALSE) { - LOG_DEBUG("hno:%u not rw cmd\n", - PS3_HOST(cmd->instance)); + LOG_DEBUG("hno:%u not rw cmd\n", PS3_HOST(cmd->instance)); ret = PS3_TRUE; goto l_out; } @@ -1429,28 +1559,30 @@ static Bool ps3_is_no_calc_mapblocks(const struct PS3VDEntry *vd_info, return ret; } -static S32 ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, - const struct PS3VDEntry *vd_info) +static int ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, + const struct PS3VDEntry *vd_info) { - S32 ret = PS3_SUCCESS; - U32 num_blocks = cmd->io_attr.num_blocks; - U32 lba_lo = cmd->io_attr.lba_lo; - U32 lba_hi = cmd->io_attr.lba_hi; - U64 lba = 0; - U8 que_offset = 0; - PS3ReqFrameHead_s *req_head= &cmd->req_frame->frontendReq.reqHead; + int ret = PS3_SUCCESS; + unsigned int num_blocks = cmd->io_attr.num_blocks; + unsigned int lba_lo = cmd->io_attr.lba_lo; + unsigned int lba_hi = cmd->io_attr.lba_hi; + unsigned long long lba = 0; + unsigned char que_offset = 0; + struct PS3ReqFrameHead *req_head = &cmd->req_frame->frontendReq.reqHead; cmd->cmd_word.qMask = 0; req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; - lba = ((U64)lba_hi << PS3_SHIFT_DWORD) | lba_lo; + lba = ((unsigned long long)lba_hi << PS3_SHIFT_DWORD) | lba_lo; - LOG_DEBUG("tid:0x%llx hno:%u CFID:%d lba:0x%llx map_block[%lld], num_blks:0x%x\n", + LOG_DEBUG( + "tid:0x%llx hno:%u CFID:%d lba:0x%llx map_block[%lld], num_blks:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, lba, vd_info->mapBlock, num_blocks); - if (ps3_is_no_calc_mapblocks(vd_info, cmd)) { - LOG_DEBUG("tid:0x%llx hno:%u CFID:%u lba:0x%llx map_block[%lld], num_blks:0x%x\n", + if (ps3_is_no_calc_mapblocks(cmd)) { + LOG_DEBUG( + "tid:0x%llx hno:%u CFID:%u lba:0x%llx map_block[%lld], num_blks:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, lba, vd_info->mapBlock, num_blocks); goto l_out; @@ -1464,45 +1596,58 @@ static S32 ps3_scsih_vd_cmd_word_cpu_set(struct ps3_cmd *cmd, goto l_out; } - if (vd_info->isSsd && cmd->instance->ioc_adpter->ssd_vd_qmask_calculate != NULL) { - if (cmd->instance->ioc_adpter->ssd_vd_qmask_calculate(cmd)) { + if (vd_info->isSsd && + cmd->instance->ioc_adpter->ssd_vd_qmask_calculate != NULL) { + if (cmd->instance->ioc_adpter->ssd_vd_qmask_calculate(cmd)) goto l_hba_ssd_vd; - } } - que_offset = PS3_CMD_WORD_QUE_CALC(vd_info->diskPos.diskDev.ps3Dev.virtDiskID, lba, + que_offset = PS3_CMD_WORD_QUE_CALC( + vd_info->diskPos.diskDev.ps3Dev.virtDiskID, lba, vd_info->mapBlock, (cmd->instance->ctrl_info.vdQueueNum - 1)); cmd->cmd_word.qMask = 1 << que_offset; - if ((PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, vd_info->mapBlock, num_blocks)) - && (cmd->instance->ioc_adpter->rw_cmd_is_need_split != NULL) - && (cmd->instance->ioc_adpter->rw_cmd_is_need_split(cmd))) { - - if (que_offset == (cmd->instance->ctrl_info.vdQueueNum - 1)) { + if ((PS3_SCSIH_NOT_SAME_MAPBLOCK(lba, vd_info->mapBlock, num_blocks)) && + (cmd->instance->ioc_adpter->rw_cmd_is_need_split != NULL) && + (cmd->instance->ioc_adpter->rw_cmd_is_need_split(cmd))) { + if (que_offset == (cmd->instance->ctrl_info.vdQueueNum - 1)) cmd->cmd_word.qMask |= 0x1; - } else { + else cmd->cmd_word.qMask |= 1 << (que_offset + 1); - } req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; LOG_DEBUG("hno:%u map_block:%llu not same map block qMask 0x:%x\n", - PS3_HOST(cmd->instance), vd_info->mapBlock, cmd->cmd_word.qMask); + PS3_HOST(cmd->instance), vd_info->mapBlock, + cmd->cmd_word.qMask); } l_hba_ssd_vd: - LOG_DEBUG("tid:0x%llx hno:%u CFID:%d que:%d ver:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - cmd->cmd_word.qMask, req_head->mapBlockVer); + LOG_DEBUG("tid:0x%llx hno:%u CFID:%d que:%d ver:%u\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.qMask, + req_head->mapBlockVer); l_out: return ret; +} + +void ps3_scsih_pd_cmd_word_cpu_set(struct ps3_cmd *cmd) +{ + const struct ps3_pd_entry *pd_info = cmd->io_attr.pd_entry; + unsigned char que_offset = + ((PS3_PDID(&pd_info->disk_pos)) & (cmd->instance->ctrl_info.vdQueueNum - 1)); + + cmd->cmd_word.qMask = 1 << que_offset; + LOG_DEBUG("tid:0x%llx hno:%u CFID:%d pdid:%u que:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), cmd->index, PS3_PDID(&pd_info->disk_pos), + cmd->cmd_word.qMask); + return; } -static S32 ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) +static int ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - INJECT_START(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKOWN, cmd); + INJECT_START(PS3_ERR_IJ_IO_RW_FLAG_SET_UNKNOWN, cmd); switch (cmd->io_attr.rw_flag) { case PS3_SCSI_CMD_TYPE_READ: @@ -1519,53 +1664,45 @@ static S32 ps3_scsih_cmd_word_type_set(struct ps3_cmd *cmd) default: cmd->cmd_word.type = PS3_CMDWORD_TYPE_MGR; ret = -PS3_FAILED; - LOG_ERROR_LIM("hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", - PS3_HOST(cmd->instance), cmd->index, ret, cmd->io_attr.rw_flag); + LOG_ERROR_LIM( + "hno:%u cmd word set type NOK CFID:%d ret:%d rw_flag:%d\n", + PS3_HOST(cmd->instance), cmd->index, ret, + cmd->io_attr.rw_flag); break; } return ret; } -static inline U16 ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd) +static inline unsigned short +ps3_scsih_is_use_hard_cmd(const struct ps3_cmd *cmd) { return ((cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_OK) || (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE)) ? - PS3_CMDWORD_FORMAT_HARDWARE : PS3_CMDWORD_FORMAT_FRONTEND; + PS3_CMDWORD_FORMAT_HARDWARE : + PS3_CMDWORD_FORMAT_FRONTEND; } -static S32 ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) +static int ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; const struct PS3VDEntry *vd_info = cmd->io_attr.vd_entry; memset(&cmd->cmd_word, 0, sizeof(cmd->cmd_word)); ret = ps3_scsih_cmd_word_type_set(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_LIM("tid:0x%llx hno:%u set cmd word fail " - "cmd:%d chl:%u id:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device)); + LOG_ERROR_LIM("tid:0x%llx hno:%u set cmd word fail\n" + "\tcmd:%d chl:%u id:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device)); ret = -PS3_FAILED; goto l_out; } ret = ps3_scsih_vd_cmd_word_cpu_set(cmd, vd_info); -#if 0 - if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_LIM("tid:0x%llx hno:%u vd cmd word cpu set NOK, " - "cmd:%u chl:%u id:%u\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device)); - ret = -PS3_FAILED; - goto l_out; - } -#endif - - cmd->cmd_word.direct = cmd->io_attr.direct_flag; + cmd->cmd_word.direct = cmd->io_attr.direct_flag; #ifndef _WINDOWS cmd->cmd_word.isrSN = ps3_msix_index_get(cmd, vd_info->dev_busy_scale); #else @@ -1579,16 +1716,15 @@ static S32 ps3_scsih_vd_cmd_word_build(struct ps3_cmd *cmd) return ret; } -static S32 ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) +static int ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_priv_data *priv_data = NULL; cmd->cmd_word.direct = cmd->io_attr.direct_flag; ret = ps3_scsih_cmd_word_type_set(cmd); - if (ret != PS3_SUCCESS) { + if (ret != PS3_SUCCESS) goto l_out; - } #ifndef _WINDOWS cmd->cmd_word.isrSN = ps3_msix_index_get(cmd, 1); @@ -1601,162 +1737,183 @@ static S32 ps3_scsih_pd_cmd_word_build(struct ps3_cmd *cmd) cmd->cmd_word.phyDiskID = priv_data->disk_pos.diskDev.ps3Dev.phyDiskID; cmd->cmd_word.virtDiskID = PS3_INVALID_DEV_ID; - if ((cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) - || (cmd->cmd_word.type == PS3_CMDWORD_TYPE_WRITE)){ - cmd->cmd_word.qMask = 0x1; + if ((cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) || + (cmd->cmd_word.type == PS3_CMDWORD_TYPE_WRITE)) { + if (cmd->instance->ioc_adpter->pd_cmd_word_cpu_set != NULL) + cmd->instance->ioc_adpter->pd_cmd_word_cpu_set(cmd); + else + cmd->cmd_word.qMask = 0x1; } - l_out: return ret; } -static S32 ps3_scsih_cmd_word_build(struct ps3_cmd *cmd) +static int ps3_scsih_cmd_word_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) ret = ps3_scsih_vd_cmd_word_build(cmd); - } else { + else ret = ps3_scsih_pd_cmd_word_build(cmd); - } if (unlikely(ret != PS3_SUCCESS)) { LOG_ERROR_LIM("tid:0x%llx hno:%u CFID:%d cmd word build NOK!\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index); } return ret; } -static inline const char *ps3_scsih_print_rw_type(U8 rw_flag) +static inline const char *ps3_scsih_print_rw_type(unsigned char rw_flag) { - static const char *rw_type_table[] = { - [PS3_SCSI_CMD_TYPE_UNKOWN] = "SCMD_T_UNKOWN", - [PS3_SCSI_CMD_TYPE_READ] ="SCMD_T_R", - [PS3_SCSI_CMD_TYPE_WRITE] ="SCMD_T_W", - [PS3_SCSI_CMD_TYPE_RW] ="SCMD_T_RW", - [PS3_SCSI_CMD_TYPE_UNMAP] ="SCMD_T_UNMAP", - [PS3_SCSI_CMD_TYPE_NORW] ="SCMD_T_NORW", - [PS3_SCSI_CMD_TYPE_COUNT] ="SCMD_T_CNT" + static const char *const rw_type_table[] = { + [PS3_SCSI_CMD_TYPE_UNKNOWN] = "SCMD_T_UNKNOWN", + [PS3_SCSI_CMD_TYPE_READ] = "SCMD_T_R", + [PS3_SCSI_CMD_TYPE_WRITE] = "SCMD_T_W", + [PS3_SCSI_CMD_TYPE_RW] = "SCMD_T_RW", + [PS3_SCSI_CMD_TYPE_UNMAP] = "SCMD_T_UNMAP", + [PS3_SCSI_CMD_TYPE_NORW] = "SCMD_T_NORW", + [PS3_SCSI_CMD_TYPE_COUNT] = "SCMD_T_CNT" }; - if (rw_flag >= PS3_SCSI_CMD_TYPE_COUNT) { - return rw_type_table[PS3_SCSI_CMD_TYPE_UNKOWN]; - } - - return rw_type_table[rw_flag]; -} - -static void ps3_scsih_print_cdb(const U8 *cdb) -{ - LOG_DEBUG("CDB: %02x %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x %02x" - " %02x %02x %02x %02x %02x %02x %02x %02x\n", - cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], - cdb[5], cdb[6], cdb[7], cdb[8], cdb[9], - cdb[10], cdb[11], cdb[12], cdb[13], cdb[14], - cdb[15], cdb[16], cdb[17], cdb[18], cdb[19], - cdb[20], cdb[21], cdb[22], cdb[23], cdb[24], - cdb[25], cdb[26], cdb[27], cdb[28], cdb[29], - cdb[30], cdb[31]); -} - -static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, U8 log_level) -{ - if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND){ - PS3ReqFrameHead_s reqHead = cmd->req_frame->frontendReq.reqHead; - LOG_LEVEL(log_level, "tid:0x%llx hno:%u fe head cmd_t:%d" - " stype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d" - "dataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d" - "virtDiskSeq:%d\n", - reqHead.traceID, PS3_HOST(cmd->instance), reqHead.cmdType, - reqHead.cmdSubType, reqHead.cmdFrameID, reqHead.control, - reqHead.devID.diskID, reqHead.noReplyWord, reqHead.dataFormat, - reqHead.reqFrameFormat, reqHead.mapBlockVer, reqHead.isWrite, - reqHead.virtDiskSeq); + if (rw_flag >= PS3_SCSI_CMD_TYPE_COUNT) + return rw_type_table[PS3_SCSI_CMD_TYPE_UNKNOWN]; + + return rw_type_table[rw_flag]; +} + +static void ps3_scsih_print_cdb(const unsigned char *cdb) +{ + LOG_DEBUG("CDB: %02x %02x %02x %02x %02x %02x %02x %02x\n" + "\t%02x %02x %02x %02x %02x %02x %02x %02x\n" + "\t%02x %02x %02x %02x %02x %02x %02x %02x\n" + "\t%02x %02x %02x %02x %02x %02x %02x %02x\n", + cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], + cdb[7], cdb[8], cdb[9], cdb[10], cdb[11], cdb[12], cdb[13], + cdb[14], cdb[15], cdb[16], cdb[17], cdb[18], cdb[19], cdb[20], + cdb[21], cdb[22], cdb[23], cdb[24], cdb[25], cdb[26], cdb[27], + cdb[28], cdb[29], cdb[30], cdb[31]); +} + +static inline void ps3_scsih_print_req_head(struct ps3_cmd *cmd, + unsigned char log_level) +{ + if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == + PS3_REQFRAME_FORMAT_FRONTEND) { + struct PS3ReqFrameHead reqHead = + cmd->req_frame->frontendReq.reqHead; + + LOG_LEVEL( + log_level, + "tid:0x%llx hno:%u fe head cmd_t:%d\n" + "\tstype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d\n" + "\tdataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d\n" + "\tvirtDiskSeq:%d\n", + reqHead.traceID, PS3_HOST(cmd->instance), + reqHead.cmdType, reqHead.cmdSubType, reqHead.cmdFrameID, + reqHead.control, reqHead.devID.diskID, + reqHead.noReplyWord, reqHead.dataFormat, + reqHead.reqFrameFormat, reqHead.mapBlockVer, + reqHead.isWrite, reqHead.virtDiskSeq); } else { - PS3ReqFrameHead_s reqHead = cmd->req_frame->hwReq.reqHead; - LOG_LEVEL(log_level, "tid:0x%llx hno:%u fe head cmd_t:%d" - " stype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d" - "dataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d" - "virtDiskSeq:%d\n", - reqHead.traceID, PS3_HOST(cmd->instance), reqHead.cmdType, - reqHead.cmdSubType, reqHead.cmdFrameID, reqHead.control, - reqHead.devID.diskID, reqHead.noReplyWord, reqHead.dataFormat, - reqHead.reqFrameFormat, reqHead.mapBlockVer, reqHead.isWrite, - reqHead.virtDiskSeq); + struct PS3ReqFrameHead reqHead = cmd->req_frame->hwReq.reqHead; + + LOG_LEVEL( + log_level, + "tid:0x%llx hno:%u fe head cmd_t:%d\n" + "\tstype:%d CFID:%d ctrl:0x%x dev id:0x%x noReplyWord:%d\n" + "\tdataFormat:%d reqFrameFormat:%d mapBlockVer:%d isWrite:%d\n" + "\tvirtDiskSeq:%d\n", + reqHead.traceID, PS3_HOST(cmd->instance), + reqHead.cmdType, reqHead.cmdSubType, reqHead.cmdFrameID, + reqHead.control, reqHead.devID.diskID, + reqHead.noReplyWord, reqHead.dataFormat, + reqHead.reqFrameFormat, reqHead.mapBlockVer, + reqHead.isWrite, reqHead.virtDiskSeq); } } -static void ps3_scsih_print_hw_req(struct ps3_cmd *cmd, U8 log_level) +static void ps3_scsih_print_hw_req(struct ps3_cmd *cmd, unsigned char log_level) { - IODT_V1_s *req = NULL; - struct ps3_pd_entry * pd_entry = (struct ps3_pd_entry *)cmd->io_attr.pd_entry; - if (pd_entry == NULL) { + struct IODT_V1 *req = NULL; + struct ps3_pd_entry *pd_entry = + (struct ps3_pd_entry *)cmd->io_attr.pd_entry; + if (pd_entry == NULL) return; - } ps3_scsih_print_req_head(cmd, log_level); switch (pd_entry->dev_type) { case PS3_DEV_TYPE_SAS_HDD: case PS3_DEV_TYPE_SAS_SSD: req = &cmd->req_frame->hwReq.sasReqFrame; - LOG_LEVEL(log_level, "hno:%u cmdProto:%d cmdType:%d " - "cmdLen:%d dataAddr:0x%llx sgeMode:%d " - "direct:%d function:%d phyDiskID:%d " - "reqFrameID:%d CmdWordType:%d cmdDir:%d " - "dataBufLenDWAlign:0x%x iuSrc:%d sataCtl:%d\n", - PS3_HOST(cmd->instance), req->protocolType, req->frameType, - le32_to_cpu(req->cmdLen), le64_to_cpu(req->dataBaseAddr), - req->dmaCfg.sgMode, req->commonWord.direct, req->commonWord.function, - le16_to_cpu(req->commonWord.phyDiskID), - le16_to_cpu(req->commonWord.reqFrameID), - req->commonWord.type, req->cmdDir, le32_to_cpu(req->dataBufLenDWAlign), - req->iuSrc, req->sasCtl); + LOG_LEVEL(log_level, + "hno:%u cmdProto:%d cmdType:%d\n" + "\tcmdLen:%d dataAddr:0x%llx sgeMode:%d\n" + "\tdirect:%d function:%d phyDiskID:%d\n" + "\treqFrameID:%d CmdWordType:%d cmdDir:%d\n" + "\tdataBufLenDWAlign:0x%x iuSrc:%d sataCtl:%d\n", + PS3_HOST(cmd->instance), req->protocolType, + req->frameType, le32_to_cpu(req->cmdLen), + le64_to_cpu(req->dataBaseAddr), req->dmaCfg.sgMode, + req->commonWord.direct, req->commonWord.function, + le16_to_cpu(req->commonWord.phyDiskID), + le16_to_cpu(req->commonWord.reqFrameID), + req->commonWord.type, req->cmdDir, + le32_to_cpu(req->dataBufLenDWAlign), req->iuSrc, + req->sasCtl); ps3_scsih_print_cdb(req->B.cdb); break; case PS3_DEV_TYPE_SATA_HDD: case PS3_DEV_TYPE_SATA_SSD: req = &cmd->req_frame->hwReq.sasReqFrame; - LOG_LEVEL(log_level, "hno:%u cmdProto:%d cmdType:%d " - "dataAddr:0x%llx sgeMode:%d " - "direct:%d function:%d phyDiskID:%d " - "reqFrameID:%d CmdWordType:%d cmdDir:%d " - "dataBufLenDWAlign:0x%x lba:0x%llx " - "opCode:0x%llx iuSrc:%d sataCtl:%d\n", - PS3_HOST(cmd->instance), req->protocolType, req->frameType, - le64_to_cpu(req->dataBaseAddr), req->dmaCfg.sgMode, - req->commonWord.direct, req->commonWord.function, - le16_to_cpu(req->commonWord.phyDiskID), - le16_to_cpu(req->commonWord.reqFrameID), req->commonWord.type, - req->cmdDir, le32_to_cpu(req->dataBufLenDWAlign), - le64_to_cpu(req->C.lba), (U64)req->C.opCode, req->iuSrc, req->sataCtl); + LOG_LEVEL(log_level, + "hno:%u cmdProto:%d cmdType:%d\n" + "\tdataAddr:0x%llx sgeMode:%d\n" + "\tdirect:%d function:%d phyDiskID:%d\n" + "\treqFrameID:%d CmdWordType:%d cmdDir:%d\n" + "\tdataBufLenDWAlign:0x%x lba:0x%llx\n" + "\topCode:0x%llx iuSrc:%d sataCtl:%d\n", + PS3_HOST(cmd->instance), req->protocolType, + req->frameType, le64_to_cpu(req->dataBaseAddr), + req->dmaCfg.sgMode, req->commonWord.direct, + req->commonWord.function, + le16_to_cpu(req->commonWord.phyDiskID), + le16_to_cpu(req->commonWord.reqFrameID), + req->commonWord.type, req->cmdDir, + le32_to_cpu(req->dataBufLenDWAlign), + le64_to_cpu(req->C.lba), + (unsigned long long)req->C.opCode, req->iuSrc, + req->sataCtl); break; case PS3_DEV_TYPE_NVME_SSD: break; - default : + default: LOG_LEVEL(log_level, "hno:%u dev_type:%d\n", - PS3_HOST(cmd->instance), pd_entry->dev_type); + PS3_HOST(cmd->instance), pd_entry->dev_type); break; } } -static void ps3_scsih_print_frontend_req(struct ps3_cmd *cmd, U8 log_level) +static void ps3_scsih_print_frontend_req(struct ps3_cmd *cmd, + unsigned char log_level) { ps3_scsih_print_req_head(cmd, log_level); - LOG_LEVEL(log_level, "cmd sge_cnt:%d sge_of:%d data_len:%d isStream:%d" - " num_blks:0x%x\n", - cmd->req_frame->frontendReq.sgeCount, - cmd->req_frame->frontendReq.sgeOffset, - cmd->req_frame->frontendReq.dataXferLen, - cmd->req_frame->frontendReq.vdAccAttr.isStream, - cmd->io_attr.num_blocks); + LOG_LEVEL(log_level, + "cmd sge_cnt:%d sge_of:%d data_len:%d isStream:%d\n" + "\tnum_blks:0x%x\n", + cmd->req_frame->frontendReq.sgeCount, + cmd->req_frame->frontendReq.sgeOffset, + cmd->req_frame->frontendReq.dataXferLen, + cmd->req_frame->frontendReq.vdAccAttr.isStream, + cmd->io_attr.num_blocks); ps3_scsih_print_cdb(cmd->req_frame->frontendReq.cdb); } -void ps3_scsih_print_req(struct ps3_cmd *cmd, U8 log_level) +void ps3_scsih_print_req(struct ps3_cmd *cmd, unsigned char log_level) { - if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == PS3_REQFRAME_FORMAT_FRONTEND) { + if (cmd->req_frame->frontendReq.reqHead.reqFrameFormat == + PS3_REQFRAME_FORMAT_FRONTEND) { ps3_scsih_print_frontend_req(cmd, log_level); } else { ps3_scsih_print_hw_req(cmd, log_level); @@ -1765,64 +1922,81 @@ void ps3_scsih_print_req(struct ps3_cmd *cmd, U8 log_level) static void ps3_scsih_print_io_cmd(struct ps3_cmd *cmd) { - if(cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { if (cmd->io_attr.pd_entry != NULL) { - LOG_DEBUG("tid:0x%llx hno:%u cmd CFID:%d, dev_t:%s [%d:%d:%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - namePS3DevType((enum PS3DevType)cmd->io_attr.pd_entry->dev_type), - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.softChan, - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.devID, - cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev.phyDiskID); - } - } - - LOG_DEBUG("tid:0x%llx hno:%u print CMD: CFID:%u" - " dev_t:%s outstand:%u is_retry_cmd:%d " - "direct_f:%d rw_f:%s CMD_WORD: type:%d direct:%d" - " qmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d" - " lba:0x%llx opcode:0x%x\n", + LOG_DEBUG( + "tid:0x%llx hno:%u cmd CFID:%d, dev_t:%s [%d:%d:%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, + namePS3DevType((enum PS3DevType)cmd->io_attr + .pd_entry->dev_type), + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev + .softChan, + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev + .devID, + cmd->io_attr.pd_entry->disk_pos.diskDev.ps3Dev + .phyDiskID); + } + } + + LOG_DEBUG( + "tid:0x%llx hno:%u print CMD: CFID:%u\n" + "\tdev_t:%s outstand:%u is_retry_cmd:%d\n" + "\tdirect_f:%d rw_f:%s CMD_WORD: type:%d direct:%d\n" + "\tqmask:0x%x CFID:%d isr_sn:%d vid:%d pid:%d\n" + "\tlba:0x%llx opcode:0x%x\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, namePS3DevType((enum PS3DevType)cmd->io_attr.dev_type), ps3_atomic_read(&cmd->instance->cmd_statistics.io_outstanding), cmd->io_attr.is_retry_cmd, cmd->io_attr.direct_flag, ps3_scsih_print_rw_type(cmd->io_attr.rw_flag), - cmd->cmd_word.type, cmd->cmd_word.direct, - cmd->cmd_word.qMask, cmd->cmd_word.cmdFrameID, - cmd->cmd_word.isrSN, cmd->cmd_word.virtDiskID, - cmd->cmd_word.phyDiskID, - ((((U64)(cmd->io_attr.lba_hi)) << 32) + (cmd->io_attr.lba_lo)), + cmd->cmd_word.type, cmd->cmd_word.direct, cmd->cmd_word.qMask, + cmd->cmd_word.cmdFrameID, cmd->cmd_word.isrSN, + cmd->cmd_word.virtDiskID, cmd->cmd_word.phyDiskID, + ((((unsigned long long)(cmd->io_attr.lba_hi)) << 32) + + (cmd->io_attr.lba_lo)), cmd->scmd->cmnd[0]); ps3_scsih_print_req(cmd, LEVEL_DEBUG); } -S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd) +int ps3_scsih_cmd_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; static unsigned long j; + ret = ps3_scsih_cmd_build_prepare(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_DEBUG("tid:0x%llx hno:%u cmd_word build prepare fail CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_DEBUG( + "tid:0x%llx hno:%u cmd_word build prepare fail CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + ret); ret = ((-PS3_IO_CONFLICT == ret || -PS3_IO_REQUEUE == ret || -PS3_IO_CONFLICT_IN_Q == ret) ? - ret : SCSI_MLQUEUE_HOST_BUSY); + ret : + SCSI_MLQUEUE_HOST_BUSY); goto l_out; } ret = ps3_scsih_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + ret); ret = SCSI_MLQUEUE_HOST_BUSY; goto l_out; } ret = ps3_scsih_req_frame_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u req_frame NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + ret); ret = SCSI_MLQUEUE_HOST_BUSY; goto l_out; } @@ -1830,43 +2004,49 @@ S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd) ps3_scsih_print_io_cmd(cmd); PS3_IO_TRACE(cmd, PS3_IO_TRACE_DIRECT_SEND); - ret = ps3_qos_decision(cmd); + ret = ps3_qos_decision(cmd); l_out: return ret; } -static inline union PS3DiskDev ps3_scsih_dev_id_get(const struct scsi_cmnd *s_cmd) +static inline union PS3DiskDev +ps3_scsih_dev_id_get(const struct scsi_cmnd *s_cmd) { struct ps3_scsi_priv_data *data = scsi_device_private_data(s_cmd); + return data->disk_pos.diskDev; } -static inline Bool ps3_scsih_is_vd_accelerate(struct ps3_cmd *cmd) +static inline unsigned char ps3_scsih_is_vd_accelerate(struct ps3_cmd *cmd) { return ps3_scsih_vd_acc_att_build(cmd); } static inline void ps3_sas_cdb_build(struct ps3_cmd *cmd) { - U32 blocks = 0; + unsigned int blocks = 0; memset(cmd->io_attr.cdb, 0, PS3_FRAME_CDB_BUFLEN); memcpy(cmd->io_attr.cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); #ifndef _WINDOWS - blocks = cmd->io_attr.num_blocks << ilog2(cmd->io_attr.vd_entry->sectorSize); + blocks = cmd->io_attr.num_blocks + << ilog2(cmd->io_attr.vd_entry->sectorSize); #else blocks = cmd->io_attr.num_blocks * cmd->io_attr.vd_entry->sectorSize; #endif - blocks = blocks >> ps3_blocksize_to_shift(cmd->io_attr.pd_entry->sector_size); + blocks = blocks >> + ps3_blocksize_to_shift(cmd->io_attr.pd_entry->sector_size); ps3_scsih_cdb_rebuild(cmd->io_attr.cdb, cmd->scmd->cmd_len, blocks, - (U32)cmd->io_attr.plba, (U32)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); + (unsigned int)cmd->io_attr.plba, + (unsigned int)(cmd->io_attr.plba >> + PS3_SHIFT_DWORD)); } -S32 ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) +int ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - switch(cmd->io_attr.pd_entry->dev_type) { + switch (cmd->io_attr.pd_entry->dev_type) { case PS3_DEV_TYPE_SAS_SSD: case PS3_DEV_TYPE_SAS_HDD: ps3_sas_cdb_build(cmd); @@ -1887,199 +2067,222 @@ S32 ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd) return ret; } -static inline U32 ps3_scsih_data_direction_build(const struct ps3_cmd *cmd) +static inline unsigned int +ps3_scsih_data_direction_build(const struct ps3_cmd *cmd) { - U32 ret; + unsigned int ret; static unsigned long j; - if((cmd->scmd->sc_data_direction == DMA_BIDIRECTIONAL) - || (cmd->scmd->sc_data_direction == DMA_TO_DEVICE)){ + + if ((cmd->scmd->sc_data_direction == DMA_BIDIRECTIONAL) || + (cmd->scmd->sc_data_direction == DMA_TO_DEVICE)) { ret = PS3_DATA_DIRECTION_WRITE; - } else if((cmd->scmd->sc_data_direction == DMA_FROM_DEVICE) - || (cmd->scmd->sc_data_direction == DMA_NONE)){ + } else if ((cmd->scmd->sc_data_direction == DMA_FROM_DEVICE) || + (cmd->scmd->sc_data_direction == DMA_NONE)) { ret = PS3_DATA_DIRECTION_READ; } else { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx date direction:%d check NOK", - PS3_HOST(cmd->instance),cmd->trace_id, cmd->scmd->sc_data_direction); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u tid:0x%llx date direction:%d check NOK", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->scmd->sc_data_direction); ret = PS3_DATA_DIRECTION_WRITE; } return ret; } -static S32 ps3_scsih_vd_frontend_req_build(struct ps3_cmd *cmd, - PS3FrontEndReqFrame_s *req, U16 sge_count) +static int ps3_scsih_vd_frontend_req_build(struct ps3_cmd *cmd, + struct PS3FrontEndReqFrame *req, + unsigned short sge_count) { - S32 ret = PS3_SUCCESS; - struct ps3_scsi_priv_data *p_priv_data = scsi_device_private_data(cmd->scmd); + int ret = PS3_SUCCESS; + struct ps3_scsi_priv_data *p_priv_data = + scsi_device_private_data(cmd->scmd); ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); req->dataXferLen = cmd->io_attr.sgl_buf_len; req->sgeCount = sge_count; - req->sgeOffset = offsetof(PS3FrontEndReqFrame_s, sgl) >> 2; - if(cmd->io_attr.seq_flag == SCSI_RW_UNUSED_CMD && - cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL) { + req->sgeOffset = offsetof(struct PS3FrontEndReqFrame, sgl) >> 2; + if (cmd->io_attr.seq_flag == SCSI_RW_UNUSED_CMD && + cmd->instance->ioc_adpter->scsih_stream_is_detect != NULL) { cmd->instance->ioc_adpter->scsih_stream_is_detect(cmd); } - req->vdAccAttr.isStream = ((cmd->io_attr.seq_flag == SCSI_RW_SEQ_CMD)?(1):(0)); + req->vdAccAttr.isStream = + ((cmd->io_attr.seq_flag == SCSI_RW_SEQ_CMD) ? (1) : (0)); if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - req->vdAccAttr.ioOutStandingCnt = (U16)ps3_atomic_read(&p_priv_data->rd_io_outstand); + req->vdAccAttr.ioOutStandingCnt = + (unsigned short)ps3_atomic_read( + &p_priv_data->rd_io_outstand); } if (ps3_scsih_is_vd_accelerate(cmd)) { - LOG_DEBUG("tid:0x%llx hno:%u cmd_type:%d CFID:%d " - "ret:%d vlba->plba:0x%llx\n", - cmd->trace_id, PS3_HOST(cmd->instance), - req->reqHead.cmdType, cmd->index, ret, cmd->io_attr.plba); + LOG_DEBUG("tid:0x%llx hno:%u cmd_type:%d CFID:%d\n" + "\tret:%d vlba->plba:0x%llx\n", + cmd->trace_id, PS3_HOST(cmd->instance), + req->reqHead.cmdType, cmd->index, ret, + cmd->io_attr.plba); } return ret; } -static inline void ps3_align_16bytes_check(U64 addr) +static inline void ps3_align_16bytes_check(unsigned long long addr) { - if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) { + if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) LOG_ERROR_LIM("addr:0x%llx not align\n", addr); - } } -static inline void ps3_align_4bytes_check(U64 addr) +static inline void ps3_align_4bytes_check(unsigned long long addr) { - if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) { + if (unlikely(addr & PS3_SCSI_ALINNMENT_MASK)) LOG_ERROR_LIM("addr:0x%llx not align\n", addr); - } } -static inline Bool ps3_is_invalid_ossgl_count(U16 valid_os_sge_count, - U16 max_drv_sge_count) +static inline unsigned char +ps3_is_invalid_ossgl_count(unsigned short valid_os_sge_count, + unsigned short max_drv_sge_count) { return (max_drv_sge_count < valid_os_sge_count + 1); } static inline void ps3_last_sge_build(struct PS3Sge *sgl_ptr, - const ps3_scatter_gather_element *os_sgl) + const struct scatterlist *os_sgl) { - sgl_ptr->length = cpu_to_le32(sg_dma_len(os_sgl)); - sgl_ptr->addr = cpu_to_le64(sg_dma_address_u64(os_sgl)); - sgl_ptr->lastSge = 1; - sgl_ptr->ext = 0; + sgl_ptr->length = cpu_to_le32(sg_dma_len(os_sgl)); + sgl_ptr->addr = cpu_to_le64(sg_dma_address_u64(os_sgl)); + sgl_ptr->lastSge = 1; + sgl_ptr->ext = 0; - return ; } -static inline Bool ps3_is_last_sge(S32 sgl_idx, U16 os_sge_count) +static inline unsigned char ps3_is_last_sge(int sgl_idx, + unsigned short os_sge_count) { return ((sgl_idx + 1) == os_sge_count); } -static inline Bool ps3_is_list_sge(S32 sgl_idx, U16 frame_sge_count) +static inline unsigned char ps3_is_list_sge(int sgl_idx, + unsigned short frame_sge_count) { return ((sgl_idx + 1) == frame_sge_count); } static inline void ps3_list_sge_build(struct PS3Sge *sgl_ptr, - const struct ps3_cmd *cmd, U16 ext_sge_size) + const struct ps3_cmd *cmd, + unsigned short ext_sge_size) { - sgl_ptr->length = ext_sge_size; - sgl_ptr->addr = cpu_to_le64(cmd->ext_buf_phys); + sgl_ptr->length = ext_sge_size; + sgl_ptr->addr = cpu_to_le64(cmd->ext_buf_phys); sgl_ptr->lastSge = 0; - sgl_ptr->ext = 1; + sgl_ptr->ext = 1; - return; } -static U32 ps3_scsih_data_buf_len(struct ps3_cmd *cmd, U32 os_sge_count) +static unsigned int ps3_scsih_data_buf_len(struct ps3_cmd *cmd, + unsigned int os_sge_count) { struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *os_sgl = NULL; - U32 index = 0; + struct scatterlist *os_sgl = NULL; + unsigned int index = 0; cmd->io_attr.sgl_buf_len = 0; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { cmd->io_attr.sgl_buf_len += sg_dma_len(os_sgl); - mb(); + mb(); /* in order to force CPU ordering */ } if (scsi_bufflen(scp) != cmd->io_attr.sgl_buf_len) { - LOG_INFO("data_buf:%u buf_len:%u mismatch\n", - scsi_bufflen(scp), cmd->io_attr.sgl_buf_len); + LOG_INFO("data_buf:%u buf_len:%u mismatch\n", scsi_bufflen(scp), + cmd->io_attr.sgl_buf_len); } return cmd->io_attr.sgl_buf_len; } -static inline U16 ps3_drv_max_sge_count(const struct ps3_cmd *cmd, - U16 frame_sge_count) +static inline unsigned short +ps3_drv_max_sge_count(const struct ps3_cmd *cmd, unsigned short frame_sge_count) { - U16 count = 0; + unsigned short count = 0; if (cmd->instance->cmd_context.sgl_mode_support) { - count = ((U16)cmd->instance->cmd_context.ext_sge_frame_count + - frame_sge_count); + count = ((unsigned short)cmd->instance->cmd_context + .ext_sge_frame_count + + frame_sge_count); } else { - count = PS3_MAX((U16)cmd->instance->cmd_context.ext_sge_frame_count + 1, - frame_sge_count); + count = PS3_MAX((unsigned short)cmd->instance->cmd_context + .ext_sge_frame_count + + 1, + frame_sge_count); } return count; } -static inline U16 ps3_scsih_frame_ext_sge_pos(const struct ps3_cmd *cmd, - U16 frame_sge_count, U16 os_sge_count) +static inline unsigned short +ps3_scsih_frame_ext_sge_pos(const struct ps3_cmd *cmd, + unsigned short frame_sge_count, + unsigned short os_sge_count) { - U16 pos = 0; + unsigned short pos = 0; - if (cmd->instance->cmd_context.sgl_mode_support) { + if (cmd->instance->cmd_context.sgl_mode_support) pos = frame_sge_count; - } else { + else pos = (os_sge_count <= frame_sge_count) ? 0 : 1; - } return pos; } -static inline U16 ps3_scsih_ext_sge_size_calc(U16 ext_sge_pos, - U16 frame_sge_count, U16 os_sge_count) +static inline unsigned short +ps3_scsih_ext_sge_size_calc(unsigned short ext_sge_pos, + unsigned short frame_sge_count, + unsigned short os_sge_count) { - U16 cnt = 0; + unsigned short cnt = 0; - if (ext_sge_pos == 0) { + if (ext_sge_pos == 0) cnt = 0; - } else if (ext_sge_pos == 1) { + else if (ext_sge_pos == 1) cnt = os_sge_count; - } else { + else cnt = os_sge_count - frame_sge_count + 1; - } return cnt * sizeof(struct PS3Sge); } -static U16 ps3_scsih_sgl_build(struct ps3_cmd *cmd, struct PS3Sge *sge, - U8 frame_sge_count) +static unsigned short ps3_scsih_sgl_build(struct ps3_cmd *cmd, + struct PS3Sge *sge, + unsigned char frame_sge_count) { - S32 index = 0; - U16 max_drv_sge_count = 0; - U16 os_sge_count = cmd->os_sge_map_count; + int index = 0; + unsigned short max_drv_sge_count = 0; + unsigned short os_sge_count = cmd->os_sge_map_count; struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *os_sgl = NULL; + struct scatterlist *os_sgl = NULL; struct PS3Sge *sge_ptr = sge; - U16 ret_sge_count = 0; - U16 ext_sge_pos = 0; - U16 ext_sge_size = 0; + unsigned short ret_sge_count = 0; + unsigned short ext_sge_pos = 0; + unsigned short ext_sge_size = 0; static unsigned long j; + cmd->io_attr.sgl_buf_len = 0; max_drv_sge_count = ps3_drv_max_sge_count(cmd, frame_sge_count); if (unlikely(ps3_is_invalid_ossgl_count(os_sge_count, - max_drv_sge_count))) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u io is " - "too huge max_drv_sge_count:%d os_sge_count:%u\n", + max_drv_sge_count))) { + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%u io is\n" + "\ttoo huge max_drv_sge_count:%d os_sge_count:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, - max_drv_sge_count , os_sge_count); + max_drv_sge_count, os_sge_count); goto l_out; } - memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); - ext_sge_pos = ps3_scsih_frame_ext_sge_pos(cmd, frame_sge_count, os_sge_count); + memset(&cmd->req_frame->hwReq.sgl, 0, + sizeof(cmd->req_frame->hwReq.sgl)); + ext_sge_pos = + ps3_scsih_frame_ext_sge_pos(cmd, frame_sge_count, os_sge_count); ext_sge_size = ps3_scsih_ext_sge_size_calc(ext_sge_pos, frame_sge_count, - os_sge_count); + os_sge_count); ret_sge_count = os_sge_count; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { @@ -2088,13 +2291,13 @@ static U16 ps3_scsih_sgl_build(struct ps3_cmd *cmd, struct PS3Sge *sge, cmd->io_attr.sgl_buf_len += sge_ptr->length; ps3_align_4bytes_check(sge_ptr->addr); LOG_DEBUG("sgl addr:0x%llx len:%d\n", sge_ptr->addr, - sge_ptr->length); + sge_ptr->length); break; } if (ps3_is_list_sge(index, ext_sge_pos)) { ps3_list_sge_build(sge_ptr, cmd, ext_sge_size); - sge_ptr = (struct PS3Sge*)cmd->ext_buf; + sge_ptr = (struct PS3Sge *)cmd->ext_buf; ret_sge_count += 1; } @@ -2111,13 +2314,14 @@ static U16 ps3_scsih_sgl_build(struct ps3_cmd *cmd, struct PS3Sge *sge, return ret_sge_count; } -static S32 ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) +static int ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; - U16 sge_count = 0; + int ret = PS3_SUCCESS; + struct PS3FrontEndReqFrame *req = &cmd->req_frame->frontendReq; + unsigned short sge_count = 0; static unsigned long j; - memset(&req->reserved, 0 , sizeof(req->reserved)); + + memset(&req->reserved, 0, sizeof(req->reserved)); req->vdAccAttr.isAccActive = 0; req->vdAccAttr.reserved1 = 0; memset(&req->vdAccAttr.reserved2, 0, sizeof(req->vdAccAttr.reserved2)); @@ -2128,36 +2332,45 @@ static S32 ps3_vd_normal_req_frame_build(struct ps3_cmd *cmd) sge_count = ps3_scsih_frontend_data_buf_build(cmd, req); if (sge_count == 0 && cmd->os_sge_map_count != 0) { ret = -PS3_FAILED; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " - "os_sge_count:%u\n", PS3_HOST(cmd->instance), - cmd->trace_id, sge_count, cmd->os_sge_map_count); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u tid:0x%llx drv_sge_count:%u os_sge_count:%u\n", + PS3_HOST(cmd->instance), + cmd->trace_id, sge_count, + cmd->os_sge_map_count); goto l_out; } } ret = ps3_scsih_vd_frontend_req_build(cmd, req, sge_count); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%d ret:%d frondend build NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%d ret:%d frondend build NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + ret); } l_out: return ret; } -static inline S32 ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) +static inline int ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; static unsigned long j; + cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; cmd->io_attr.is_use_frontend_prp = PS3_FALSE; - memset((void *) &cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); + memset((void *)&cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); ret = ps3_scsih_vd_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, + ret); ret = -PS3_FAILED; goto l_out; } @@ -2168,19 +2381,23 @@ static inline S32 ps3_vd_adv_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) return ret; } -static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; static unsigned long j; + if ((cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_OK) || - (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_ADVICE)) { + (cmd->io_attr.direct_flag == PS3_CMDWORD_DIRECT_ADVICE)) { ret = ps3_vd_direct_req_frame_build(cmd); - if ((ret != PS3_SUCCESS) && - (cmd->io_attr.pd_entry->dev_type == PS3_DEV_TYPE_NVME_SSD) ) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal" - "is_use_frontend_prp:%d\n", cmd->trace_id, - PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); + if ((ret != PS3_SUCCESS) && (cmd->io_attr.pd_entry->dev_type == + PS3_DEV_TYPE_NVME_SSD)) { + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u advice direct NVMe vd NOK, to normal\n" + "\tis_use_frontend_prp:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->io_attr.is_use_frontend_prp); ret = ps3_vd_adv_to_normal_req_frame_rebuild(cmd); } } else { @@ -2189,35 +2406,39 @@ static S32 ps3_scsih_vd_req_frame_build(struct ps3_cmd *cmd) return ret; } -static S32 ps3_software_zone_build(struct ps3_cmd *cmd, - U64 virtDiskLba, U8 type, U16 sge_count) +static int ps3_software_zone_build(struct ps3_cmd *cmd, + unsigned long long virtDiskLba, + unsigned char type, unsigned short sge_count) { - PS3SoftwareZone_s *zone = NULL; - U32 num_blocks = cmd->io_attr.num_blocks; - S32 ret = PS3_SUCCESS; + struct PS3SoftwareZone *zone = NULL; + unsigned int num_blocks = cmd->io_attr.num_blocks; + int ret = PS3_SUCCESS; static unsigned long j; - INJECT_START(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKOWN, &type); - if(unlikely((type < PS3_DEV_TYPE_SAS_HDD) || - (type >= PS3_DEV_TYPE_COUNT))) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u type:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), type); + + INJECT_START(PS3_ERR_IJ_SOFT_ZONE_TYPE_SET_UNKNOWN, &type); + if (unlikely((type < PS3_DEV_TYPE_SAS_HDD) || + (type >= PS3_DEV_TYPE_COUNT))) { + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u type:%d\n", cmd->trace_id, + PS3_HOST(cmd->instance), type); ret = -PS3_FAILED; goto l_ret; } zone = &cmd->req_frame->hwReq.softwareZone; - ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &zone->opcode, &zone->subOpcode); + ps3_scsih_cdb_opcode_get(cmd->scmd->cmnd, &zone->opcode, + &zone->subOpcode); zone->virtDiskLba = cpu_to_le64(virtDiskLba); zone->numBlocks = cpu_to_le32(num_blocks); zone->sgeCount = sge_count; - if( type == PS3_DEV_TYPE_NVME_SSD) { + if (type == PS3_DEV_TYPE_NVME_SSD) { zone->sglOffset = offsetof(struct PS3NvmeCmdDw0_9, dPtr) >> 2; - zone->sglFormat = 1; + zone->sglFormat = 1; } else { zone->sglOffset = offsetof(struct PS3HwReqFrame, sgl) >> 2; - zone->sglFormat = 0; + zone->sglFormat = 0; } zone->isResendCmd = 0; @@ -2225,31 +2446,28 @@ static S32 ps3_software_zone_build(struct ps3_cmd *cmd, return ret; } -static Bool ps3_prp_build_check(struct ps3_cmd *cmd, U32 data_len) +static unsigned char ps3_prp_build_check(struct ps3_cmd *cmd, + unsigned int data_len) { struct scsi_cmnd *scmd = cmd->scmd; - Bool prp_convert_support = PS3_TRUE; - S32 index = 0; - U16 total_sge_count = cmd->os_sge_map_count; - U32 nvme_page_size = cmd->instance->cmd_attr.nvme_page_size; - ps3_scatter_gather_element *sge_ptr = scsi_sglist(scmd); - U64 sge_addr = 0; - U32 first_prp_len = 0; - U32 nvme_page_size_mask = nvme_page_size - 1; + unsigned char prp_convert_support = PS3_TRUE; + int index = 0; + unsigned short total_sge_count = cmd->os_sge_map_count; + unsigned int nvme_page_size = cmd->instance->cmd_attr.nvme_page_size; + struct scatterlist *sge_ptr = scsi_sglist(scmd); + unsigned long long sge_addr = 0; + unsigned int first_prp_len = 0; + unsigned int nvme_page_size_mask = nvme_page_size - 1; static unsigned long j; (void)data_len; - LOG_DEBUG("hno:%u CFID:%u sge_count:%u\n", - PS3_HOST(cmd->instance), cmd->index, total_sge_count); + LOG_DEBUG("hno:%u CFID:%u sge_count:%u\n", PS3_HOST(cmd->instance), + cmd->index, total_sge_count); scsi_for_each_sg(scmd, sge_ptr, total_sge_count, index) { sge_addr = sg_dma_address(sge_ptr); -#if 0 - LOG_DEBUG("hno:%u CFID:%u index:%u sge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), cmd->index, index, sge_addr, - sg_dma_len(sge_ptr)); -#endif if (index == 0) { - first_prp_len = nvme_page_size - (sge_addr & nvme_page_size_mask); + first_prp_len = nvme_page_size - + (sge_addr & nvme_page_size_mask); if (first_prp_len >= sg_dma_len(sge_ptr)) { prp_convert_support = PS3_TRUE; break; @@ -2258,34 +2476,49 @@ static Bool ps3_prp_build_check(struct ps3_cmd *cmd, U32 data_len) if (total_sge_count <= 1) { prp_convert_support = PS3_TRUE; break; - } else if (ps3_utility_mod64(sge_addr + sg_dma_len(sge_ptr), - nvme_page_size)) { + } else if (ps3_utility_mod64( + sge_addr + sg_dma_len(sge_ptr), + nvme_page_size)) { prp_convert_support = PS3_FALSE; - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " - "sge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), cmd->index, - index, sge_addr, sg_dma_len(sge_ptr)); + LOG_WARN_TIME_LIM(&j, + PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u CFID:%u index:%u\n" + "\tsge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), + cmd->index, index, sge_addr, + sg_dma_len(sge_ptr)); break; } } else { - if ((total_sge_count > 1) && (index == (total_sge_count - 1))) { - if (ps3_utility_mod64(sge_addr, nvme_page_size)) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u CFID:%u index:%u " - "sge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), cmd->index, - index, sge_addr, sg_dma_len(sge_ptr)); + if ((total_sge_count > 1) && + (index == (total_sge_count - 1))) { + if (ps3_utility_mod64(sge_addr, + nvme_page_size)) { + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u CFID:%u index:%u\n" + "\tsge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), + cmd->index, index, sge_addr, + sg_dma_len(sge_ptr)); prp_convert_support = PS3_FALSE; break; } } - if ((total_sge_count > 1) && (index != (total_sge_count - 1))) { - if (ps3_utility_mod64(sg_dma_len(sge_ptr), nvme_page_size) || - ps3_utility_mod64(sge_addr, nvme_page_size)) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "middle hno:%u CFID:%u index:%u " - "sge_addr:0x%llx len:%u\n", - PS3_HOST(cmd->instance), cmd->index, - index, sge_addr, sg_dma_len(sge_ptr)); + if ((total_sge_count > 1) && + (index != (total_sge_count - 1))) { + if (ps3_utility_mod64(sg_dma_len(sge_ptr), + nvme_page_size) || + ps3_utility_mod64(sge_addr, + nvme_page_size)) { + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "middle hno:%u CFID:%u index:%u\n" + "\tsge_addr:0x%llx len:%u\n", + PS3_HOST(cmd->instance), + cmd->index, index, sge_addr, + sg_dma_len(sge_ptr)); prp_convert_support = PS3_FALSE; break; } @@ -2296,37 +2529,44 @@ static Bool ps3_prp_build_check(struct ps3_cmd *cmd, U32 data_len) return prp_convert_support; } -static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, - U8 frame_prp_count, U32 data_len, Bool is_need_clean_sgl) +static unsigned short ps3_scsih_prp_build(struct ps3_cmd *cmd, + unsigned long long *prp_ptr, + unsigned char frame_prp_count, + unsigned int data_len, + unsigned char is_need_clean_sgl) { struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *sge_scmd = scsi_sglist(scp); - U32 page_size = cmd->instance->cmd_attr.nvme_page_size; - U32 nvme_page_size_mask = page_size - 1; - U32 sge_len = sg_dma_len(sge_scmd); - U64 sge_addr = sg_dma_address_u64(sge_scmd); - U32 first_prp_len = 0; - U16 prp_entry_count = 0; + struct scatterlist *sge_scmd = scsi_sglist(scp); + unsigned int page_size = cmd->instance->cmd_attr.nvme_page_size; + unsigned int nvme_page_size_mask = page_size - 1; + unsigned int sge_len = sg_dma_len(sge_scmd); + unsigned long long sge_addr = sg_dma_address_u64(sge_scmd); + unsigned int first_prp_len = 0; + unsigned short prp_entry_count = 0; static unsigned long j; + if (is_need_clean_sgl) { - memset(&cmd->req_frame->hwReq.sgl, 0, sizeof(cmd->req_frame->hwReq.sgl)); + memset(&cmd->req_frame->hwReq.sgl, 0, + sizeof(cmd->req_frame->hwReq.sgl)); } *prp_ptr = sge_addr; prp_entry_count++; first_prp_len = page_size - (sge_addr & nvme_page_size_mask); - LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx data_len:%u sge_len:%u" - "first_max_prp_len:%u\n", PS3_HOST(cmd->instance), - cmd->index, sge_addr, data_len, sge_len, first_prp_len); + LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx data_len:%u sge_len:%u\n" + "\tfirst_max_prp_len:%u\n", + PS3_HOST(cmd->instance), cmd->index, sge_addr, data_len, + sge_len, first_prp_len); - data_len = (data_len > first_prp_len)? (data_len - first_prp_len) : 0; - if (data_len <= 0) { + data_len = (data_len > first_prp_len) ? (data_len - first_prp_len) : 0; + if (data_len <= 0) goto l_out; - } if (sge_len > first_prp_len) { sge_addr += first_prp_len; - sge_len = (sge_len > first_prp_len) ? (sge_len - first_prp_len) : 0 ; + sge_len = (sge_len > first_prp_len) ? + (sge_len - first_prp_len) : + 0; } else { sge_scmd = sg_next(sge_scmd); sge_len = sg_dma_len(sge_scmd); @@ -2337,10 +2577,15 @@ static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, frame_prp_count--; for (;;) { - if (prp_entry_count > cmd->instance->cmd_context.max_prp_count) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u prp_entry_count:%u " - "max_prp_count:%u\n", cmd->trace_id, PS3_HOST(cmd->instance), - cmd->index, prp_entry_count, cmd->instance->cmd_context.max_prp_count); + if (prp_entry_count > + cmd->instance->cmd_context.max_prp_count) { + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%u prp_entry_count:%u\n" + "\tmax_prp_count:%u\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, prp_entry_count, + cmd->instance->cmd_context.max_prp_count); prp_entry_count = 0; goto l_out; } @@ -2348,7 +2593,7 @@ static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, if (frame_prp_count == 1) { if (data_len > page_size) { *prp_ptr = cmd->ext_buf_phys; - prp_ptr = (U64*)cmd->ext_buf; + prp_ptr = (unsigned long long *)cmd->ext_buf; prp_entry_count++; } frame_prp_count--; @@ -2359,22 +2604,24 @@ static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, sge_len = (sge_len > page_size) ? (sge_len - page_size) : 0; data_len = (data_len > page_size) ? (data_len - page_size) : 0; - if (frame_prp_count > 0) { + if (frame_prp_count > 0) frame_prp_count--; - } if (data_len <= 0) { - LOG_DEBUG("end hno:%u CFID:%u data_len:%u prp_entry:0x%llx " - "sge_addr:0x%llx sge_len:%u prp_entry_count:%u\n", - PS3_HOST(cmd->instance), cmd->index, data_len, *prp_ptr, - sge_addr, sge_len, prp_entry_count); + LOG_DEBUG( + "end hno:%u CFID:%u data_len:%u prp_entry:0x%llx\n" + "\tsge_addr:0x%llx sge_len:%u prp_entry_count:%u\n", + PS3_HOST(cmd->instance), cmd->index, data_len, + *prp_ptr, sge_addr, sge_len, prp_entry_count); break; } if (unlikely(cmd->instance->is_print_special_log)) { - LOG_DEBUG("end hno:%u CFID:%u data_len:%u prp_entry:0x%llx " - "sge_addr:0x%llx sge_len:%u\n", PS3_HOST(cmd->instance), - cmd->index, data_len, *prp_ptr, sge_addr, sge_len); + LOG_DEBUG( + "end hno:%u CFID:%u data_len:%u prp_entry:0x%llx\n" + "\tsge_addr:0x%llx sge_len:%u\n", + PS3_HOST(cmd->instance), cmd->index, data_len, + *prp_ptr, sge_addr, sge_len); } prp_ptr++; @@ -2392,20 +2639,23 @@ static U16 ps3_scsih_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, return prp_entry_count; } -static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, - U32 data_len, U16 prp_count) +static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, + unsigned long long *prp_ptr, + unsigned int data_len, + unsigned short prp_count) { struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *sge_scmd = scsi_sglist(scp); + struct scatterlist *sge_scmd = scsi_sglist(scp); struct PS3Sge *sge_ptr = (struct PS3Sge *)prp_ptr; - U32 page_size = cmd->instance->cmd_attr.nvme_page_size; - U32 nvme_page_size_mask = page_size - 1; - U32 first_prp_len = 0; - U32 sge_len = sg_dma_len(sge_scmd); - U64 sge_addr = sg_dma_address_u64(sge_scmd); + unsigned int page_size = cmd->instance->cmd_attr.nvme_page_size; + unsigned int nvme_page_size_mask = page_size - 1; + unsigned int first_prp_len = 0; + unsigned int sge_len = sg_dma_len(sge_scmd); + unsigned long long sge_addr = sg_dma_address_u64(sge_scmd); - first_prp_len = page_size - (sg_dma_address_u64(sge_scmd) & nvme_page_size_mask); - data_len = (data_len > first_prp_len)? (data_len - first_prp_len) : 0; + first_prp_len = page_size - + (sg_dma_address_u64(sge_scmd) & nvme_page_size_mask); + data_len = (data_len > first_prp_len) ? (data_len - first_prp_len) : 0; sge_ptr->length = first_prp_len; sge_ptr->addr = sge_addr; @@ -2414,15 +2664,17 @@ static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, ps3_align_16bytes_check(sge_ptr->addr); LOG_DEBUG("hno:%u CFID:%u sge0_addr:0x%llx sge_len:%u\n", - PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, sge_ptr->length); + PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, + sge_ptr->length); - if(data_len <= 0){ + if (data_len <= 0) goto l_out; - } if (sge_len > first_prp_len) { sge_addr += first_prp_len; - sge_len = (sge_len > first_prp_len) ? (sge_len - first_prp_len) : 0 ; + sge_len = (sge_len > first_prp_len) ? + (sge_len - first_prp_len) : + 0; } else { sge_scmd = sg_next(sge_scmd); sge_len = sg_dma_len(sge_scmd); @@ -2439,63 +2691,64 @@ static void ps3_scsih_frontend_prp_build(struct ps3_cmd *cmd, U64 *prp_ptr, ps3_align_16bytes_check(sge_ptr->addr); goto l_out; } else { - sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * sizeof(U64); + sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * + sizeof(unsigned long long); sge_ptr->addr = cmd->ext_buf_phys; sge_ptr->lastSge = 0; sge_ptr->ext = 1; sge_ptr = (struct PS3Sge *)prp_ptr; sge_ptr = sge_ptr + PS3_FRAME_REQ_SGE_NUM_FE - 1; - sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * sizeof(U64); + sge_ptr->length = (prp_count - PS3_FRAME_REQ_PRP_NUM_FE) * + sizeof(unsigned long long); sge_ptr->addr = cmd->ext_buf_phys; sge_ptr->lastSge = 0; sge_ptr->ext = 1; } LOG_DEBUG("hno:%u CFID:%u sge1_addr:0x%llx sge_len:%u sge_ext:%d\n", - PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, sge_ptr->length, sge_ptr->ext); + PS3_HOST(cmd->instance), cmd->index, sge_ptr->addr, + sge_ptr->length, sge_ptr->ext); l_out: - return ; + return; } -static inline S32 ps3_scsih_prp_len_check(struct ps3_cmd *cmd, U32 data_len) +static inline int ps3_scsih_prp_len_check(struct ps3_cmd *cmd, + unsigned int data_len) { - S32 ret = PS3_SUCCESS; - U32 max_prp_count = cmd->instance->cmd_context.max_prp_count; - U64 max_nvme_data_size = (U64)(max_prp_count - (U32)PS3_FRAME_REQ_PRP_NUM_FE - 1) * + int ret = PS3_SUCCESS; + unsigned int max_prp_count = cmd->instance->cmd_context.max_prp_count; + unsigned long long max_nvme_data_size = + (unsigned long long)(max_prp_count - + (unsigned int)PS3_FRAME_REQ_PRP_NUM_FE - + 1) * cmd->instance->cmd_attr.nvme_page_size; static unsigned long j; + if (unlikely(max_nvme_data_size < data_len)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u io is too huge " - "[max_nvme_data_size:%llu][data_len:%d]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - max_nvme_data_size , data_len); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u io is too huge\n" + "\t[max_nvme_data_size:%llu][data_len:%d]\n", + cmd->trace_id, PS3_HOST(cmd->instance), + max_nvme_data_size, data_len); ret = -PS3_FAILED; } return ret; } -#if 0 -static U16 ps3_scsih_nvme_normal_cmd_split(struct ps3_cmd *cmd, - PS3FrontEndReqFrame_s *req, U32 data_len) +static unsigned short +ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, + struct PS3FrontEndReqFrame *req) { - U16 prp_count = 0; - - (void)cmd; - (void)req; - (void)data_len; - - return prp_count; -} -#endif -static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, - PS3FrontEndReqFrame_s *req) -{ - U16 sge_count = 0; - U32 data_len = 0; + unsigned short sge_count = 0; + unsigned int data_len = 0; static unsigned long j; + if (cmd->io_attr.is_use_frontend_prp) { if (cmd->os_sge_map_count == 0) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u os_sge_map_count==0\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%u os_sge_map_count==0\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index); sge_count = 0; goto l_out; } @@ -2506,36 +2759,36 @@ static U16 ps3_scsih_frontend_data_buf_build(struct ps3_cmd *cmd, } if (ps3_prp_build_check(cmd, data_len)) { - sge_count = ps3_scsih_prp_build(cmd, &req->prp.prp1, - PS3_FRAME_REQ_PRP_NUM_FE, data_len, PS3_TRUE); + sge_count = + ps3_scsih_prp_build(cmd, &req->prp.prp1, + PS3_FRAME_REQ_PRP_NUM_FE, + data_len, PS3_TRUE); ps3_scsih_frontend_prp_build(cmd, &req->prp.prp1, - data_len, sge_count); + data_len, sge_count); } else { -#if 0 - LOG_WARN("tid:0x%llx hno:%u CFID:%u need split cmd\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); - - sge_count = ps3_scsih_nvme_normal_cmd_split(cmd, req, data_len); -#else - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u CFID:%u nvme prp change to sgl\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index); + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u CFID:%u nvme prp change to sgl\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index); sge_count = 0; -#endif } } else { - sge_count = ps3_scsih_sgl_build(cmd, req->sgl, PS3_FRAME_REQ_SGE_NUM_FE); + sge_count = ps3_scsih_sgl_build(cmd, req->sgl, + PS3_FRAME_REQ_SGE_NUM_FE); } l_out: return sge_count; } -static S32 ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) +static int ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - PS3FrontEndReqFrame_s *req = &cmd->req_frame->frontendReq; + int ret = PS3_SUCCESS; + struct PS3FrontEndReqFrame *req = &cmd->req_frame->frontendReq; static unsigned long j; + ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_FRONTEND); memset(&req->reserved, 0, sizeof(req->reserved)); @@ -2550,26 +2803,30 @@ static S32 ps3_scsih_pd_frontend_req_build(struct ps3_cmd *cmd) req->sgeCount = ps3_scsih_frontend_data_buf_build(cmd, req); if (req->sgeCount == 0 && cmd->os_sge_map_count != 0) { ret = -PS3_FAILED; - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u tid:0x%llx drv_sge_count:%u " - "os_sge_count:%u\n", PS3_HOST(cmd->instance), - cmd->trace_id, req->sgeCount, cmd->os_sge_map_count); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u tid:0x%llx drv_sge_count:%u\n" + "\tos_sge_count:%u\n", + PS3_HOST(cmd->instance), + cmd->trace_id, req->sgeCount, + cmd->os_sge_map_count); goto l_out; } } memcpy(req->cdb, cmd->scmd->cmnd, cmd->scmd->cmd_len); - req->sgeOffset = offsetof(PS3FrontEndReqFrame_s, sgl) >> 2; + req->sgeOffset = offsetof(struct PS3FrontEndReqFrame, sgl) >> 2; req->dataXferLen = cmd->io_attr.sgl_buf_len; l_out: return ret; } -static U16 ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) +static unsigned short ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) { - U32 time_s = SCMD_GET_REQUEST(cmd->scmd)->timeout / HZ; - U16 timeout = 0; + unsigned int time_s = SCMD_GET_REQUEST(cmd->scmd)->timeout / HZ; + unsigned short timeout = 0; + if (time_s > 0xfffe) { timeout = 0; return timeout; @@ -2578,53 +2835,72 @@ static U16 ps3_scsi_cmd_timeout_get(struct ps3_cmd *cmd) return timeout; } -static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, U8 req_frame_format) +static void ps3_scsih_req_frame_head_build(struct ps3_cmd *cmd, + unsigned char req_frame_format) { - PS3ReqFrameHead_s *req_head= &cmd->req_frame->hwReq.reqHead; + struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; static unsigned long j; + req_head->reqFrameFormat = req_frame_format; req_head->cmdSubType = 0; req_head->cmdFrameID = cmd->index; req_head->noReplyWord = PS3_CMD_WORD_NEED_REPLY_WORD; - req_head->dataFormat = cmd->io_attr.is_use_frontend_prp || req_frame_format == PS3_REQFRAME_FORMAT_NVME ? \ - PS3_PRP : PS3_SGL; + req_head->dataFormat = + cmd->io_attr.is_use_frontend_prp || + req_frame_format == PS3_REQFRAME_FORMAT_NVME ? + PS3_PRP : + PS3_SGL; req_head->isWrite = ps3_scsih_data_direction_build(cmd); req_head->timeout = ps3_scsi_cmd_timeout_get(cmd); req_head->traceID = cmd->trace_id; +#ifdef PS3_NCQ_PRIO_SUPPORT + if (PS3_IS_NCQ_PRIO_DISK_ENABLE(cmd)) { + req_head->ncq_prio = ps3_scsih_is_io_belongs_to_rt_class(cmd); + } +#endif + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { req_head->devID = cmd->io_attr.vd_entry->diskPos.diskDev; if (unlikely(req_head->devID.diskID == 0)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u chl:%u id:%u dev id:0x%x NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance), PS3_SDEV_CHANNEL(cmd->scmd->device), - PS3_SDEV_TARGET(cmd->scmd->device), req_head->devID.diskID); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u chl:%u id:%u dev id:0x%x NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance), + PS3_SDEV_CHANNEL(cmd->scmd->device), + PS3_SDEV_TARGET(cmd->scmd->device), + req_head->devID.diskID); } req_head->cmdType = ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) ? - PS3_CMD_VD_SCSI_IO_RW : PS3_CMD_VD_SCSI_IO_NORW; + PS3_CMD_VD_SCSI_IO_RW : + PS3_CMD_VD_SCSI_IO_NORW; req_head->virtDiskSeq = cmd->io_attr.vd_entry->virtDiskSeq; - }else { - req_head->devID.diskID = PS3_DISKID(&cmd->io_attr.pd_entry->disk_pos); + } else { + req_head->devID.diskID = + PS3_DISKID(&cmd->io_attr.pd_entry->disk_pos); req_head->mapBlockVer = PS3_CMDWORD_VER_INVALID; req_head->cmdType = ps3_scsih_is_rw_type(cmd->io_attr.rw_flag) ? - PS3_CMD_PD_SCSI_IO_RW : PS3_CMD_PD_SCSI_IO_NORW; + PS3_CMD_PD_SCSI_IO_RW : + PS3_CMD_PD_SCSI_IO_NORW; } - return; } -static inline U64 ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, - U16 sge_count) +static inline unsigned long long +ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, + unsigned short sge_count) { - U64 data_base = 0; + unsigned long long data_base = 0; if (sge_count == PS3_SGL_MODE_SGE_COUNT_DIRECT) { data_base = cmd->req_frame->hwReq.sgl[0].addr; } else if ((sge_count > PS3_FRAME_REQ_SGE_NUM_HW) && - (!cmd->instance->cmd_context.sgl_mode_support)) { - data_base = cmd->ext_buf_phys; - ps3_align_16bytes_check(data_base); + (!cmd->instance->cmd_context.sgl_mode_support)) { + data_base = cmd->ext_buf_phys; + ps3_align_16bytes_check(data_base); } else { - data_base = cmd->req_frame_phys + offsetof(PS3HwReqFrame_s, sgl); + data_base = cmd->req_frame_phys + + offsetof(struct PS3HwReqFrame, sgl); ps3_align_16bytes_check(data_base); } @@ -2632,17 +2908,19 @@ static inline U64 ps3_scsih_direct_sgl_base_addr(const struct ps3_cmd *cmd, } static inline void ps3_scsih_sata_iodt_data_build(struct ps3_cmd *cmd, - U32 sge_count, U64 data_addr) + unsigned int sge_count, + unsigned long long data_addr) { - IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; + struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; struct ps3_scsi_io_attr *cmd_io_attr = &cmd->io_attr; - U16 sector_size = cmd_io_attr->pd_entry->sector_size; + unsigned short sector_size = cmd_io_attr->pd_entry->sector_size; #ifndef _WINDOWS - U32 data_buf_len = cmd_io_attr->num_blocks << ilog2(sector_size); + unsigned int data_buf_len = cmd_io_attr->num_blocks + << ilog2(sector_size); #else - U32 data_buf_len = cmd_io_attr->num_blocks * sector_size; + unsigned int data_buf_len = cmd_io_attr->num_blocks * sector_size; #endif - switch(sge_count) { + switch (sge_count) { case PS3_SGL_MODE_SGE_COUNT_NO_DATA: iodt->dataBufLenDWAlign = 0; iodt->dataBaseAddr = 0; @@ -2650,27 +2928,30 @@ static inline void ps3_scsih_sata_iodt_data_build(struct ps3_cmd *cmd, break; case PS3_SGL_MODE_SGE_COUNT_DIRECT: iodt->dataBaseAddr = cpu_to_le64(data_addr); - iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); + iodt->dataBufLenDWAlign = + cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); iodt->dmaCfg.sgMode = IODT_SGEMODE_DIRECT; break; default: iodt->dataBaseAddr = cpu_to_le64(data_addr); - iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); + iodt->dataBufLenDWAlign = + cpu_to_le32(ENCODE_CCS_XFERLEN(data_buf_len)); iodt->dmaCfg.sgMode = IODT_SGEMODE_SGL; break; } - return; } -static S32 ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, U16 sge_count, U64 data_addr) +static int ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, + unsigned short sge_count, + unsigned long long data_addr) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct ps3_scsi_io_attr *cmd_io_attr = &cmd->io_attr; - IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; - PS3ReqFrameHead_s *req_head = &cmd->req_frame->hwReq.reqHead; - U8 req_frame_format = PS3_REQFRAME_FORMAT_SATA; + struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; + struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; + unsigned char req_frame_format = PS3_REQFRAME_FORMAT_SATA; - memset(iodt, 0, sizeof(IODT_V1_s)); + memset(iodt, 0, sizeof(struct IODT_V1)); ps3_scsih_req_frame_head_build(cmd, req_frame_format); @@ -2701,23 +2982,25 @@ static S32 ps3_scsih_sata_hw_req_frame_build(struct ps3_cmd *cmd, U16 sge_count, return ret; } -static S32 ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U64 lba = 0; - U64 data_addr = 0; - U16 sge_count = 0; + int ret = PS3_SUCCESS; + unsigned long long lba = 0; + unsigned long long data_addr = 0; + unsigned short sge_count = 0; if (ps3_is_need_build_hw_req_frame(cmd)) { sge_count = ps3_scsih_sgl_build(cmd, cmd->req_frame->hwReq.sgl, - PS3_FRAME_REQ_SGE_NUM_HW); + PS3_FRAME_REQ_SGE_NUM_HW); data_addr = ps3_scsih_direct_sgl_base_addr(cmd, sge_count); - ret = ps3_scsih_sata_hw_req_frame_build(cmd, sge_count, data_addr); + ret = ps3_scsih_sata_hw_req_frame_build(cmd, sge_count, + data_addr); if (likely(ret == PS3_SUCCESS)) { cmd->req_frame->hwReq.reqHead.traceID = cmd->trace_id; lba = PS3_LBA(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); - ret = ps3_software_zone_build(cmd, lba, - cmd->io_attr.pd_entry->dev_type, sge_count); + ret = ps3_software_zone_build( + cmd, lba, cmd->io_attr.pd_entry->dev_type, + sge_count); } } else { ret = ps3_scsih_pd_frontend_req_build(cmd); @@ -2727,10 +3010,12 @@ static S32 ps3_scsih_sata_req_frame_build(struct ps3_cmd *cmd) } static inline void ps3_scsih_sas_iodt_data_build(struct ps3_cmd *cmd, - U64 data_addr, U32 sge_count) + unsigned long long data_addr, + unsigned int sge_count) { - IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; - switch(sge_count) { + struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; + + switch (sge_count) { case PS3_SGL_MODE_SGE_COUNT_NO_DATA: iodt->dataBufLenDWAlign = 0; iodt->dataBaseAddr = 0; @@ -2738,33 +3023,35 @@ static inline void ps3_scsih_sas_iodt_data_build(struct ps3_cmd *cmd, break; case PS3_SGL_MODE_SGE_COUNT_DIRECT: - iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32( + ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); iodt->dataBaseAddr = cpu_to_le64(data_addr); iodt->dmaCfg.sgMode = IODT_SGEMODE_DIRECT; break; default: - iodt->dataBufLenDWAlign = cpu_to_le32(ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); + iodt->dataBufLenDWAlign = cpu_to_le32( + ENCODE_CCS_XFERLEN(cmd->io_attr.sgl_buf_len)); iodt->dataBaseAddr = cpu_to_le64(data_addr); iodt->dmaCfg.sgMode = IODT_SGEMODE_SGL; break; } - return; } -static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, U16 disk_id, - U64 data_addr, U32 sge_count) +static int ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, + unsigned short disk_id, + unsigned long long data_addr, + unsigned int sge_count) { - IODT_V1_s *iodt = &cmd->req_frame->hwReq.sasReqFrame; - U8 *cdb = cmd->scmd->cmnd; - S32 ret = PS3_SUCCESS; - PS3ReqFrameHead_s *req_head = &cmd->req_frame->hwReq.reqHead; - U8 req_frame_format = PS3_REQFRAME_FORMAT_SAS; + struct IODT_V1 *iodt = &cmd->req_frame->hwReq.sasReqFrame; + unsigned char *cdb = cmd->scmd->cmnd; + int ret = PS3_SUCCESS; + struct PS3ReqFrameHead *req_head = &cmd->req_frame->hwReq.reqHead; + unsigned char req_frame_format = PS3_REQFRAME_FORMAT_SAS; - if(cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) cdb = cmd->io_attr.cdb; - } - memset(iodt, 0, sizeof(IODT_V1_s)); + memset(iodt, 0, sizeof(struct IODT_V1)); ps3_scsih_req_frame_head_build(cmd, req_frame_format); @@ -2772,11 +3059,10 @@ static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, U16 disk_id, iodt->frameType = FRAMETYPE_DIRECT; iodt->iuSrc = IU_SRC_IODT; - if(cmd->scmd->cmd_len != CMD_LEN_THR) { + if (cmd->scmd->cmd_len != CMD_LEN_THR) iodt->cmdLen = CMD_LEN_S; - } else { + else iodt->cmdLen = CMD_LEN_L; - } memcpy(iodt->B.cdb, cdb, CMD_LEN_THR); @@ -2784,13 +3070,12 @@ static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, U16 disk_id, iodt->sasCtl = 0; - if(cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) { + if (cmd->cmd_word.type == PS3_CMDWORD_TYPE_READ) iodt->commonWord.type = PS3_CMDWORD_TYPE_READ; - } else { + else iodt->commonWord.type = PS3_CMDWORD_TYPE_WRITE; - } - iodt->commonWord.direct = DIRECT_FLAG_DIRECT; + iodt->commonWord.direct = DIRECT_FLAG_DIRECT; iodt->commonWord.function = ps3_get_pci_function(cmd->instance->pdev); iodt->commonWord.phyDiskID = disk_id; iodt->commonWord.reqFrameID = req_head->cmdFrameID; @@ -2799,24 +3084,27 @@ static S32 ps3_scsih_sas_hw_req_frame_build(struct ps3_cmd *cmd, U16 disk_id, return ret; } -static S32 ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U16 sge_count = 0; - U64 data_addr = 0; - U64 lba = 0; + int ret = PS3_SUCCESS; + unsigned short sge_count = 0; + unsigned long long data_addr = 0; + unsigned long long lba = 0; if (ps3_is_need_build_hw_req_frame(cmd)) { - sge_count = ps3_scsih_sgl_build(cmd, - cmd->req_frame->hwReq.sgl, PS3_FRAME_REQ_SGE_NUM_HW); + sge_count = ps3_scsih_sgl_build(cmd, cmd->req_frame->hwReq.sgl, + PS3_FRAME_REQ_SGE_NUM_HW); data_addr = ps3_scsih_direct_sgl_base_addr(cmd, sge_count); - ret = ps3_scsih_sas_hw_req_frame_build(cmd, - PS3_PDID(&cmd->io_attr.pd_entry->disk_pos), + ret = ps3_scsih_sas_hw_req_frame_build( + cmd, PS3_PDID(&cmd->io_attr.pd_entry->disk_pos), data_addr, sge_count); if (likely(ret == PS3_SUCCESS)) { - lba = (U64)cmd->io_attr.lba_hi << PS3_SHIFT_DWORD | cmd->io_attr.lba_lo; - ret = ps3_software_zone_build(cmd, lba, - cmd->io_attr.pd_entry->dev_type, sge_count); + lba = (unsigned long long)cmd->io_attr.lba_hi + << PS3_SHIFT_DWORD | + cmd->io_attr.lba_lo; + ret = ps3_software_zone_build( + cmd, lba, cmd->io_attr.pd_entry->dev_type, + sge_count); } } else { ret = ps3_scsih_pd_frontend_req_build(cmd); @@ -2825,107 +3113,128 @@ static S32 ps3_scsih_sas_req_frame_build(struct ps3_cmd *cmd) } static void ps3_hw_nvme_req_frame_build(struct ps3_cmd *cmd, - PS3HwReqFrame_s *hw_reqframe) + struct PS3HwReqFrame *hw_reqframe) { - PS3NvmeRWCmd_s *rwReqFrame = &hw_reqframe->nvmeReqFrame.rwReqFrame; + struct PS3NvmeRWCmd *rwReqFrame = &hw_reqframe->nvmeReqFrame.rwReqFrame; + rwReqFrame->numLba = cpu_to_le32(cmd->io_attr.num_blocks - 1); - rwReqFrame->numLba |= (U32)((U32)cmd->io_attr.cdb_opts.fua << 30); + rwReqFrame->numLba |= + (unsigned int)((unsigned int)cmd->io_attr.cdb_opts.fua << 30); - rwReqFrame->sLbaHi = cpu_to_le32((U32)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); - rwReqFrame->sLbaLo = cpu_to_le32((U32)(cmd->io_attr.plba)); + rwReqFrame->sLbaHi = cpu_to_le32( + (unsigned int)(cmd->io_attr.plba >> PS3_SHIFT_DWORD)); + rwReqFrame->sLbaLo = cpu_to_le32((unsigned int)(cmd->io_attr.plba)); rwReqFrame->cDW0_9.cID = cpu_to_le16(cmd->index); rwReqFrame->cDW0_9.psdt = 0; rwReqFrame->cDW0_9.nsID = 1; - if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ) { + if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_READ) rwReqFrame->cDW0_9.opcode = 0x02; - } else if(cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) { + else if (cmd->io_attr.rw_flag == PS3_SCSI_CMD_TYPE_WRITE) rwReqFrame->cDW0_9.opcode = 0x01; - } else { - } - LOG_DEBUG("hno:%u cid:%d, op:%d, nsid:%d, prp1:0x%llx, " - "prp2:0x%llx, numLb:%d, LbaHi:0x%x, LbaLo:0x%x, dw13:0x%x, " - "dw13:0x%x, dw13:0x%x\n", - PS3_HOST(cmd->instance), rwReqFrame->cDW0_9.cID, - rwReqFrame->cDW0_9.opcode, rwReqFrame->cDW0_9.nsID, - rwReqFrame->cDW0_9.dPtr.prp.prp1, - rwReqFrame->cDW0_9.dPtr.prp.prp2, - rwReqFrame->numLba, rwReqFrame->sLbaHi, rwReqFrame->sLbaLo, - rwReqFrame->cDW13, rwReqFrame->cDW14, rwReqFrame->cDW15); + LOG_DEBUG("hno:%u cid:%d, op:%d, nsid:%d, prp1:0x%llx,\n" + "\tprp2:0x%llx, numLb:%d, LbaHi:0x%x, LbaLo:0x%x, dw13:0x%x,\n" + "\tdw13:0x%x, dw13:0x%x\n", + PS3_HOST(cmd->instance), rwReqFrame->cDW0_9.cID, + rwReqFrame->cDW0_9.opcode, rwReqFrame->cDW0_9.nsID, + rwReqFrame->cDW0_9.dPtr.prp.prp1, + rwReqFrame->cDW0_9.dPtr.prp.prp2, rwReqFrame->numLba, + rwReqFrame->sLbaHi, rwReqFrame->sLbaLo, rwReqFrame->cDW13, + rwReqFrame->cDW14, rwReqFrame->cDW15); - return ; } -static void ps3_hw_nvme_ext_fill(struct ps3_cmd *cmd, U16 prp_count) +static void ps3_hw_nvme_ext_fill(struct ps3_cmd *cmd, unsigned short prp_count) { if (prp_count > PS3_FRAME_REQ_PRP_NUM_HW) { cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].length = - (prp_count - PS3_FRAME_REQ_PRP_NUM_HW) * sizeof(U64); + (prp_count - PS3_FRAME_REQ_PRP_NUM_HW) * + sizeof(unsigned long long); cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].addr = cmd->ext_buf_phys; - cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].lastSge = 0; + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].lastSge = + 0; cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 1; } else { - if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext != 0) { - cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1].ext = 0; + if (cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1] + .ext != 0) { + cmd->req_frame->hwReq.sgl[PS3_FRAME_REQ_SGE_NUM_HW - 1] + .ext = 0; } } } -static S32 ps3_scsih_nvme_hw_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_nvme_hw_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - U64 * prp_ptr = NULL; - PS3HwReqFrame_s *hw_reqframe = NULL; - U8 pd_dev_type = PS3_DEV_TYPE_COUNT; - U64 lba = 0; - U16 prp_count = 0; - U32 data_len = ps3_scsih_data_buf_len(cmd, cmd->os_sge_map_count); + int ret = PS3_SUCCESS; + unsigned long long *prp_ptr = NULL; + struct PS3HwReqFrame *hw_reqframe = NULL; + unsigned char pd_dev_type = PS3_DEV_TYPE_COUNT; + unsigned long long lba = 0; + unsigned short prp_count = 0; + unsigned int data_len = + ps3_scsih_data_buf_len(cmd, cmd->os_sge_map_count); static unsigned long j; + hw_reqframe = &cmd->req_frame->hwReq; - memset(&hw_reqframe->nvmeReqFrame, 0, sizeof(PS3NvmeReqFrame_u)); + memset(&hw_reqframe->nvmeReqFrame, 0, sizeof(union PS3NvmeReqFrame)); prp_ptr = &hw_reqframe->nvmeReqFrame.rwReqFrame.cDW0_9.dPtr.prp.prp1; ps3_scsih_req_frame_head_build(cmd, PS3_REQFRAME_FORMAT_NVME); - if (cmd->io_attr.pd_entry != NULL) { + if (cmd->io_attr.pd_entry != NULL) pd_dev_type = cmd->io_attr.pd_entry->dev_type; - } if (ps3_prp_build_check(cmd, data_len)) { - prp_count = ps3_scsih_prp_build(cmd, prp_ptr, PS3_FRAME_REQ_PRP_NUM_HW, data_len, PS3_FALSE); + prp_count = ps3_scsih_prp_build(cmd, prp_ptr, + PS3_FRAME_REQ_PRP_NUM_HW, + data_len, PS3_FALSE); ps3_hw_nvme_ext_fill(cmd, prp_count); ps3_hw_nvme_req_frame_build(cmd, hw_reqframe); cmd->req_frame->hwReq.reqHead.traceID = cmd->trace_id; - lba = (U64)cmd->io_attr.lba_hi << PS3_SHIFT_DWORD | cmd->io_attr.lba_lo; + lba = (unsigned long long)cmd->io_attr.lba_hi + << PS3_SHIFT_DWORD | + cmd->io_attr.lba_lo; ret = ps3_software_zone_build(cmd, lba, pd_dev_type, prp_count); } else { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u this io don't support prp!\n", + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u this io don't support prp!\n", cmd->trace_id, PS3_HOST(cmd->instance)); ret = -PS3_FAILED; } return ret; } -static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) +static int ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; static unsigned long j; + if (ps3_is_need_build_hw_req_frame(cmd)) { ret = ps3_scsih_nvme_hw_req_frame_build(cmd); if (ret != PS3_SUCCESS) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u direct NVMe NOK, to normal" - "is_use_frontend_prp:%d\n", cmd->trace_id, - PS3_HOST(cmd->instance), cmd->io_attr.is_use_frontend_prp); + LOG_WARN_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u direct NVMe NOK, to normal\n" + "\tis_use_frontend_prp:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->io_attr.is_use_frontend_prp); cmd->io_attr.direct_flag = PS3_CMDWORD_DIRECT_NORMAL; cmd->io_attr.is_use_frontend_prp = PS3_FALSE; - memset((void *) &cmd->cmd_word, 0, sizeof(struct PS3CmdWord)); - memset((void *)cmd->req_frame, 0, sizeof(union PS3ReqFrame)); - memset(cmd->ext_buf, 0, cmd->instance->cmd_context.ext_buf_size); + memset((void *)&cmd->cmd_word, 0, + sizeof(struct PS3CmdWord)); + memset((void *)cmd->req_frame, 0, + sizeof(union PS3ReqFrame)); + memset(cmd->ext_buf, 0, + cmd->instance->cmd_context.ext_buf_size); ret = ps3_scsih_pd_cmd_word_build(cmd); if (unlikely(ret != PS3_SUCCESS)) { - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", - cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, ret); + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "tid:0x%llx hno:%u cmd_word build NOK CFID:%d ret:%d\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->index, ret); ret = -PS3_FAILED; goto l_out; } @@ -2939,7 +3248,8 @@ static S32 ps3_scsih_nvme_req_frame_build(struct ps3_cmd *cmd) return ret; } -static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, U8 reply_flags) +static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, + unsigned char reply_flags) { PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd, reply_flags); PS3_DEV_IO_OUTSTAND_DEC(cmd->instance, cmd); @@ -2954,72 +3264,81 @@ static inline void ps3_scsih_cmd_back_stat(struct ps3_cmd *cmd, U8 reply_flags) static inline void ps3_scsih_overrun_underrun_verify(struct ps3_cmd *cmd) { - if ((ps3_scsih_is_sas_jbod_cmd(cmd)) - || (ps3_scsih_is_sata_jbod_cmd(cmd) - && ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd))) { + if ((ps3_scsih_is_sas_jbod_cmd(cmd)) || + (ps3_scsih_is_sata_jbod_cmd(cmd) && + ps3_scsih_cdb_is_rw_cmd(cmd->scmd->cmnd))) { if (cmd->io_attr.sgl_buf_len > scsi_bufflen(cmd->scmd)) { scsi_set_resid(cmd->scmd, 0); - cmd->scmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); - LOG_DEBUG("cmd overrun, CFID:%u op:0x%x data_len:%u scsi_buf_len:%u\n", - cmd->index, cmd->scmd->cmnd[0], cmd->io_attr.sgl_buf_len, scsi_bufflen(cmd->scmd)); + cmd->scmd->result = + PS3_SCSI_RESULT_HOST_STATUS(DID_SOFT_ERROR); + LOG_DEBUG( + "cmd overrun, CFID:%u op:0x%x data_len:%u scsi_buf_len:%u\n", + cmd->index, cmd->scmd->cmnd[0], + cmd->io_attr.sgl_buf_len, + scsi_bufflen(cmd->scmd)); } } - return; } -static inline void ps3_r1x_read_dec(struct ps3_cmd *cmd, struct ps3_r1x_read_balance_info *rb_info) +static inline void ps3_r1x_read_dec(struct ps3_cmd *cmd, + struct ps3_r1x_read_balance_info *rb_info) { if (rb_info != NULL && cmd->r1x_read_pd > 0) { if (cmd->r1x_read_pd > PS3_MAX_PD_NUM_ONE_VD) { PS3_BUG(); return; } - ps3_atomic_dec(&rb_info->scsi_outstanding_cmds[cmd->r1x_read_pd]); + ps3_atomic_dec( + &rb_info->scsi_outstanding_cmds[cmd->r1x_read_pd]); } } -S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags) +int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; struct scsi_cmnd *s_cmd = cmd->scmd; struct ps3_scsi_priv_data *data = NULL; struct ps3_cmd *err_cmd = cmd; struct ps3_cmd *peer_cmd = NULL; if (unlikely(s_cmd == NULL)) { - LOG_ERROR_IN_IRQ(cmd->instance, - "hno:%u CFID:%d scmd is null\n", - PS3_HOST(cmd->instance), cmd->index); + LOG_ERROR_IN_IRQ(cmd->instance, "hno:%u CFID:%d scmd is null\n", + PS3_HOST(cmd->instance), cmd->index); goto l_out; } if (cmd->r1x_peer_cmd != NULL) { - LOG_DEBUG("hno:%u CFID:%d one of the r1x write scmd is return, rflag:%d\n", + LOG_DEBUG( + "hno:%u CFID:%d one of the r1x write scmd is return, rflag:%d\n", PS3_HOST(cmd->instance), cmd->index, reply_flags); cmd->r1x_reply_flag = reply_flags; cmd->is_r1x_scsi_complete = PS3_TRUE; if (!cmd->r1x_peer_cmd->is_r1x_scsi_complete) { - PS3_IOC_DRV2IOC_BACK_INC(cmd->instance, cmd->r1x_peer_cmd, reply_flags); - LOG_DEBUG("hno:%u CFID:%d r1x write peer cmd:%d is not return\n", + PS3_IOC_DRV2IOC_BACK_INC( + cmd->instance, cmd->r1x_peer_cmd, reply_flags); + LOG_DEBUG( + "hno:%u CFID:%d r1x write peer cmd:%d is not return\n", PS3_HOST(cmd->instance), cmd->index, cmd->r1x_peer_cmd->index); goto l_out; } - if (cmd->r1x_peer_cmd->r1x_reply_flag != PS3_REPLY_WORD_FLAG_SUCCESS) { + if (cmd->r1x_peer_cmd->r1x_reply_flag != + PS3_REPLY_WORD_FLAG_SUCCESS) { err_cmd = cmd->r1x_peer_cmd; reply_flags = cmd->r1x_peer_cmd->r1x_reply_flag; } - if (cmd->index >= (U32)cmd->instance->cmd_attr.cur_can_que) { + if (cmd->index >= + (unsigned int)cmd->instance->cmd_attr.cur_can_que) cmd = cmd->r1x_peer_cmd; - } } data = scsi_device_private_data(s_cmd); - LOG_DEBUG("tid:0x%llx hno:%u scsi cmd reply cb CFID:%u rep_f:%u" - " op:0x%x chl:%u id:%u data_len:%u scsi_buflen:%u dev_type:%s\n", + LOG_DEBUG( + "tid:0x%llx hno:%u scsi cmd reply cb CFID:%u rep_f:%u\n" + "\top:0x%x chl:%u id:%u data_len:%u scsi_buflen:%u dev_type:%s\n", cmd->trace_id, PS3_HOST(cmd->instance), cmd->index, reply_flags, s_cmd->cmnd[0], PS3_SDEV_CHANNEL(cmd->scmd->device), PS3_SDEV_TARGET(cmd->scmd->device), cmd->io_attr.sgl_buf_len, @@ -3035,29 +3354,31 @@ S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags) } else { ps3_scsih_overrun_underrun_verify(cmd); if (cmd->scmd->result == DID_OK) { - ps3_qos_adjust_pd_rsc(s_cmd->device, cmd->instance, PS3_QOS_QUOTA_ADJUST_UP); + ps3_qos_adjust_pd_rsc(s_cmd->device, cmd->instance, + PS3_QOS_QUOTA_ADJUST_UP); } } ps3_r1x_read_dec(cmd, data->r1x_rb_info); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)) +#if defined(PS3_SUPPORT_CMD_SCP) s_cmd->SCp.ptr = NULL; #endif ps3_scsi_dma_unmap(cmd); - ps3_qos_cmd_update(cmd->instance, cmd); + ps3_qos_cmd_update(cmd->instance, cmd, PS3_TRUE); ps3_r1x_write_unlock(&data->lock_mgr, cmd); peer_cmd = cmd->r1x_peer_cmd; INJECT_START(PS3_ERR_IJ_WAIT_ABORT_FLAG, peer_cmd); PS3_IO_OUTSTAND_DEC(cmd->instance, s_cmd); - PS3_VD_OUTSTAND_DEC(cmd->instance, s_cmd); + PS3_VD_OUTSTAND_DEC(cmd->instance, cmd); ps3_scsi_cmd_free(cmd); if (peer_cmd != NULL) { - LOG_DEBUG("host_no:%u r1x scsi write done CFID:%d and CFID:%d\n", - PS3_HOST(peer_cmd->instance), peer_cmd->r1x_peer_cmd->index, - peer_cmd->index); + LOG_DEBUG( + "host_no:%u r1x scsi write done CFID:%d and CFID:%d\n", + PS3_HOST(peer_cmd->instance), + peer_cmd->r1x_peer_cmd->index, peer_cmd->index); ps3_r1x_peer_cmd_free_nolock(peer_cmd); } SCMD_IO_DONE(s_cmd); @@ -3066,28 +3387,27 @@ S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags) return ret; } -void ps3_scsih_direct_to_normal_req_frame_rebuild( - struct ps3_cmd *cmd) +void ps3_scsih_direct_to_normal_req_frame_rebuild(struct ps3_cmd *cmd) { ps3_vd_adv_to_normal_req_frame_rebuild(cmd); } #ifdef _WINDOWS -static Bool ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, - ps3_scatter_gather_element *os_sgl, S32 index) +static unsigned char ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, + struct scatterlist *os_sgl, + int index) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; struct scsi_cmnd *scp = cmd->scmd; - U16 os_sge_count = (U16)scp->scatterlist->NumberOfElements; + unsigned short os_sge_count = + (unsigned short)scp->scatterlist->NumberOfElements; - if (index != 0 && index != os_sge_count-1) { + if (index != 0 && index != os_sge_count - 1) goto l_check; - } - if ( cmd->io_attr.dev_type == PS3_DEV_TYPE_VD ) { - if (cmd->io_attr.vd_entry->isNvme) { + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { + if (cmd->io_attr.vd_entry->isNvme) goto l_nvme_check; - } } else if (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD) { goto l_nvme_check; } else { @@ -3096,20 +3416,21 @@ static Bool ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, goto l_check; l_nvme_check: if (index == 0) { - if (os_sgl->PhysicalAddress.QuadPart & PS3_SCSI_ALINNMENT_MASK) { + if (os_sgl->PhysicalAddress.QuadPart & + PS3_SCSI_ALINNMENT_MASK) { ret = PS3_TRUE; } } else { if (os_sgl->PhysicalAddress.QuadPart & - scp->dma_addr_alignment_mask) { + scp->dma_addr_alignment_mask) { ret = PS3_TRUE; } } goto l_out; l_check: - if ((os_sgl->PhysicalAddress.QuadPart & scp->dma_addr_alignment_mask) - || (os_sgl->Length & scp->dma_len_alignment_mask)) { + if ((os_sgl->PhysicalAddress.QuadPart & scp->dma_addr_alignment_mask) || + (os_sgl->Length & scp->dma_len_alignment_mask)) { ret = PS3_TRUE; } l_out: @@ -3118,16 +3439,18 @@ static Bool ps3_scsi_sge_remap_check(struct ps3_cmd *cmd, static void ps3_scsi_dma_algin_calc(struct ps3_cmd *cmd) { - U32 dma_addr_alignment = 0; - U32 dma_len_alignment = 0; + unsigned int dma_addr_alignment = 0; + unsigned int dma_len_alignment = 0; struct scsi_cmnd *scp = cmd->scmd; if ((cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && - (ps3_scsih_is_use_hard_cmd(cmd) != PS3_CMDWORD_FORMAT_HARDWARE)) { + (ps3_scsih_is_use_hard_cmd(cmd) != PS3_CMDWORD_FORMAT_HARDWARE)) { dma_addr_alignment = cmd->io_attr.vd_entry->dmaAddrAlignShift; dma_len_alignment = cmd->io_attr.vd_entry->dmaLenAlignShift; - dma_addr_alignment = dma_addr_alignment ? 1 << dma_addr_alignment : 0; - dma_len_alignment = dma_len_alignment ? 1 << dma_len_alignment : 0; + dma_addr_alignment = + dma_addr_alignment ? 1 << dma_addr_alignment : 0; + dma_len_alignment = + dma_len_alignment ? 1 << dma_len_alignment : 0; } else { dma_addr_alignment = cmd->io_attr.pd_entry->dma_addr_alignment; dma_len_alignment = cmd->io_attr.pd_entry->dma_len_alignment; @@ -3135,53 +3458,49 @@ static void ps3_scsi_dma_algin_calc(struct ps3_cmd *cmd) scp->dma_addr_alignment_mask = PS3_SCSI_ALINNMENT_MASK; scp->dma_len_alignment_mask = 0; - if (dma_addr_alignment) { + if (dma_addr_alignment) scp->dma_addr_alignment_mask = dma_addr_alignment - 1; - } - if(dma_len_alignment){ + if (dma_len_alignment) scp->dma_len_alignment_mask = dma_len_alignment - 1; - } - if (( (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && - (cmd->io_attr.vd_entry->isNvme)) || - (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD) ) { + if (((cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) && + (cmd->io_attr.vd_entry->isNvme)) || + (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { scp->dma_addr_alignment_mask = PS3_SCSI_4K_ALINNMENT_MASK; scp->dma_len_alignment_mask = PS3_SCSI_4K_ALINNMENT_MASK; } - LOG_DEBUG("tid:0x%llx hno:%u align[addr:%d,len:%d][addr_mask:%x,len_mask:%x]\n", - cmd->trace_id, PS3_HOST(cmd->instance), - dma_addr_alignment, - dma_len_alignment, - scp->dma_addr_alignment_mask, + LOG_DEBUG( + "tid:0x%llx hno:%u align[addr:%d,len:%d][addr_mask:%x,len_mask:%x]\n", + cmd->trace_id, PS3_HOST(cmd->instance), dma_addr_alignment, + dma_len_alignment, scp->dma_addr_alignment_mask, scp->dma_len_alignment_mask); } static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd) { - S32 index = 0; - U16 os_sge_count = 0; + int index = 0; + unsigned short os_sge_count = 0; struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *os_sgl = NULL; + struct scatterlist *os_sgl = NULL; + scp->is_remap_databuff = PS3_FALSE; - if (scp->scatterlist == NULL) { + if (scp->scatterlist == NULL) goto l_out; - } if (!ps3_scsih_cdb_is_rw_cmd(scp->cmnd) && - (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { + (cmd->io_attr.dev_type == PS3_DEV_TYPE_NVME_SSD)) { goto l_out; } ps3_scsi_dma_algin_calc(cmd); - os_sge_count = (U16)scp->scatterlist->NumberOfElements; + os_sge_count = (unsigned short)scp->scatterlist->NumberOfElements; scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) { + if (os_sgl == NULL) break; - } if (ps3_scsi_sge_remap_check(cmd, os_sgl, index)) { scp->is_remap_databuff = PS3_TRUE; @@ -3189,88 +3508,79 @@ static void ps3_scsi_need_remap_check(struct ps3_cmd *cmd) } } l_out: - if(scp->is_remap_databuff) { - LOG_DEBUG("tid:0x%llx hno:%u unalign[addr_mask:%x,len_mask:%x] " - "sgl addr:0x%llx len:%d or SAS sge num:%d > %d, index:%d\n", + if (scp->is_remap_databuff) { + LOG_DEBUG( + "tid:0x%llx hno:%u unalign[addr_mask:%x,len_mask:%x]\n" + "\tsgl addr:0x%llx len:%d or SAS sge num:%d > %d, index:%d\n", cmd->trace_id, PS3_HOST(cmd->instance), scp->dma_addr_alignment_mask, scp->dma_len_alignment_mask, - os_sgl->PhysicalAddress.QuadPart, - os_sgl->Length, + os_sgl->PhysicalAddress.QuadPart, os_sgl->Length, scp->scatterlist->NumberOfElements, - PS3_FRAME_REQ_SGE_NUM_HW, - index); + PS3_FRAME_REQ_SGE_NUM_HW, index); } - return; } -static S32 ps3_scsi_remap_sgl(struct ps3_cmd *cmd) +static int ps3_scsi_remap_sgl(struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct scsi_cmnd *scp = cmd->scmd; void *srb_data_buff = SrbGetDataBuffer(cmd->srb); - if (srb_data_buff == NULL) { + if (srb_data_buff == NULL) goto l_out; - } scp->remap_databuff_length = scp->data_transfer_length; if (scp->data_transfer_length & scp->dma_len_alignment_mask) { scp->remap_databuff_length = - (scp->data_transfer_length + scp->dma_len_alignment_mask + 1) & - (~(U64)scp->dma_len_alignment_mask); + (scp->data_transfer_length + + scp->dma_len_alignment_mask + 1) & + (~(unsigned long long)scp->dma_len_alignment_mask); } - scp->remap_databuff = ps3_dma_alloc_coherent(cmd->instance, - scp->remap_databuff_length, - &scp->remap_databuff_phy); - if (scp->remap_databuff == NULL) { + scp->remap_databuff = ps3_dma_alloc_coherent( + cmd->instance, scp->remap_databuff_length, + (unsigned long long *)&scp->remap_databuff_phy); + if (scp->remap_databuff == NULL) goto l_out; - } cmd->os_sge_map_count = 1; memset(&scp->remap_sgl, 0, sizeof(scp->remap_sgl)); - scp->scatterlist = (STOR_SCATTER_GATHER_LIST*)&scp->remap_sgl; + scp->scatterlist = (STOR_SCATTER_GATHER_LIST *)&scp->remap_sgl; scp->scatterlist->NumberOfElements = 1; scp->scatterlist->List[0].Length = scp->remap_databuff_length; - scp->scatterlist->List[0].PhysicalAddress.QuadPart = (LONGLONG)scp->remap_databuff_phy; - RtlMoveMemory(scp->remap_databuff, - srb_data_buff, - scp->data_transfer_length); + scp->scatterlist->List[0].PhysicalAddress.QuadPart = + (LONGLONG)scp->remap_databuff_phy; + RtlMoveMemory(scp->remap_databuff, srb_data_buff, + scp->data_transfer_length); LOG_DEBUG("remap io,%p, data_len:%d, remap_len:%d, addr:0x%llx\n", - srb_data_buff, - scp->data_transfer_length, - scp->remap_databuff_length, - scp->remap_databuff_phy); + srb_data_buff, scp->data_transfer_length, + scp->remap_databuff_length, scp->remap_databuff_phy); ret = PS3_SUCCESS; l_out: return ret; } -static S32 ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) +static int ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) { - S32 ret = -PS3_FAILED; + int ret = -PS3_FAILED; struct scsi_cmnd *scp = cmd->scmd; void *srb_data_buff = SrbGetDataBuffer(cmd->srb); - if (srb_data_buff == NULL) { + if (srb_data_buff == NULL) goto l_out; - } if (scp->remap_databuff != NULL) { - RtlMoveMemory(srb_data_buff, - scp->remap_databuff, - scp->data_transfer_length); - - LOG_DEBUG("unremap io,%p, len:%d \n", - srb_data_buff, - scp->data_transfer_length); - - ps3_dma_free_coherent(cmd->instance, - scp->remap_databuff_length, - scp->remap_databuff, - scp->remap_databuff_phy ); + RtlMoveMemory(srb_data_buff, scp->remap_databuff, + scp->data_transfer_length); + + LOG_DEBUG("unremap io,%p, len:%d\n", srb_data_buff, + scp->data_transfer_length); + + ps3_dma_free_coherent(cmd->instance, scp->remap_databuff_length, + scp->remap_databuff, + scp->remap_databuff_phy); scp->remap_databuff = NULL; scp->is_remap_databuff = PS3_FALSE; cmd->os_sge_map_count = 0; @@ -3282,12 +3592,12 @@ static S32 ps3_scsi_unremap_sgl(struct ps3_cmd *cmd) } #endif -S32 ps3_scsi_dma_map(struct ps3_cmd *cmd) +int ps3_scsi_dma_map(struct ps3_cmd *cmd) { - S32 index = 0; - S32 os_sge_count = 0; + int index = 0; + int os_sge_count = 0; struct scsi_cmnd *scp = cmd->scmd; - ps3_scatter_gather_element *os_sgl = NULL; + struct scatterlist *os_sgl = NULL; os_sge_count = scsi_dma_map(scp); if (unlikely(os_sge_count <= 0)) { @@ -3296,23 +3606,29 @@ S32 ps3_scsi_dma_map(struct ps3_cmd *cmd) } scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) { + if (os_sgl == NULL) break; - } - INJECT_START(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, &(sg_dma_address_u64(os_sgl))); - if (index == 0 && cmd->instance->page_mode_change - && (sg_dma_address_u64(os_sgl) & cmd->instance->page_mode_addr_mask)) { - cmd->instance->page_mode_addr_mask = PS3_PAGE_MODE_ABOVE_4_ADDR_MASK; - if (sg_dma_address_u64(os_sgl) & PS3_PAGE_MODE_ABOVE_4_ADDR_MASK) { + INJECT_START(PS3_ERR_IJ_SGL_ADDR_PAGE_MODE_5, + &(sg_dma_address_u64(os_sgl))); + if (index == 0 && cmd->instance->page_mode_change && + (sg_dma_address_u64(os_sgl) & + cmd->instance->page_mode_addr_mask)) { + cmd->instance->page_mode_addr_mask = + PS3_PAGE_MODE_ABOVE_4_ADDR_MASK; + if (sg_dma_address_u64(os_sgl) & + PS3_PAGE_MODE_ABOVE_4_ADDR_MASK) { cmd->instance->page_mode_change = PS3_FALSE; - } - dev_info(&cmd->instance->pdev->dev, + } + dev_info( + &cmd->instance->pdev->dev, "page mode change, addr:0x%llx\n", - sg_dma_address_u64(os_sgl)); + (unsigned long long)sg_dma_address_u64(os_sgl)); } - INJECT_START(PS3_ERR_IJ_SGL_ADDR_RESTORE, &(sg_dma_address_u64(os_sgl))); - sg_dma_address(os_sgl) = - PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(cmd->instance->dma_addr_bit_pos, sg_dma_address_u64(os_sgl)); + INJECT_START(PS3_ERR_IJ_SGL_ADDR_RESTORE, + &(sg_dma_address_u64(os_sgl))); + sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + cmd->instance->dma_addr_bit_pos, + sg_dma_address_u64(os_sgl)); } cmd->os_sge_map_count = os_sge_count; @@ -3322,94 +3638,80 @@ S32 ps3_scsi_dma_map(struct ps3_cmd *cmd) void ps3_scsi_dma_unmap(struct ps3_cmd *cmd) { - S32 index = 0; - U16 os_sge_count = 0; + int index = 0; + unsigned short os_sge_count = 0; struct scsi_cmnd *scp = NULL; - ps3_scatter_gather_element *os_sgl = NULL; + struct scatterlist *os_sgl = NULL; - if (cmd == NULL) { + if (cmd == NULL) goto l_out; - } os_sge_count = cmd->os_sge_map_count; scp = cmd->scmd; - if (os_sge_count == 0) { + if (os_sge_count == 0) goto l_out; - } scsi_for_each_sg(scp, os_sgl, os_sge_count, index) { - if (os_sgl == NULL) { + if (os_sgl == NULL) break; - } - sg_dma_address(os_sgl) = - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(cmd->instance->dma_addr_bit_pos, sg_dma_address_u64(os_sgl)); + sg_dma_address(os_sgl) = PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW( + cmd->instance->dma_addr_bit_pos, + sg_dma_address_u64(os_sgl)); } - if (scp->sdb.table.sgl) { + if (scp->sdb.table.sgl) scsi_dma_unmap(scp); - } cmd->os_sge_map_count = 0; l_out: return; } -#if 0 -struct disk_type_to_proc_func_table* ps3_req_func_entry_query(U8 dev_type) +static int ps3_vd_access_policy_check(struct ps3_instance *instance, + unsigned char channel, unsigned short id, + struct scsi_cmnd *s_cmd) { - struct disk_type_to_proc_func_table *entry = NULL; - U32 table_size = ARRAY_SIZE(g_req_frame_func_table); - U32 i = 0; - - for (; i < table_size; ++i) { - if (dev_type == g_req_frame_func_table[i].type) { - entry = &g_req_frame_func_table[i]; - goto l_out; - } - } -l_out: - return entry; -} -#endif - -static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, - U8 channel, U16 id, struct scsi_cmnd *s_cmd) -{ - S32 ret = PS3_SUCCESS; - U8 opcode = 0; - U16 sub_opcode = 0; - struct PS3VDEntry *entry = ps3_dev_mgr_lookup_vd_info(instance, channel, id); + int ret = PS3_SUCCESS; + unsigned char opcode = 0; + unsigned short sub_opcode = 0; + struct PS3VDEntry *entry = + ps3_dev_mgr_lookup_vd_info(instance, channel, id); static unsigned long j; + if (unlikely(entry == NULL)) { #ifndef _WINDOWS s_cmd->result = PS3_SCSI_RESULT_HOST_STATUS(DID_BAD_TARGET); #else scsi_cmnd_hoststatus_set(s_cmd, DID_BAD_TARGET); #endif - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "hno:%u chl:%u id:%u\n", - PS3_HOST(instance), channel, id); + LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "hno:%u chl:%u id:%u\n", PS3_HOST(instance), + channel, id); ret = -PS3_ENODEV; goto l_out; } if (unlikely((entry->accessPolicy == VD_ACCESS_POLICY_BLOCK) && - ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd))) { - ps3_errcode_to_scsi_status(instance, s_cmd, PS3_STATUS_ACCESS_BLOCK, NULL, 0, NULL); + ps3_scsih_cdb_is_rw_cmd(s_cmd->cmnd))) { + ps3_errcode_to_scsi_status(instance, s_cmd, + PS3_STATUS_ACCESS_BLOCK, NULL, 0, + NULL); ps3_scsih_cdb_opcode_get(s_cmd->cmnd, &opcode, &sub_opcode); - LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u" - "op:0x%x sub_op:0x%x block io\n", - PS3_HOST(instance), channel, id, entry->accessPolicy, - opcode, sub_opcode); + LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u op:0x%x sub_op:0x%x block io\n", + PS3_HOST(instance), channel, id, entry->accessPolicy, + opcode, sub_opcode); ret = -PS3_IO_BLOCK; goto l_out; - } else if (unlikely((entry->accessPolicy == VD_ACCESS_POLICY_READ_ONLY) && - ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd))) { - ps3_errcode_to_scsi_status(instance, s_cmd, PS3_STATUS_ACCESS_BLOCK, NULL, 0, NULL); + } else if (unlikely((entry->accessPolicy == + VD_ACCESS_POLICY_READ_ONLY) && + ps3_scsih_cdb_is_write_cmd(s_cmd->cmnd))) { + ps3_errcode_to_scsi_status(instance, s_cmd, + PS3_STATUS_ACCESS_BLOCK, NULL, 0, + NULL); ps3_scsih_cdb_opcode_get(s_cmd->cmnd, &opcode, &sub_opcode); - LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u" - "op:0x%x sub_op:0x%x block write io\n", - PS3_HOST(instance), channel, id, entry->accessPolicy, - opcode, sub_opcode); + LOG_DEBUG("hno:%u chl:%u id:%u vd_access_policy:%u op:0x%x sub_op:0x%x write io\n", + PS3_HOST(instance), channel, id, entry->accessPolicy, + opcode, sub_opcode); ret = -PS3_IO_BLOCK; goto l_out; } @@ -3417,41 +3719,41 @@ static S32 ps3_vd_access_policy_check(struct ps3_instance *instance, return ret; } -S32 ps3_get_requeue_or_reset(void) +int ps3_get_requeue_or_reset(void) { -#if ((defined(RHEL_MAJOR) && (RHEL_MAJOR == 7) && (RHEL_MINOR == 3)) || \ -((LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) && \ -(LINUX_VERSION_CODE < KERNEL_VERSION(4,4,14)))) +#if defined(PS3_DID_REQUEUE) return PS3_SCSI_RESULT_HOST_STATUS(DID_REQUEUE); #else return PS3_SCSI_RESULT_HOST_STATUS(DID_RESET); #endif } -Bool ps3_write_direct_enable(struct ps3_cmd *cmd) +unsigned char ps3_write_direct_enable(struct ps3_cmd *cmd) { - Bool result = PS3_TRUE; + unsigned char result = PS3_TRUE; + if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) && - !cmd->io_attr.vd_entry->isWriteDirectEnable) { + !cmd->io_attr.vd_entry->isWriteDirectEnable) { result = PS3_FALSE; } return result; } -Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd) +unsigned char ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; struct ps3_scsi_priv_data *device_priv_data = NULL; device_priv_data = PS3_SDEV_PRI_DATA(cmd->scmd->device); if (device_priv_data != NULL) { - cmd->cmd_word.qMask = 1 << - (device_priv_data->qmask_count & (cmd->instance->ctrl_info.vdQueueNum - 1)); + cmd->cmd_word.qMask = + 1 << (device_priv_data->qmask_count & + (cmd->instance->ctrl_info.vdQueueNum - 1)); device_priv_data->qmask_count++; - ret = PS3_TRUE;; + ret = PS3_TRUE; + ; } return ret; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih.h index e451f019a5d1..0c5ea1e9d70c 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_SCSIH_H_ #define _PS3_SCSIH_H_ @@ -11,143 +11,135 @@ #include "ps3_htp_def.h" #include "ps3_inner_data.h" +#include "ps3_kernel_version.h" #define PS3_HW_VD_MAX_IO_SIZE_1M (1ULL << 20) #define PS3_PAGE_MODE_ABOVE_3_ADDR_MASK 0xFFFFFF8000000000ULL #define PS3_PAGE_MODE_ABOVE_4_ADDR_MASK 0xFFFF000000000000ULL -#define PS3_IS_R0J1(raidlevel) \ - ((raidlevel) == RAID0 || (raidlevel) == RAID1 || \ - (raidlevel) == RAID10 || (raidlevel) == RAID1E || \ - (raidlevel) == RAID00) +#define PS3_IS_R0J1(raidlevel) \ + ((raidlevel) == RAID0 || (raidlevel) == RAID1 || \ + (raidlevel) == RAID10 || (raidlevel) == RAID1E || \ + (raidlevel) == RAID00) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)) -#define SCMD_GET_REQUEST(scmd) scsi_cmd_to_rq(scmd) +#if defined(PS3_SCMD_GET_REQUEST) +#define SCMD_GET_REQUEST(scmd) scsi_cmd_to_rq(scmd) #else -#define SCMD_GET_REQUEST(scmd) scmd->request +#define SCMD_GET_REQUEST(scmd) scmd->request #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,16,0)) -#define SCMD_IO_DONE(scmd) scsi_done(scmd) +#if defined(PS3_SCMD_IO_DONE) +#define SCMD_IO_DONE(scmd) scsi_done(scmd) #else -#define SCMD_IO_DONE(scmd) scmd->scsi_done(scmd) -#endif - -#if 0 -#define PS3_IF_QUIT_STREAM_DIRECT_DETECT(raidlevel) \ - ((ps3_direct_check_stream_query() == PS3_FALSE) && PS3_IS_R0J1(raidlevel)) +#define SCMD_IO_DONE(scmd) scmd->scsi_done(scmd) #endif -#define PS3_IF_QUIT_STREAM_DIRECT_DETECT() \ +#define PS3_IF_QUIT_STREAM_DIRECT_DETECT() \ (ps3_direct_check_stream_query() == PS3_FALSE) -typedef S32 (*dev_type_to_proc_func)(struct ps3_cmd*); struct disk_type_to_proc_func_table { - U8 type; - dev_type_to_proc_func func; + unsigned char type; + int (*func)(struct ps3_cmd *cmd); }; -#define CMND_LEN16 (16) -#define FRAME_CMD_MASK_SHIFT (0x1) -#define FRAME_CMD_MASK_BITS (0x07) +#define CMND_LEN16 (16) +#define FRAME_CMD_MASK_SHIFT (0x1) +#define FRAME_CMD_MASK_BITS (0x07) enum PS3_FRAME_CMD_TYPE { - SCSI_FRAME_CMD = 0, - SAS_FRAME_CMD = 1, - SATA_FRAME_CMD = 2, - NVME_FRAME_CMD = 3, + SCSI_FRAME_CMD = 0, + SAS_FRAME_CMD = 1, + SATA_FRAME_CMD = 2, + NVME_FRAME_CMD = 3, UNKNOWN_FRAME_CMD, }; enum PS3_RW_CMD_TYPE { - SCSI_RW_UNUSED_CMD = 0, - SCSI_RW_SEQ_CMD = 1, - SCSI_RW_RANDOM_CMD = 2, + SCSI_RW_UNUSED_CMD = 0, + SCSI_RW_SEQ_CMD = 1, + SCSI_RW_RANDOM_CMD = 2, }; struct scsi_cmd_parse_table { - U8 cmd_type; - U8 rw_attr; + unsigned char cmd_type; + unsigned char rw_attr; }; -static inline void ps3_put_unaligned_be64(U8 *p, U32 val_hi, U32 val_lo) +static inline void ps3_put_unaligned_be64(unsigned char *p, unsigned int val_hi, + unsigned int val_lo) { - p[0] = (U8) (val_hi >> PS3_SHIFT_3BYTE) & 0xff; - p[1] = (U8) (val_hi >> PS3_SHIFT_WORD) & 0xff; - p[2] = (U8) (val_hi >> PS3_SHIFT_BYTE) & 0xff; - p[3] = (U8) val_hi & 0xff; - - p[4] = (U8) (val_lo >> PS3_SHIFT_3BYTE) & 0xff; - p[5] = (U8) (val_lo >> PS3_SHIFT_WORD) & 0xff; - p[6] = (U8) (val_lo >> PS3_SHIFT_BYTE) & 0xff; - p[7] = (U8) val_lo & 0xff; + p[0] = (unsigned char)(val_hi >> PS3_SHIFT_3BYTE) & 0xff; + p[1] = (unsigned char)(val_hi >> PS3_SHIFT_WORD) & 0xff; + p[2] = (unsigned char)(val_hi >> PS3_SHIFT_BYTE) & 0xff; + p[3] = (unsigned char)val_hi & 0xff; + + p[4] = (unsigned char)(val_lo >> PS3_SHIFT_3BYTE) & 0xff; + p[5] = (unsigned char)(val_lo >> PS3_SHIFT_WORD) & 0xff; + p[6] = (unsigned char)(val_lo >> PS3_SHIFT_BYTE) & 0xff; + p[7] = (unsigned char)val_lo & 0xff; } -static inline void ps3_put_unaligned_be32(U8 *p, U32 val) +static inline void ps3_put_unaligned_be32(unsigned char *p, unsigned int val) { - p[0] = (U8) (val >> PS3_SHIFT_3BYTE) & 0xff; - p[1] = (U8) (val >> PS3_SHIFT_WORD) & 0xff; - p[2] = (U8) (val >> PS3_SHIFT_BYTE) & 0xff; - p[3] = (U8) val & 0xff; + p[0] = (unsigned char)(val >> PS3_SHIFT_3BYTE) & 0xff; + p[1] = (unsigned char)(val >> PS3_SHIFT_WORD) & 0xff; + p[2] = (unsigned char)(val >> PS3_SHIFT_BYTE) & 0xff; + p[3] = (unsigned char)val & 0xff; } -static inline void ps3_put_unaligned_be16(U8 *p, U16 val) +static inline void ps3_put_unaligned_be16(unsigned char *p, unsigned short val) { - p[0] = (U8) (val >> PS3_SHIFT_BYTE) & 0xff; - p[1] = (U8) val & 0xff; + p[0] = (unsigned char)(val >> PS3_SHIFT_BYTE) & 0xff; + p[1] = (unsigned char)val & 0xff; } -static inline U16 ps3_get_unaligned_be16(U8 *p) +static inline unsigned short ps3_get_unaligned_be16(unsigned char *p) { - return (U16)((p[0] << PS3_SHIFT_BYTE) | p[1]); + return (unsigned short)((p[0] << PS3_SHIFT_BYTE) | p[1]); } #ifndef _WINDOWS -typedef struct scatterlist ps3_scatter_gather_element; - -S32 ps3_scsih_queue_command(struct Scsi_Host *s_host, - struct scsi_cmnd *s_cmd); +int ps3_scsih_queue_command(struct Scsi_Host *s_host, struct scsi_cmnd *s_cmd); #else -Bool ps3_scsih_sys_state_check(struct ps3_instance *instance, S32 *host_status); +unsigned char ps3_scsih_sys_state_check(struct ps3_instance *instance, + int *host_status); #endif -S32 ps3_scsih_cmd_build(struct ps3_cmd *cmd); +int ps3_scsih_cmd_build(struct ps3_cmd *cmd); -void ps3_scsih_direct_to_normal_req_frame_rebuild( - struct ps3_cmd *cmd); +void ps3_scsih_direct_to_normal_req_frame_rebuild(struct ps3_cmd *cmd); -S32 ps3_scsih_io_done(struct ps3_cmd *cmd, U16 reply_flags); +int ps3_scsih_io_done(struct ps3_cmd *cmd, unsigned short reply_flags); void ps3_scsi_dma_unmap(struct ps3_cmd *cmd); -S32 ps3_scsi_dma_map(struct ps3_cmd *cmd); +int ps3_scsi_dma_map(struct ps3_cmd *cmd); -#if 0 -struct disk_type_to_proc_func_table* ps3_req_func_entry_query(U8 dev_type); -#endif +unsigned char +ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, + const struct ps3_pd_entry *pd_entry); -Bool ps3_scsih_sata_direct_is_support(struct ps3_cmd *cmd, - const struct ps3_pd_entry *pd_entry); +unsigned char ps3_scsih_stream_is_detect(struct ps3_cmd *cmd); +unsigned char ps3_raid_scsih_stream_is_direct(const struct ps3_cmd *cmd); +unsigned char ps3_hba_scsih_stream_is_direct(const struct ps3_cmd *cmd); -Bool ps3_scsih_stream_is_detect(struct ps3_cmd * cmd); -Bool ps3_raid_scsih_stream_is_direct(const struct ps3_cmd * cmd); -Bool ps3_hba_scsih_stream_is_direct(const struct ps3_cmd * cmd); +void ps3_scsih_print_req(struct ps3_cmd *cmd, unsigned char log_level); -void ps3_scsih_print_req(struct ps3_cmd *cmd, U8 log_level); +int ps3_get_requeue_or_reset(void); -S32 ps3_get_requeue_or_reset(void); +unsigned char ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd); -Bool ps3_scsih_sata_direct_is_need(struct ps3_cmd *cmd); +unsigned char ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd); -Bool ps3_scsih_is_sata_jbod_mgr_cmd(const struct ps3_cmd *cmd); +unsigned int ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd); -U32 ps3_scsih_xfer_cnt_get(const struct ps3_cmd *cmd); +unsigned char ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd); -Bool ps3_is_r1x_write_cmd(const struct ps3_cmd *cmd); +int ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd); -S32 ps3_vd_direct_req_frame_build(struct ps3_cmd *cmd); +unsigned char ps3_write_direct_enable(struct ps3_cmd *cmd); -Bool ps3_write_direct_enable(struct ps3_cmd *cmd); +unsigned char ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd); -Bool ps3_ssd_vd_qmask_calculate_hba(struct ps3_cmd *cmd); +void ps3_scsih_pd_cmd_word_cpu_set(struct ps3_cmd *cmd); #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c index 71d3887b2bbc..364bd579acc5 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.c @@ -1,35 +1,78 @@ - -#ifndef _WINDOWS +// SPDX-License-Identifier: GPL-2.0 #include #include "ps3_scsih.h" #include "ps3_module_para.h" -#endif #include "ps3_scsih_cmd_parse.h" #include "ps3_err_def.h" #include "ps3_inner_data.h" #include "ps3_instance_manager.h" #include "ps3_driver_log.h" +#include "ps3_kernel_version.h" +#ifndef PS3_WRITE_VERIFY_16 #define PS3_WRITE_VERIFY_16 (0x8e) +#endif + +#ifndef PS3_WRITE_VERIFY_32 #define PS3_WRITE_VERIFY_32 (0x0C) +#endif + +#ifndef ORWRITE_16 #define ORWRITE_16 (0x8B) +#endif + +#ifndef ORWRITE_32 #define ORWRITE_32 (0x0E) +#endif + +#ifndef PRE_FETCH_16 #define PRE_FETCH_16 (0x90) +#endif + +#ifndef READ_BUFFER_16 #define READ_BUFFER_16 (0X9B) +#endif + +#ifndef REPORT_REFERRALS #define REPORT_REFERRALS (0x9E) +#endif + +#ifndef SANITIZE #define SANITIZE (0x48) +#endif + +#ifndef WRITE_ATOMIC_16 #define WRITE_ATOMIC_16 (0x9C) +#endif + +#ifndef WRITE_ATOMIC_32 #define WRITE_ATOMIC_32 (0x0F) +#endif + +#ifndef WRITE_SCATTERED_16 #define WRITE_SCATTERED_16 (0x12) +#endif + +#ifndef WRITE_SCATTERED_32 #define WRITE_SCATTERED_32 (0x0011) +#endif + +#ifndef WRITE_STREAM_16 #define WRITE_STREAM_16 (0x9A) +#endif + +#ifndef WRITE_STREAM_32 #define WRITE_STREAM_32 (0x10) +#endif + +#ifndef WRITE_LONG_16 #define WRITE_LONG_16 (0x11) +#endif -Bool ps3_scsih_is_rw_type(U8 type) +unsigned char ps3_scsih_is_rw_type(unsigned char type) { - Bool is_rw_type = PS3_FALSE; + unsigned char is_rw_type = PS3_FALSE; switch (type) { case PS3_SCSI_CMD_TYPE_READ: @@ -46,32 +89,34 @@ Bool ps3_scsih_is_rw_type(U8 type) return is_rw_type; } -Bool ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd) +unsigned char ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; (void)cmd; return ret; } -Bool ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd) +unsigned char ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd) { - Bool is_need_split = PS3_FALSE; - U32 num_blocks = 0; - U32 lba_lo = 0; - U32 lba_hi = 0; + unsigned char is_need_split = PS3_FALSE; + unsigned int num_blocks = 0; + unsigned int lba_lo = 0; + unsigned int lba_hi = 0; - ps3_scsih_cdb_parse(cmd->scmd->cmnd, &num_blocks, &lba_lo, &lba_hi, &is_need_split); + ps3_scsih_cdb_parse(cmd->scmd->cmnd, &num_blocks, &lba_lo, &lba_hi, + &is_need_split); return is_need_split; } -static U8 ps3_scsih_service_action32_rw_type_get(const U8 *cdb) +static unsigned char +ps3_scsih_service_action32_rw_type_get(const unsigned char *cdb) { - enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKOWN; + enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKNOWN; + unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); - U16 cmd_type = PS3_SERVICE_ACTION32(cdb); switch (cmd_type) { case READ_32: rw_type = PS3_SCSI_CMD_TYPE_READ; @@ -81,7 +126,9 @@ static U8 ps3_scsih_service_action32_rw_type_get(const U8 *cdb) case PS3_WRITE_VERIFY_32: case ORWRITE_32: case WRITE_ATOMIC_32: - rw_type = (enum ps3_scsi_cmd_type)((U8)PS3_SCSI_CMD_TYPE_WRITE | PS3_SCSI_CONFLICT_CHECK); + rw_type = (enum ps3_scsi_cmd_type)( + (unsigned char)PS3_SCSI_CMD_TYPE_WRITE | + PS3_SCSI_CONFLICT_CHECK); break; case VERIFY_32: case WRITE_SAME_32: @@ -95,14 +142,15 @@ static U8 ps3_scsih_service_action32_rw_type_get(const U8 *cdb) break; } - return (U8)rw_type; + return (unsigned char)rw_type; } -static inline U8 ps3_service_action16_rw_type_get(const U8 *cdb) +static inline unsigned char +ps3_service_action16_rw_type_get(const unsigned char *cdb) { - enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKOWN; + enum ps3_scsi_cmd_type rw_type = PS3_SCSI_CMD_TYPE_UNKNOWN; + unsigned char cmd_type = cdb[1] & 0x1f; - U8 cmd_type = cdb[1] & 0x1f; switch (cmd_type) { case WRITE_LONG_16: case WRITE_SCATTERED_16: @@ -113,30 +161,31 @@ static inline U8 ps3_service_action16_rw_type_get(const U8 *cdb) break; } - return (U8)rw_type; + return (unsigned char)rw_type; } -static inline void ps3_scsih_cdb_options_get(const U8 *cdb, - ps3_scsi_cdb_opts_u *cdb_opts) +static inline void +ps3_scsih_cdb_options_get(const unsigned char *cdb, + union ps3_scsi_cdb_option *cdb_opts) { - ps3_scsi_cdb_opts_u *pRead = (ps3_scsi_cdb_opts_u *)(cdb); + union ps3_scsi_cdb_option *pRead = (union ps3_scsi_cdb_option *)(cdb); cdb_opts->fua = pRead->fua; cdb_opts->protect = pRead->protect; cdb_opts->dpo = pRead->dpo; } -S32 ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) +int ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) { - ps3_scsi_cdb_opts_u *cdb_opts = &cmd->io_attr.cdb_opts; + union ps3_scsi_cdb_option *cdb_opts = &cmd->io_attr.cdb_opts; #ifndef _WINDOWS - const U8 *cdb = cmd->scmd->cmnd; + const unsigned char *cdb = cmd->scmd->cmnd; #else - const U8 *cdb = scsi_cmnd_cdb(cmd->scmd); + const unsigned char *cdb = scsi_cmnd_cdb(cmd->scmd); #endif - U16 sub_cmd_type = 0; - S32 ret = PS3_SUCCESS; + unsigned short sub_cmd_type = 0; + int ret = PS3_SUCCESS; switch (cdb[0]) { case READ_10: @@ -173,10 +222,10 @@ S32 ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd) return ret; } -Bool ps3_scsih_is_protocal_rw(const U8 *cdb) +unsigned char ps3_scsih_is_protocal_rw(const unsigned char *cdb) { - Bool ret = PS3_DRV_FALSE; - U16 sub_cmd_type = 0; + unsigned char ret = PS3_DRV_FALSE; + unsigned short sub_cmd_type = 0; switch (cdb[0]) { case READ_6: @@ -207,9 +256,9 @@ Bool ps3_scsih_is_protocal_rw(const U8 *cdb) return ret; } -U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) +unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb) { - U8 rw_type = (U8)PS3_SCSI_CMD_TYPE_UNKOWN; + unsigned char rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_UNKNOWN; switch (cdb[0]) { case READ_6: @@ -218,7 +267,7 @@ U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) case READ_16: case PRE_FETCH: case PRE_FETCH_16: - rw_type = (U8)PS3_SCSI_CMD_TYPE_READ; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_READ; break; case WRITE_6: @@ -230,7 +279,8 @@ U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) case ORWRITE_16: case WRITE_ATOMIC_16: case PS3_WRITE_VERIFY_16: - rw_type = (U8)PS3_SCSI_CMD_TYPE_WRITE | PS3_SCSI_CONFLICT_CHECK; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_WRITE | + PS3_SCSI_CONFLICT_CHECK; break; case VERIFY: case WRITE_SAME: @@ -241,18 +291,20 @@ U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) case SYNCHRONIZE_CACHE_16: case WRITE_STREAM_16: case WRITE_LONG: - rw_type = (U8)PS3_SCSI_CMD_TYPE_WRITE; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_WRITE; break; case VARIABLE_LENGTH_CMD: rw_type = ps3_scsih_service_action32_rw_type_get(cdb); break; case UNMAP: - rw_type = (U8)PS3_SCSI_CMD_TYPE_UNMAP | PS3_SCSI_CONFLICT_CHECK; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_UNMAP | + PS3_SCSI_CONFLICT_CHECK; break; case COMPARE_AND_WRITE: - rw_type = (U8)PS3_SCSI_CMD_TYPE_RW | PS3_SCSI_CONFLICT_CHECK; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_RW | + PS3_SCSI_CONFLICT_CHECK; break; case SERVICE_ACTION_OUT_16: @@ -260,73 +312,81 @@ U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb) break; default: - rw_type = (U8)PS3_SCSI_CMD_TYPE_NORW; + rw_type = (unsigned char)PS3_SCSI_CMD_TYPE_NORW; break; } return rw_type; } -static inline void ps3_scsih_cdb_rw6_rebuild(U8 *cdb, U32 num_blocks, - U32 lba_lo) +static inline void ps3_scsih_cdb_rw6_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo) { cdb[1] &= ~(0x1f); - cdb[1] |= (U8) (lba_lo >> PS3_SHIFT_WORD) & 0x1f; - cdb[2] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[3] = (U8) lba_lo & 0xff; + cdb[1] |= (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0x1f; + cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[3] = (unsigned char)lba_lo & 0xff; - cdb[4] = (256 == num_blocks ) ? 0 : ((U8) num_blocks & 0xff); + cdb[4] = (num_blocks == 256) ? 0 : ((unsigned char)num_blocks & 0xff); } -static inline void ps3_scsih_cdb_rw10_rebuild(U8 *cdb, U32 num_blocks, - U32 lba_lo) +static inline void ps3_scsih_cdb_rw10_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo) { - cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_lo & 0xff; + cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_lo & 0xff; - cdb[7] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[8] = (U8) num_blocks & 0xff; + cdb[7] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[8] = (unsigned char)num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw12_rebuild(U8 *cdb, U32 num_blocks, - U32 lba_lo) +static inline void ps3_scsih_cdb_rw12_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo) { - cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_lo & 0xff; - - cdb[6] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (U8) num_blocks & 0xff; + cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_lo & 0xff; + + cdb[6] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (unsigned char)num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw16_rebuild(U8 *cdb, U32 num_blocks, - U32 lba_lo, U32 lba_hi) +static inline void ps3_scsih_cdb_rw16_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo, + unsigned int lba_hi) { - cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_hi & 0xff; - - cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (U8) lba_lo & 0xff; - - cdb[10] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[11] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[12] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[13] = (U8) num_blocks & 0xff; + cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_hi & 0xff; + + cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (unsigned char)lba_lo & 0xff; + + cdb[10] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[11] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[12] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[13] = (unsigned char)num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw32_rebuild(U8 *cdb, U32 num_blocks, - U32 lba_lo, U32 lba_hi) +static inline void ps3_scsih_cdb_rw32_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo, + unsigned int lba_hi) { - U16 cmd_type = PS3_SERVICE_ACTION32(cdb); + unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); + LOG_DEBUG("[ps3]VARIABLE_LENGTH_CMD :0x%x!\n", cmd_type); switch (cmd_type) { @@ -338,75 +398,80 @@ static inline void ps3_scsih_cdb_rw32_rebuild(U8 *cdb, U32 num_blocks, case ORWRITE_32: case WRITE_ATOMIC_32: case WRITE_STREAM_32: - cdb[12] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[13] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[14] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[15] = (U8) lba_hi & 0xff; - - cdb[16] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[17] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[18] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[19] = (U8) lba_lo & 0xff; - - cdb[20] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[21] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[22] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[23] = (U8) lba_lo & 0xff; - - cdb[28] = (U8) (num_blocks >> PS3_SHIFT_3BYTE) & 0xff; - cdb[29] = (U8) (num_blocks >> PS3_SHIFT_WORD) & 0xff; - cdb[30] = (U8) (num_blocks >> PS3_SHIFT_BYTE) & 0xff; - cdb[31] = (U8) num_blocks & 0xff; + cdb[12] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[13] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[14] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[15] = (unsigned char)lba_hi & 0xff; + + cdb[16] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[17] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[18] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[19] = (unsigned char)lba_lo & 0xff; + cdb[20] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[21] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[22] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[23] = (unsigned char)lba_lo & 0xff; + cdb[28] = (unsigned char)(num_blocks >> PS3_SHIFT_3BYTE) & 0xff; + cdb[29] = (unsigned char)(num_blocks >> PS3_SHIFT_WORD) & 0xff; + cdb[30] = (unsigned char)(num_blocks >> PS3_SHIFT_BYTE) & 0xff; + cdb[31] = (unsigned char)num_blocks & 0xff; break; - default : + default: break; } } -static inline void ps3_scsih_cdb_write_long10_rebuild(U8 *cdb,U32 lba_lo) +static inline void ps3_scsih_cdb_write_long10_rebuild(unsigned char *cdb, + unsigned int lba_lo) { - cdb[2] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_lo & 0xff; + cdb[2] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_lo & 0xff; } -static inline void ps3_cdb_comp_and_write_rebuild(U8 *cdb, - U32 num_blocks, U32 lba_lo, U32 lba_hi) +static inline void ps3_cdb_comp_and_write_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo, + unsigned int lba_hi) { - cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_hi & 0xff; + cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_hi & 0xff; - cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (U8) lba_lo & 0xff; + cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (unsigned char)lba_lo & 0xff; - cdb[13] = (U8) num_blocks & 0xff; + cdb[13] = (unsigned char)num_blocks & 0xff; } -static inline void ps3_scsih_service_16_rebuild(U8 *cdb, - U32 lba_lo, U32 lba_hi) +static inline void ps3_scsih_service_16_rebuild(unsigned char *cdb, + unsigned int lba_lo, + unsigned int lba_hi) { - U8 cmd_type = cdb[1] & 0x1f; + unsigned char cmd_type = cdb[1] & 0x1f; + LOG_DEBUG("[ps3] CMD :0x%x!\n", cmd_type); - if (WRITE_LONG_16 == cmd_type) { - cdb[2] = (U8) (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; - cdb[3] = (U8) (lba_hi >> PS3_SHIFT_WORD) & 0xff; - cdb[4] = (U8) (lba_hi >> PS3_SHIFT_BYTE) & 0xff; - cdb[5] = (U8) lba_hi & 0xff; + if (cmd_type == WRITE_LONG_16) { + cdb[2] = (unsigned char)(lba_hi >> PS3_SHIFT_3BYTE) & 0xff; + cdb[3] = (unsigned char)(lba_hi >> PS3_SHIFT_WORD) & 0xff; + cdb[4] = (unsigned char)(lba_hi >> PS3_SHIFT_BYTE) & 0xff; + cdb[5] = (unsigned char)lba_hi & 0xff; - cdb[6] = (U8) (lba_lo >> PS3_SHIFT_3BYTE) & 0xff; - cdb[7] = (U8) (lba_lo >> PS3_SHIFT_WORD) & 0xff; - cdb[8] = (U8) (lba_lo >> PS3_SHIFT_BYTE) & 0xff; - cdb[9] = (U8) lba_lo & 0xff; + cdb[6] = (unsigned char)(lba_lo >> PS3_SHIFT_3BYTE) & 0xff; + cdb[7] = (unsigned char)(lba_lo >> PS3_SHIFT_WORD) & 0xff; + cdb[8] = (unsigned char)(lba_lo >> PS3_SHIFT_BYTE) & 0xff; + cdb[9] = (unsigned char)lba_lo & 0xff; } } -static inline void ps3_scsih_atomic_stream_16_rebuild(U8 *cdb, - U32 num_blocks, U32 lba_lo, U32 lba_hi) +static inline void ps3_scsih_atomic_stream_16_rebuild(unsigned char *cdb, + unsigned int num_blocks, + unsigned int lba_lo, + unsigned int lba_hi) { cdb[2] = (lba_hi >> PS3_SHIFT_3BYTE) & 0xff; cdb[3] = (lba_hi >> PS3_SHIFT_WORD) & 0xff; @@ -422,61 +487,77 @@ static inline void ps3_scsih_atomic_stream_16_rebuild(U8 *cdb, cdb[13] = num_blocks & 0xff; } -static inline void ps3_scsih_cdb_rw6_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_cdb_rw6_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { - const U32 default_num_blocks = 256; + const unsigned int default_num_blocks = 256; (void)lba_hi; - *lba_lo = (U32)(((cdb[1] & 0x1f) << PS3_SHIFT_WORD) | - (cdb[2] << PS3_SHIFT_BYTE) | cdb[3]); - *num_blocks = ((U32)cdb[4] == 0) ? default_num_blocks : (U32)cdb[4]; - return; + *lba_lo = (unsigned int)(((cdb[1] & 0x1f) << PS3_SHIFT_WORD) | + (cdb[2] << PS3_SHIFT_BYTE) | cdb[3]); + *num_blocks = ((unsigned int)cdb[4] == 0) ? default_num_blocks : + (unsigned int)cdb[4]; } -static inline void ps3_scsih_cdb_rw10_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_cdb_rw10_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { (void)lba_hi; - *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks = ((U32)cdb[8] | ((U32)cdb[7] << PS3_SHIFT_BYTE)); + *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = ((unsigned int)cdb[8] | + ((unsigned int)cdb[7] << PS3_SHIFT_BYTE)); - return; } -static inline void ps3_scsih_cdb_rw12_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_cdb_rw12_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { (void)lba_hi; - *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | - ((U32)cdb[7] << PS3_SHIFT_WORD) | - ((U32)cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; - return; + *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[9]; } -static inline void ps3_scsih_cdb_rw16_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_cdb_rw16_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { - *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | - ((U32)cdb[7] << PS3_SHIFT_WORD) | - ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; - *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks = ((U32)cdb[10] << PS3_SHIFT_3BYTE) | - ((U32)cdb[11] << PS3_SHIFT_WORD) | - ((U32)cdb[12] << PS3_SHIFT_BYTE) | (U32)cdb[13]; - return; + *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[9]; + *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = ((unsigned int)cdb[10] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[11] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[12] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[13]; } -static inline void ps3_scsih_cdb_rw32_parse(const U8 *cdb, - U32 *num_blocks, U32 *lba_lo, U32 *lba_hi, Bool *is_need_split) +static inline void ps3_scsih_cdb_rw32_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi, + unsigned char *is_need_split) { - U16 cmd_type = PS3_SERVICE_ACTION32(cdb); + unsigned short cmd_type = PS3_SERVICE_ACTION32(cdb); + LOG_DEBUG("[ps3]VARIABLE_LENGTH_CMD :0x%x!\n", cmd_type); *is_need_split = PS3_FALSE; @@ -485,23 +566,27 @@ static inline void ps3_scsih_cdb_rw32_parse(const U8 *cdb, case WRITE_32: case PS3_WRITE_VERIFY_32: *is_need_split = PS3_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) +#if defined(PS3_FALLTHROUGH) fallthrough; #endif + /* fallthrough */ case VERIFY_32: case WRITE_SAME_32: case ORWRITE_32: case WRITE_ATOMIC_32: case WRITE_STREAM_32: - *lba_lo = ((U32)cdb[16] << PS3_SHIFT_3BYTE) | - ((U32)cdb[17] << PS3_SHIFT_WORD) | - ((U32) cdb[18] << PS3_SHIFT_BYTE) | (U32)cdb[19]; - *lba_hi = ((U32)cdb[12] << PS3_SHIFT_3BYTE) | - ((U32)cdb[13] << PS3_SHIFT_WORD) | - ((U32)cdb[14] << PS3_SHIFT_BYTE) | (U32)cdb[15]; - *num_blocks = ((U32)cdb[28] << PS3_SHIFT_3BYTE) | - ((U32)cdb[29] << PS3_SHIFT_WORD) | - ((U32)cdb[30] << PS3_SHIFT_BYTE) | (U32)cdb[31]; + *lba_lo = ((unsigned int)cdb[16] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[17] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[18] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[19]; + *lba_hi = ((unsigned int)cdb[12] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[13] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[14] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[15]; + *num_blocks = ((unsigned int)cdb[28] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[29] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[30] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[31]; break; case WRITE_SCATTERED_32: @@ -513,45 +598,56 @@ static inline void ps3_scsih_cdb_rw32_parse(const U8 *cdb, break; } - return; } -static inline void ps3_cdb_write_long10_parse(const U8 *cdb, - U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) +static inline void ps3_cdb_write_long10_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { (void)lba_hi; - *lba_lo = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks =1; + *lba_lo = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = 1; } -static inline void ps3_cdb_comp_and_write_parse(const U8 *cdb, - U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) +static inline void ps3_cdb_comp_and_write_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { - *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | - ((U32)cdb[7] << PS3_SHIFT_WORD) | - ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; - *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks = (U32)cdb[13]; + *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[9]; + *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = (unsigned int)cdb[13]; } -static inline void ps3_scsih_service_16_parse(const U8 *cdb, - U32 *num_blocks, U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_service_16_parse(const unsigned char *cdb, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { - U8 cmd_type = cdb[1] & 0x1f; + unsigned char cmd_type = cdb[1] & 0x1f; + LOG_DEBUG("[ps3] CMD :0x%x!\n", cmd_type); switch (cmd_type) { case WRITE_LONG_16: - *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | - ((U32)cdb[7] << PS3_SHIFT_WORD) | - ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; - *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; + *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[9]; + *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; *num_blocks = 1; break; @@ -564,11 +660,11 @@ static inline void ps3_scsih_service_16_parse(const U8 *cdb, break; } - return; } -void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi, Bool *is_need_split) +void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, + unsigned int *lba_lo, unsigned int *lba_hi, + unsigned char *is_need_split) { *num_blocks = 0; *lba_lo = 0; @@ -586,9 +682,10 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, case WRITE_10: case WRITE_VERIFY: *is_need_split = PS3_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) +#if defined(PS3_FALLTHROUGH) fallthrough; #endif + /* fallthrough */ case VERIFY: case WRITE_SAME: case PRE_FETCH: @@ -600,9 +697,10 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, case WRITE_12: case WRITE_VERIFY_12: *is_need_split = PS3_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) +#if defined(PS3_FALLTHROUGH) fallthrough; #endif + /* fallthrough */ case VERIFY_12: ps3_scsih_cdb_rw12_parse(cdb, num_blocks, lba_lo, lba_hi); break; @@ -611,9 +709,10 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, case WRITE_16: case PS3_WRITE_VERIFY_16: *is_need_split = PS3_TRUE; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) +#if defined(PS3_FALLTHROUGH) fallthrough; #endif + /* fallthrough */ case VERIFY_16: case WRITE_SAME_16: case ORWRITE_16: @@ -628,7 +727,8 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, break; case VARIABLE_LENGTH_CMD: - ps3_scsih_cdb_rw32_parse(cdb, num_blocks, lba_lo, lba_hi, is_need_split); + ps3_scsih_cdb_rw32_parse(cdb, num_blocks, lba_lo, lba_hi, + is_need_split); break; case COMPARE_AND_WRITE: @@ -637,13 +737,16 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, case WRITE_ATOMIC_16: case WRITE_STREAM_16: - *lba_lo = ((U32)cdb[6] << PS3_SHIFT_3BYTE) | - ((U32)cdb[7] << PS3_SHIFT_WORD) | - ((U32) cdb[8] << PS3_SHIFT_BYTE) | (U32)cdb[9]; - *lba_hi = ((U32)cdb[2] << PS3_SHIFT_3BYTE) | - ((U32)cdb[3] << PS3_SHIFT_WORD) | - ((U32)cdb[4] << PS3_SHIFT_BYTE) | (U32)cdb[5]; - *num_blocks = ((U32)cdb[12] << PS3_SHIFT_BYTE) | (U32)cdb[13]; + *lba_lo = ((unsigned int)cdb[6] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[7] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[8] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[9]; + *lba_hi = ((unsigned int)cdb[2] << PS3_SHIFT_3BYTE) | + ((unsigned int)cdb[3] << PS3_SHIFT_WORD) | + ((unsigned int)cdb[4] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[5]; + *num_blocks = ((unsigned int)cdb[12] << PS3_SHIFT_BYTE) | + (unsigned int)cdb[13]; break; case WRITE_LONG: @@ -658,14 +761,17 @@ void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, break; } - return; } -static inline void ps3_convert_to_cdb16(U8 *cdb, U16 cdb_len, U32 num_blocks, U32 lba_lo, U32 lba_hi) +static inline void ps3_convert_to_cdb16(unsigned char *cdb, + unsigned short cdb_len, + unsigned int num_blocks, + unsigned int lba_lo, + unsigned int lba_hi) { - U8 opcode = 0; - U8 flagvals = 0; - U8 groupnum = 0; - U8 control = 0; + unsigned char opcode = 0; + unsigned char flagvals = 0; + unsigned char groupnum = 0; + unsigned char control = 0; switch (cdb_len) { case 6: @@ -673,15 +779,13 @@ static inline void ps3_convert_to_cdb16(U8 *cdb, U16 cdb_len, U32 num_blocks, U3 control = cdb[5]; break; case 10: - opcode = - cdb[0] == READ_10 ? READ_16 : WRITE_16; + opcode = cdb[0] == READ_10 ? READ_16 : WRITE_16; flagvals = cdb[1]; groupnum = cdb[6]; control = cdb[9]; break; case 12: - opcode = - cdb[0] == READ_12 ? READ_16 : WRITE_16; + opcode = cdb[0] == READ_12 ? READ_16 : WRITE_16; flagvals = cdb[1]; groupnum = cdb[10]; control = cdb[11]; @@ -694,26 +798,27 @@ static inline void ps3_convert_to_cdb16(U8 *cdb, U16 cdb_len, U32 num_blocks, U3 cdb[1] = flagvals; cdb[14] = groupnum; cdb[15] = control; - - cdb[9] = (U8)(lba_lo & 0xff); - cdb[8] = (U8)((lba_lo >> PS3_SHIFT_BYTE) & 0xff); - cdb[7] = (U8)((lba_lo >> PS3_SHIFT_WORD) & 0xff); - cdb[6] = (U8)((lba_lo >> PS3_SHIFT_3BYTE) & 0xff); - cdb[5] = (U8)(lba_hi & 0xff); - cdb[4] = (U8)((lba_hi >> PS3_SHIFT_BYTE) & 0xff); - cdb[3] = (U8)((lba_hi >> PS3_SHIFT_WORD) & 0xff); - cdb[2] = (U8)((lba_hi >> PS3_SHIFT_3BYTE) & 0xff); - - cdb[13] = (U8)(num_blocks & 0xff); - cdb[12] = (U8)((num_blocks >> PS3_SHIFT_BYTE) & 0xff); - cdb[11] = (U8)((num_blocks >> PS3_SHIFT_WORD) & 0xff); - cdb[10] = (U8)((num_blocks >> PS3_SHIFT_3BYTE) & 0xff); + cdb[9] = (unsigned char)(lba_lo & 0xff); + cdb[8] = (unsigned char)((lba_lo >> PS3_SHIFT_BYTE) & 0xff); + cdb[7] = (unsigned char)((lba_lo >> PS3_SHIFT_WORD) & 0xff); + cdb[6] = (unsigned char)((lba_lo >> PS3_SHIFT_3BYTE) & 0xff); + cdb[5] = (unsigned char)(lba_hi & 0xff); + cdb[4] = (unsigned char)((lba_hi >> PS3_SHIFT_BYTE) & 0xff); + cdb[3] = (unsigned char)((lba_hi >> PS3_SHIFT_WORD) & 0xff); + cdb[2] = (unsigned char)((lba_hi >> PS3_SHIFT_3BYTE) & 0xff); + cdb[13] = (unsigned char)(num_blocks & 0xff); + cdb[12] = (unsigned char)((num_blocks >> PS3_SHIFT_BYTE) & 0xff); + cdb[11] = (unsigned char)((num_blocks >> PS3_SHIFT_WORD) & 0xff); + cdb[10] = (unsigned char)((num_blocks >> PS3_SHIFT_3BYTE) & 0xff); } -void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, - U32 lba_lo, U32 lba_hi) +void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, + unsigned int num_blocks, unsigned int lba_lo, + unsigned int lba_hi) { - if (unlikely((cdb_len < 16) && (((U64)lba_hi << PS3_SHIFT_DWORD | lba_lo) > 0xffffffff))) { + if (unlikely((cdb_len < 16) && + (((unsigned long long)lba_hi << PS3_SHIFT_DWORD | lba_lo) > + 0xffffffff))) { ps3_convert_to_cdb16(cdb, cdb_len, num_blocks, lba_lo, lba_hi); goto l_out; } @@ -721,7 +826,7 @@ void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, switch (cdb[0]) { case READ_6: case WRITE_6: - ps3_scsih_cdb_rw6_rebuild( cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw6_rebuild(cdb, num_blocks, lba_lo); break; case READ_10: @@ -731,14 +836,14 @@ void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, case WRITE_SAME: case PRE_FETCH: case SYNCHRONIZE_CACHE: - ps3_scsih_cdb_rw10_rebuild( cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw10_rebuild(cdb, num_blocks, lba_lo); break; case READ_12: case WRITE_12: case VERIFY_12: case WRITE_VERIFY_12: - ps3_scsih_cdb_rw12_rebuild( cdb, num_blocks, lba_lo); + ps3_scsih_cdb_rw12_rebuild(cdb, num_blocks, lba_lo); break; case READ_16: @@ -749,7 +854,7 @@ void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, case ORWRITE_16: case PRE_FETCH_16: case SYNCHRONIZE_CACHE_16: - ps3_scsih_cdb_rw16_rebuild( cdb, num_blocks, lba_lo, lba_hi); + ps3_scsih_cdb_rw16_rebuild(cdb, num_blocks, lba_lo, lba_hi); break; case VARIABLE_LENGTH_CMD: @@ -762,7 +867,8 @@ void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, case WRITE_ATOMIC_16: case WRITE_STREAM_16: - ps3_scsih_atomic_stream_16_rebuild(cdb, num_blocks, lba_lo, lba_hi); + ps3_scsih_atomic_stream_16_rebuild(cdb, num_blocks, lba_lo, + lba_hi); break; case WRITE_LONG: @@ -780,25 +886,24 @@ void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, return; } -void ps3_scsih_lba_parse(const U8 *cdb, U64 *lba) +void ps3_scsih_lba_parse(const unsigned char *cdb, unsigned long long *lba) { - U32 num_blocks = 0; - U32 lba_lo = 0; - U32 lba_hi = 0; - Bool is_need_split = PS3_FALSE; + unsigned int num_blocks = 0; + unsigned int lba_lo = 0; + unsigned int lba_hi = 0; + unsigned char is_need_split = PS3_FALSE; ps3_scsih_cdb_parse(cdb, &num_blocks, &lba_lo, &lba_hi, &is_need_split); - *lba = ((U64)lba_hi << PS3_SHIFT_DWORD) | lba_lo; + *lba = ((unsigned long long)lba_hi << PS3_SHIFT_DWORD) | lba_lo; } -void ps3_scsih_len_parse(const U8 *cdb, U32 *len) +void ps3_scsih_len_parse(const unsigned char *cdb, unsigned int *len) { - U32 num_blocks = 0; - U32 lba_lo = 0; - U32 lba_hi = 0; - Bool is_need_split = PS3_FALSE; + unsigned int num_blocks = 0; + unsigned int lba_lo = 0; + unsigned int lba_hi = 0; + unsigned char is_need_split = PS3_FALSE; ps3_scsih_cdb_parse(cdb, &num_blocks, &lba_lo, &lba_hi, &is_need_split); *len = num_blocks; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h index 5add446d624a..dde93d2a3cbd 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_cmd_parse.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_SCSIH_CMD_PARSE_H_ #define _PS3_SCSIH_CMD_PARSE_H_ @@ -6,57 +7,14 @@ #include "ps3_inner_data.h" #include "ps3_driver_log.h" -#ifndef _WINDOWS #include -#else - -#define VARIABLE_LENGTH_CMD 0x7f -#define SYNCHRONIZE_CACHE_16 0x91 -#define SYNCHRONIZE_CACHE 0x35 - -#define FORMAT_UNIT 0x04 -#define REASSIGN_BLOCKS 0x07 -#define READ_6 0x08 -#define WRITE_6 0x0a -#define READ_10 0x28 -#define WRITE_10 0x2a -#define WRITE_VERIFY 0x2e -#define VERIFY 0x2f -#define PRE_FETCH 0x34 -#define SYNCHRONIZE_CACHE 0x35 -#define WRITE_LONG 0x3f -#define WRITE_SAME 0x41 -#define UNMAP 0x42 -#define VARIABLE_LENGTH_CMD 0x7f -#define READ_12 0xa8 -#define WRITE_12 0xaa -#define WRITE_VERIFY_12 0xae -#define VERIFY_12 0xaf -#define EXTENDED_COPY 0x83 -#define READ_16 0x88 -#define COMPARE_AND_WRITE 0x89 -#define WRITE_16 0x8a -#define WRITE_ATTRIBUTE 0x8d -#define PS3_WRITE_VERIFY_16 0x8e -#define VERIFY_16 0x8f -#define SYNCHRONIZE_CACHE_16 0x91 -#define WRITE_SAME_16 0x93 -#define SERVICE_ACTION_IN_16 0x9e -#define SERVICE_ACTION_OUT_16 0x9f -#define READ_32 0x09 -#define VERIFY_32 0x0a -#define WRITE_32 0x0b -#define PS3_WRITE_VERIFY_32 0x0c -#define WRITE_SAME_32 0x0d -#endif - -#define PS3_SCSI_CONFLICT_CHECK 0x80 -#define PS3_SCSI_CONFLICT_CHECK_TEST(type) ((type) & PS3_SCSI_CONFLICT_CHECK) -#define PS3_SCSI_CMD_TYPE(type) ((type) & 0x7F) +#define PS3_SCSI_CONFLICT_CHECK 0x80 +#define PS3_SCSI_CONFLICT_CHECK_TEST(type) ((type)&PS3_SCSI_CONFLICT_CHECK) +#define PS3_SCSI_CMD_TYPE(type) ((type)&0x7F) enum ps3_scsi_cmd_type { - PS3_SCSI_CMD_TYPE_UNKOWN, + PS3_SCSI_CMD_TYPE_UNKNOWN, PS3_SCSI_CMD_TYPE_READ, PS3_SCSI_CMD_TYPE_WRITE, PS3_SCSI_CMD_TYPE_RW, @@ -67,7 +25,7 @@ enum ps3_scsi_cmd_type { enum { PS3_ATA_OPC_READ_FPDMA = 0x60, - PS3_ATA_OPC_WRITE_FPDMA =0x61, + PS3_ATA_OPC_WRITE_FPDMA = 0x61, PS3_SATA_DEV_REG_DEFAULT = 0x40, PS3_NCQ_FUA_OFFSET_IN_DEVICE_REG = 7, }; @@ -75,17 +33,19 @@ enum { #define PS3_SERVICE_ACTION32(cdb) (*(cdb + 9) | (*(cdb + 8) << PS3_SHIFT_BYTE)) #define PS3_SERVICE_ACTION16_TO_OPCODE(cdb) (*(cdb + 1) & 0x1f) -static inline void ps3_scsih_cdb_opcode_get(const U8 *cdb, - U8 *opcode, U16 *sub_opcode) +static inline void ps3_scsih_cdb_opcode_get(const unsigned char *cdb, + unsigned char *opcode, + unsigned short *sub_opcode) { *opcode = cdb[0]; - switch(cdb[0]) { + switch (cdb[0]) { case VARIABLE_LENGTH_CMD: *sub_opcode = PS3_SERVICE_ACTION32(cdb); break; case SERVICE_ACTION_IN_16: case SERVICE_ACTION_OUT_16: - *sub_opcode = (U16)PS3_SERVICE_ACTION16_TO_OPCODE(cdb); + *sub_opcode = + (unsigned short)PS3_SERVICE_ACTION16_TO_OPCODE(cdb); break; default: *sub_opcode = 0; @@ -94,34 +54,35 @@ static inline void ps3_scsih_cdb_opcode_get(const U8 *cdb, } #ifndef U32_HIGH_LOW_TO_U64 -#define U32_HIGH_LOW_TO_U64(u64_high, u64_low) \ - (((U64)(u64_high) << 32) | (u64_low)) +#define U32_HIGH_LOW_TO_U64(u64_high, u64_low) \ + (((unsigned long long)(u64_high) << 32) | (u64_low)) #endif -Bool ps3_scsih_is_rw_type(U8 type); +unsigned char ps3_scsih_is_rw_type(unsigned char type); -U8 ps3_scsih_cdb_rw_type_get(const U8 *cdb); +unsigned char ps3_scsih_cdb_rw_type_get(const unsigned char *cdb); -void ps3_scsih_cdb_parse(const U8 *cdb, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi, Bool *is_need_split); +void ps3_scsih_cdb_parse(const unsigned char *cdb, unsigned int *num_blocks, + unsigned int *lba_lo, unsigned int *lba_hi, + unsigned char *is_need_split); -static inline Bool ps3_scsih_cdb_is_rw_cmd(const U8 *cdb) +static inline unsigned char ps3_scsih_cdb_is_rw_cmd(const unsigned char *cdb) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + return ps3_scsih_is_rw_type(type); } -static inline Bool ps3_scsih_is_read_cmd(U8 type) +static inline unsigned char ps3_scsih_is_read_cmd(unsigned char type) { return (type == PS3_SCSI_CMD_TYPE_READ); } -static inline Bool ps3_scsih_is_write_cmd(U8 type) +static inline unsigned char ps3_scsih_is_write_cmd(unsigned char type) { - Bool ret = PS3_FALSE; + unsigned char ret = PS3_FALSE; - switch (type) - { + switch (type) { case PS3_SCSI_CMD_TYPE_WRITE: case PS3_SCSI_CMD_TYPE_UNMAP: case PS3_SCSI_CMD_TYPE_RW: @@ -134,50 +95,58 @@ static inline Bool ps3_scsih_is_write_cmd(U8 type) l_out: return ret; } -static inline Bool ps3_scsih_is_sync_cache(const U8 *cdb) +static inline unsigned char ps3_scsih_is_sync_cache(const unsigned char *cdb) { return cdb[0] == SYNCHRONIZE_CACHE || cdb[0] == SYNCHRONIZE_CACHE_16; } -void ps3_scsih_lba_parse(const U8 *cdb, U64 *lba); +void ps3_scsih_lba_parse(const unsigned char *cdb, unsigned long long *lba); -void ps3_scsih_len_parse(const U8 *cdb, U32 *len); +void ps3_scsih_len_parse(const unsigned char *cdb, unsigned int *len); -S32 ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd); +int ps3_scsih_cdb_opts_parse(struct ps3_cmd *cmd); -void ps3_scsih_cdb_rebuild(U8 *cdb, U16 cdb_len, U32 num_blocks, U32 lba_lo, U32 lba_hi); +void ps3_scsih_cdb_rebuild(unsigned char *cdb, unsigned short cdb_len, + unsigned int num_blocks, unsigned int lba_lo, + unsigned int lba_hi); -static inline Bool ps3_scsih_cdb_is_read_cmd(const U8 *cdb) +static inline unsigned char ps3_scsih_cdb_is_read_cmd(const unsigned char *cdb) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + return ps3_scsih_is_read_cmd(type); } -static inline Bool ps3_scsih_cdb_is_write_cmd(const U8 *cdb) +static inline unsigned char ps3_scsih_cdb_is_write_cmd(const unsigned char *cdb) { - U8 type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + unsigned char type = PS3_SCSI_CMD_TYPE(ps3_scsih_cdb_rw_type_get(cdb)); + return ps3_scsih_is_write_cmd(type); } -Bool ps3_scsih_is_protocal_rw(const U8 *cdb); +unsigned char ps3_scsih_is_protocal_rw(const unsigned char *cdb); -Bool ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd); +unsigned char ps3_scsih_rw_cmd_is_need_split_hba(struct ps3_cmd *cmd); -Bool ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd); +unsigned char ps3_scsih_rw_cmd_is_need_split_raid(struct ps3_cmd *cmd); -static inline void ps3_scsih_unmap_desc_parse(const U8 *desc, U32 *num_blocks, - U32 *lba_lo, U32 *lba_hi) +static inline void ps3_scsih_unmap_desc_parse(const unsigned char *desc, + unsigned int *num_blocks, + unsigned int *lba_lo, + unsigned int *lba_hi) { - *lba_lo = ((U32)desc[4] << PS3_SHIFT_3BYTE) | - ((U32)desc[5] << PS3_SHIFT_WORD) | - ((U32) desc[6] << PS3_SHIFT_BYTE) | (U32)desc[7]; - *lba_hi = ((U32)desc[0] << PS3_SHIFT_3BYTE) | - ((U32)desc[1] << PS3_SHIFT_WORD) | - ((U32)desc[2] << PS3_SHIFT_BYTE) | (U32)desc[3]; - *num_blocks = ((U32)desc[8] << PS3_SHIFT_3BYTE) | - ((U32)desc[9] << PS3_SHIFT_WORD) | - ((U32)desc[10] << PS3_SHIFT_BYTE) | (U32)desc[11]; - return; + *lba_lo = ((unsigned int)desc[4] << PS3_SHIFT_3BYTE) | + ((unsigned int)desc[5] << PS3_SHIFT_WORD) | + ((unsigned int)desc[6] << PS3_SHIFT_BYTE) | + (unsigned int)desc[7]; + *lba_hi = ((unsigned int)desc[0] << PS3_SHIFT_3BYTE) | + ((unsigned int)desc[1] << PS3_SHIFT_WORD) | + ((unsigned int)desc[2] << PS3_SHIFT_BYTE) | + (unsigned int)desc[3]; + *num_blocks = ((unsigned int)desc[8] << PS3_SHIFT_3BYTE) | + ((unsigned int)desc[9] << PS3_SHIFT_WORD) | + ((unsigned int)desc[10] << PS3_SHIFT_BYTE) | + (unsigned int)desc[11]; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c index 9e63e076825b..4bd1bfbae827 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.c @@ -1,5 +1,5 @@ - -#ifndef _WINDOWS +// SPDX-License-Identifier: GPL-2.0 +#ifndef _WINDOWS #include #include #else @@ -8,36 +8,40 @@ #include "ps3_scsih_raid_engine.h" #include "ps3_instance_manager.h" -#include "ps3_meta.h" +#include "ps3_htp_meta.h" #include "ps3_scsih_cmd_parse.h" #include "ps3_driver_log.h" #include "ps3_util.h" #include "ps3_module_para.h" #include "ps3_scsih.h" -#define LBA_TO_STRIPE_INDEX(u64_lba, u32_stripe_data_size, u64_stripe_idx) \ - (u64_stripe_idx) = (u64_lba) / (u32_stripe_data_size) +#define LBA_TO_STRIPE_INDEX(u64_lba, u32_stripe_data_size, u64_stripe_idx) \ + ((u64_stripe_idx) = (PS3_DIV64_32((u64_lba), (u32_stripe_data_size)))) #define LBA_TO_STRIPE_OFFSET(u64_lba, u32_stripe_data_size, u32_stripe_offset) \ - (u32_stripe_offset) = (u64_lba) % (u32_stripe_data_size) - -#define SPANNO_DISKIDX_TO_PHYDISKID(vd_entry, span_idx, span_disk_idx) \ - (vd_entry)->span[(span_idx)].extent[(span_disk_idx)].phyDiskID.ps3Dev.phyDiskID - -#define VD_SPAN_PD_NUM(vd_entry, span_idx) \ - (vd_entry)->span[(span_idx)].spanPdNum - -#define STRIP_SIZE_MASK(strip_size) ((strip_size) - 1) - -#define RAID660_GET_PQ_SPINDLENO(stripe_idx, phy_disk_count, q_disk_idx) \ -do { \ - if (ps3_is_power_of_2(phy_disk_count)){ \ - (q_disk_idx) = (stripe_idx) & ((phy_disk_count) - 1); \ - } else { \ - (q_disk_idx) = (stripe_idx) % (phy_disk_count); \ - } \ - (q_disk_idx) = (phy_disk_count) - (q_disk_idx) - 1; \ -} while (0); + ((u32_stripe_offset) = (PS3_MOD64((u64_lba), (u32_stripe_data_size)))) + +#define SPANNO_DISKIDX_TO_PHYDISKID(vd_entry, span_idx, span_disk_idx) \ + ((vd_entry) \ + ->span[(span_idx)] \ + .extent[(span_disk_idx)] \ + .phyDiskID.ps3Dev.phyDiskID) + +#define VD_SPAN_PD_NUM(vd_entry, span_idx) \ + ((vd_entry)->span[(span_idx)].spanPdNum) + +#define STRIP_SIZE_MASK(strip_size) ((strip_size)-1) + +#define RAID660_GET_PQ_SPINDLENO(stripe_idx, phy_disk_count, q_disk_idx) \ + do { \ + if (ps3_is_power_of_2(phy_disk_count)) { \ + (q_disk_idx) = (stripe_idx) & ((phy_disk_count)-1); \ + } else { \ + (q_disk_idx) = \ + PS3_MOD64((stripe_idx), (phy_disk_count)); \ + } \ + (q_disk_idx) = (phy_disk_count) - (q_disk_idx)-1; \ + } while (0) #define PS3_R1X_HDD_MAX_SWAP_CNT_1 (64) #define PS3_R1X_HDD_MAX_SWAP_CNT_2 (32) @@ -45,19 +49,20 @@ do { \ #define PS3_R1X_SSD_MAX_SWAP_CNT_2 (16) #define PS3_R1X_SWAP_VD_MEMBER_CNT (8) #define PS3_R1X_RB_DIFF_CMDS_DEFAULT (4) -#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) -#define PS3_R1X_RB_INFO_INDEX(span, span_disk_idx) \ - ((span) * PS3_MAX_PD_COUNT_IN_SPAN + (span_disk_idx) + 1) -U32 g_ps3_r1x_rb_diff_cmds = PS3_R1X_RB_DIFF_CMDS_DEFAULT; +#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) +#define PS3_R1X_RB_INFO_INDEX(span, span_disk_idx) \ + ((span) * PS3_MAX_PD_COUNT_IN_SPAN + (span_disk_idx) + 1) +unsigned int g_ps3_r1x_rb_diff_cmds = PS3_R1X_RB_DIFF_CMDS_DEFAULT; -static inline Bool ps3_is_power_of_2(U32 n) +static inline unsigned char ps3_is_power_of_2(unsigned int n) { - return (Bool)(n != 0 && ((n & (n - 1)) == 0)); + return (unsigned char)(n != 0 && ((n & (n - 1)) == 0)); } -static inline Bool ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) +static inline unsigned char +ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) { - Bool ret = PS3_DRV_TRUE; + unsigned char ret = PS3_DRV_TRUE; if (unlikely(vd_entry == NULL)) { ret = PS3_DRV_FALSE; @@ -77,133 +82,178 @@ static inline Bool ps3_vd_entry_valid_check(const struct PS3VDEntry *vd_entry) return ret; } -Bool ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, U32 vlba_lo, U32 lba_length) +unsigned char ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, + unsigned int vlba_lo, + unsigned int lba_length) { - if (unlikely(!ps3_vd_entry_valid_check(vd_entry))) { + if (unlikely(!ps3_vd_entry_valid_check(vd_entry))) return PS3_DRV_FALSE; - } - if ( (vd_entry->stripSize - (vlba_lo & STRIP_SIZE_MASK(vd_entry->stripSize)) ) - >= lba_length ) { + if ((vd_entry->stripSize - + (vlba_lo & STRIP_SIZE_MASK(vd_entry->stripSize))) >= lba_length) { return PS3_DRV_TRUE; - } else { + } else { return PS3_DRV_FALSE; } } static void ps3_r0_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; } -static void ps3_r1x_rand_read_target_pd_calc(struct ps3_cmd *cmd, U32 span_idx, - U32 span_pd_idx, U32 span_pd_back_idx) +static void ps3_r1x_rand_read_target_pd_calc(struct ps3_cmd *cmd, + unsigned int span_idx, + unsigned int span_pd_idx, + unsigned int span_pd_back_idx) { struct ps3_r1x_read_balance_info *rb_info = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - U64 vlba = 0; - U32 outstanding0 = 0; - U32 outstanding1 = 0; - U64 diff0 = 0; - U64 diff1 = 0; - U32 pd0 = 0; - U32 pd1 = 0; - U32 target_pd = 0; + unsigned long long vlba = 0; + unsigned int outstanding0 = 0; + unsigned int outstanding1 = 0; + unsigned long long diff0 = 0; + unsigned long long diff1 = 0; + unsigned int pd0 = 0; + unsigned int pd1 = 0; + unsigned char pd0_state = 0; + unsigned char pd1_state = 0; + unsigned int target_pd = 0; if (!cmd->r1x_read_pd) { priv_data = scsi_device_private_data(cmd->scmd); rb_info = priv_data->r1x_rb_info; - vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, + cmd->io_attr.lba_lo); pd0 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_idx); pd1 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_back_idx); - outstanding0 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); - outstanding1 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); - - if (outstanding0 > outstanding1 + g_ps3_r1x_rb_diff_cmds) { + pd0_state = ps3_vd_member_state_get(cmd->io_attr.vd_entry, span_idx, span_pd_idx); + pd1_state = ps3_vd_member_state_get(cmd->io_attr.vd_entry, span_idx, span_pd_back_idx); + + if (pd0_state == MIC_PD_STATE_ONLINE && pd1_state == MIC_PD_STATE_ONLINE) { + outstanding0 = + ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); + outstanding1 = + ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); + + if (outstanding0 > outstanding1 + g_ps3_r1x_rb_diff_cmds) { + target_pd = pd1; + } else if (outstanding1 > + outstanding0 + g_ps3_r1x_rb_diff_cmds) { + target_pd = pd0; + } else { + diff0 = ABS_DIFF(vlba, + rb_info->last_accessed_block[pd0]); + diff1 = ABS_DIFF(vlba, + rb_info->last_accessed_block[pd1]); + target_pd = (diff0 <= diff1 ? pd0 : pd1); + } + } else if (pd1_state == MIC_PD_STATE_ONLINE) { target_pd = pd1; - } else if (outstanding1 > outstanding0 + g_ps3_r1x_rb_diff_cmds) { - target_pd = pd0; } else { - diff0 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd0]); - diff1 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd1]); - target_pd = (diff0 <= diff1 ? pd0 : pd1); + target_pd = pd0; } if (target_pd == pd0) { - cmd->io_attr.span_pd_idx = (U8)span_pd_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_pd_back_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_pd_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_back_idx; + cmd->io_attr.target_pd_state = pd0_state; } else { - cmd->io_attr.span_pd_idx = (U8)span_pd_back_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_pd_idx; - } + cmd->io_attr.span_pd_idx = (unsigned char)span_pd_back_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_idx; + cmd->io_attr.target_pd_state = pd1_state; + } cmd->r1x_read_pd = target_pd; - rb_info->last_accessed_block[target_pd] = vlba + cmd->io_attr.num_blocks; + rb_info->last_accessed_block[target_pd] = + vlba + cmd->io_attr.num_blocks; ps3_atomic_inc(&rb_info->scsi_outstanding_cmds[target_pd]); } } -static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, U32 span_idx, - U32 span_pd_idx, U32 span_pd_back_idx) +static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, + unsigned int span_idx, + unsigned int span_pd_idx, + unsigned int span_pd_back_idx) { struct ps3_r1x_read_balance_info *rb_info = NULL; struct ps3_scsi_priv_data *priv_data = NULL; - U64 vlba = 0; - U32 outstanding0 = 0; - U32 outstanding1 = 0; - U64 diff0 = 0; - U64 diff1 = 0; - U32 pd0 = 0; - U32 pd1 = 0; - U32 target_pd = 0; + unsigned long long vlba = 0; + unsigned int outstanding0 = 0; + unsigned int outstanding1 = 0; + unsigned long long diff0 = 0; + unsigned long long diff1 = 0; + unsigned int pd0 = 0; + unsigned int pd1 = 0; + unsigned char pd0_state = 0; + unsigned char pd1_state = 0; + unsigned int target_pd = 0; if (!cmd->r1x_read_pd) { priv_data = scsi_device_private_data(cmd->scmd); rb_info = priv_data->r1x_rb_info; - vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, + cmd->io_attr.lba_lo); pd0 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_idx); pd1 = PS3_R1X_RB_INFO_INDEX(span_idx, span_pd_back_idx); - outstanding0 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); - outstanding1 = ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); - - if (outstanding0 == 0 && outstanding1 != 0) { - target_pd = pd0; - } else if (outstanding0 != 0 && outstanding1 == 0) { + pd0_state = ps3_vd_member_state_get(cmd->io_attr.vd_entry, span_idx, span_pd_idx); + pd1_state = ps3_vd_member_state_get(cmd->io_attr.vd_entry, span_idx, span_pd_back_idx); + + if (pd0_state == MIC_PD_STATE_ONLINE && pd1_state == MIC_PD_STATE_ONLINE) { + outstanding0 = + ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd0]); + outstanding1 = + ps3_atomic_read(&rb_info->scsi_outstanding_cmds[pd1]); + + if (outstanding0 == 0 && outstanding1 != 0) { + target_pd = pd0; + } else if (outstanding0 != 0 && outstanding1 == 0) { + target_pd = pd1; + } else { + diff0 = ABS_DIFF(vlba, + rb_info->last_accessed_block[pd0]); + diff1 = ABS_DIFF(vlba, + rb_info->last_accessed_block[pd1]); + target_pd = (diff0 <= diff1 ? pd0 : pd1); + } + } else if (pd1_state == MIC_PD_STATE_ONLINE) { target_pd = pd1; } else { - diff0 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd0]); - diff1 = ABS_DIFF(vlba, rb_info->last_accessed_block[pd1]); - target_pd = (diff0 <= diff1 ? pd0 : pd1); + target_pd = pd0; } if (target_pd == pd0) { - cmd->io_attr.span_pd_idx = (U8)span_pd_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_pd_back_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_pd_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_back_idx; + cmd->io_attr.target_pd_state = pd0_state; } else { - cmd->io_attr.span_pd_idx = (U8)span_pd_back_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_pd_idx; - } + cmd->io_attr.span_pd_idx =(unsigned char)span_pd_back_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_pd_idx; + cmd->io_attr.target_pd_state = pd1_state; + } cmd->r1x_read_pd = target_pd; - rb_info->last_accessed_block[target_pd] = vlba + cmd->io_attr.num_blocks; + rb_info->last_accessed_block[target_pd] = + vlba + cmd->io_attr.num_blocks; ps3_atomic_inc(&rb_info->scsi_outstanding_cmds[target_pd]); } } @@ -211,36 +261,39 @@ static void ps3_r1x_seq_read_target_pd_calc(struct ps3_cmd *cmd, U32 span_idx, static void ps3_r1_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); cmd->io_attr.plba = vd_entry->startLBA + vlba; cmd->io_attr.span_idx = 0; cmd->io_attr.plba_back = cmd->io_attr.plba; if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { - ps3_r1x_rand_read_target_pd_calc(cmd, 0, 0, 1); - } else { + if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) + ps3_r1x_rand_read_target_pd_calc(cmd, 0, 0, 1); + else ps3_r1x_seq_read_target_pd_calc(cmd, 0, 0, 1); - } } else { cmd->io_attr.span_pd_idx = 0; cmd->io_attr.span_pd_idx_p = 1; } - LOG_DEBUG("hno:%u chl:%u id:%u rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", - PS3_HOST(cmd->instance), cmd->scmd->device->channel, cmd->scmd->device->id, - cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); + LOG_DEBUG( + "hno:%u chl:%u id:%u rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", + PS3_HOST(cmd->instance), cmd->scmd->device->channel, + cmd->scmd->device->id, cmd->io_attr.rw_flag, + cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); } static void ps3_r5_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_parity_disk_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_parity_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -248,209 +301,227 @@ static void ps3_r5_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) if (ps3_is_power_of_2(vd_entry->physDrvCnt)) { span_parity_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); } else { - span_parity_disk_idx = stripe_idx % vd_entry->physDrvCnt; + span_parity_disk_idx = + PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); } span_parity_disk_idx = vd_entry->physDrvCnt - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if ( span_data_disk_idx >= vd_entry->physDrvCnt) { + if (span_data_disk_idx >= vd_entry->physDrvCnt) span_data_disk_idx -= vd_entry->physDrvCnt; - } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_parity_disk_idx; - LOG_DEBUG("vlba:0x%llx plba:0x%llx startLBA:0x%llx stripe_idx:%llu" - "strip_size_shift:%u stripe_offset:%u span_pd_indx:%u\n", - vlba, cmd->io_attr.plba, vd_entry->startLBA, stripe_idx, - strip_size_shift, stripe_offset, cmd->io_attr.span_pd_idx); + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_parity_disk_idx; + LOG_DEBUG("vlba:0x%llx plba:0x%llx startLBA:0x%llx stripe_idx:%llu\n" + "\tstrip_size_shift:%u stripe_offset:%u span_pd_indx:%u\n", + vlba, cmd->io_attr.plba, vd_entry->startLBA, stripe_idx, + strip_size_shift, stripe_offset, cmd->io_attr.span_pd_idx); } static void ps3_r6_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_q_disk_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_q_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - RAID660_GET_PQ_SPINDLENO(stripe_idx, vd_entry->physDrvCnt, span_q_disk_idx); + RAID660_GET_PQ_SPINDLENO(stripe_idx, vd_entry->physDrvCnt, + span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if ( span_data_disk_idx >= vd_entry->physDrvCnt) { + if (span_data_disk_idx >= vd_entry->physDrvCnt) span_data_disk_idx -= vd_entry->physDrvCnt; - } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.span_idx = 0; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_q = (U8)span_q_disk_idx; - if(0 != span_q_disk_idx){ + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_q = (unsigned char)span_q_disk_idx; + if (span_q_disk_idx != 0) cmd->io_attr.span_pd_idx_p = span_q_disk_idx - 1; - } else{ + else cmd->io_attr.span_pd_idx_p = vd_entry->physDrvCnt - 1; - } + } static void ps3_r10_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_data_disk_back_idx = 0; - U32 span_idx = 0; - U8 span_pd_num = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_data_disk_back_idx = 0; + unsigned int span_idx = 0; + unsigned char span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - while(stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { + while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx << 1; span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if ( span_data_disk_idx > span_pd_num ) { + if (span_data_disk_idx > span_pd_num) { span_data_disk_idx -= span_pd_num; span_data_disk_back_idx = - ((span_data_disk_idx+1) == span_pd_num)? - 0 :(span_data_disk_idx+1); + ((span_data_disk_idx + 1) == span_pd_num) ? + 0 : + (span_data_disk_idx + 1); stripe_idx = (stripe_idx << 1) + 1; } else { - if (span_pd_num & 1) { + if (span_pd_num & 1) { stripe_idx = stripe_idx << 1; span_data_disk_back_idx = - ((span_data_disk_idx+1) == span_pd_num)? - 0 :(span_data_disk_idx+1); + ((span_data_disk_idx + 1) == span_pd_num) ? + 0 : + (span_data_disk_idx + 1); } else { span_data_disk_back_idx = span_data_disk_idx + 1; } } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.plba_back = cmd->io_attr.plba; - if (span_data_disk_back_idx == 0) { + if (span_data_disk_back_idx == 0) cmd->io_attr.plba_back += vd_entry->stripSize; - } - cmd->io_attr.span_idx = (U8)span_idx; + cmd->io_attr.span_idx = (unsigned char)span_idx; if (!(span_pd_num & 1) && ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { - ps3_r1x_rand_read_target_pd_calc(cmd, span_idx, - span_data_disk_idx, span_data_disk_back_idx); + if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { + ps3_r1x_rand_read_target_pd_calc( + cmd, span_idx, span_data_disk_idx, + span_data_disk_back_idx); } else { - ps3_r1x_seq_read_target_pd_calc(cmd, span_idx, - span_data_disk_idx, span_data_disk_back_idx); + ps3_r1x_seq_read_target_pd_calc( + cmd, span_idx, span_data_disk_idx, + span_data_disk_back_idx); } } else { - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_data_disk_back_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = + (unsigned char)span_data_disk_back_idx; } - LOG_DEBUG("hno:%u tid:0x%llx chl:%u id:%u " - "odd physDrvCnt:%d rw=%u span_pd_idx=%u-plba:0x%llx span_pd_idx_p=%u-bplba:0x%llx stripe_offset=0x%x\n", + LOG_DEBUG( + "hno:%u tid:0x%llx chl:%u id:%u\n" + "\todd physDrvCnt:%d rw=%u span_pd_idx=%u-plba:0x%llx\n" + "\tspan_pd_idx_p=%u-bplba:0x%llx stripe_offset=0x%x\n", PS3_HOST(cmd->instance), cmd->trace_id, cmd->scmd->device->channel, cmd->scmd->device->id, - vd_entry->physDrvCnt & 1, - cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, - cmd->io_attr.plba, cmd->io_attr.span_pd_idx_p, - cmd->io_attr.plba_back, stripe_offset); + vd_entry->physDrvCnt & 1, cmd->io_attr.rw_flag, + cmd->io_attr.span_pd_idx, cmd->io_attr.plba, + cmd->io_attr.span_pd_idx_p, cmd->io_attr.plba_back, + stripe_offset); } static void ps3_r1e_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_data_disk_back_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_data_disk_back_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx << 1; - if ( span_data_disk_idx > vd_entry->physDrvCnt ) { + if (span_data_disk_idx > vd_entry->physDrvCnt) { span_data_disk_idx -= vd_entry->physDrvCnt; span_data_disk_back_idx = - ((span_data_disk_idx+1) == vd_entry->physDrvCnt)? - 0 :(span_data_disk_idx+1) ; + ((span_data_disk_idx + 1) == vd_entry->physDrvCnt) ? + 0 : + (span_data_disk_idx + 1); stripe_idx = (stripe_idx << 1) + 1; } else { if (vd_entry->physDrvCnt & 1) { stripe_idx = stripe_idx << 1; span_data_disk_back_idx = - ((span_data_disk_idx+1) == vd_entry->physDrvCnt)? - 0 :(span_data_disk_idx+1) ; + ((span_data_disk_idx + 1) == + vd_entry->physDrvCnt) ? + 0 : + (span_data_disk_idx + 1); } else { span_data_disk_back_idx = span_data_disk_idx + 1; } } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); cmd->io_attr.plba_back = cmd->io_attr.plba; - if (span_data_disk_back_idx == 0) { + if (span_data_disk_back_idx == 0) cmd->io_attr.plba_back += vd_entry->stripSize; - } cmd->io_attr.span_idx = 0; - if (!(vd_entry->physDrvCnt & 1) && ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { - if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { - ps3_r1x_rand_read_target_pd_calc(cmd, 0, span_data_disk_idx, span_data_disk_back_idx); + if (!(vd_entry->physDrvCnt & 1) && + ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { + if (cmd->io_attr.seq_flag == SCSI_RW_RANDOM_CMD) { + ps3_r1x_rand_read_target_pd_calc( + cmd, 0, span_data_disk_idx, + span_data_disk_back_idx); } else { - ps3_r1x_seq_read_target_pd_calc(cmd, 0, span_data_disk_idx, span_data_disk_back_idx); + ps3_r1x_seq_read_target_pd_calc( + cmd, 0, span_data_disk_idx, + span_data_disk_back_idx); } } else { - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_data_disk_back_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = + (unsigned char)span_data_disk_back_idx; } - LOG_DEBUG("hno:%u chl:%u id:%u " - "odd physDrvCnt:%d rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", - PS3_HOST(cmd->instance), cmd->scmd->device->channel, cmd->scmd->device->id, - vd_entry->physDrvCnt & 1, cmd->io_attr.rw_flag, - cmd->io_attr.span_pd_idx, cmd->io_attr.span_pd_idx_p); + LOG_DEBUG("hno:%u chl:%u id:%u odd physDrvCnt:%d rw=%u, span_pd_idx=%u, span_pd_idx_p=%u\n", + PS3_HOST(cmd->instance), cmd->scmd->device->channel, + cmd->scmd->device->id, vd_entry->physDrvCnt & 1, + cmd->io_attr.rw_flag, cmd->io_attr.span_pd_idx, + cmd->io_attr.span_pd_idx_p); } static void ps3_r00_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -460,27 +531,28 @@ static void ps3_r00_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) span_idx++; } - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (U8)span_idx; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; + cmd->io_attr.span_idx = (unsigned char)span_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; } static void ps3_r50_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_parity_disk_idx = 0; - U32 span_idx = 0; - U8 span_pd_num = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_parity_disk_idx = 0; + unsigned int span_idx = 0; + unsigned char span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -491,39 +563,39 @@ static void ps3_r50_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) } span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if (ps3_is_power_of_2(span_pd_num)) { + if (ps3_is_power_of_2(span_pd_num)) span_parity_disk_idx = stripe_idx & (span_pd_num - 1); - } else { - span_parity_disk_idx = stripe_idx % span_pd_num; - } + else + span_parity_disk_idx = PS3_MOD64(stripe_idx, span_pd_num); + span_parity_disk_idx = span_pd_num - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if ( span_data_disk_idx >= span_pd_num) { + if (span_data_disk_idx >= span_pd_num) span_data_disk_idx -= span_pd_num; - } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (U8)span_idx; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_p = (U8)span_parity_disk_idx; + cmd->io_attr.span_idx = (unsigned char)span_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_p = (unsigned char)span_parity_disk_idx; } static void ps3_r60_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_q_disk_idx = 0; - U32 span_idx = 0; - U8 span_pd_num = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_q_disk_idx = 0; + unsigned int span_idx = 0; + unsigned char span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -536,50 +608,54 @@ static void ps3_r60_convert_vlba_to_pd_attr(struct ps3_cmd *cmd) span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); RAID660_GET_PQ_SPINDLENO(stripe_idx, span_pd_num, span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if ( span_data_disk_idx >= span_pd_num) { + if (span_data_disk_idx >= span_pd_num) span_data_disk_idx -= span_pd_num; - } - cmd->io_attr.plba = vd_entry->startLBA + - (stripe_idx << strip_size_shift) + + cmd->io_attr.plba = + vd_entry->startLBA + (stripe_idx << strip_size_shift) + (stripe_offset & STRIP_SIZE_MASK(vd_entry->stripSize)); - cmd->io_attr.span_idx = (U8)span_idx; - cmd->io_attr.span_pd_idx = (U8)span_data_disk_idx; - cmd->io_attr.span_pd_idx_q = (U8)span_q_disk_idx; - if(0 != span_q_disk_idx){ + cmd->io_attr.span_idx = (unsigned char)span_idx; + cmd->io_attr.span_pd_idx = (unsigned char)span_data_disk_idx; + cmd->io_attr.span_pd_idx_q = (unsigned char)span_q_disk_idx; + if (span_q_disk_idx != 0) cmd->io_attr.span_pd_idx_p = span_q_disk_idx - 1; - } else{ + else cmd->io_attr.span_pd_idx_p = span_pd_num - 1; - } } -static S32 ps3_convert_to_pd_info(struct ps3_cmd *cmd) +static int ps3_convert_to_pd_info(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + unsigned char state; + int ret = PS3_SUCCESS; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - const struct PS3Extent *extent = &(vd_entry->span[cmd->io_attr.span_idx]. - extent[cmd->io_attr.span_pd_idx]); + const struct PS3Extent *extent = + &(vd_entry->span[cmd->io_attr.span_idx] + .extent[cmd->io_attr.span_pd_idx]); - if (extent->state != MIC_PD_STATE_ONLINE) { + if (cmd->io_attr.target_pd_state != 0xff) + state = cmd->io_attr.target_pd_state; + else + state = extent->state; + + if (state != MIC_PD_STATE_ONLINE) { LOG_DEBUG("cmd :%u direct check pd:%u state:%s != ONLINE\n", - cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, - getPdStateName((MicPdState_e)extent->state, cmd->instance->is_raid)); + cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, + getPdStateName((enum MicPdState)extent->state, + cmd->instance->is_raid)); ret = -PS3_ENODEV; goto l_out; } - cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id(cmd->instance, - extent->phyDiskID.ps3Dev.phyDiskID); + cmd->io_attr.pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( + cmd->instance, extent->phyDiskID.ps3Dev.phyDiskID); if (unlikely(cmd->io_attr.pd_entry == NULL)) { - LOG_FILE_ERROR("host_no:%u trace_id:0x%llx idspan_id:%d " - "span_pd_idx:%d pd[%u:%u:%u], pd_entry == NULL\n", - PS3_HOST(cmd->instance), - cmd->trace_id, - cmd->io_attr.span_idx, - cmd->io_attr.span_pd_idx, + LOG_FILE_ERROR( + "host_no:%u trace_id:0x%llx idspan_id:%d span_pd_idx:%d pd[%u:%u:%u], pd_entry == NULL\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->io_attr.span_idx, cmd->io_attr.span_pd_idx, extent->phyDiskID.ps3Dev.softChan, extent->phyDiskID.ps3Dev.devID, extent->phyDiskID.ps3Dev.phyDiskID); @@ -587,17 +663,17 @@ static S32 ps3_convert_to_pd_info(struct ps3_cmd *cmd) goto l_out; } - if (!ps3_is_r1x_write_cmd(cmd)) { + if (!ps3_is_r1x_write_cmd(cmd)) goto l_out; - } - extent = &(vd_entry->span[cmd->io_attr.span_idx]. - extent[cmd->io_attr.span_pd_idx_p]); + extent = &(vd_entry->span[cmd->io_attr.span_idx] + .extent[cmd->io_attr.span_pd_idx_p]); if (extent->state != MIC_PD_STATE_ONLINE) { LOG_DEBUG("cmd :%u direct check pd:%u state:%s != ONLINE\n", - cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, - getPdStateName((MicPdState_e)extent->state, cmd->instance->is_raid)); + cmd->index, extent->phyDiskID.ps3Dev.phyDiskID, + getPdStateName((enum MicPdState)extent->state, + cmd->instance->is_raid)); ret = -PS3_ENODEV; goto l_out; } @@ -605,12 +681,10 @@ static S32 ps3_convert_to_pd_info(struct ps3_cmd *cmd) cmd->io_attr.peer_pd_entry = ps3_dev_mgr_lookup_pd_info_by_id( cmd->instance, extent->phyDiskID.ps3Dev.phyDiskID); if (unlikely(cmd->io_attr.peer_pd_entry == NULL)) { - LOG_ERROR_LIM("host_no:%u trace_id:0x%llx idspan_id:%d " - "span_pd_idx:%d peer_pd[%u:%u:%u], pd_entry == NULL\n", - PS3_HOST(cmd->instance), - cmd->trace_id, - cmd->io_attr.span_idx, - cmd->io_attr.span_pd_idx, + LOG_ERROR_LIM( + "host_no:%u trace_id:0x%llx idspan_id:%d span_pd_idx:%d peer_pd[%u:%u:%u], pd_entry == NULL\n", + PS3_HOST(cmd->instance), cmd->trace_id, + cmd->io_attr.span_idx, cmd->io_attr.span_pd_idx, extent->phyDiskID.ps3Dev.softChan, extent->phyDiskID.ps3Dev.devID, extent->phyDiskID.ps3Dev.phyDiskID); @@ -622,18 +696,19 @@ static S32 ps3_convert_to_pd_info(struct ps3_cmd *cmd) return ret; } -S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) +int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; - if ( unlikely(!ps3_vd_entry_valid_check(cmd->io_attr.vd_entry)) ) { + if (unlikely(!ps3_vd_entry_valid_check(cmd->io_attr.vd_entry))) { ret = -PS3_FAILED; - LOG_ERROR_LIM("trace_id:0x%llx host_no:%u vd entry is invalid\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + LOG_ERROR_LIM( + "trace_id:0x%llx host_no:%u vd entry is invalid\n", + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } - switch(cmd->io_attr.vd_entry->raidLevel) { + switch (cmd->io_attr.vd_entry->raidLevel) { case RAID0: ps3_r0_convert_vlba_to_pd_attr(cmd); break; @@ -663,8 +738,9 @@ S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) break; default: ret = -PS3_FAILED; - LOG_ERROR_LIM("trace_id:0x%llx host_no:%u vd level:%d is illegal\n", - cmd->trace_id, PS3_HOST(cmd->instance), + LOG_ERROR_LIM( + "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", + cmd->trace_id, PS3_HOST(cmd->instance), cmd->io_attr.vd_entry->raidLevel); goto l_out; } @@ -673,15 +749,17 @@ S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd) return ret; } -Bool ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) +unsigned char ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; - PS3VDAccAttr_s *acc_attr = &cmd->req_frame->frontendReq.vdAccAttr; + int ret = PS3_SUCCESS; + struct PS3VDAccAttr *acc_attr = &cmd->req_frame->frontendReq.vdAccAttr; static unsigned long j; + ret = ps3_scsih_vlba_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { - LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "trace_id:0x%llx host_no:%u vlba calc NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + LOG_WARN_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "trace_id:0x%llx host_no:%u vlba calc NOK\n", + cmd->trace_id, PS3_HOST(cmd->instance)); acc_attr->isAccActive = 0; goto l_out; } @@ -696,14 +774,14 @@ Bool ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd) return (acc_attr->isAccActive == 1); } -S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) +int ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; ret = ps3_scsih_vlba_to_pd_calc(cmd); if (ret != PS3_SUCCESS) { LOG_WARN_LIM("trace_id:0x%llx host_no:%u vlba calc NOK\n", - cmd->trace_id, PS3_HOST(cmd->instance)); + cmd->trace_id, PS3_HOST(cmd->instance)); goto l_out; } @@ -713,26 +791,30 @@ S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd) return ret; } -static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, U16 disk_id) +static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, + unsigned short disk_id) { - U16 i = 0; + unsigned short i = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_instance *instance = cmd->instance; + if (unlikely(cmd->target_pd_count >= PS3_QOS_MAX_PD_IN_VD)) { - LOG_INFO("host_no:%u CFID:%u did:%u target pd count %u check NOK\n", - PS3_HOST(instance), cmd->index, disk_id, cmd->target_pd_count); + LOG_INFO( + "host_no:%u CFID:%u did:%u target pd count %u check NOK\n", + PS3_HOST(instance), cmd->index, disk_id, + cmd->target_pd_count); goto l_out; } - if (disk_id > instance->ctrl_info.maxPdCount ) { + if (disk_id > instance->ctrl_info.maxPdCount) { LOG_DEBUG("disk_id is error.host_no:%u CFID:%u did:%u\n", - PS3_HOST(instance), cmd->index, disk_id); + PS3_HOST(instance), cmd->index, disk_id); goto l_out; } qos_pd_mgr = &instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; if (ps3_atomic_read(&qos_pd_mgr->valid) != 1) { LOG_DEBUG("qos pd is invalid. host_no:%u CFID:%u did:%u\n", - PS3_HOST(instance), cmd->index, disk_id); + PS3_HOST(instance), cmd->index, disk_id); goto l_out; } @@ -750,36 +832,42 @@ static void ps3_update_cmd_target_pd(struct ps3_cmd *cmd, U16 disk_id) return; } -static void ps3_r0_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) +static void ps3_r0_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) { - U32 stripe_offset = 0; - U32 strip_size_shift = 0; - U8 span_idx = 0; - U32 span_disk_idx = 0; - U16 disk_id= 0; + unsigned int stripe_offset = 0; + unsigned int strip_size_shift = 0; + unsigned char span_idx = 0; + unsigned int span_disk_idx = 0; + unsigned short disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); span_disk_idx = stripe_offset >> strip_size_shift; - if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r0_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; - Bool first_strip = PS3_TRUE; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; + unsigned char first_strip = PS3_TRUE; while (left_len > 0) { ps3_r0_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = + vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -792,12 +880,12 @@ static void ps3_r0_target_pd_get(struct ps3_cmd *cmd) static void ps3_r1_target_pd_get(struct ps3_cmd *cmd) { - U8 span_idx = 0; - U16 span_disk_idx = 0; - U16 disk_id= 0; + unsigned char span_idx = 0; + unsigned short span_disk_idx = 0; + unsigned short disk_id = 0; const struct PS3Extent *extent = NULL; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - Bool primary_valid = PS3_FALSE; + unsigned char primary_valid = PS3_FALSE; ps3_scsih_vlba_to_pd_calc(cmd); span_disk_idx = cmd->io_attr.span_pd_idx; @@ -818,40 +906,46 @@ static void ps3_r1_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r00_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) +static void ps3_r00_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) { - U32 stripe_offset = 0; - U32 strip_size_shift = 0; - U8 span_idx = 0; - U32 span_disk_idx = 0; - U16 disk_id= 0; + unsigned int stripe_offset = 0; + unsigned int strip_size_shift = 0; + unsigned char span_idx = 0; + unsigned int span_disk_idx = 0; + unsigned short disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } span_disk_idx = stripe_offset >> strip_size_shift; - if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r00_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; - Bool first_strip = PS3_TRUE; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; + unsigned char first_strip = PS3_TRUE; while (left_len > 0) { ps3_r00_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = + vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -862,15 +956,15 @@ static void ps3_r00_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) +static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_parity_disk_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_parity_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U16 disk_id = 0; + unsigned short disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -878,35 +972,41 @@ static void ps3_r5_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) if (ps3_is_power_of_2(vd_entry->physDrvCnt)) { span_parity_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); } else { - span_parity_disk_idx = stripe_idx % vd_entry->physDrvCnt; + span_parity_disk_idx = + PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); } span_parity_disk_idx = vd_entry->physDrvCnt - span_parity_disk_idx - 1; strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if (span_data_disk_idx >= vd_entry->physDrvCnt) { + if (span_data_disk_idx >= vd_entry->physDrvCnt) span_data_disk_idx -= vd_entry->physDrvCnt; - } - if (vd_entry->span[0].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[0].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[0].extent[span_data_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[0] + .extent[span_data_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r5_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; - Bool first_strip = PS3_TRUE; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; + unsigned char first_strip = PS3_TRUE; while (left_len > 0) { ps3_r5_vlba_to_pd(cmd, vlba); if (first_strip) { - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = + vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); first_strip = PS3_FALSE; } else { @@ -917,51 +1017,54 @@ static void ps3_r5_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r6_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) +static void ps3_r6_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_q_disk_idx = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_q_disk_idx = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U16 disk_id = 0; + unsigned short disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); - if (ps3_is_power_of_2(vd_entry->physDrvCnt)){ + if (ps3_is_power_of_2(vd_entry->physDrvCnt)) span_q_disk_idx = stripe_idx & (vd_entry->physDrvCnt - 1); - } else { - span_q_disk_idx = stripe_idx % vd_entry->physDrvCnt; - } + else + span_q_disk_idx = PS3_MOD64(stripe_idx, vd_entry->physDrvCnt); span_q_disk_idx = (vd_entry->physDrvCnt) - span_q_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if ( span_data_disk_idx >= vd_entry->physDrvCnt) { + if (span_data_disk_idx >= vd_entry->physDrvCnt) span_data_disk_idx -= vd_entry->physDrvCnt; - } - if (vd_entry->span[0].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[0].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[0].extent[span_data_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[0] + .extent[span_data_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r6_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; ps3_r6_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -971,16 +1074,16 @@ static void ps3_r6_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) +static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_parity_disk_idx = 0; - U32 span_idx = 0; - U8 span_pd_num = 0; - U16 disk_id = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_parity_disk_idx = 0; + unsigned int span_idx = 0; + unsigned char span_pd_num = 0; + unsigned short disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); @@ -992,38 +1095,41 @@ static void ps3_r50_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) } span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); - if (ps3_is_power_of_2(span_pd_num)) { + if (ps3_is_power_of_2(span_pd_num)) span_parity_disk_idx = stripe_idx & (span_pd_num - 1); - } else { - span_parity_disk_idx = stripe_idx % span_pd_num; - } + else + span_parity_disk_idx = PS3_MOD64(stripe_idx, span_pd_num); span_parity_disk_idx = span_pd_num - span_parity_disk_idx - 1; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_parity_disk_idx + span_data_disk_idx + 1; - if ( span_data_disk_idx >= span_pd_num) { + if (span_data_disk_idx >= span_pd_num) span_data_disk_idx -= span_pd_num; - } - if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_data_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r50_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; ps3_r50_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1033,17 +1139,17 @@ static void ps3_r50_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) +static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long vlba) { - U32 stripe_offset = 0; - U64 stripe_idx = 0; - U32 strip_size_shift = 0; - U32 span_data_disk_idx = 0; - U32 span_q_disk_idx = 0; - U32 span_idx = 0; - U8 span_pd_num = 0; + unsigned int stripe_offset = 0; + unsigned long long stripe_idx = 0; + unsigned int strip_size_shift = 0; + unsigned int span_data_disk_idx = 0; + unsigned int span_q_disk_idx = 0; + unsigned int span_idx = 0; + unsigned char span_pd_num = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U16 disk_id = 0; + unsigned short disk_id = 0; LBA_TO_STRIPE_INDEX(vlba, vd_entry->stripeDataSize, stripe_idx); LBA_TO_STRIPE_OFFSET(vlba, vd_entry->stripeDataSize, stripe_offset); @@ -1056,31 +1162,35 @@ static void ps3_r60_vlba_to_pd(struct ps3_cmd *cmd, U64 vlba) span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); RAID660_GET_PQ_SPINDLENO(stripe_idx, span_pd_num, span_q_disk_idx); - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); span_data_disk_idx = stripe_offset >> strip_size_shift; span_data_disk_idx = span_data_disk_idx + span_q_disk_idx + 1; - if ( span_data_disk_idx >= span_pd_num) { + if (span_data_disk_idx >= span_pd_num) span_data_disk_idx -= span_pd_num; - } - if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_data_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_data_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_data_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } static void ps3_r60_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; ps3_r60_vlba_to_pd(cmd, vlba); - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1090,21 +1200,21 @@ static void ps3_r60_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) +static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) { - U32 stripe_offset = 0; - U32 strip_size_shift = 0; - U8 span_idx = 0; - U32 span_disk_idx = 0; - U32 span_disk_back_idx = 0; - U16 span_pd_num = 0; - U16 disk_id= 0; + unsigned int stripe_offset = 0; + unsigned int strip_size_shift = 0; + unsigned char span_idx = 0; + unsigned int span_disk_idx = 0; + unsigned int span_disk_back_idx = 0; + unsigned short span_pd_num = 0; + unsigned short disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - Bool primary_valid = PS3_FALSE; + unsigned char primary_valid = PS3_FALSE; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); - while(stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { + while (stripe_offset >= vd_entry->span[span_idx].spanStripeDataSize) { stripe_offset -= vd_entry->span[span_idx].spanStripeDataSize; span_idx++; } @@ -1112,15 +1222,13 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) span_disk_idx = span_disk_idx << 1; span_pd_num = VD_SPAN_PD_NUM(vd_entry, span_idx); if (span_pd_num & 1) { - if (span_disk_idx > span_pd_num ) { + if (span_disk_idx > span_pd_num) span_disk_idx -= span_pd_num; - } - if (span_disk_idx + 1 == span_pd_num) { + if (span_disk_idx + 1 == span_pd_num) span_disk_back_idx = 0; - } else { + else span_disk_back_idx = span_disk_idx + 1; - } } else { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.span_pd_idx & 1) { @@ -1133,15 +1241,21 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) } } - if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); primary_valid = PS3_TRUE; } if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) || !primary_valid) { - if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_back_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_back_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } @@ -1149,15 +1263,16 @@ static void ps3_r10_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; const struct PS3Extent *extent = NULL; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; - U16 flat_pd_id = 0; - Bool primary_valid = PS3_FALSE; - U8 span_idx = 0; - U8 span_disk_idx = 0; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; + unsigned short flat_pd_id = 0; + unsigned char primary_valid = PS3_FALSE; + unsigned char span_idx = 0; + unsigned char span_disk_idx = 0; ps3_scsih_vlba_to_pd_calc(cmd); span_idx = cmd->io_attr.span_idx; @@ -1172,14 +1287,15 @@ static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) span_disk_idx = cmd->io_attr.span_pd_idx_p; extent = &vd_entry->span[span_idx].extent[span_disk_idx]; if (extent->state == MIC_PD_STATE_ONLINE) { - flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; + flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, flat_pd_id); } } - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1189,30 +1305,28 @@ static void ps3_r10_target_pd_get(struct ps3_cmd *cmd) } } -static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) +static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, unsigned long long lba) { - U32 stripe_offset = 0; - U32 strip_size_shift = 0; - U8 span_idx = 0; - U32 span_disk_idx = 0; - U32 span_disk_back_idx = 0; - U16 disk_id= 0; + unsigned int stripe_offset = 0; + unsigned int strip_size_shift = 0; + unsigned char span_idx = 0; + unsigned int span_disk_idx = 0; + unsigned int span_disk_back_idx = 0; + unsigned short disk_id = 0; const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; - Bool primary_valid = PS3_FALSE; + unsigned char primary_valid = PS3_FALSE; - strip_size_shift = ps3_blocksize_to_shift (vd_entry->stripSize); + strip_size_shift = ps3_blocksize_to_shift(vd_entry->stripSize); LBA_TO_STRIPE_OFFSET(lba, vd_entry->stripeDataSize, stripe_offset); span_disk_idx = stripe_offset >> strip_size_shift; span_disk_idx = span_disk_idx << 1; if (vd_entry->physDrvCnt & 1) { - if (span_disk_idx > vd_entry->physDrvCnt) { + if (span_disk_idx > vd_entry->physDrvCnt) span_disk_idx -= vd_entry->physDrvCnt; - } - if (span_disk_idx + 1 == vd_entry->physDrvCnt) { + if (span_disk_idx + 1 == vd_entry->physDrvCnt) span_disk_back_idx = 0; - } else { + else span_disk_back_idx = span_disk_idx + 1; - } } else { if (ps3_scsih_is_read_cmd(cmd->io_attr.rw_flag)) { if (cmd->io_attr.span_pd_idx & 1) { @@ -1225,14 +1339,20 @@ static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) } } - if (vd_entry->span[span_idx].extent[span_disk_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); primary_valid = PS3_TRUE; } if (ps3_scsih_is_write_cmd(cmd->io_attr.rw_flag) || !primary_valid) { - if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == MIC_PD_STATE_ONLINE) { - disk_id = vd_entry->span[span_idx].extent[span_disk_back_idx].phyDiskID.ps3Dev.phyDiskID; + if (vd_entry->span[span_idx].extent[span_disk_back_idx].state == + MIC_PD_STATE_ONLINE) { + disk_id = vd_entry->span[span_idx] + .extent[span_disk_back_idx] + .phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, disk_id); } } @@ -1240,15 +1360,16 @@ static void ps3_r1e_vlba_to_pd(struct ps3_cmd *cmd, U64 lba) static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) { - U64 vlba = U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); + unsigned long long vlba = + U32_HIGH_LOW_TO_U64(cmd->io_attr.lba_hi, cmd->io_attr.lba_lo); const struct PS3VDEntry *vd_entry = cmd->io_attr.vd_entry; const struct PS3Extent *extent = NULL; - U32 left_len = cmd->io_attr.num_blocks; - U32 strip_len = 0; - U16 flat_pd_id = 0; - Bool primary_valid = PS3_FALSE; - U8 span_idx = 0; - U8 span_disk_idx = 0; + unsigned int left_len = cmd->io_attr.num_blocks; + unsigned int strip_len = 0; + unsigned short flat_pd_id = 0; + unsigned char primary_valid = PS3_FALSE; + unsigned char span_idx = 0; + unsigned char span_disk_idx = 0; ps3_scsih_vlba_to_pd_calc(cmd); span_idx = cmd->io_attr.span_idx; @@ -1263,14 +1384,15 @@ static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) span_disk_idx = cmd->io_attr.span_pd_idx_p; extent = &vd_entry->span[span_idx].extent[span_disk_idx]; if (extent->state == MIC_PD_STATE_ONLINE) { - flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; + flat_pd_id = extent->phyDiskID.ps3Dev.phyDiskID; ps3_update_cmd_target_pd(cmd, flat_pd_id); } } - strip_len = vd_entry->stripSize - (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); + strip_len = vd_entry->stripSize - + (vlba & STRIP_SIZE_MASK(vd_entry->stripSize)); strip_len = PS3_MIN(strip_len, left_len); - left_len -= strip_len; + left_len -= strip_len; vlba += strip_len; while (left_len > 0) { strip_len = PS3_MIN(left_len, vd_entry->stripSize); @@ -1280,9 +1402,11 @@ static void ps3_r1e_target_pd_get(struct ps3_cmd *cmd) } } -static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, U16 i, U16 j) +static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, + unsigned short i, unsigned short j) { struct ps3_qos_member_pd_info tmp; + tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; @@ -1290,13 +1414,13 @@ static inline void ps3_swap_in_array(struct ps3_qos_member_pd_info *arr, U16 i, static void ps3_qos_target_pd_adjust(struct ps3_cmd *cmd) { - U16 i = 0; - U16 j = 0; + unsigned short i = 0; + unsigned short j = 0; for (i = 0; i < cmd->target_pd_count; i++) { for (j = i + 1; j < cmd->target_pd_count; j++) { if (cmd->target_pd[i].flat_disk_id > - cmd->target_pd[j].flat_disk_id) { + cmd->target_pd[j].flat_disk_id) { ps3_swap_in_array(cmd->target_pd, i, j); } } @@ -1306,59 +1430,67 @@ static void ps3_qos_target_pd_adjust(struct ps3_cmd *cmd) void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd) { const struct PS3VDEntry *vd_entry = NULL; - U16 disk_id = 0; + unsigned short disk_id = 0; struct ps3_qos_pd_mgr *qos_pd_mgr = NULL; struct ps3_qos_pd_mgr *qos_peer_pd_mgr = NULL; static unsigned long j; + if (cmd->io_attr.dev_type == PS3_DEV_TYPE_VD) { vd_entry = cmd->io_attr.vd_entry; if (cmd->cmd_word.direct == PS3_CMDWORD_DIRECT_ADVICE) { disk_id = PS3_PDID(&cmd->io_attr.pd_entry->disk_pos); if (ps3_is_r1x_write_cmd(cmd)) { - qos_pd_mgr = &cmd->instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; - disk_id = PS3_PDID(&cmd->io_attr.peer_pd_entry->disk_pos); - qos_peer_pd_mgr = &cmd->instance->qos_context.pd_ctx.qos_pd_mgrs[disk_id]; - disk_id = (qos_pd_mgr->pd_quota <= qos_peer_pd_mgr->pd_quota) ? - qos_pd_mgr->disk_id : qos_peer_pd_mgr->disk_id; + qos_pd_mgr = &cmd->instance->qos_context.pd_ctx + .qos_pd_mgrs[disk_id]; + disk_id = PS3_PDID( + &cmd->io_attr.peer_pd_entry->disk_pos); + qos_peer_pd_mgr = + &cmd->instance->qos_context.pd_ctx + .qos_pd_mgrs[disk_id]; + disk_id = (qos_pd_mgr->pd_quota <= + qos_peer_pd_mgr->pd_quota) ? + qos_pd_mgr->disk_id : + qos_peer_pd_mgr->disk_id; } ps3_update_cmd_target_pd(cmd, disk_id); } else { - if (!vd_entry->isNvme && !vd_entry->isSsd) { + if (!vd_entry->isNvme && !vd_entry->isSsd) goto _out; - } - switch(vd_entry->raidLevel) { - case RAID0: - ps3_r0_target_pd_get(cmd); - break; - case RAID1: - ps3_r1_target_pd_get(cmd); - break; - case RAID10: - ps3_r10_target_pd_get(cmd); - break; - case RAID1E: - ps3_r1e_target_pd_get(cmd); - break; - case RAID00: - ps3_r00_target_pd_get(cmd); - break; - case RAID5: - ps3_r5_target_pd_get(cmd); - break; - case RAID6: - ps3_r6_target_pd_get(cmd); - break; - case RAID50: - ps3_r50_target_pd_get(cmd); - break; - case RAID60: - ps3_r60_target_pd_get(cmd); - break; - default: - LOG_ERROR_TIME_LIM(&j, PS3_LOG_LIMIT_INTERVAL_MSEC, "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", - cmd->trace_id, PS3_HOST(cmd->instance), - cmd->io_attr.vd_entry->raidLevel); + switch (vd_entry->raidLevel) { + case RAID0: + ps3_r0_target_pd_get(cmd); + break; + case RAID1: + ps3_r1_target_pd_get(cmd); + break; + case RAID10: + ps3_r10_target_pd_get(cmd); + break; + case RAID1E: + ps3_r1e_target_pd_get(cmd); + break; + case RAID00: + ps3_r00_target_pd_get(cmd); + break; + case RAID5: + ps3_r5_target_pd_get(cmd); + break; + case RAID6: + ps3_r6_target_pd_get(cmd); + break; + case RAID50: + ps3_r50_target_pd_get(cmd); + break; + case RAID60: + ps3_r60_target_pd_get(cmd); + break; + default: + LOG_ERROR_TIME_LIM( + &j, PS3_LOG_LIMIT_INTERVAL_MSEC, + "trace_id:0x%llx host_no:%u vd level:%d is illegal\n", + cmd->trace_id, PS3_HOST(cmd->instance), + cmd->io_attr.vd_entry->raidLevel); } ps3_qos_target_pd_adjust(cmd); @@ -1367,39 +1499,41 @@ void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd) ps3_update_cmd_target_pd(cmd, cmd->io_attr.disk_id); } _out: - LOG_DEBUG("qos target pd calc. host_no:%u cmd[%u,%u] pd_cnt:%u dev_t:%u diskid:%u\n", - PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.type, cmd->target_pd_count, - cmd->io_attr.dev_type, cmd->io_attr.disk_id); + LOG_DEBUG( + "qos target pd calc. host_no:%u cmd[%u,%u] pd_cnt:%u dev_t:%u diskid:%u\n", + PS3_HOST(cmd->instance), cmd->index, cmd->cmd_word.type, + cmd->target_pd_count, cmd->io_attr.dev_type, + cmd->io_attr.disk_id); } -U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) +unsigned short ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry) { - U16 ret = PS3_IS_SSD_EVEN_R1X_VD; - U8 span_idx = 0; + unsigned short ret = PS3_IS_SSD_EVEN_R1X_VD; + unsigned char span_idx = 0; + if (!vd_entry->isSsd) { ret = PS3_IS_HDD_R1X_VD; goto l_out; } switch (vd_entry->raidLevel) { - case RAID10: - for (; span_idx < vd_entry->spanCount; span_idx++) { - if (VD_SPAN_PD_NUM(vd_entry, span_idx) & 1) { - ret = PS3_IS_SSD_ODD_R1X_VD; - goto l_out; - } - } - break; - case RAID1E: - if (VD_SPAN_PD_NUM(vd_entry, 0) & 1) { + case RAID10: + for (; span_idx < vd_entry->spanCount; span_idx++) { + if (VD_SPAN_PD_NUM(vd_entry, span_idx) & 1) { ret = PS3_IS_SSD_ODD_R1X_VD; goto l_out; } - break; - default: - ret = PS3_IS_VALID_R1X_VD; - break; + } + break; + case RAID1E: + if (VD_SPAN_PD_NUM(vd_entry, 0) & 1) { + ret = PS3_IS_SSD_ODD_R1X_VD; + goto l_out; + } + break; + default: + ret = PS3_IS_VALID_R1X_VD; + break; } l_out: return ret; } - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h index b231a461c21c..99fdca3d2bb8 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_scsih_raid_engine.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_SCSIH_RAID_ENGINE_H_ #define _PS3_SCSIH_RAID_ENGINE_H_ @@ -6,23 +6,25 @@ #include "ps3_err_def.h" #include "ps3_cmd_channel.h" -enum ps3_odd_r1x_vd_judge_type { +enum ps3_odd_r1x_vd_judge_type { PS3_IS_HDD_R1X_VD, PS3_IS_SSD_ODD_R1X_VD, PS3_IS_SSD_EVEN_R1X_VD, PS3_IS_VALID_R1X_VD }; -Bool ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, U32 vlba_lo, U32 lba_length); +unsigned char ps3_scsih_is_same_strip(const struct PS3VDEntry *vd_entry, + unsigned int vlba_lo, + unsigned int lba_length); -S32 ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd); +int ps3_scsih_vd_rw_io_to_pd_calc(struct ps3_cmd *cmd); -Bool ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd); +unsigned char ps3_scsih_vd_acc_att_build(struct ps3_cmd *cmd); -S32 ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd); +int ps3_scsih_vlba_to_pd_calc(struct ps3_cmd *cmd); void ps3_qos_cmd_member_pd_calc(struct ps3_cmd *cmd); -U16 ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry); +unsigned short ps3_odd_r1x_judge(struct PS3VDEntry *vd_entry); -#endif \ No newline at end of file +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c index f4710fc29cca..d6f2edbfe0d9 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.c @@ -1,23 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include #include -#include "ps3_trace_id.h" +#include "ps3_htp_trace_id.h" #include "ps3_err_def.h" #include "ps3_trace_id_alloc.h" -static DEFINE_PER_CPU(ps3_trace_id_u, ps3_trace_id); +static DEFINE_PER_CPU(union ps3_trace_id, ps3_trace_id); -static U8 g_ps3_trace_id_swith = ps3_trace_id_switch_open; +static unsigned char g_ps3_trace_id_switch = ps3_trace_id_switch_open; -void ps3_trace_id_alloc(U64 *trace_id) +void ps3_trace_id_alloc(unsigned long long *trace_id) { - ps3_trace_id_u *id = NULL; - U64 trace_id_count = 0; + union ps3_trace_id *id = NULL; + unsigned long long trace_id_count = 0; - if (g_ps3_trace_id_swith != ps3_trace_id_switch_open) { + if (g_ps3_trace_id_switch != ps3_trace_id_switch_open) { *trace_id = 0; goto l_out; } @@ -27,19 +28,20 @@ void ps3_trace_id_alloc(U64 *trace_id) trace_id_count = id->ps3_trace_id.count; ++trace_id_count; - id->ps3_trace_id.count = (trace_id_count & TRACE_ID_CHIP_OUT_COUNT_MASK); + id->ps3_trace_id.count = + (trace_id_count & TRACE_ID_CHIP_OUT_COUNT_MASK); *trace_id = id->trace_id; preempt_enable(); l_out: - return ; + return; } void ps3_trace_id_init(void) { - S32 cpu = 0; - ps3_trace_id_u *id = NULL; + int cpu = 0; + union ps3_trace_id *id = NULL; for_each_possible_cpu(cpu) { id = &per_cpu(ps3_trace_id, cpu); @@ -48,27 +50,26 @@ void ps3_trace_id_init(void) id->ps3_trace_id.count = 0; } - return; } -S32 ps3_trace_id_switch_store(U8 value) +int ps3_trace_id_switch_store(unsigned char value) { - S32 ret = PS3_SUCCESS; + int ret = PS3_SUCCESS; if (value != ps3_trace_id_switch_close && - value != ps3_trace_id_switch_open) { + value != ps3_trace_id_switch_open) { ret = PS3_FAILED; goto l_out; } - g_ps3_trace_id_swith = value; + g_ps3_trace_id_switch = value; l_out: return ret; } -U8 ps3_trace_id_switch_show(void) +unsigned char ps3_trace_id_switch_show(void) { - return g_ps3_trace_id_swith; + return g_ps3_trace_id_switch; } #endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h index 7b7722120811..7bdb3ade56ba 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_trace_id_alloc.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_TRACE_ID_ALLOC_H_ #define _PS3_TRACE_ID_ALLOC_H_ @@ -13,21 +13,21 @@ enum { ps3_trace_id_switch_close, }; -typedef union { - U64 trace_id; +union ps3_trace_id { + unsigned long long trace_id; struct { - U64 count : 52; - U64 cpu_id : 11; - U64 flag : 1; + unsigned long long count : 52; + unsigned long long cpu_id : 11; + unsigned long long flag : 1; } ps3_trace_id; -} ps3_trace_id_u; +}; -void ps3_trace_id_alloc(U64 *trace_id); +void ps3_trace_id_alloc(unsigned long long *trace_id); void ps3_trace_id_init(void); -S32 ps3_trace_id_switch_store(U8 value); +int ps3_trace_id_switch_store(unsigned char value); -U8 ps3_trace_id_switch_show(void); +unsigned char ps3_trace_id_switch_show(void); -#endif \ No newline at end of file +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_util.h b/drivers/scsi/linkdata/ps3stor/ps3_util.h index 3965fa08b981..0a5f19cc356e 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_util.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_util.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_UTIL_H_ #define _PS3_UTIL_H_ @@ -10,19 +10,20 @@ #include "htp_v200/ps3_htp_def.h" #include "ps3_driver_log.h" #include "ps3_platform_utils.h" +#include "ps3_kernel_version.h" #define PS3_DRV_MAX(x, y) ((x) > (y) ? (x) : (y)) -#define PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F1)) & (addr)) -#define PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(addr) \ +#define PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(addr) \ (((1ULL) << (PCIE_DMA_HOST_ADDR_BIT_POS_F0)) & (addr)) enum { - PS3_BLOCK_SIZE_16 = 16, - PS3_BLOCK_SIZE_32 = 32, - PS3_BLOCK_SIZE_64 = 64, + PS3_BLOCK_SIZE_16 = 16, + PS3_BLOCK_SIZE_32 = 32, + PS3_BLOCK_SIZE_64 = 64, PS3_BLOCK_SIZE_128 = 128, PS3_BLOCK_SIZE_256 = 256, PS3_BLOCK_SIZE_512 = 512, @@ -32,38 +33,38 @@ enum { PS3_BLOCK_SIZE_8192 = 8192, }; -#define PS3_BLOCK_SIZE_16K (16uLL << 10) -#define PS3_BLOCK_SIZE_32K (32uLL << 10) -#define PS3_BLOCK_SIZE_64K (64uLL << 10) -#define PS3_BLOCK_SIZE_128K (128uLL << 10) -#define PS3_BLOCK_SIZE_256K (256uLL << 10) -#define PS3_BLOCK_SIZE_512K (512uLL << 10) -#define PS3_BLOCK_SIZE_1M (1uLL << 20) -#define PS3_BLOCK_SIZE_2M (2uLL << 20) -#define PS3_BLOCK_SIZE_4M (4uLL << 20) -#define PS3_BLOCK_SIZE_8M (8uLL << 20) -#define PS3_BLOCK_SIZE_16M (16uLL << 20) -#define PS3_BLOCK_SIZE_32M (32uLL << 20) -#define PS3_BLOCK_SIZE_64M (64uLL << 20) -#define PS3_BLOCK_SIZE_128M (128uLL << 20) -#define PS3_BLOCK_SIZE_256M (256uLL << 20) -#define PS3_BLOCK_SIZE_512M (512uLL << 20) -#define PS3_BLOCK_SIZE_1G (1uLL << 30) -#define PS3_BLOCK_SIZE_2G (2uLL << 30) -#define PS3_BLOCK_SIZE_4G (4uLL << 30) -#define PS3_BLOCK_SIZE_8G (8uLL << 30) -#define PS3_BLOCK_SIZE_16G (16uLL << 30) -#define PS3_BLOCK_SIZE_32G (32uLL << 30) -#define PS3_BLOCK_SIZE_64G (64uLL << 30) -#define PS3_BLOCK_SIZE_128G (128uLL << 30) -#define PS3_BLOCK_SIZE_256G (256uLL << 30) -#define PS3_BLOCK_SIZE_512G (512uLL << 30) -#define PS3_BLOCK_SIZE_1T (1uLL << 40) -#define PS3_BLOCK_SIZE_2T (2uLL << 40) -#define PS3_BLOCK_SIZE_4T (4uLL << 40) -#define PS3_BLOCK_SIZE_8T (8uLL << 40) -#define PS3_BLOCK_SIZE_16T (16uLL << 40) -#define PS3_BLOCK_SIZE_32T (32uLL << 40) +#define PS3_BLOCK_SIZE_16K (16uLL << 10) +#define PS3_BLOCK_SIZE_32K (32uLL << 10) +#define PS3_BLOCK_SIZE_64K (64uLL << 10) +#define PS3_BLOCK_SIZE_128K (128uLL << 10) +#define PS3_BLOCK_SIZE_256K (256uLL << 10) +#define PS3_BLOCK_SIZE_512K (512uLL << 10) +#define PS3_BLOCK_SIZE_1M (1uLL << 20) +#define PS3_BLOCK_SIZE_2M (2uLL << 20) +#define PS3_BLOCK_SIZE_4M (4uLL << 20) +#define PS3_BLOCK_SIZE_8M (8uLL << 20) +#define PS3_BLOCK_SIZE_16M (16uLL << 20) +#define PS3_BLOCK_SIZE_32M (32uLL << 20) +#define PS3_BLOCK_SIZE_64M (64uLL << 20) +#define PS3_BLOCK_SIZE_128M (128uLL << 20) +#define PS3_BLOCK_SIZE_256M (256uLL << 20) +#define PS3_BLOCK_SIZE_512M (512uLL << 20) +#define PS3_BLOCK_SIZE_1G (1uLL << 30) +#define PS3_BLOCK_SIZE_2G (2uLL << 30) +#define PS3_BLOCK_SIZE_4G (4uLL << 30) +#define PS3_BLOCK_SIZE_8G (8uLL << 30) +#define PS3_BLOCK_SIZE_16G (16uLL << 30) +#define PS3_BLOCK_SIZE_32G (32uLL << 30) +#define PS3_BLOCK_SIZE_64G (64uLL << 30) +#define PS3_BLOCK_SIZE_128G (128uLL << 30) +#define PS3_BLOCK_SIZE_256G (256uLL << 30) +#define PS3_BLOCK_SIZE_512G (512uLL << 30) +#define PS3_BLOCK_SIZE_1T (1uLL << 40) +#define PS3_BLOCK_SIZE_2T (2uLL << 40) +#define PS3_BLOCK_SIZE_4T (4uLL << 40) +#define PS3_BLOCK_SIZE_8T (8uLL << 40) +#define PS3_BLOCK_SIZE_16T (16uLL << 40) +#define PS3_BLOCK_SIZE_32T (32uLL << 40) enum { PS3_BLOCK_SIZE_SHIFT_4 = 4, @@ -110,9 +111,9 @@ enum { PS3_BLOCK_SIZE_SHIFT_32T = 45, }; -static inline U32 ps3_blocksize_to_shift(U32 block_size) +static inline unsigned int ps3_blocksize_to_shift(unsigned int block_size) { - U32 shift = 0; + unsigned int shift = 0; switch (block_size) { case PS3_BLOCK_SIZE_16: @@ -153,9 +154,9 @@ static inline U32 ps3_blocksize_to_shift(U32 block_size) return shift; } -static inline U32 ps3_ringsize_to_shift(U64 ring_size) +static inline unsigned int ps3_ringsize_to_shift(unsigned long long ring_size) { - U32 shift = 0; + unsigned int shift = 0; switch (ring_size) { case PS3_BLOCK_SIZE_512: @@ -276,125 +277,137 @@ static inline U32 ps3_ringsize_to_shift(U64 ring_size) return shift; } -static U8 ps3_dma_addr_bit_pos_check(dma_addr_t handle) +static unsigned char ps3_dma_addr_bit_pos_check(dma_addr_t handle) { - U8 bit_pos = 0; - if (PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(handle)) { + unsigned char bit_pos = 0; + + if (PCIE_DMA_HOST_ADDR_BIT54_MASK_CHECK(handle)) bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F0; - } else if (PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(handle)) { + else if (PCIE_DMA_HOST_ADDR_BIT53_MASK_CHECK(handle)) bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS_F1; - } else { + else bit_pos = PCIE_DMA_HOST_ADDR_BIT_POS; - } return bit_pos; } static inline struct dma_pool *ps3_dma_pool_create(const char *name, - struct device *dev, size_t size, size_t align, size_t boundary) + struct device *dev, + size_t size, size_t align, + size_t boundary) { struct dma_pool *pool = NULL; + pool = dma_pool_create(name, dev, size, align, boundary); - LOG_INFO("create dma pool:name '%s', size %lu, align %lu, boundary %lu, pool %p\n", - name, size, align, boundary, pool); + LOG_INFO( + "create dma pool:name '%s', size %lu, align %lu, boundary %lu, pool %p\n", + name, (unsigned long)size, (unsigned long)align, + (unsigned long)boundary, pool); return pool; } static inline void *ps3_dma_pool_alloc(struct ps3_instance *instance, - struct dma_pool *pool, gfp_t mem_flags, dma_addr_t *handle) + struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) { void *ret = dma_pool_alloc(pool, mem_flags, handle); - if(ret != NULL) { - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + + if (ret != NULL) { + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW( + instance->dma_addr_bit_pos, *handle); } return ret; } static inline void *ps3_dma_pool_zalloc(struct ps3_instance *instance, - struct dma_pool *pool, gfp_t mem_flags, - dma_addr_t *handle) + struct dma_pool *pool, gfp_t mem_flags, + dma_addr_t *handle) { void *ret = dma_pool_zalloc(pool, mem_flags, handle); - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + *handle); return ret; } static inline void ps3_dma_pool_destroy(struct dma_pool *pool) { dma_pool_destroy(pool); - LOG_INFO("pool destroy %p \n",pool); - return; + LOG_INFO("pool destroy %p\n", pool); } -static inline void ps3_dma_pool_free(struct dma_pool *pool, - void *vaddr, dma_addr_t dma) +static inline void ps3_dma_pool_free(struct dma_pool *pool, void *vaddr, + dma_addr_t dma) { - U8 bit_pos = 0; + unsigned char bit_pos = 0; + bit_pos = ps3_dma_addr_bit_pos_check(dma); - dma_pool_free(pool, vaddr, PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma)); - return; + dma_pool_free(pool, vaddr, + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma)); } -static inline U32 ps3_scsi_channel_query(struct scsi_cmnd *scmd) +static inline unsigned int ps3_scsi_channel_query(struct scsi_cmnd *scmd) { - U32 ret = U32_MAX; + unsigned int ret = U32_MAX; - if (scmd == NULL) { + if (scmd == NULL) goto l_out; - } - if (scmd->device == NULL) { + if (scmd->device == NULL) goto l_out; - } ret = scmd->device->channel; l_out: return ret; } -static inline U32 ps3_scsi_target_query(struct scsi_cmnd *scmd) +static inline unsigned int ps3_scsi_target_query(struct scsi_cmnd *scmd) { - U32 ret = U32_MAX; + unsigned int ret = U32_MAX; - if (scmd == NULL) { + if (scmd == NULL) goto l_out; - } - if (scmd->device == NULL) { + if (scmd->device == NULL) goto l_out; - } ret = scmd->device->id; l_out: return ret; } -static inline void *ps3_dma_alloc_coherent(struct ps3_instance *instance, size_t size, - U64 *handle) +static inline void *ps3_dma_alloc_coherent(struct ps3_instance *instance, + size_t size, + unsigned long long *handle) { void *buffer = NULL; - buffer = dma_alloc_coherent(&instance->pdev->dev, size, handle, GFP_KERNEL); - *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, *handle); + + buffer = dma_alloc_coherent(&instance->pdev->dev, size, + (dma_addr_t *)handle, GFP_KERNEL); + *handle = PCIE_DMA_HOST_ADDR_BIT_POS_SET_NEW(instance->dma_addr_bit_pos, + *handle); return buffer; } -static inline void ps3_dma_free_coherent(struct ps3_instance *instance, size_t size, - void *vaddr, U64 dma_handle) +static inline void ps3_dma_free_coherent(struct ps3_instance *instance, + size_t size, void *vaddr, + unsigned long long dma_handle) { - U8 bit_pos = 0; + unsigned char bit_pos = 0; + bit_pos = ps3_dma_addr_bit_pos_check(dma_handle); dma_free_coherent(&instance->pdev->dev, size, vaddr, - PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, dma_handle)); - return; + PCIE_DMA_HOST_ADDR_BIT_POS_CLEAR_NEW(bit_pos, + dma_handle)); } -static inline U32 ps3_utility_mod64(U64 dividend, U32 divisor) +static inline unsigned int ps3_utility_mod64(unsigned long long dividend, + unsigned int divisor) { - U64 d = dividend; - U32 remainder = 0; + unsigned long long d = dividend; + unsigned int remainder = 0; if (!divisor) { LOG_ERROR("DIVISOR is zero, in div fn\n"); - return (U32)-1; + return (unsigned int)-1; } #ifndef _WINDOWS @@ -404,5 +417,45 @@ static inline U32 ps3_utility_mod64(U64 dividend, U32 divisor) #endif return remainder; } + +static inline unsigned long long +ps3_utility_div64_32(unsigned long long dividend, unsigned int divisor) +{ + unsigned long long d = dividend; + + if (!divisor) + LOG_ERROR("DIVISOR is zero, in div64_32 fn\n"); + + do_div(d, divisor); + + return d; +} + +#if defined(PS3_STRSCPY) +#define PS3_STRCPY(dest, src, n) strscpy(dest, src, n) +#else +#define PS3_STRCPY(dest, src, n) strncpy(dest, src, n) +#endif + +#if defined(PS3_KMAP_LOCAL) +#define PS3_KMAP(page) kmap_local_page(page) +#else +#define PS3_KMAP(page) kmap(page) #endif +#if defined(PS3_KUNMAP_LOCAL) +#define PS3_KUNMAP(page, buff) kunmap_local(buff) +#else +#define PS3_KUNMAP(page, buff) kunmap(page) +#endif + +#if defined(CONFIG_64BIT) +#define PS3_DIV64_32(dividend, divisor) ((dividend) / (divisor)) +#define PS3_MOD64(dividend, divisor) ((dividend) % (divisor)) +#else +#define PS3_DIV64_32(dividend, divisor) \ + (ps3_utility_div64_32((dividend), (divisor))) +#define PS3_MOD64(dividend, divisor) (ps3_utility_mod64((dividend), (divisor))) +#endif + +#endif diff --git a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c index 4e25829b24de..78dbe8d66f3d 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c +++ b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #ifndef _WINDOWS #include #include @@ -18,127 +19,150 @@ #include "ps3_ioc_manager.h" #include "ps3_err_inject.h" -#define PS3_WATCHDOG_NAME_MAX_LENGTH (48) - -static S32 ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) +#define PS3_WATCHDOG_NAME_MAX_LENGTH (32) +static int ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) { - U32 ioc_recovery_count = 0; - U32 ioc_state = PS3_FW_STATE_UNDEFINED; - S32 ret = PS3_SUCCESS; - U32 heartbeat_triggered = 0; + unsigned int ioc_recovery_count = 0; + unsigned int ioc_state = PS3_FW_STATE_UNDEFINED; + int ret = PS3_SUCCESS; + unsigned int heartbeat_triggered = 0; if (ps3_pci_err_recovery_get(instance)) { LOG_WARN_LIM("hno:%u pci recovery resetting\n", - PS3_HOST(instance)); + PS3_HOST(instance)); goto l_out; } if (!ps3_ioc_recovery_count_get(instance, &ioc_recovery_count)) { ps3_atomic_inc(&instance->watchdog_reg_read_fail_count); LOG_ERROR_LIM("hno:%u get recovery count NOK, cnt: %d\n", - PS3_HOST(instance), ps3_atomic_read(&instance->watchdog_reg_read_fail_count)); + PS3_HOST(instance), + ps3_atomic_read( + &instance->watchdog_reg_read_fail_count)); goto l_out; } if (!ps3_ioc_state_get_with_check(instance, &ioc_state)) { ps3_atomic_inc(&instance->watchdog_reg_read_fail_count); LOG_ERROR_LIM("hno:%u get ioc state NOK, cnt: %u\n", - PS3_HOST(instance), ps3_atomic_read(&instance->watchdog_reg_read_fail_count)); + PS3_HOST(instance), + ps3_atomic_read( + &instance->watchdog_reg_read_fail_count)); goto l_out; } ps3_atomic_set(&instance->watchdog_reg_read_fail_count, 0); if (instance->ioc_adpter->ioc_heartbeat_detect) { - if ((instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_DECIDE || - instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RECOVERY || - instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_HARDRESET_RETRY) - &&(instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE)) { + if ((instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_DECIDE || + instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_RECOVERY || + instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_HARDRESET_RETRY) && + (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { goto l_out; } - heartbeat_triggered = instance->ioc_adpter->ioc_heartbeat_detect(instance); - if (heartbeat_triggered == PS3_TRUE - && !ps3_pci_err_recovery_get(instance)) { + heartbeat_triggered = + instance->ioc_adpter->ioc_heartbeat_detect(instance); + if (heartbeat_triggered == PS3_TRUE && + !ps3_pci_err_recovery_get(instance)) { LOG_INFO("hno:%u heartbeat recovery triggered\n", - PS3_HOST(instance)); - ps3_mutex_lock(&instance->recovery_context->ps3_watchdog_recovery_mutex); - if (instance->recovery_context->heartbeat_recovery == PS3_HEARTBEAT_NULL) { + PS3_HOST(instance)); + ps3_mutex_lock(&instance->recovery_context + ->ps3_watchdog_recovery_mutex); + if (instance->recovery_context->heartbeat_recovery == + PS3_HEARTBEAT_NULL) { instance->recovery_context->heartbeat_recovery = PS3_HEARTBEAT_HARDRESET_DECIDE; } - ps3_mutex_unlock(&instance->recovery_context->ps3_watchdog_recovery_mutex); + ps3_mutex_unlock( + &instance->recovery_context + ->ps3_watchdog_recovery_mutex); goto l_recovery; } } if (ioc_state == PS3_FW_STATE_FAULT || - ioc_state == PS3_FW_STATE_CRITICAL) { + ioc_state == PS3_FW_STATE_CRITICAL) { goto l_recovery; } if ((ioc_state == PS3_FW_STATE_RUNNING) && - (instance->recovery_context->ioc_recovery_count == - ioc_recovery_count)) { + (instance->recovery_context->ioc_recovery_count == + ioc_recovery_count)) { goto l_out; } - if (ioc_state == PS3_FW_STATE_RESET) { + if (ioc_state == PS3_FW_STATE_RESET) goto l_out; - } - if (ioc_recovery_count == PS3_IOC_RECOVERY_COUNT_MASK) { + if (ioc_recovery_count == PS3_IOC_RECOVERY_COUNT_MASK) goto l_out; - } - if (ioc_state == PS3_FW_STATE_UNDEFINED) { + if (ioc_state == PS3_FW_STATE_UNDEFINED) goto l_out; - } - if (ioc_state == PS3_FW_STATE_MASK) { + if (ioc_state == PS3_FW_STATE_MASK) goto l_out; - } l_recovery: - LOG_INFO("hno:%u watchdog recovery request, ioc_state[0x%x]," - " ioc_reco_cnt[%u], local_reco_cnt[%u]\n", - PS3_HOST(instance), ioc_state, ioc_recovery_count, - instance->recovery_context->ioc_recovery_count); + LOG_INFO( + "hno:%u watchdog recovery req, ioc_state[0x%x] ioc_reco_cnt[%u], local_reco_cnt[%u]\n", + PS3_HOST(instance), ioc_state, ioc_recovery_count, + instance->recovery_context->ioc_recovery_count); PS3_IJ_SLEEP(200000, PS3_ERR_IJ_WATCHDOG_DELAY); - if (ps3_atomic_read(&instance->state_machine.state) != PS3_INSTANCE_STATE_DEAD) { - if (ps3_need_block_hard_reset_request(instance) || PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || \ - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_SHALLOW || \ - instance->recovery_context->recovery_state == PS3_HARD_RECOVERY_DECIDE) { - LOG_WARN_LIM("hno:%u can not start reset request recovery_state:%d\n", - PS3_HOST(instance), instance->recovery_context->recovery_state); + if (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_DEAD) { + if (ps3_need_block_hard_reset_request(instance) || + PS3_IS_INSTANCE_NOT_LOAD_NORMAL(instance) || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { + LOG_WARN_LIM( + "hno:%u can not start reset request recovery_state:%d\n", + PS3_HOST(instance), + instance->recovery_context->recovery_state); } else { - LOG_WARN("hno:%u ps3 watchdog recovery start, heartbeat_triggered:%u ioc_state:0x%x\n", - PS3_HOST(instance), heartbeat_triggered, ioc_state); - if(ps3_recovery_request(instance) == PS3_SUCCESS){ + LOG_WARN( + "hno:%u ps3 watchdog recovery start, heartbeat_triggered:%u ioc_state:0x%x\n", + PS3_HOST(instance), heartbeat_triggered, + ioc_state); + if (ps3_recovery_request(instance, PS3_FALSE) == PS3_SUCCESS) { LOG_INFO("hno[%u], recovery success!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ret = PS3_SUCCESS; - }else{ - LOG_ERROR("hno[%u], recovery request NOK, %s!\n", + } else { + LOG_ERROR( + "hno[%u], recovery request NOK, %s!\n", PS3_HOST(instance), - namePS3InstanceState(ps3_atomic_read(&instance->state_machine.state))); + namePS3InstanceState(ps3_atomic_read( + &instance->state_machine + .state))); return -PS3_FAILED; } } } l_out: - if (ps3_atomic_read(&instance->watchdog_reg_read_fail_count) >= PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT) { + if (ps3_atomic_read(&instance->watchdog_reg_read_fail_count) >= + PS3_TRANS_DEAD_IOC_FAILED_MAX_COUNT) { #ifdef PS3_HARDWARE_SIM - LOG_WARN("hno:%u reg read failed 5 times consecutively, simu platform ignore\n", + LOG_WARN( + "hno:%u reg read failed 5 times consecutively, simu platform ignore\n", PS3_HOST(instance)); #else ps3_instance_state_transfer_to_dead(instance); instance->watchdog_context.is_stop = PS3_TRUE; - LOG_ERROR("hno:%u reg read failed 5 times consecutively, transfer to dead\n", + LOG_ERROR( + "hno:%u reg read failed 5 times consecutively, transfer to dead\n", PS3_HOST(instance)); ret = -PS3_FAILED; #endif @@ -149,19 +173,18 @@ static S32 ps3_watchdog_fault_detect_and_recovery(struct ps3_instance *instance) #ifndef _WINDOWS -static void ps3_watchdog_service(struct work_struct* work) +static void ps3_watchdog_service(struct work_struct *work) { - struct ps3_watchdog_context* watchdog_ctx = - ps3_container_of(work, struct ps3_watchdog_context, - watchdog_work.work); + struct ps3_watchdog_context *watchdog_ctx = ps3_container_of( + work, struct ps3_watchdog_context, watchdog_work.work); struct ps3_instance *instance = watchdog_ctx->instance; - struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; - S32 ret = PS3_SUCCESS; + struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; + int ret = PS3_SUCCESS; if (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE) { + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE) { watchdog_ctx->is_halt = PS3_TRUE; goto l_next; } @@ -170,36 +193,36 @@ static void ps3_watchdog_service(struct work_struct* work) if (instance->is_probe_finish && instance->state_machine.is_load) { ret = ps3_watchdog_fault_detect_and_recovery(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u watchdog fault detect and recovery \ - NOK watchdog service exit\n", - PS3_HOST(instance)); + LOG_ERROR( + "hno:%u watchdog fault detect and recovery NOK watchdog service exit\n", + PS3_HOST(instance)); } } l_next: if (watchdog_ctx->is_stop) { - LOG_INFO("hno:%u watchdog has stop\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u watchdog has stop\n", PS3_HOST(instance)); return; } - ps3_qos_waitq_poll(instance); + ps3_qos_waitq_poll(instance); if (watchdog_ctx->watchdog_queue != NULL) { queue_delayed_work(watchdog_ctx->watchdog_queue, delayed_work, - msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); + msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); } } -S32 ps3_watchdog_start(struct ps3_instance *instance) +int ps3_watchdog_start(struct ps3_instance *instance) { - struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; + struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; char watchdog_queue_name[PS3_WATCHDOG_NAME_MAX_LENGTH]; - struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; + struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; + ps3_atomic_inc(&instance->watchdog_ref); - mb(); + mb(); /* in order to force CPU ordering */ - if (PS3_FALSE == watchdog_ctx->is_stop) { + if (watchdog_ctx->is_stop == PS3_FALSE) { LOG_DEBUG("hno:%u watchdog running\n", PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); return PS3_SUCCESS; @@ -207,7 +230,7 @@ S32 ps3_watchdog_start(struct ps3_instance *instance) if (watchdog_ctx->watchdog_queue != NULL) { LOG_DEBUG("hno:%u watchdog for is already started!\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); goto l_out; } @@ -217,13 +240,13 @@ S32 ps3_watchdog_start(struct ps3_instance *instance) INIT_DELAYED_WORK(delayed_work, ps3_watchdog_service); snprintf(watchdog_queue_name, PS3_WATCHDOG_NAME_MAX_LENGTH, - "ps3_watchdog_service_host%d", instance->host->host_no); + "ps3_wdt_ho%d", instance->host->host_no); watchdog_ctx->watchdog_queue = create_singlethread_workqueue(watchdog_queue_name); if (watchdog_ctx->watchdog_queue == NULL) { LOG_ERROR("hno:%u watchdog work queue create failed\n", - PS3_HOST(instance)); + PS3_HOST(instance)); ps3_atomic_dec(&instance->watchdog_ref); return -PS3_FAILED; } @@ -231,7 +254,7 @@ S32 ps3_watchdog_start(struct ps3_instance *instance) watchdog_ctx->instance = instance; watchdog_ctx->is_stop = PS3_FALSE; queue_delayed_work(watchdog_ctx->watchdog_queue, delayed_work, - msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); + msecs_to_jiffies(PS3_WATCHDOG_INTERVAL)); ps3_atomic_dec(&instance->watchdog_ref); l_out: @@ -240,47 +263,44 @@ S32 ps3_watchdog_start(struct ps3_instance *instance) void ps3_watchdog_stop(struct ps3_instance *instance) { - struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; - struct workqueue_struct* watchdog_queue; - struct delayed_work* delayed_work = &watchdog_ctx->watchdog_work; + struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; + struct workqueue_struct *watchdog_queue; + struct delayed_work *delayed_work = &watchdog_ctx->watchdog_work; - if (PS3_TRUE == watchdog_ctx->is_stop) { + if (watchdog_ctx->is_stop == PS3_TRUE) return; - } watchdog_ctx->is_stop = PS3_TRUE; - mb(); - while(ps3_atomic_read(&instance->watchdog_ref) != 0) { + mb(); /* in order to force CPU ordering */ + while (ps3_atomic_read(&instance->watchdog_ref) != 0) ps3_msleep(PS3_LOOP_TIME_INTERVAL_100MS); - } if (watchdog_ctx->watchdog_queue != NULL) { watchdog_queue = watchdog_ctx->watchdog_queue; - if (!cancel_delayed_work_sync(delayed_work)) { + if (!cancel_delayed_work_sync(delayed_work)) flush_workqueue(watchdog_queue); - } destroy_workqueue(watchdog_queue); watchdog_ctx->watchdog_queue = NULL; - LOG_INFO("hno:%u watchdog destory work and stop\n", - PS3_HOST(instance)); + LOG_INFO("hno:%u watchdog destroy work and stop\n", + PS3_HOST(instance)); } } #else static void ps3_watchdog_service(void *ins) { - struct ps3_instance *instance = (struct ps3_instance*)ins; - struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; - S32 ret = PS3_SUCCESS; - - if(ps3_atomic_read(&instance->state_machine.state) != - PS3_INSTANCE_STATE_OPERATIONAL && - (instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_SHALLOW || - instance->recovery_context->recovery_state == - PS3_HARD_RECOVERY_DECIDE)) { + struct ps3_instance *instance = (struct ps3_instance *)ins; + struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; + int ret = PS3_SUCCESS; + + if (ps3_atomic_read(&instance->state_machine.state) != + PS3_INSTANCE_STATE_OPERATIONAL && + (instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_SHALLOW || + instance->recovery_context->recovery_state == + PS3_HARD_RECOVERY_DECIDE)) { watchdog_ctx->is_halt = PS3_TRUE; goto l_next; } @@ -290,16 +310,15 @@ static void ps3_watchdog_service(void *ins) if (instance->is_probe_finish) { ret = ps3_watchdog_fault_detect_and_recovery(instance); if (ret != PS3_SUCCESS) { - LOG_ERROR("hno:%u watchdog fault detect and recovery \ - failed watchdog service exit\n", - PS3_HOST(instance)); + LOG_ERROR( + "hno:%u watchdog fault detect and recovery failed watchdog service exit\n", + PS3_HOST(instance)); } } l_next: if (watchdog_ctx->is_stop) { - LOG_DEBUG("hno:%u watchdog has stop\n", - PS3_HOST(instance)); + LOG_DEBUG("hno:%u watchdog has stop\n", PS3_HOST(instance)); return; } @@ -308,25 +327,26 @@ static void ps3_watchdog_service(void *ins) ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL); } -S32 ps3_watchdog_start(struct ps3_instance *instance) +int ps3_watchdog_start(struct ps3_instance *instance) { - S32 ret = PS3_SUCCESS; - struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; + int ret = PS3_SUCCESS; + struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; memset(watchdog_ctx, 0, sizeof(struct ps3_watchdog_context)); - if (ps3_delay_worker_init(instance, watchdog_work, "ps3_watchdog_service", ps3_watchdog_service) != PS3_SUCCESS) { - LOG_ERROR("hno:%u timer init failed\n", - PS3_HOST(instance)); + if (ps3_delay_worker_init(instance, watchdog_work, + "ps3_watchdog_service", + ps3_watchdog_service) != PS3_SUCCESS) { + LOG_ERROR("hno:%u timer init failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; goto l_out; } watchdog_ctx->is_stop = PS3_FALSE; - if (ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL) != PS3_SUCCESS) { - LOG_ERROR("hno:%u timer request failed\n", - PS3_HOST(instance)); + if (ps3_delay_worker_start(watchdog_work, PS3_WATCHDOG_INTERVAL) != + PS3_SUCCESS) { + LOG_ERROR("hno:%u timer request failed\n", PS3_HOST(instance)); ret = -PS3_FAILED; watchdog_ctx->is_stop = PS3_TRUE; goto l_out; @@ -338,15 +358,14 @@ S32 ps3_watchdog_start(struct ps3_instance *instance) void ps3_watchdog_stop(struct ps3_instance *instance) { - struct ps3_watchdog_context* watchdog_ctx = &instance->watchdog_context; - struct ps3_delay_worker* watchdog_work = &watchdog_ctx->watchdog_work; + struct ps3_watchdog_context *watchdog_ctx = &instance->watchdog_context; + struct ps3_delay_worker *watchdog_work = &watchdog_ctx->watchdog_work; watchdog_ctx->is_stop = PS3_TRUE; ps3_delay_worker_exit(watchdog_work); memset(watchdog_ctx, 0, sizeof(struct ps3_watchdog_context)); - LOG_WARN("hno:%u watchdog destory work and stop\n", - PS3_HOST(instance)); + LOG_WARN("hno:%u watchdog destroy work and stop\n", + PS3_HOST(instance)); } #endif - diff --git a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h index 156fb28428d7..cc1098db4780 100644 --- a/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h +++ b/drivers/scsi/linkdata/ps3stor/ps3_watchdog.h @@ -1,4 +1,4 @@ - +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _PS3_WATCHDOG_H_ #define _PS3_WATCHDOG_H_ @@ -12,21 +12,21 @@ #include "ps3_htp_def.h" #include "ps3_instance_manager.h" -#define PS3_WATCHDOG_INTERVAL (1000) +#define PS3_WATCHDOG_INTERVAL (1000) struct ps3_watchdog_context { #ifndef _WINDOWS - struct delayed_work watchdog_work; - struct workqueue_struct *watchdog_queue; - struct ps3_instance *instance; + struct delayed_work watchdog_work; + struct workqueue_struct *watchdog_queue; + struct ps3_instance *instance; #else struct ps3_delay_worker watchdog_work; #endif - Bool is_stop; - Bool is_halt; + unsigned char is_stop; + unsigned char is_halt; }; -S32 ps3_watchdog_start(struct ps3_instance *instance); +int ps3_watchdog_start(struct ps3_instance *instance); void ps3_watchdog_stop(struct ps3_instance *instance); #endif -- Gitee