Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4193857rwd; Tue, 30 May 2023 01:40:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pzmGp+JGuI8CZMwCIpCI1X18LalmMG3hawU2HDhT0QzFXTb/WHI/Mrwmm2sQZMUBSXyW2 X-Received: by 2002:a05:6a20:549a:b0:10f:fea:1997 with SMTP id i26-20020a056a20549a00b0010f0fea1997mr2035025pzk.5.1685436019929; Tue, 30 May 2023 01:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685436019; cv=none; d=google.com; s=arc-20160816; b=eDgs3qo0LgMETnyOTd3w5sLfsz9BAyyajxKNu0XTm+w4PBFDjFrWCZP5pRQXSYDUdu k1I4HvVAV2w7RbWGJYIplVb4OLQ3V56YKWRrotT9wIzIqiTachHwt6LyhFXwcNE6W0Vl 5r0wgHUDyC+xftiNk73vP+KJCoI/fuCKtGhTmunEjlRza/qgXZCRDbAp+yTDIIMS63C3 JCs1ZOWA21HVY29qJWjvQhbb6qMYIt4Mu/AD77fDwEFsLbc9gW2h77MqTiQMcSYSE0aS JDl+CYVHpRZfb5BWkJbuch4D/9gBdv+4xFcbIl6uzVfwErKjDRLcRQ77IZSZ0IkBOPBo U4Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=RVxapAUbS67rQrQwJsX11MSKl0ekjRrWTXgidy1owkc=; b=HR8ZnjwxQCWw2pyNmufnVUT9DO5gaf0AX4fgiqYJ5Mv32BqTvTbPEb71lghjqAgbDr W3Z95tYpYVoWMSAwXVoksnKRP8LrJ20okYn9u3EupTICUTm5ZKNMOJQBdhgyv4TcikYW 6iJd1YOycRC5FMzS1yIb1LPKIe7xz29cGR2yENhidKyzkMqvEvLMVHVFXP+WznYeL2Zq 7QLlloA2H3YygMmS9GdI0f8QsusUZPlVM/QMo5YCdDyGJzrhZVbSTOfmGIU34u/gK5GJ x9lvowWEIfFXNmM9l0XjccwJyP/mRwyznISi94UJ6Sox0m0Ydl2TMmnFZuVWr45WsLM/ pBwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="gRCEM/u5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a17090a19c500b002536f332d07si993553pjj.149.2023.05.30.01.40.05; Tue, 30 May 2023 01:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="gRCEM/u5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbjE3I1Y (ORCPT + 99 others); Tue, 30 May 2023 04:27:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjE3I1W (ORCPT ); Tue, 30 May 2023 04:27:22 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1147B0; Tue, 30 May 2023 01:27:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685435241; x=1716971241; h=from:to:cc:subject:date:message-id; bh=Y1u5VKUrzfq/TNpbW/rgb44i5VtQdp1XEdoxN1+4FaQ=; b=gRCEM/u5HJ7eLgm0k651uKrFITbUXG9FFQmUuF/NZCPjGxfRAsHBkWjg Pp1bnA9TPSoZGPIOQHHo4ZGBeZBecuQij/DN6aQMahf/AEevN5Z7uyTHv zupwwTOiHsV3iMgSlweFY7QmbHyT1aOVJvY2JiY5uP34SKoWf1caMzhKb KHUAW3lqWTxBpvFm300E8MMM9mWzQ+gozdl/9ViM0AaCfJxvfSC3mfEdg TF8ZdxsIv01gjrEgtuKJ7AKXK7UjE1ckuT77oecMP2fZnhOgrSvCFhn8J vxmRXSlPsSSonQTI+fMiLZHJkx7B6vP0K7V3pahLo0nxPZeIkaZsxkw87 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="383107721" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="383107721" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 01:27:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="953034513" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="953034513" Received: from zulkifl3-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga006.fm.intel.com with ESMTP; 30 May 2023 01:27:18 -0700 From: Muhammad Husaini Zulkifli To: netdev@vger.kernel.org, vinicius.gomes@intel.com, kuba@kernel.org, vladimir.oltean@nxp.com, pabeni@redhat.com Cc: linux-kernel@vger.kernel.org, tee.min.tan@linux.intel.com, muhammad.husaini.zulkifli@intel.com, edumazet@google.com Subject: [PATCH net v1] net/sched: taprio: fix cycle time extension logic Date: Tue, 30 May 2023 16:25:41 +0800 Message-Id: <20230530082541.495-1-muhammad.husaini.zulkifli@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-4.1 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tan Tee Min According to IEEE Std. 802.1Q-2018 section Q.5 CycleTimeExtension, the Cycle Time Extension variable allows this extension of the last old cycle to be done in a defined way. If the last complete old cycle would normally end less than OperCycleTimeExtension nanoseconds before the new base time, then the last complete cycle before AdminBaseTime is reached is extended so that it ends at AdminBaseTime. This patch extends the last entry of last complete cycle to AdminBaseTime. Fixes: a3d43c0d56f1 ("taprio: Add support adding an admin schedule") Signed-off-by: Tan Tee Min Signed-off-by: Muhammad Husaini Zulkifli --- net/sched/sch_taprio.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 76db9a10ef504..ef487fef83fce 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -99,6 +99,7 @@ struct taprio_sched { u32 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ u32 fp[TC_QOPT_MAX_QUEUE]; /* only for dump and offloading */ u32 txtime_delay; + bool sched_changed; }; struct __tc_taprio_qopt_offload { @@ -934,8 +935,10 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) admin = rcu_dereference_protected(q->admin_sched, lockdep_is_held(&q->current_entry_lock)); - if (!oper) + if (!oper || q->sched_changed) { + q->sched_changed = false; switch_schedules(q, &admin, &oper); + } /* This can happen in two cases: 1. this is the very first run * of this function (i.e. we weren't running any schedule @@ -962,20 +965,27 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) end_time = ktime_add_ns(entry->end_time, next->interval); end_time = min_t(ktime_t, end_time, oper->cycle_end_time); + if (should_change_schedules(admin, oper, oper->cycle_end_time) && + list_is_last(&next->list, &oper->entries)) { + u32 ori_interval = next->interval; + + next->interval += ktime_sub(sched_base_time(admin), end_time); + oper->cycle_time += next->interval - ori_interval; + end_time = sched_base_time(admin); + oper->cycle_end_time = end_time; + q->sched_changed = true; + } + for (tc = 0; tc < num_tc; tc++) { - if (next->gate_duration[tc] == oper->cycle_time) + if (next->gate_duration[tc] == oper->cycle_time) { next->gate_close_time[tc] = KTIME_MAX; - else + } else if (q->sched_changed && next->gate_duration[tc]) { + next->gate_close_time[tc] = end_time; + next->gate_duration[tc] = next->interval; + } else { next->gate_close_time[tc] = ktime_add_ns(entry->end_time, next->gate_duration[tc]); - } - - if (should_change_schedules(admin, oper, end_time)) { - /* Set things so the next time this runs, the new - * schedule runs. - */ - end_time = sched_base_time(admin); - switch_schedules(q, &admin, &oper); + } } next->end_time = end_time; -- 2.17.1