linux/net/ethtool/cmis_cdb.c

// SPDX-License-Identifier: GPL-2.0-only

#include <linux/ethtool.h>
#include <linux/jiffies.h>

#include "common.h"
#include "module_fw.h"
#include "cmis.h"

/* For accessing the LPL field on page 9Fh, the allowable length extension is
 * min(i, 15) byte octets where i specifies the allowable additional number of
 * byte octets in a READ or a WRITE.
 */
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_page_init(struct ethtool_module_eeprom *page_data,
			    u8 page, u32 offset, u32 length)
{}

#define CMIS_REVISION_PAGE
#define CMIS_REVISION_OFFSET

struct cmis_rev_rpl {};

static u8 cmis_rev_rpl_major(struct cmis_rev_rpl *rpl)
{}

static int cmis_rev_major_get(struct net_device *dev, u8 *rev_major)
{}

#define CMIS_CDB_ADVERTISEMENT_PAGE
#define CMIS_CDB_ADVERTISEMENT_OFFSET

/* Based on section 8.4.11 "CDB Messaging Support Advertisement" in CMIS
 * standard revision 5.2.
 */
struct cmis_cdb_advert_rpl {};

static u8 cmis_cdb_advert_rpl_inst_supported(struct cmis_cdb_advert_rpl *rpl)
{}

static int cmis_cdb_advertisement_get(struct ethtool_cmis_cdb *cdb,
				      struct net_device *dev)
{}

#define CMIS_PASSWORD_ENTRY_PAGE
#define CMIS_PASSWORD_ENTRY_OFFSET

struct cmis_password_entry_pl {};

/* See section 9.3.1 "CMD 0000h: Query Status" in CMIS standard revision 5.2.
 * struct cmis_cdb_query_status_pl and struct cmis_cdb_query_status_rpl are
 * structured layouts of the flat arrays,
 * struct ethtool_cmis_cdb_request::payload and
 * struct ethtool_cmis_cdb_rpl::payload respectively.
 */
struct cmis_cdb_query_status_pl {};

struct cmis_cdb_query_status_rpl {};

static int
cmis_cdb_validate_password(struct ethtool_cmis_cdb *cdb,
			   struct net_device *dev,
			   const struct ethtool_module_fw_flash_params *params,
			   struct ethnl_module_fw_flash_ntf_params *ntf_params)
{}

/* Some CDB commands asserts the CDB completion flag only from CMIS
 * revision 5. Therefore, check the relevant validity flag only when
 * the revision supports it.
 */
void ethtool_cmis_cdb_check_completion_flag(u8 cmis_rev, u8 *flags)
{}

#define CMIS_CDB_MODULE_FEATURES_RESV_DATA

/* See section 9.4.1 "CMD 0040h: Module Features" in CMIS standard revision 5.2.
 * struct cmis_cdb_module_features_rpl is structured layout of the flat
 * array, ethtool_cmis_cdb_rpl::payload.
 */
struct cmis_cdb_module_features_rpl {};

static u16
cmis_cdb_module_features_completion_time(struct cmis_cdb_module_features_rpl *rpl)
{}

static int cmis_cdb_module_features_get(struct ethtool_cmis_cdb *cdb,
					struct net_device *dev,
					struct ethnl_module_fw_flash_ntf_params *ntf_params)
{}

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)
{}

static bool is_completed(u8 data)
{}

#define CMIS_CDB_STATUS_SUCCESS

static bool status_success(u8 data)
{}

#define CMIS_CDB_STATUS_FAIL

static bool status_fail(u8 data)
{}

struct cmis_wait_for_cond_rpl {};

static int
ethtool_cmis_module_poll(struct net_device *dev,
			 struct cmis_wait_for_cond_rpl *rpl, u32 offset,
			 bool (*cond_success)(u8), bool (*cond_fail)(u8))
{}

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)
{}

#define CMIS_CDB_COMPLETION_FLAG_OFFSET

static int cmis_cdb_wait_for_completion(struct net_device *dev,
					struct ethtool_cmis_cdb_cmd_args *args)
{}

#define CMIS_CDB_STATUS_OFFSET

static void cmis_cdb_status_fail_msg_get(u8 status, char **err_msg)
{
	switch (status) {
	case 0b10000001:
		*err_msg = "CDB Status is in progress: Busy capturing command";
		break;
	case 0b10000010:
		*err_msg =
			"CDB Status is in progress: Busy checking/validating command";
		break;
	case 0b10000011:
		*err_msg = "CDB Status is in progress: Busy executing";
		break;
	case 0b01000000:
		*err_msg = "CDB status failed: no specific failure";
		break;
	case 0b01000010:
		*err_msg =
			"CDB status failed: Parameter range error or parameter not supported";
		break;
	case 0b01000101:
		*err_msg = "CDB status failed: CdbChkCode error";
		break;
	default:
		*err_msg = "Unknown failure reason";
	}
};

static int cmis_cdb_wait_for_status(struct net_device *dev,
				    struct ethtool_cmis_cdb_cmd_args *args)
{}

#define CMIS_CDB_REPLY_OFFSET

static int cmis_cdb_process_reply(struct net_device *dev,
				  struct ethtool_module_eeprom *page_data,
				  struct ethtool_cmis_cdb_cmd_args *args)
{}

static int
__ethtool_cmis_cdb_execute_cmd(struct net_device *dev,
			       struct ethtool_module_eeprom *page_data,
			       u8 page, u32 offset, u32 length, void *data)
{}

static u8 cmis_cdb_calc_checksum(const void *data, size_t size)
{}

#define CMIS_CDB_CMD_ID_OFFSET

int ethtool_cmis_cdb_execute_cmd(struct net_device *dev,
				 struct ethtool_cmis_cdb_cmd_args *args)
{}