From patchwork Mon Apr 14 13:11:56 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: 14050373 X-Patchwork-Delegate: kuba@kernel.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013065.outbound.protection.outlook.com [52.101.67.65]) (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 AD3E42BF3E1; Mon, 14 Apr 2025 13:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.65 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744636354; cv=fail; b=MT6ytl8EJCjDxxyjW0Po72Ef/rtyxHoppUvFJv2LWNswHwJugMGYh3qjZnuFfX2DzJpwB/BiKzYeZzLEVUjyfaQoO57MJJUITaYdpRlB/9EYHUG+GYuwV8rvr08sagsTMwx0ic5IiXQDLJQFtJ3yPBHZL+pGzXWDUYt75DKUUe4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744636354; c=relaxed/simple; bh=0A9TPHTyha+Bhj/TEMEc3oRnfPMX8v2XuztrPzg7hZc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=aU516eA2JcNcLVtadXRsGEInJjcok5PQ7BHPPa1BDZy5KWH9jmundlE8s4QDpARDKypgFrDRdRDjSK4khbnqhzniSdvNBJcADcaPF9B0nFRK6WDyEMI0SzuctWT377ZE7pMyqXRoemx+bxp7SCtjlpaIGWzg3MrX3DcgNOCXmXQ= 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=T4ToYjTB; arc=fail smtp.client-ip=52.101.67.65 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="T4ToYjTB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yq/HALcIpjTYU3agafCDXLvvigLu0E4a8TTDWAqiTTguDAsp/3ozG2HJAq7Vw4wAsoQMazWR+aDeJ8BTM0K+J/oq0Aa9ijd8E/B3uBrNfSP8JLepCPhLz6ZahLWsSKnulLkMZmen6xg1Ep7T7Ki5sSwlDppPU58L1qOjAbjijEH6gYPAbP1+cXHbb5GmcPYcMWhV72kpwLZ+IDBMcsulT+O7Kemz5zCywNC5fYtmsGT/SvtKGjiLUe9ZXoOwMd/SkZ6V8d2RTQCGBhQ7A8W+TxJGxvhvebmC4VTk0a3KxXyFL8H++BEXn4XH16VOrqmeSyAqR+TR41imCbEyvP8WqQ== 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=gXB6w1BxSsKtWdGvG9rcC5TzbKqkxABbbe3byTh0RaA=; b=SNy0fA6XvSkeFsJBOKkK6jqnTJOQWselk/O4qEpKk+0SR7CNo/d66+GBAcLQM//URdId8hzeomD0pxIu+om342WNSmnflORKEWD6hH0BIPTiUDaSsjfFuSO7WDQMj5pjH8VMi3VHqKv6RX9aKTptmdbUXeXkjS6OLopNIvB9rXWHqhRKydUuW+JqDfLLF9H5e4BAmd3/c+KyL5H2phfIhsMO229heDifAvMfGtk30SO4WkzeNjFaB0MzEp4Rf/fUNpNCogBf53rDmTfED+jdSuloQwcreiTLQxCrfHOiTHvsuQyeI5gHIZia9EKql8/mR2+MQAipiiv1mMt1joAoMg== 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=gXB6w1BxSsKtWdGvG9rcC5TzbKqkxABbbe3byTh0RaA=; b=T4ToYjTBM61NsikAR0nU2vMVLQqYiJdhjPjYd0eIeKKqNEYNudCLLgwZ0PtNKD83Gcs2PyaeM4a0v+ET9K1oA7MfXOMjb6/nvvVR6yqSY5D9cAMsAmSshk2eDb0d2DCuYWMyIBxom4qCBcJHE0Hbb5CUk7mztGo+AiQk2qhIaSFFiS0Jq0nFChlJ+fh+Ii90DOD7buCacu/VoFP4g5VlBjdHjWB87pk3FPxSRwI5ONkZB8kVwGR8yiWp30sPU7q4GvAe9fin0YJ+PxfWaq9TwuHwb+JSkwOOQvis4cI2JRpm9l1APPuL5WoNYiSpU4iDNi3jEEHuew0q1BemEpNoUA== Received: from DUZP191CA0018.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f9::8) by PAVPR07MB9191.eurprd07.prod.outlook.com (2603:10a6:102:317::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.35; Mon, 14 Apr 2025 13:12:27 +0000 Received: from DU2PEPF00028D0B.eurprd03.prod.outlook.com (2603:10a6:10:4f9:cafe::40) by DUZP191CA0018.outlook.office365.com (2603:10a6:10:4f9::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8632.34 via Frontend Transport; Mon, 14 Apr 2025 13:12:27 +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 DU2PEPF00028D0B.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8655.12 via Frontend Transport; Mon, 14 Apr 2025 13:12:27 +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 53EDCIJH000852; Mon, 14 Apr 2025 13:12:44 GMT From: chia-yu.chang@nokia-bell-labs.com To: 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 v10 RESEND net-next 4/5] sched: Dump configuration and statistics of dualpi2 qdisc Date: Mon, 14 Apr 2025 15:11:56 +0200 Message-Id: <20250414131157.97425-5-chia-yu.chang@nokia-bell-labs.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250414131157.97425-1-chia-yu.chang@nokia-bell-labs.com> References: <20250414131157.97425-1-chia-yu.chang@nokia-bell-labs.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PEPF00028D0B:EE_|PAVPR07MB9191:EE_ X-MS-Office365-Filtering-Correlation-Id: efdba670-f2a5-48c2-3143-08dd7b560127 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|36860700013|7416014|1800799024|376014|921020; X-Microsoft-Antispam-Message-Info: NFrhNl7r+x9Xdaniyp2vEua6b6zmt7E6Qy1fGAJO1CUH6tD1qkhHlbA34a+BDS7FYu7S+fxPbsaAYIG7QJZRmhLhxFLNQ6jX5lwMVi12y2nt8HW60EWAHahhHqaLhvLWudpAm7ZFXdmGTiZRRoDoBcUy2iI7pWih5uAvtb/PuMSlZbSlnubfXdlY4Izv1KxGN0b56y2wXgkBjPmzylvUL/HW3ge/3JH5TqJ6CLgd9lHyoUs2hIskYo/gPEULol1YrX+saDNY6OKVSubvjUxPzoMEExlVyHo9/0Y6FWsy4ko+q3Wf+7fjiBYf+cl+prU1FH5POljt7y3rhqlh0znAzcJsahjw1CzuaIQ3plDDYKZyINT01M4PU1Jef6PHos7KioKi3Ww1Ys3R6mxHu1ddjhD3RfSkhbO402fv4uqrSr2lYtV1eysWsuHdHhvAu8JuvLcYJg1BgkRQCaS/u+1YPKWYYgHx8WQLrGdEkWhQkbIhsvpK3NGOcqwtwxmobRO2KVRxRC3AAiNlGR6BbqpLohnP062fTuPc87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;IPV:CAL;SFV:NSPM;H:fr711usmtp2.zeu.alcatel-lucent.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(7416014)(1800799024)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: nokia-bell-labs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2025 13:12:27.2290 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: efdba670-f2a5-48c2-3143-08dd7b560127 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: DU2PEPF00028D0B.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR07MB9191 X-Patchwork-Delegate: kuba@kernel.org 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 3bf9db6d3bb3..50d40e71deb0 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); @@ -422,6 +430,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. @@ -526,6 +610,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, };