/* SPDX-License-Identifier: GPL-2.0-only */ #define ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH … #define ETHTOOL_CMIS_CDB_CMD_PAGE … #define ETHTOOL_CMIS_CDB_PAGE_I2C_ADDR … /** * struct ethtool_cmis_cdb - CDB commands parameters * @cmis_rev: CMIS revision major. * @read_write_len_ext: Allowable additional number of byte octets to the LPL * in a READ or a WRITE CDB commands. * @max_completion_time: Maximum CDB command completion time in msec. */ struct ethtool_cmis_cdb { … }; enum ethtool_cmis_cdb_cmd_id { … }; /** * struct ethtool_cmis_cdb_request - CDB commands request fields as decribed in * the CMIS standard * @id: Command ID. * @epl_len: EPL memory length. * @lpl_len: LPL memory length. * @chk_code: Check code for the previous field and the payload. * @resv1: Added to match the CMIS standard request continuity. * @resv2: Added to match the CMIS standard request continuity. * @payload: Payload for the CDB commands. */ struct ethtool_cmis_cdb_request { … }; #define CDB_F_COMPLETION_VALID … #define CDB_F_STATUS_VALID … #define CDB_F_MODULE_STATE_VALID … /** * struct ethtool_cmis_cdb_cmd_args - CDB commands execution arguments * @req: CDB command fields as described in the CMIS standard. * @max_duration: Maximum duration time for command completion in msec. * @read_write_len_ext: Allowable additional number of byte octets to the LPL * in a READ or a WRITE commands. * @msleep_pre_rpl: Waiting time before checking reply in msec. * @rpl_exp_len: Expected reply length in bytes. * @flags: Validation flags for CDB commands. * @err_msg: Error message to be sent to user space. */ struct ethtool_cmis_cdb_cmd_args { … }; /** * struct ethtool_cmis_cdb_rpl_hdr - CDB commands reply header arguments * @rpl_len: Reply length. * @rpl_chk_code: Reply check code. */ struct ethtool_cmis_cdb_rpl_hdr { … }; /** * struct ethtool_cmis_cdb_rpl - CDB commands reply arguments * @hdr: CDB commands reply header arguments. * @payload: Payload for the CDB commands reply. */ struct ethtool_cmis_cdb_rpl { … }; u32 ethtool_cmis_get_max_payload_size(u8 num_of_byte_octs); void ethtool_cmis_cdb_compose_args(struct ethtool_cmis_cdb_cmd_args *args, enum ethtool_cmis_cdb_cmd_id cmd, u8 *pl, u8 lpl_len, u16 max_duration, u8 read_write_len_ext, u16 msleep_pre_rpl, u8 rpl_exp_len, u8 flags); void ethtool_cmis_cdb_check_completion_flag(u8 cmis_rev, u8 *flags); void ethtool_cmis_page_init(struct ethtool_module_eeprom *page_data, u8 page, u32 offset, u32 length); void ethtool_cmis_page_fini(struct ethtool_module_eeprom *page_data); struct ethtool_cmis_cdb * ethtool_cmis_cdb_init(struct net_device *dev, const struct ethtool_module_fw_flash_params *params, struct ethnl_module_fw_flash_ntf_params *ntf_params); void ethtool_cmis_cdb_fini(struct ethtool_cmis_cdb *cdb); int ethtool_cmis_wait_for_cond(struct net_device *dev, u8 flags, u8 flag, u16 max_duration, u32 offset, bool (*cond_success)(u8), bool (*cond_fail)(u8), u8 *state); int ethtool_cmis_cdb_execute_cmd(struct net_device *dev, struct ethtool_cmis_cdb_cmd_args *args);