/* * Copyright (c) 2018-present Facebook. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once enum ipmi_fb_net_fns { NETFN_OEM_USB_DBG_REQ = 0x3C, NETFN_OEM_USB_DBG_RES = 0x3D, }; // OEM Command Codes for USB basded Debug Card enum oem_usb_dbg_cmds { CMD_OEM_USB_DBG_GET_FRAME_INFO = 0x1, CMD_OEM_USB_DBG_GET_UPDATED_FRAMES = 0x2, CMD_OEM_USB_DBG_GET_POST_DESC = 0x3, CMD_OEM_USB_DBG_GET_GPIO_DESC = 0x4, CMD_OEM_USB_DBG_GET_FRAME_DATA = 0x5, CMD_OEM_USB_DBG_CTRL_PANEL = 0x6, }; // OEM Command Codes for FB 1S/2S servers enum fb_oem_cmds { CMD_OEM_ADD_RAS_SEL = 0x10, CMD_OEM_ADD_IMC_LOG = 0x11, CMD_OEM_SET_MAC_ADDR = 0x18, CMD_OEM_GET_MAC_ADDR = 0x19, CMD_OEM_SET_PROC_INFO = 0x1A, CMD_OEM_GET_PROC_INFO = 0x1B, CMD_OEM_SET_DIMM_INFO = 0x1C, CMD_OEM_GET_DIMM_INFO = 0x1D, CMD_OEM_BYPASS_CMD = 0x34, CMD_OEM_GET_BOARD_ID = 0x37, CMD_OEM_GET_80PORT_RECORD = 0x49, CMD_OEM_SET_BOOT_ORDER = 0x52, CMD_OEM_GET_BOOT_ORDER = 0x53, CMD_OEM_GET_HTTPS_BOOT_DATA = 0x57, CMD_OEM_GET_HTTPS_BOOT_ATTR = 0x58, CMD_OEM_SET_MACHINE_CONFIG_INFO = 0x6A, CMD_OEM_LEGACY_SET_PPR = 0x6E, CMD_OEM_LEGACY_GET_PPR = 0x6F, CMD_OEM_SET_POST_START = 0x73, CMD_OEM_SET_POST_END = 0x74, CMD_OEM_SET_PPIN_INFO = 0x77, CMD_OEM_SET_ADR_TRIGGER = 0x7A, CMD_OEM_GET_PLAT_INFO = 0x7E, CMD_OEM_SET_SYSTEM_GUID = 0xEF, CMD_OEM_GET_FW_INFO = 0xF2, CMD_OEM_SLED_AC_CYCLE = 0xF3, CMD_OEM_GET_PCIE_CONFIG = 0xF4, CMD_OEM_SET_IMC_VERSION = 0xF5, CMD_OEM_SET_FW_UPDATE_STATE = 0xF6, CMD_OEM_GET_BIOS_FLASH_INFO = 0x55, CMD_OEM_GET_PCIE_PORT_CONFIG = 0x80, CMD_OEM_SET_PCIE_PORT_CONFIG = 0x81, CMD_OEM_GET_TPM_PRESENCE = 0x82, CMD_OEM_SET_TPM_PRESENCE = 0x83, CMD_OEM_SET_BIOS_FLASH_INFO = 0x87, CMD_OEM_SET_PPR = 0x90, CMD_OEM_GET_PPR = 0x91, CMD_OEM_SET_IPMB_OFFONLINE = 0xE6, CMD_OEM_RISER_SENSOR_MON_CRL = 0xE7, CMD_OEM_BBV_POWER_CYCLE = 0xE9, CMD_OEM_CRASHDUMP = 0x70, }; // OEM Command Codes for QC enum fb_oem_qc_cmds { CMD_OEM_Q_SET_PROC_INFO = 0x10, CMD_OEM_Q_GET_PROC_INFO = 0x11, CMD_OEM_Q_SET_DIMM_INFO = 0x12, CMD_OEM_Q_GET_DIMM_INFO = 0x13, CMD_OEM_Q_SET_DRIVE_INFO = 0x14, CMD_OEM_Q_GET_DRIVE_INFO = 0x15, }; /* To handle the processor product * name (ASCII code). */ #define MAX_BUF 50 #define BMC_POS 0 #define SIZE_CPU_PPIN 8 #define SIZE_BOOT_ORDER 6 #define BOOT_MODE_UEFI 0x01 #define BOOT_MODE_CMOS_CLR 0x02 #define BOOT_MODE_FORCE_BOOT 0x04 #define BOOT_MODE_BOOT_FLAG 0x80 #define BIT_0 0x01 #define BIT_1 0x02 #define BIT_2 0x04 #define BIT_3 0x08 #define KEY_PROC_NAME "product_name" #define KEY_BASIC_INFO "basic_info" #define DIMM_TYPE "type" #define DIMM_SPEED "speed" #define JSON_DIMM_TYPE_FILE "/usr/share/lcd-debug/dimm_type.json" #define JSON_OEM_DATA_FILE "/etc/oemData.json" #define KEY_PPIN_INFO "mb_cpu_ppin" #define KEY_MC_CONFIG "mb_machine_config" #define KEY_MC_CHAS_TYPE "chassis_type" #define KEY_MC_MB_TYPE "mb_type" #define KEY_MC_PROC_CNT "processor_count" #define KEY_MC_MEM_CNT "memory_count" #define KEY_MC_HDD35_CNT "hdd35_count" #define KEY_MC_HDD25_CNT "hdd25_count" #define KEY_MC_RSR_TYPE "riser_type" #define KEY_MC_PCIE_LOC "pcie_card_loc" #define KEY_MC_SLOT1_TYPE "slot1_pcie_type" #define KEY_MC_SLOT2_TYPE "slot2_pcie_type" #define KEY_MC_SLOT3_TYPE "slot3_pcie_type" #define KEY_MC_SLOT4_TYPE "slot4_pcie_type" #define KEY_MC_AEP_CNT "aep_mem_count" #define KEY_TS_SLED "timestamp_sled" #define KEY_BOOT_ORDER "server_boot_order" #define KEY_BOOT_MODE "boot_mode" #define KEY_BOOT_SEQ "boot_sequence" #define KEY_SYS_CONFIG "sys_config" #define KEY_DIMM_INDEX "dimm_index" #define KEY_DIMM_TYPE "dimm_type" #define KEY_DIMM_SPEED "dimm_speed" #define KEY_DIMM_SIZE "dimm_size" #define KEY_PPR "ppr" #define KEY_PPR_ACTION "ppr_row_action" #define KEY_PPR_ROW_COUNT "ppr_row_count" #define KEY_PPR_INDEX "ppr_index" #define KEY_PPR_ROW_ADDR "ppr_row_addr" #define KEY_PPR_HST_DATA "ppr_history_data" #define CC_PARAM_NOT_SUPP_IN_CURR_STATE 0xD5 #define PPR_ROW_ADDR_LEN 8 #define PPR_HST_DATA_LEN 17 #define BOOT_SEQ_ARRAY_SIZE 10 const char* bootSeqDefine[] = {"USB_DEV", "NET_IPV4", "SATA_HDD", "SATA_CD", "OTHER", "", "", "", "", "NET_IPV6"}; /* Byte 2-6– Boot sequence Bit 2:0 – boot device id 000b: USB device 001b: Network 010b: SATA HDD 011b: SATA-CDROM 100b: Other removable Device Bit 7:3 – reserve for boot device special request If Bit 2:0 is 001b (Network), Bit3 is IPv4/IPv6 order Bit3=0b: IPv4 first Bit3=1b: IPv6 first */ std::map bootMap = { {"USB_DEV", 0}, {"NET_IPV4", 1}, {"NET_IPV6", 9}, {"SATA_HDD", 2}, {"SATA_CD", 3}, {"OTHER", 4}}; std::map dimmVenMap = { {0xce, "Samsung"}, {0xad, "Hynix"}, {0x2c, "Micron"}}; const char* chassisType[] = {"ORV1", "ORV2"}; const char* mbType[] = {"SS", "DS", "TYPE3"}; const char* riserType[] = {"NO_CARD", "2_SLOT", "3_SLOT"}; const char* pcieType[] = {"ABSENT", "AVA1", "AVA2", "AVA3", "AVA4", "Re-timer", "HBA", "OTHER"}; enum fb_ppr_sel { PPR_ACTION = 1, PPR_ROW_COUNT, PPR_ROW_ADDR, PPR_HISTORY_DATA, }; typedef struct { uint8_t chassis_type; // 00 - ORv1, 01 - ORv2 (FBTP) uint8_t mb_type; // 00 - SS, 01 - DS, 02 - Type3 uint8_t proc_cnt; uint8_t mem_cnt; uint8_t hdd35_cnt; // 0/1 in FBTP, ff - unknown uint8_t hdd25_cnt; // 0 for FBTP uint8_t riser_type; // 00 - not installed, 01 - 2 slot, 02 - 3 slot uint8_t pcie_card_loc; // Bit0 - Slot1 Present/Absent, Bit1 - Slot 2 // Present/Absent etc. uint8_t slot1_pcie_type; // Always NIC for FBTP uint8_t slot2_pcie_type; // 2-4: 00 - Absent, 01 - AVA 2 x m.2, 02 - AVA // 3x m.2, uint8_t slot3_pcie_type; // 03 - AVA 4 x m.2, 04 - Re-timer, 05 - HBA uint8_t slot4_pcie_type; // 06 - Other flash cards (Intel, HGST), // 80 - Unknown uint8_t aep_mem_cnt; } machineConfigInfo_t; /* FB OEM QC commands data structures */ #define NETFUN_FB_OEM_QC 0x36 #define KEY_Q_PROC_INFO "q_proc_info" #define KEY_PROC_INDEX "proc_index" #define KEY_Q_DIMM_INFO "q_dimm_info" #define KEY_DIMM_INDEX "dimm_index" #define KEY_Q_DRIVE_INFO "q_drive_info" #define KEY_HDD_CTRL_TYPE "hdd_ctrl_type" #define KEY_HDD_INDEX "hdd_index" typedef struct { uint8_t mfrId[3]; uint8_t procIndex; uint8_t paramSel; uint8_t data[]; } qProcInfo_t; typedef struct { uint8_t mfrId[3]; uint8_t dimmIndex; uint8_t paramSel; uint8_t data[]; } qDimmInfo_t; typedef struct { uint8_t mfrId[3]; uint8_t hddCtrlType; uint8_t hddIndex; uint8_t paramSel; uint8_t data[]; } qDriveInfo_t; enum class HttpsBootAttr : uint8_t { certSize = 0x00, certCrc = 0x01 }; enum class BankType : uint8_t { mca = 0x01, virt = 0x02, cpuWdt = 0x03, tcdx = 0x06, cake = 0x07, pie0 = 0x08, iom = 0x09, ccix = 0x0a, cs = 0x0b, pcieAer = 0x0c, wdtReg = 0x0d, ctrl = 0x80, crdHdr = 0x81 }; enum class CrdState { free = 0x01, waitData = 0x02, packing = 0x03 }; enum class CrdCtrl { getState = 0x01, finish = 0x02 }; constexpr uint8_t ccmNum = 8; constexpr uint8_t tcdxNum = 12; constexpr uint8_t cakeNum = 6; constexpr uint8_t pie0Num = 1; constexpr uint8_t iomNum = 4; constexpr uint8_t ccixNum = 4; constexpr uint8_t csNum = 8; #pragma pack(push, 1) struct HttpsDataReq { uint16_t offset; uint8_t length; }; struct CrdCmdHdr { uint8_t version; uint8_t reserved[3]; }; struct CrdBankHdr { BankType bankType; uint8_t version; union { struct { uint8_t bankId; uint8_t coreId; }; uint8_t reserved[2]; }; }; struct CrashDumpHdr { CrdCmdHdr cmdHdr; CrdBankHdr bankHdr; }; // Type 0x01: MCA Bank struct CrdMcaBank { uint64_t mcaCtrl; uint64_t mcaSts; uint64_t mcaAddr; uint64_t mcaMisc0; uint64_t mcaCtrlMask; uint64_t mcaConfig; uint64_t mcaIpid; uint64_t mcaSynd; uint64_t mcaDestat; uint64_t mcaDeaddr; uint64_t mcaMisc1; }; struct BankCorePair { uint8_t bankId; uint8_t coreId; }; // Type 0x02: Virtual/Global Bank struct CrdVirtualBankV2 { uint32_t s5ResetSts; uint32_t breakevent; uint16_t mcaCount; uint16_t procNum; uint32_t apicId; uint32_t eax; uint32_t ebx; uint32_t ecx; uint32_t edx; struct BankCorePair mcaList[]; }; struct CrdVirtualBankV3 { uint32_t s5ResetSts; uint32_t breakevent; uint32_t rstSts; uint16_t mcaCount; uint16_t procNum; uint32_t apicId; uint32_t eax; uint32_t ebx; uint32_t ecx; uint32_t edx; struct BankCorePair mcaList[]; }; // Type 0x03: CPU/Data Fabric Watchdog Timer Bank struct CrdCpuWdtBank { uint32_t hwAssertStsHi[ccmNum]; uint32_t hwAssertStsLo[ccmNum]; uint32_t origWdtAddrLogHi[ccmNum]; uint32_t origWdtAddrLogLo[ccmNum]; uint32_t hwAssertMskHi[ccmNum]; uint32_t hwAssertMskLo[ccmNum]; uint32_t origWdtAddrLogStat[ccmNum]; }; template struct CrdHwAssertBank { uint32_t hwAssertStsHi[N]; uint32_t hwAssertStsLo[N]; uint32_t hwAssertMskHi[N]; uint32_t hwAssertMskLo[N]; }; // Type 0x0C: PCIe AER Bank struct CrdPcieAerBank { uint8_t bus; uint8_t dev; uint8_t fun; uint16_t cmd; uint16_t sts; uint16_t slot; uint8_t secondBus; uint16_t vendorId; uint16_t devId; uint16_t classCodeLo; // Class Code 3 byte uint8_t classCodeHi; uint16_t secondSts; uint16_t ctrl; uint32_t uncorrErrSts; uint32_t uncorrErrMsk; uint32_t uncorrErrSeverity; uint32_t corrErrSts; uint32_t corrErrMsk; uint32_t hdrLogDw0; uint32_t hdrLogDw1; uint32_t hdrLogDw2; uint32_t hdrLogDw3; uint32_t rootErrSts; uint16_t corrErrSrcId; uint16_t errSrcId; uint32_t laneErrSts; }; // Type 0x0D: SMU/PSP/PTDMA Watchdog Timers Register Bank struct CrdWdtRegBank { uint8_t nbio; char name[32]; uint32_t addr; uint8_t count; uint32_t data[]; }; // Type 0x81: Crashdump Header struct CrdHdrBank { uint64_t ppin; uint32_t ucodeVer; uint32_t pmio; }; #pragma pack(pop) const char* cpuInfoKey[] = {"", "product_name", "basic_info", "type", "micro_code", "turbo_mode"}; const char* dimmInfoKey[] = { "", "location", "type", "speed", "part_name", "serial_num", "manufacturer_id", "status", "present_bit"}; const char* driveInfoKey[] = {"location", "serial_num", "model_name", "fw_version", "capacity", "quantity", "type", "wwn"}; const char* ctrlTypeKey[] = {"bios", "expander", "lsi"};