Skip to content

Commit

Permalink
ice: Add txbalancing devlink param
Browse files Browse the repository at this point in the history
It was observed that Tx performance was inconsistent across all queues
and/or VSIs and that it was directly connected to existing 9-layer
topology of the Tx scheduler.

Introduce new private devlink param - txbalance. This paramerer gives user
flexibility to choose the 5-layer transmit scheduler topology which helps
to smooth out the transmit performance.

Allowed parameter values are true for enabled and false for disabled.

Example usage:

Show:
devlink dev param show pci/0000:4b:00.0 name txbalancing
pci/0000:4b:00.0:
  name txbalancing type driver-specific
    values:
      cmode permanent value true

Set:
devlink dev param set pci/0000:4b:00.0 name txbalancing value true cmode
permanent

Signed-off-by: Lukasz Czapnik <lukasz.czapnik@intel.com>
Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
  • Loading branch information
lczapnik authored and intel-lab-lkp committed Jul 20, 2022
1 parent def2064 commit 15b804e
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 5 deletions.
9 changes: 9 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,15 @@ struct ice_aqc_nvm {
};

#define ICE_AQC_NVM_START_POINT 0
#define ICE_AQC_NVM_TX_TOPO_MOD_ID 0x14B

struct ice_aqc_nvm_tx_topo_user_sel {
__le16 length;
u8 data;
#define ICE_AQC_NVM_TX_TOPO_USER_SEL BIT(4)

u8 reserved;
};

/* NVM Checksum Command (direct, 0x0706) */
struct ice_aqc_nvm_checksum {
Expand Down
159 changes: 159 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_devlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,158 @@ static int ice_devlink_info_get(struct devlink *devlink,
return err;
}

enum ice_devlink_param_id {
ICE_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX,
ICE_DEVLINK_PARAM_ID_TX_BALANCE,
};

/**
* ice_get_tx_topo_user_sel - Read user's choice from flash
* @pf: pointer to pf structure
* @txbalance_ena: value read from flash will be saved here
*
* Reads user's preference for Tx Scheduler Topology Tree from PFA TLV.
*
* Returns zero when read was successful, negative values otherwise.
*/
int ice_get_tx_topo_user_sel(struct ice_pf *pf, bool *txbalance_ena)
{
struct ice_aqc_nvm_tx_topo_user_sel usr_sel = {};
struct ice_hw *hw = &pf->hw;
int status;

status = ice_acquire_nvm(hw, ICE_RES_READ);
if (status)
return status;

status = ice_aq_read_nvm(hw, ICE_AQC_NVM_TX_TOPO_MOD_ID, 0,
sizeof(usr_sel), &usr_sel, true, true, NULL);
ice_release_nvm(hw);

*txbalance_ena = usr_sel.data & ICE_AQC_NVM_TX_TOPO_USER_SEL;

return status;
}

/**
* ice_update_tx_topo_user_sel - Save user's preference in flash
* @pf: pointer to pf structure
* @txbalance_ena: value to be saved in flash
*
* When txbalance_ena is set to true it means user's preference is to use
* five layer Tx Scheduler Topology Tree, when it is set to false then it is
* nine layer. This choice should be stored in PFA TLV field and should be
* picked up by driver, next time during init.
*
* Returns zero when save was successful, negative values otherwise.
*/
int
ice_update_tx_topo_user_sel(struct ice_pf *pf, bool txbalance_ena)
{
struct ice_aqc_nvm_tx_topo_user_sel usr_sel = {};
struct ice_hw *hw = &pf->hw;
int status;

status = ice_acquire_nvm(hw, ICE_RES_WRITE);
if (status)
return status;

status = ice_aq_read_nvm(hw, ICE_AQC_NVM_TX_TOPO_MOD_ID, 0,
sizeof(usr_sel), &usr_sel, true, true, NULL);
if (status)
goto exit_release_res;

if (txbalance_ena)
usr_sel.data |= ICE_AQC_NVM_TX_TOPO_USER_SEL;
else
usr_sel.data &= ~ICE_AQC_NVM_TX_TOPO_USER_SEL;

status = ice_write_one_nvm_block(pf, ICE_AQC_NVM_TX_TOPO_MOD_ID, 2,
sizeof(usr_sel.data), &usr_sel.data,
true, NULL, NULL);

exit_release_res:
ice_release_nvm(hw);

return status;
}

/**
* ice_devlink_txbalance_get - Get txbalance parameter
* @devlink: pointer to the devlink instance
* @id: the parameter ID to set
* @ctx: context to store the parameter value
*
* Returns zero on success and negative value on failure.
*/
static int ice_devlink_txbalance_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
struct ice_pf *pf = devlink_priv(devlink);
struct device *dev = ice_pf_to_dev(pf);
int status;

status = ice_get_tx_topo_user_sel(pf, &ctx->val.vbool);
if (status) {
dev_warn(dev, "Failed to read Tx Scheduler Tree - User Selection data from flash\n");
return -EIO;
}

return 0;
}

