The ice_sched_cfg_agg() function is called with an aggregator ID and type. It performs a lookup of the aggregator info structure by ID. If the lookup fails, it calls ice_alloc_agg_info to allocate a new aggregator structure for that ID.
This behavior used to make sense when ice_cfg_agg() was exported and intended to create a new aggregator node for a specific ID. This is no longer true, and all three callers of ice_sched_cfg_agg() already have a valid agg_info structure. Refactor the function to take the agg_info pointer directly, dropping the unnecessary lookup and allocation fallback. This simplifies the function, and keeps its scope targeted at traffic class configuration. This removes essentially dead code, and prevents the need for adding additional error cleanup for failures that are impossible. Suggested-by: Aleksandr Loktionov <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> --- drivers/net/ethernet/intel/ice/ice_sched.c | 49 ++++++++++-------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c index c45e9076518d..cb5f6120ad0c 100644 --- a/drivers/net/ethernet/intel/ice/ice_sched.c +++ b/drivers/net/ethernet/intel/ice/ice_sched.c @@ -2744,41 +2744,28 @@ ice_alloc_agg_info(struct ice_hw *hw, u32 min_id, u32 max_id, /** * ice_sched_cfg_agg - configure aggregator node * @pi: port information structure - * @agg_id: aggregator ID - * @agg_type: aggregator type queue, VSI, or aggregator group + * @agg_info: pointer to aggregator node to configure * @tc_bitmap: bits TC bitmap * - * It registers a unique aggregator node into scheduler services. It - * allows a user to register with a unique ID to track it's resources. - * The aggregator type determines if this is a queue group, VSI group - * or aggregator group. It then creates the aggregator node(s) for requested - * TC(s) or removes an existing aggregator node including its configuration - * if indicated via tc_bitmap. Call ice_rm_agg_cfg to release aggregator - * resources and remove aggregator ID. - * This function needs to be called with scheduler lock held. + * Configure an aggregator node's traffic classes according to the provided + * tc_bitmap. + * + * Context: Must be called with scheduler lock held. */ -static int -ice_sched_cfg_agg(struct ice_port_info *pi, u32 agg_id, - enum ice_agg_type agg_type, unsigned long *tc_bitmap) +static int ice_sched_cfg_agg(struct ice_port_info *pi, + struct ice_sched_agg_info *agg_info, + unsigned long *tc_bitmap) { - struct ice_sched_agg_info *agg_info; - struct ice_hw *hw = pi->hw; - int status = 0; + int status; u8 tc; - agg_info = xa_load(&hw->agg_list, agg_id); - if (!agg_info) - agg_info = ice_alloc_agg_info(hw, agg_id, agg_id, agg_type); - if (IS_ERR(agg_info)) - return PTR_ERR(agg_info); - /* Create aggregator node(s) for requested TC(s) */ ice_for_each_traffic_class(tc) { if (!ice_is_tc_ena(*tc_bitmap, tc)) { /* Delete aggregator cfg TC if it exists previously */ status = ice_rm_agg_cfg_tc(pi, agg_info, tc, false); if (status) - break; + return status; continue; } @@ -2787,15 +2774,15 @@ ice_sched_cfg_agg(struct ice_port_info *pi, u32 agg_id, continue; /* Create new aggregator node for TC */ - status = ice_sched_add_agg_cfg(pi, agg_id, tc); + status = ice_sched_add_agg_cfg(pi, agg_info->agg_id, tc); if (status) - break; + return status; /* Save aggregator node's TC information */ set_bit(tc, agg_info->tc_bitmap); } - return status; + return 0; } /** @@ -3121,8 +3108,7 @@ int ice_cfg_vsi_agg(struct ice_port_info *pi, u16 vsi_handle, } /* Configure the aggregator node */ - status = ice_sched_cfg_agg(pi, agg_info->agg_id, ICE_AGG_TYPE_AGG, - &bitmap); + status = ice_sched_cfg_agg(pi, agg_info, &bitmap); if (status) goto out_unlock; @@ -4402,9 +4388,7 @@ void ice_sched_replay_agg(struct ice_hw *hw) agg_info->replay_tc_bitmap, replay_bitmap); status = ice_sched_cfg_agg(hw->port_info, - agg_info->agg_id, - ICE_AGG_TYPE_AGG, - replay_bitmap); + agg_info, replay_bitmap); if (status) { dev_info(ice_hw_to_dev(hw), "Replay agg id[%d] failed\n", @@ -4471,8 +4455,7 @@ static int ice_sched_replay_vsi_agg(struct ice_hw *hw, u16 vsi_handle) ice_sched_get_ena_tc_bitmap(pi, agg_info->replay_tc_bitmap, replay_bitmap); /* Replay aggregator node associated to vsi_handle */ - status = ice_sched_cfg_agg(hw->port_info, agg_info->agg_id, - ICE_AGG_TYPE_AGG, replay_bitmap); + status = ice_sched_cfg_agg(hw->port_info, agg_info, replay_bitmap); if (status) return status; -- 2.54.0.1064.gd145956f57df
