Skip to content

Commit

Permalink
net: ethtool: Add new parameters and a function to support EPL
Browse files Browse the repository at this point in the history
In the CMIS specification for pluggable modules, LPL (Local Payload) and
EPL (Extended Payload) are two types of data payloads used for managing
various functions and features of the module.

EPL payloads are used for more complex and extensive management
functions that require a larger amount of data, so writing firmware
blocks using EPL is much more efficient.

Currently, only LPL payload is supported for writing firmware blocks to
the module.

Add EPL related parameters to the function ethtool_cmis_cdb_compose_args()
and add a specific function for calculating the maximum allowable length
extension for EPL. Both will be used in the next patch to add support for
writing firmware blocks using EPL.

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Danielle Ratson authored and David S. Miller committed Oct 13, 2024
1 parent eae38f0 commit edc3445
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
12 changes: 7 additions & 5 deletions net/ethtool/cmis.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ struct ethtool_cmis_cdb_rpl {
u8 payload[ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH];
};

u32 ethtool_cmis_get_max_payload_size(u8 num_of_byte_octs);
u32 ethtool_cmis_get_max_lpl_size(u8 num_of_byte_octs);
u32 ethtool_cmis_get_max_epl_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);
enum ethtool_cmis_cdb_cmd_id cmd, u8 *lpl,
u8 lpl_len, u8 *epl, u16 epl_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);

Expand Down
32 changes: 21 additions & 11 deletions net/ethtool/cmis_cdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@
* 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)
u32 ethtool_cmis_get_max_lpl_size(u8 num_of_byte_octs)
{
return 8 * (1 + min_t(u8, num_of_byte_octs, 15));
}

/* For accessing the EPL field on page 9Fh, the allowable length extension is
* min(i, 255) byte octets where i specifies the allowable additional number of
* byte octets in a READ or a WRITE.
*/
u32 ethtool_cmis_get_max_epl_size(u8 num_of_byte_octs)
{
return 8 * (1 + min_t(u8, num_of_byte_octs, 255));
}

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)
enum ethtool_cmis_cdb_cmd_id cmd, u8 *lpl,
u8 lpl_len, u8 *epl, u16 epl_len,
u16 max_duration, u8 read_write_len_ext,
u16 msleep_pre_rpl, u8 rpl_exp_len, u8 flags)
{
args->req.id = cpu_to_be16(cmd);
args->req.lpl_len = lpl_len;
if (pl)
memcpy(args->req.payload, pl, args->req.lpl_len);
if (lpl)
memcpy(args->req.payload, lpl, args->req.lpl_len);

args->max_duration = max_duration;
args->read_write_len_ext =
ethtool_cmis_get_max_payload_size(read_write_len_ext);
ethtool_cmis_get_max_lpl_size(read_write_len_ext);
args->msleep_pre_rpl = msleep_pre_rpl;
args->rpl_exp_len = rpl_exp_len;
args->flags = flags;
Expand Down Expand Up @@ -183,7 +192,7 @@ cmis_cdb_validate_password(struct ethtool_cmis_cdb *cdb,
}

ethtool_cmis_cdb_compose_args(&args, ETHTOOL_CMIS_CDB_CMD_QUERY_STATUS,
(u8 *)&qs_pl, sizeof(qs_pl), 0,
(u8 *)&qs_pl, sizeof(qs_pl), NULL, 0, 0,
cdb->read_write_len_ext, 1000,
sizeof(*rpl),
CDB_F_COMPLETION_VALID | CDB_F_STATUS_VALID);
Expand Down Expand Up @@ -245,8 +254,9 @@ static int cmis_cdb_module_features_get(struct ethtool_cmis_cdb *cdb,
ethtool_cmis_cdb_check_completion_flag(cdb->cmis_rev, &flags);
ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_MODULE_FEATURES,
NULL, 0, 0, cdb->read_write_len_ext,
1000, sizeof(*rpl), flags);
NULL, 0, NULL, 0, 0,
cdb->read_write_len_ext, 1000,
sizeof(*rpl), flags);

