[PATCH net-next 4/6] net: macb: Implement TAPRIO DESTROY command offload for gate cleanup

Vineeth Karumanchi posted 6 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH net-next 4/6] net: macb: Implement TAPRIO DESTROY command offload for gate cleanup
Posted by Vineeth Karumanchi 2 months, 2 weeks ago
Add hardware offload support for "tc qdisc destroy" operations to safely
remove IEEE 802.1Qbv time-gated scheduling configuration and restore
default queue behavior.

Cleanup sequence:
- Reset network device TC configuration state
- Disable Enhanced Network Scheduling and Timing for all queues
- Clear all ENST timing control registers (START_TIME, ON_TIME, OFF_TIME)
- Atomic register programming with proper synchronization

This ensures complete removal of time-aware scheduling state, returning
the controller to standard FIFO queue operation without residual timing
constraints

Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 28 ++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 4518b59168d5..6b3eff28a842 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4239,6 +4239,34 @@ static int macb_taprio_setup_replace(struct net_device *ndev,
 	return err;
 }
 
+static void macb_taprio_destroy(struct net_device *ndev)
+{
+	struct macb *bp = netdev_priv(ndev);
+	struct macb_queue *queue;
+	unsigned long flags;
+	u32 enst_disable_mask;
+	u8 i;
+
+	netdev_reset_tc(ndev);
+	enst_disable_mask = GENMASK(bp->num_queues - 1, 0) << GEM_ENST_DISABLE_QUEUE_OFFSET;
+	netdev_dbg(ndev, "TAPRIO destroy: disabling all gates\n");
+
+	spin_lock_irqsave(&bp->lock, flags);
+
+	/* Single disable command for all queues */
+	gem_writel(bp, ENST_CONTROL, enst_disable_mask);
+
+	/* Clear all queue ENST registers in batch */
+	for (i = 0; i < bp->num_queues; i++) {
+		queue = &bp->queues[i];
+		queue_writel(queue, ENST_START_TIME, 0);
+		queue_writel(queue, ENST_ON_TIME, 0);
+		queue_writel(queue, ENST_OFF_TIME, 0);
+	}
+
+	spin_unlock_irqrestore(&bp->lock, flags);
+}
+
 static const struct net_device_ops macb_netdev_ops = {
 	.ndo_open		= macb_open,
 	.ndo_stop		= macb_close,
-- 
2.34.1
Re: [PATCH net-next 4/6] net: macb: Implement TAPRIO DESTROY command offload for gate cleanup
Posted by claudiu beznea (tuxon) 2 months, 1 week ago

On 7/22/25 18:41, Vineeth Karumanchi wrote:
> Add hardware offload support for "tc qdisc destroy" operations to safely
> remove IEEE 802.1Qbv time-gated scheduling configuration and restore
> default queue behavior.
> 
> Cleanup sequence:
> - Reset network device TC configuration state
> - Disable Enhanced Network Scheduling and Timing for all queues
> - Clear all ENST timing control registers (START_TIME, ON_TIME, OFF_TIME)
> - Atomic register programming with proper synchronization
> 
> This ensures complete removal of time-aware scheduling state, returning
> the controller to standard FIFO queue operation without residual timing
> constraints
> 
> Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
> ---
>   drivers/net/ethernet/cadence/macb_main.c | 28 ++++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 4518b59168d5..6b3eff28a842 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4239,6 +4239,34 @@ static int macb_taprio_setup_replace(struct net_device *ndev,
>   	return err;
>   }
>   
> +static void macb_taprio_destroy(struct net_device *ndev)

This function is unused in this patch. Nothing mentions it.

> +{
> +	struct macb *bp = netdev_priv(ndev);
> +	struct macb_queue *queue;
> +	unsigned long flags;
> +	u32 enst_disable_mask;
> +	u8 i;

unsigned int

> +
> +	netdev_reset_tc(ndev);
> +	enst_disable_mask = GENMASK(bp->num_queues - 1, 0) << GEM_ENST_DISABLE_QUEUE_OFFSET;

You can use GEM_BF(GENMASK(...), ENST_DISABLE_QUEUE) if you 
GEM_ENST_DISABLE_QUEUE_SIZE is defined

> +	netdev_dbg(ndev, "TAPRIO destroy: disabling all gates\n");
> +
> +	spin_lock_irqsave(&bp->lock, flags);

guard()

> +
> +	/* Single disable command for all queues */
> +	gem_writel(bp, ENST_CONTROL, enst_disable_mask);
> +
> +	/* Clear all queue ENST registers in batch */
> +	for (i = 0; i < bp->num_queues; i++) {

You can follow the pattern across macb_main.c and replace it with:

         for (unsigned int q = 0, queue = &bp->queues[q]; q < bp->num_queues; 
++q, ++queue)

> +		queue = &bp->queues[i];

And drop this line

Thank you,
Claudiu

> +		queue_writel(queue, ENST_START_TIME, 0);
> +		queue_writel(queue, ENST_ON_TIME, 0);
> +		queue_writel(queue, ENST_OFF_TIME, 0);
> +	}
> +
> +	spin_unlock_irqrestore(&bp->lock, flags);
> +}
> +
>   static const struct net_device_ops macb_netdev_ops = {
>   	.ndo_open		= macb_open,
>   	.ndo_stop		= macb_close,