From patchwork Fri Jun 2 16:29:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 102655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1157648vqr; Fri, 2 Jun 2023 09:40:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yYUQ+5Q9P0+50xSMY3wcZt38I6zvDVacQMY5UxtIZHQUwHE3Zt+YO5+RMS3tnE1oubLbq X-Received: by 2002:a17:902:d506:b0:1ad:eb62:f617 with SMTP id b6-20020a170902d50600b001adeb62f617mr601281plg.45.1685724015284; Fri, 02 Jun 2023 09:40:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685724015; cv=pass; d=google.com; s=arc-20160816; b=VjJ4qppky2vIYI4Qk9Eq7GesJC0drLlBrQDIpW9Qnxy72eu/5CXY1hX1hAYkmzql4r Rl9JewAUqiVJDVQIBLmsNTquGPf+qDqELZ5FneCy1yRoqnxl9fWFcVu/Mp7XRrZ0QCml 8RLBkEYBCYDsORFq26ZqlVziG3DiLIvZbiOyDI5ejm2kjdciiljjxGNgOl6LUXlM+QIS ZetMPFattLHG//NZ/0U5aEVyrQ/n3yk027P/XzSwgsCbSYDh3Dm0fseDujXhTUb0I9Af LTpetgt6kXZnE3M0FNvW7gSJMn71JOi6SIAMpzSFrWsT5LxE88WE2DlM9QaUlyLSvlHF o6ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=TpUPR95aWNLLc8ygCD+ogUcMebiV1U9TfzQlRtEEor4=; b=YRwQMBupqB7r2geXta2weYUnRyFY2PYwQ4WfuHZ77CAKJKuw0kfbTx1Dzy4FcaITA/ CpzfGGzb5aUNWoaaWyfIJwtNLp1Gq7p9/vPlxqTWc3ne8O0zgVZ0RZAZsbCdmM/2zO/E z7/Dl66LXJjh+QklOqGDp9TuVEA8Lno291Q+GvAja9Rv/VOe1ohxlyzJiuthtE+upgBa GpvfVqeh1XgTlxhHgSPvzEVbXotyax/1+aSiBhpbox0ipVwYTeqm1L2dMRC8e2w/Cr5q z5NE5hbBofSz4BWwY4RRxPrQU8V8FHgcW74CHFEkEMlOp5FzcDEafoCWSveZH16YQEdx TZhw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=bn5NTeeC; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170902ed5400b0019a96849d6dsi1089614plb.605.2023.06.02.09.40.02; Fri, 02 Jun 2023 09:40:15 -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=@nxp.com header.s=selector2 header.b=bn5NTeeC; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236922AbjFBQaO (ORCPT + 99 others); Fri, 2 Jun 2023 12:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236860AbjFBQaB (ORCPT ); Fri, 2 Jun 2023 12:30:01 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2083.outbound.protection.outlook.com [40.107.249.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B71FEB4; Fri, 2 Jun 2023 09:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ADf+PziJAgbCEdJy9gXH9AKX0BA2GJZ7yRpWuKTyA+OCWC/oXuVJOpki/1mAtNLSpNZnrCkLKaaMXLdxk191D326c3U7IKM9CRNKBnymvUGIO41VyZ7HNVw8FIkzrATxy8Zb289SFrhB67x+6hEGnpUuQA0/dqRLCWniAaKIVTpBhytdNgi4Zb0pSThe+Bz4ThihcqLyVEC692CiB3+O8g93dDISXxpqQxJCP/zb1gMoZcB8gX1fL7g7uk8rX2ZgtiUrMszF8NvDpmkgs7dQ0mKVf3nphaiTEDNdQE20TztpHTmMZvXYZ7Ppta04LbZ4/OLma4JcrxSPt+/PUmAA3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=TpUPR95aWNLLc8ygCD+ogUcMebiV1U9TfzQlRtEEor4=; b=SmWrxprPJ76NBZSZjvesqEX1HkjdCRYxYSKPmxj3ifRaEq9KBdmX0v/Zhwr1IN6qs2Pyf0GuWQrUijVu+zzBqM+KxRhtF3tphu9JfiE/UpDwKNeDgF1s+xDMitt4qUXq6Z8i/tDS9P9+cvAeq0ML/cp3p+/vGWUyO7Ux0khXStOwsrBrronL+f4AuJ1DJO5CUF/4PsUNM1nfVe6H4NYBx3g8Bn39lgKQeEI2c0D84kZgfFAyisbI+5jwlunjKQfNvVlc4ranv61Bs1SCW6S6RMiqpdtwjkD7plne8ASMLl7xL6px55MLT529BlOz6Pd2sszxXpXuu7rDLFBE9BbKzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TpUPR95aWNLLc8ygCD+ogUcMebiV1U9TfzQlRtEEor4=; b=bn5NTeeCQbMK8x85h87z2uZBARkOpg+gH7TiziBPAGuVyOb5KCcfTp2gTIWk0PocROq9E24g6+Q+LjwxTargtU+ReBKnueMILQ0UfYKpbLoR7XEX1Ks+brpKpSeMXohG4Wy7RFTAZam8q1z/mn1Ob/FC/cvKqbEhUFR752TLan4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by AM0PR04MB6867.eurprd04.prod.outlook.com (2603:10a6:208:182::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.21; Fri, 2 Jun 2023 16:29:52 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::47e4:eb1:e83c:fa4a]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::47e4:eb1:e83c:fa4a%4]) with mapi id 15.20.6455.020; Fri, 2 Jun 2023 16:29:52 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jamal Hadi Salim , Cong Wang , Jiri Pirko , linux-kernel@vger.kernel.org, Peilin Ye , Pedro Tammela Subject: [RFC PATCH net-next] net/sched: introduce pretty printers for Qdiscs Date: Fri, 2 Jun 2023 19:29:35 +0300 Message-Id: <20230602162935.2380811-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: VI1PR09CA0120.eurprd09.prod.outlook.com (2603:10a6:803:78::43) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|AM0PR04MB6867:EE_ X-MS-Office365-Filtering-Correlation-Id: bb87a41d-dd50-446c-8abf-08db63869793 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MHSnlWpxnExkRzhBeTam2LW/ljJyE8uSUyc5L1hCLueb+nYdKP35w2PatB0veU/7PFBYi65QJSQmNsGFB9QYI1RJIGHCoCK/6DHJMHstTASfQV7bArkvoUnd25tFfar3WQViVlFfmq/HYT54urAIIsAgX05AFM58J1XNLl0lBjxyEJOwv8IzM0xvRO4tqSKAkP9BR+r7DHnIBvEubypLHHdwTueOwZnaIRCUIL31+fpBHdIL1aVhV9WVg6SdQL8nkSQGlBcxKnarbfnBhrfNthBlsKt4S2SYL45cPfA2+r7ESiB4lzt8yWEw2FPZLVrCNE4OYLjoZAeLTSz6kvdfQW7HsCP/Ax6YQNNIKR6Fhk+mMv29eoKSWVN6qq3BEuYcOOUqogny/BzNLB2djp7yrwona7Sod00i+7H59ub5ILjGqVkdyvH/FrQvU5yIIDyNaxUQh6bXTeHeha0+fzjbBKr1otWWup10Ztzp8hS+TE8XDkGjDBiMoh+jN459nGoRMaqdM7AiFXqxcG38J/H0nYuGV6CmXU8jVI7cTgwJrH9V9eKaqdlZfPQ73q6xwIkqqY8vBPIoYXcvbiKjASXzA6PGsO41WC8Z+UIxfX32qst2kPHhvI6SosPmtVvCss5O X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(396003)(39860400002)(346002)(136003)(376002)(451199021)(6512007)(186003)(6506007)(1076003)(26005)(41300700001)(38350700002)(38100700002)(2616005)(83380400001)(6486002)(6666004)(52116002)(54906003)(36756003)(66556008)(66476007)(4326008)(66946007)(6916009)(478600001)(316002)(44832011)(7416002)(5660300002)(2906002)(8676002)(86362001)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BgDmRz0IoDfEg+dqOabpiNt1EtYHLrrH9zSoYS5gS6DMp/H7fPqscbw8hsm3xHrdmzAW+XFSEcQXBZOv/eg0f0/GmCZYlUXYsQ1gX8GR2jwBUV0H0AbgAqqkpMVTDFP5AiEK4E7eE0xCgzKKR/RrX5FCQWCa3BCFf8evQHFl1Hsu+Oe4czclbYiE8hDWPRjxLWGD6VpUlvkvLHfc7VLadI9jL6GCBRwM2uXsnhgB3zY3MWrpuXkdF7RZwL5CQY5HQImeiN+Knr4rwCBW2LoV1P6ax1npc3Eazm8kqpV/aFFUm7dwUAfRBanmCsaNWPapZiVpPhxh4N5g4c+OJZZwyO+jQ3WvSEOhInM2vz9KFNf567cgn4Q0Eb4+uj93k2Z5DhwPqzWBvGtNtSkW7KBVkM7FxCLH2bD7gyJQqcH3XGydq5q9jap3j5G69d4+riT7vBE5kc9O6EA1k4C7KGkcjsl8FcybtPqxv0RSVIvkHsAFEzvj5N6vZh1v09ZP9Q5XI5rhZICdgNbH+djRNPcLU/DPpvQYVd0bmmO9W9tDW7j6epHz4cGIalDCPy2I/neqVrCTParpwxhoKJR5RjG3TZ5qi2YrlKP07ngUwv0Fy9YlACAyi/BJItFg1gDVxHZGHObTfBbgrwPUDqeN4II+KQXpGbOWElhitInYpqX8JFG1yENQ/H9+ksr6DnWQwUXAEl4qls1REe4B3PzhlGCCHfxyAzzi2uaBQCLeAuCY39irVlsIXwqe9Pqh5247gsXchOCVb3OwF7h2oy/r9aJD7z8AdWQ+tad0ARBKSKaRTopqQ2syv7BvU6trywyNLLZJ2UTQeNjXF8lP1qts3GFCeVDy8M6yqXnpwmeoxembnIxVfFNDgOvNDavtSwmL2C8uyaAOytBG7+VbnFHs11/drlQsaRzMcsB/Vy2p694wcWeM5TjwpxSL96Pi+aabxIWoyOXFuaKLEsvDX32PL08brbvFdC5oYz/qoTLvclmgT2JQpgXavYNsMnReryROjjqKhXvkqto0JiS07rZdifWlYySn+Drm5rlSPkkiqf7xefYelQbaV8E4AXW+HrWWuvUTCTKQQ0liEC+rhR03zM2kfnYjPuXXgfX1KrN4eeds2r+cIOfwGxernWesiS2e1e9KiXA1UB7pH3ZTGGhpoJLx1yYep9yw92SreK/WmN4BJ5CE0eEGFfIZ1rElJTSdraNvKw+GCmFeLfFrZ80xpUr6Dwd9VFzMfHHE2TP1kKcVhhOLQ9SIIwUe5iilD1WZFv6rwRhiblCo29nSbuuf0NFvYeHLy9TpdoeZzBCfVPa9FifqNNN/CM/6zBBRY6MhAkuOgU1pZAZFqufVWqzQp0rkT0GtBw8rQNyx2DlhKb23GjxHogt0uW+7cg0mPHxfsRBcze7qoIANgPtm/ppgRAmaW/w+fgMk1rCiUQiM95OX9StEu7Ug+dzWBzBJHCok2aNzQUOLpWJLXdkMnkDmSx67gWRj/orodt+7m22XBQVMov2BI6mRyo1mzw2OceqiJXTmq2mOS3OhuOQ9Fc3lczp2zs6vcQvLiYa+XvPQMmhlhU3AZPNl540csvE1Z0wk/eHf7KCC3cWBKBVrCedrDpBGrw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb87a41d-dd50-446c-8abf-08db63869793 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2023 16:29:52.6074 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5PuCoRQBie9sl/2hHmr+abjw15pwykJtg0WN+MlfDFMx9Hxr+Igy4b5GfDd85Qc7KjoDRaQpUWNJwIpf93wtGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6867 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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?1767609745281414380?= X-GMAIL-MSGID: =?utf-8?q?1767609745281414380?= Sometimes when debugging Qdiscs it may be confusing to know exactly what you're looking at, especially since they're hierarchical. Pretty printing the handle, parent handle and netdev is a bit cumbersome, so this patch proposes a set of wrappers around __qdisc_printk() which are heavily inspired from __net_printk(). It is assumed that these printers will be more useful for untalented kernel hackers such as myself rather than to the overall quality of the code, since Qdiscs rarely print stuff to the kernel log by design (and where they do, maybe that should be reconsidered in the first place). A single demo conversion has been made, there is room for more if the idea is appreciated. Signed-off-by: Vladimir Oltean --- include/net/sch_debug.h | 45 +++++++++++++++++++++ net/sched/Makefile | 2 +- net/sched/sch_api.c | 4 +- net/sched/sch_debug.c | 86 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 include/net/sch_debug.h create mode 100644 net/sched/sch_debug.c diff --git a/include/net/sch_debug.h b/include/net/sch_debug.h new file mode 100644 index 000000000000..032de4710671 --- /dev/null +++ b/include/net/sch_debug.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_SCHED_DEBUG_H +#define __NET_SCHED_DEBUG_H + +#include +#include + +struct Qdisc; + +__printf(3, 4) __cold +void qdisc_printk(const char *level, const struct Qdisc *sch, + const char *format, ...); +__printf(2, 3) __cold +void qdisc_emerg(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_alert(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_crit(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_err(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_warn(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_notice(const struct Qdisc *sch, const char *format, ...); +__printf(2, 3) __cold +void qdisc_info(const struct Qdisc *sch, const char *format, ...); + +#if defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) +#define qdisc_dbg(__sch, format, args...) \ +do { \ + dynamic_qdisc_dbg(__sch, format, ##args); \ +} while (0) +#elif defined(DEBUG) +#define qdisc_dbg(__sch, format, args...) \ + qdisc_printk(KERN_DEBUG, __sch, format, ##args) +#else +#define qdisc_dbg(__sch, format, args...) \ +({ \ + if (0) \ + qdisc_printk(KERN_DEBUG, __sch, format, ##args); \ +}) +#endif + +#endif diff --git a/net/sched/Makefile b/net/sched/Makefile index b5fd49641d91..ab13bf7db283 100644 --- a/net/sched/Makefile +++ b/net/sched/Makefile @@ -6,7 +6,7 @@ obj-y := sch_generic.o sch_mq.o obj-$(CONFIG_INET) += sch_frag.o -obj-$(CONFIG_NET_SCHED) += sch_api.o sch_blackhole.o +obj-$(CONFIG_NET_SCHED) += sch_api.o sch_blackhole.o sch_debug.o obj-$(CONFIG_NET_CLS) += cls_api.o obj-$(CONFIG_NET_CLS_ACT) += act_api.o obj-$(CONFIG_NET_ACT_POLICE) += act_police.o diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index fdb8f429333d..a6bfe2e40f89 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -597,8 +598,7 @@ EXPORT_SYMBOL(__qdisc_calculate_pkt_len); void qdisc_warn_nonwc(const char *txt, struct Qdisc *qdisc) { if (!(qdisc->flags & TCQ_F_WARN_NONWC)) { - pr_warn("%s: %s qdisc %X: is non-work-conserving?\n", - txt, qdisc->ops->id, qdisc->handle >> 16); + qdisc_warn(qdisc, "%s: qdisc is non-work-conserving?\n", txt); qdisc->flags |= TCQ_F_WARN_NONWC; } } diff --git a/net/sched/sch_debug.c b/net/sched/sch_debug.c new file mode 100644 index 000000000000..1f47dac88c6e --- /dev/null +++ b/net/sched/sch_debug.c @@ -0,0 +1,86 @@ +#include +#include +#include + +static void qdisc_handle_str(u32 handle, char *str) +{ + if (handle == TC_H_ROOT) { + sprintf(str, "root"); + return; + } else if (handle == TC_H_INGRESS) { + sprintf(str, "ingress"); + return; + } else { + sprintf(str, "%x:%x", TC_H_MAJ(handle) >> 16, TC_H_MIN(handle)); + return; + } +} + +static void __qdisc_printk(const char *level, const struct Qdisc *sch, + struct va_format *vaf) +{ + struct net_device *dev = qdisc_dev(sch); + char handle_str[10], parent_str[10]; + + qdisc_handle_str(sch->handle, handle_str); + qdisc_handle_str(sch->parent, parent_str); + + if (dev && dev->dev.parent) { + dev_printk_emit(level[1] - '0', + dev->dev.parent, + "%s %s %s%s %s %s parent %s: %pV", + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + sch->ops->id, handle_str, parent_str, vaf); + } else if (dev) { + printk("%s%s%s %s %s parent %s: %pV", + level, netdev_name(dev), netdev_reg_state(dev), + sch->ops->id, handle_str, parent_str, vaf); + } else { + printk("%s(NULL net_device) %s %s parent %s: %pV", level, + sch->ops->id, handle_str, parent_str, vaf); + } +} + +void qdisc_printk(const char *level, const struct Qdisc *sch, + const char *format, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, format); + + vaf.fmt = format; + vaf.va = &args; + + __qdisc_printk(level, sch, &vaf); + + va_end(args); +} +EXPORT_SYMBOL(qdisc_printk); + +#define define_qdisc_printk_level(func, level) \ +void func(const struct Qdisc *sch, const char *fmt, ...) \ +{ \ + struct va_format vaf; \ + va_list args; \ + \ + va_start(args, fmt); \ + \ + vaf.fmt = fmt; \ + vaf.va = &args; \ + \ + __qdisc_printk(level, sch, &vaf); \ + \ + va_end(args); \ +} \ +EXPORT_SYMBOL(func); + +define_qdisc_printk_level(qdisc_emerg, KERN_EMERG); +define_qdisc_printk_level(qdisc_alert, KERN_ALERT); +define_qdisc_printk_level(qdisc_crit, KERN_CRIT); +define_qdisc_printk_level(qdisc_err, KERN_ERR); +define_qdisc_printk_level(qdisc_warn, KERN_WARNING); +define_qdisc_printk_level(qdisc_notice, KERN_NOTICE); +define_qdisc_printk_level(qdisc_info, KERN_INFO);