From: Or Gerlitz <ogerlitz@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Don Dutile <ddutile@redhat.com>,
Doug Ledford <dledford@redhat.com>,
Saeed Mahameed <saeedm@mellanox.com>,
Tal Alon <talal@mellanox.com>,
Hadar Har-Zion <hadarh@mellanox.com>,
Rony Efraim <ronye@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>
Subject: [PATCH net-next V1 17/18] net/mlx5: E-Switch, Introduce get vf statistics
Date: Sun, 29 Nov 2015 17:37:25 +0200 [thread overview]
Message-ID: <1448811446-18598-18-git-send-email-ogerlitz@mellanox.com> (raw)
In-Reply-To: <1448811446-18598-1-git-send-email-ogerlitz@mellanox.com>
From: Saeed Mahameed <saeedm@mellanox.com>
Add support to get VF statistics using query vport
counter command.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 67 +++++++++++++++++++++++
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 3 +
2 files changed, 70 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index ea14664..8f428bf 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1213,3 +1213,70 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
return modify_esw_vport_cvlan(esw->dev, vport, vlan, qos, set);
}
+
+int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
+ int vport,
+ struct ifla_vf_stats *vf_stats)
+{
+ int outlen = MLX5_ST_SZ_BYTES(query_vport_counter_out);
+ u32 in[MLX5_ST_SZ_DW(query_vport_counter_in)];
+ int err = 0;
+ u32 *out;
+
+ if (!ESW_ALLOWED(esw))
+ return -EPERM;
+ if (!LEGAL_VPORT(esw, vport))
+ return -EINVAL;
+
+ out = mlx5_vzalloc(outlen);
+ if (!out)
+ return -ENOMEM;
+
+ memset(in, 0, sizeof(in));
+
+ MLX5_SET(query_vport_counter_in, in, opcode,
+ MLX5_CMD_OP_QUERY_VPORT_COUNTER);
+ MLX5_SET(query_vport_counter_in, in, op_mod, 0);
+ MLX5_SET(query_vport_counter_in, in, vport_number, vport);
+ if (vport)
+ MLX5_SET(query_vport_counter_in, in, other_vport, 1);
+
+ memset(out, 0, outlen);
+ err = mlx5_cmd_exec(esw->dev, in, sizeof(in), out, outlen);
+ if (err)
+ goto free_out;
+
+ #define MLX5_GET_CTR(p, x) \
+ MLX5_GET64(query_vport_counter_out, p, x)
+
+ memset(vf_stats, 0, sizeof(*vf_stats));
+ vf_stats->rx_packets =
+ MLX5_GET_CTR(out, received_eth_unicast.packets) +
+ MLX5_GET_CTR(out, received_eth_multicast.packets) +
+ MLX5_GET_CTR(out, received_eth_broadcast.packets);
+
+ vf_stats->rx_bytes =
+ MLX5_GET_CTR(out, received_eth_unicast.octets) +
+ MLX5_GET_CTR(out, received_eth_multicast.octets) +
+ MLX5_GET_CTR(out, received_eth_broadcast.octets);
+
+ vf_stats->tx_packets =
+ MLX5_GET_CTR(out, transmitted_eth_unicast.packets) +
+ MLX5_GET_CTR(out, transmitted_eth_multicast.packets) +
+ MLX5_GET_CTR(out, transmitted_eth_broadcast.packets);
+
+ vf_stats->tx_bytes =
+ MLX5_GET_CTR(out, transmitted_eth_unicast.octets) +
+ MLX5_GET_CTR(out, transmitted_eth_multicast.octets) +
+ MLX5_GET_CTR(out, transmitted_eth_broadcast.octets);
+
+ vf_stats->multicast =
+ MLX5_GET_CTR(out, received_eth_multicast.packets);
+
+ vf_stats->broadcast =
+ MLX5_GET_CTR(out, received_eth_broadcast.packets);
+
+free_out:
+ kvfree(out);
+ return err;
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index b4284a4..9bac542 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -154,5 +154,8 @@ int mlx5_eswitch_set_vport_vlan(struct mlx5_eswitch *esw,
int vport, u16 vlan, u8 qos);
int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
int vport, struct ifla_vf_info *ivi);
+int mlx5_eswitch_get_vport_stats(struct mlx5_eswitch *esw,
+ int vport,
+ struct ifla_vf_stats *vf_stats);
#endif /* __MLX5_ESWITCH_H__ */
--
2.3.7
next prev parent reply other threads:[~2015-11-29 15:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 15:37 [PATCH net-next V1 00/18] Introducing ConnectX-4 Ethernet SRIOV Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 01/18] net/mlx5_core: Modify enable/disable hca functions Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 02/18] net/mlx5_core: Add base sriov support Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 03/18] net/mlx5: Add HW capabilities and structs for SR-IOV E-Switch Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 04/18] net/mlx5: Update access functions to Query/Modify vport MAC address Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 05/18] net/mlx5: Introduce access functions to modify/query vport mac lists Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 06/18] net/mlx5: Introduce access functions to modify/query vport state Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 07/18] net/mlx5: Introduce access functions to modify/query vport promisc mode Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 08/18] net/mlx5: Introduce access functions to modify/query vport vlans Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 09/18] net/mlx5e: Write UC/MC list and promisc mode into vport context Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 10/18] net/mlx5e: Write vlan list " Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 11/18] net/mlx5: Introducing E-Switch and l2 table Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 12/18] net/mlx5: E-Switch, Introduce FDB hardware capabilities Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 13/18] net/mlx5: E-Switch, Add SR-IOV (FDB) support Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 14/18] net/mlx5: E-Switch, Introduce Vport administration functions Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 15/18] net/mlx5: E-Switch, Introduce HCA cap and E-Switch vport context Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 16/18] net/mlx5: E-Switch, Introduce set vport vlan (VST mode) Or Gerlitz
2015-11-29 15:37 ` Or Gerlitz [this message]
2015-11-29 15:37 ` [PATCH net-next V1 18/18] net/mlx5e: Add support for SR-IOV ndos Or Gerlitz
2015-11-29 16:35 ` kbuild test robot
2015-11-29 16:35 ` [PATCH] net/mlx5e: fix semicolon.cocci warnings kbuild test robot
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=1448811446-18598-18-git-send-email-ogerlitz@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=davem@davemloft.net \
--cc=ddutile@redhat.com \
--cc=dledford@redhat.com \
--cc=hadarh@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ronye@mellanox.com \
--cc=saeedm@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