+ice_sched_rm_vsi_subtree(struct ice_port_info *pi,
+                        struct ice_sched_node *vsi_node, u8 owner, u8 tc)
+{
+       u16 vsi_handle = vsi_node->vsi_handle;
+       bool all_vsi_nodes_removed = true;
+       int j = 0;
+
+       while (vsi_node) {
+               struct ice_sched_node *next_vsi_node;
+
+               if (ice_sched_is_leaf_node_present(vsi_node)) {
+                       ice_debug(pi->hw, ICE_DBG_SCHED, "VSI has leaf nodes in TC 
%d\n", tc);
+                       return -EBUSY;
+               }
+               while (j < vsi_node->num_children) {
+                       if (vsi_node->children[j]->owner == owner) {
+                               ice_free_sched_node(pi, vsi_node->children[j]);
+
+                               /* reset the counter again since the num
+                                * children will be updated after node removal
+                                */
+                               j = 0;

I know this code is a copy-pasta, but it looks that there is no need to
reset the counter (whole array isn't reshuffled), just don't increase it

IOW, would be good to check if this line (and the semi-obvious and
half-wrong comment) could be removed.

you could keep my RB tag, thank you again for the series!

+                       } else {
+                               j++;
+                       }
+               }
+
+               next_vsi_node = ice_sched_find_next_vsi_node(vsi_node);
+
+               /* remove the VSI if it has no children */
+               if (!vsi_node->num_children)
+                       ice_free_sched_node(pi, vsi_node);
+               else
+                       all_vsi_nodes_removed = false;
+
+               vsi_node = next_vsi_node;
+       }
+
+       /* clean up aggregator related VSI info if any */
+       if (all_vsi_nodes_removed)
+               ice_sched_rm_agg_vsi_info(pi, vsi_handle);
+
+       return 0;
+}

Reply via email to