From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next] net: core: Expose number of link up/down transitions Date: Wed, 17 Jan 2018 16:28:49 -0800 Message-ID: References: <20180117230704.21949-1-f.fainelli@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: edumazet@google.com, andrew@lunn.ch, cphealy@gmail.com, David Decotigny , "David S. Miller" , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Daniel Borkmann , Nikolay Aleksandrov , Alexei Starovoitov , Roopa Prabhu , Mahesh Bandewar , Vlad Yasevich , Jakub Kicinski , Jonas Bonn , stephen hemminger , Hans Liljestrand , "Reshetova, Elena" , Kirill Tkhai , Andrey Vagin , netdev@vger.kernel.org Return-path: In-Reply-To: <20180117230704.21949-1-f.fainelli@gmail.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 1/17/18 3:06 PM, Florian Fainelli wrote: > diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c > index 7bf8b85ade16..9f732c3dc2ce 100644 > --- a/net/core/net-sysfs.c > +++ b/net/core/net-sysfs.c > @@ -295,10 +295,29 @@ static ssize_t carrier_changes_show(struct device *dev, > struct net_device *netdev = to_net_dev(dev); > > return sprintf(buf, fmt_dec, > - atomic_read(&netdev->carrier_changes)); > + atomic_read(&netdev->count_link_up) + > + atomic_read(&netdev->count_link_down)); > } > static DEVICE_ATTR_RO(carrier_changes); > > +static ssize_t count_link_up_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct net_device *netdev = to_net_dev(dev); > + > + return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_up)); > +} > +static DEVICE_ATTR_RO(count_link_up); > + > +static ssize_t count_link_down_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct net_device *netdev = to_net_dev(dev); > + > + return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_down)); > +} > +static DEVICE_ATTR_RO(count_link_down); > + > /* read-write attributes */ > > static int change_mtu(struct net_device *dev, unsigned long new_mtu) > @@ -547,6 +566,8 @@ static struct attribute *net_class_attrs[] __ro_after_init = { > &dev_attr_phys_port_name.attr, > &dev_attr_phys_switch_id.attr, > &dev_attr_proto_down.attr, > + &dev_attr_count_link_up.attr, > + &dev_attr_count_link_down.attr, > NULL, > }; > ATTRIBUTE_GROUPS(net_class); Personally, I do not like adding any more sysfs files. As discussed in the past sysfs is a huge contributor to the overhead of netdevs.