From patchwork Fri Apr 7 14:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13204945 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A6C6C6FD1D for ; Fri, 7 Apr 2023 14:15:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240532AbjDGOPX (ORCPT ); Fri, 7 Apr 2023 10:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240100AbjDGOPP (ORCPT ); Fri, 7 Apr 2023 10:15:15 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2073.outbound.protection.outlook.com [40.107.8.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 015D583F8 for ; Fri, 7 Apr 2023 07:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iPj+Pn8lmMKWyzhyI9YQvmohIWim7ie3clPhKzdux7QSs93c4pDwjffqLIwnrKjpaHyEY+PLe763zZskdJaXDwdpKPdtdzTlo1d1YQJSgU0K29pKCunXqLRJSZN7a9Yx0VrBHMDyWeWwT/ucDdNlosNtmI4AHr3n2S2ib58jv2YluT2FQfXr0OMY1rvMtKLBcOFQNEwYzmdUNii20aWi0VU73fFQX9m0LPh41RDko1dnkpNMOEUOL1V+yk46OC4ci+GiOyAfXBQ7MD0fuUDc4/p0hJL7cTvFHByapx+VnzMO2VfLPZRMIqUmpoegeFWk8kEYlfWEUdbwgWR2TBFuHw== 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=OnjROZJtGCDMTEY81tZ5d+QBvjO+bd8idaF3gAwg9kw=; b=Ahm+PGevAmWPYzL2vkOk2YUxQi2UJf8+hcHy9sWvxKpivoMa0EKtnS0XPPwAygpY5tkOADloM1pCpcSPJFNoxS6NGwLWGBh/tRI8T750Svm2yUZbwT1UgaxZi8/URZ5onUbskvoh+2TFDF7ZjUJ8uaMsvr4yinmOuawZ0mmtVAzVkjQBVKJ9ro+oRxgpBDHgMgz6JR0QLIzbw6M4NiHELlo8qiZ0K6+bHQoMThQXgERDvEuuysp3PuQwvh+ZTW0ChRknSeuO6oFihugId9NWoRzQtSNQZ0lpxJCFrXfGuNNxJGw6ApR3icbQ0tgZitiS7IkU7TM4mFyZCYlRhLUGbg== 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=OnjROZJtGCDMTEY81tZ5d+QBvjO+bd8idaF3gAwg9kw=; b=Vq+uMsNoVN9UdwyZvZq4PQF5Gsv3bjlzOJYnWEOXacIJwGeo8hhRpRw+O878g5gUyr18bbeua2pNFG5owAkcagFGOgdyNqSmZ9Jjonx67QPJCinxZeXz5EewCaofwd2XzokrI/ORFk9kjp9hHjGvkp45zz3A+83VAoeWb1CN9QY= 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 VE1PR04MB7405.eurprd04.prod.outlook.com (2603:10a6:800:1a4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Fri, 7 Apr 2023 14:15:03 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6277.033; Fri, 7 Apr 2023 14:15:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Florian Fainelli Subject: [PATCH net-next 1/2] net: dsa: add trace points for FDB/MDB operations Date: Fri, 7 Apr 2023 17:14:50 +0300 Message-Id: <20230407141451.133048-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230407141451.133048-1-vladimir.oltean@nxp.com> References: <20230407141451.133048-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0134.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::39) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VE1PR04MB7405:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c0e9eb2-90cc-4583-27ac-08db37727ab1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9etsMcAh2HGi9LSXlRhkJVLvLwzVqiGAUuF7ArXBNgHwEnZ2HEvkg1VEgORWIjDUCKKXSXoLrqk6lX/FiCrbHLlgi42ypt5WOOM0fIsxStpaTXL6X8A8CSA83Z1lm4pBoHMPj1MczV9uQW/Lawql/tFTtmt28/gkinOB3pzEnk+exFYPuP8RGvU4b5h7vOjLdhBXNQsfAdFcWIKzpAhB+xWipg+OFEsZ1K1LOsNjLpEPZEI+09T2RuX2e4FFcEIU3ILzTcGkXOfohJDM/ORg7mi4l3AuXWkwzKfnPzEZW8C8dJ4sDqRYfeFPaKDu5yNBc59MI8EdPkiGAhAPzyGBX9mmmad3756KgZWCCuqYB/QtghSPRnPzmE9AlhufHalC35gysNhFxUYDVb7qlOPWU8+dTuxr/nl90Z1KDLWOTuoUxNs0sOjl8KJQzyr4Uk0rEZesiqCtM8ecj4OXJNF2tF5p7dtyKOKmjTQXeuFjyD3f9BgmJremkDRX5y+bQ7TVc0MfqmGAw4hMUzKctDRJpo12ZVhBoNPig9p90AFWJHcj6udV+hAf3eWmqxBMLnlltm4Vp/pwcFlXHCaEivEBMObSlPuZfCH2kXGeMQyEqnX5Q1bc9ni8DEJ4WdbrSZ7y 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)(39860400002)(346002)(396003)(376002)(136003)(451199021)(36756003)(86362001)(41300700001)(52116002)(316002)(8676002)(6916009)(4326008)(54906003)(66556008)(6486002)(66476007)(66946007)(478600001)(44832011)(2906002)(8936002)(30864003)(5660300002)(186003)(38350700002)(38100700002)(6666004)(6512007)(6506007)(1076003)(26005)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5elGdAfOQWufFnYynLpanr6Oi1O3MHXZV3DRT0Zdts9I1rmvDQpr0QYIbSrnoUzm0OEK5Dh76PIGYlnXODUfKTFegeUAH8ZYMyq6bDLTfNnEivxnZMWgRQDkjCT9m0JYxAsGtgecLVBZkh+1qzJqx8aWkGY0cTH+3SpxElzCkinTG43VCg40CTSL7VacsR3eKpbFioU4N6DR6l55gtDdnmgxakhZKB7vti+gLUD6B95AGzyWAa4YMHcwHdI7G6Lc2p3E0MrS8seXoJVqr2eQcEPPHjHk7PNFKz0sQqGRETVsUKE1InQPZSjrQchuWVjWm+UJlOTx/5/RfpPDkdW4IHh3grmk3vERa3DqDaBdpXTDKGjZuDlCU0z/7zz7gHzype4yoKwYj+HpA5Bdb1viTjCx80HGa/AXhuGn2dWSuK9YTyVHBAl0mXa83ClHMrPrPTer4sm6214sv0ohNhV+O1+z9/7AoXIIGxBFa52xNtNdhOv0RkZfvhOPMUMb1hhGyAJQuGyR8SKfYHShchHqSHcOMU61E8/eh6rFGIAwgvEYABTseWQaei3wbY8BQLqheK6cXSIbuSQXEr1xszViwMYVOBIYyLy8N//rg32KOnndYFQCxa892EjvGSrYDCZXZivW0QAe3sipotXE6NjUncAbin1Oj3jJDvaJ7R6P06TmiEIRxR+P7XAr8dWUb8FIicahTvXImpEtOGt1/xXR9BJU9eqZ61+GjRkdtZcCX3uK7v9CbLQAIz98jPDF3CMVjmgMSiw9mtrzcYfYsg4FFreJRm8wN5wCaHwBnwbe6vnW+pj8u28m3gUIhWuylePJhxc/zCAbLv9JmDtnRdN3FyJ8W3/LmE6yXbEe8FThx+CzByW4G0LtXXUFOURmJ24FnP/qW+KJXNKRPo5h26tqWJg9+k7AS5blbX+JC0K2+isEIxQC5oScysgnMobqpq7uGkwFzrCHP4QSbMr4GyySeg3bg4Nm1LYSvdO8VQtmSgnEqXbMyllfdQ9CyCwNU7HP3/iFJqzc6ZbIju8o4nWFC3Joq7MSQUymF4uGbPutHqYetQfSALIzWOisVljfdbIaQAedF5ZxoGTH0gp7q7tCDBYM7ku+4/fJIyg/dXGxM9nVIxYkjB4wWKf7qdQUA30nC7Y8Wd4Ti3I+U+09u1WkTybf5JpgcrCledqJYutOhsfOwRZwoMntnVdv/8weBp5+uYmLIHfov2PpU2Njf9xwxAheTzBi46J7GNltvCZywOXhZFAKxO3wian5qOJ5b6PY0HfNDjGbYrHKfUQO49O64dwOOpbomlo2V8+nGxcgYwktRpqKcvAyRT/SiddoiZjElYY0SDqdV4o1Pds0JGU0Ilg9lpYwCpqqwXbClHSCInLub/X8rRGTbNPrhSLVtmiHbHKM7l/CHDRKHYrVhLtyDt/FfDQHrE+2q/Gpk5ot7eRshBHBsIgu4bRjaxQzKTmqGv3mAuNoeuFMKlUchPz8NDDT1fX9ymg6JveLQzaHg2G3QOfDI5AwviK2T3JEfiS1URdNbWUKoh6mAL6/qGTZL5eO1YvivQsbKOvRQBjNJBrRhZl/vY4Lb9odiayii1jp6Da2DJ0lvy/cvGNmAPY5NA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c0e9eb2-90cc-4583-27ac-08db37727ab1 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2023 14:15:03.0446 (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: 74O+cOaD4ko76GlH8VSrIpClKekb8XKYlcjIQw007pQ741WWvNAuTGhd64S4CzISBbmPfaY7/NYRy1UViUARWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7405 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org DSA performs non-trivial housekeeping of unicast and multicast addresses on shared (CPU and DSA) ports, and puts a bit of pressure on higher layers, requiring them to behave correctly (remove these addresses exactly as many times as they were added). Otherwise, either addresses linger around forever, or DSA returns -ENOENT complaining that entries that were already deleted must be deleted again. To aid debugging, introduce some trace points specifically for FDB and MDB - that's where some of the bugs still are right now. Some bugs I have seen were also due to race conditions, see: - 630fd4822af2 ("net: dsa: flush switchdev workqueue on bridge join error path") - a2614140dc0f ("net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN") so it would be good to not disturb the timing too much, hence the choice to use trace points vs regular dev_dbg(). I've had these for some time on my computer in a less polished form, and they've proven useful. What I found most useful was to enable CONFIG_BOOTTIME_TRACING, add "trace_event=dsa" to the kernel cmdline, and run "cat /sys/kernel/debug/tracing/trace". This is to debug more complex environments with network managers started by the init system, things like that. Signed-off-by: Vladimir Oltean --- net/dsa/Makefile | 6 +- net/dsa/switch.c | 61 +++++++-- net/dsa/trace.c | 39 ++++++ net/dsa/trace.h | 329 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 423 insertions(+), 12 deletions(-) create mode 100644 net/dsa/trace.c create mode 100644 net/dsa/trace.h diff --git a/net/dsa/Makefile b/net/dsa/Makefile index cc7e93a562fe..281907e53632 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -10,7 +10,8 @@ dsa_core-y += \ slave.o \ switch.o \ tag.o \ - tag_8021q.o + tag_8021q.o \ + trace.o # tagging formats obj-$(CONFIG_NET_DSA_TAG_AR9331) += tag_ar9331.o @@ -31,3 +32,6 @@ obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o + +# for tracing framework to find trace.h +CFLAGS_trace.o := -I$(src) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index d5bc4bb7310d..ff1b5d980e37 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -18,6 +18,7 @@ #include "slave.h" #include "switch.h" #include "tag_8021q.h" +#include "trace.h" static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, unsigned int ageing_time) @@ -164,14 +165,20 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp, int err = 0; /* No need to bother with refcounting for user ports */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_mdb_add(ds, port, mdb, db); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_mdb_add(ds, port, mdb, db); + trace_dsa_mdb_add_hw(dp, mdb->addr, mdb->vid, &db, err); + + return err; + } mutex_lock(&dp->addr_lists_lock); a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, db); if (a) { refcount_inc(&a->refcount); + trace_dsa_mdb_add_bump(dp, mdb->addr, mdb->vid, &db, + &a->refcount); goto out; } @@ -182,6 +189,7 @@ static int dsa_port_do_mdb_add(struct dsa_port *dp, } err = ds->ops->port_mdb_add(ds, port, mdb, db); + trace_dsa_mdb_add_hw(dp, mdb->addr, mdb->vid, &db, err); if (err) { kfree(a); goto out; @@ -209,21 +217,30 @@ static int dsa_port_do_mdb_del(struct dsa_port *dp, int err = 0; /* No need to bother with refcounting for user ports */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_mdb_del(ds, port, mdb, db); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_mdb_del(ds, port, mdb, db); + trace_dsa_mdb_del_hw(dp, mdb->addr, mdb->vid, &db, err); + + return err; + } mutex_lock(&dp->addr_lists_lock); a = dsa_mac_addr_find(&dp->mdbs, mdb->addr, mdb->vid, db); if (!a) { + trace_dsa_mdb_del_not_found(dp, mdb->addr, mdb->vid, &db); err = -ENOENT; goto out; } - if (!refcount_dec_and_test(&a->refcount)) + if (!refcount_dec_and_test(&a->refcount)) { + trace_dsa_mdb_del_drop(dp, mdb->addr, mdb->vid, &db, + &a->refcount); goto out; + } err = ds->ops->port_mdb_del(ds, port, mdb, db); + trace_dsa_mdb_del_hw(dp, mdb->addr, mdb->vid, &db, err); if (err) { refcount_set(&a->refcount, 1); goto out; @@ -247,14 +264,19 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr, int err = 0; /* No need to bother with refcounting for user ports */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_fdb_add(ds, port, addr, vid, db); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_fdb_add(ds, port, addr, vid, db); + trace_dsa_fdb_add_hw(dp, addr, vid, &db, err); + + return err; + } mutex_lock(&dp->addr_lists_lock); a = dsa_mac_addr_find(&dp->fdbs, addr, vid, db); if (a) { refcount_inc(&a->refcount); + trace_dsa_fdb_add_bump(dp, addr, vid, &db, &a->refcount); goto out; } @@ -265,6 +287,7 @@ static int dsa_port_do_fdb_add(struct dsa_port *dp, const unsigned char *addr, } err = ds->ops->port_fdb_add(ds, port, addr, vid, db); + trace_dsa_fdb_add_hw(dp, addr, vid, &db, err); if (err) { kfree(a); goto out; @@ -291,21 +314,29 @@ static int dsa_port_do_fdb_del(struct dsa_port *dp, const unsigned char *addr, int err = 0; /* No need to bother with refcounting for user ports */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_fdb_del(ds, port, addr, vid, db); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_fdb_del(ds, port, addr, vid, db); + trace_dsa_fdb_del_hw(dp, addr, vid, &db, err); + + return err; + } mutex_lock(&dp->addr_lists_lock); a = dsa_mac_addr_find(&dp->fdbs, addr, vid, db); if (!a) { + trace_dsa_fdb_del_not_found(dp, addr, vid, &db); err = -ENOENT; goto out; } - if (!refcount_dec_and_test(&a->refcount)) + if (!refcount_dec_and_test(&a->refcount)) { + trace_dsa_fdb_del_drop(dp, addr, vid, &db, &a->refcount); goto out; + } err = ds->ops->port_fdb_del(ds, port, addr, vid, db); + trace_dsa_fdb_del_hw(dp, addr, vid, &db, err); if (err) { refcount_set(&a->refcount, 1); goto out; @@ -332,6 +363,8 @@ static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag, a = dsa_mac_addr_find(&lag->fdbs, addr, vid, db); if (a) { refcount_inc(&a->refcount); + trace_dsa_lag_fdb_add_bump(lag->dev, addr, vid, &db, + &a->refcount); goto out; } @@ -342,6 +375,7 @@ static int dsa_switch_do_lag_fdb_add(struct dsa_switch *ds, struct dsa_lag *lag, } err = ds->ops->lag_fdb_add(ds, *lag, addr, vid, db); + trace_dsa_lag_fdb_add_hw(lag->dev, addr, vid, &db, err); if (err) { kfree(a); goto out; @@ -370,14 +404,19 @@ static int dsa_switch_do_lag_fdb_del(struct dsa_switch *ds, struct dsa_lag *lag, a = dsa_mac_addr_find(&lag->fdbs, addr, vid, db); if (!a) { + trace_dsa_lag_fdb_del_not_found(lag->dev, addr, vid, &db); err = -ENOENT; goto out; } - if (!refcount_dec_and_test(&a->refcount)) + if (!refcount_dec_and_test(&a->refcount)) { + trace_dsa_lag_fdb_del_drop(lag->dev, addr, vid, &db, + &a->refcount); goto out; + } err = ds->ops->lag_fdb_del(ds, *lag, addr, vid, db); + trace_dsa_lag_fdb_del_hw(lag->dev, addr, vid, &db, err); if (err) { refcount_set(&a->refcount, 1); goto out; diff --git a/net/dsa/trace.c b/net/dsa/trace.c new file mode 100644 index 000000000000..1b107165d331 --- /dev/null +++ b/net/dsa/trace.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright 2022-2023 NXP + */ + +#define CREATE_TRACE_POINTS +#include "trace.h" + +void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ]) +{ + switch (db->type) { + case DSA_DB_PORT: + sprintf(buf, "port %s", db->dp->name); + break; + case DSA_DB_LAG: + sprintf(buf, "lag %s id %d", db->lag.dev->name, db->lag.id); + break; + case DSA_DB_BRIDGE: + sprintf(buf, "bridge %s num %d", db->bridge.dev->name, + db->bridge.num); + break; + default: + sprintf(buf, "unknown"); + break; + } +} + +const char *dsa_port_kind(const struct dsa_port *dp) +{ + switch (dp->type) { + case DSA_PORT_TYPE_USER: + return "user"; + case DSA_PORT_TYPE_CPU: + return "cpu"; + case DSA_PORT_TYPE_DSA: + return "dsa"; + default: + return "unused"; + } +} diff --git a/net/dsa/trace.h b/net/dsa/trace.h new file mode 100644 index 000000000000..42c8bbc7d472 --- /dev/null +++ b/net/dsa/trace.h @@ -0,0 +1,329 @@ +/* SPDX-License-Identifier: GPL-2.0 + * Copyright 2022-2023 NXP + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dsa + +#if !defined(_NET_DSA_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _NET_DSA_TRACE_H + +#include +#include +#include +#include + +/* Enough to fit "bridge %s num %d" where num has 3 digits */ +#define DSA_DB_BUFSIZ (IFNAMSIZ + 16) + +void dsa_db_print(const struct dsa_db *db, char buf[DSA_DB_BUFSIZ]); +const char *dsa_port_kind(const struct dsa_port *dp); + +DECLARE_EVENT_CLASS(dsa_port_addr_op_hw, + + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, + const struct dsa_db *db, int err), + + TP_ARGS(dp, addr, vid, db, err), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(int, err) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->err = err; + ), + + TP_printk("%s %s port %d addr %pM vid %u db \"%s\" err %d", + __get_str(dev), __get_str(kind), __entry->port, __entry->addr, + __entry->vid, __entry->db_buf, __entry->err) +); + +/* Add unicast/multicast address to hardware, either on user ports + * (where no refcounting is kept), or on shared ports when the entry + * is first seen and its refcount is 1. + */ +DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_add_hw, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + TP_ARGS(dp, addr, vid, db, err)); + +DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_add_hw, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + TP_ARGS(dp, addr, vid, db, err)); + +/* Delete unicast/multicast address from hardware, either on user ports or + * when the refcount on shared ports reaches 0 + */ +DEFINE_EVENT(dsa_port_addr_op_hw, dsa_fdb_del_hw, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + TP_ARGS(dp, addr, vid, db, err)); + +DEFINE_EVENT(dsa_port_addr_op_hw, dsa_mdb_del_hw, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + TP_ARGS(dp, addr, vid, db, err)); + +DECLARE_EVENT_CLASS(dsa_port_addr_op_refcount, + + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, + const struct dsa_db *db, const refcount_t *refcount), + + TP_ARGS(dp, addr, vid, db, refcount), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(unsigned int, refcount) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->refcount = refcount_read(refcount); + ), + + TP_printk("%s %s port %d addr %pM vid %u db \"%s\" refcount %u", + __get_str(dev), __get_str(kind), __entry->port, __entry->addr, + __entry->vid, __entry->db_buf, __entry->refcount) +); + +/* Bump the refcount of an existing unicast/multicast address on shared ports */ +DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_add_bump, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, + const refcount_t *refcount), + TP_ARGS(dp, addr, vid, db, refcount)); + +DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_add_bump, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, + const refcount_t *refcount), + TP_ARGS(dp, addr, vid, db, refcount)); + +/* Drop the refcount of a multicast address that we still keep on + * shared ports + */ +DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_fdb_del_drop, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, + const refcount_t *refcount), + TP_ARGS(dp, addr, vid, db, refcount)); + +DEFINE_EVENT(dsa_port_addr_op_refcount, dsa_mdb_del_drop, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db, + const refcount_t *refcount), + TP_ARGS(dp, addr, vid, db, refcount)); + +DECLARE_EVENT_CLASS(dsa_port_addr_del_not_found, + + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, u16 vid, + const struct dsa_db *db), + + TP_ARGS(dp, addr, vid, db), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + ), + + TP_printk("%s %s port %d addr %pM vid %u db \"%s\"", + __get_str(dev), __get_str(kind), __entry->port, + __entry->addr, __entry->vid, __entry->db_buf) +); + +/* Attempt to delete a unicast/multicast address on shared ports for which + * the delete operation was called more times than the addition + */ +DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_fdb_del_not_found, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db), + TP_ARGS(dp, addr, vid, db)); + +DEFINE_EVENT(dsa_port_addr_del_not_found, dsa_mdb_del_not_found, + TP_PROTO(const struct dsa_port *dp, const unsigned char *addr, + u16 vid, const struct dsa_db *db), + TP_ARGS(dp, addr, vid, db)); + +TRACE_EVENT(dsa_lag_fdb_add_hw, + + TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + + TP_ARGS(lag_dev, addr, vid, db, err), + + TP_STRUCT__entry( + __string(dev, lag_dev->name) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(int, err) + ), + + TP_fast_assign( + __assign_str(dev, lag_dev->name); + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->err = err; + ), + + TP_printk("%s addr %pM vid %u db \"%s\" err %d", + __get_str(dev), __entry->addr, __entry->vid, + __entry->db_buf, __entry->err) +); + +TRACE_EVENT(dsa_lag_fdb_add_bump, + + TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, + u16 vid, const struct dsa_db *db, const refcount_t *refcount), + + TP_ARGS(lag_dev, addr, vid, db, refcount), + + TP_STRUCT__entry( + __string(dev, lag_dev->name) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(unsigned int, refcount) + ), + + TP_fast_assign( + __assign_str(dev, lag_dev->name); + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->refcount = refcount_read(refcount); + ), + + TP_printk("%s addr %pM vid %u db \"%s\" refcount %u", + __get_str(dev), __entry->addr, __entry->vid, + __entry->db_buf, __entry->refcount) +); + +TRACE_EVENT(dsa_lag_fdb_del_hw, + + TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, + u16 vid, const struct dsa_db *db, int err), + + TP_ARGS(lag_dev, addr, vid, db, err), + + TP_STRUCT__entry( + __string(dev, lag_dev->name) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(int, err) + ), + + TP_fast_assign( + __assign_str(dev, lag_dev->name); + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->err = err; + ), + + TP_printk("%s addr %pM vid %u db \"%s\" err %d", + __get_str(dev), __entry->addr, __entry->vid, + __entry->db_buf, __entry->err) +); + +TRACE_EVENT(dsa_lag_fdb_del_drop, + + TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, + u16 vid, const struct dsa_db *db, const refcount_t *refcount), + + TP_ARGS(lag_dev, addr, vid, db, refcount), + + TP_STRUCT__entry( + __string(dev, lag_dev->name) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + __field(unsigned int, refcount) + ), + + TP_fast_assign( + __assign_str(dev, lag_dev->name); + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + __entry->refcount = refcount_read(refcount); + ), + + TP_printk("%s addr %pM vid %u db \"%s\" refcount %u", + __get_str(dev), __entry->addr, __entry->vid, + __entry->db_buf, __entry->refcount) +); + +TRACE_EVENT(dsa_lag_fdb_del_not_found, + + TP_PROTO(const struct net_device *lag_dev, const unsigned char *addr, + u16 vid, const struct dsa_db *db), + + TP_ARGS(lag_dev, addr, vid, db), + + TP_STRUCT__entry( + __string(dev, lag_dev->name) + __array(unsigned char, addr, ETH_ALEN) + __field(u16, vid) + __array(char, db_buf, DSA_DB_BUFSIZ) + ), + + TP_fast_assign( + __assign_str(dev, lag_dev->name); + ether_addr_copy(__entry->addr, addr); + __entry->vid = vid; + dsa_db_print(db, __entry->db_buf); + ), + + TP_printk("%s addr %pM vid %u db \"%s\"", + __get_str(dev), __entry->addr, __entry->vid, __entry->db_buf) +); + +#endif /* _NET_DSA_TRACE_H */ + +/* We don't want to use include/trace/events */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE trace +/* This part must be outside protection */ +#include From patchwork Fri Apr 7 14:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13204946 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8880C6FD1D for ; Fri, 7 Apr 2023 14:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240519AbjDGOPj (ORCPT ); Fri, 7 Apr 2023 10:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjDGOPi (ORCPT ); Fri, 7 Apr 2023 10:15:38 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2073.outbound.protection.outlook.com [40.107.8.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AB338A5B for ; Fri, 7 Apr 2023 07:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HFLowSieKpSHcacEiwFuqW4cpJ349wLXr4XqczSWq6vnUV04hrvI98lqGB28HCREPiIDLSwkTkLyBQmqXwNi1qMpE3RM88506vZgSfeKLfV7ZYSYNOEwBjXikdNMdo9T38SDa4C0rqVCiD++JT+2dVzkG33nPrVrHEvAwTS3J7ME/+FnDQEjuzLVNpF/nHyBRYAEQhrswCsp8r8n4rsANCztcYW7VHU8HYTjJjj1Ic4pmd4ACvHmbzYw40P99ohPjovH/T4s+ZDzIuvDrPPIa7Tt/0czEbJjhvCUGMWmCuIJhEwIRi2as+LOD0k/AsbmIOWXK7LLFPtCxwl259Utzw== 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=Ex+Mstf5UwOoMrJNKmPD73HfwcHqWlLEjEgrKOGKJ8A=; b=ZbHCZKhUwah87CD6UN4yA7fQZGgMS0+isgeFOgfCA3nzzp0Web/5kYhgZGAEnmKfusL6U9wok433Wc7y+2czqV1kV0l+ndcga4UUW35E7QI2I9jbxuME5E1IK/yoHABFxWb2VjDRqzBSkezz39HE5vJsAz4OjA+PtEHuG4hUBOHa1wx0hlSW9nKN8vdrGobk607yQjiB4K2TOYUYCPtaPd4Bvjm1EL1Os4g3I563UCiAbjz0L6ZLPu/DgMZ1xDfnhm1Tbzr6MpG8EWyfqG0ycwoWrb1Q6C2FTGDKkIlGP1CNaZToRJAoVImLy9ZOngiJJhlM19xtTYqrCIdkwy69AA== 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=Ex+Mstf5UwOoMrJNKmPD73HfwcHqWlLEjEgrKOGKJ8A=; b=mbl7Ut9DJDQTAWrYXrqeW0e7OKVSatSx9mjSWzQCF4ONJ1JYRmfb2h6ITlFU4lKW4L4oW+xDFvf2TRb8OWingwIo0UDlk1dW3IgbKPu2AbdZcjKUaCavKVWYXlySlvRU/sPX7j5HfyxM0jrOsqZFCnNWK4tNO+VuL2dBKsODmj4= 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 VE1PR04MB7405.eurprd04.prod.outlook.com (2603:10a6:800:1a4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Fri, 7 Apr 2023 14:15:03 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::55b1:d2dd:4327:912b%5]) with mapi id 15.20.6277.033; Fri, 7 Apr 2023 14:15:03 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Andrew Lunn , Florian Fainelli Subject: [PATCH net-next 2/2] net: dsa: add trace points for VLAN operations Date: Fri, 7 Apr 2023 17:14:51 +0300 Message-Id: <20230407141451.133048-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230407141451.133048-1-vladimir.oltean@nxp.com> References: <20230407141451.133048-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR01CA0134.eurprd01.prod.exchangelabs.com (2603:10a6:208:168::39) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|VE1PR04MB7405:EE_ X-MS-Office365-Filtering-Correlation-Id: d590d8d7-b427-4ae8-32c4-08db37727b40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j0a4k+WS95/JY61Jw7HSlSTD60sewRTHc8vjtK6ypiRiln4m1MpJPM0wEbDE91orrZ4r4tnzCYcXCMZswriNlllQmIgIMluwsQmCtu/erWqFzO6r7ZQPmYCPEpihSJ9lxGdKeii+0JDhAcnNO1d3WdYMMOX8J4kTE4Q8zx3LbOmAlLs2aj1EOGRoVhm4pkWf6kJJER0DKKOD07ALgZeOzWYTIEdpamEkFZ/I8Q0CNGsQquCVqPQw6GuX2IxH9EsywZKt0vx6Qsz7VjZRaV4ddPk6eO8iUHSi8eUjSy2keDl6tlHQjkw+gFRLz/5RvV7h9zHIp4Wh8EFfY8UfZ7SNMMygLth9gXxZyyFOWGJQttbREjAPzmFrXrR8Ae+qSqzS7suLdQosEn6j26xI0h4TBLqJjWlzz0cReDUzKfcNkLUVNqDkfD1oJfN4kQXsTLrelLAkaZxeNPI7bi+nnrh+raKAMMDGDo00Tb38SY+qtuv6dEZiubfTzoNM9IyQqwirauYmuyG14ebVGTlkWF43TfH2FFp2YrfIibnbD/9jb7WIjF0r9fO/cNSBf4jCfQCXs5XHEabHae+HWbYt5+KAWC6lASSlw/aqq5A+slvPgCXqsfJqjg+fg/1xJ5hPP2AW 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)(39860400002)(346002)(396003)(376002)(136003)(451199021)(36756003)(86362001)(41300700001)(52116002)(316002)(8676002)(6916009)(4326008)(54906003)(66556008)(6486002)(66476007)(66946007)(478600001)(44832011)(2906002)(8936002)(5660300002)(186003)(38350700002)(38100700002)(6666004)(6512007)(6506007)(1076003)(26005)(2616005)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 83L3zUberDNR/NsR+yo1/e0XTGZNPsL9ergGKgAzl8LeHviUk+MREmA7syzA3UepxlTQyvLNakgyGjOJyzAxy9MCmxPmVMzQ3mTuMlVsjbl2FzPPtLl6FUiQg5aZ5h1Yh+HNHhAlI1iz4ZklTzYj7qcgvBJc+ac+4AABkYTfcZGtrmLgt2LnYJe/DFKFr/rHgGp0mI8wzMgyPgFbHKgwDEVUd/wjH3tYPFZmKuELw+hKaSQWnkDnsZE4GVb15uq4fI5Md/JZjWDObwh1syuJv4om869+P18oY6mJdq66UDb0kuDBFutZ2onVpwaSgAqk8zOg0d9Aw0MGijXZe7jIEUmW4kANtPMSJtm4ecX7qnQZO/9fJMfLhuJvx2qKbaXb92eQpHBdovsbltFoFNqPFkiIIxcslAwhcb4Fwf++OtPrxtqQLAB9WLiaVFigiPt5auLrnClVoB7k0G+TpgcebLgjwFGhzD6UuJZeA3j+mS55s3Z4lOrWZUdS1onmnwV3LunnmjthNWmzjjXEth5HgfYFCxRvpGp43L6uKsvNaZTc0Cxi0JJ59Zu5gMReV9I9dn56DTJQaude3wuNf9ydINdeXAgW5mYPyYYcVpEKwzp+wfyo4KSfjI3ellczw3M5MfX/7WeihsWFyMyMSh5cJ6QPImgJwIwUk9L91QOl35JtZLvNJEbTaS03zgcqrRGoCDkvcWYutWttqck23XKd2rl52E5FI9HcgjhFov2MrRfN5msosHIzyHVeX06pqzoY3l73uzVT8FzYO8kDndYRzqGddA7ADLcQA6C4AnhiFC1H2ZQludn/UHWhcW6AowTmBky+dSzPZDOlyAhlmoJmJn5CXOfWtVt7SbAiMBfPpVsAkGhOm+Ib2VKYjxa59zzP9iRAxD+DmAOkRpmk95VBj11fecMgR5gPqqvN7XIMVOIS/OuMFaulE+DHGSjwVoYJZflfWNwCLLLyv13NsqI0KPX6RXWtokQ34jiInSKm6M40sj3IjUeb37PNDYm7SDin2zhPMlZfUf1n7xYJauaH3RoEKgAM+kIeluxuOPDqpUSL1TOmGNuhq76sYq0Zc32l5AE2W42lI7NpL5tOivFLOgMA+gt2vg0NJncRaSfhZpeHv7GqHyjcdmYF0g2caMGSqwP4xBhsaiRa08C3k1A5saAxkaYBnv2Phc2Zx6mvhSnLu//aBQPOSwXHBVgxo537TJP6AxZoKVBHYq1d6J0BE1MFvN8T9GH24lJiSc8cHLCpI95Zj6fX1vnpzwOz07RsaUsDmQRivWXinnzLxjrMs/2zyKbs6faiSSGhxWwYrulGoTKkFJn0A/kYRkEfB/0f7IFHcZJWlC46nJE8v4fQ5TouedFzAZi6aH50HNbhOMSgbYAQKfN5V8MVR5WsXgJ4nevHfv6FFX9BCzaSP7oRTl+S8gY2ui94M2afK79aKADVf9Vv/8RGxcc+dOKm2/9P3xyRBjbv/iTt1VTgh11pPvKvN5qXvsAqQOJLc5rvYHNTPiG5Ba8jxAqK7SkOpbB6TaYqdBU9jbKIliFpSQLmGqBT2f4s7zdhLZ57ZoStpGzQOpt/ofz1uwas/qMnhcb/4+mFf8bms9xYw0b774SD5w== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d590d8d7-b427-4ae8-32c4-08db37727b40 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2023 14:15:03.8406 (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: 0lCyP1OVa/FJqShZckM3O/MTPFUaX7Or2CgVpEywW45C1sYlJk7jRQUmPHeyKBchIf3dKlR3b0vBsDYM4mE//A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7405 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org These are not as critical as the FDB/MDB trace points (I'm not aware of outstanding VLAN related bugs), but maybe they are useful to somebody, either debugging something or simply trying to learn more. Signed-off-by: Vladimir Oltean --- net/dsa/switch.c | 24 ++++++++-- net/dsa/trace.h | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 5 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index ff1b5d980e37..8c9a9f94b756 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -695,8 +695,12 @@ static int dsa_port_do_vlan_add(struct dsa_port *dp, int err = 0; /* No need to bother with refcounting for user ports. */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_vlan_add(ds, port, vlan, extack); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_vlan_add(ds, port, vlan, extack); + trace_dsa_vlan_add_hw(dp, vlan, err); + + return err; + } /* No need to propagate on shared ports the existing VLANs that were * re-notified after just the flags have changed. This would cause a @@ -711,6 +715,7 @@ static int dsa_port_do_vlan_add(struct dsa_port *dp, v = dsa_vlan_find(&dp->vlans, vlan); if (v) { refcount_inc(&v->refcount); + trace_dsa_vlan_add_bump(dp, vlan, &v->refcount); goto out; } @@ -721,6 +726,7 @@ static int dsa_port_do_vlan_add(struct dsa_port *dp, } err = ds->ops->port_vlan_add(ds, port, vlan, extack); + trace_dsa_vlan_add_hw(dp, vlan, err); if (err) { kfree(v); goto out; @@ -745,21 +751,29 @@ static int dsa_port_do_vlan_del(struct dsa_port *dp, int err = 0; /* No need to bother with refcounting for user ports */ - if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) - return ds->ops->port_vlan_del(ds, port, vlan); + if (!(dsa_port_is_cpu(dp) || dsa_port_is_dsa(dp))) { + err = ds->ops->port_vlan_del(ds, port, vlan); + trace_dsa_vlan_del_hw(dp, vlan, err); + + return err; + } mutex_lock(&dp->vlans_lock); v = dsa_vlan_find(&dp->vlans, vlan); if (!v) { + trace_dsa_vlan_del_not_found(dp, vlan); err = -ENOENT; goto out; } - if (!refcount_dec_and_test(&v->refcount)) + if (!refcount_dec_and_test(&v->refcount)) { + trace_dsa_vlan_del_drop(dp, vlan, &v->refcount); goto out; + } err = ds->ops->port_vlan_del(ds, port, vlan); + trace_dsa_vlan_del_hw(dp, vlan, err); if (err) { refcount_set(&v->refcount, 1); goto out; diff --git a/net/dsa/trace.h b/net/dsa/trace.h index 42c8bbc7d472..567f29a39707 100644 --- a/net/dsa/trace.h +++ b/net/dsa/trace.h @@ -9,7 +9,9 @@ #define _NET_DSA_TRACE_H #include +#include #include +#include #include #include @@ -318,6 +320,122 @@ TRACE_EVENT(dsa_lag_fdb_del_not_found, __get_str(dev), __entry->addr, __entry->vid, __entry->db_buf) ); +DECLARE_EVENT_CLASS(dsa_vlan_op_hw, + + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, int err), + + TP_ARGS(dp, vlan, err), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __field(u16, vid) + __field(u16, flags) + __field(bool, changed) + __field(int, err) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + __entry->vid = vlan->vid; + __entry->flags = vlan->flags; + __entry->changed = vlan->changed; + __entry->err = err; + ), + + TP_printk("%s %s port %d vid %u%s%s%s", + __get_str(dev), __get_str(kind), __entry->port, __entry->vid, + __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "", + __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "", + __entry->changed ? " (changed)" : "") +); + +DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_add_hw, + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, int err), + TP_ARGS(dp, vlan, err)); + +DEFINE_EVENT(dsa_vlan_op_hw, dsa_vlan_del_hw, + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, int err), + TP_ARGS(dp, vlan, err)); + +DECLARE_EVENT_CLASS(dsa_vlan_op_refcount, + + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, + const refcount_t *refcount), + + TP_ARGS(dp, vlan, refcount), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __field(u16, vid) + __field(u16, flags) + __field(bool, changed) + __field(unsigned int, refcount) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + __entry->vid = vlan->vid; + __entry->flags = vlan->flags; + __entry->changed = vlan->changed; + __entry->refcount = refcount_read(refcount); + ), + + TP_printk("%s %s port %d vid %u%s%s%s refcount %u", + __get_str(dev), __get_str(kind), __entry->port, __entry->vid, + __entry->flags & BRIDGE_VLAN_INFO_PVID ? " pvid" : "", + __entry->flags & BRIDGE_VLAN_INFO_UNTAGGED ? " untagged" : "", + __entry->changed ? " (changed)" : "", __entry->refcount) +); + +DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_add_bump, + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, + const refcount_t *refcount), + TP_ARGS(dp, vlan, refcount)); + +DEFINE_EVENT(dsa_vlan_op_refcount, dsa_vlan_del_drop, + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan, + const refcount_t *refcount), + TP_ARGS(dp, vlan, refcount)); + +TRACE_EVENT(dsa_vlan_del_not_found, + + TP_PROTO(const struct dsa_port *dp, + const struct switchdev_obj_port_vlan *vlan), + + TP_ARGS(dp, vlan), + + TP_STRUCT__entry( + __string(dev, dev_name(dp->ds->dev)) + __string(kind, dsa_port_kind(dp)) + __field(int, port) + __field(u16, vid) + ), + + TP_fast_assign( + __assign_str(dev, dev_name(dp->ds->dev)); + __assign_str(kind, dsa_port_kind(dp)); + __entry->port = dp->index; + __entry->vid = vlan->vid; + ), + + TP_printk("%s %s port %d vid %u", + __get_str(dev), __get_str(kind), __entry->port, __entry->vid) +); + #endif /* _NET_DSA_TRACE_H */ /* We don't want to use include/trace/events */