0001
0002
0003
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
0016 #define IOSM_DEVLINK_MAX_IMG_LEN 3
0017
0018 #define IOSM_DEVLINK_MAGIC_HEADER "IOSM_DEVLINK_HEADER"
0019
0020 #define IOSM_DEVLINK_MAGIC_HEADER_LEN 20
0021
0022 #define IOSM_DEVLINK_IMG_TYPE 4
0023
0024 #define IOSM_DEVLINK_RESERVED 34
0025
0026 #define IOSM_DEVLINK_HDR_SIZE sizeof(struct iosm_devlink_image)
0027
0028 #define IOSM_MAX_FILENAME_LEN 32
0029
0030 #define IOSM_EBL_RSP_SIZE 76
0031
0032 #define IOSM_NOF_CD_REGION 6
0033
0034 #define MAX_SNAPSHOTS 1
0035
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
0045
0046
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
0056
0057
0058
0059
0060
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
0071
0072
0073
0074
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
0085
0086
0087
0088
0089
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
0101
0102
0103
0104
0105
0106 struct iosm_flash_params {
0107 u8 erase_full_flash;
0108 u8 erase_full_flash_done;
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
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
0131
0132
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
0141
0142
0143
0144
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
0155
0156
0157
0158
0159
0160
0161
0162
0163
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
0179
0180
0181
0182 union iosm_rpsi_param_u {
0183 __le16 word[2];
0184 __le32 dword;
0185 };
0186
0187
0188
0189
0190
0191
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