From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, nogahf@mellanox.com, idosch@mellanox.com,
eladr@mellanox.com, yotamg@mellanox.com, ogerlitz@mellanox.com,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
linville@tuxdriver.com, tgraf@suug.ch, gospo@cumulusnetworks.com,
sfeldma@gmail.com, sd@queasysnail.net, eranbe@mellanox.com,
ast@plumgrid.com, edumazet@google.com,
hannes@stressinduktion.org, f.fainelli@gmail.com,
dsa@cumulusnetworks.com
Subject: [patch net-next v5 2/4] rtnetlink: add HW/SW stats distinction in rtnl_fill_stats
Date: Tue, 21 Jun 2016 17:15:54 +0200 [thread overview]
Message-ID: <1466522156-4795-3-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1466522156-4795-1-git-send-email-jiri@resnulli.us>
From: Nogah Frankel <nogahf@mellanox.com>
Since hardware stats are now returned by default, add a way to
query only software stats.
They are saved in IFLA_SW_STATS64.
(This option is valid only if the driver returns HW stats in the
default ndo stats)
Signed-off-by: Nogah Frankel <nogahf@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
include/uapi/linux/if_link.h | 1 +
net/core/rtnetlink.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index bb36bd5..98175e7 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -156,6 +156,7 @@ enum {
IFLA_GSO_MAX_SEGS,
IFLA_GSO_MAX_SIZE,
IFLA_PAD,
+ IFLA_SW_STATS64,
__IFLA_MAX
};
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eb49ca2..7958cde 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -901,6 +901,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
+ nla_total_size_64bit(sizeof(struct rtnl_link_ifmap))
+ nla_total_size(sizeof(struct rtnl_link_stats))
+ nla_total_size_64bit(sizeof(struct rtnl_link_stats64))
+ + nla_total_size_64bit(sizeof(struct rtnl_link_stats64)) /* IFLA_SW_STATS64 */
+ nla_total_size(MAX_ADDR_LEN) /* IFLA_ADDRESS */
+ nla_total_size(MAX_ADDR_LEN) /* IFLA_BROADCAST */
+ nla_total_size(4) /* IFLA_TXQLEN */
@@ -928,7 +929,6 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
+ nla_total_size(MAX_PHYS_ITEM_ID_LEN) /* IFLA_PHYS_SWITCH_ID */
+ nla_total_size(IFNAMSIZ) /* IFLA_PHYS_PORT_NAME */
+ nla_total_size(1); /* IFLA_PROTO_DOWN */
-
}
static int rtnl_vf_ports_fill(struct sk_buff *skb, struct net_device *dev)
@@ -1082,6 +1082,17 @@ static noinline_for_stack int rtnl_fill_stats(struct sk_buff *skb,
sp = nla_data(attr);
dev_get_stats(dev, sp);
+ if (dev_have_sw_stats(dev)) {
+ attr = nla_reserve_64bit(skb, IFLA_SW_STATS64,
+ sizeof(struct rtnl_link_stats64),
+ IFLA_PAD);
+ if (!attr)
+ return -EMSGSIZE;
+
+ sp = nla_data(attr);
+ dev_get_sw_stats(dev, sp);
+ }
+
attr = nla_reserve(skb, IFLA_STATS,
sizeof(struct rtnl_link_stats));
if (!attr)
--
2.5.5
next prev parent reply other threads:[~2016-06-21 15:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 15:15 [patch net-next v5 0/4] return offloaded stats as default and expose original sw stats Jiri Pirko
2016-06-21 15:15 ` [patch net-next v5 1/4] netdevice: add SW statistics ndo Jiri Pirko
2016-06-21 15:15 ` Jiri Pirko [this message]
2016-06-21 15:15 ` [patch net-next v5 3/4] net: core: add SW stats to if_stats_msg Jiri Pirko
2016-06-21 15:15 ` [patch net-next v5 4/4] mlxsw: spectrum: Implement SW stats ndo and expose HW stats by default Jiri Pirko
2016-06-22 19:32 ` [patch net-next v5 0/4] return offloaded stats as default and expose original sw stats Roopa Prabhu
2016-06-23 5:40 ` Jiri Pirko
2016-06-23 11:27 ` Roopa Prabhu
2016-06-23 11:35 ` Jiri Pirko
2016-06-23 15:11 ` Anuradha Karuppiah
2016-06-23 15:40 ` Jiri Pirko
2016-06-25 15:50 ` Roopa Prabhu
2016-06-26 9:33 ` Jiri Pirko
2016-06-26 18:06 ` Roopa Prabhu
2016-06-26 18:15 ` Jiri Pirko
2016-06-27 2:53 ` Roopa Prabhu
2016-06-27 6:51 ` Jiri Pirko
2016-06-27 13:02 ` Roopa Prabhu
2016-06-27 13:11 ` Jiri Pirko
2016-07-08 14:05 ` Roopa Prabhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466522156-4795-3-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=dsa@cumulusnetworks.com \
--cc=edumazet@google.com \
--cc=eladr@mellanox.com \
--cc=eranbe@mellanox.com \
--cc=f.fainelli@gmail.com \
--cc=gospo@cumulusnetworks.com \
--cc=hannes@stressinduktion.org \
--cc=idosch@mellanox.com \
--cc=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=nogahf@mellanox.com \
--cc=ogerlitz@mellanox.com \
--cc=roopa@cumulusnetworks.com \
--cc=sd@queasysnail.net \
--cc=sfeldma@gmail.com \
--cc=tgraf@suug.ch \
--cc=yotamg@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).