/* SPDX-License-Identifier: GPL-2.0-only * * Copyright (C) 2020-2021 Intel Corporation. */ #ifndef _IOSM_IPC_DEVLINK_H_ #define _IOSM_IPC_DEVLINK_H_ #include <net/devlink.h> #include "iosm_ipc_imem.h" #include "iosm_ipc_imem_ops.h" #include "iosm_ipc_pcie.h" /* Image ext max len */ #define IOSM_DEVLINK_MAX_IMG_LEN … /* Magic Header */ #define IOSM_DEVLINK_MAGIC_HEADER … /* Magic Header len */ #define IOSM_DEVLINK_MAGIC_HEADER_LEN … /* Devlink image type */ #define IOSM_DEVLINK_IMG_TYPE … /* Reserve header size */ #define IOSM_DEVLINK_RESERVED … /* Devlink Image Header size */ #define IOSM_DEVLINK_HDR_SIZE … /* MAX file name length */ #define IOSM_MAX_FILENAME_LEN … /* EBL response size */ #define IOSM_EBL_RSP_SIZE … /* MAX number of regions supported */ #define IOSM_NOF_CD_REGION … /* MAX number of SNAPSHOTS supported */ #define MAX_SNAPSHOTS … /* Default Coredump file size */ #define REPORT_JSON_SIZE … #define COREDUMP_FCD_SIZE … #define CDD_LOG_SIZE … #define EEPROM_BIN_SIZE … #define BOOTCORE_TRC_BIN_SIZE … #define BOOTCORE_PREV_TRC_BIN_SIZE … /** * enum iosm_devlink_param_id - Enum type to different devlink params * @IOSM_DEVLINK_PARAM_ID_BASE: Devlink param base ID * @IOSM_DEVLINK_PARAM_ID_ERASE_FULL_FLASH: Set if full erase required */ enum iosm_devlink_param_id { … }; /** * enum iosm_rpsi_cmd_code - Enum type for RPSI command list * @rpsi_cmd_code_ebl: Command to load ebl * @rpsi_cmd_coredump_start: Command to get list of files and * file size info from PSI * @rpsi_cmd_coredump_get: Command to get the coredump data * @rpsi_cmd_coredump_end: Command to stop receiving the coredump */ enum iosm_rpsi_cmd_code { … }; /** * enum iosm_flash_comp_type - Enum for different flash component types * @FLASH_COMP_TYPE_PSI: PSI flash comp type * @FLASH_COMP_TYPE_EBL: EBL flash comp type * @FLASH_COMP_TYPE_FLS: FLS flash comp type * @FLASH_COMP_TYPE_INVAL: Invalid flash comp type */ enum iosm_flash_comp_type { … }; /** * struct iosm_devlink_sio - SIO instance * @rx_list: Downlink skbuf list received from CP * @read_sem: Needed for the blocking read or downlink transfer * @channel_id: Reserved channel id for flashing/CD collection to RAM * @channel: Channel instance for flashing and coredump * @devlink_read_pend: Check if read is pending */ struct iosm_devlink_sio { … }; /** * struct iosm_flash_params - List of flash params required for flashing * @erase_full_flash: To set the flashing mode * erase_full_flash = 1; full erase * erase_full_flash = 0; no erase * @erase_full_flash_done: Flag to check if it is a full erase */ struct iosm_flash_params { … }; /** * struct iosm_devlink_image - Structure with Fls file header info * @magic_header: Header of the firmware image * @image_type: Firmware image type * @region_address: Address of the region to be flashed * @download_region: Field to identify if it is a region * @last_region: Field to identify if it is last region * @reserved: Reserved field */ struct iosm_devlink_image { … } __packed; /** * struct iosm_ebl_ctx_data - EBL ctx data used during flashing * @ebl_sw_info_version: SWID version info obtained from EBL * @m_ebl_resp: Buffer used to read and write the ebl data */ struct iosm_ebl_ctx_data { … }; /** * struct iosm_coredump_file_info - Coredump file info * @filename: Name of coredump file * @default_size: Default size of coredump file * @actual_size: Actual size of coredump file * @entry: Index of the coredump file */ struct iosm_coredump_file_info { … }; /** * struct iosm_devlink - IOSM Devlink structure * @devlink_sio: SIO instance for read/write functionality * @pcie: Pointer to PCIe component * @dev: Pointer to device struct * @devlink_ctx: Pointer to devlink context * @param: Params required for flashing * @ebl_ctx: Data to be read and written to Modem * @cd_file_info: coredump file info * @iosm_devlink_mdm_coredump: region ops for coredump collection * @cd_regions: coredump regions */ struct iosm_devlink { … }; /** * union iosm_rpsi_param_u - RPSI cmd param for CRC calculation * @word: Words member used in CRC calculation * @dword: Actual data */ iosm_rpsi_param_u; /** * struct iosm_rpsi_cmd - Structure for RPSI Command * @param: Used to calculate CRC * @cmd: Stores the RPSI command * @crc: Stores the CRC value */ struct iosm_rpsi_cmd { … }; struct iosm_devlink *ipc_devlink_init(struct iosm_imem *ipc_imem); void ipc_devlink_deinit(struct iosm_devlink *ipc_devlink); int ipc_devlink_send_cmd(struct iosm_devlink *ipc_devlink, u16 cmd, u32 entry); #endif /* _IOSM_IPC_DEVLINK_H */