[Intel-wired-lan] [PATCH net-next v10 4/5] ice: Add txbalancing devlink param
Tony Nguyen
anthony.l.nguyen at intel.com
Fri Mar 17 17:17:59 UTC 2023
On 3/14/2023 3:25 AM, Michal Wilczynski wrote:
> From: Lukasz Czapnik <lukasz.czapnik at intel.com>
[...]
> +/**
> + * 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 = (struct ice_pf *)devlink_priv(devlink);
The casting is unneeded... same for others below this.
> + 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 = (struct ice_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");
Does this need a newline?
> +
> + 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 = (struct ice_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_tear_down_devlink_rate_tree - removes devlink-rate exported tree
> * @pf: pf struct
> @@ -1391,7 +1545,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),
> };
>
> static void ice_devlink_free(void *devlink_ptr)
> diff --git a/drivers/net/ethernet/intel/ice/ice_fw_update.c b/drivers/net/ethernet/intel/ice/ice_fw_update.c
> index 3dc5662d62a6..dc5b49104674 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fw_update.c
> +++ b/drivers/net/ethernet/intel/ice/ice_fw_update.c
> @@ -286,7 +286,7 @@ ice_send_component_table(struct pldmfw *context, struct pldmfw_component *compon
> *
> * Returns: zero on success, or a negative error code on failure.
> */
> -static int
> +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)
> diff --git a/drivers/net/ethernet/intel/ice/ice_fw_update.h b/drivers/net/ethernet/intel/ice/ice_fw_update.h
> index 750574885716..04b200462757 100644
> --- a/drivers/net/ethernet/intel/ice/ice_fw_update.h
> +++ b/drivers/net/ethernet/intel/ice/ice_fw_update.h
> @@ -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
> diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c
> index f6f52a248066..745f2459943f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_nvm.c
> +++ b/drivers/net/ethernet/intel/ice/ice_nvm.c
> @@ -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)
> diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.h b/drivers/net/ethernet/intel/ice/ice_nvm.h
> index 774c2317967d..88978b9a95b1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_nvm.h
> +++ b/drivers/net/ethernet/intel/ice/ice_nvm.h
> @@ -14,6 +14,9 @@ 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);
More information about the Intel-wired-lan
mailing list