err = ethtool_cmis_cdb_execute_cmd(dev, &args);
if (err < 0) {
Expand Down
17 changes: 10 additions & 7 deletions net/ethtool/cmis_fw_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ cmis_fw_update_fw_mng_features_get(struct ethtool_cmis_cdb *cdb,
ethtool_cmis_cdb_check_completion_flag(cdb->cmis_rev, &flags);
ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_FW_MANAGMENT_FEATURES,
NULL, 0, cdb->max_completion_time,
NULL, 0, NULL, 0,
cdb->max_completion_time,
cdb->read_write_len_ext, 1000,
sizeof(*rpl), flags);

Expand Down Expand Up @@ -122,7 +123,7 @@ cmis_fw_update_start_download(struct ethtool_cmis_cdb *cdb,

ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_START_FW_DOWNLOAD,
(u8 *)&pl, lpl_len,
(u8 *)&pl, lpl_len, NULL, 0,
fw_mng->max_duration_start,
cdb->read_write_len_ext, 1000, 0,
CDB_F_COMPLETION_VALID | CDB_F_STATUS_VALID);
Expand Down Expand Up @@ -158,7 +159,7 @@ cmis_fw_update_write_image(struct ethtool_cmis_cdb *cdb,
int err;

max_lpl_len = min_t(u32,
ethtool_cmis_get_max_payload_size(cdb->read_write_len_ext),
ethtool_cmis_get_max_lpl_size(cdb->read_write_len_ext),
ETHTOOL_CMIS_CDB_LPL_MAX_PL_LENGTH);
max_block_size =
max_lpl_len - sizeof_field(struct cmis_cdb_write_fw_block_lpl_pl,
Expand All @@ -183,7 +184,7 @@ cmis_fw_update_write_image(struct ethtool_cmis_cdb *cdb,

ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_WRITE_FW_BLOCK_LPL,
(u8 *)&pl, lpl_len,
(u8 *)&pl, lpl_len, NULL, 0,
fw_mng->max_duration_write,
cdb->read_write_len_ext, 1, 0,
CDB_F_COMPLETION_VALID | CDB_F_STATUS_VALID);
Expand Down Expand Up @@ -212,7 +213,8 @@ cmis_fw_update_complete_download(struct ethtool_cmis_cdb *cdb,

ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_COMPLETE_FW_DOWNLOAD,
NULL, 0, fw_mng->max_duration_complete,
NULL, 0, NULL, 0,
fw_mng->max_duration_complete,
cdb->read_write_len_ext, 1000, 0,
CDB_F_COMPLETION_VALID | CDB_F_STATUS_VALID);

Expand Down Expand Up @@ -294,7 +296,7 @@ cmis_fw_update_run_image(struct ethtool_cmis_cdb *cdb, struct net_device *dev,
int err;

ethtool_cmis_cdb_compose_args(&args, ETHTOOL_CMIS_CDB_CMD_RUN_FW_IMAGE,
(u8 *)&pl, sizeof(pl),
(u8 *)&pl, sizeof(pl), NULL, 0,
cdb->max_completion_time,
cdb->read_write_len_ext, 1000, 0,
CDB_F_MODULE_STATE_VALID);
Expand Down Expand Up @@ -326,7 +328,8 @@ cmis_fw_update_commit_image(struct ethtool_cmis_cdb *cdb,

ethtool_cmis_cdb_compose_args(&args,
ETHTOOL_CMIS_CDB_CMD_COMMIT_FW_IMAGE,
NULL, 0, cdb->max_completion_time,
NULL, 0, NULL, 0,
cdb->max_completion_time,
cdb->read_write_len_ext, 1000, 0,
CDB_F_COMPLETION_VALID | CDB_F_STATUS_VALID);

Expand Down

0 comments on commit edc3445

Please sign in to comment.