/**
* ice_devlink_txbalance_set - Set txbalance parameter
* @devlink: pointer to the devlink instance
* @id: the parameter ID to set
* @ctx: context to get the parameter value
*
* Returns zero on success and negative value on failure.
*/
static int ice_devlink_txbalance_set(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
{
struct ice_pf *pf = devlink_priv(devlink);
struct device *dev = ice_pf_to_dev(pf);
int status;

status = ice_update_tx_topo_user_sel(pf, ctx->val.vbool);
if (status)
return -EIO;

dev_warn(dev, "Transmit balancing setting has been changed on this device. You must reboot the system for the change to take effect");

return 0;
}

/**
* ice_devlink_txbalance_validate - Validate passed txbalance parameter value
* @devlink: unused pointer to devlink instance
* @id: the parameter ID to validate
* @val: value to validate
* @extack: netlink extended ACK structure
*
* Supported values are:
* true - five layer, false - nine layer Tx Scheduler Topology Tree
*
* Returns zero when passed parameter value is supported. Negative value on
* error.
*/
static int ice_devlink_txbalance_validate(struct devlink *devlink, u32 id,
union devlink_param_value val,
struct netlink_ext_ack *extack)
{
struct ice_pf *pf = devlink_priv(devlink);
struct ice_hw *hw = &pf->hw;

if (!hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) {
NL_SET_ERR_MSG_MOD(extack, "Error: Requested feature is not supported by the FW on this device. Update the FW and run this command again.");
return -EOPNOTSUPP;
}

return 0;
}

/**
* ice_devlink_reload_empr_start - Start EMP reset to activate new firmware
* @devlink: pointer to the devlink instance to reload
Expand Down Expand Up @@ -589,6 +741,13 @@ static const struct devlink_param ice_devlink_params[] = {
ice_devlink_enable_iw_get,
ice_devlink_enable_iw_set,
ice_devlink_enable_iw_validate),
DEVLINK_PARAM_DRIVER(ICE_DEVLINK_PARAM_ID_TX_BALANCE,
"txbalancing",
DEVLINK_PARAM_TYPE_BOOL,
BIT(DEVLINK_PARAM_CMODE_PERMANENT),
ice_devlink_txbalance_get,
ice_devlink_txbalance_set,
ice_devlink_txbalance_validate),

};

Expand Down
7 changes: 3 additions & 4 deletions drivers/net/ethernet/intel/ice/ice_fw_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,9 @@ ice_send_component_table(struct pldmfw *context, struct pldmfw_component *compon
*
* Returns: zero on success, or a negative error code on failure.
*/
static int
ice_write_one_nvm_block(struct ice_pf *pf, u16 module, u32 offset,
u16 block_size, u8 *block, bool last_cmd,
u8 *reset_level, struct netlink_ext_ack *extack)
int ice_write_one_nvm_block(struct ice_pf *pf, u16 module, u32 offset,
u16 block_size, u8 *block, bool last_cmd,
u8 *reset_level, struct netlink_ext_ack *extack)
{
u16 completion_module, completion_retval;
struct device *dev = ice_pf_to_dev(pf);
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_fw_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ int ice_devlink_flash_update(struct devlink *devlink,
struct netlink_ext_ack *extack);
int ice_get_pending_updates(struct ice_pf *pf, u8 *pending,
struct netlink_ext_ack *extack);
int ice_write_one_nvm_block(struct ice_pf *pf, u16 module, u32 offset,
u16 block_size, u8 *block, bool last_cmd,
u8 *reset_level, struct netlink_ext_ack *extack);

#endif
2 changes: 1 addition & 1 deletion drivers/net/ethernet/intel/ice/ice_nvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* Read the NVM using the admin queue commands (0x0701)
*/
static int
int
ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
void *data, bool last_command, bool read_shadow_ram,
struct ice_sq_cd *cd)
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_nvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ struct ice_orom_civd_info {
int ice_acquire_nvm(struct ice_hw *hw, enum ice_aq_res_access_type access);
void ice_release_nvm(struct ice_hw *hw);
int
ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length,
void *data, bool last_command, bool read_shadow_ram,
struct ice_sq_cd *cd);
int
ice_read_flat_nvm(struct ice_hw *hw, u32 offset, u32 *length, u8 *data,
bool read_shadow_ram);
int
Expand Down

0 comments on commit 15b804e

Please sign in to comment.