From patchwork Tue Apr 15 12:43:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang \(Nokia\)" X-Patchwork-Id: 881509 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2049.outbound.protection.outlook.com [40.107.20.49]) (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 67DE322F01; Tue, 15 Apr 2025 12:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721042; cv=fail; b=qvuWe7Taf11d7VellAnTqqcPlrvtZMXg5chWhiGSvqWhurx0uk2S8OG8p67SkDPBOAf61GM1evzHHdDpAqlnaveIGBdswrxuISylB6VJjxavBGrQ20NLyChPv74RetlXICO6PsrEMA4+48VfgQklc5YDrVQ/hMR0gi/iu6ZRZho= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721042; c=relaxed/simple; bh=T6YdsXWfwagRJ6cY/dLM7kc/mNBPfvMKVPvHgKbzyso=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Wxxh6IYeXbxsskssosRjon/69QkFEY/gkxWdFECjwgsafYfBfc43abrPvszjWb50QCbWyNANKt8xbWJY0umLcetFviAjVsPN9cQcVj1r9hMyGfhm+gloG9nM1PrKGRjzwFHeHFTg3NJlniSCh9x54mgPy+pk6++JEx49csu33Ik= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=AXRpBEp5; arc=fail smtp.client-ip=40.107.20.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="AXRpBEp5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MdALz4I4V1nsoyNyR9XaqEIQWB9XKYiuNtHP49n9hM2iXDrmU/Qriqira09izxdqxkh3g8DETqb50d+JM1+IJiENsnfloSPEKHABwNOYPWm7dM1/TIsPxmwYhkAW+QrNBCZChHDSBmbGmlCqnzqYZ52okqA/qo9YAMIxPmTOftZRqtS/hV3NL1ShvN18erVUpM53DQkvJzrab8234LrjyAHWcoDAyqF8okQRAngSUJptecjwrG+OkCp+x0q1TV3B4BkMwqt9BOv22Wy970758SEM8E6OtQKVkmBBE/sOsoogebauu76olZ/U8or6xshsbuLi6Fjfvts45LyAk73phg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OAruTQFdDsbzZJbN3TZIoGPXKG4aOYZ4bOtIlakumwI=; b=MRPBkpIJ2UV/PIeKg/aMPl8eP9y0z0XlLWFz77TO7vtYJJYf9xc8YAuYoQnhEFoZH3wxnIJm/qDVy2bdtj5t/WE17AQyMU0DEWx6mrBm3hYU0BmexgBb84X4tJD8Xo7WMY9dwQWrV7nGpmPl5IQbjf/7X/TDSYxDfMUVG6mivKiyhTeouUrC2qlDNTQkT6wqc1cUEnZstQq98a2oOI498Ch/ALcxQbLBniTzaxHcuEJmnEy+0X+GMtTB0xNhJgZcT2a4BmeTcwkxtlXDhFCtHyK0DnySZ4jN1dIl4aEzJP6AJ39+57410aU+A30/069PLU9XzeIuMC3azBCzT08qQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.100) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OAruTQFdDsbzZJbN3TZIoGPXKG4aOYZ4bOtIlakumwI=; b=AXRpBEp5turQP9DUlY/BNvvb501arTmXb1UfYWCJivCLX+ApdqbgaOa95NK4GIqRfyfqn2EaNrREzfGki6E7BdwUPtYCahJEBbqoGtoFEj66kR5T7nMLW2LrlvAERSUUVUGwq0BGqP8VHsWAjr63998HgjMp1XVxKDm7hE5+Ymnof+2udsAq9PIeqFoIgqYTpRYvbwwsdt5ALXk+aYtk5BbQUd5SQYvO2oXokzGd6PoQVWeEP3nUCGzw3QXoZexiAY2X5JILKBlcsATDoYtaJYDo2kKKhr73azfQ9c1EsPlTRsht35xuX8nDqLRB92ncObhwPyYUXlDjQlSoalw5ug== Received: from DUZPR01CA0247.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::17) by PR3PR07MB6842.eurprd07.prod.outlook.com (2603:10a6:102:77::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.34; Tue, 15 Apr 2025 12:43:57 +0000 Received: from DB1PEPF000509EF.eurprd03.prod.outlook.com (2603:10a6:10:4b5:cafe::95) by DUZPR01CA0247.outlook.office365.com (2603:10a6:10:4b5::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.36 via Frontend Transport; Tue, 15 Apr 2025 12:44:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.100) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.100 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.100; helo=fr711usmtp2.zeu.alcatel-lucent.com; pr=C Received: from fr711usmtp2.zeu.alcatel-lucent.com (131.228.6.100) by DB1PEPF000509EF.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Tue, 15 Apr 2025 12:43:57 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr711usmtp2.zeu.alcatel-lucent.com (GMO) with ESMTP id 53FChgEe013987; Tue, 15 Apr 2025 12:44:14 GMT From: chia-yu.chang@nokia-bell-labs.com To: xandfury@gmail.com, netdev@vger.kernel.org, dave.taht@gmail.com, pabeni@redhat.com, jhs@mojatatu.com, kuba@kernel.org, stephen@networkplumber.org, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, horms@kernel.org, andrew+netdev@lunn.ch, donald.hunter@gmail.com, ast@fiberby.net, liuhangbin@gmail.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@cablelabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH v11 net-next 1/5] Documentation: netlink: specs: tc: Add DualPI2 specification Date: Tue, 15 Apr 2025 14:43:13 +0200 Message-Id: <20250415124317.11561-2-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> References: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF000509EF:EE_|PR3PR07MB6842:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ec3974d-ca9d-494a-8917-08dd7c1b3051 X-LD-Processed: 5d471751-9675-428d-917b-70f44f9630b0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|1800799024|36860700013|376014|82310400026|921020; X-Microsoft-Antispam-Message-Info: rPbxDU7/Z/Ah1b1gbSYdcccrQPaw99SFRsYO6vd/6X+iMMIgckoShNpPo1nAobCRtXFfpxzD9RSLbfJMT3WNlWm9k7494ShbwOJsQcLbbxtJno2/q0/eQu2c5YBOleeXX+G3ChgM27xhQborydpNxfiyzaz1RciNBv9Lw5Ji/U02Ozi2b1FBEMHTtpSwtZVw6o7ycjbxbihAPOAu/QugvB3uTnBbAx5j7PPX89prqKatgCDVpnDmJNbrP8hT660ibAqxPJiAaUAZFlGKuMiduyB3Yzvo1/6AfuiRhSMc6NUdxuTMPQQij9HXFyvgDjl/dDdfeAWO9WCxTjVhXZI3Zg4A0dgNzBOF2+X8xjpFZ9TqbcmE+05ubzmtZLCIjGY2wcK46zMOsPLS8IrBI7cKrsURbKnp1mxNkCH8XSS8MOL7Rg/r0POCDB3s6xY7YMNdU+Og9aByjKSTza9SU9ojw4F4O0fXykK2ZhmsxZb+Xdv04qNChJhKFM7vV07rH3+uHG2XUhjfET2KrM0tlbpmklpn+AjmVnIw3acJM4WpGp3qn1qPINNMn67Si2YnTXbmB79v1Vr72+bEIZ3+SFPVdYUh2bGizWvTMUKEmObhb6f/dj72N47obCwrxKCkXCHonWdAD0X+l2+g4EHbHLBEpiWth/swR0dHnAeuM1p7AChn37R3xUp+0SF0lfJlfN4ZZsS3i/QvauvHbhKM8ps3sQWGvQgLa6nY5U250uuNR1fP4Q7mxg7PnE7PKR7yT2CCUW/BhvQGkTniLiXmSRt3f0kLz8fb9hy7UrSa8gfvZ9L5xmtiUKI8PAllClWiZovlSyNYNT/STSRjYplykMmgylYlmqa1sodHiCAUs6RsvEDix2Yp1qoAsIA/q7HnXQyiqviTN7dVYz37MaxBhsmojUndhBUbav8uV981K2jZn/Q6M+Hav62z460LS2AyIp5XXRrFAtgShUO5BY6v4QBQMV9wqYBBp5/7aZI3K7eAe8MzaupNvHjhJjNrcPLoQV/vWmwUXr96bPQJfGwp7RvFzwQZvsH9OENKcd4g0YG9rtKYF2KGjClcBzmj38tvaUkvLUxJMgSVquj6b8kiXo4c/6tDQc08WQrsV5JeLTCTCrLFrsdRA8MiK5JoXfrv8eu94ioHGEJffWHrPp/q4clzAqjfn6vihPPDmuCIWaS27RWMykUEqyDDG8vhnae+qYg3VHKts7a56HUi4rsXPRkkt8sCh9Cg9Vw45RRopZdKt4gEJ1bQ/p5Xsl4QV6ZbVI6WF9BM8b56hEbxP76wtqUcemVs1WsTumHAUVAGrGUR1hi0/nkBo2wxgQkz8Luk7RZAVXCvLgDYQNZAHsSufjMbQYxM76GCaHowYRSS+WU+L5ydZg+y/TMG2qWqKZBPKn2Rd6QuLYRsRSi7CwZD+NETtku/qFJPC1xnM3/a/n1bEcwzoWqit5xPscmgLbw9kPhzRNWgLDfJiNcpbuY5docvNimV/wL6AJRo70r8hR+Ib9hoGT7TKTN2DOCCvTtwHQKbDYzDtL8aITeCaz+z7/4gTg== X-Forefront-Antispam-Report: CIP:131.228.6.100; CTRY:FI; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:fr711usmtp2.zeu.alcatel-lucent.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2025 12:43:57.1839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ec3974d-ca9d-494a-8917-08dd7c1b3051 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.6.100]; Helo=[fr711usmtp2.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509EF.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB6842 From: Chia-Yu Chang Introduce the specification of tc qdisc DualPI2 stats and attributes, which is the reference implementation of IETF RFC9332 DualQ Coupled AQM (https://datatracker.ietf.org/doc/html/rfc9332) providing two different queues: low latency queue (L-queue) and classic queue (C-queue). Signed-off-by: Chia-Yu Chang --- Documentation/netlink/specs/tc.yaml | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml index aacccea5dfe4..0fb971935285 100644 --- a/Documentation/netlink/specs/tc.yaml +++ b/Documentation/netlink/specs/tc.yaml @@ -816,6 +816,58 @@ definitions: - name: drop-overmemory type: u32 + - + name: tc-dualpi2-xstats + type: struct + members: + - + name: prob + type: u32 + doc: Current probability + - + name: delay_c + type: u32 + doc: Current C-queue delay in microseconds + - + name: delay_l + type: u32 + doc: Current L-queue delay in microseconds + - + name: pkts_in_c + type: u32 + doc: Number of packets enqueued in the C-queue + - + name: pkts_in_l + type: u32 + doc: Number of packets enqueued in the L-queue + - + name: maxq + type: u32 + doc: Maximum number of packets seen by the DualPI2 + - + name: ecn_mark + type: u32 + doc: All packets marked with ecn + - + name: step_mark + type: u32 + doc: Only packets marked with ecn due to L-queue step AQM + - + name: credit + type: s32 + doc: Current credit value for WRR + - + name: memory_used + type: u32 + doc: Memory used in bytes by the DualPI2 + - + name: max_memory_used + type: u32 + doc: Maximum memory used in bytes by the DualPI2 + - + name: memory_limit + type: u32 + doc: Memory limit in bytes - name: tc-fq-pie-xstats type: struct @@ -2299,6 +2351,92 @@ attribute-sets: - name: quantum type: u32 + - + name: tc-dualpi2-attrs + attributes: + - + name: limit + type: u32 + doc: Limit of total number of packets in queue + - + name: memlimit + type: u32 + doc: Memory limit of total number of packets in queue + - + name: target + type: u32 + doc: Classic target delay in microseconds + - + name: tupdate + type: u32 + doc: Drop probability update interval time in microseconds + - + name: alpha + type: u32 + doc: Integral gain factor in Hz for PI controller + - + name: beta + type: u32 + doc: Proportional gain factor in Hz for PI controller + - + name: step_thresh + type: u32 + doc: L4S step marking threshold in microseconds or in packet (see step_packets) + - + name: step_packets + type: flags + doc: L4S Step marking threshold unit + entries: + - microseconds + - packets + - + name: min_qlen_step + type: u32 + doc: Pacekts enqueued to the L-queue can apply the step threshold when the queue length of L-queue is larger than this value. (0 is recommended) + - + name: coupling_factor + type: u8 + doc: Probability coupling factor between Classic and L4S (2 is recommended) + - + name: drop_overload + type: flags + doc: Control the overload strategy (drop to preserve latency or let the queue overflow) + entries: + - drop_on_overload + - overflow + - + name: drop_early + type: flags + doc: Decide where the Classic packets are PI-based dropped or marked + entries: + - drop_enqueue + - drop_dequeue + - + name: classic_protection + type: u8 + doc: Classic WRR weight in percentage (from 0 to 100) + - + name: ecn_mask + type: flags + doc: Configure the L-queue ECN classifier + entries: + - l4s_ect + - any_ect + - + name: gso_split + type: flags + doc: Split aggregated skb or not + entries: + - split_gso + - no_split_gso + - + name: max_rtt + type: u32 + doc: The maximum expected RTT of the traffic that is controlled by DualPI2 in usec + - + name: typical_rtt + type: u32 + doc: The typical base RTT of the traffic that is controlled by DualPI2 in usec - name: tc-ematch-attrs attributes: @@ -3679,6 +3817,9 @@ sub-messages: - value: drr attribute-set: tc-drr-attrs + - + value: dualpi2 + attribute-set: tc-dualpi2-attrs - value: etf attribute-set: tc-etf-attrs @@ -3846,6 +3987,9 @@ sub-messages: - value: codel fixed-header: tc-codel-xstats + - + value: dualpi2 + fixed-header: tc-dualpi2-xstats - value: fq fixed-header: tc-fq-qd-stats From patchwork Tue Apr 15 12:43:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chia-Yu Chang \(Nokia\)" X-Patchwork-Id: 881508 Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11013036.outbound.protection.outlook.com [40.107.159.36]) (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 02FA2291160; Tue, 15 Apr 2025 12:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.159.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721052; cv=fail; b=DT6kTw12tD/E7N3yBDtqEfh1lzo84+/Vfs9xTRH2DeyBUXUmiGvaUjng+Hj1hxzaTBZ+ScbcV8dcYL9qejKQ3oMet03Ma2w2Xi7acpuzf0wzbun9WfFCfQe1xUCiWfEoQDAQEW9YPF6UROREcN4sfir2jZtLZ4M68O2kxJuHZak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721052; c=relaxed/simple; bh=J3gghKMCAQYb6X22VHtQEYa1bUEVPr6Qr/EONqACy7I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=gcSct0g1dz6VHCDB1/G78pjlj2z0q5GkD8nCGgeUObLMdjDRWgEl2ptAA5sV+4GWbhaB3HlZNDEPho+KELmeA+ScU6nlgbUhqolwUGRTQjRqCT2UvQr2rq4VDRf3c+Hu8X1QmIMdGqsO/R3j+eSmpw0tJVSlbzETseEB7nUTvaQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=giDmx10z; arc=fail smtp.client-ip=40.107.159.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="giDmx10z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zLoVN4e72qHiJpLWK97giIZlk2hcyhID0GsmUtq9ZO/QtKyg5YSyMw5gyuVtDEXh6FpUDgBzOUv+TH0hFyt3ZWgCqdTgdvWZbVekBATzPR47ASlaOUjFFWpHUrl4ud1iUstL7/X57uqWub4nXm3nIKMHXcVj0EYYMu8iblUOl8xAYkeG0N3D2XKP2LlFYqBUWwMHSruVU0PC28IEuSr+pWo/UkAuLnwCO5gz1bdu5UkpFmNLWLT4WPGxpCdOV58IDxGKg7Vns4h8FZKazxA/h1ufkJUoeu8Z6MjpIPpemiXg+3SD67V0Aa7/MBSDKooSSeNPEIGY8/yK7bse4kBaEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mr0WVWpJ9qsK9Ltohw5GCNG/Q6S00o1y4G+EOv4qSBk=; b=dn9Oo0yNz41WkERBNOMspwRd3ieVhKE7IfKwTpGIBlV9wS8gvVW5pLP5k3W9Td4PNDBc/vT2eJ6oI4uSxyHH/klZ0mUVVK3UVqhyl1wD8pGDO8HGYLEjfWJb/Fv+DuQPTwm+CQoyFsxG828A0/JPcw7cW+vuG45cfFn0wiAOIY3jozsF/6DTXXBocry+4L/jNu7sZOQ1VM9qCE1yD2dm7XWQFTpDpbz34ZymE11Prn5HPmIYWXldEa+T7W7wV3RFQGWqWciXL+8TSU+/ljNVYPweIe7OoN5f0HAfm3VJ/o7EvX9mgIr0uM8fvr+izdD82SxLr8VepCVjIp8Lr+86zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.6.100) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mr0WVWpJ9qsK9Ltohw5GCNG/Q6S00o1y4G+EOv4qSBk=; b=giDmx10zj6/qLul+Gtbb2+iCDoS6hGLoyG7qdd8jFQSdHRL75jt4qPh3bti8CgLkDz0w53y2aV5aUOFbW1gY20AEQFeyhKrFm+1c7tQ1ak9IhWX4Hs2mnNhUSrf9M5sf4GQC/4vDK0vL50Is5Wr0Zex06UoHB68QB1BVLRtSRhnZQKf9kCvRosd8R/x6zpTlxSEyRv9HYBSkmwSk54uY9azUlgc9jp5lriyo8yenaJU/6uoV6an0DS341UknjTVIDPGVlUXSyyMZvIHsS51+BnUul5CbDVw/lstZqsZeTFF6VORPncd9AcwNyNPOErMJsPNPasKr7AnPWSQIsVCwdQ== Received: from AM8P190CA0003.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:219::8) by AM7PR07MB6421.eurprd07.prod.outlook.com (2603:10a6:20b:140::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.32; Tue, 15 Apr 2025 12:44:03 +0000 Received: from AMS0EPF000001A7.eurprd05.prod.outlook.com (2603:10a6:20b:219:cafe::9b) by AM8P190CA0003.outlook.office365.com (2603:10a6:20b:219::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.34 via Frontend Transport; Tue, 15 Apr 2025 12:44:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.6.100) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nokia-bell-labs.com; Received-SPF: Pass (protection.outlook.com: domain of nokia-bell-labs.com designates 131.228.6.100 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.6.100; helo=fr711usmtp2.zeu.alcatel-lucent.com; pr=C Received: from fr711usmtp2.zeu.alcatel-lucent.com (131.228.6.100) by AMS0EPF000001A7.mail.protection.outlook.com (10.167.16.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Tue, 15 Apr 2025 12:44:02 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr711usmtp2.zeu.alcatel-lucent.com (GMO) with ESMTP id 53FChgEh013987; Tue, 15 Apr 2025 12:44:19 GMT From: chia-yu.chang@nokia-bell-labs.com To: xandfury@gmail.com, netdev@vger.kernel.org, dave.taht@gmail.com, pabeni@redhat.com, jhs@mojatatu.com, kuba@kernel.org, stephen@networkplumber.org, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, horms@kernel.org, andrew+netdev@lunn.ch, donald.hunter@gmail.com, ast@fiberby.net, liuhangbin@gmail.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@cablelabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Chia-Yu Chang Subject: [PATCH v11 net-next 4/5] sched: Dump configuration and statistics of dualpi2 qdisc Date: Tue, 15 Apr 2025 14:43:16 +0200 Message-Id: <20250415124317.11561-5-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> References: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001A7:EE_|AM7PR07MB6421:EE_ X-MS-Office365-Filtering-Correlation-Id: 316a20e9-06bd-4c09-a0d6-08dd7c1b33a6 X-LD-Processed: 5d471751-9675-428d-917b-70f44f9630b0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|7416014|36860700013|921020; X-Microsoft-Antispam-Message-Info: R1vmYcF8lMomvRACZUAKNwZwBb8YQU4OgsJmOETDG9u3VreTgHhslVgo5M6jnGW+KO77nHF0H/2t4XO22JvQsfWGA0qg8U8NJbpwIWYhIipOcipNBiAgtz5dDhFFIiDQiXUBggfqYW1/aYKShhoAr08Xf7/3XDomd/j/LVFjsmZKedIQDnpWLQ1NhnAQqWKKuVColdrBhyRYqs1tikFbrocbsoTlc2lzmDL90DEDdcWNwZjOzteQC0+2P9sYJSYQoddJmrGr+IBUIL0yHz0Ri9l4/XPTG8odoKbGjy1XDm319Stnm9LSb1JcQEf/qz780ha+NpzZJVG+QQ0rwxICAd983m1qaRZ4Auc0EiTHM74CfN1SpsAuMSfKi0yakKRqTqfbwMpx3V1sanE50HuyhSoRJgQN030sIgaQm3w3OnIMJu9b2WQzvUmkK8KQkd5LK4w7iJAAJvTIWbJpP7BwVlF+PsX7k1kXZIu2RoPOcvk7J+zoOWsLHEfnLZv9QcsXV9iBjUiltKVeK+qnP27qTt/MscPsN0i1c7gWeUses/7WusiKtkJ65y89nSS2a7Tlo/YmZru1kR8MzeCrwtUzdbpzJ3kVtBN+vZz7YmqoXtKCZJN9rGkBG6/J7sCMFpDsYLt5dAO6CvTZouQ6rilGHHLnOVTzKBDcbt+4HSZcMBNPacPvf8N+s/IMMxuqeGFYpSU2LYm6EEHC7HAky269O2VnotGQuwlo3jjyXdZiH7u39HSQW14E9PDSJ1oCRLekP28fO0NgjqP/M7TVsKAHTfnvQDRQ0TtPhBfAvKY0rXpgBUKrgFEAhNAeGuhkGqdkf+bRQcT54D4D/9ow1ef78R/JW6/vXeOzUopyVlex8LQNLKA08tzwaQI4+TBp/5jLhEGZqCQqIPw6xza4wGe8BNOTW9haILbCncWNqJEZdD66Cd3JG9yb4pturptnaiVoiYpBVGZ3S5ab3lufebcKemLRia1mTQr/qJnwFoYKq/LuEgZNHYGaKtZmWaEYHfB7vMA0UbT1/LhZns6Fr5hCajxFhY43C0mTGBzB8bHSGHd9DawVQWHEd9QfX9NuG/bo6c3NTihcZuajh4eLSALX94Pu/hqxv/HZh+pVzJwjbSGovRAZLcrTQF21RERz3lxgMIZGARSzv9PIl54/c6EPeVr/acPnBY0rO+I5Hvk59fKXu0vBuoY40nF0+8RQYxWVP2g340qSpN5Pzf2Q+iTyXnWh2lLHsdlCTtNDjvmeKFAd3tLqgvrbYWnB7+kqwJ7O6N2H5kViqm/ISokXHB/YtgoUIYSpnxJE6Kr3WxdwPdtW9b/BZr7+1woEwSH1CGZBZeM1mvz7ssT8+vHLpqf1WjV65HfVnzVjmRQMkPUQJ6sm5zi6ZKErjaTnXYb1BNYBdMAzLN0fwUZgu/GXDQBCLXYQqi0WFzubxmRr9vevz1dCY9fqdSM/dbTbpV16pO6MS3FN5ReFoau+OC2npRL8NAUGAI9C4HKFN6PTqXKjJ76GdUKMg3m75+bOgflYWsH+Kr/f2gCSoMoijuBR9dp3BQ== X-Forefront-Antispam-Report: CIP:131.228.6.100; CTRY:FI; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:fr711usmtp2.zeu.alcatel-lucent.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(7416014)(36860700013)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2025 12:44:02.7904 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 316a20e9-06bd-4c09-a0d6-08dd7c1b33a6 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.6.100]; Helo=[fr711usmtp2.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A7.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR07MB6421 From: Chia-Yu Chang The configuration and statistics dump of the DualPI2 Qdisc provides information related to both queues, such as packet numbers and queuing delays in the L-queue and C-queue, as well as general information such as probability value, WRR credits, memory usage, packet marking counters, max queue size, etc. The following patch includes enqueue/dequeue for DualPI2. Signed-off-by: Chia-Yu Chang --- include/uapi/linux/pkt_sched.h | 15 ++++++ net/sched/sch_dualpi2.c | 86 ++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h index fd5bec118cdc..62fec34c1005 100644 --- a/include/uapi/linux/pkt_sched.h +++ b/include/uapi/linux/pkt_sched.h @@ -1234,4 +1234,19 @@ enum { #define TCA_DUALPI2_MAX (__TCA_DUALPI2_MAX - 1) +struct tc_dualpi2_xstats { + __u32 prob; /* current probability */ + __u32 delay_c; /* current delay in C queue */ + __u32 delay_l; /* current delay in L queue */ + __s32 credit; /* current c_protection credit */ + __u32 packets_in_c; /* number of packets enqueued in C queue */ + __u32 packets_in_l; /* number of packets enqueued in L queue */ + __u32 maxq; /* maximum queue size */ + __u32 ecn_mark; /* packets marked with ecn*/ + __u32 step_marks; /* ECN marks due to the step AQM */ + __u32 memory_used; /* Meory used of both queues */ + __u32 max_memory_used; /* Maximum used memory */ + __u32 memory_limit; /* Memory limit of both queues */ +}; + #endif diff --git a/net/sched/sch_dualpi2.c b/net/sched/sch_dualpi2.c index 3f91f6b1db2f..78027d6ce917 100644 --- a/net/sched/sch_dualpi2.c +++ b/net/sched/sch_dualpi2.c @@ -126,6 +126,14 @@ static u32 dualpi2_scale_alpha_beta(u32 param) return tmp; } +static u32 dualpi2_unscale_alpha_beta(u32 param) +{ + u64 tmp = ((u64)param * NSEC_PER_SEC << ALPHA_BETA_SCALING); + + do_div(tmp, MAX_PROB); + return tmp; +} + static ktime_t next_pi2_timeout(struct dualpi2_sched_data *q) { return ktime_add_ns(ktime_get_ns(), q->pi2.tupdate); @@ -421,6 +429,82 @@ static int dualpi2_init(struct Qdisc *sch, struct nlattr *opt, return 0; } +static u32 convert_ns_to_usec(u64 ns) +{ + do_div(ns, NSEC_PER_USEC); + return ns; +} + +static int dualpi2_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start_noflag(skb, TCA_OPTIONS); + if (!opts) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_DUALPI2_LIMIT, READ_ONCE(sch->limit)) || + nla_put_u32(skb, TCA_DUALPI2_MEMORY_LIMIT, + READ_ONCE(q->memory_limit)) || + nla_put_u32(skb, TCA_DUALPI2_TARGET, + convert_ns_to_usec(READ_ONCE(q->pi2.target))) || + nla_put_u32(skb, TCA_DUALPI2_TUPDATE, + convert_ns_to_usec(READ_ONCE(q->pi2.tupdate))) || + nla_put_u32(skb, TCA_DUALPI2_ALPHA, + dualpi2_unscale_alpha_beta(READ_ONCE(q->pi2.alpha))) || + nla_put_u32(skb, TCA_DUALPI2_BETA, + dualpi2_unscale_alpha_beta(READ_ONCE(q->pi2.beta))) || + nla_put_u32(skb, TCA_DUALPI2_STEP_THRESH, + READ_ONCE(q->step.in_packets) ? + READ_ONCE(q->step.thresh) : + convert_ns_to_usec(READ_ONCE(q->step.thresh))) || + nla_put_u32(skb, TCA_DUALPI2_MIN_QLEN_STEP, + READ_ONCE(q->min_qlen_step)) || + nla_put_u8(skb, TCA_DUALPI2_COUPLING, + READ_ONCE(q->coupling_factor)) || + nla_put_u8(skb, TCA_DUALPI2_DROP_OVERLOAD, + READ_ONCE(q->drop_overload)) || + nla_put_u8(skb, TCA_DUALPI2_STEP_PACKETS, + READ_ONCE(q->step.in_packets)) || + nla_put_u8(skb, TCA_DUALPI2_DROP_EARLY, + READ_ONCE(q->drop_early)) || + nla_put_u8(skb, TCA_DUALPI2_C_PROTECTION, + READ_ONCE(q->c_protection.wc)) || + nla_put_u8(skb, TCA_DUALPI2_ECN_MASK, READ_ONCE(q->ecn_mask)) || + nla_put_u8(skb, TCA_DUALPI2_SPLIT_GSO, READ_ONCE(q->split_gso))) + goto nla_put_failure; + + return nla_nest_end(skb, opts); + +nla_put_failure: + nla_nest_cancel(skb, opts); + return -1; +} + +static int dualpi2_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct tc_dualpi2_xstats st = { + .prob = READ_ONCE(q->pi2.prob), + .packets_in_c = q->packets_in_c, + .packets_in_l = q->packets_in_l, + .maxq = q->maxq, + .ecn_mark = q->ecn_mark, + .credit = q->c_protection.credit, + .step_marks = q->step_marks, + .memory_used = q->memory_used, + .max_memory_used = q->max_memory_used, + .memory_limit = q->memory_limit, + }; + u64 qc, ql; + + get_queue_delays(q, &qc, &ql); + st.delay_l = convert_ns_to_usec(ql); + st.delay_c = convert_ns_to_usec(qc); + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + /* Reset both L-queue and C-queue, internal packet counters, PI probability, * C-queue protection credit, and timestamps, while preserving current * configuration of DUALPI2. @@ -525,6 +609,8 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .destroy = dualpi2_destroy, .reset = dualpi2_reset, .change = dualpi2_change, + .dump = dualpi2_dump, + .dump_stats = dualpi2_dump_stats, .owner = THIS_MODULE, }; From patchwork Tue Apr 15 12:43:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Chia-Yu Chang \(Nokia\)" X-Patchwork-Id: 881507 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012002.outbound.protection.outlook.com [52.101.66.2]) (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 6C6DA2957BD; Tue, 15 Apr 2025 12:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721057; cv=fail; b=GpSF6zLkFB2Iyh0W8h/s9w8AT9A6imUnAoxQLhCokL1+aF9dgNMOIaWl4XNqPy7XlbvcO63m9ZQwcG3u3mktFHqB4kZVovIqmwySzEPD+1Vj3A6BEuLIVAF5nBu8q9I0cM11j+zWGv2beEuXplfAA+CMauWKvEBIk5NJYg6Lb3E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744721057; c=relaxed/simple; bh=skgtMvZ+fSByPn+9wX1a8pyy76i4yBBKfSzxPwpVPtI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=qrcRr8trmD4GEm46W7JJJEZQL4IVwRWuifGjHeFnixeNySBhXbQzxfIw37uTFQIZLt8cX+emjHBihFJ46ohM1Jaz/N6SvSbzwh2MDhdfFSJA8tYesRsvqx4WuWC/2ws6ldysfubBnw9Hg6bk3pnrfZ937ktH2nASYT3SWRquPcE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com; spf=fail smtp.mailfrom=nokia-bell-labs.com; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b=sxou5QqI; arc=fail smtp.client-ip=52.101.66.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia-bell-labs.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia-bell-labs.com header.i=@nokia-bell-labs.com header.b="sxou5QqI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kgiy8jN5rb1ysHMEetRIKglMTaGGDCdL4wQhaAeGLlW7CXCmOqajTR+QZvRO3akzf43ZSehlVy783XC9eNQA7oyEUSBp9AG1zW+MYjOCg1CgZpbi7piHoamjoYEFRh0Oz+w3m4ZzumWrOw1BN+gFcLXQ5fh11Srshe/DsBuW1VPmVjNAECZN3+DBZPnE5Gv5VmChrWKf8hNYmrnyS5oXj7wmBMe9NVBko82iEtXGdm5KRaPNZXvip/q4lcgE273A5wcTlWjprgCtmYMah6ai6LCp9MTmu7XuQgyYCK22hkp0cTOJ10x2SgAsL/+SSyEl9CTpKrGqdc8+9roxhGu9xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BGtju3jWs5pUyzUPQRhd6MQriiCgP+Lbpgem4BhWBGw=; b=HzFTuGsEQZs3Lb0NhU5ltyv/pLDj6Y/AIjaxI7BHTkArlYUVMD88FWUxaXTaUqYb6apAjrFwoRda9rKSFOswlqR9ujcPQIJpuGknAfKCZOBcg0fL/K9WJzv7dXoPKA058hapampdifbCcSpKcTHQndUUytq28j3o22Opx9Zc0UMeTZJgNnhHCiuTKO8C7iKt/XohlIuJjQ116fsh9QcVPVC7ydaLQS1wsZa57ZXUYu99kCou1dbx/9nEL/2aIeFL+V5kWCHTJh3KBhMddQwyvpzRRFsIY/QY1wAUuijCixKSlqVGTVAy9sGNhQ27DLsFI9MyJDmpc0331o/IeJYk1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 131.228.6.100) smtp.rcpttodomain=nokia-bell-labs.com smtp.mailfrom=nokia-bell-labs.com; dmarc=temperror action=none header.from=nokia-bell-labs.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-bell-labs.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BGtju3jWs5pUyzUPQRhd6MQriiCgP+Lbpgem4BhWBGw=; b=sxou5QqIg2F3eiCBjWgfQLu3xWDExTVTlDG3hrAWFGyJ/L8O5tE1MrqDRQxoL4HQaAM8gArny4S5XX7OUYeFcq+1nSsHtdPLQUbDMbh9nw/BQp/sl1LM9TZACpGf5fp/CRDhdxcnUNwOYkByBilDt0yOThfYavz95ZxzWbjTpuRPbB6jgO8LTzvOAxVJo37jmOz3ntSUESOYdF/XO9p7RiQUJgNjnpvFSfcc0MDFp5c0pqRfVFATubsAl5o4nzs420EG2fwkno+4x4/qMP74GKFzMIhmXU625h8D5jGDT9jtYf/+9v812ocPi9n+fu+b/ToN7e12JcYKicZTIpOQZg== Received: from AS4P250CA0010.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::7) by PAXPR07MB8471.eurprd07.prod.outlook.com (2603:10a6:102:2b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.27; Tue, 15 Apr 2025 12:44:07 +0000 Received: from AMS0EPF000001AF.eurprd05.prod.outlook.com (2603:10a6:20b:5df:cafe::8f) by AS4P250CA0010.outlook.office365.com (2603:10a6:20b:5df::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.36 via Frontend Transport; Tue, 15 Apr 2025 12:44:07 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 131.228.6.100) smtp.mailfrom=nokia-bell-labs.com; dkim=none (message not signed) header.d=none;dmarc=temperror action=none header.from=nokia-bell-labs.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of nokia-bell-labs.com: DNS Timeout) Received: from fr711usmtp2.zeu.alcatel-lucent.com (131.228.6.100) by AMS0EPF000001AF.mail.protection.outlook.com (10.167.16.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Tue, 15 Apr 2025 12:44:06 +0000 Received: from sarah.nbl.nsn-rdnet.net (sarah.nbl.nsn-rdnet.net [10.0.73.150]) by fr711usmtp2.zeu.alcatel-lucent.com (GMO) with ESMTP id 53FChgEi013987; Tue, 15 Apr 2025 12:44:21 GMT From: chia-yu.chang@nokia-bell-labs.com To: xandfury@gmail.com, netdev@vger.kernel.org, dave.taht@gmail.com, pabeni@redhat.com, jhs@mojatatu.com, kuba@kernel.org, stephen@networkplumber.org, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, horms@kernel.org, andrew+netdev@lunn.ch, donald.hunter@gmail.com, ast@fiberby.net, liuhangbin@gmail.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, ij@kernel.org, ncardwell@google.com, koen.de_schepper@nokia-bell-labs.com, g.white@cablelabs.com, ingemar.s.johansson@ericsson.com, mirja.kuehlewind@ericsson.com, cheshire@apple.com, rs.ietf@gmx.at, Jason_Livingood@comcast.com, vidhi_goel@apple.com Cc: Olga Albisser , Olivier Tilmans , Henrik Steen , Bob Briscoe , Chia-Yu Chang Subject: [PATCH v11 net-next 5/5] sched: Add enqueue/dequeue of dualpi2 qdisc Date: Tue, 15 Apr 2025 14:43:17 +0200 Message-Id: <20250415124317.11561-6-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> References: <20250415124317.11561-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AF:EE_|PAXPR07MB8471:EE_ X-MS-Office365-Filtering-Correlation-Id: db01a585-2ec3-4966-8833-08dd7c1b35c2 X-LD-Processed: 5d471751-9675-428d-917b-70f44f9630b0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|7416014|376014|1800799024|13003099007|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?sfGL0nkYXFmo0zhhKtwKpiOQLH5dlc5?= =?utf-8?q?enTWEhW2Iab9iwxO5AZdmh3jbVsPjaK/+bQ30KLlIfN/ALUMKDKvzuY9bdD220sRd?= =?utf-8?q?vP/ACOEOyW+OahvyzUyAhCiArWbrAvhGSzhmHZ9FjfM+zWSSpVuCfRMGXXRguDG3e?= =?utf-8?q?56aStHkJvCDAD+nHkMfBiFIju8RO8Cad2NlIfrJIYUAqGdfNpdoa95ggno9vEJYO3?= =?utf-8?q?WDlrSnwmEM2Wo5S4G8wsctUn/AMiVZ6W10JQ0z0vtZP0xPK25kQkOj0+tBr32x4v6?= =?utf-8?q?dls5A52wIkD1TIao3e+nE/bL81Fg+nDZvFitz6wsUK0i1cjzwidi5lozMzVKPYYZc?= =?utf-8?q?1ooVfiQ+9oQeGzz33CAbJzCzaHslGPAQCCVwFCeh1TRetYQCC/xOybXC3J8tP4qct?= =?utf-8?q?WyglZEBCC0i853Daft0yNaKSX39rf9Dem2QtNPzmvryR00CX9rbT7fjeFBOeVbSC2?= =?utf-8?q?nI19vqEG/AugMAKw8M3t+x5RTGnUjQgAqANjxBAObfz2I69vyL2WuuAYMrFOWtVaj?= =?utf-8?q?tqThupzBerEwPFufMek+NZckrYcvxiBIDBwQY9f97WU/E0Wx6Ztf+rvNtSQLLE2Yv?= =?utf-8?q?86V22DcHY/Oz44Z/45pLknPJgrGBAHJsmXN671dQzxX9ZKtFR2Kt1J+aBOS+RRHzh?= =?utf-8?q?EB4ASk0rGMOCRx7ipw5ZZ5RBN6LQrbQ0a1frXAI+YusOYfD3Pu3vGKejRbG8z9rDA?= =?utf-8?q?pNOqFizkPRo2ZK2v+uTmzpb/9kw0S2qUKGLnGpSZ75lXynilaD23S8CGR6vehLKPH?= =?utf-8?q?ElKlskfsfjQ1dNhM1zuhFgio0cAv072jDFfQNnfNoBMGJkZ7NBqPHdIARSoqbRAMX?= =?utf-8?q?gBCbL9WoWTGempyB+pr3vYBlZHorbAhCgp0kkPh22zLKqRDm7X8qHd6V2XQMmGjtv?= =?utf-8?q?zt7Scv039vmtnrepndhZaKNd40+2ag+SqXAHJJTwjWFDc2Sk7HlWC0lSondBfBwGH?= =?utf-8?q?3zw9ZBc28IbA5ghR5kebUchJS6fKBwPJ3UGkjxlr5ahLUHTA6WJO/4O7+U5/Dxt9c?= =?utf-8?q?8k3Vh2vy0+JVWgmcztz55UgXDrcTlzes5oETU3T6XS3a/nSwhORBFYEoCorPG7tLY?= =?utf-8?q?TiCBiWMdX6PEFnFHcs81AvVwMZkWO/IHQeOHn3VIUC4uv0VhvnLhHeH745Op2Fw51?= =?utf-8?q?34jSJzGdUC7by57GbsjLsG7touRW0i2DWhS4svjJ6tpOY0+JWKhFuhZyc+ZuJaxYV?= =?utf-8?q?zZZBqdANufjtr4riaH1950m52w0rlwsjrx0xGo2/a4b7avluOg+rVDhM4SuB0sfXK?= =?utf-8?q?pcG7MB8e4PUYHZlpSxLRGZ4saiLaQUTWQ3fNjxDv2Dnv02m3QN9gVRo5yKCA/ql5A?= =?utf-8?q?NAdPZmNBI69ocRq9wv+UpTeX9gbx6FUOLrG0Zcu9h8wFJHmAhxse5OBGrNVPx5kpi?= =?utf-8?q?HJoXKJW5XMAu2Nbmr/D+z21GVQV+F2tWrkAiQCmMOzNaF2M74jDQV/gEclSQPZFvk?= =?utf-8?q?7dwO2Qgm51d9acjxyioZTG9m3x+0BdQF9UR2NoO78NDWTgvdqaJyU=3D?= X-Forefront-Antispam-Report: CIP:131.228.6.100; CTRY:FI; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:fr711usmtp2.zeu.alcatel-lucent.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024)(13003099007)(921020); DIR:OUT; SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2025 12:44:06.2974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db01a585-2ec3-4966-8833-08dd7c1b35c2 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.6.100]; Helo=[fr711usmtp2.zeu.alcatel-lucent.com] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001AF.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB8471 From: Koen De Schepper DualPI2 provides L4S-type low latency & loss to traffic that uses a scalable congestion controller (e.g. TCP-Prague, DCTCP) without degrading the performance of 'classic' traffic (e.g. Reno, Cubic etc.). It is to be the reference implementation of IETF RFC9332 DualQ Coupled AQM (https://datatracker.ietf.org/doc/html/rfc9332). Note that creating two independent queues cannot meet the goal of DualPI2 mentioned in RFC9332: "...to preserve fairness between ECN-capable and non-ECN-capable traffic." Further, it could even lead to starvation of Classic traffic, which is also inconsistent with the requirements in RFC9332: "...although priority MUST be bounded in order not to starve Classic traffic." DualPI2 is designed to maintain approximate per-flow fairness on L-queue and C-queue by forming a single qdisc using the coupling factor and scheduler between two queues. The qdisc provides two queues called low latency and classic. It classifies packets based on the ECN field in the IP headers. By default it directs non-ECN and ECT(0) into the classic queue and ECT(1) and CE into the low latency queue, as per the IETF spec. Each queue runs its own AQM: * The classic AQM is called PI2, which is similar to the PIE AQM but more responsive and simpler. Classic traffic requires a decent target queue (default 15ms for Internet deployment) to fully utilize the link and to avoid high drop rates. * The low latency AQM is, by default, a very shallow ECN marking threshold (1ms) similar to that used for DCTCP. The DualQ isolates the low queuing delay of the Low Latency queue from the larger delay of the 'Classic' queue. However, from a bandwidth perspective, flows in either queue will share out the link capacity as if there was just a single queue. This bandwidth pooling effect is achieved by coupling together the drop and ECN-marking probabilities of the two AQMs. The PI2 AQM has two main parameters in addition to its target delay. The integral gain factor alpha is used to slowly correct any persistent standing queue error from the target delay, while the proportional gain factor beta is used to quickly compensate for queue changes (growth or shrinkage). Either alpha and beta are given as a parameter, or they can be calculated by tc from alternative typical and maximum RTT parameters. Internally, the output of a linear Proportional Integral (PI) controller is used for both queues. This output is squared to calculate the drop or ECN-marking probability of the classic queue. This counterbalances the square-root rate equation of Reno/Cubic, which is the trick that balances flow rates across the queues. For the ECN-marking probability of the low latency queue, the output of the base AQM is multiplied by a coupling factor. This determines the balance between the flow rates in each queue. The default setting makes the flow rates roughly equal, which should be generally applicable. If DUALPI2 AQM has detected overload (due to excessive non-responsive traffic in either queue), it will switch to signaling congestion solely using drop, irrespective of the ECN field. Alternatively, it can be configured to limit the drop probability and let the queue grow and eventually overflow (like tail-drop). GSO splitting in DUALPI2 is configurable from userspace while the default behavior is to split gso. When running DUALPI2 at unshaped 10gigE with 4 download streams test, splitting gso apart results in halving the latency with no loss in throughput: Summary of tcp_4down run 'no_split_gso': avg median # data pts Ping (ms) ICMP : 0.53 0.30 ms 350 TCP download avg : 2326.86 N/A Mbits/s 350 TCP download sum : 9307.42 N/A Mbits/s 350 TCP download::1 : 2672.99 2568.73 Mbits/s 350 TCP download::2 : 2586.96 2570.51 Mbits/s 350 TCP download::3 : 1786.26 1798.82 Mbits/s 350 TCP download::4 : 2261.21 2309.49 Mbits/s 350 Summart of tcp_4down run 'split_gso': avg median # data pts Ping (ms) ICMP   : 0.22 0.23 ms 350 TCP download avg : 2335.02 N/A Mbits/s 350 TCP download sum : 9340.09 N/A Mbits/s 350 TCP download::1 : 2335.30 2334.22 Mbits/s 350 TCP download::2 : 2334.72 2334.20 Mbits/s 350 TCP download::3 : 2335.28 2334.58 Mbits/s 350 TCP download::4 : 2334.79 2334.39 Mbits/s 350 A similar result is observed when running DUALPI2 at unshaped 1gigE with 1 download stream test: Summary of tcp_1down run 'no_split_gso': avg median # data pts Ping (ms) ICMP : 1.13 1.25 ms 350 TCP download : 941.41 941.46 Mbits/s 350 Summart of tcp_1down run 'split_gso': avg median # data pts Ping (ms) ICMP : 0.51 0.55 ms 350 TCP download : 941.41 941.45 Mbits/s 350 Additional details can be found in the draft: https://datatracker.ietf.org/doc/html/rfc9332 Signed-off-by: Koen De Schepper Co-developed-by: Olga Albisser Signed-off-by: Olga Albisser Co-developed-by: Olivier Tilmans Signed-off-by: Olivier Tilmans Co-developed-by: Henrik Steen Signed-off-by: Henrik Steen Signed-off-by: Bob Briscoe Signed-off-by: Ilpo Järvinen Co-developed-by: Chia-Yu Chang Signed-off-by: Chia-Yu Chang Acked-by: Dave Taht --- include/net/dropreason-core.h | 6 + net/sched/Kconfig | 12 + net/sched/Makefile | 1 + net/sched/sch_dualpi2.c | 453 ++++++++++++++++++++++++++++++++++ 4 files changed, 472 insertions(+) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index bea77934a235..faae9f416e54 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -120,6 +120,7 @@ FN(ARP_PVLAN_DISABLE) \ FN(MAC_IEEE_MAC_CONTROL) \ FN(BRIDGE_INGRESS_STP_STATE) \ + FN(DUALPI2_STEP_DROP) \ FNe(MAX) /** @@ -570,6 +571,11 @@ enum skb_drop_reason { * ingress bridge port does not allow frames to be forwarded. */ SKB_DROP_REASON_BRIDGE_INGRESS_STP_STATE, + /** + * @SKB_DROP_REASON_DUALPI2_STEP_DROP: dropped by the step drop + * threshold of DualPI2 qdisc. + */ + SKB_DROP_REASON_DUALPI2_STEP_DROP, /** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen diff --git a/net/sched/Kconfig b/net/sched/Kconfig index a800127effcd..d73db028a6bd 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig @@ -403,6 +403,18 @@ config NET_SCH_ETS If unsure, say N. +config NET_SCH_DUALPI2 + tristate "Dual Queue PI Square (DUALPI2) scheduler" + help + Say Y here if you want to use the Dual Queue Proportional Integral + Controller Improved with a Square scheduling algorithm. + For more information, please see https://tools.ietf.org/html/rfc9332 + + To compile this driver as a module, choose M here: the module + will be called sch_dualpi2. + + If unsure, say N. + menuconfig NET_SCH_DEFAULT bool "Allow override default queue discipline" help diff --git a/net/sched/Makefile b/net/sched/Makefile index 82c3f78ca486..1abb06554057 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -62,6 +62,7 @@ obj-$(CONFIG_NET_SCH_FQ_PIE) += sch_fq_pie.o obj-$(CONFIG_NET_SCH_CBS) += sch_cbs.o obj-$(CONFIG_NET_SCH_ETF) += sch_etf.o obj-$(CONFIG_NET_SCH_TAPRIO) += sch_taprio.o +obj-$(CONFIG_NET_SCH_DUALPI2) += sch_dualpi2.o obj-$(CONFIG_NET_CLS_U32) += cls_u32.o obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o diff --git a/net/sched/sch_dualpi2.c b/net/sched/sch_dualpi2.c index 78027d6ce917..2faa45d6ac46 100644 --- a/net/sched/sch_dualpi2.c +++ b/net/sched/sch_dualpi2.c @@ -116,8 +116,45 @@ struct dualpi2_sched_data { u32 step_marks; /* ECN mark pkt counter due to step AQM */ u32 memory_used; /* Memory used of both queues */ u32 max_memory_used;/* Maximum used memory */ + + struct { /* Deferred drop statistics */ + u32 cnt; /* Packets dropped */ + u32 len; /* Bytes dropped */ + } deferred_drops; +}; + +struct dualpi2_skb_cb { + u64 ts; /* Timestamp at enqueue */ + u8 apply_step:1, /* Can we apply the step threshold */ + classified:2, /* Packet classification results */ + ect:2; /* Packet ECT codepoint */ +}; + +enum dualpi2_classification_results { + DUALPI2_C_CLASSIC = 0, /* C-queue */ + DUALPI2_C_L4S = 1, /* L-queue (scale mark/classic drop) */ + DUALPI2_C_LLLL = 2, /* L-queue (no drops/marks) */ + __DUALPI2_C_MAX /* Keep last*/ }; +static struct dualpi2_skb_cb *dualpi2_skb_cb(struct sk_buff *skb) +{ + qdisc_cb_private_validate(skb, sizeof(struct dualpi2_skb_cb)); + return (struct dualpi2_skb_cb *)qdisc_skb_cb(skb)->data; +} + +static u64 dualpi2_sojourn_time(struct sk_buff *skb, u64 reference) +{ + return reference - dualpi2_skb_cb(skb)->ts; +} + +static u64 head_enqueue_time(struct Qdisc *q) +{ + struct sk_buff *skb = qdisc_peek_head(q); + + return skb ? dualpi2_skb_cb(skb)->ts : 0; +} + static u32 dualpi2_scale_alpha_beta(u32 param) { u64 tmp = ((u64)param * MAX_PROB >> ALPHA_BETA_SCALING); @@ -139,6 +176,25 @@ static ktime_t next_pi2_timeout(struct dualpi2_sched_data *q) return ktime_add_ns(ktime_get_ns(), q->pi2.tupdate); } +static bool skb_is_l4s(struct sk_buff *skb) +{ + return dualpi2_skb_cb(skb)->classified == DUALPI2_C_L4S; +} + +static bool skb_in_l_queue(struct sk_buff *skb) +{ + return dualpi2_skb_cb(skb)->classified != DUALPI2_C_CLASSIC; +} + +static bool dualpi2_mark(struct dualpi2_sched_data *q, struct sk_buff *skb) +{ + if (INET_ECN_set_ce(skb)) { + q->ecn_mark++; + return true; + } + return false; +} + static void dualpi2_reset_c_protection(struct dualpi2_sched_data *q) { q->c_protection.credit = q->c_protection.init; @@ -158,6 +214,401 @@ static void dualpi2_calculate_c_protection(struct Qdisc *sch, dualpi2_reset_c_protection(q); } +static bool dualpi2_roll(u32 prob) +{ + return get_random_u32() <= prob; +} + +/* Packets in the C-queue are subject to a marking probability pC, which is the + * square of the internal PI probability (i.e., have an overall lower mark/drop + * probability). If the qdisc is overloaded, ignore ECT values and only drop. + * + * Note that this marking scheme is also applied to L4S packets during overload. + * Return true if packet dropping is required in C queue + */ +static bool dualpi2_classic_marking(struct dualpi2_sched_data *q, + struct sk_buff *skb, u32 prob, + bool overload) +{ + if (dualpi2_roll(prob) && dualpi2_roll(prob)) { + if (overload || dualpi2_skb_cb(skb)->ect == INET_ECN_NOT_ECT) + return true; + dualpi2_mark(q, skb); + } + return false; +} + +/* Packets in the L-queue are subject to a marking probability pL given by the + * internal PI probability scaled by the coupling factor. + * + * On overload (i.e., @local_l_prob is >= 100%): + * - if the qdisc is configured to trade losses to preserve latency (i.e., + * @q->drop_overload), apply classic drops first before marking. + * - otherwise, preserve the "no loss" property of ECN at the cost of queueing + * delay, eventually resulting in taildrop behavior once sch->limit is + * reached. + * Return true if packet dropping is required in L queue + */ +static bool dualpi2_scalable_marking(struct dualpi2_sched_data *q, + struct sk_buff *skb, + u64 local_l_prob, u32 prob, + bool overload) +{ + if (overload) { + /* Apply classic drop */ + if (!q->drop_overload || + !(dualpi2_roll(prob) && dualpi2_roll(prob))) + goto mark; + return true; + } + + /* We can safely cut the upper 32b as overload==false */ + if (dualpi2_roll(local_l_prob)) { + /* Non-ECT packets could have classified as L4S by filters. */ + if (dualpi2_skb_cb(skb)->ect == INET_ECN_NOT_ECT) + return true; +mark: + dualpi2_mark(q, skb); + } + return false; +} + +/* Decide whether a given packet must be dropped (or marked if ECT), according + * to the PI2 probability. + * + * Never mark/drop if we have a standing queue of less than 2 MTUs. + */ +static bool must_drop(struct Qdisc *sch, struct dualpi2_sched_data *q, + struct sk_buff *skb) +{ + u64 local_l_prob; + bool overload; + u32 prob; + + if (sch->qstats.backlog < 2 * psched_mtu(qdisc_dev(sch))) + return false; + + prob = READ_ONCE(q->pi2.prob); + local_l_prob = (u64)prob * q->coupling_factor; + overload = local_l_prob > MAX_PROB; + + switch (dualpi2_skb_cb(skb)->classified) { + case DUALPI2_C_CLASSIC: + return dualpi2_classic_marking(q, skb, prob, overload); + case DUALPI2_C_L4S: + return dualpi2_scalable_marking(q, skb, local_l_prob, prob, + overload); + default: /* DUALPI2_C_LLLL */ + return false; + } +} + +static void dualpi2_read_ect(struct sk_buff *skb) +{ + struct dualpi2_skb_cb *cb = dualpi2_skb_cb(skb); + int wlen = skb_network_offset(skb); + + switch (skb_protocol(skb, true)) { + case htons(ETH_P_IP): + wlen += sizeof(struct iphdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + goto not_ecn; + + cb->ect = ipv4_get_dsfield(ip_hdr(skb)) & INET_ECN_MASK; + break; + case htons(ETH_P_IPV6): + wlen += sizeof(struct ipv6hdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + goto not_ecn; + + cb->ect = ipv6_get_dsfield(ipv6_hdr(skb)) & INET_ECN_MASK; + break; + default: + goto not_ecn; + } + return; + +not_ecn: + /* Non pullable/writable packets can only be dropped hence are + * classified as not ECT. + */ + cb->ect = INET_ECN_NOT_ECT; +} + +static int dualpi2_skb_classify(struct dualpi2_sched_data *q, + struct sk_buff *skb) +{ + struct dualpi2_skb_cb *cb = dualpi2_skb_cb(skb); + struct tcf_result res; + struct tcf_proto *fl; + int result; + + dualpi2_read_ect(skb); + if (cb->ect & q->ecn_mask) { + cb->classified = DUALPI2_C_L4S; + return NET_XMIT_SUCCESS; + } + + if (TC_H_MAJ(skb->priority) == q->sch->handle && + TC_H_MIN(skb->priority) < __DUALPI2_C_MAX) { + cb->classified = TC_H_MIN(skb->priority); + return NET_XMIT_SUCCESS; + } + + fl = rcu_dereference_bh(q->tcf_filters); + if (!fl) { + cb->classified = DUALPI2_C_CLASSIC; + return NET_XMIT_SUCCESS; + } + + result = tcf_classify(skb, NULL, fl, &res, false); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + case TC_ACT_TRAP: + return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + } +#endif + cb->classified = TC_H_MIN(res.classid) < __DUALPI2_C_MAX ? + TC_H_MIN(res.classid) : DUALPI2_C_CLASSIC; + } + return NET_XMIT_SUCCESS; +} + +static int dualpi2_enqueue_skb(struct sk_buff *skb, struct Qdisc *sch, + struct sk_buff **to_free) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct dualpi2_skb_cb *cb; + + if (unlikely(qdisc_qlen(sch) >= sch->limit) || + unlikely((u64)q->memory_used + skb->truesize > q->memory_limit)) { + qdisc_qstats_overlimit(sch); + if (skb_in_l_queue(skb)) + qdisc_qstats_overlimit(q->l_queue); + return qdisc_drop_reason(skb, sch, to_free, + SKB_DROP_REASON_QDISC_OVERLIMIT); + } + + if (q->drop_early && must_drop(sch, q, skb)) { + qdisc_drop_reason(skb, sch, to_free, + SKB_DROP_REASON_QDISC_OVERLIMIT); + return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + } + + cb = dualpi2_skb_cb(skb); + cb->ts = ktime_get_ns(); + q->memory_used += skb->truesize; + if (q->memory_used > q->max_memory_used) + q->max_memory_used = q->memory_used; + + if (qdisc_qlen(sch) > q->maxq) + q->maxq = qdisc_qlen(sch); + + if (skb_in_l_queue(skb)) { + /* Only apply the step if a queue is building up */ + dualpi2_skb_cb(skb)->apply_step = skb_is_l4s(skb) && + qdisc_qlen(q->l_queue) >= q->min_qlen_step; + /* Keep the overall qdisc stats consistent */ + ++sch->q.qlen; + qdisc_qstats_backlog_inc(sch, skb); + ++q->packets_in_l; + if (!q->l_head_ts) + q->l_head_ts = cb->ts; + return qdisc_enqueue_tail(skb, q->l_queue); + } + ++q->packets_in_c; + if (!q->c_head_ts) + q->c_head_ts = cb->ts; + return qdisc_enqueue_tail(skb, sch); +} + +/* By default, dualpi2 will split GSO skbs into independent skbs and enqueue + * each of those individually. This yields the following benefits, at the + * expense of CPU usage: + * - Finer-grained AQM actions as the sub-packets of a burst no longer share the + * same fate (e.g., the random mark/drop probability is applied individually) + * - Improved precision of the starvation protection/WRR scheduler at dequeue, + * as the size of the dequeued packets will be smaller. + */ +static int dualpi2_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, + struct sk_buff **to_free) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + int err; + + err = dualpi2_skb_classify(q, skb); + if (err != NET_XMIT_SUCCESS) { + if (err & __NET_XMIT_BYPASS) + qdisc_qstats_drop(sch); + __qdisc_drop(skb, to_free); + return err; + } + + if (q->split_gso && skb_is_gso(skb)) { + netdev_features_t features; + struct sk_buff *nskb, *next; + int cnt, byte_len, orig_len; + int err; + + features = netif_skb_features(skb); + nskb = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); + if (IS_ERR_OR_NULL(nskb)) + return qdisc_drop(skb, sch, to_free); + + cnt = 1; + byte_len = 0; + orig_len = qdisc_pkt_len(skb); + skb_list_walk_safe(nskb, nskb, next) { + skb_mark_not_on_list(nskb); + qdisc_skb_cb(nskb)->pkt_len = nskb->len; + dualpi2_skb_cb(nskb)->classified = + dualpi2_skb_cb(skb)->classified; + dualpi2_skb_cb(nskb)->ect = dualpi2_skb_cb(skb)->ect; + err = dualpi2_enqueue_skb(nskb, sch, to_free); + if (err == NET_XMIT_SUCCESS) { + /* Compute the backlog adjustment that needs + * to be propagated in the qdisc tree to reflect + * all new skbs successfully enqueued. + */ + ++cnt; + byte_len += nskb->len; + } + } + if (err == NET_XMIT_SUCCESS) { + /* The caller will add the original skb stats to its + * backlog, compensate this. + */ + --cnt; + byte_len -= orig_len; + } + qdisc_tree_reduce_backlog(sch, -cnt, -byte_len); + consume_skb(skb); + return err; + } + return dualpi2_enqueue_skb(skb, sch, to_free); +} + +/* Select the queue from which the next packet can be dequeued, ensuring that + * neither queue can starve the other with a WRR scheduler. + * + * The sign of the WRR credit determines the next queue, while the size of + * the dequeued packet determines the magnitude of the WRR credit change. If + * either queue is empty, the WRR credit is kept unchanged. + * + * As the dequeued packet can be dropped later, the caller has to perform the + * qdisc_bstats_update() calls. + */ +static struct sk_buff *dequeue_packet(struct Qdisc *sch, + struct dualpi2_sched_data *q, + int *credit_change, + u64 now) +{ + struct sk_buff *skb = NULL; + int c_len; + + *credit_change = 0; + c_len = qdisc_qlen(sch) - qdisc_qlen(q->l_queue); + if (qdisc_qlen(q->l_queue) && (!c_len || q->c_protection.credit <= 0)) { + skb = __qdisc_dequeue_head(&q->l_queue->q); + WRITE_ONCE(q->l_head_ts, head_enqueue_time(q->l_queue)); + if (c_len) + *credit_change = q->c_protection.wc; + qdisc_qstats_backlog_dec(q->l_queue, skb); + /* Keep the global queue size consistent */ + --sch->q.qlen; + q->memory_used -= skb->truesize; + } else if (c_len) { + skb = __qdisc_dequeue_head(&sch->q); + WRITE_ONCE(q->c_head_ts, head_enqueue_time(sch)); + if (qdisc_qlen(q->l_queue)) + *credit_change = ~((s32)q->c_protection.wl) + 1; + q->memory_used -= skb->truesize; + } else { + dualpi2_reset_c_protection(q); + return NULL; + } + *credit_change *= qdisc_pkt_len(skb); + qdisc_qstats_backlog_dec(sch, skb); + return skb; +} + +static int do_step_aqm(struct dualpi2_sched_data *q, struct sk_buff *skb, + u64 now) +{ + u64 qdelay = 0; + + if (q->step.in_packets) + qdelay = qdisc_qlen(q->l_queue); + else + qdelay = dualpi2_sojourn_time(skb, now); + + if (dualpi2_skb_cb(skb)->apply_step && qdelay > q->step.thresh) { + if (!dualpi2_skb_cb(skb)->ect) + /* Drop this non-ECT packet */ + return 1; + if (dualpi2_mark(q, skb)) + ++q->step_marks; + } + qdisc_bstats_update(q->l_queue, skb); + return 0; +} + +static void drop_and_retry(struct dualpi2_sched_data *q, struct sk_buff *skb, + struct Qdisc *sch, enum skb_drop_reason reason) +{ + ++q->deferred_drops.cnt; + q->deferred_drops.len += qdisc_pkt_len(skb); + kfree_skb_reason(skb, reason); + qdisc_qstats_drop(sch); +} + +static struct sk_buff *dualpi2_qdisc_dequeue(struct Qdisc *sch) +{ + struct dualpi2_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + int credit_change; + u64 now; + + now = ktime_get_ns(); + + while ((skb = dequeue_packet(sch, q, &credit_change, now))) { + if (!q->drop_early && must_drop(sch, q, skb)) { + drop_and_retry(q, skb, sch, + SKB_DROP_REASON_QDISC_CONGESTED); + continue; + } + + if (skb_in_l_queue(skb) && do_step_aqm(q, skb, now)) { + qdisc_qstats_drop(q->l_queue); + drop_and_retry(q, skb, sch, + SKB_DROP_REASON_DUALPI2_STEP_DROP); + continue; + } + + q->c_protection.credit += credit_change; + qdisc_bstats_update(sch, skb); + break; + } + + /* We cannot call qdisc_tree_reduce_backlog() if our qlen is 0, + * or HTB crashes. + */ + if (q->deferred_drops.cnt && qdisc_qlen(sch)) { + qdisc_tree_reduce_backlog(sch, q->deferred_drops.cnt, + q->deferred_drops.len); + q->deferred_drops.cnt = 0; + q->deferred_drops.len = 0; + } + return skb; +} + static s64 __scale_delta(u64 diff) { do_div(diff, 1 << ALPHA_BETA_GRANULARITY); @@ -604,6 +1055,8 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .id = "dualpi2", .cl_ops = &dualpi2_class_ops, .priv_size = sizeof(struct dualpi2_sched_data), + .enqueue = dualpi2_qdisc_enqueue, + .dequeue = dualpi2_qdisc_dequeue, .peek = qdisc_peek_dequeued, .init = dualpi2_init, .destroy = dualpi2_destroy,