src/dpdk/drivers/net/ice/base/ice_sched.c
static enum ice_status
ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
			  u8 tc)
{
	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
	u32 first_node_teid, vsi_teid;
	enum ice_status status;
	u16 num_nodes_added;
	u8 aggl, vsil, i;

	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 ICE_ERR_DOES_NOT_EXIST;

	vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
	if (!vsi_node)
		return ICE_ERR_DOES_NOT_EXIST;

	/* Is this VSI already part of given aggregator? */
	if (ice_sched_find_node_in_subtree(pi->hw, agg_node, vsi_node))
		return ICE_SUCCESS;

	aggl = ice_sched_get_agg_layer(pi->hw);
	vsil = ice_sched_get_vsi_layer(pi->hw);

	/* set intermediate node count to 1 between aggregator and VSI layers */
	for (i = aggl + 1; i < vsil; i++)
		num_nodes[i] = 1;

	/* Check if the aggregator subtree has any free node to add the VSI */
	for (i = 0; i < agg_node->num_children; i++) {
		parent = ice_sched_get_free_vsi_parent(pi->hw,
						       agg_node->children[i],
						       num_nodes);
		if (parent)
			goto move_nodes;
	}

	/* add new nodes */
	parent = agg_node;
	for (i = aggl + 1; i < vsil; i++) {
		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);
		else
			parent = parent->children[0];

		if (!parent)
			return ICE_ERR_CFG;
	}

move_nodes:
	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
}
/**
 * ice_sched_move_vsi_to_agg - move VSI to aggregator node
 * @pi: port information structure
 * @vsi_handle: software VSI handle
 * @agg_id: aggregator ID
 * @tc: TC number
 *
 * This function moves a VSI to an aggregator node or its subtree.
 * Intermediate nodes may be created if required.
 */
move VSI to aggregator node
@pi: port information structure
@vsi_handle: software VSI handle
@agg_id: aggregator ID
@tc: TC number

This function moves a VSI to an aggregator node or its subtree.
Intermediate nodes may be created if required.
move VSI to aggregator node @pi : port information structure @vsi_handle : software VSI handle @agg_id : aggregator ID @tc : TC number This function moves a VSI to an aggregator node or its subtree . Intermediate nodes may be created if required .
static enum ice_status
ice_sched_move_vsi_to_agg(struct ice_port_info *pi, u16 vsi_handle, u32 agg_id,
			  u8 tc)
{
	struct ice_sched_node *vsi_node, *agg_node, *tc_node, *parent;
	u16 num_nodes[ICE_AQC_TOPO_MAX_LEVEL_NUM] = { 0 };
	u32 first_node_teid, vsi_teid;
	enum ice_status status;
	u16 num_nodes_added;
	u8 aggl, vsil, i;
	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 ICE_ERR_DOES_NOT_EXIST;
	vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
	if (!vsi_node)
		return ICE_ERR_DOES_NOT_EXIST;
	if (ice_sched_find_node_in_subtree(pi->hw, agg_node, vsi_node))
		return ICE_SUCCESS;
	aggl = ice_sched_get_agg_layer(pi->hw);
	vsil = ice_sched_get_vsi_layer(pi->hw);
	for (i = aggl + 1; i < vsil; i++)
		num_nodes[i] = 1;
	for (i = 0; i < agg_node->num_children; i++) {
		parent = ice_sched_get_free_vsi_parent(pi->hw,
						       agg_node->children[i],
						       num_nodes);
		if (parent)
			goto move_nodes;
	}
	parent = agg_node;
	for (i = aggl + 1; i < vsil; i++) {
		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);
		else
			parent = parent->children[0];
		if (!parent)
			return ICE_ERR_CFG;
	}
move_nodes:
	vsi_teid = LE32_TO_CPU(vsi_node->info.node_teid);
	return ice_sched_move_nodes(pi, parent, 1, &vsi_teid);
}
static enum ice_status ice_sched_move_vsi_to_agg ( struct ice_port_info * pi , u16 vsi_handle , u32 agg_id , u8 tc ) { struct ice_sched_node * vsi_node , * agg_node , * tc_node , * parent ; u16 num_nodes [ ICE_AQC_TOPO_MAX_LEVEL_NUM ] = { 0 } ; u32 first_node_teid , vsi_teid ; enum ice_status status ; u16 num_nodes_added ; u8 aggl , vsil , i ; 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 ICE_ERR_DOES_NOT_EXIST ; vsi_node = ice_sched_get_vsi_node ( pi , tc_node , vsi_handle ) ; if ( ! vsi_node ) return ICE_ERR_DOES_NOT_EXIST ; if ( ice_sched_find_node_in_subtree ( pi -> hw , agg_node , vsi_node ) ) return ICE_SUCCESS ; aggl = ice_sched_get_agg_layer ( pi -> hw ) ; vsil = ice_sched_get_vsi_layer ( pi -> hw ) ; for ( i = aggl + 1 ; i < vsil ; i ++ ) num_nodes [ i ] = 1 ; for ( i = 0 ; i < agg_node -> num_children ; i ++ ) { parent = ice_sched_get_free_vsi_parent ( pi -> hw , agg_node -> children [ i ] , num_nodes ) ; if ( parent ) goto move_nodes ; } parent = agg_node ; for ( i = aggl + 1 ; i < vsil ; i ++ ) { 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 ) ; else parent = parent -> children [ 0 ] ; if ( ! parent ) return ICE_ERR_CFG ; } move_nodes : vsi_teid = LE32_TO_CPU ( vsi_node -> info . node_teid ) ; return ice_sched_move_nodes ( pi , parent , 1 , & vsi_teid ) ; }
ice_sched_move_vsi_to_agg - move VSI to aggregator node
 @pi: port information structure
 @vsi_handle: software VSI handle
 @agg_id: aggregator ID
 @tc: TC number
ice_sched_move_vsi_to_agg - move VSI to aggregator node @pi : port information structure @vsi_handle : software VSI handle @agg_id : aggregator ID @tc : TC number
/* Is this VSI already part of given aggregator? */ /* set intermediate node count to 1 between aggregator and VSI layers */ /* Check if the aggregator subtree has any free node to add the VSI */ /* add new nodes */ /* The newly added node can be a new parent for the next
		 * layer nodes
		 */