All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nambiar, Amritha <amritha.nambiar@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next PATCH 3/5] i40e: Enable VF specific ethtool statistics via VF representor netdevs.
Date: Tue, 9 Aug 2016 17:21:31 -0700	[thread overview]
Message-ID: <57AA738B.3080601@intel.com> (raw)
In-Reply-To: <1470329387-25138-3-git-send-email-sridhar.samudrala@intel.com>

On 8/4/2016 9:49 AM, Sridhar Samudrala wrote:
> Sample script that shows ethtool stats on VF representor netdev
> PF: enp5s0f0, VF0: enp5s2  VF_REP0: enp5s0f0-vf0
>
>     # devlink dev set pci/0000:05:00.0 smode switchdev
>     # echo 2 > /sys/class/net/enp5s0f0/device/sriov_numvfs
>     # ip link set enp5s2 up
>     # ethtool -S enp5s0f0-vf0
>     NIC statistics:
>       rx_bytes: 0
>       rx_unicast: 0
>       rx_multicast: 0
>       rx_broadcast: 0
>       rx_discards: 0
>       rx_unknown_protocol: 0
>       tx_bytes: 140
>       tx_unicast: 0
>       tx_multicast: 2
>       tx_broadcast: 0
>       tx_discards: 0
>       tx_errors: 0
>
> Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>

  Acked-by: Amritha Nambiar <amritha.nambiar@intel.com>

> ---
>   drivers/net/ethernet/intel/i40e/i40e.h             |  1 +
>   drivers/net/ethernet/intel/i40e/i40e_ethtool.c     | 67 ++++++++++++++++++++++
>   drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  1 +
>   3 files changed, 69 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
> index 724bd82..2d35c0d 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e.h
> @@ -875,4 +875,5 @@ i40e_status i40e_get_npar_bw_setting(struct i40e_pf *pf);
>   i40e_status i40e_set_npar_bw_setting(struct i40e_pf *pf);
>   i40e_status i40e_commit_npar_bw_setting(struct i40e_pf *pf);
>   void i40e_print_link_message(struct i40e_vsi *vsi, bool isup);
> +void i40e_set_vf_netdev_ethtool_ops(struct net_device *netdev);
>   #endif /* _I40E_H_ */
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> index c912e04..0c3bffa 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> @@ -3040,3 +3040,70 @@ void i40e_set_ethtool_ops(struct net_device *netdev)
>   {
>   	netdev->ethtool_ops = &i40e_ethtool_ops;
>   }
> +
> +static const char i40e_vf_netdev_ethtool_sset[][ETH_GSTRING_LEN] = {
> +	"rx_bytes",
> +	"rx_unicast",
> +	"rx_multicast",
> +	"rx_broadcast",
> +	"rx_discards",
> +	"rx_unknown_protocol",
> +	"tx_bytes",
> +	"tx_unicast",
> +	"tx_multicast",
> +	"tx_broadcast",
> +	"tx_discards",
> +	"tx_errors",
> +};
> +
> +#define I40E_VF_NETDEV_ETHTOOL_STAT_COUNT \
> +			ARRAY_SIZE(i40e_vf_netdev_ethtool_sset)
> +
> +static void i40e_vf_netdev_ethtool_get_strings(struct net_device *dev,
> +					       u32 stringset,
> +					       u8 *ethtool_strings)
> +{
> +	switch (stringset) {
> +	case ETH_SS_STATS:
> +		memcpy(ethtool_strings, &i40e_vf_netdev_ethtool_sset,
> +		       sizeof(i40e_vf_netdev_ethtool_sset));
> +		break;
> +	}
> +}
> +
> +static int i40e_vf_netdev_ethtool_get_sset_count(struct net_device *dev,
> +						 int stringset)
> +{
> +	switch (stringset) {
> +	case ETH_SS_STATS:
> +		return I40E_VF_NETDEV_ETHTOOL_STAT_COUNT;
> +	default:
> +		return -EOPNOTSUPP;
> +	}
> +}
> +
> +static void i40e_vf_netdev_ethtool_get_stats(struct net_device *dev,
> +				struct ethtool_stats *target_ethtool_stats,
> +				u64 *target_stat_values)
> +{
> +	struct i40e_vf_netdev_priv *priv = netdev_priv(dev);
> +	struct i40e_vf *vf = priv->vf;
> +	struct i40e_pf *pf = vf->pf;
> +	struct i40e_vsi *vsi;
> +
> +	vsi = pf->vsi[vf->lan_vsi_idx];
> +	i40e_update_stats(vsi);
> +	memcpy(target_stat_values, &vsi->eth_stats,
> +	       I40E_VF_NETDEV_ETHTOOL_STAT_COUNT * 8);
> +}
> +
> +static const struct ethtool_ops i40e_vf_netdev_ethtool_ops = {
> +	.get_strings		= i40e_vf_netdev_ethtool_get_strings,
> +	.get_ethtool_stats      = i40e_vf_netdev_ethtool_get_stats,
> +	.get_sset_count         = i40e_vf_netdev_ethtool_get_sset_count,
> +};
> +
> +void i40e_set_vf_netdev_ethtool_ops(struct net_device *netdev)
> +{
> +	netdev->ethtool_ops = &i40e_vf_netdev_ethtool_ops;
> +}
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> index d41c37c..313a53c 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
> @@ -1046,6 +1046,7 @@ int i40e_alloc_vf_netdev(struct i40e_vf *vf, u16 vf_num)
>   	priv->vf = &(pf->vf[vf_num]);
>   
>   	netdev->netdev_ops = &i40e_vf_netdev_ops;
> +	i40e_set_vf_netdev_ethtool_ops(netdev);
>   
>   	netif_carrier_off(netdev);
>   	netif_tx_disable(netdev);


  reply	other threads:[~2016-08-10  0:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 16:49 [Intel-wired-lan] [next PATCH 1/5] i40e: Introduce devlink interface Sridhar Samudrala
2016-08-04 16:49 ` [Intel-wired-lan] [next PATCH 2/5] i40e: Introduce VF representor/control netdevs Sridhar Samudrala
2016-08-10  0:18   ` Nambiar, Amritha
2016-08-04 16:49 ` [Intel-wired-lan] [next PATCH 3/5] i40e: Enable VF specific ethtool statistics via VF representor netdevs Sridhar Samudrala
2016-08-10  0:21   ` Nambiar, Amritha [this message]
2016-08-04 16:49 ` [Intel-wired-lan] [next PATCH 4/5] i40e: Refactor flow director filter management to make it per VSI Sridhar Samudrala
2016-08-04 16:49 ` [Intel-wired-lan] [next PATCH 5/5] i40e: Enable ntuple filters on VFs via VF representor netdevs Sridhar Samudrala
2016-08-10  0:12 ` [Intel-wired-lan] [next PATCH 1/5] i40e: Introduce devlink interface Nambiar, Amritha
2016-08-10 16:01 ` Alexander Duyck
2016-08-10 16:50   ` John Fastabend
2016-08-10 18:18     ` Alexander Duyck
2016-08-10 18:41       ` John Fastabend
2016-08-16 18:54         ` Samudrala, Sridhar
2016-08-16 20:39           ` Alexander Duyck
2016-08-16 21:51             ` Samudrala, Sridhar
2016-08-17  0:17               ` Alexander Duyck
2016-08-17 19:24                 ` John Fastabend
2016-08-10 20:50 ` Jeff Kirsher

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=57AA738B.3080601@intel.com \
    --to=amritha.nambiar@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.