netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "claudiu beznea (tuxon)" <claudiu.beznea@tuxon.dev>
To: Vineeth Karumanchi <vineeth.karumanchi@amd.com>,
	nicolas.ferre@microchip.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: git@amd.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/6] net: macb: Integrate ENST timing parameters and hardware unit conversion
Date: Sat, 26 Jul 2025 15:24:44 +0300	[thread overview]
Message-ID: <3cb5f213-3c06-46c5-a314-ce9fb5b1d175@tuxon.dev> (raw)
In-Reply-To: <20250722154111.1871292-3-vineeth.karumanchi@amd.com>

Hi, Vineeth,

On 7/22/25 18:41, Vineeth Karumanchi wrote:
> Add Enhanced Network Scheduling and Timing (ENST) support to
> queue infrastructure with speed-dependent timing calculations for
> precise gate control.
> 
> Hardware timing unit conversion:
> - Timing values programmed as hardware units based on link speed
> - Conversion formula: time_bytes = time_ns / divisor
> - Speed-specific divisors:
>    * 1 Gbps:   divisor = 8
>    * 100 Mbps: divisor = 80
>    * 10 Mbps:  divisor = 800
> 
> Infrastructure changes:
> - Extend macb_queue structure with ENST timing control registers
> - Add queue_enst_configs structure for per-entry TC configuration storage
> - Map ENST register offsets into existing queue management framework
> - Define ENST_NS_TO_HW_UNITS() macro for automatic speed-based conversion
> 
> This enables hardware-native timing programming while abstracting the
> speed-dependent conversions
> 
> Signed-off-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>
> ---
>   drivers/net/ethernet/cadence/macb.h      | 32 ++++++++++++++++++++++++
>   drivers/net/ethernet/cadence/macb_main.c |  6 +++++
>   2 files changed, 38 insertions(+)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
> index e456ac65d6c6..ef3995564c5c 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -857,6 +857,16 @@
>   
>   #define MACB_READ_NSR(bp)	macb_readl(bp, NSR)
>   
> +/* ENST macros*/
> +#define ENST_NS_TO_HW_UNITS(ns, speed_mbps) \
> +		DIV_ROUND_UP((ns) * (speed_mbps), (ENST_TIME_GRANULARITY_NS * 1000))
> +
> +#define ENST_MAX_HW_INTERVAL(speed_mbps) \
> +		DIV_ROUND_UP(GENMASK(GEM_ON_TIME_SIZE - 1, 0) * ENST_TIME_GRANULARITY_NS * 1000,\
> +		(speed_mbps))
> +
> +#define ENST_MAX_START_TIME_SEC GENMASK(GEM_START_TIME_SEC_SIZE - 1, 0)

These are not used in this patch.

> +
>   /* struct macb_dma_desc - Hardware DMA descriptor
>    * @addr: DMA address of data buffer
>    * @ctrl: Control and status bits
> @@ -1262,6 +1272,11 @@ struct macb_queue {
>   	unsigned int		RBQP;
>   	unsigned int		RBQPH;
>   
> +	/* ENST register offsets for this queue */
> +	unsigned int		ENST_START_TIME;
> +	unsigned int		ENST_ON_TIME;
> +	unsigned int		ENST_OFF_TIME;
> +
>   	/* Lock to protect tx_head and tx_tail */
>   	spinlock_t		tx_ptr_lock;
>   	unsigned int		tx_head, tx_tail;
> @@ -1450,4 +1465,21 @@ struct macb_platform_data {
>   	struct clk	*hclk;
>   };
>   
> +/**
> + * struct queue_enst_configs - Configuration for Enhanced Scheduled Traffic (ENST) queue
> + * @queue_id:         Identifier for the queue
> + * @start_time_mask:  Bitmask representing the start time for the queue
> + * @on_time_bytes:    "on" time nsec expressed in bytes
> + * @off_time_bytes:   "off" time nsec expressed in bytes
> + *
> + * This structure holds the configuration parameters for an ENST queue,
> + * used to control time-based transmission scheduling in the MACB driver.
> + */
> +struct queue_enst_configs {

s/queue_enst_config/macb_queue_enst_config

> +	u8 queue_id;

Could you please move this above to avoid any padding?

> +	u32 start_time_mask;
> +	u32 on_time_bytes;
> +	u32 off_time_bytes;
> +};
> +

