From: John Fastabend <john.fastabend@gmail.com>
To: Or Gerlitz <ogerlitz@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Amir Vadai <amirv@mellanox.com>,
Tal Alon <talal@mellanox.com>,
Eran Ben Elisha <eranbe@mellanox.com>,
Hadar Hen Zion <hadarh@mellanox.com>,
Greg Rose <gregory.v.rose@intel.com>,
Mitch Williams <mitch.a.williams@intel.com>
Subject: Re: [PATCH net-next 12/13] net/core: Add reading VF statistics through the PF netdevice
Date: Wed, 10 Jun 2015 08:23:15 -0700 [thread overview]
Message-ID: <55785663.7030608@gmail.com> (raw)
In-Reply-To: <1433948378-17570-13-git-send-email-ogerlitz@mellanox.com>
On 06/10/2015 07:59 AM, Or Gerlitz wrote:
> From: Eran Ben Elisha <eranbe@mellanox.com>
>
> Add ndo_get_vf_stats where the PF retrieves and fills the VFs traffic
> statistics. Add rtnl_link_vf_stats64 for passing the VF statistics from
> the PF to user-space.
>
> Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
> Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> ---
> include/linux/netdevice.h | 4 ++++
> include/uapi/linux/if_link.h | 11 +++++++++++
> net/core/rtnetlink.c | 12 ++++++++++--
> 3 files changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 6f5f71f..b1d3b88 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1100,6 +1100,10 @@ struct net_device_ops {
> struct ifla_vf_info *ivf);
> int (*ndo_set_vf_link_state)(struct net_device *dev,
> int vf, int link_state);
> + int (*ndo_get_vf_stats)(struct net_device *dev,
> + int vf,
> + struct rtnl_link_vf_stats64
> + *vf_stats);
> int (*ndo_set_vf_port)(struct net_device *dev,
> int vf,
> struct nlattr *port[]);
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index 1737b7a..9c25aeb 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -70,6 +70,16 @@ struct rtnl_link_stats64 {
> __u64 tx_compressed;
> };
>
> +/* VF statistics structure */
> +struct rtnl_link_vf_stats64 {
> + __u64 rx_packets; /* total packets received */
> + __u64 tx_packets; /* total packets transmitted */
> + __u64 rx_bytes; /* total bytes received */
> + __u64 tx_bytes; /* total bytes transmitted */
> + __u64 broadcast; /* broadcast packets received */
> + __u64 multicast; /* multicast packets received */
> +};
Can we encode this in a nested netlink structure when its passed
up to userspace? I have more stats I would like to export in the
future such as dropped packets and if we put the structure in the UAPI
we wont be able to easily extend this.
The structure could be moved into ./include/linux/if_link.h though.
> +
> /* The struct should be in sync with struct ifmap */
> struct rtnl_link_ifmap {
> __u64 mem_start;
> @@ -482,6 +492,7 @@ enum {
> IFLA_VF_RSS_QUERY_EN, /* RSS Redirection Table and Hash Key query
> * on/off switch
> */
> + IFLA_VF_STATS, /* network device statistics */
> __IFLA_VF_MAX,
> };
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 077b6d2..6d7c939 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -819,7 +819,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
> nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
> nla_total_size(sizeof(struct ifla_vf_rate)) +
> nla_total_size(sizeof(struct ifla_vf_link_state)) +
> - nla_total_size(sizeof(struct ifla_vf_rss_query_en)));
> + nla_total_size(sizeof(struct ifla_vf_rss_query_en)) +
> + nla_total_size(sizeof(struct rtnl_link_vf_stats64)));
> return size;
> } else
> return 0;
> @@ -1138,6 +1139,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
> struct ifla_vf_spoofchk vf_spoofchk;
> struct ifla_vf_link_state vf_linkstate;
> struct ifla_vf_rss_query_en vf_rss_query_en;
> + struct rtnl_link_vf_stats64 vf_stats;
>
> /*
> * Not all SR-IOV capable drivers support the
> @@ -1176,6 +1178,10 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
> nla_nest_cancel(skb, vfinfo);
> goto nla_put_failure;
> }
> + memset(&vf_stats, 0, sizeof(vf_stats));
> + if (dev->netdev_ops->ndo_get_vf_stats)
> + dev->netdev_ops->ndo_get_vf_stats(dev, i,
> + &vf_stats);
> if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
> nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
> nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
> @@ -1188,7 +1194,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
> &vf_linkstate) ||
> nla_put(skb, IFLA_VF_RSS_QUERY_EN,
> sizeof(vf_rss_query_en),
> - &vf_rss_query_en))
> + &vf_rss_query_en) ||
> + nla_put(skb, IFLA_VF_STATS, sizeof(vf_stats),
> + &vf_stats))
> goto nla_put_failure;
> nla_nest_end(skb, vf);
> }
>
--
John Fastabend Intel Corporation
next prev parent reply other threads:[~2015-06-10 15:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-10 14:59 [PATCH net-next 00/13] mlx4 driver update (+ new VF ndo) Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 01/13] net/mlx4_core: Check before cleaning counters bitmap Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 02/13] net/mlx4_core: Reset counters data when freed Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 03/13] net/mlx4_core: Add sink counter Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 04/13] net/mlx4_core: Remove counters table allocation from VF flow Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 05/13] net/mlx4_core: Adjust counter grant policy in the resource tracker Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 06/13] net/mlx4_core: Add port attribute when tracking counters Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 07/13] net/mlx4_core: Allocate default counter per port Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 08/13] IB/mlx4: Add RoCE/IB dedicated counters Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 09/13] IB/mlx4: Set VF to read from QP counters Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 10/13] net/mlx4_core: Add helper to query counters Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 11/13] net/mlx4_en: Show PF own statistics via ethtool Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 12/13] net/core: Add reading VF statistics through the PF netdevice Or Gerlitz
2015-06-10 15:23 ` John Fastabend [this message]
2015-06-11 17:37 ` Or Gerlitz
2015-06-10 14:59 ` [PATCH net-next 13/13] net/mlx4_en: Support ndo_get_vf_stats Or Gerlitz
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=55785663.7030608@gmail.com \
--to=john.fastabend@gmail.com \
--cc=amirv@mellanox.com \
--cc=davem@davemloft.net \
--cc=eranbe@mellanox.com \
--cc=gregory.v.rose@intel.com \
--cc=hadarh@mellanox.com \
--cc=mitch.a.williams@intel.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=talal@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).