Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2491734imm; Thu, 16 Aug 2018 10:22:12 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxu8ipZ2IYn0k33fqhpxL3btz7c4qFd7Ko+HJt2GOx4MJWvMkPCjywzk1AAJ7gcjh5r4bv/ X-Received: by 2002:a17:902:8481:: with SMTP id c1-v6mr29962887plo.177.1534440131958; Thu, 16 Aug 2018 10:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534440131; cv=none; d=google.com; s=arc-20160816; b=EriuB5D23gJ2FoohWHKp50H+YwkSxmndhDBfT58ZqQESf02znZA/ZWk0svvN6itcdI P5zbTcXBfZQGx0WEfNckzOhMfCAqmkjK3PsFPLuHuOuNeX560rriCWuSJk8Wz6UvIgOY dnGx0YM+AfS02YKp6rqWTc3HNFHPuml8BsvdLR2ihpKOEN7DJ1lRIeCu4JoqjUjn4zTY 1fZ5InNTMwCz3JXAdDgFCcYGc7EwX2DZUbclCAu7CBFPMaN1rSaqNRb56vq6wvR0xjU0 CQssosuAfcur6YYqPtuugACgz0NoKXTRiNZ42GxPw+f7cJ9B4OVHDqaNlxF6FGki3P2J hvZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=1g4W4DPaKo8EPB3Yox5xayg40Vuqf10sRmiBShKv2lk=; b=JgOX93P6CiFF54pD1267v0xsDP/VUMfgZLCYUmjTx9BlgIsbPaHOT5hOm5wz9OTB3f ykW1VL258lHNr7yjbBQyU55/m8DDd/pQUbeOuLVC+bzIVCJKlUPlyioNfKjwqvuHuYUh uNeGtjI8zEoALykUdq+Fx66c4UODriQ5/V6yK7T8Ty1tM5tmFiSkixNMeCfSx5vAL+yO 2W+W1Yt64jq1FJK5GsxccbouYS4Utq5Prm7QfCzvxjYOHiCHDwg6DnSCvt6yoF1YyR4D XwZ6nAE9ovquCrVw1q75PE8eVeiz2YSxI88XCkq577cs0VkSljS1MbjheOlGN6Jb3i5L 5StQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@waldekranz-com.20150623.gappssmtp.com header.s=20150623 header.b=AuLjc1VP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m126-v6si30866267pfb.126.2018.08.16.10.21.56; Thu, 16 Aug 2018 10:22:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@waldekranz-com.20150623.gappssmtp.com header.s=20150623 header.b=AuLjc1VP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390528AbeHPMbj (ORCPT + 99 others); Thu, 16 Aug 2018 08:31:39 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:37015 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387553AbeHPMbi (ORCPT ); Thu, 16 Aug 2018 08:31:38 -0400 Received: by mail-lj1-f195.google.com with SMTP id v9-v6so3133543ljk.4 for ; Thu, 16 Aug 2018 02:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization; bh=1g4W4DPaKo8EPB3Yox5xayg40Vuqf10sRmiBShKv2lk=; b=AuLjc1VPGEFjCod4WjjxF2SP8PILZWQsbrohXnNsN65tzephB07/AScQv1hWE4wpbA aYx3/6Se+sMxFO/OUV+pvQDHbjunkLqA1qNPB1Ubt9LzEBcslTEPS1BbJtUSOpJiB6zb OYKn3Tz+S7EGtKN4ajhOXD7GkKhOGxfGJl0Ua3GdwzmDC0uiyY7T+gYbTr5rwYuf7qkL tx62FnGkWH70W6Xic3d/94r2QOEAXe2YpbW3t/vXVOsC8R52bZ1XND9ef9yGwWGeniXQ 0+VkfZXpQTRPJvkw3EO+wB+HYIolXQyqhtfW24GDdPohFpt+O27VEDi5Dz+NonFFTdio lz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization; bh=1g4W4DPaKo8EPB3Yox5xayg40Vuqf10sRmiBShKv2lk=; b=YjebC9CkcdfxdaYkn8NTPfjKzEZOp/tFXxHSstRheClB3EtdWFC9QgVRv2u6eiWxgR kLdFGZCApST0TVHhq0aMFYZFd1wGJOKihRUjbzgT++kXJtDuSxnEoHpuefBqDAVNXno3 WnEfdmctXknV2T8Qdlc3tcpauZqJeAtyVnQvToV3Mx1F/MJtBOvUoGYzVJQI38HiAlis Xg6AEOZczxtrprrHEvPgUMWU8iaHqb1zDciwrDvuVgkl30juETFohA7llAgZpRj9hjZN nujZt/imQ/2y4aGlwYQ7gyxeBb3c7Qzjr1pY8H6Apw6DXM27YZU77t5OfVypgA9JLoIq KiyQ== X-Gm-Message-State: AOUpUlF1oaeVjKRN4N4queHz0EJZI0omiz/RdPuWTwjH25fD2nk8xaZb xWDXcn/eDSkBxMXBoUeW4MdX9Q== X-Received: by 2002:a2e:2096:: with SMTP id g22-v6mr4176691lji.37.1534412059468; Thu, 16 Aug 2018 02:34:19 -0700 (PDT) Received: from wkz-wmo.labs.westermo.se (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id q85-v6sm4983138lfg.20.2018.08.16.02.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 02:34:18 -0700 (PDT) From: Tobias Waldekranz To: tobias@waldekranz.com Cc: Andrew Lunn , Florian Fainelli , "David S. Miller" , Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org (open list), netdev@vger.kernel.org (open list:ETHERNET PHY LIBRARY) Subject: [PATCH] net: phy: add tracepoints Date: Thu, 16 Aug 2018 11:34:15 +0200 Message-Id: <20180816093418.2621-1-tobias@waldekranz.com> X-Mailer: git-send-email 2.17.1 Organization: Westermo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Two tracepoints for now: * `phy_interrupt` Pretty self-explanatory. * `phy_state_change` Whenever the PHY's state machine is run, trace the old and the new state. Signed-off-by: Tobias Waldekranz --- drivers/net/phy/phy.c | 4 +++ include/trace/events/phy.h | 68 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 include/trace/events/phy.h diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9aabfa1a455a..8d22926f3962 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -38,6 +38,9 @@ #include +#define CREATE_TRACE_POINTS +#include + #define PHY_STATE_STR(_state) \ case PHY_##_state: \ return __stringify(_state); \ @@ -1039,6 +1042,7 @@ void phy_state_machine(struct work_struct *work) if (err < 0) phy_error(phydev); + trace_phy_state_change(phydev, old_state); if (old_state != phydev->state) phydev_dbg(phydev, "PHY state change %s -> %s\n", phy_state_to_str(old_state), diff --git a/include/trace/events/phy.h b/include/trace/events/phy.h new file mode 100644 index 000000000000..7ba6c0dda47e --- /dev/null +++ b/include/trace/events/phy.h @@ -0,0 +1,68 @@ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM phy + +#if !defined(_TRACE_PHY_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_PHY_H + +#include + +TRACE_EVENT(phy_interrupt, + TP_PROTO(int irq, struct phy_device *phydev), + TP_ARGS(irq, phydev), + TP_STRUCT__entry( + __field(int, irq) + __field(int, addr) + __field(int, state) + __array(char, ifname, IFNAMSIZ) + ), + TP_fast_assign( + __entry->irq = irq; + __entry->addr = phydev->mdio.addr; + __entry->state = phydev->state; + if (phydev->attached_dev) + memcpy(__entry->ifname, + netdev_name(phydev->attached_dev), + IFNAMSIZ); + else + memset(__entry->ifname, 0, IFNAMSIZ); + ), + TP_printk("phy-%d-irq irq=%d ifname=%16s state=%d", + __entry->addr, + __entry->irq, + __entry->ifname, + __entry->state + ) + ); + +TRACE_EVENT(phy_state_change, + TP_PROTO(struct phy_device *phydev, enum phy_state old_state), + TP_ARGS(phydev, old_state), + TP_STRUCT__entry( + __field(int, addr) + __field(int, state) + __field(int, old_state) + __array(char, ifname, IFNAMSIZ) + ), + TP_fast_assign( + __entry->addr = phydev->mdio.addr; + __entry->state = phydev->state; + __entry->old_state = old_state; + if (phydev->attached_dev) + memcpy(__entry->ifname, + netdev_name(phydev->attached_dev), + IFNAMSIZ); + else + memset(__entry->ifname, 0, IFNAMSIZ); + ), + TP_printk("phy-%d-change ifname=%16s old_state=%d state=%d", + __entry->addr, + __entry->ifname, + __entry->old_state, + __entry->state + ) + ); + +#endif /* _TRACE_PHY_H */ + +/* This part must be outside protection */ +#include -- 2.17.1