Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only
0002  *
0003  * Copyright (C) 2020-2021 Intel Corporation.
0004  */
0005 
0006 #ifndef _IOSM_IPC_DEVLINK_H_
0007 #define _IOSM_IPC_DEVLINK_H_
0008 
0009 #include <net/devlink.h>
0010 
0011 #include "iosm_ipc_imem.h"
0012 #include "iosm_ipc_imem_ops.h"
0013 #include "iosm_ipc_pcie.h"
0014 
0015 /* Image ext max len */
0016 #define IOSM_DEVLINK_MAX_IMG_LEN 3
0017 /* Magic Header */
0018 #define IOSM_DEVLINK_MAGIC_HEADER "IOSM_DEVLINK_HEADER"
0019 /* Magic Header len */
0020 #define IOSM_DEVLINK_MAGIC_HEADER_LEN 20
0021 /* Devlink image type */
0022 #define IOSM_DEVLINK_IMG_TYPE 4
0023 /* Reserve header size */
0024 #define IOSM_DEVLINK_RESERVED 34
0025 /* Devlink Image Header size */
0026 #define IOSM_DEVLINK_HDR_SIZE sizeof(struct iosm_devlink_image)
0027 /* MAX file name length */
0028 #define IOSM_MAX_FILENAME_LEN 32
0029 /* EBL response size */
0030 #define IOSM_EBL_RSP_SIZE 76
0031 /* MAX number of regions supported */
0032 #define IOSM_NOF_CD_REGION 6
0033 /* MAX number of SNAPSHOTS supported */
0034 #define MAX_SNAPSHOTS 1
0035 /* Default Coredump file size */
0036 #define REPORT_JSON_SIZE 0x800
0037 #define COREDUMP_FCD_SIZE 0x10E00000
0038 #define CDD_LOG_SIZE 0x30000
0039 #define EEPROM_BIN_SIZE 0x10000
0040 #define BOOTCORE_TRC_BIN_SIZE 0x8000
0041 #define BOOTCORE_PREV_TRC_BIN_SIZE 0x20000
0042 
0043 /**
0044  * enum iosm_devlink_param_id - Enum type to different devlink params
0045  * @IOSM_DEVLINK_PARAM_ID_BASE:         Devlink param base ID
0046  * @IOSM_DEVLINK_PARAM_ID_ERASE_FULL_FLASH:     Set if full erase required
0047  */
0048 
0049 enum iosm_devlink_param_id {
0050     IOSM_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
0051     IOSM_DEVLINK_PARAM_ID_ERASE_FULL_FLASH,
0052 };
0053 
0054 /**
0055  * enum iosm_rpsi_cmd_code - Enum type for RPSI command list
0056  * @rpsi_cmd_code_ebl:      Command to load ebl
0057  * @rpsi_cmd_coredump_start:    Command to get list of files and
0058  *              file size info from PSI
0059  * @rpsi_cmd_coredump_get:      Command to get the coredump data
0060  * @rpsi_cmd_coredump_end:      Command to stop receiving the coredump
0061  */
0062 enum iosm_rpsi_cmd_code {
0063     rpsi_cmd_code_ebl = 0x02,
0064     rpsi_cmd_coredump_start = 0x10,
0065     rpsi_cmd_coredump_get   = 0x11,
0066     rpsi_cmd_coredump_end   = 0x12,
0067 };
0068 
0069 /**
0070  * enum iosm_flash_comp_type - Enum for different flash component types
0071  * @FLASH_COMP_TYPE_PSI:    PSI flash comp type
0072  * @FLASH_COMP_TYPE_EBL:    EBL flash comp type
0073  * @FLASH_COMP_TYPE_FLS:    FLS flash comp type
0074  * @FLASH_COMP_TYPE_INVAL:  Invalid flash comp type
0075  */
0076 enum iosm_flash_comp_type {
0077     FLASH_COMP_TYPE_PSI,
0078     FLASH_COMP_TYPE_EBL,
0079     FLASH_COMP_TYPE_FLS,
0080     FLASH_COMP_TYPE_INVAL,
0081 };
0082 
0083 /**
0084  * struct iosm_devlink_sio - SIO instance
0085  * @rx_list:    Downlink skbuf list received from CP
0086  * @read_sem:   Needed for the blocking read or downlink transfer
0087  * @channel_id: Reserved channel id for flashing/CD collection to RAM
0088  * @channel:    Channel instance for flashing and coredump
0089  * @devlink_read_pend: Check if read is pending
0090  */
0091 struct iosm_devlink_sio {
0092     struct sk_buff_head rx_list;
0093     struct completion read_sem;
0094     int channel_id;
0095     struct ipc_mem_channel *channel;
0096     u32 devlink_read_pend;
0097 };
0098 
0099 /**
0100  * struct iosm_flash_params - List of flash params required for flashing
0101  * @erase_full_flash:   To set the flashing mode
0102  *                      erase_full_flash = 1; full erase
0103  *                      erase_full_flash = 0; no erase
0104  * @erase_full_flash_done: Flag to check if it is a full erase
0105  */
0106 struct iosm_flash_params {
0107     u8 erase_full_flash;
0108     u8 erase_full_flash_done;
0109 };
0110 
0111 /**
0112  * struct iosm_devlink_image - Structure with Fls file header info
0113  * @magic_header:   Header of the firmware image
0114  * @image_type:     Firmware image type
0115  * @region_address: Address of the region to be flashed
0116  * @download_region:    Field to identify if it is a region
0117  * @last_region:    Field to identify if it is last region
0118  * @reserved:       Reserved field
0119  */
0120 struct iosm_devlink_image {
0121     char magic_header[IOSM_DEVLINK_MAGIC_HEADER_LEN];
0122     char image_type[IOSM_DEVLINK_IMG_TYPE];
0123     __le32 region_address;
0124     u8 download_region;
0125     u8 last_region;
0126     u8 reserved[IOSM_DEVLINK_RESERVED];
0127 } __packed;
0128 
0129 /**
0130  * struct iosm_ebl_ctx_data -  EBL ctx data used during flashing
0131  * @ebl_sw_info_version: SWID version info obtained from EBL
0132  * @m_ebl_resp:         Buffer used to read and write the ebl data
0133  */
0134 struct iosm_ebl_ctx_data {
0135     u8 ebl_sw_info_version;
0136     u8 m_ebl_resp[IOSM_EBL_RSP_SIZE];
0137 };
0138 
0139 /**
0140  * struct iosm_coredump_file_info -  Coredump file info
0141  * @filename:       Name of coredump file
0142  * @default_size:   Default size of coredump file
0143  * @actual_size:    Actual size of coredump file
0144  * @entry:      Index of the coredump file
0145  */
0146 struct iosm_coredump_file_info {
0147     char filename[IOSM_MAX_FILENAME_LEN];
0148     u32 default_size;
0149     u32 actual_size;
0150     u32 entry;
0151 };
0152 
0153 /**
0154  * struct iosm_devlink - IOSM Devlink structure
0155  * @devlink_sio:        SIO instance for read/write functionality
0156  * @pcie:               Pointer to PCIe component
0157  * @dev:                Pointer to device struct
0158  * @devlink_ctx:    Pointer to devlink context
0159  * @param:      Params required for flashing
0160  * @ebl_ctx:        Data to be read and written to Modem
0161  * @cd_file_info:   coredump file info
0162  * @iosm_devlink_mdm_coredump:  region ops for coredump collection
0163  * @cd_regions:     coredump regions
0164  */
0165 struct iosm_devlink {
0166     struct iosm_devlink_sio devlink_sio;
0167     struct iosm_pcie *pcie;
0168     struct device *dev;
0169     struct devlink *devlink_ctx;
0170     struct iosm_flash_params param;
0171     struct iosm_ebl_ctx_data ebl_ctx;
0172     struct iosm_coredump_file_info *cd_file_info;
0173     struct devlink_region_ops iosm_devlink_mdm_coredump[IOSM_NOF_CD_REGION];
0174     struct devlink_region *cd_regions[IOSM_NOF_CD_REGION];
0175 };
0176 
0177 /**
0178  * union iosm_rpsi_param_u - RPSI cmd param for CRC calculation
0179  * @word:   Words member used in CRC calculation
0180  * @dword:  Actual data
0181  */
0182 union iosm_rpsi_param_u {
0183     __le16 word[2];
0184     __le32 dword;
0185 };
0186 
0187 /**
0188  * struct iosm_rpsi_cmd - Structure for RPSI Command
0189  * @param:      Used to calculate CRC
0190  * @cmd:        Stores the RPSI command
0191  * @crc:        Stores the CRC value
0192  */
0193 struct iosm_rpsi_cmd {
0194     union iosm_rpsi_param_u param;
0195     __le16  cmd;
0196     __le16  crc;
0197 };
0198 
0199 struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem);
0200 
0201 void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink);
0202 
0203 int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry);
0204 
0205 #endif /* _IOSM_IPC_DEVLINK_H */