@@ -631,10 +631,30 @@ static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_prio = {
631
631
.clean_stats = mlxsw_sp_setup_tc_qdisc_prio_clean_stats ,
632
632
};
633
633
634
- /* Grafting is not supported in mlxsw. It will result in un-offloading of the
635
- * grafted qdisc as well as the qdisc in the qdisc new location.
636
- * (However, if the graft is to the location where the qdisc is already at, it
637
- * will be ignored completely and won't cause un-offloading).
634
+ /* Linux allows linking of Qdiscs to arbitrary classes (so long as the resulting
635
+ * graph is free of cycles). These operations do not change the parent handle
636
+ * though, which means it can be incomplete (if there is more than one class
637
+ * where the Qdisc in question is grafted) or outright wrong (if the Qdisc was
638
+ * linked to a different class and then removed from the original class).
639
+ *
640
+ * E.g. consider this sequence of operations:
641
+ *
642
+ * # tc qdisc add dev swp1 root handle 1: prio
643
+ * # tc qdisc add dev swp1 parent 1:3 handle 13: red limit 1000000 avpkt 10000
644
+ * RED: set bandwidth to 10Mbit
645
+ * # tc qdisc link dev swp1 handle 13: parent 1:2
646
+ *
647
+ * At this point, both 1:2 and 1:3 have the same RED Qdisc instance as their
648
+ * child. But RED will still only claim that 1:3 is its parent. If it's removed
649
+ * from that band, its only parent will be 1:2, but it will continue to claim
650
+ * that it is in fact 1:3.
651
+ *
652
+ * The notification for child Qdisc replace (e.g. TC_RED_REPLACE) comes before
653
+ * the notification for parent graft (e.g. TC_PRIO_GRAFT). We take the replace
654
+ * notification to offload the child Qdisc, based on its parent handle, and use
655
+ * the graft operation to validate that the class where the child is actually
656
+ * grafted corresponds to the parent handle. If the two don't match, we
657
+ * unoffload the child.
638
658
*/
639
659
static int
640
660
mlxsw_sp_qdisc_prio_graft (struct mlxsw_sp_port * mlxsw_sp_port ,
@@ -644,9 +664,6 @@ mlxsw_sp_qdisc_prio_graft(struct mlxsw_sp_port *mlxsw_sp_port,
644
664
int tclass_num = MLXSW_SP_PRIO_BAND_TO_TCLASS (p -> band );
645
665
struct mlxsw_sp_qdisc * old_qdisc ;
646
666
647
- /* Check if the grafted qdisc is already in its "new" location. If so -
648
- * nothing needs to be done.
649
- */
650
667
if (p -> band < IEEE_8021QAZ_MAX_TCS &&
651
668
mlxsw_sp_port -> tclass_qdiscs [tclass_num ].handle == p -> child_handle )
652
669
return 0 ;
0 commit comments