This structure is not used in this patch. Can you please introduce it in the 
patch it is used?


>   #endif /* _MACB_H */
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index ce95fad8cedd..ff87d3e1d8a0 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4305,6 +4305,9 @@ static int macb_init(struct platform_device *pdev)
>   			queue->TBQP = GEM_TBQP(hw_q - 1);
>   			queue->RBQP = GEM_RBQP(hw_q - 1);
>   			queue->RBQS = GEM_RBQS(hw_q - 1);
> +			queue->ENST_START_TIME = GEM_ENST_START_TIME(hw_q);
> +			queue->ENST_ON_TIME = GEM_ENST_ON_TIME(hw_q);
> +			queue->ENST_OFF_TIME = GEM_ENST_OFF_TIME(hw_q);

You can drop these lines here and move it outside of the if (hw_q) {} else {} block.

>   #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
>   			if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
>   				queue->TBQPH = GEM_TBQPH(hw_q - 1);
> @@ -4319,6 +4322,9 @@ static int macb_init(struct platform_device *pdev)
>   			queue->IMR  = MACB_IMR;
>   			queue->TBQP = MACB_TBQP;
>   			queue->RBQP = MACB_RBQP;
> +			queue->ENST_START_TIME = GEM_ENST_START_TIME(0);
> +			queue->ENST_ON_TIME = GEM_ENST_ON_TIME(0);
> +			queue->ENST_OFF_TIME = GEM_ENST_OFF_TIME(0);

With the above suggested change, these lines could be dropped.

On the other hand these lines are used in patch 3. So I would prefer to have 
them introduced there.

Thank you,
Claudiu

>   #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
>   			if (bp->hw_dma_cap & HW_DMA_CAP_64B) {
>   				queue->TBQPH = MACB_TBQPH;


  reply	other threads:[~2025-07-26 12:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22 15:41 [PATCH net-next 0/6] net: macb: Add TAPRIO traffic scheduling support Vineeth Karumanchi
2025-07-22 15:41 ` [PATCH net-next 1/6] net: macb: Define ENST hardware registers for time-aware scheduling Vineeth Karumanchi
2025-07-26 12:23   ` claudiu beznea (tuxon)
2025-07-22 15:41 ` [PATCH net-next 2/6] net: macb: Integrate ENST timing parameters and hardware unit conversion Vineeth Karumanchi
2025-07-26 12:24   ` claudiu beznea (tuxon) [this message]
2025-07-22 15:41 ` [PATCH net-next 3/6] net: macb: Add IEEE 802.1Qbv TAPRIO REPLACE command offload support Vineeth Karumanchi
2025-07-23 10:02   ` kernel test robot
2025-07-26 12:25   ` claudiu beznea (tuxon)
2025-07-26 15:32     ` Andrew Lunn
2025-07-29  8:59     ` Karumanchi, Vineeth
2025-07-31  9:07       ` Claudiu Beznea
2025-07-22 15:41 ` [PATCH net-next 4/6] net: macb: Implement TAPRIO DESTROY command offload for gate cleanup Vineeth Karumanchi
2025-07-26 12:26   ` claudiu beznea (tuxon)
2025-07-22 15:41 ` [PATCH net-next 5/6] net: macb: Implement TAPRIO TC offload command interface Vineeth Karumanchi
2025-07-26 12:29   ` claudiu beznea (tuxon)
2025-07-29  9:38     ` Karumanchi, Vineeth
2025-07-31  9:07       ` Claudiu Beznea
2025-07-28 16:31   ` kernel test robot
2025-07-22 15:41 ` [PATCH net-next 6/6] net: macb: Add MACB_CAPS_QBV capability flag for IEEE 802.1Qbv support Vineeth Karumanchi
2025-07-23 19:05   ` Simon Horman
2025-07-29  9:42     ` Karumanchi, Vineeth
2025-07-24  0:46   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3cb5f213-3c06-46c5-a314-ce9fb5b1d175@tuxon.dev \
    --to=claudiu.beznea@tuxon.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=git@amd.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pabeni@redhat.com \
    --cc=vineeth.karumanchi@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).