Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0
0002  *
0003  * Copyright 2020-2022 HabanaLabs, Ltd.
0004  * All Rights Reserved.
0005  *
0006  */
0007 
0008 #ifndef CPUCP_IF_H
0009 #define CPUCP_IF_H
0010 
0011 #include <linux/types.h>
0012 #include <linux/if_ether.h>
0013 
0014 #include "hl_boot_if.h"
0015 
0016 #define NUM_HBM_PSEUDO_CH               2
0017 #define NUM_HBM_CH_PER_DEV              8
0018 #define CPUCP_PKT_HBM_ECC_INFO_WR_PAR_SHIFT     0
0019 #define CPUCP_PKT_HBM_ECC_INFO_WR_PAR_MASK      0x00000001
0020 #define CPUCP_PKT_HBM_ECC_INFO_RD_PAR_SHIFT     1
0021 #define CPUCP_PKT_HBM_ECC_INFO_RD_PAR_MASK      0x00000002
0022 #define CPUCP_PKT_HBM_ECC_INFO_CA_PAR_SHIFT     2
0023 #define CPUCP_PKT_HBM_ECC_INFO_CA_PAR_MASK      0x00000004
0024 #define CPUCP_PKT_HBM_ECC_INFO_DERR_SHIFT       3
0025 #define CPUCP_PKT_HBM_ECC_INFO_DERR_MASK        0x00000008
0026 #define CPUCP_PKT_HBM_ECC_INFO_SERR_SHIFT       4
0027 #define CPUCP_PKT_HBM_ECC_INFO_SERR_MASK        0x00000010
0028 #define CPUCP_PKT_HBM_ECC_INFO_TYPE_SHIFT       5
0029 #define CPUCP_PKT_HBM_ECC_INFO_TYPE_MASK        0x00000020
0030 #define CPUCP_PKT_HBM_ECC_INFO_HBM_CH_SHIFT     6
0031 #define CPUCP_PKT_HBM_ECC_INFO_HBM_CH_MASK      0x000007C0
0032 
0033 #define PLL_MAP_MAX_BITS    128
0034 #define PLL_MAP_LEN     (PLL_MAP_MAX_BITS / 8)
0035 
0036 /*
0037  * info of the pkt queue pointers in the first async occurrence
0038  */
0039 struct cpucp_pkt_sync_err {
0040     __le32 pi;
0041     __le32 ci;
0042 };
0043 
0044 struct hl_eq_hbm_ecc_data {
0045     /* SERR counter */
0046     __le32 sec_cnt;
0047     /* DERR counter */
0048     __le32 dec_cnt;
0049     /* Supplemental Information according to the mask bits */
0050     __le32 hbm_ecc_info;
0051     /* Address in hbm where the ecc happened */
0052     __le32 first_addr;
0053     /* SERR continuous address counter */
0054     __le32 sec_cont_cnt;
0055     __le32 pad;
0056 };
0057 
0058 /*
0059  * EVENT QUEUE
0060  */
0061 
0062 struct hl_eq_header {
0063     __le32 reserved;
0064     __le32 ctl;
0065 };
0066 
0067 struct hl_eq_ecc_data {
0068     __le64 ecc_address;
0069     __le64 ecc_syndrom;
0070     __u8 memory_wrapper_idx;
0071     __u8 is_critical;
0072     __u8 pad[6];
0073 };
0074 
0075 enum hl_sm_sei_cause {
0076     SM_SEI_SO_OVERFLOW,
0077     SM_SEI_LBW_4B_UNALIGNED,
0078     SM_SEI_AXI_RESPONSE_ERR
0079 };
0080 
0081 struct hl_eq_sm_sei_data {
0082     __le32 sei_log;
0083     /* enum hl_sm_sei_cause */
0084     __u8 sei_cause;
0085     __u8 pad[3];
0086 };
0087 
0088 enum hl_fw_alive_severity {
0089     FW_ALIVE_SEVERITY_MINOR,
0090     FW_ALIVE_SEVERITY_CRITICAL
0091 };
0092 
0093 struct hl_eq_fw_alive {
0094     __le64 uptime_seconds;
0095     __le32 process_id;
0096     __le32 thread_id;
0097     /* enum hl_fw_alive_severity */
0098     __u8 severity;
0099     __u8 pad[7];
0100 };
0101 
0102 struct hl_eq_intr_cause {
0103     __le64 intr_cause_data;
0104 };
0105 
0106 struct hl_eq_pcie_drain_ind_data {
0107     struct hl_eq_intr_cause intr_cause;
0108     __le64 drain_wr_addr_lbw;
0109     __le64 drain_rd_addr_lbw;
0110     __le64 drain_wr_addr_hbw;
0111     __le64 drain_rd_addr_hbw;
0112 };
0113 
0114 struct hl_eq_razwi_lbw_info_regs {
0115     __le32 rr_aw_razwi_reg;
0116     __le32 rr_aw_razwi_id_reg;
0117     __le32 rr_ar_razwi_reg;
0118     __le32 rr_ar_razwi_id_reg;
0119 };
0120 
0121 struct hl_eq_razwi_hbw_info_regs {
0122     __le32 rr_aw_razwi_hi_reg;
0123     __le32 rr_aw_razwi_lo_reg;
0124     __le32 rr_aw_razwi_id_reg;
0125     __le32 rr_ar_razwi_hi_reg;
0126     __le32 rr_ar_razwi_lo_reg;
0127     __le32 rr_ar_razwi_id_reg;
0128 };
0129 
0130 /* razwi_happened masks */
0131 #define RAZWI_HAPPENED_HBW  0x1
0132 #define RAZWI_HAPPENED_LBW  0x2
0133 #define RAZWI_HAPPENED_AW   0x4
0134 #define RAZWI_HAPPENED_AR   0x8
0135 
0136 struct hl_eq_razwi_info {
0137     __le32 razwi_happened_mask;
0138     union {
0139         struct hl_eq_razwi_lbw_info_regs lbw;
0140         struct hl_eq_razwi_hbw_info_regs hbw;
0141     };
0142     __le32 pad;
0143 };
0144 
0145 struct hl_eq_razwi_with_intr_cause {
0146     struct hl_eq_razwi_info razwi_info;
0147     struct hl_eq_intr_cause intr_cause;
0148 };
0149 
0150 #define HBM_CA_ERR_CMD_LIFO_LEN     8
0151 #define HBM_RD_ERR_DATA_LIFO_LEN    8
0152 #define HBM_WR_PAR_CMD_LIFO_LEN     11
0153 
0154 enum hl_hbm_sei_cause {
0155     /* Command/address parity error event is split into 2 events due to
0156      * size limitation: ODD suffix for odd HBM CK_t cycles and EVEN  suffix
0157      * for even HBM CK_t cycles
0158      */
0159     HBM_SEI_CMD_PARITY_EVEN,
0160     HBM_SEI_CMD_PARITY_ODD,
0161     /* Read errors can be reflected as a combination of SERR/DERR/parity
0162      * errors. Therefore, we define one event for all read error types.
0163      * LKD will perform further proccessing.
0164      */
0165     HBM_SEI_READ_ERR,
0166     HBM_SEI_WRITE_DATA_PARITY_ERR,
0167     HBM_SEI_CATTRIP,
0168     HBM_SEI_MEM_BIST_FAIL,
0169     HBM_SEI_DFI,
0170     HBM_SEI_INV_TEMP_READ_OUT,
0171     HBM_SEI_BIST_FAIL,
0172 };
0173 
0174 /* Masks for parsing hl_hbm_sei_headr fields */
0175 #define HBM_ECC_SERR_CNTR_MASK      0xFF
0176 #define HBM_ECC_DERR_CNTR_MASK      0xFF00
0177 #define HBM_RD_PARITY_CNTR_MASK     0xFF0000
0178 
0179 /* HBM index and MC index are known by the event_id */
0180 struct hl_hbm_sei_header {
0181     union {
0182         /* relevant only in case of HBM read error */
0183         struct {
0184             __u8 ecc_serr_cnt;
0185             __u8 ecc_derr_cnt;
0186             __u8 read_par_cnt;
0187             __u8 reserved;
0188         };
0189         /* All other cases */
0190         __le32 cnt;
0191     };
0192     __u8 sei_cause;     /* enum hl_hbm_sei_cause */
0193     __u8 mc_channel;        /* range: 0-3 */
0194     __u8 mc_pseudo_channel; /* range: 0-7 */
0195     __u8 is_critical;
0196 };
0197 
0198 #define HBM_RD_ADDR_SID_SHIFT       0
0199 #define HBM_RD_ADDR_SID_MASK        0x1
0200 #define HBM_RD_ADDR_BG_SHIFT        1
0201 #define HBM_RD_ADDR_BG_MASK     0x6
0202 #define HBM_RD_ADDR_BA_SHIFT        3
0203 #define HBM_RD_ADDR_BA_MASK     0x18
0204 #define HBM_RD_ADDR_COL_SHIFT       5
0205 #define HBM_RD_ADDR_COL_MASK        0x7E0
0206 #define HBM_RD_ADDR_ROW_SHIFT       11
0207 #define HBM_RD_ADDR_ROW_MASK        0x3FFF800
0208 
0209 struct hbm_rd_addr {
0210     union {
0211         /* bit fields are only for FW use */
0212         struct {
0213             u32 dbg_rd_err_addr_sid:1;
0214             u32 dbg_rd_err_addr_bg:2;
0215             u32 dbg_rd_err_addr_ba:2;
0216             u32 dbg_rd_err_addr_col:6;
0217             u32 dbg_rd_err_addr_row:15;
0218             u32 reserved:6;
0219         };
0220         __le32 rd_addr_val;
0221     };
0222 };
0223 
0224 #define HBM_RD_ERR_BEAT_SHIFT       2
0225 /* dbg_rd_err_misc fields: */
0226 /* Read parity is calculated per DW on every beat */
0227 #define HBM_RD_ERR_PAR_ERR_BEAT0_SHIFT  0
0228 #define HBM_RD_ERR_PAR_ERR_BEAT0_MASK   0x3
0229 #define HBM_RD_ERR_PAR_DATA_BEAT0_SHIFT 8
0230 #define HBM_RD_ERR_PAR_DATA_BEAT0_MASK  0x300
0231 /* ECC is calculated per PC on every beat */
0232 #define HBM_RD_ERR_SERR_BEAT0_SHIFT 16
0233 #define HBM_RD_ERR_SERR_BEAT0_MASK  0x10000
0234 #define HBM_RD_ERR_DERR_BEAT0_SHIFT 24
0235 #define HBM_RD_ERR_DERR_BEAT0_MASK  0x100000
0236 
0237 struct hl_eq_hbm_sei_read_err_intr_info {
0238     /* DFI_RD_ERR_REP_ADDR */
0239     struct hbm_rd_addr dbg_rd_err_addr;
0240     /* DFI_RD_ERR_REP_ERR */
0241     union {
0242         struct {
0243             /* bit fields are only for FW use */
0244             u32 dbg_rd_err_par:8;
0245             u32 dbg_rd_err_par_data:8;
0246             u32 dbg_rd_err_serr:4;
0247             u32 dbg_rd_err_derr:4;
0248             u32 reserved:8;
0249         };
0250         __le32 dbg_rd_err_misc;
0251     };
0252     /* DFI_RD_ERR_REP_DM */
0253     __le32 dbg_rd_err_dm;
0254     /* DFI_RD_ERR_REP_SYNDROME */
0255     __le32 dbg_rd_err_syndrome;
0256     /* DFI_RD_ERR_REP_DATA */
0257     __le32 dbg_rd_err_data[HBM_RD_ERR_DATA_LIFO_LEN];
0258 };
0259 
0260 struct hl_eq_hbm_sei_ca_par_intr_info {
0261     /* 14 LSBs */
0262     __le16 dbg_row[HBM_CA_ERR_CMD_LIFO_LEN];
0263     /* 18 LSBs */
0264     __le32 dbg_col[HBM_CA_ERR_CMD_LIFO_LEN];
0265 };
0266 
0267 #define WR_PAR_LAST_CMD_COL_SHIFT   0
0268 #define WR_PAR_LAST_CMD_COL_MASK    0x3F
0269 #define WR_PAR_LAST_CMD_BG_SHIFT    6
0270 #define WR_PAR_LAST_CMD_BG_MASK     0xC0
0271 #define WR_PAR_LAST_CMD_BA_SHIFT    8
0272 #define WR_PAR_LAST_CMD_BA_MASK     0x300
0273 #define WR_PAR_LAST_CMD_SID_SHIFT   10
0274 #define WR_PAR_LAST_CMD_SID_MASK    0x400
0275 
0276 /* Row address isn't latched */
0277 struct hbm_sei_wr_cmd_address {
0278     /* DFI_DERR_LAST_CMD */
0279     union {
0280         struct {
0281             /* bit fields are only for FW use */
0282             u32 col:6;
0283             u32 bg:2;
0284             u32 ba:2;
0285             u32 sid:1;
0286             u32 reserved:21;
0287         };
0288         __le32 dbg_wr_cmd_addr;
0289     };
0290 };
0291 
0292 struct hl_eq_hbm_sei_wr_par_intr_info {
0293     /* entry 0: WR command address from the 1st cycle prior to the error
0294      * entry 1: WR command address from the 2nd cycle prior to the error
0295      * and so on...
0296      */
0297     struct hbm_sei_wr_cmd_address dbg_last_wr_cmds[HBM_WR_PAR_CMD_LIFO_LEN];
0298     /* derr[0:1] - 1st HBM cycle DERR output
0299      * derr[2:3] - 2nd HBM cycle DERR output
0300      */
0301     __u8 dbg_derr;
0302     /* extend to reach 8B */
0303     __u8 pad[3];
0304 };
0305 
0306 /*
0307  * this struct represents the following sei causes:
0308  * command parity, ECC double error, ECC single error, dfi error, cattrip,
0309  * temperature read-out, read parity error and write parity error.
0310  * some only use the header while some have extra data.
0311  */
0312 struct hl_eq_hbm_sei_data {
0313     struct hl_hbm_sei_header hdr;
0314     union {
0315         struct hl_eq_hbm_sei_ca_par_intr_info ca_parity_even_info;
0316         struct hl_eq_hbm_sei_ca_par_intr_info ca_parity_odd_info;
0317         struct hl_eq_hbm_sei_read_err_intr_info read_err_info;
0318         struct hl_eq_hbm_sei_wr_par_intr_info wr_parity_info;
0319     };
0320 };
0321 
0322 /* Engine/farm arc interrupt type */
0323 enum hl_engine_arc_interrupt_type {
0324     /* Qman/farm ARC DCCM QUEUE FULL interrupt type */
0325     ENGINE_ARC_DCCM_QUEUE_FULL_IRQ = 1
0326 };
0327 
0328 /* Data structure specifies details of payload of DCCM QUEUE FULL interrupt */
0329 struct hl_engine_arc_dccm_queue_full_irq {
0330     /* Queue index value which caused DCCM QUEUE FULL */
0331     __le32 queue_index;
0332     __le32 pad;
0333 };
0334 
0335 /* Data structure specifies details of QM/FARM ARC interrupt */
0336 struct hl_eq_engine_arc_intr_data {
0337     /* ARC engine id e.g.  DCORE0_TPC0_QM_ARC, DCORE0_TCP1_QM_ARC */
0338     __le32 engine_id;
0339     __le32 intr_type; /* enum hl_engine_arc_interrupt_type */
0340     /* More info related to the interrupt e.g. queue index
0341      * incase of DCCM_QUEUE_FULL interrupt.
0342      */
0343     __le64 payload;
0344     __le64 pad[5];
0345 };
0346 
0347 struct hl_eq_entry {
0348     struct hl_eq_header hdr;
0349     union {
0350         struct hl_eq_ecc_data ecc_data;
0351         struct hl_eq_hbm_ecc_data hbm_ecc_data; /* Gaudi1 HBM */
0352         struct hl_eq_sm_sei_data sm_sei_data;
0353         struct cpucp_pkt_sync_err pkt_sync_err;
0354         struct hl_eq_fw_alive fw_alive;
0355         struct hl_eq_intr_cause intr_cause;
0356         struct hl_eq_pcie_drain_ind_data pcie_drain_ind_data;
0357         struct hl_eq_razwi_info razwi_info;
0358         struct hl_eq_razwi_with_intr_cause razwi_with_intr_cause;
0359         struct hl_eq_hbm_sei_data sei_data; /* Gaudi2 HBM */
0360         struct hl_eq_engine_arc_intr_data arc_data;
0361         __le64 data[7];
0362     };
0363 };
0364 
0365 #define HL_EQ_ENTRY_SIZE        sizeof(struct hl_eq_entry)
0366 
0367 #define EQ_CTL_READY_SHIFT      31
0368 #define EQ_CTL_READY_MASK       0x80000000
0369 
0370 #define EQ_CTL_EVENT_TYPE_SHIFT     16
0371 #define EQ_CTL_EVENT_TYPE_MASK      0x0FFF0000
0372 
0373 #define EQ_CTL_INDEX_SHIFT      0
0374 #define EQ_CTL_INDEX_MASK       0x0000FFFF
0375 
0376 enum pq_init_status {
0377     PQ_INIT_STATUS_NA = 0,
0378     PQ_INIT_STATUS_READY_FOR_CP,
0379     PQ_INIT_STATUS_READY_FOR_HOST,
0380     PQ_INIT_STATUS_READY_FOR_CP_SINGLE_MSI,
0381     PQ_INIT_STATUS_LEN_NOT_POWER_OF_TWO_ERR,
0382     PQ_INIT_STATUS_ILLEGAL_Q_ADDR_ERR
0383 };
0384 
0385 /*
0386  * CpuCP Primary Queue Packets
0387  *
0388  * During normal operation, the host's kernel driver needs to send various
0389  * messages to CpuCP, usually either to SET some value into a H/W periphery or
0390  * to GET the current value of some H/W periphery. For example, SET the
0391  * frequency of MME/TPC and GET the value of the thermal sensor.
0392  *
0393  * These messages can be initiated either by the User application or by the
0394  * host's driver itself, e.g. power management code. In either case, the
0395  * communication from the host's driver to CpuCP will *always* be in
0396  * synchronous mode, meaning that the host will send a single message and poll
0397  * until the message was acknowledged and the results are ready (if results are
0398  * needed).
0399  *
0400  * This means that only a single message can be sent at a time and the host's
0401  * driver must wait for its result before sending the next message. Having said
0402  * that, because these are control messages which are sent in a relatively low
0403  * frequency, this limitation seems acceptable. It's important to note that
0404  * in case of multiple devices, messages to different devices *can* be sent
0405  * at the same time.
0406  *
0407  * The message, inputs/outputs (if relevant) and fence object will be located
0408  * on the device DDR at an address that will be determined by the host's driver.
0409  * During device initialization phase, the host will pass to CpuCP that address.
0410  * Most of the message types will contain inputs/outputs inside the message
0411  * itself. The common part of each message will contain the opcode of the
0412  * message (its type) and a field representing a fence object.
0413  *
0414  * When the host's driver wishes to send a message to CPU CP, it will write the
0415  * message contents to the device DDR, clear the fence object and then write to
0416  * the PSOC_ARC1_AUX_SW_INTR, to issue interrupt 121 to ARC Management CPU.
0417  *
0418  * Upon receiving the interrupt (#121), CpuCP will read the message from the
0419  * DDR. In case the message is a SET operation, CpuCP will first perform the
0420  * operation and then write to the fence object on the device DDR. In case the
0421  * message is a GET operation, CpuCP will first fill the results section on the
0422  * device DDR and then write to the fence object. If an error occurred, CpuCP
0423  * will fill the rc field with the right error code.
0424  *
0425  * In the meantime, the host's driver will poll on the fence object. Once the
0426  * host sees that the fence object is signaled, it will read the results from
0427  * the device DDR (if relevant) and resume the code execution in the host's
0428  * driver.
0429  *
0430  * To use QMAN packets, the opcode must be the QMAN opcode, shifted by 8
0431  * so the value being put by the host's driver matches the value read by CpuCP
0432  *
0433  * Non-QMAN packets should be limited to values 1 through (2^8 - 1)
0434  *
0435  * Detailed description:
0436  *
0437  * CPUCP_PACKET_DISABLE_PCI_ACCESS -
0438  *       After receiving this packet the embedded CPU must NOT issue PCI
0439  *       transactions (read/write) towards the Host CPU. This also include
0440  *       sending MSI-X interrupts.
0441  *       This packet is usually sent before the device is moved to D3Hot state.
0442  *
0443  * CPUCP_PACKET_ENABLE_PCI_ACCESS -
0444  *       After receiving this packet the embedded CPU is allowed to issue PCI
0445  *       transactions towards the Host CPU, including sending MSI-X interrupts.
0446  *       This packet is usually send after the device is moved to D0 state.
0447  *
0448  * CPUCP_PACKET_TEMPERATURE_GET -
0449  *       Fetch the current temperature / Max / Max Hyst / Critical /
0450  *       Critical Hyst of a specified thermal sensor. The packet's
0451  *       arguments specify the desired sensor and the field to get.
0452  *
0453  * CPUCP_PACKET_VOLTAGE_GET -
0454  *       Fetch the voltage / Max / Min of a specified sensor. The packet's
0455  *       arguments specify the sensor and type.
0456  *
0457  * CPUCP_PACKET_CURRENT_GET -
0458  *       Fetch the current / Max / Min of a specified sensor. The packet's
0459  *       arguments specify the sensor and type.
0460  *
0461  * CPUCP_PACKET_FAN_SPEED_GET -
0462  *       Fetch the speed / Max / Min of a specified fan. The packet's
0463  *       arguments specify the sensor and type.
0464  *
0465  * CPUCP_PACKET_PWM_GET -
0466  *       Fetch the pwm value / mode of a specified pwm. The packet's
0467  *       arguments specify the sensor and type.
0468  *
0469  * CPUCP_PACKET_PWM_SET -
0470  *       Set the pwm value / mode of a specified pwm. The packet's
0471  *       arguments specify the sensor, type and value.
0472  *
0473  * CPUCP_PACKET_FREQUENCY_SET -
0474  *       Set the frequency of a specified PLL. The packet's arguments specify
0475  *       the PLL and the desired frequency. The actual frequency in the device
0476  *       might differ from the requested frequency.
0477  *
0478  * CPUCP_PACKET_FREQUENCY_GET -
0479  *       Fetch the frequency of a specified PLL. The packet's arguments specify
0480  *       the PLL.
0481  *
0482  * CPUCP_PACKET_LED_SET -
0483  *       Set the state of a specified led. The packet's arguments
0484  *       specify the led and the desired state.
0485  *
0486  * CPUCP_PACKET_I2C_WR -
0487  *       Write 32-bit value to I2C device. The packet's arguments specify the
0488  *       I2C bus, address and value.
0489  *
0490  * CPUCP_PACKET_I2C_RD -
0491  *       Read 32-bit value from I2C device. The packet's arguments specify the
0492  *       I2C bus and address.
0493  *
0494  * CPUCP_PACKET_INFO_GET -
0495  *       Fetch information from the device as specified in the packet's
0496  *       structure. The host's driver passes the max size it allows the CpuCP to
0497  *       write to the structure, to prevent data corruption in case of
0498  *       mismatched driver/FW versions.
0499  *
0500  * CPUCP_PACKET_FLASH_PROGRAM_REMOVED - this packet was removed
0501  *
0502  * CPUCP_PACKET_UNMASK_RAZWI_IRQ -
0503  *       Unmask the given IRQ. The IRQ number is specified in the value field.
0504  *       The packet is sent after receiving an interrupt and printing its
0505  *       relevant information.
0506  *
0507  * CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY -
0508  *       Unmask the given IRQs. The IRQs numbers are specified in an array right
0509  *       after the cpucp_packet structure, where its first element is the array
0510  *       length. The packet is sent after a soft reset was done in order to
0511  *       handle any interrupts that were sent during the reset process.
0512  *
0513  * CPUCP_PACKET_TEST -
0514  *       Test packet for CpuCP connectivity. The CPU will put the fence value
0515  *       in the result field.
0516  *
0517  * CPUCP_PACKET_FREQUENCY_CURR_GET -
0518  *       Fetch the current frequency of a specified PLL. The packet's arguments
0519  *       specify the PLL.
0520  *
0521  * CPUCP_PACKET_MAX_POWER_GET -
0522  *       Fetch the maximal power of the device.
0523  *
0524  * CPUCP_PACKET_MAX_POWER_SET -
0525  *       Set the maximal power of the device. The packet's arguments specify
0526  *       the power.
0527  *
0528  * CPUCP_PACKET_EEPROM_DATA_GET -
0529  *       Get EEPROM data from the CpuCP kernel. The buffer is specified in the
0530  *       addr field. The CPU will put the returned data size in the result
0531  *       field. In addition, the host's driver passes the max size it allows the
0532  *       CpuCP to write to the structure, to prevent data corruption in case of
0533  *       mismatched driver/FW versions.
0534  *
0535  * CPUCP_PACKET_NIC_INFO_GET -
0536  *       Fetch information from the device regarding the NIC. the host's driver
0537  *       passes the max size it allows the CpuCP to write to the structure, to
0538  *       prevent data corruption in case of mismatched driver/FW versions.
0539  *
0540  * CPUCP_PACKET_TEMPERATURE_SET -
0541  *       Set the value of the offset property of a specified thermal sensor.
0542  *       The packet's arguments specify the desired sensor and the field to
0543  *       set.
0544  *
0545  * CPUCP_PACKET_VOLTAGE_SET -
0546  *       Trigger the reset_history property of a specified voltage sensor.
0547  *       The packet's arguments specify the desired sensor and the field to
0548  *       set.
0549  *
0550  * CPUCP_PACKET_CURRENT_SET -
0551  *       Trigger the reset_history property of a specified current sensor.
0552  *       The packet's arguments specify the desired sensor and the field to
0553  *       set.
0554  *
0555  * CPUCP_PACKET_PCIE_THROUGHPUT_GET -
0556  *       Get throughput of PCIe.
0557  *       The packet's arguments specify the transaction direction (TX/RX).
0558  *       The window measurement is 10[msec], and the return value is in KB/sec.
0559  *
0560  * CPUCP_PACKET_PCIE_REPLAY_CNT_GET
0561  *       Replay count measures number of "replay" events, which is basicly
0562  *       number of retries done by PCIe.
0563  *
0564  * CPUCP_PACKET_TOTAL_ENERGY_GET -
0565  *       Total Energy is measurement of energy from the time FW Linux
0566  *       is loaded. It is calculated by multiplying the average power
0567  *       by time (passed from armcp start). The units are in MilliJouls.
0568  *
0569  * CPUCP_PACKET_PLL_INFO_GET -
0570  *       Fetch frequencies of PLL from the required PLL IP.
0571  *       The packet's arguments specify the device PLL type
0572  *       Pll type is the PLL from device pll_index enum.
0573  *       The result is composed of 4 outputs, each is 16-bit
0574  *       frequency in MHz.
0575  *
0576  * CPUCP_PACKET_POWER_GET -
0577  *       Fetch the present power consumption of the device (Current * Voltage).
0578  *
0579  * CPUCP_PACKET_NIC_PFC_SET -
0580  *       Enable/Disable the NIC PFC feature. The packet's arguments specify the
0581  *       NIC port, relevant lanes to configure and one bit indication for
0582  *       enable/disable.
0583  *
0584  * CPUCP_PACKET_NIC_FAULT_GET -
0585  *       Fetch the current indication for local/remote faults from the NIC MAC.
0586  *       The result is 32-bit value of the relevant register.
0587  *
0588  * CPUCP_PACKET_NIC_LPBK_SET -
0589  *       Enable/Disable the MAC loopback feature. The packet's arguments specify
0590  *       the NIC port, relevant lanes to configure and one bit indication for
0591  *       enable/disable.
0592  *
0593  * CPUCP_PACKET_NIC_MAC_INIT -
0594  *       Configure the NIC MAC channels. The packet's arguments specify the
0595  *       NIC port and the speed.
0596  *
0597  * CPUCP_PACKET_MSI_INFO_SET -
0598  *       set the index number for each supported msi type going from
0599  *       host to device
0600  *
0601  * CPUCP_PACKET_NIC_XPCS91_REGS_GET -
0602  *       Fetch the un/correctable counters values from the NIC MAC.
0603  *
0604  * CPUCP_PACKET_NIC_STAT_REGS_GET -
0605  *       Fetch various NIC MAC counters from the NIC STAT.
0606  *
0607  * CPUCP_PACKET_NIC_STAT_REGS_CLR -
0608  *       Clear the various NIC MAC counters in the NIC STAT.
0609  *
0610  * CPUCP_PACKET_NIC_STAT_REGS_ALL_GET -
0611  *       Fetch all NIC MAC counters from the NIC STAT.
0612  *
0613  * CPUCP_PACKET_IS_IDLE_CHECK -
0614  *       Check if the device is IDLE in regard to the DMA/compute engines
0615  *       and QMANs. The f/w will return a bitmask where each bit represents
0616  *       a different engine or QMAN according to enum cpucp_idle_mask.
0617  *       The bit will be 1 if the engine is NOT idle.
0618  *
0619  * CPUCP_PACKET_HBM_REPLACED_ROWS_INFO_GET -
0620  *       Fetch all HBM replaced-rows and prending to be replaced rows data.
0621  *
0622  * CPUCP_PACKET_HBM_PENDING_ROWS_STATUS -
0623  *       Fetch status of HBM rows pending replacement and need a reboot to
0624  *       be replaced.
0625  *
0626  * CPUCP_PACKET_POWER_SET -
0627  *       Resets power history of device to 0
0628  *
0629  * CPUCP_PACKET_ENGINE_CORE_ASID_SET -
0630  *       Packet to perform engine core ASID configuration
0631  *
0632  * CPUCP_PACKET_MONITOR_DUMP_GET -
0633  *       Get monitors registers dump from the CpuCP kernel.
0634  *       The CPU will put the registers dump in the a buffer allocated by the driver
0635  *       which address is passed via the CpuCp packet. In addition, the host's driver
0636  *       passes the max size it allows the CpuCP to write to the structure, to prevent
0637  *       data corruption in case of mismatched driver/FW versions.
0638  *       Relevant only to Gaudi.
0639  */
0640 
0641 enum cpucp_packet_id {
0642     CPUCP_PACKET_DISABLE_PCI_ACCESS = 1,    /* internal */
0643     CPUCP_PACKET_ENABLE_PCI_ACCESS,     /* internal */
0644     CPUCP_PACKET_TEMPERATURE_GET,       /* sysfs */
0645     CPUCP_PACKET_VOLTAGE_GET,       /* sysfs */
0646     CPUCP_PACKET_CURRENT_GET,       /* sysfs */
0647     CPUCP_PACKET_FAN_SPEED_GET,     /* sysfs */
0648     CPUCP_PACKET_PWM_GET,           /* sysfs */
0649     CPUCP_PACKET_PWM_SET,           /* sysfs */
0650     CPUCP_PACKET_FREQUENCY_SET,     /* sysfs */
0651     CPUCP_PACKET_FREQUENCY_GET,     /* sysfs */
0652     CPUCP_PACKET_LED_SET,           /* debugfs */
0653     CPUCP_PACKET_I2C_WR,            /* debugfs */
0654     CPUCP_PACKET_I2C_RD,            /* debugfs */
0655     CPUCP_PACKET_INFO_GET,          /* IOCTL */
0656     CPUCP_PACKET_FLASH_PROGRAM_REMOVED,
0657     CPUCP_PACKET_UNMASK_RAZWI_IRQ,      /* internal */
0658     CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY,    /* internal */
0659     CPUCP_PACKET_TEST,          /* internal */
0660     CPUCP_PACKET_FREQUENCY_CURR_GET,    /* sysfs */
0661     CPUCP_PACKET_MAX_POWER_GET,     /* sysfs */
0662     CPUCP_PACKET_MAX_POWER_SET,     /* sysfs */
0663     CPUCP_PACKET_EEPROM_DATA_GET,       /* sysfs */
0664     CPUCP_PACKET_NIC_INFO_GET,      /* internal */
0665     CPUCP_PACKET_TEMPERATURE_SET,       /* sysfs */
0666     CPUCP_PACKET_VOLTAGE_SET,       /* sysfs */
0667     CPUCP_PACKET_CURRENT_SET,       /* sysfs */
0668     CPUCP_PACKET_PCIE_THROUGHPUT_GET,   /* internal */
0669     CPUCP_PACKET_PCIE_REPLAY_CNT_GET,   /* internal */
0670     CPUCP_PACKET_TOTAL_ENERGY_GET,      /* internal */
0671     CPUCP_PACKET_PLL_INFO_GET,      /* internal */
0672     CPUCP_PACKET_NIC_STATUS,        /* internal */
0673     CPUCP_PACKET_POWER_GET,         /* internal */
0674     CPUCP_PACKET_NIC_PFC_SET,       /* internal */
0675     CPUCP_PACKET_NIC_FAULT_GET,     /* internal */
0676     CPUCP_PACKET_NIC_LPBK_SET,      /* internal */
0677     CPUCP_PACKET_NIC_MAC_CFG,       /* internal */
0678     CPUCP_PACKET_MSI_INFO_SET,      /* internal */
0679     CPUCP_PACKET_NIC_XPCS91_REGS_GET,   /* internal */
0680     CPUCP_PACKET_NIC_STAT_REGS_GET,     /* internal */
0681     CPUCP_PACKET_NIC_STAT_REGS_CLR,     /* internal */
0682     CPUCP_PACKET_NIC_STAT_REGS_ALL_GET, /* internal */
0683     CPUCP_PACKET_IS_IDLE_CHECK,     /* internal */
0684     CPUCP_PACKET_HBM_REPLACED_ROWS_INFO_GET,/* internal */
0685     CPUCP_PACKET_HBM_PENDING_ROWS_STATUS,   /* internal */
0686     CPUCP_PACKET_POWER_SET,         /* internal */
0687     CPUCP_PACKET_RESERVED,          /* not used */
0688     CPUCP_PACKET_ENGINE_CORE_ASID_SET,  /* internal */
0689     CPUCP_PACKET_RESERVED2,         /* not used */
0690     CPUCP_PACKET_RESERVED3,         /* not used */
0691     CPUCP_PACKET_RESERVED4,         /* not used */
0692     CPUCP_PACKET_RESERVED5,         /* not used */
0693     CPUCP_PACKET_MONITOR_DUMP_GET,      /* debugfs */
0694 };
0695 
0696 #define CPUCP_PACKET_FENCE_VAL  0xFE8CE7A5
0697 
0698 #define CPUCP_PKT_CTL_RC_SHIFT      12
0699 #define CPUCP_PKT_CTL_RC_MASK       0x0000F000
0700 
0701 #define CPUCP_PKT_CTL_OPCODE_SHIFT  16
0702 #define CPUCP_PKT_CTL_OPCODE_MASK   0x1FFF0000
0703 
0704 #define CPUCP_PKT_RES_PLL_OUT0_SHIFT    0
0705 #define CPUCP_PKT_RES_PLL_OUT0_MASK 0x000000000000FFFFull
0706 #define CPUCP_PKT_RES_PLL_OUT1_SHIFT    16
0707 #define CPUCP_PKT_RES_PLL_OUT1_MASK 0x00000000FFFF0000ull
0708 #define CPUCP_PKT_RES_PLL_OUT2_SHIFT    32
0709 #define CPUCP_PKT_RES_PLL_OUT2_MASK 0x0000FFFF00000000ull
0710 #define CPUCP_PKT_RES_PLL_OUT3_SHIFT    48
0711 #define CPUCP_PKT_RES_PLL_OUT3_MASK 0xFFFF000000000000ull
0712 
0713 #define CPUCP_PKT_VAL_PFC_IN1_SHIFT 0
0714 #define CPUCP_PKT_VAL_PFC_IN1_MASK  0x0000000000000001ull
0715 #define CPUCP_PKT_VAL_PFC_IN2_SHIFT 1
0716 #define CPUCP_PKT_VAL_PFC_IN2_MASK  0x000000000000001Eull
0717 
0718 #define CPUCP_PKT_VAL_LPBK_IN1_SHIFT    0
0719 #define CPUCP_PKT_VAL_LPBK_IN1_MASK 0x0000000000000001ull
0720 #define CPUCP_PKT_VAL_LPBK_IN2_SHIFT    1
0721 #define CPUCP_PKT_VAL_LPBK_IN2_MASK 0x000000000000001Eull
0722 
0723 #define CPUCP_PKT_VAL_MAC_CNT_IN1_SHIFT 0
0724 #define CPUCP_PKT_VAL_MAC_CNT_IN1_MASK  0x0000000000000001ull
0725 #define CPUCP_PKT_VAL_MAC_CNT_IN2_SHIFT 1
0726 #define CPUCP_PKT_VAL_MAC_CNT_IN2_MASK  0x00000000FFFFFFFEull
0727 
0728 /* heartbeat status bits */
0729 #define CPUCP_PKT_HB_STATUS_EQ_FAULT_SHIFT      0
0730 #define CPUCP_PKT_HB_STATUS_EQ_FAULT_MASK       0x00000001
0731 
0732 struct cpucp_packet {
0733     union {
0734         __le64 value;   /* For SET packets */
0735         __le64 result;  /* For GET packets */
0736         __le64 addr;    /* For PQ */
0737     };
0738 
0739     __le32 ctl;
0740 
0741     __le32 fence;       /* Signal to host that message is completed */
0742 
0743     union {
0744         struct {/* For temperature/current/voltage/fan/pwm get/set */
0745             __le16 sensor_index;
0746             __le16 type;
0747         };
0748 
0749         struct {    /* For I2C read/write */
0750             __u8 i2c_bus;
0751             __u8 i2c_addr;
0752             __u8 i2c_reg;
0753             /*
0754              * In legacy implemetations, i2c_len was not present,
0755              * was unused and just added as pad.
0756              * So if i2c_len is 0, it is treated as legacy
0757              * and r/w 1 Byte, else if i2c_len is specified,
0758              * its treated as new multibyte r/w support.
0759              */
0760             __u8 i2c_len;
0761         };
0762 
0763         struct {/* For PLL info fetch */
0764             __le16 pll_type;
0765             /* TODO pll_reg is kept temporary before removal */
0766             __le16 pll_reg;
0767         };
0768 
0769         /* For any general request */
0770         __le32 index;
0771 
0772         /* For frequency get/set */
0773         __le32 pll_index;
0774 
0775         /* For led set */
0776         __le32 led_index;
0777 
0778         /* For get CpuCP info/EEPROM data/NIC info */
0779         __le32 data_max_size;
0780 
0781         /*
0782          * For any general status bitmask. Shall be used whenever the
0783          * result cannot be used to hold general purpose data.
0784          */
0785         __le32 status_mask;
0786     };
0787 
0788     /* For NIC requests */
0789     __le32 port_index;
0790 };
0791 
0792 struct cpucp_unmask_irq_arr_packet {
0793     struct cpucp_packet cpucp_pkt;
0794     __le32 length;
0795     __le32 irqs[];
0796 };
0797 
0798 struct cpucp_nic_status_packet {
0799     struct cpucp_packet cpucp_pkt;
0800     __le32 length;
0801     __le32 data[];
0802 };
0803 
0804 struct cpucp_array_data_packet {
0805     struct cpucp_packet cpucp_pkt;
0806     __le32 length;
0807     __le32 data[];
0808 };
0809 
0810 enum cpucp_led_index {
0811     CPUCP_LED0_INDEX = 0,
0812     CPUCP_LED1_INDEX,
0813     CPUCP_LED2_INDEX
0814 };
0815 
0816 enum cpucp_packet_rc {
0817     cpucp_packet_success,
0818     cpucp_packet_invalid,
0819     cpucp_packet_fault
0820 };
0821 
0822 /*
0823  * cpucp_temp_type should adhere to hwmon_temp_attributes
0824  * defined in Linux kernel hwmon.h file
0825  */
0826 enum cpucp_temp_type {
0827     cpucp_temp_input,
0828     cpucp_temp_min = 4,
0829     cpucp_temp_min_hyst,
0830     cpucp_temp_max = 6,
0831     cpucp_temp_max_hyst,
0832     cpucp_temp_crit,
0833     cpucp_temp_crit_hyst,
0834     cpucp_temp_offset = 19,
0835     cpucp_temp_lowest = 21,
0836     cpucp_temp_highest = 22,
0837     cpucp_temp_reset_history = 23,
0838     cpucp_temp_warn = 24,
0839     cpucp_temp_max_crit = 25,
0840     cpucp_temp_max_warn = 26,
0841 };
0842 
0843 enum cpucp_in_attributes {
0844     cpucp_in_input,
0845     cpucp_in_min,
0846     cpucp_in_max,
0847     cpucp_in_lowest = 6,
0848     cpucp_in_highest = 7,
0849     cpucp_in_reset_history
0850 };
0851 
0852 enum cpucp_curr_attributes {
0853     cpucp_curr_input,
0854     cpucp_curr_min,
0855     cpucp_curr_max,
0856     cpucp_curr_lowest = 6,
0857     cpucp_curr_highest = 7,
0858     cpucp_curr_reset_history
0859 };
0860 
0861 enum cpucp_fan_attributes {
0862     cpucp_fan_input,
0863     cpucp_fan_min = 2,
0864     cpucp_fan_max
0865 };
0866 
0867 enum cpucp_pwm_attributes {
0868     cpucp_pwm_input,
0869     cpucp_pwm_enable
0870 };
0871 
0872 enum cpucp_pcie_throughput_attributes {
0873     cpucp_pcie_throughput_tx,
0874     cpucp_pcie_throughput_rx
0875 };
0876 
0877 /* TODO temporary kept before removal */
0878 enum cpucp_pll_reg_attributes {
0879     cpucp_pll_nr_reg,
0880     cpucp_pll_nf_reg,
0881     cpucp_pll_od_reg,
0882     cpucp_pll_div_factor_reg,
0883     cpucp_pll_div_sel_reg
0884 };
0885 
0886 /* TODO temporary kept before removal */
0887 enum cpucp_pll_type_attributes {
0888     cpucp_pll_cpu,
0889     cpucp_pll_pci,
0890 };
0891 
0892 /*
0893  * cpucp_power_type aligns with hwmon_power_attributes
0894  * defined in Linux kernel hwmon.h file
0895  */
0896 enum cpucp_power_type {
0897     CPUCP_POWER_INPUT = 8,
0898     CPUCP_POWER_INPUT_HIGHEST = 9,
0899     CPUCP_POWER_RESET_INPUT_HISTORY = 11
0900 };
0901 
0902 /*
0903  * MSI type enumeration table for all ASICs and future SW versions.
0904  * For future ASIC-LKD compatibility, we can only add new enumerations.
0905  * at the end of the table (before CPUCP_NUM_OF_MSI_TYPES).
0906  * Changing the order of entries or removing entries is not allowed.
0907  */
0908 enum cpucp_msi_type {
0909     CPUCP_EVENT_QUEUE_MSI_TYPE,
0910     CPUCP_NIC_PORT1_MSI_TYPE,
0911     CPUCP_NIC_PORT3_MSI_TYPE,
0912     CPUCP_NIC_PORT5_MSI_TYPE,
0913     CPUCP_NIC_PORT7_MSI_TYPE,
0914     CPUCP_NIC_PORT9_MSI_TYPE,
0915     CPUCP_NUM_OF_MSI_TYPES
0916 };
0917 
0918 /*
0919  * PLL enumeration table used for all ASICs and future SW versions.
0920  * For future ASIC-LKD compatibility, we can only add new enumerations.
0921  * at the end of the table.
0922  * Changing the order of entries or removing entries is not allowed.
0923  */
0924 enum pll_index {
0925     CPU_PLL = 0,
0926     PCI_PLL = 1,
0927     NIC_PLL = 2,
0928     DMA_PLL = 3,
0929     MESH_PLL = 4,
0930     MME_PLL = 5,
0931     TPC_PLL = 6,
0932     IF_PLL = 7,
0933     SRAM_PLL = 8,
0934     NS_PLL = 9,
0935     HBM_PLL = 10,
0936     MSS_PLL = 11,
0937     DDR_PLL = 12,
0938     VID_PLL = 13,
0939     BANK_PLL = 14,
0940     MMU_PLL = 15,
0941     IC_PLL = 16,
0942     MC_PLL = 17,
0943     EMMC_PLL = 18,
0944     PLL_MAX
0945 };
0946 
0947 enum rl_index {
0948     TPC_RL = 0,
0949     MME_RL,
0950     EDMA_RL,
0951 };
0952 
0953 enum pvt_index {
0954     PVT_SW,
0955     PVT_SE,
0956     PVT_NW,
0957     PVT_NE
0958 };
0959 
0960 /* Event Queue Packets */
0961 
0962 struct eq_generic_event {
0963     __le64 data[7];
0964 };
0965 
0966 /*
0967  * CpuCP info
0968  */
0969 
0970 #define CARD_NAME_MAX_LEN       16
0971 #define CPUCP_MAX_SENSORS       128
0972 #define CPUCP_MAX_NICS          128
0973 #define CPUCP_LANES_PER_NIC     4
0974 #define CPUCP_NIC_QSFP_EEPROM_MAX_LEN   1024
0975 #define CPUCP_MAX_NIC_LANES     (CPUCP_MAX_NICS * CPUCP_LANES_PER_NIC)
0976 #define CPUCP_NIC_MASK_ARR_LEN      ((CPUCP_MAX_NICS + 63) / 64)
0977 #define CPUCP_NIC_POLARITY_ARR_LEN  ((CPUCP_MAX_NIC_LANES + 63) / 64)
0978 #define CPUCP_HBM_ROW_REPLACE_MAX   32
0979 
0980 struct cpucp_sensor {
0981     __le32 type;
0982     __le32 flags;
0983 };
0984 
0985 /**
0986  * struct cpucp_card_types - ASIC card type.
0987  * @cpucp_card_type_pci: PCI card.
0988  * @cpucp_card_type_pmc: PCI Mezzanine Card.
0989  */
0990 enum cpucp_card_types {
0991     cpucp_card_type_pci,
0992     cpucp_card_type_pmc
0993 };
0994 
0995 #define CPUCP_SEC_CONF_ENABLED_SHIFT    0
0996 #define CPUCP_SEC_CONF_ENABLED_MASK 0x00000001
0997 
0998 #define CPUCP_SEC_CONF_FLASH_WP_SHIFT   1
0999 #define CPUCP_SEC_CONF_FLASH_WP_MASK    0x00000002
1000 
1001 #define CPUCP_SEC_CONF_EEPROM_WP_SHIFT  2
1002 #define CPUCP_SEC_CONF_EEPROM_WP_MASK   0x00000004
1003 
1004 /**
1005  * struct cpucp_security_info - Security information.
1006  * @config: configuration bit field
1007  * @keys_num: number of stored keys
1008  * @revoked_keys: revoked keys bit field
1009  * @min_svn: minimal security version
1010  */
1011 struct cpucp_security_info {
1012     __u8 config;
1013     __u8 keys_num;
1014     __u8 revoked_keys;
1015     __u8 min_svn;
1016 };
1017 
1018 /**
1019  * struct cpucp_info - Info from CpuCP that is necessary to the host's driver
1020  * @sensors: available sensors description.
1021  * @kernel_version: CpuCP linux kernel version.
1022  * @reserved: reserved field.
1023  * @card_type: card configuration type.
1024  * @card_location: in a server, each card has different connections topology
1025  *                 depending on its location (relevant for PMC card type)
1026  * @cpld_version: CPLD programmed F/W version.
1027  * @infineon_version: Infineon main DC-DC version.
1028  * @fuse_version: silicon production FUSE information.
1029  * @thermal_version: thermald S/W version.
1030  * @cpucp_version: CpuCP S/W version.
1031  * @infineon_second_stage_version: Infineon 2nd stage DC-DC version.
1032  * @dram_size: available DRAM size.
1033  * @card_name: card name that will be displayed in HWMON subsystem on the host
1034  * @tpc_binning_mask: TPC binning mask, 1 bit per TPC instance
1035  *                    (0 = functional, 1 = binned)
1036  * @decoder_binning_mask: Decoder binning mask, 1 bit per decoder instance
1037  *                        (0 = functional, 1 = binned), maximum 1 per dcore
1038  * @sram_binning: Categorize SRAM functionality
1039  *                (0 = fully functional, 1 = lower-half is not functional,
1040  *                 2 = upper-half is not functional)
1041  * @sec_info: security information
1042  * @pll_map: Bit map of supported PLLs for current ASIC version.
1043  * @mme_binning_mask: MME binning mask,
1044  *                    bits [0:6]   <==> dcore0 mme fma
1045  *                    bits [7:13]  <==> dcore1 mme fma
1046  *                    bits [14:20] <==> dcore0 mme ima
1047  *                    bits [21:27] <==> dcore1 mme ima
1048  *                    For each group, if the 6th bit is set then first 5 bits
1049  *                    represent the col's idx [0-31], otherwise these bits are
1050  *                    ignored, and col idx 32 is binned. 7th bit is don't care.
1051  * @dram_binning_mask: DRAM binning mask, 1 bit per dram instance
1052  *                     (0 = functional 1 = binned)
1053  * @memory_repair_flag: eFuse flag indicating memory repair
1054  * @edma_binning_mask: EDMA binning mask, 1 bit per EDMA instance
1055  *                     (0 = functional 1 = binned)
1056  * @xbar_binning_mask: Xbar binning mask, 1 bit per Xbar instance
1057  *                     (0 = functional 1 = binned)
1058  * @interposer_version: Interposer version programmed in eFuse
1059  * @substrate_version: Substrate version programmed in eFuse
1060  * @fw_os_version: Firmware OS Version
1061  */
1062 struct cpucp_info {
1063     struct cpucp_sensor sensors[CPUCP_MAX_SENSORS];
1064     __u8 kernel_version[VERSION_MAX_LEN];
1065     __le32 reserved;
1066     __le32 card_type;
1067     __le32 card_location;
1068     __le32 cpld_version;
1069     __le32 infineon_version;
1070     __u8 fuse_version[VERSION_MAX_LEN];
1071     __u8 thermal_version[VERSION_MAX_LEN];
1072     __u8 cpucp_version[VERSION_MAX_LEN];
1073     __le32 infineon_second_stage_version;
1074     __le64 dram_size;
1075     char card_name[CARD_NAME_MAX_LEN];
1076     __le64 tpc_binning_mask;
1077     __le64 decoder_binning_mask;
1078     __u8 sram_binning;
1079     __u8 dram_binning_mask;
1080     __u8 memory_repair_flag;
1081     __u8 edma_binning_mask;
1082     __u8 xbar_binning_mask;
1083     __u8 interposer_version;
1084     __u8 substrate_version;
1085     __u8 reserved2;
1086     struct cpucp_security_info sec_info;
1087     __le32 reserved3;
1088     __u8 pll_map[PLL_MAP_LEN];
1089     __le64 mme_binning_mask;
1090     __u8 fw_os_version[VERSION_MAX_LEN];
1091 };
1092 
1093 struct cpucp_mac_addr {
1094     __u8 mac_addr[ETH_ALEN];
1095 };
1096 
1097 enum cpucp_serdes_type {
1098     TYPE_1_SERDES_TYPE,
1099     TYPE_2_SERDES_TYPE,
1100     HLS1_SERDES_TYPE,
1101     HLS1H_SERDES_TYPE,
1102     HLS2_SERDES_TYPE,
1103     UNKNOWN_SERDES_TYPE,
1104     MAX_NUM_SERDES_TYPE = UNKNOWN_SERDES_TYPE
1105 };
1106 
1107 struct cpucp_nic_info {
1108     struct cpucp_mac_addr mac_addrs[CPUCP_MAX_NICS];
1109     __le64 link_mask[CPUCP_NIC_MASK_ARR_LEN];
1110     __le64 pol_tx_mask[CPUCP_NIC_POLARITY_ARR_LEN];
1111     __le64 pol_rx_mask[CPUCP_NIC_POLARITY_ARR_LEN];
1112     __le64 link_ext_mask[CPUCP_NIC_MASK_ARR_LEN];
1113     __u8 qsfp_eeprom[CPUCP_NIC_QSFP_EEPROM_MAX_LEN];
1114     __le64 auto_neg_mask[CPUCP_NIC_MASK_ARR_LEN];
1115     __le16 serdes_type; /* enum cpucp_serdes_type */
1116     __le16 tx_swap_map[CPUCP_MAX_NICS];
1117     __u8 reserved[6];
1118 };
1119 
1120 #define PAGE_DISCARD_MAX    64
1121 
1122 struct page_discard_info {
1123     __u8 num_entries;
1124     __u8 reserved[7];
1125     __le32 mmu_page_idx[PAGE_DISCARD_MAX];
1126 };
1127 
1128 /*
1129  * struct ser_val - the SER (symbol error rate) value is represented by "integer * 10 ^ -exp".
1130  * @integer: the integer part of the SER value;
1131  * @exp: the exponent part of the SER value.
1132  */
1133 struct ser_val {
1134     __le16 integer;
1135     __le16 exp;
1136 };
1137 
1138 /*
1139  * struct cpucp_nic_status - describes the status of a NIC port.
1140  * @port: NIC port index.
1141  * @bad_format_cnt: e.g. CRC.
1142  * @responder_out_of_sequence_psn_cnt: e.g NAK.
1143  * @high_ber_reinit_cnt: link reinit due to high BER.
1144  * @correctable_err_cnt: e.g. bit-flip.
1145  * @uncorrectable_err_cnt: e.g. MAC errors.
1146  * @retraining_cnt: re-training counter.
1147  * @up: is port up.
1148  * @pcs_link: has PCS link.
1149  * @phy_ready: is PHY ready.
1150  * @auto_neg: is Autoneg enabled.
1151  * @timeout_retransmission_cnt: timeout retransmission events
1152  * @high_ber_cnt: high ber events
1153  */
1154 struct cpucp_nic_status {
1155     __le32 port;
1156     __le32 bad_format_cnt;
1157     __le32 responder_out_of_sequence_psn_cnt;
1158     __le32 high_ber_reinit;
1159     __le32 correctable_err_cnt;
1160     __le32 uncorrectable_err_cnt;
1161     __le32 retraining_cnt;
1162     __u8 up;
1163     __u8 pcs_link;
1164     __u8 phy_ready;
1165     __u8 auto_neg;
1166     __le32 timeout_retransmission_cnt;
1167     __le32 high_ber_cnt;
1168 };
1169 
1170 enum cpucp_hbm_row_replace_cause {
1171     REPLACE_CAUSE_DOUBLE_ECC_ERR,
1172     REPLACE_CAUSE_MULTI_SINGLE_ECC_ERR,
1173 };
1174 
1175 struct cpucp_hbm_row_info {
1176     __u8 hbm_idx;
1177     __u8 pc;
1178     __u8 sid;
1179     __u8 bank_idx;
1180     __le16 row_addr;
1181     __u8 replaced_row_cause; /* enum cpucp_hbm_row_replace_cause */
1182     __u8 pad;
1183 };
1184 
1185 struct cpucp_hbm_row_replaced_rows_info {
1186     __le16 num_replaced_rows;
1187     __u8 pad[6];
1188     struct cpucp_hbm_row_info replaced_rows[CPUCP_HBM_ROW_REPLACE_MAX];
1189 };
1190 
1191 enum cpu_reset_status {
1192     CPU_RST_STATUS_NA = 0,
1193     CPU_RST_STATUS_SOFT_RST_DONE = 1,
1194 };
1195 
1196 /*
1197  * struct dcore_monitor_regs_data - DCORE monitor regs data.
1198  * the structure follows sync manager block layout. relevant only to Gaudi.
1199  * @mon_pay_addrl: array of payload address low bits.
1200  * @mon_pay_addrh: array of payload address high bits.
1201  * @mon_pay_data: array of payload data.
1202  * @mon_arm: array of monitor arm.
1203  * @mon_status: array of monitor status.
1204  */
1205 struct dcore_monitor_regs_data {
1206     __le32 mon_pay_addrl[512];
1207     __le32 mon_pay_addrh[512];
1208     __le32 mon_pay_data[512];
1209     __le32 mon_arm[512];
1210     __le32 mon_status[512];
1211 };
1212 
1213 /* contains SM data for each SYNC_MNGR (relevant only to Gaudi) */
1214 struct cpucp_monitor_dump {
1215     struct dcore_monitor_regs_data sync_mngr_w_s;
1216     struct dcore_monitor_regs_data sync_mngr_e_s;
1217     struct dcore_monitor_regs_data sync_mngr_w_n;
1218     struct dcore_monitor_regs_data sync_mngr_e_n;
1219 };
1220 
1221 #endif /* CPUCP_IF_H */