Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1011261lqd; Thu, 25 Apr 2024 03:32:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuphl2mpcme0X/TAXakB4I2zCxLQl1/TGDGdV1DuacxiO8x/Rbt36ZP0wtHcBQV4NkRpWpfWgSZzhpXKSctuYVME3DsWFpKMhGaIialg== X-Google-Smtp-Source: AGHT+IG3vD11tXtNPJChGQjXWIgUbnLUlRUEUPrCcvoKo54b5AzR8UAULQl/6mfKKkEOordwYfHy X-Received: by 2002:a05:620a:261d:b0:790:98cb:752a with SMTP id z29-20020a05620a261d00b0079098cb752amr2838306qko.9.1714041166148; Thu, 25 Apr 2024 03:32:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714041166; cv=pass; d=google.com; s=arc-20160816; b=qCReQYx1eaVes79ygCWri+S4yw7S63DKEjrOIyQS5Up76vKx+CtaaU4n0AKTuyLYZn 4y1romsrVp0RarMHjKaWUAmPl0J5W6A/sWRZ+lLMsTVP8wvU8OYC/cmJi7Mzm+YJ/s+A E0XVn//HQwStLpeZe5v6ECpbY3DfCsKi0TWyCaQG2pmLjS0Kq0HAC8oLy2E4j4i5E/0f 5tl0Qw8My43jT+tbd36rpvYZqbC52wT+duXo+Mz75xhjaN1u1dN715PByQsajqjUVoMg KvZ0+zgPTn3iKlGiVD1/1yvP8GRswjcTSiWwNvfZ/luaTc4OPHU6j8kwi5XH1AQYMwzN 7r1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=28BXa8VxttMfc0TEExNi0FUUh3WfxcfWgxA0Q4ZUKPE=; fh=XjKJsMWW96YOKI8v/Pmmu7UxKZyVQXx69ZNzVOns/G8=; b=Te8f4DzEEup4aAOjEkWD0uRt/6n2PXWgqWoy/4MepHTeDdEgzCfnCwsPz6fhA0PFbw nNlCmFWgbHC9AgUIHZDlcN9SdzImEqKAXH+ho1JTvloylh+bWEWxOFe94geqlN41d8m/ dPugR38UPa4mlQu6O00N3rIe0BhF2XPAFas6Nz0STwL1C2qdCuk3yvENaJfDxsJXmC9t Uvfhzn85XfEvsjeKioDxY5jp3lNTnTFltgU6EmsepMAfBM3KPBv7oKErfAZnO0abk2Rq 79rWWg5h87PccdpTMiTzx8wy5M6PLFONUu0OZI/AP5l4b37+yQUDmBUGz73dJyMr3Rev x5xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=t8KtZk+e; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-158397-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bp12-20020a05620a458c00b0078f17284cbasi17004659qkb.317.2024.04.25.03.32.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 03:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158397-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=t8KtZk+e; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-158397-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158397-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B24C21C2539B for ; Thu, 25 Apr 2024 10:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABF652263A; Thu, 25 Apr 2024 10:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="t8KtZk+e" Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FB6E1BF40; Thu, 25 Apr 2024 10:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714041127; cv=none; b=IA/lJnl1mSOivb4xuiqSBPvYUsPINt6EA5tueNUArm3hjz1kM0PfjVlFvJLMBH2/DXp5rdiQ7bSeo8mKjSVqjwFZdIEA5HKspG51S3r/Pk1hOHLMTVZLcpfCgyFgZuvGCTjGaV1aoo2NFOR5AHb7RYJgfYKJq+cJkRwxt4Ts2/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714041127; c=relaxed/simple; bh=RMkbX26fdGoh43r6FT0+j6A0gxpNeQAV1acti6JwF98=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QqgABKEAwuyJImRq8mw0TPc5tE+DqGPRjIr6HtXWz8En56RTJ7lXLsfMZKsZL70bPHrOtTM5gju2NwddVOS86jLTpv2aKhxIFHQN59ntGvYBFFuyqBiVk7/b6QdDJMRMWsxJ+Ws/6/HCGHcQBERo1iKXkdDUIyPNHBTLinPUmbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=t8KtZk+e; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43PAVjsQ124968; Thu, 25 Apr 2024 05:31:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1714041105; bh=28BXa8VxttMfc0TEExNi0FUUh3WfxcfWgxA0Q4ZUKPE=; h=From:To:CC:Subject:Date; b=t8KtZk+ecxXD8doaTgt1wGov/UDpusI/gGnUiENiBh+P1TO8UBQw8psil/SXcF9eq wvDmT7hSS6o30ZSIhgZso5P2mikYF+8aGBtg+keEGPy4Jm4e9RpZT1lIUzG2kkUtGb 5+tO050xIM6jnIqS0fjCt8GGzbuC4pz/COsdWPSk= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43PAVjg8056078 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 25 Apr 2024 05:31:45 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 25 Apr 2024 05:31:44 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 25 Apr 2024 05:31:44 -0500 Received: from localhost (chintan-thinkstation-p360-tower.dhcp.ti.com [172.24.227.220]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43PAVim4024030; Thu, 25 Apr 2024 05:31:44 -0500 From: Chintan Vankar To: Tanmay Patil , =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= , Simon Horman , Roger Quadros , Vladimir Oltean , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , , , , CC: , , Chintan Vankar Subject: [PATCH net-next] net: ethernet: ti: am65-cpsw-qos: Add support to taprio for past base_time Date: Thu, 25 Apr 2024 16:01:42 +0530 Message-ID: <20240425103142.1999123-1-c-vankar@ti.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 From: Tanmay Patil 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 Signed-off-by: Chintan Vankar --- 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(-) 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 #include +#include #include #include #include @@ -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) { -- 2.34.1