1 /* 2 * SPDX-FileCopyrightText: Copyright (c) 2020-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. 3 * SPDX-License-Identifier: MIT 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24 25 #include "common_nvswitch.h" 26 #include "ls10/ls10.h" 27 #include "ls10/inforom_ls10.h" 28 #include "inforom/ifrstruct.h" 29 #include "soe/soeififr.h" 30 #include "rmsoecmdif.h" 31 #include "flcn/flcn_nvswitch.h" 32 #include "rmflcncmdif_nvswitch.h" 33 34 NvlStatus 35 nvswitch_inforom_nvl_log_error_event_ls10 36 ( 37 nvswitch_device *device, 38 void *pNvlGeneric, 39 void *pNvlErrorEvent, 40 NvBool *bDirty 41 ) 42 { 43 return -NVL_ERR_NOT_IMPLEMENTED; 44 } 45 46 NvlStatus nvswitch_inforom_nvl_update_link_correctable_error_info_ls10 47 ( 48 nvswitch_device *device, 49 void *pNvlGeneric, 50 void *pData, 51 NvU8 linkId, 52 NvU8 nvliptInstance, 53 NvU8 localLinkIdx, 54 void *pNvlErrorCounts, 55 NvBool *bDirty 56 ) 57 { 58 return -NVL_ERR_NOT_IMPLEMENTED; 59 } 60 61 NvlStatus 62 nvswitch_oms_inforom_flush_ls10 63 ( 64 nvswitch_device *device 65 ) 66 { 67 return -NVL_ERR_NOT_IMPLEMENTED; 68 } 69 70 void 71 nvswitch_initialize_oms_state_ls10 72 ( 73 nvswitch_device *device, 74 INFOROM_OMS_STATE *pOmsState 75 ) 76 { 77 return; 78 } 79 80 NvBool 81 nvswitch_oms_get_device_disable_ls10 82 ( 83 INFOROM_OMS_STATE *pOmsState 84 ) 85 { 86 return NV_FALSE; 87 } 88 89 void 90 nvswitch_oms_set_device_disable_ls10 91 ( 92 INFOROM_OMS_STATE *pOmsState, 93 NvBool bForceDeviceDisable 94 ) 95 { 96 return; 97 } 98 99 void 100 nvswitch_inforom_ecc_get_total_errors_ls10 101 ( 102 nvswitch_device *device, 103 INFOROM_ECC_OBJECT *pEccGeneric, 104 NvU64 *pCorrectedTotal, 105 NvU64 *pUncorrectedTotal 106 ) 107 { 108 return; 109 } 110 111 NvlStatus 112 nvswitch_inforom_load_obd_ls10 113 ( 114 nvswitch_device *device 115 ) 116 { 117 struct inforom *pInforom = device->pInforom; 118 119 if (pInforom == NULL) 120 { 121 return -NVL_ERR_NOT_SUPPORTED; 122 } 123 124 return nvswitch_inforom_load_object(device, pInforom, "OBD", 125 INFOROM_OBD_OBJECT_V2_XX_FMT, 126 pInforom->OBD.packedObject.v2, 127 &pInforom->OBD.object.v2); 128 } 129 130 NvlStatus 131 nvswitch_bbx_add_sxid_ls10 132 ( 133 nvswitch_device *device, 134 NvU32 exceptionType, 135 NvU32 data0, 136 NvU32 data1, 137 NvU32 data2 138 ) 139 { 140 NvlStatus status; 141 FLCN *pFlcn; 142 RM_FLCN_CMD_SOE bbxCmd; 143 NvU32 cmdSeqDesc; 144 NVSWITCH_TIMEOUT timeout; 145 146 if (!nvswitch_is_inforom_supported_ls10(device)) 147 { 148 NVSWITCH_PRINT(device, INFO, "InfoROM is not supported, skipping\n"); 149 return NVL_SUCCESS; 150 } 151 152 // Avoid logging SOE related SXIDs to prevent recursive errors 153 if (exceptionType > NVSWITCH_ERR_HW_SOE && exceptionType < NVSWITCH_ERR_HW_SOE_LAST) 154 { 155 NVSWITCH_PRINT(device, INFO, "Not logging SXID: %d to InfoROM\n", exceptionType); 156 return NVL_SUCCESS; 157 } 158 159 pFlcn = device->pSoe->pFlcn; 160 nvswitch_timeout_create(NVSWITCH_INTERVAL_5MSEC_IN_NS, &timeout); 161 162 nvswitch_os_memset(&bbxCmd, 0, sizeof(bbxCmd)); 163 bbxCmd.hdr.unitId = RM_SOE_UNIT_IFR; 164 bbxCmd.hdr.size = sizeof(bbxCmd); 165 bbxCmd.cmd.ifr.cmdType = RM_SOE_IFR_BBX_SXID_ADD; 166 bbxCmd.cmd.ifr.bbxSxidAdd.exceptionType = exceptionType; 167 bbxCmd.cmd.ifr.bbxSxidAdd.data[0] = data0; 168 bbxCmd.cmd.ifr.bbxSxidAdd.data[1] = data1; 169 bbxCmd.cmd.ifr.bbxSxidAdd.data[2] = data2; 170 171 status = flcnQueueCmdPostBlocking(device, pFlcn, 172 (PRM_FLCN_CMD)&bbxCmd, 173 NULL, // pMsg 174 NULL, // pPayload 175 SOE_RM_CMDQ_LOG_ID, 176 &cmdSeqDesc, 177 &timeout); 178 if (status != NV_OK) 179 { 180 NVSWITCH_PRINT(device, ERROR, "%s: BBX cmd %d failed. rc:%d\n", 181 __FUNCTION__, bbxCmd.cmd.ifr.cmdType, status); 182 } 183 184 return status; 185 } 186 187 NvlStatus 188 nvswitch_bbx_unload_ls10 189 ( 190 nvswitch_device *device 191 ) 192 { 193 NvlStatus status; 194 FLCN *pFlcn; 195 RM_FLCN_CMD_SOE bbxCmd; 196 NvU32 cmdSeqDesc; 197 NVSWITCH_TIMEOUT timeout; 198 199 pFlcn = device->pSoe->pFlcn; 200 nvswitch_timeout_create(NVSWITCH_INTERVAL_4SEC_IN_NS, &timeout); 201 202 nvswitch_os_memset(&bbxCmd, 0, sizeof(bbxCmd)); 203 bbxCmd.hdr.unitId = RM_SOE_UNIT_IFR; 204 bbxCmd.hdr.size = sizeof(bbxCmd); 205 bbxCmd.cmd.ifr.cmdType = RM_SOE_IFR_BBX_SHUTDOWN; 206 207 status = flcnQueueCmdPostBlocking(device, pFlcn, 208 (PRM_FLCN_CMD)&bbxCmd, 209 NULL, // pMsg 210 NULL, // pPayload 211 SOE_RM_CMDQ_LOG_ID, 212 &cmdSeqDesc, 213 &timeout); 214 if (status != NV_OK) 215 { 216 NVSWITCH_PRINT(device, ERROR, "%s: BBX cmd %d failed. rc:%d\n", 217 __FUNCTION__, bbxCmd.cmd.ifr.cmdType, status); 218 } 219 220 return status; 221 } 222 223 NvlStatus 224 nvswitch_bbx_load_ls10 225 ( 226 nvswitch_device *device, 227 NvU64 time_ns, 228 NvU8 osType, 229 NvU32 osVersion 230 ) 231 { 232 NvlStatus status; 233 FLCN *pFlcn; 234 RM_FLCN_CMD_SOE bbxCmd; 235 NvU32 cmdSeqDesc = 0; 236 NVSWITCH_TIMEOUT timeout; 237 238 pFlcn = device->pSoe->pFlcn; 239 nvswitch_timeout_create(NVSWITCH_INTERVAL_4SEC_IN_NS, &timeout); 240 241 nvswitch_os_memset(&bbxCmd, 0, sizeof(bbxCmd)); 242 bbxCmd.hdr.unitId = RM_SOE_UNIT_IFR; 243 bbxCmd.hdr.size = sizeof(bbxCmd); 244 bbxCmd.cmd.ifr.cmdType = RM_SOE_IFR_BBX_INITIALIZE; 245 bbxCmd.cmd.ifr.bbxInit.osType = osType; 246 bbxCmd.cmd.ifr.bbxInit.osVersion = osVersion; 247 RM_FLCN_U64_PACK(&bbxCmd.cmd.ifr.bbxInit.time, &time_ns); 248 249 NVSWITCH_PRINT(device, INFO, "RM_SOE_IFR_BBX_INITIALIZE called, time_ns=%llu \n", time_ns); 250 251 status = flcnQueueCmdPostBlocking(device, pFlcn, 252 (PRM_FLCN_CMD)&bbxCmd, 253 NULL, // pMsg 254 NULL, // pPayload 255 SOE_RM_CMDQ_LOG_ID, 256 &cmdSeqDesc, 257 &timeout); 258 if (status != NV_OK) 259 { 260 NVSWITCH_PRINT(device, ERROR, "%s: BBX cmd %d failed. rc:%d\n", 261 __FUNCTION__, bbxCmd.cmd.ifr.cmdType, status); 262 } 263 264 return status; 265 } 266 267 NvlStatus 268 nvswitch_bbx_get_sxid_ls10 269 ( 270 nvswitch_device *device, 271 NVSWITCH_GET_SXIDS_PARAMS *params 272 ) 273 { 274 return -NVL_ERR_NOT_SUPPORTED; 275 } 276