src/dpdk/drivers/net/ice/base/ice_sched.c
enum ice_status
ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
		  u8 owner, bool enable)
{
	struct ice_sched_node *vsi_node, *tc_node;
	struct ice_vsi_ctx *vsi_ctx;
	enum ice_status status = ICE_SUCCESS;
	struct ice_hw *hw = pi->hw;

	ice_debug(pi->hw, ICE_DBG_SCHED, "add/config VSI %d\n", vsi_handle);
	tc_node = ice_sched_get_tc_node(pi, tc);
	if (!tc_node)
		return ICE_ERR_PARAM;
	vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
	if (!vsi_ctx)
		return ICE_ERR_PARAM;
	vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);

	/* suspend the VSI if TC is not enabled */
	if (!enable) {
		if (vsi_node && vsi_node->in_use) {
			u32 teid = LE32_TO_CPU(vsi_node->info.node_teid);

			status = ice_sched_suspend_resume_elems(hw, 1, &teid,
								true);
			if (!status)
				vsi_node->in_use = false;
		}
		return status;
	}

	/* TC is enabled, if it is a new VSI then add it to the tree */
	if (!vsi_node) {
		status = ice_sched_add_vsi_to_topo(pi, vsi_handle, tc);
		if (status)
			return status;

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

		vsi_ctx->sched.vsi_node[tc] = vsi_node;
		vsi_node->in_use = true;
		/* invalidate the max queues whenever VSI gets added first time
		 * into the scheduler tree (boot or after reset). We need to
		 * recreate the child nodes all the time in these cases.
		 */
		vsi_ctx->sched.max_lanq[tc] = 0;
	}

	/* update the VSI child nodes */
	status = ice_sched_update_vsi_child_nodes(pi, vsi_handle, tc, maxqs,
						  owner);
	if (status)
		return status;

	/* TC is enabled, resume the VSI if it is in the suspend state */
	if (!vsi_node->in_use) {
		u32 teid = LE32_TO_CPU(vsi_node->info.node_teid);

		status = ice_sched_suspend_resume_elems(hw, 1, &teid, false);
		if (!status)
			vsi_node->in_use = true;
	}

	return status;
}
/**
 * ice_sched_cfg_vsi - configure the new/existing VSI
 * @pi: port information structure
 * @vsi_handle: software VSI handle
 * @tc: TC number
 * @maxqs: max number of queues
 * @owner: LAN or RDMA
 * @enable: TC enabled or disabled
 *
 * This function adds/updates VSI nodes based on the number of queues. If TC is
 * enabled and VSI is in suspended state then resume the VSI back. If TC is
 * disabled then suspend the VSI if it is not already.
 */


