1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* Copyright (c) 2016-2017 Hisilicon Limited. */ 3 4 #ifndef __HCLGE_ERR_H 5 #define __HCLGE_ERR_H 6 7 #include "hclge_main.h" 8 #include "hnae3.h" 9 10 #define HCLGE_MPF_RAS_INT_MIN_BD_NUM 10 11 #define HCLGE_PF_RAS_INT_MIN_BD_NUM 4 12 #define HCLGE_MPF_MSIX_INT_MIN_BD_NUM 10 13 #define HCLGE_PF_MSIX_INT_MIN_BD_NUM 4 14 15 #define HCLGE_RAS_PF_OTHER_INT_STS_REG 0x20B00 16 #define HCLGE_RAS_REG_NFE_MASK 0xFF00 17 #define HCLGE_RAS_REG_ROCEE_ERR_MASK 0x3000000 18 #define HCLGE_RAS_REG_ERR_MASK \ 19 (HCLGE_RAS_REG_NFE_MASK | HCLGE_RAS_REG_ROCEE_ERR_MASK) 20 21 #define HCLGE_VECTOR0_REG_MSIX_MASK 0x1FF00 22 23 #define HCLGE_IMP_TCM_ECC_ERR_INT_EN 0xFFFF0000 24 #define HCLGE_IMP_TCM_ECC_ERR_INT_EN_MASK 0xFFFF0000 25 #define HCLGE_IMP_ITCM4_ECC_ERR_INT_EN 0x300 26 #define HCLGE_IMP_ITCM4_ECC_ERR_INT_EN_MASK 0x300 27 #define HCLGE_CMDQ_NIC_ECC_ERR_INT_EN 0xFFFF 28 #define HCLGE_CMDQ_NIC_ECC_ERR_INT_EN_MASK 0xFFFF 29 #define HCLGE_CMDQ_ROCEE_ECC_ERR_INT_EN 0xFFFF0000 30 #define HCLGE_CMDQ_ROCEE_ECC_ERR_INT_EN_MASK 0xFFFF0000 31 #define HCLGE_IMP_RD_POISON_ERR_INT_EN 0x0100 32 #define HCLGE_IMP_RD_POISON_ERR_INT_EN_MASK 0x0100 33 #define HCLGE_TQP_ECC_ERR_INT_EN 0x0FFF 34 #define HCLGE_TQP_ECC_ERR_INT_EN_MASK 0x0FFF 35 #define HCLGE_MSIX_SRAM_ECC_ERR_INT_EN_MASK 0x0F000000 36 #define HCLGE_MSIX_SRAM_ECC_ERR_INT_EN 0x0F000000 37 #define HCLGE_IGU_ERR_INT_EN 0x0000000F 38 #define HCLGE_IGU_ERR_INT_TYPE 0x00000660 39 #define HCLGE_IGU_ERR_INT_EN_MASK 0x000F 40 #define HCLGE_IGU_TNL_ERR_INT_EN 0x0002AABF 41 #define HCLGE_IGU_TNL_ERR_INT_EN_MASK 0x003F 42 #define HCLGE_PPP_MPF_ECC_ERR_INT0_EN 0xFFFFFFFF 43 #define HCLGE_PPP_MPF_ECC_ERR_INT0_EN_MASK 0xFFFFFFFF 44 #define HCLGE_PPP_MPF_ECC_ERR_INT1_EN 0xFFFFFFFF 45 #define HCLGE_PPP_MPF_ECC_ERR_INT1_EN_MASK 0xFFFFFFFF 46 #define HCLGE_PPP_PF_ERR_INT_EN 0x0003 47 #define HCLGE_PPP_PF_ERR_INT_EN_MASK 0x0003 48 #define HCLGE_PPP_MPF_ECC_ERR_INT2_EN 0x003F 49 #define HCLGE_PPP_MPF_ECC_ERR_INT2_EN_MASK 0x003F 50 #define HCLGE_PPP_MPF_ECC_ERR_INT3_EN 0x003F 51 #define HCLGE_PPP_MPF_ECC_ERR_INT3_EN_MASK 0x003F 52 #define HCLGE_TM_SCH_ECC_ERR_INT_EN 0x3 53 #define HCLGE_TM_QCN_MEM_ERR_INT_EN 0xFFFFFF 54 #define HCLGE_NCSI_ERR_INT_EN 0x3 55 #define HCLGE_NCSI_ERR_INT_TYPE 0x9 56 #define HCLGE_MAC_COMMON_ERR_INT_EN 0x107FF 57 #define HCLGE_MAC_COMMON_ERR_INT_EN_MASK 0x107FF 58 #define HCLGE_MAC_TNL_INT_EN GENMASK(9, 0) 59 #define HCLGE_MAC_TNL_INT_EN_MASK GENMASK(9, 0) 60 #define HCLGE_MAC_TNL_INT_CLR GENMASK(9, 0) 61 #define HCLGE_PPU_MPF_ABNORMAL_INT0_EN GENMASK(31, 0) 62 #define HCLGE_PPU_MPF_ABNORMAL_INT0_EN_MASK GENMASK(31, 0) 63 #define HCLGE_PPU_MPF_ABNORMAL_INT1_EN GENMASK(31, 0) 64 #define HCLGE_PPU_MPF_ABNORMAL_INT1_EN_MASK GENMASK(31, 0) 65 #define HCLGE_PPU_MPF_ABNORMAL_INT2_EN 0x3FFF3FFF 66 #define HCLGE_PPU_MPF_ABNORMAL_INT2_EN_MASK 0x3FFF3FFF 67 #define HCLGE_PPU_MPF_ABNORMAL_INT2_EN2 0xB 68 #define HCLGE_PPU_MPF_ABNORMAL_INT2_EN2_MASK 0xB 69 #define HCLGE_PPU_MPF_ABNORMAL_INT3_EN GENMASK(7, 0) 70 #define HCLGE_PPU_MPF_ABNORMAL_INT3_EN_MASK GENMASK(23, 16) 71 #define HCLGE_PPU_PF_ABNORMAL_INT_EN GENMASK(5, 0) 72 #define HCLGE_PPU_PF_ABNORMAL_INT_EN_MASK GENMASK(5, 0) 73 #define HCLGE_SSU_1BIT_ECC_ERR_INT_EN GENMASK(31, 0) 74 #define HCLGE_SSU_1BIT_ECC_ERR_INT_EN_MASK GENMASK(31, 0) 75 #define HCLGE_SSU_MULTI_BIT_ECC_ERR_INT_EN GENMASK(31, 0) 76 #define HCLGE_SSU_MULTI_BIT_ECC_ERR_INT_EN_MASK GENMASK(31, 0) 77 #define HCLGE_SSU_BIT32_ECC_ERR_INT_EN 0x0101 78 #define HCLGE_SSU_BIT32_ECC_ERR_INT_EN_MASK 0x0101 79 #define HCLGE_SSU_COMMON_INT_EN GENMASK(9, 0) 80 #define HCLGE_SSU_COMMON_INT_EN_MASK GENMASK(9, 0) 81 #define HCLGE_SSU_PORT_BASED_ERR_INT_EN 0x0BFF 82 #define HCLGE_SSU_PORT_BASED_ERR_INT_EN_MASK 0x0BFF0000 83 #define HCLGE_SSU_FIFO_OVERFLOW_ERR_INT_EN GENMASK(23, 0) 84 #define HCLGE_SSU_FIFO_OVERFLOW_ERR_INT_EN_MASK GENMASK(23, 0) 85 86 #define HCLGE_SSU_COMMON_ERR_INT_MASK GENMASK(9, 0) 87 #define HCLGE_SSU_PORT_INT_MSIX_MASK 0x7BFF 88 #define HCLGE_IGU_INT_MASK GENMASK(3, 0) 89 #define HCLGE_IGU_EGU_TNL_INT_MASK GENMASK(5, 0) 90 #define HCLGE_PPP_MPF_INT_ST3_MASK GENMASK(5, 0) 91 #define HCLGE_PPU_MPF_INT_ST3_MASK GENMASK(7, 0) 92 #define HCLGE_PPU_MPF_INT_ST2_MSIX_MASK BIT(29) 93 #define HCLGE_PPU_PF_INT_RAS_MASK 0x18 94 #define HCLGE_PPU_PF_INT_MSIX_MASK 0x26 95 #define HCLGE_PPU_PF_OVER_8BD_ERR_MASK 0x01 96 #define HCLGE_QCN_FIFO_INT_MASK GENMASK(17, 0) 97 #define HCLGE_QCN_ECC_INT_MASK GENMASK(21, 0) 98 #define HCLGE_NCSI_ECC_INT_MASK GENMASK(1, 0) 99 100 #define HCLGE_ROCEE_RAS_NFE_INT_EN 0xF 101 #define HCLGE_ROCEE_RAS_CE_INT_EN 0x1 102 #define HCLGE_ROCEE_RAS_NFE_INT_EN_MASK 0xF 103 #define HCLGE_ROCEE_RAS_CE_INT_EN_MASK 0x1 104 #define HCLGE_ROCEE_RERR_INT_MASK BIT(0) 105 #define HCLGE_ROCEE_BERR_INT_MASK BIT(1) 106 #define HCLGE_ROCEE_AXI_ERR_INT_MASK GENMASK(1, 0) 107 #define HCLGE_ROCEE_ECC_INT_MASK BIT(2) 108 #define HCLGE_ROCEE_OVF_INT_MASK BIT(3) 109 #define HCLGE_ROCEE_OVF_ERR_INT_MASK 0x10000 110 #define HCLGE_ROCEE_OVF_ERR_TYPE_MASK 0x3F 111 112 #define HCLGE_DESC_DATA_MAX 8 113 #define HCLGE_REG_NUM_MAX 256 114 #define HCLGE_DESC_NO_DATA_LEN 8 115 116 enum hclge_err_int_type { 117 HCLGE_ERR_INT_MSIX = 0, 118 HCLGE_ERR_INT_RAS_CE = 1, 119 HCLGE_ERR_INT_RAS_NFE = 2, 120 HCLGE_ERR_INT_RAS_FE = 3, 121 }; 122 123 enum hclge_mod_name_list { 124 MODULE_NONE = 0, 125 MODULE_BIOS_COMMON = 1, 126 MODULE_GE = 2, 127 MODULE_IGU_EGU = 3, 128 MODULE_LGE = 4, 129 MODULE_NCSI = 5, 130 MODULE_PPP = 6, 131 MODULE_QCN = 7, 132 MODULE_RCB_RX = 8, 133 MODULE_RTC = 9, 134 MODULE_SSU = 10, 135 MODULE_TM = 11, 136 MODULE_RCB_TX = 12, 137 MODULE_TXDMA = 13, 138 MODULE_MASTER = 14, 139 /* add new MODULE NAME for NIC here in order */ 140 MODULE_ROCEE_TOP = 40, 141 MODULE_ROCEE_TIMER = 41, 142 MODULE_ROCEE_MDB = 42, 143 MODULE_ROCEE_TSP = 43, 144 MODULE_ROCEE_TRP = 44, 145 MODULE_ROCEE_SCC = 45, 146 MODULE_ROCEE_CAEP = 46, 147 MODULE_ROCEE_GEN_AC = 47, 148 MODULE_ROCEE_QMM = 48, 149 MODULE_ROCEE_LSAN = 49, 150 /* add new MODULE NAME for RoCEE here in order */ 151 }; 152 153 enum hclge_err_type_list { 154 NONE_ERROR = 0, 155 FIFO_ERROR = 1, 156 MEMORY_ERROR = 2, 157 POISON_ERROR = 3, 158 MSIX_ECC_ERROR = 4, 159 TQP_INT_ECC_ERROR = 5, 160 PF_ABNORMAL_INT_ERROR = 6, 161 MPF_ABNORMAL_INT_ERROR = 7, 162 COMMON_ERROR = 8, 163 PORT_ERROR = 9, 164 ETS_ERROR = 10, 165 NCSI_ERROR = 11, 166 GLB_ERROR = 12, 167 /* add new ERROR TYPE for NIC here in order */ 168 ROCEE_NORMAL_ERR = 40, 169 ROCEE_OVF_ERR = 41, 170 /* add new ERROR TYPE for ROCEE here in order */ 171 }; 172 173 struct hclge_hw_blk { 174 u32 msk; 175 const char *name; 176 int (*config_err_int)(struct hclge_dev *hdev, bool en); 177 }; 178 179 struct hclge_hw_error { 180 u32 int_msk; 181 const char *msg; 182 enum hnae3_reset_type reset_level; 183 }; 184 185 struct hclge_hw_module_id { 186 enum hclge_mod_name_list module_id; 187 const char *msg; 188 }; 189 190 struct hclge_hw_type_id { 191 enum hclge_err_type_list type_id; 192 const char *msg; 193 }; 194 195 struct hclge_sum_err_info { 196 u8 reset_type; 197 u8 mod_num; 198 u8 rsv[2]; 199 }; 200 201 struct hclge_mod_err_info { 202 u8 mod_id; 203 u8 err_num; 204 u8 rsv[2]; 205 }; 206 207 struct hclge_type_reg_err_info { 208 u8 type_id; 209 u8 reg_num; 210 u8 rsv[2]; 211 u32 hclge_reg[HCLGE_REG_NUM_MAX]; 212 }; 213 214 int hclge_config_mac_tnl_int(struct hclge_dev *hdev, bool en); 215 int hclge_config_nic_hw_error(struct hclge_dev *hdev, bool state); 216 int hclge_config_rocee_ras_interrupt(struct hclge_dev *hdev, bool en); 217 void hclge_handle_all_hns_hw_errors(struct hnae3_ae_dev *ae_dev); 218 bool hclge_find_error_source(struct hclge_dev *hdev); 219 void hclge_handle_occurred_error(struct hclge_dev *hdev); 220 pci_ers_result_t hclge_handle_hw_ras_error(struct hnae3_ae_dev *ae_dev); 221 int hclge_handle_hw_msix_error(struct hclge_dev *hdev, 222 unsigned long *reset_requests); 223 int hclge_handle_error_info_log(struct hnae3_ae_dev *ae_dev); 224 int hclge_handle_mac_tnl(struct hclge_dev *hdev); 225 #endif 226