src/dpdk/drivers/net/ice/base/ice_sched.c
static enum ice_status
ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
{
	struct ice_sched_node *parent, *agg_node, *tc_node;
	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
	enum ice_status status = ICE_SUCCESS;
	struct ice_hw *hw = pi->hw;
	u32 first_node_teid;
	u16 num_nodes_added;
	u8 i, aggl;

	tc_node = ice_sched_get_tc_node(pi, tc);
	if (!tc_node)
		return ICE_ERR_CFG;

	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
	/* Does Agg node already exist ? */
	if (agg_node)
		return status;

	aggl = ice_sched_get_agg_layer(hw);

	/* need one node in Agg layer */
	num_nodes[aggl] = 1;

	/* Check whether the intermediate nodes have space to add the
	 * new aggregator. If they are full, then SW needs to allocate a new
	 * intermediate node on those layers
	 */
	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
		parent = ice_sched_get_first_node(pi, tc_node, i);

		/* scan all the siblings */
		while (parent) {
			if (parent->num_children < hw->max_children[i])
				break;
			parent = parent->sibling;
		}

		/* all the nodes are full, reserve one for this layer */
		if (!parent)
			num_nodes[i]++;
	}

	/* add the aggregator node */
	parent = tc_node;
	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
		if (!parent)
			return ICE_ERR_CFG;

		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
						      num_nodes[i],
						      &first_node_teid,
						      &num_nodes_added);
		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
			return ICE_ERR_CFG;

		/* The newly added node can be a new parent for the next
		 * layer nodes
		 */
		if (num_nodes_added) {
			parent = ice_sched_find_node_by_teid(tc_node,
							     first_node_teid);
			/* register aggregator ID with the aggregator node */
			if (parent && i == aggl)
				parent->agg_id = agg_id;
		} else {
			parent = parent->children[0];
		}
	}

	return ICE_SUCCESS;
}
/**
 * ice_sched_add_agg_cfg - create an aggregator node
 * @pi: port information structure
 * @agg_id: aggregator ID
 * @tc: TC number
 *
 * This function creates an aggregator node and intermediate nodes if required
 * for the given TC
 */
create an aggregator node
@pi: port information structure
@agg_id: aggregator ID
@tc: TC number

This function creates an aggregator node and intermediate nodes if required
for the given TC
create an aggregator node @pi : port information structure @agg_id : aggregator ID @tc : TC number This function creates an aggregator node and intermediate nodes if required for the given TC
static enum ice_status
ice_sched_add_agg_cfg(struct ice_port_info *pi, u32 agg_id, u8 tc)
{
	struct ice_sched_node *parent, *agg_node, *tc_node;
	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
	enum ice_status status = ICE_SUCCESS;
	struct ice_hw *hw = pi->hw;
	u32 first_node_teid;
	u16 num_nodes_added;
	u8 i, aggl;
	tc_node = ice_sched_get_tc_node(pi, tc);
	if (!tc_node)
		return ICE_ERR_CFG;
	agg_node = ice_sched_get_agg_node(pi, tc_node, agg_id);
	if (agg_node)
		return status;
	aggl = ice_sched_get_agg_layer(hw);
	num_nodes[aggl] = 1;
	for (i = hw->sw_entry_point_layer; i < aggl; i++) {
		parent = ice_sched_get_first_node(pi, tc_node, i);
		while (parent) {
			if (parent->num_children < hw->max_children[i])
				break;
			parent = parent->sibling;
		}
		if (!parent)
			num_nodes[i]++;
	}
	parent = tc_node;
	for (i = hw->sw_entry_point_layer; i <= aggl; i++) {
		if (!parent)
			return ICE_ERR_CFG;
		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent, i,
						      num_nodes[i],
						      &first_node_teid,
						      &num_nodes_added);
		if (status != ICE_SUCCESS || num_nodes[i] != num_nodes_added)
			return ICE_ERR_CFG;
		if (num_nodes_added) {
			parent = ice_sched_find_node_by_teid(tc_node,
							     first_node_teid);
			if (parent && i == aggl)
				parent->agg_id = agg_id;
		} else {
			parent = parent->children[0];
		}
	}
	return ICE_SUCCESS;
}
static enum ice_status ice_sched_add_agg_cfg ( struct ice_port_info * pi , u32 agg_id , u8 tc ) { struct ice_sched_node * parent , * agg_node , * tc_node ; u16 num_nodes [ ICE_AQC_TOPO_MAX_LEVEL_NUM ] = { 0 } ; enum ice_status status = ICE_SUCCESS ; struct ice_hw * hw = pi -> hw ; u32 first_node_teid ; u16 num_nodes_added ; u8 i , aggl ; tc_node = ice_sched_get_tc_node ( pi , tc ) ; if ( ! tc_node ) return ICE_ERR_CFG ; agg_node = ice_sched_get_agg_node ( pi , tc_node , agg_id ) ; if ( agg_node ) return status ; aggl = ice_sched_get_agg_layer ( hw ) ; num_nodes [ aggl ] = 1 ; for ( i = hw -> sw_entry_point_layer ; i < aggl ; i ++ ) { parent = ice_sched_get_first_node ( pi , tc_node , i ) ; while ( parent ) { if ( parent -> num_children < hw -> max_children [ i ] ) break ; parent = parent -> sibling ; } if ( ! parent ) num_nodes [ i ] ++ ; } parent = tc_node ; for ( i = hw -> sw_entry_point_layer ; i <= aggl ; i ++ ) { if ( ! parent ) return ICE_ERR_CFG ; status = ice_sched_add_nodes_to_layer ( pi , tc_node , parent , i , num_nodes [ i ] , & first_node_teid , & num_nodes_added ) ; if ( status != ICE_SUCCESS || num_nodes [ i ] != num_nodes_added ) return ICE_ERR_CFG ; if ( num_nodes_added ) { parent = ice_sched_find_node_by_teid ( tc_node , first_node_teid ) ; if ( parent && i == aggl ) parent -> agg_id = agg_id ; } else { parent = parent -> children [ 0 ] ; } } return ICE_SUCCESS ; }
ice_sched_add_agg_cfg - create an aggregator node
 @pi: port information structure
 @agg_id: aggregator ID
 @tc: TC number
ice_sched_add_agg_cfg - create an aggregator node @pi : port information structure @agg_id : aggregator ID @tc : TC number
/* Does Agg node already exist ? */ /* need one node in Agg layer */ /* Check whether the intermediate nodes have space to add the
	 * new aggregator. If they are full, then SW needs to allocate a new
	 * intermediate node on those layers
	 */ /* scan all the siblings */ /* all the nodes are full, reserve one for this layer */ /* add the aggregator node */ /* The newly added node can be a new parent for the next
		 * layer nodes
		 */ /* register aggregator ID with the aggregator node */