This function adds/updates VSI nodes based on the number of queues. If TC is
enabled and VSI is in suspended state then resume the VSI back. If TC is
disabled then suspend the VSI if it is not already.
This function adds / updates VSI nodes based on the number of queues . If TC is enabled and VSI is in suspended state then resume the VSI back . If TC is disabled then suspend the VSI if it is not already .
enum ice_status
ice_sched_cfg_vsi(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u16 maxqs,
		  u8 owner, bool enable)
{
	struct ice_sched_node *vsi_node, *tc_node;
	struct ice_vsi_ctx *vsi_ctx;
	enum ice_status status = ICE_SUCCESS;
	struct ice_hw *hw = pi->hw;
	ice_debug(pi->hw, ICE_DBG_SCHED, "add/config VSI %d\n", vsi_handle);
	tc_node = ice_sched_get_tc_node(pi, tc);
	if (!tc_node)
		return ICE_ERR_PARAM;
	vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle);
	if (!vsi_ctx)
		return ICE_ERR_PARAM;
	vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
	if (!enable) {
		if (vsi_node && vsi_node->in_use) {
			u32 teid = LE32_TO_CPU(vsi_node->info.node_teid);
			status = ice_sched_suspend_resume_elems(hw, 1, &teid,
								true);
			if (!status)
				vsi_node->in_use = false;
		}
		return status;
	}
	if (!vsi_node) {
		status = ice_sched_add_vsi_to_topo(pi, vsi_handle, tc);
		if (status)
			return status;
		vsi_node = ice_sched_get_vsi_node(pi, tc_node, vsi_handle);
		if (!vsi_node)
			return ICE_ERR_CFG;
		vsi_ctx->sched.vsi_node[tc] = vsi_node;
		vsi_node->in_use = true;
		vsi_ctx->sched.max_lanq[tc] = 0;
	}
	status = ice_sched_update_vsi_child_nodes(pi, vsi_handle, tc, maxqs,
						  owner);
	if (status)
		return status;
	if (!vsi_node->in_use) {
		u32 teid = LE32_TO_CPU(vsi_node->info.node_teid);
		status = ice_sched_suspend_resume_elems(hw, 1, &teid, false);
		if (!status)
			vsi_node->in_use = true;
	}
	return status;
}
enum ice_status ice_sched_cfg_vsi ( struct ice_port_info * pi , u16 vsi_handle , u8 tc , u16 maxqs , u8 owner , bool enable ) { struct ice_sched_node * vsi_node , * tc_node ; struct ice_vsi_ctx * vsi_ctx ; enum ice_status status = ICE_SUCCESS ; struct ice_hw * hw = pi -> hw ; ice_debug ( pi -> hw , ICE_DBG_SCHED , " \n " , vsi_handle ) ; tc_node = ice_sched_get_tc_node ( pi , tc ) ; if ( ! tc_node ) return ICE_ERR_PARAM ; vsi_ctx = ice_get_vsi_ctx ( hw , vsi_handle ) ; if ( ! vsi_ctx ) return ICE_ERR_PARAM ; vsi_node = ice_sched_get_vsi_node ( pi , tc_node , vsi_handle ) ; if ( ! enable ) { if ( vsi_node && vsi_node -> in_use ) { u32 teid = LE32_TO_CPU ( vsi_node -> info . node_teid ) ; status = ice_sched_suspend_resume_elems ( hw , 1 , & teid , true ) ; if ( ! status ) vsi_node -> in_use = false ; } return status ; } if ( ! vsi_node ) { status = ice_sched_add_vsi_to_topo ( pi , vsi_handle , tc ) ; if ( status ) return status ; vsi_node = ice_sched_get_vsi_node ( pi , tc_node , vsi_handle ) ; if ( ! vsi_node ) return ICE_ERR_CFG ; vsi_ctx -> sched . vsi_node [ tc ] = vsi_node ; vsi_node -> in_use = true ; vsi_ctx -> sched . max_lanq [ tc ] = 0 ; } status = ice_sched_update_vsi_child_nodes ( pi , vsi_handle , tc , maxqs , owner ) ; if ( status ) return status ; if ( ! vsi_node -> in_use ) { u32 teid = LE32_TO_CPU ( vsi_node -> info . node_teid ) ; status = ice_sched_suspend_resume_elems ( hw , 1 , & teid , false ) ; if ( ! status ) vsi_node -> in_use = true ; } return status ; }
ice_sched_cfg_vsi - configure the new/existing VSI
 @pi: port information structure
 @vsi_handle: software VSI handle
 @tc: TC number
 @maxqs: max number of queues
 @owner: LAN or RDMA
 @enable: TC enabled or disabled
ice_sched_cfg_vsi - configure the new / existing VSI @pi : port information structure @vsi_handle : software VSI handle @tc : TC number @maxqs : max number of queues @owner : LAN or RDMA @enable : TC enabled or disabled
/* suspend the VSI if TC is not enabled */ /* TC is enabled, if it is a new VSI then add it to the tree */ /* invalidate the max queues whenever VSI gets added first time
		 * into the scheduler tree (boot or after reset). We need to
		 * recreate the child nodes all the time in these cases.
		 */ /* update the VSI child nodes */ /* TC is enabled, resume the VSI if it is in the suspend state */