From patchwork Wed Jun 14 14:07:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1287649vqr; Wed, 14 Jun 2023 07:08:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CmJvtNPWzSmcOEotra4vMmWzOtiDgqjGejWU6tANs+nf5JftkiMyPOf1SMGzIp7OtPUJg X-Received: by 2002:a17:90a:1da:b0:25e:542d:acc with SMTP id 26-20020a17090a01da00b0025e542d0accmr937105pjd.8.1686751721759; Wed, 14 Jun 2023 07:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686751721; cv=none; d=google.com; s=arc-20160816; b=Cm17jx+lJhTDWcEE6UO8qO6v4zX9chkEdWPzAkjFlV2o+zYcNvDZWujBWuRI+aUpFN kN+Wi3egfXRTcWb8nvvUthKNucI+Ueh9/J06FWE53l1nhvH4rLB/vEfv5c1atSxOWW7d 4CLDJh/GahucheFSNwA7UbIAQv0vlQotXPhCXvf4Oz6I+VKmd5UckTGHsidIB6ll9Qbk AKy0d3Lhtv5vWRlYYVB6utYiRO2TJNli4OE9I+h0hixzKP8TFod+iFwjBQOiWKCuN0dW QYcHp9uANCi+kq3baAxO61fLzWV59RpK0LzHqMIHtNGHZAemG77o4B5kCfqjAiXeGwmU w8RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=g0kxT8UuGZDLapzulcDZLbRyKl1FZxwDwVUyDtTqgTM=; b=vwZcP2oLUlcKQrh9vXCwwDVZBt6AeGOXO7bNXRI4b/as742zVTy3tVaqptPzvgC4AY orQ8n8t9XDfQ9Ja8aDoXvPEUexO+N1+vhH3IA2f+XZev+zrtU9tE+m4eGPaJcmYdvCGj dhSGZ2vCyUA77alvWRA5Je/0WSXf+EY96aEyOZUZlkquN2Ksf7MZOrpprr3kg1zcOtOP 94bDIIsYzu1c5TqA6lQr6CC5zw7AMMQtZoKw3hlZsA5cdF18KEDyg5WSBQ5UAbXXMetf qp6P2vXG0bOPAUBLwiQS/MrNsIdEygkwI+/LPp0RY2teEwobrkT1ymBqNPheIozJLCkn 4Lpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OPdXmQc2; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fg+FJIuZ; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mm23-20020a17090b359700b0025baa49fa95si6566764pjb.1.2023.06.14.07.07.59; Wed, 14 Jun 2023 07:08:41 -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=@linutronix.de header.s=2020 header.b=OPdXmQc2; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=fg+FJIuZ; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245372AbjFNOHe (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245364AbjFNOHc (ORCPT ); Wed, 14 Jun 2023 10:07:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3284FCD; Wed, 14 Jun 2023 07:07:31 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0kxT8UuGZDLapzulcDZLbRyKl1FZxwDwVUyDtTqgTM=; b=OPdXmQc2iWgpOGq0YWxc+qabH7RHLIUl2krzJQZ/IFJrv+4YJ20rpcADfaL7nS836gEDkx u4k0lsUWgNLXxRHbEWEZhhjGjkogxaUAsCkIWEvkhBnKbmvqfgF93pXrlB/J5N6daqZTVC tfpiBZ8W2Y84WiR4aYUnAFU6Bzz0bvQmh6OSgpW4ltoSQt0QDek19ddsEzhRwHslcL/K8y HDWQUEKdjR5Hgm/nXJ59WnPYocD/Bo2as8F4eLbD7xUoCa+BWl/KOyeCSJcNsbaHfH/vOk CaD/Vje7dkrxvmO0n1OLjd/grqfTXBiuSR0wnJIYR7WBuH4xExAi6Zroluz+Ag== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0kxT8UuGZDLapzulcDZLbRyKl1FZxwDwVUyDtTqgTM=; b=fg+FJIuZ8ojp+l7iqa7Xhk+uBKHrS/vn3/BdUvbjOjMeCFYoYcnCe51pBDUV1ILSfW5SCh DkHLTPS/Tw0hrhCA== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 1/6] igc: Rename qbv_enable to taprio_offload_enable Date: Wed, 14 Jun 2023 16:07:09 +0200 Message-Id: <20230614140714.14443-2-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768687373379336635?= X-GMAIL-MSGID: =?utf-8?q?1768687373379336635?= In the current implementation the flags adapter->qbv_enable and IGC_FLAG_TSN_QBV_ENABLED have a similar name, but do not have the same meaning. The first one is used only to indicate taprio offload (i.e. when igc_save_qbv_schedule was called), while the second one corresponds to the Qbv mode of the hardware. However, the second one is also used to support the TX launchtime feature, i.e. ETF qdisc offload. This leads to situations where adapter->qbv_enable is false, but the flag IGC_FLAG_TSN_QBV_ENABLED is set. This is prone to confusion. The rename should reduce this confusion. Since it is a pure rename, it has no impact on functionality. Fixes: e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc.h | 2 +- drivers/net/ethernet/intel/igc/igc_main.c | 6 +++--- drivers/net/ethernet/intel/igc/igc_tsn.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc.h b/drivers/net/ethernet/intel/igc/igc.h index 18d4af934d8c..4d22662e8021 100644 --- a/drivers/net/ethernet/intel/igc/igc.h +++ b/drivers/net/ethernet/intel/igc/igc.h @@ -186,7 +186,7 @@ struct igc_adapter { ktime_t base_time; ktime_t cycle_time; - bool qbv_enable; + bool taprio_offload_enable; u32 qbv_config_change_errors; /* OS defined structs */ diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 88145c30c919..56117846b8da 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6115,16 +6115,16 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, switch (qopt->cmd) { case TAPRIO_CMD_REPLACE: - adapter->qbv_enable = true; + adapter->taprio_offload_enable = true; break; case TAPRIO_CMD_DESTROY: - adapter->qbv_enable = false; + adapter->taprio_offload_enable = false; break; default: return -EOPNOTSUPP; } - if (!adapter->qbv_enable) + if (!adapter->taprio_offload_enable) return igc_tsn_clear_schedule(adapter); if (qopt->base_time < 0) diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c index 94a2b0dfb54d..c6636a7264d5 100644 --- a/drivers/net/ethernet/intel/igc/igc_tsn.c +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c @@ -37,7 +37,7 @@ static unsigned int igc_tsn_new_flags(struct igc_adapter *adapter) { unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED; - if (adapter->qbv_enable) + if (adapter->taprio_offload_enable) new_flags |= IGC_FLAG_TSN_QBV_ENABLED; if (is_any_launchtime(adapter)) From patchwork Wed Jun 14 14:07:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1299039vqr; Wed, 14 Jun 2023 07:23:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4kW+AFJA+BS1bcXkKbagkHeE0aFEGvY6Hn60+BROg2UBoX3EOQh2AJSFDcayjpw0U4Ffhq X-Received: by 2002:a05:6a20:734d:b0:10c:6b27:6415 with SMTP id v13-20020a056a20734d00b0010c6b276415mr1888886pzc.8.1686752583116; Wed, 14 Jun 2023 07:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686752583; cv=none; d=google.com; s=arc-20160816; b=jkwMgKxkAeCMybBdiOFq0eHrST8zOOCLn0d2/h6cmJMoXXBV+0TtqACBEDa/c50WBr q0gS/XTXrKeU6RwkzGkiNOWcdUu9CYhcUel24R/ckPkL7eUvGrYXK9iedskX0v/8R+z1 vvR8AR/w65dSNcGdGqEw9Hwcnqp/0Vj1hPZc5DR8IRULWAG3s/ytCIgxsudFAKkTEXzm R4YqYcHhnRctWNu5mEX8PKoKlZm3U5H9AjzZbmaAyRa9BgB45WvXG1HhZjohyv8IsmYy WEBqyvAWl3nYL+52b1+9vXbLll2km4V3AjVVHiaKsqlReeAHXmELtup1xreS9OgtLNuy tkGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=E4YEaT+aOUEFj7DigAgxbM4RznI4oXWfWpU3L2Qmto8=; b=cBpuXSJf0BCQjKAbRNSICBtmmEjumGTs0jNGbheg/nNA5pgURrHY3Akl3mDtzxL7A+ cGUhhzMEq+Ps5CXIh8yq/ha9dFCe42M4iatT7KOpoikhuwP30LAewJiH/e77iE3DEHXa cg4Qv+70/h5khiqFr4L6R+YvxsM7dBlm12uthjNkp0aUYEmDmBoSwfoIyWZTzS/b5TKP wRHKFMCWWam5Tdcr9dnbWQKE2nmlFeK47nMY/xbWQPZg4Gj5T+BIJEPdyO+Hz/NAb8Hv BGmgiBzhAPhJ7KzH5PIPwILASNDzkT3yF46rMQcPZ7fz4axqqq/7CSEg0xZr2Ztkgcgv 5HIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rjLACA+D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CW5qpZOA; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a656ab1000000b0053ee9b2181fsi7197820pgu.118.2023.06.14.07.22.38; Wed, 14 Jun 2023 07:23:03 -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=@linutronix.de header.s=2020 header.b=rjLACA+D; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CW5qpZOA; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245371AbjFNOHi (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245365AbjFNOHe (ORCPT ); Wed, 14 Jun 2023 10:07:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3974B19B5; Wed, 14 Jun 2023 07:07:32 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4YEaT+aOUEFj7DigAgxbM4RznI4oXWfWpU3L2Qmto8=; b=rjLACA+DkXLZcQ8DPRtCD+qKMo3cdMoczMFVfOTbljMvVI1NcqDBFtd1CowbR+vc9Lw1nl OQkVYe86r2bM7oUXQD+jXcV2R4KHwEDFHofHRoc8wMTSoia3jYXGYDGItfXxntszkKP2i1 Smg0tlGgkA9aIgQrr/BZrDg3UDYZa1Si2zxbqKlJHKFDb6r9vpiqdcaUqZBPeQcvMRbUKm YICM057FYGS7+a/ioswIVImlEwWUL2neuYHYuwVwRd0hqUnjL3UKdJqaVWWN+iQSBDpOhs UikjIFKnD4IVL3sIYWttT4bpp+92PiK7nM5osOMOfpRihV02MAF+c3nk7cYbqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4YEaT+aOUEFj7DigAgxbM4RznI4oXWfWpU3L2Qmto8=; b=CW5qpZOAMqDU1sPWk664/S4CRHxPNDe9AjuXmorNFQopfnw+ZTuA7G8d5OIaYDMVmiuVo9 tpyerRmHrWiRV7CQ== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 2/6] igc: Do not enable taprio offload for invalid arguments Date: Wed, 14 Jun 2023 16:07:10 +0200 Message-Id: <20230614140714.14443-3-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768688276343284765?= X-GMAIL-MSGID: =?utf-8?q?1768688276343284765?= Only set adapter->taprio_offload_enable after validating the arguments. Otherwise, it stays set even if the offload was not enabled. Since the subsequent code does not get executed in case of invalid arguments, it will not be read at first. However, by activating and then deactivating another offload (e.g. ETF/TX launchtime offload), taprio_offload_enable is read and erroneously keeps the offload feature of the NIC enabled. This can be reproduced as follows: # TAPRIO offload (flags == 0x2) and negative base-time leading to expected -ERANGE sudo tc qdisc replace dev enp1s0 parent root handle 100 stab overhead 24 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time -1000 \ sched-entry S 01 300000 \ flags 0x2 # IGC_TQAVCTRL is 0x0 as expected (iomem=relaxed for reading register) sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 # Activate ETF offload sudo tc qdisc replace dev enp1s0 parent root handle 6666 mqprio \ num_tc 3 \ map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 \ queues 1@0 1@1 2@2 \ hw 0 sudo tc qdisc add dev enp1s0 parent 6666:1 etf \ clockid CLOCK_TAI \ delta 500000 \ offload # IGC_TQAVCTRL is 0x9 as expected sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 # Deactivate ETF offload again sudo tc qdisc delete dev enp1s0 parent 6666:1 # IGC_TQAVCTRL should now be 0x0 again, but is observed as 0x9 sudo pcimem /sys/bus/pci/devices/0000:01:00.0/resource0 0x3570 w*1 Fixes: e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_main.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 56117846b8da..122158b321d5 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6091,6 +6091,7 @@ static int igc_tsn_clear_schedule(struct igc_adapter *adapter) adapter->base_time = 0; adapter->cycle_time = NSEC_PER_SEC; + adapter->taprio_offload_enable = false; adapter->qbv_config_change_errors = 0; for (i = 0; i < adapter->num_tx_queues; i++) { @@ -6113,20 +6114,12 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, size_t n; int i; - switch (qopt->cmd) { - case TAPRIO_CMD_REPLACE: - adapter->taprio_offload_enable = true; - break; - case TAPRIO_CMD_DESTROY: - adapter->taprio_offload_enable = false; - break; - default: - return -EOPNOTSUPP; - } - - if (!adapter->taprio_offload_enable) + if (qopt->cmd == TAPRIO_CMD_DESTROY) return igc_tsn_clear_schedule(adapter); + if (qopt->cmd != TAPRIO_CMD_REPLACE) + return -EOPNOTSUPP; + if (qopt->base_time < 0) return -ERANGE; @@ -6138,6 +6131,7 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, adapter->cycle_time = qopt->cycle_time; adapter->base_time = qopt->base_time; + adapter->taprio_offload_enable = true; for (n = 0; n < qopt->num_entries; n++) { struct tc_taprio_sched_entry *e = &qopt->entries[n]; From patchwork Wed Jun 14 14:07:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1288051vqr; Wed, 14 Jun 2023 07:09:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ57F0K33Jno7iXJx4jdIz4mW6otX+F0e42kK1qyMRIbJeacd5E/Jx8d0QQbhb1zbQJ914Zc X-Received: by 2002:a17:902:eecc:b0:1af:b957:718b with SMTP id h12-20020a170902eecc00b001afb957718bmr10972825plb.39.1686751748306; Wed, 14 Jun 2023 07:09:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686751748; cv=none; d=google.com; s=arc-20160816; b=x3fEWGkMQXaiU42K6GjFqdBd5PihSvRLWmLIO6oIkjmp7ikOBDxsPOL1bEGK/3O7YL tbrAGTW0P3jHQdXPXuNLsr7iQK/5KxZH3B5bS8ikwL8VfrPuMf15OyvsAPSz5uUbLt01 vGKiJbTXh6Q8V0fmY0wzWgKrAg1DZFNGeeQNWLKlt2EL9Y2ub19J8KTr7aEXyhGNXnvL xOdKZtDt+SEW6DtpCBaU+XxAqje5u2uhVVsoCcOPlPveLZwpObclMqLoM3iT6Lt6nkOm sFJI547XLnrgaKWuuLIcwQp7UuYGR+JWuSyfU4aW8EWlvrrcSKTBhGI6vJcbJlhV3gqo MNng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=x6Htu7np35GOzuU2rwqMOLnSJ2z47YfJkRbHy1TCsl0=; b=X8mNMgA8q7Tx1yu6Ds+U0f1VF+BB0V3DWYJrqaT/gZwMst8Db3n1iXyctAeN1xmPer A40S7qmj4XOqzsGnyyuCtxUUdWR+nEkxiTYZTBf6sGDBC+RZ06u8D2niHaofPk3X1ZSP Ch57KA0GqAEFNuzDGuI65E2yMYi9T4Kx/QMueoVHzo4Nqs6joEngLgN5Pqmk8ayfTcz9 B56W7TmR8ueYrBqkjVt27Z10msZNmZhoRqVpKIBj4yMhgMciAycFyqJzK0YWBfvXsEnj yVTCXSpxLMTuZkFmyJnI/67JHX9UMxqG/OwKZFcq2A0hYE7LnjVDOTUlTFu6fIMDU51h G3NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1+8JZxpl; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a170902d48100b001b3f4e1762asi3058732plg.490.2023.06.14.07.08.22; Wed, 14 Jun 2023 07:09:08 -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=@linutronix.de header.s=2020 header.b=1+8JZxpl; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245407AbjFNOHo (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245370AbjFNOHe (ORCPT ); Wed, 14 Jun 2023 10:07:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5EECD; Wed, 14 Jun 2023 07:07:33 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x6Htu7np35GOzuU2rwqMOLnSJ2z47YfJkRbHy1TCsl0=; b=1+8JZxple640L2i78OWj0AT4lW7BSRG5mTek6g1HCJErHIPJWpbpZbA8770+hU+H+m0tNb c9BnZ8Psh4CSh/9fzNZmdOxxeQ2hs3QOXMSxanhaAq7kgy8pyfqTNpd9Pkk8zVadW2EqGg EHQnvyIaPn/G1d5Uws7atr6Ma3KiSfbQ8PQ6+j/C7XxECFdHZtDqNkZ7XoW90Oy36m5gGm NDleKInVyFDzlbfFnAK6BXpJrUyKA/ggBwhnEwJbDOWCVgZ5XKbGumlrZckJHJ+B59NqtC vykd4w1CGkQtniToM4Nce/jXtkl0xIgA8tz4o8zkfydewwK0vEH42Qg5/ID54w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x6Htu7np35GOzuU2rwqMOLnSJ2z47YfJkRbHy1TCsl0=; b=slM6BJwhD6d50c957awDJHQXUZNZ9MEQweTUaWR3uNdodBTiBsjm6mW1Cvxg+B6E0s8OkD 9nYgz1dY/rUvzFBg== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 3/6] igc: Handle already enabled taprio offload for basetime 0 Date: Wed, 14 Jun 2023 16:07:11 +0200 Message-Id: <20230614140714.14443-4-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768687401491670684?= X-GMAIL-MSGID: =?utf-8?q?1768687401491670684?= Since commit e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") it is possible to enable taprio offload with a basetime of 0. However, the check if taprio offload is already enabled (and thus -EALREADY should be returned for igc_save_qbv_schedule) still relied on adapter->base_time > 0. This can be reproduced as follows: # TAPRIO offload (flags == 0x2) and base-time = 0 sudo tc qdisc replace dev enp1s0 parent root handle 100 stab overhead 24 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time 0 \ sched-entry S 01 300000 \ flags 0x2 # The second call should fail with "Error: Device failed to setup taprio offload." # But that only happens if base-time was != 0 sudo tc qdisc replace dev enp1s0 parent root handle 100 stab overhead 24 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time 0 \ sched-entry S 01 300000 \ flags 0x2 Fixes: e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 122158b321d5..35ace8d338a5 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -6123,7 +6123,7 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter, if (qopt->base_time < 0) return -ERANGE; - if (igc_is_device_id_i225(hw) && adapter->base_time) + if (igc_is_device_id_i225(hw) && adapter->taprio_offload_enable) return -EALREADY; if (!validate_schedule(adapter, qopt)) From patchwork Wed Jun 14 14:07:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:640b:b0:12b:d5da:ddc2 with SMTP id f11csp1348379rwh; Wed, 14 Jun 2023 07:45:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7W+7N71zYCyu6GnjdFs5rkDc1wjCr1IaVGNck2HE3te5DAxLE5UoJlgywUzkDhXzCAKCYA X-Received: by 2002:a05:6402:110f:b0:518:30f2:2823 with SMTP id u15-20020a056402110f00b0051830f22823mr9405052edv.20.1686753911399; Wed, 14 Jun 2023 07:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753911; cv=none; d=google.com; s=arc-20160816; b=j1sUWvAKLAfOnyQ6J4lJFkxYLWPVexobplUYhJ3wmDeHOpdXaEVr2x07v8g0HZ1YM+ ql8Hy3Sy1p6OwAxoPHlUTtSth6UOa/5r8RYukXla0AwW9FEozwt+K5Y5+WAURm+vz8Xu JRMf1vPw1fYa6tfNu0AXV4xLgGcas2AiQHPKIcCwlHIsraU6rpBTR7kDCYMtzShVg0z+ CBLv0mk6v93a+1TCqvERcEF7bhQ728l5E/+OdSJ+danU/8AMoeCX5ilIxdXj9uAsoxbk 53rdL1sGcMEt7NBqoja9/kQvHLbYpJHaoBcgqFk0kx45azNrGWInFk+KJAgQGp0M7sSd G3+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=TCMbNNv1wUCpp0eUsLbLvQKi9uBHfNttKgJxjYAeb0M=; b=cX7LZcAoelD2WOpb547aZ3Y/zL68NOGyIgJPX1K3ol0lU7gEX5RjidNgTKYnmPJdj+ 9SyGYHZQX7OuCip3zDwf1vHS9uB7ANIhCg6md3FP0JTYDX0BdOTbfT1a3d5jLC49sQ/r 9RnmMTyB2pHhAv4OJSMDb6aqW52gP39oypBobvIlenfgZD1odPAgS/nmqISws3uZGGvp 78ZN+bVTph7vPtrcSye33EFLArwJYPO3+6G/DAYkFbpG4+X12aIXHw8/xqV6LqC6XnWG MNBOJOg+7YreBzlZkhbRF8C1ky0xP5wT7eV39L/bWrSRiIhifTJErnYK1VSpkjG0uZ4N RaJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="y3apSj/1"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4wvkId7p; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020aa7d0c2000000b0050a021d39besi8794996edo.454.2023.06.14.07.44.42; Wed, 14 Jun 2023 07:45:11 -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=@linutronix.de header.s=2020 header.b="y3apSj/1"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4wvkId7p; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245412AbjFNOHr (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245364AbjFNOHh (ORCPT ); Wed, 14 Jun 2023 10:07:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 562FA1BE5; Wed, 14 Jun 2023 07:07:34 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TCMbNNv1wUCpp0eUsLbLvQKi9uBHfNttKgJxjYAeb0M=; b=y3apSj/1vJ6DYmeRmtuz58yggKV/HUKT/ugbiKU51svYY4S7rF0nFts3eNFdT4vrYcwIb4 0gFFhhcWdvwGUTGZYVdzMMrHQhbN4ffJSx2y+GYO9Ql1OVwUYF2H4PvV4z3mX2DEbhdlWX BExwMnc4Me9dpiUusAf863WxGpSNMRsl88WWAjDLoRKfh5gOG9df7dOrl8d5Et8zTZgB3l vHlj8eDL3UtLgppTuUt5rYQL/bW8lr8J9zeroaaNIUs4ZP37MPZBIx34CM6CUv7grPSlx1 eTj52atV/m9E4QcSQDjgK0q4SGarto1XZ5eKL2955mvoCwCkX6fCr9XdWkoaAQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TCMbNNv1wUCpp0eUsLbLvQKi9uBHfNttKgJxjYAeb0M=; b=4wvkId7pYYzXqtq36DOtC/f7wZFtHHd/o9YUg5/t8OkzDtR3DsoCiV85Z5FybSDkQi0lzl 5V2zDazABw5qxdCQ== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 4/6] igc: No strict mode in pure launchtime/CBS offload Date: Wed, 14 Jun 2023 16:07:12 +0200 Message-Id: <20230614140714.14443-5-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768689669437648369?= X-GMAIL-MSGID: =?utf-8?q?1768689669437648369?= The flags IGC_TXQCTL_STRICT_CYCLE and IGC_TXQCTL_STRICT_END prevent the packet transmission over slot and cycle boundaries. This is important for taprio offload where the slots and cycles correspond to the slots and cycles configured for the network. However, the Qbv offload feature of the i225 is also used for enabling TX launchtime / ETF offload. In that case, however, the cycle has no meaning for the network and is only used internally to adapt the base time register after a second has passed. Enabling strict mode in this case would unneccesarily prevent the transmission of certain packets (i.e. at the boundary of a second) and thus interfers with the ETF qdisc that promises transmission at a certain point in time. Similar to ETF, this also applies to CBS offload that also should not be influenced by strict mode unless taprio offload would be enabled at the same time. This fully reverts commit d8f45be01dd9 ("igc: Use strict cycles for Qbv scheduling") but its commit message only describes what was already implemented before that commit. The difference to a plain revert of that commit is that it now copes with the base_time = 0 case that was fixed with commit e17090eb2494 ("igc: allow BaseTime 0 enrollment for Qbv") In particular, enabling strict mode leads to TX hang situations under high traffic if taprio is applied WITHOUT taprio offload but WITH ETF offload, e.g. as in sudo tc qdisc replace dev enp1s0 parent root handle 100 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time 0 \ sched-entry S 01 300000 \ flags 0x1 \ txtime-delay 500000 \ clockid CLOCK_TAI sudo tc qdisc replace dev enp1s0 parent 100:1 etf \ clockid CLOCK_TAI \ delta 500000 \ offload \ skip_sock_check and traffic generator sudo trafgen -i traffic.cfg -o enp1s0 --cpp -n0 -q -t1400ns with traffic.cfg #define ETH_P_IP 0x0800 { /* Ethernet Header */ 0x30, 0x1f, 0x9a, 0xd0, 0xf0, 0x0e, # MAC Dest - adapt as needed 0x24, 0x5e, 0xbe, 0x57, 0x2e, 0x36, # MAC Src - adapt as needed const16(ETH_P_IP), /* IPv4 Header */ 0b01000101, 0, # IPv4 version, IHL, TOS const16(1028), # IPv4 total length (UDP length + 20 bytes (IP header)) const16(2), # IPv4 ident 0b01000000, 0, # IPv4 flags, fragmentation off 64, # IPv4 TTL 17, # Protocol UDP csumip(14, 33), # IPv4 checksum /* UDP Header */ 10, 0, 48, 1, # IP Src - adapt as needed 10, 0, 48, 10, # IP Dest - adapt as needed const16(5555), # UDP Src Port const16(6666), # UDP Dest Port const16(1008), # UDP length (UDP header 8 bytes + payload length) csumudp(14, 34), # UDP checksum /* Payload */ fill('W', 1000), } and the observed message with that is for example igc 0000:01:00.0 enp1s0: Detected Tx Unit Hang Tx Queue <0> TDH TDT next_to_use next_to_clean buffer_info[next_to_clean] time_stamp next_to_watch <00000000245a4efb> jiffies desc.status <1048000> Fixes: d8f45be01dd9 ("igc: Use strict cycles for Qbv scheduling") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_tsn.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/igc/igc_tsn.c b/drivers/net/ethernet/intel/igc/igc_tsn.c index c6636a7264d5..63d410e7b876 100644 --- a/drivers/net/ethernet/intel/igc/igc_tsn.c +++ b/drivers/net/ethernet/intel/igc/igc_tsn.c @@ -133,8 +133,28 @@ static int igc_tsn_enable_offload(struct igc_adapter *adapter) wr32(IGC_STQT(i), ring->start_time); wr32(IGC_ENDQT(i), ring->end_time); - txqctl |= IGC_TXQCTL_STRICT_CYCLE | - IGC_TXQCTL_STRICT_END; + if (adapter->taprio_offload_enable) { + /* If taprio_offload_enable is set we are in "taprio" + * mode and we need to be strict about the + * cycles: only transmit a packet if it can be + * completed during that cycle. + * + * If taprio_offload_enable is NOT true when + * enabling TSN offload, the cycle should have + * no external effects, but is only used internally + * to adapt the base time register after a second + * has passed. + * + * Enabling strict mode in this case would + * unneccesarily prevent the transmission of + * certain packets (i.e. at the boundary of a + * second) and thus interfer with the launchtime + * feature that promises transmission at a + * certain point in time. + */ + txqctl |= IGC_TXQCTL_STRICT_CYCLE | + IGC_TXQCTL_STRICT_END; + } if (ring->launchtime_enable) txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT; From patchwork Wed Jun 14 14:07:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1312554vqr; Wed, 14 Jun 2023 07:41:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ESodAgL9wmClpDXptjA5YupPPQzZct14Ru24EjEUNDdlVMeI1+u4r2xh+BrKcZqKtoE0G X-Received: by 2002:a05:6358:7018:b0:12b:dc0e:d33e with SMTP id 24-20020a056358701800b0012bdc0ed33emr6217233rwo.23.1686753708335; Wed, 14 Jun 2023 07:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753708; cv=none; d=google.com; s=arc-20160816; b=vE8CcpOWOjDJH42oeLYeW9hEZIt5AcjQmkL5qw6Mfrd/mD/zrvP0MO8QjfQydNcrOy 3JyKYXxYG/7AZGYaULQk8UU+1zdC27hbXWHFwmpECJV9ISWfLsTL2qaLMtUUA1OnKFaq sgqNgVyGEjXgZEYN7FrbBFifYnFj/dyF+emBjzrvk9vqBJbu1sOUBWdx8NDfGtCKCiTm 4lSccwHkMOu616SFZQxOMUmbS8PIFWoVVBWmzps+h8VjWyELpGHYMtNmiXWB/acrB3sV CJJgRvi1u17cz3nW/QLFXoWhYSvMhnawssgfYCv2T+Y1gXC2jDzS6Pi3FDaewbyjwgY3 p7Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=TC7Wp5NlKZNJnsc4iMHhksCcpiK06fmD323se6b+ImQ6nznqa7frNDAVGjMle8eyx4 n+k96oxGUHKzV0nCP2t7NajmhAhmCCrUNoI5fLnsWAj+URvIyJcfLI0QVYzyHbp3P7AT A13Xox72zYZ6eIJaWLiq1fnojV3oh9hn0v5oN5ASxMphbbNkTw1peXrepRnhkXO+OXxt CBB4lgghQWa60SMTl9uB5jBiL8cClUn8Rvs+9SSen4IqKA2r9WZmajRdDtI/VT2Uo+TO maGRJrStg0XqsBKYT+meAm07BOAoQNW2KNMLXFdvVFRhtJc38T9o13AQbr4VZ/Uvkl7m AF7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e1jQpj4m; dkim=neutral (no key) header.i=@linutronix.de header.b=Zp2JPID6; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k190-20020a636fc7000000b0054402b987ecsi10880796pgc.803.2023.06.14.07.41.12; Wed, 14 Jun 2023 07:41:48 -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=@linutronix.de header.s=2020 header.b=e1jQpj4m; dkim=neutral (no key) header.i=@linutronix.de header.b=Zp2JPID6; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245424AbjFNOHw (ORCPT + 99 others); Wed, 14 Jun 2023 10:07:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245382AbjFNOHh (ORCPT ); Wed, 14 Jun 2023 10:07:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C22AF1BFD; Wed, 14 Jun 2023 07:07:35 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=e1jQpj4mpNOmUjLaTWrTqzJCKoe2XCIeX84UQxj8V+Ot1GjzyK4wF2ASVXOEk692Bue4FH RF58gFTXbaZbf5YM0srXUHwnnTSdsbvEtKVutDE4fZjqwpSfxclXybP9ChEfyK+k6hlcmD iE9nPwlA/d2G61e7QBFIQIFgKiIYkr/si5Tp4oje8P3Cxw/T2mde51yLfFKrI578U6LcVy LTvwFSJobm9cE/XYKDlOVi7YAsob56NxctFPKJ/TN8ru/S4o2OWm9tMnCdzRjkQ360zZzM aUlCS/ExREN7aG7u+9vnEW67tZoepFWuWuj1veN9j7I6KviTOd7oWFFEjHzbLw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7hUQE7jx0fknKMAL9e6sfNn3hoeeuEK7E2AxmOK/Kq4=; b=Zp2JPID67ZKSHdcUNmB9agCGcbNECGLtbWi+KbGEHVsxXJ21kzyORuLrlHdx8fSHFz8ZBM XPAv3YOD4EkoFkBg== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 5/6] igc: Fix launchtime before start of cycle Date: Wed, 14 Jun 2023 16:07:13 +0200 Message-Id: <20230614140714.14443-6-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768689456395029214?= X-GMAIL-MSGID: =?utf-8?q?1768689456395029214?= It is possible (verified on a running system) that frames are processed by igc_tx_launchtime with a txtime before the start of the cycle (baset_est). However, the result of txtime - baset_est is written into a u32, leading to a wrap around to a positive number. The following launchtime > 0 check will only branch to executing launchtime = 0 if launchtime is already 0. Fix it by using a s32 before checking launchtime > 0. Fixes: db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index 35ace8d338a5..ec8649751d19 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1010,7 +1010,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime, ktime_t base_time = adapter->base_time; ktime_t now = ktime_get_clocktai(); ktime_t baset_est, end_of_cycle; - u32 launchtime; + s32 launchtime; s64 n; n = div64_s64(ktime_sub_ns(now, base_time), cycle_time); From patchwork Wed Jun 14 14:07:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Kauer X-Patchwork-Id: 107991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:640b:b0:12b:d5da:ddc2 with SMTP id f11csp1349716rwh; Wed, 14 Jun 2023 07:47:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4j9XMdh+5Y+haev3QsPU5NgG0b+Owk20ZMuP+p8z5D0qPuUDKb4JbFph8EFlr3ohC9Sr61 X-Received: by 2002:a17:907:97cd:b0:97b:956f:e6b5 with SMTP id js13-20020a17090797cd00b0097b956fe6b5mr17235868ejc.23.1686754038526; Wed, 14 Jun 2023 07:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686754038; cv=none; d=google.com; s=arc-20160816; b=gUtp+7GGe0BWXf+EQsV4TKLgCSOAgZTR6uDHmfth/3PmFuGb80avX+slxJRFw0WuLT ohA5thjsz25Sv6I3OJMXh2tX/7s1i77iJomiirH/l/09L8WjmhgL9T7uiDCEqHmVMT5o qFnjbX0esNwpP0kF3qrFMAJzzNyM5SpiAp0jnScrSjDxvyqFfWnHQEGo/tQP40hoKygn JsvUPhwZbXGEY2ZpnPhdLEQbUcK5NM+aBr8um/T6nKwDTqDw3uIc3z5uHmVP4xsloJLy CNK6u+CMk7fs6h2ifNz60jPNYgXcmHDxugg2GSTKLBKS/YzT4hV+EYrtfLeBaEDTAE4O Km7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=Q1hYNE6dCTQuk9WVmYS4k1xlOgvvBhb4CT2be2LL7DM=; b=EnBaC8hVmbFg8kgcrMsNTj2RkY6/16rXUhbj0ZF1TLxDXQILoxPpRH/A4TByCXcshd +BHtlWPH9GFCEOcQPcCUvo8oo39zcG5gk66CN4V042l5juW8tSnMCtFpp9xf/l9fiFlT JLScnau8UsSR9K9oWoMf6UTEl/AtNxvsLvlSCbFR7XcF92zGFbgM97wokM65qlBVlnDx 8+HKxn9xRTSUnh/S+ZIQCwiJmmm+1G1wsDQ+5YmXGxRjoDcSOk0+swGjg0cKQZZeIEso wiD9SZq+CKPOBzxF17bKjwj3DHhnpRL5pem/TuzqwEqBGoVhf7o/AfKabLN9tHH8dh8a jrJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZZvYV1zw; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me26-20020a170906aeda00b00978028dabedsi7903319ejb.1001.2023.06.14.07.46.53; Wed, 14 Jun 2023 07:47:18 -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=@linutronix.de header.s=2020 header.b=ZZvYV1zw; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245229AbjFNOIB (ORCPT + 99 others); Wed, 14 Jun 2023 10:08:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245415AbjFNOHs (ORCPT ); Wed, 14 Jun 2023 10:07:48 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D25C1FE5; Wed, 14 Jun 2023 07:07:40 -0700 (PDT) From: Florian Kauer DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686751659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q1hYNE6dCTQuk9WVmYS4k1xlOgvvBhb4CT2be2LL7DM=; b=ZZvYV1zwPCWYO/QJxWCTeJyNCkmnzf432jgNJvSDhZlVIMN27BnuXbf0i31BtLI3gV/+YA FVz6Ic0Y69dCCdRV1A/qfWvkosFGNADeBdWJueyQ1q3kIwsdmNGLKXQrEEVrNum87qnrOn dlzBLjNaRmPCAGL1pGEZzrY+4EOtDVdBv7o/B3ClKaJHiRwtEGivNNdv2jm7scRPu9adob R9JMzXwSYTxW5qjG+SRx8WWYw8SE0vDm5LtwWT0pkObGsW9ckb6ml+3m5JKtV+Xb6WNue5 37sEu1gU/uwYLRcNEAG7C72Xb+kpOeavkDFTgRJ3XiMMugOt2xi1+LKVQztVwQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686751659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q1hYNE6dCTQuk9WVmYS4k1xlOgvvBhb4CT2be2LL7DM=; b=yHOFDzNtJEKU4s4MeGdhgcrNo8WlP4GxqaRe2tJ06SItoPxdsOzaIf8OR6Ie4RfzqKCNtO T8JTtGrn54Bj37CA== To: Jesse Brandeburg , Tony Nguyen , Vinicius Costa Gomes , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tan Tee Min , Muhammad Husaini Zulkifli , Aravindhan Gunasekaran , Malli C Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kurt@linutronix.de, florian.kauer@linutronix.de Subject: [PATCH net-next 6/6] igc: Fix inserting of empty frame for launchtime Date: Wed, 14 Jun 2023 16:07:14 +0200 Message-Id: <20230614140714.14443-7-florian.kauer@linutronix.de> In-Reply-To: <20230614140714.14443-1-florian.kauer@linutronix.de> References: <20230614140714.14443-1-florian.kauer@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768689802627876701?= X-GMAIL-MSGID: =?utf-8?q?1768689802627876701?= The insertion of an empty frame was introduced with commit db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") in order to ensure that the current cycle has at least one packet if there is some packet to be scheduled for the next cycle. However, the current implementation does not properly check if a packet is already scheduled for the current cycle. Currently, an empty packet is always inserted if and only if txtime >= end_of_cycle && txtime > last_tx_cycle but since last_tx_cycle is always either the end of the current cycle (end_of_cycle) or the end of a previous cycle, the second part (txtime > last_tx_cycle) is always true unless txtime == last_tx_cycle. What actually needs to be checked here is if the last_tx_cycle was already written within the current cycle, so an empty frame should only be inserted if and only if txtime >= end_of_cycle && end_of_cycle > last_tx_cycle. This patch does not only avoid an unnecessary insertion, but it can actually be harmful to insert an empty packet if packets are already scheduled in the current cycle, because it can lead to a situation where the empty packet is actually processed as the first packet in the upcoming cycle shifting the packet with the first_flag even one cycle into the future, finally leading to a TX hang. The TX hang can be reproduced on a i225 with: sudo tc qdisc replace dev enp1s0 parent root handle 100 taprio \ num_tc 1 \ map 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ queues 1@0 \ base-time 0 \ sched-entry S 01 300000 \ flags 0x1 \ txtime-delay 500000 \ clockid CLOCK_TAI sudo tc qdisc replace dev enp1s0 parent 100:1 etf \ clockid CLOCK_TAI \ delta 500000 \ offload \ skip_sock_check and traffic generator sudo trafgen -i traffic.cfg -o enp1s0 --cpp -n0 -q -t1400ns with traffic.cfg #define ETH_P_IP 0x0800 { /* Ethernet Header */ 0x30, 0x1f, 0x9a, 0xd0, 0xf0, 0x0e, # MAC Dest - adapt as needed 0x24, 0x5e, 0xbe, 0x57, 0x2e, 0x36, # MAC Src - adapt as needed const16(ETH_P_IP), /* IPv4 Header */ 0b01000101, 0, # IPv4 version, IHL, TOS const16(1028), # IPv4 total length (UDP length + 20 bytes (IP header)) const16(2), # IPv4 ident 0b01000000, 0, # IPv4 flags, fragmentation off 64, # IPv4 TTL 17, # Protocol UDP csumip(14, 33), # IPv4 checksum /* UDP Header */ 10, 0, 48, 1, # IP Src - adapt as needed 10, 0, 48, 10, # IP Dest - adapt as needed const16(5555), # UDP Src Port const16(6666), # UDP Dest Port const16(1008), # UDP length (UDP header 8 bytes + payload length) csumudp(14, 34), # UDP checksum /* Payload */ fill('W', 1000), } and the observed message with that is for example igc 0000:01:00.0 enp1s0: Detected Tx Unit Hang Tx Queue <0> TDH <32> TDT <3c> next_to_use <3c> next_to_clean <32> buffer_info[next_to_clean] time_stamp next_to_watch <00000000632a1828> jiffies desc.status <1048000> Fixes: db0b124f02ba ("igc: Enhance Qbv scheduling by using first flag bit") Signed-off-by: Florian Kauer Reviewed-by: Kurt Kanzenbach --- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index ec8649751d19..1556beaefbc3 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -1023,7 +1023,7 @@ static __le32 igc_tx_launchtime(struct igc_ring *ring, ktime_t txtime, *first_flag = true; ring->last_ff_cycle = baset_est; - if (ktime_compare(txtime, ring->last_tx_cycle) > 0) + if (ktime_compare(end_of_cycle, ring->last_tx_cycle) > 0) *insert_empty = true; } }