From: Pawel Chmielewski <pawel.chmielew...@intel.com>

Add only limited number of ethtools ops. Also, stats set for a
subfunction is different than a regular netdev since there are
not port stats, show only related VSI statistics.

Reviewed-by: Wojciech Drewek <wojciech.dre...@intel.com>
Signed-off-by: Pawel Chmielewski <pawel.chmielew...@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkow...@linux.intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 36 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_sf_eth.c  |  1 +
 2 files changed, 37 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c 
b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index 3cc364a4d682..c862b21bad9f 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -1564,6 +1564,22 @@ static int ice_set_priv_flags(struct net_device *netdev, 
u32 flags)
        return ret;
 }
 
+/**
+ * ice_get_sf_sset_count - get number of stats to display for specified netdev
+ * of subfunction flavor
+ * @netdev: network interface device structure
+ * @sset: set of statistics to display
+ */
+static int ice_get_sf_sset_count(struct net_device *netdev, int sset)
+{
+       switch (sset) {
+       case ETH_SS_STATS:
+               return ICE_VSI_STATS_LEN + ice_q_stats_len(netdev);
+       default:
+               return -EOPNOTSUPP;
+       }
+}
+
 static int ice_get_sset_count(struct net_device *netdev, int sset)
 {
        switch (sset) {
@@ -4290,6 +4306,17 @@ static const struct ethtool_ops 
ice_ethtool_safe_mode_ops = {
        .get_channels           = ice_get_channels,
 };
 
+static const struct ethtool_ops ice_sf_ethtool_ops = {
+       .get_drvinfo            = ice_get_drvinfo,
+       .get_link               = ethtool_op_get_link,
+       .get_strings            = ice_get_strings,
+       .get_ethtool_stats      = ice_get_ethtool_stats,
+       .get_sset_count         = ice_get_sf_sset_count,
+       .get_ringparam          = ice_get_ringparam,
+       .set_ringparam          = ice_set_ringparam,
+       .get_channels           = ice_get_channels,
+};
+
 /**
  * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
  * @netdev: network interface device structure
@@ -4326,3 +4353,12 @@ void ice_set_ethtool_ops(struct net_device *netdev)
 {
        netdev->ethtool_ops = &ice_ethtool_ops;
 }
+
+/**
+ * ice_set_ethtool_sf_ops - setup subfunction ethtool ops
+ * @netdev: network interface device structure
+ */
+void ice_set_ethtool_sf_ops(struct net_device *netdev)
+{
+       netdev->ethtool_ops = &ice_sf_ethtool_ops;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_sf_eth.c 
b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
index f569f176f29f..f45ac76f0f43 100644
--- a/drivers/net/ethernet/intel/ice/ice_sf_eth.c
+++ b/drivers/net/ethernet/intel/ice/ice_sf_eth.c
@@ -55,6 +55,7 @@ static int ice_sf_cfg_netdev(struct ice_dynamic_port 
*dyn_port)
        eth_hw_addr_set(netdev, dyn_port->hw_addr);
        ether_addr_copy(netdev->perm_addr, dyn_port->hw_addr);
        netdev->netdev_ops = &ice_sf_netdev_ops;
+       ice_set_ethtool_sf_ops(netdev);
        SET_NETDEV_DEVLINK_PORT(netdev, &dyn_port->devlink_port);
 
        err = register_netdev(netdev);
-- 
2.42.0

Reply via email to