diff mbox series

[net-next] net: ethernet: ti: am65-cpsw-qos: Add support to taprio for past base_time

Message ID 20240425103142.1999123-1-c-vankar@ti.com (mailing list archive)
State Accepted
Commit d63394abc923093423c141d4049b72aa403fff07
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: ethernet: ti: am65-cpsw-qos: Add support to taprio for past base_time | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 96 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-25--15-00 (tests: 995)

Commit Message

Chintan Vankar April 25, 2024, 10:31 a.m. UTC
From: Tanmay Patil <t-patil@ti.com>

If the base-time for taprio is in the past, start the schedule at the time
of the form "base_time + N*cycle_time" where N is the smallest possible
integer such that the above time is in the future.

Signed-off-by: Tanmay Patil <t-patil@ti.com>
Signed-off-by: Chintan Vankar <c-vankar@ti.com>
---

This patch is based on net-next commit d80687161271.

 drivers/net/ethernet/ti/am65-cpsw-qos.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Simon Horman April 27, 2024, 1:31 p.m. UTC | #1
On Thu, Apr 25, 2024 at 04:01:42PM +0530, Chintan Vankar wrote:
> From: Tanmay Patil <t-patil@ti.com>
> 
> If the base-time for taprio is in the past, start the schedule at the time
> of the form "base_time + N*cycle_time" where N is the smallest possible
> integer such that the above time is in the future.
> 
> Signed-off-by: Tanmay Patil <t-patil@ti.com>
> Signed-off-by: Chintan Vankar <c-vankar@ti.com>

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org April 29, 2024, 5:20 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 25 Apr 2024 16:01:42 +0530 you wrote:
> From: Tanmay Patil <t-patil@ti.com>
> 
> If the base-time for taprio is in the past, start the schedule at the time
> of the form "base_time + N*cycle_time" where N is the smallest possible
> integer such that the above time is in the future.
> 
> Signed-off-by: Tanmay Patil <t-patil@ti.com>
> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
> 
> [...]

Here is the summary with links:
  - [net-next] net: ethernet: ti: am65-cpsw-qos: Add support to taprio for past base_time
    https://git.kernel.org/netdev/net-next/c/d63394abc923

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/am65-cpsw-qos.c b/drivers/net/ethernet/ti/am65-cpsw-qos.c
index 16f192a5b160..fa96db7c1a13 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-qos.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-qos.c
@@ -9,6 +9,7 @@ 
 
 #include <linux/pm_runtime.h>
 #include <linux/math.h>
+#include <linux/math64.h>
 #include <linux/time.h>
 #include <linux/units.h>
 #include <net/pkt_cls.h>
@@ -837,6 +838,7 @@  static int am65_cpsw_taprio_replace(struct net_device *ndev,
 	struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 	struct am65_cpts *cpts = common->cpts;
 	struct am65_cpsw_est *est_new;
+	u64 cur_time, n;
 	int ret, tact;
 
 	if (!netif_running(ndev)) {
@@ -888,13 +890,21 @@  static int am65_cpsw_taprio_replace(struct net_device *ndev,
 	if (tact == TACT_PROG)
 		am65_cpsw_timer_stop(ndev);
 
-	if (!est_new->taprio.base_time)
-		est_new->taprio.base_time = am65_cpts_ns_gettime(cpts);
-
 	am65_cpsw_port_est_get_buf_num(ndev, est_new);
 	am65_cpsw_est_set_sched_list(ndev, est_new);
 	am65_cpsw_port_est_assign_buf_num(ndev, est_new->buf);
 
+	/* If the base-time is in the past, start schedule from the time:
+	 * base_time + (N*cycle_time)
+	 * where N is the smallest possible integer such that the above
+	 * time is in the future.
+	 */
+	cur_time = am65_cpts_ns_gettime(cpts);
+	if (est_new->taprio.base_time < cur_time) {
+		n = div64_u64(cur_time - est_new->taprio.base_time, est_new->taprio.cycle_time);
+		est_new->taprio.base_time += (n + 1) * est_new->taprio.cycle_time;
+	}
+
 	am65_cpsw_est_set(ndev, 1);
 
 	if (tact == TACT_PROG) {