From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tobias Waldekranz Subject: Re: [PATCH] net: phy: add tracepoints Date: Thu, 16 Aug 2018 11:48:00 +0200 Message-ID: <20180816094800.GA3136@gmail.com> References: <20180816093418.2621-1-tobias@waldekranz.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Andrew Lunn , Florian Fainelli , "David S. Miller" , Steven Rostedt , Ingo Molnar , open list , "open list:ETHERNET PHY LIBRARY" Return-path: Received: from mail-lj1-f194.google.com ([209.85.208.194]:44012 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388054AbeHPMp0 (ORCPT ); Thu, 16 Aug 2018 08:45:26 -0400 Received: by mail-lj1-f194.google.com with SMTP id r13-v6so3141696ljg.10 for ; Thu, 16 Aug 2018 02:48:03 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20180816093418.2621-1-tobias@waldekranz.com> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, Aug 16, 2018 at 11:34:15AM +0200, Tobias Waldekranz wrote: > 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 > This was sent in error. A v2 will follow. I had not used get_maintainers.pl before, sorry about the noise! -- Thanks - wkz