1 #include <linux/ethtool.h> 2 #include <linux/netdevice.h> 3 #include <linux/pci.h> 4 5 #include "fbnic.h" 6 #include "fbnic_netdev.h" 7 #include "fbnic_tlv.h" 8 9 static void 10 fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) 11 { 12 struct fbnic_net *fbn = netdev_priv(netdev); 13 struct fbnic_dev *fbd = fbn->fbd; 14 15 fbnic_get_fw_ver_commit_str(fbd, drvinfo->fw_version, 16 sizeof(drvinfo->fw_version)); 17 } 18 19 static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) 20 { 21 if (counter->reported) 22 *stat = counter->value; 23 } 24 25 static void 26 fbnic_get_eth_mac_stats(struct net_device *netdev, 27 struct ethtool_eth_mac_stats *eth_mac_stats) 28 { 29 struct fbnic_net *fbn = netdev_priv(netdev); 30 struct fbnic_mac_stats *mac_stats; 31 struct fbnic_dev *fbd = fbn->fbd; 32 const struct fbnic_mac *mac; 33 34 mac_stats = &fbd->hw_stats.mac; 35 mac = fbd->mac; 36 37 mac->get_eth_mac_stats(fbd, false, &mac_stats->eth_mac); 38 39 fbnic_set_counter(ð_mac_stats->FramesTransmittedOK, 40 &mac_stats->eth_mac.FramesTransmittedOK); 41 fbnic_set_counter(ð_mac_stats->FramesReceivedOK, 42 &mac_stats->eth_mac.FramesReceivedOK); 43 fbnic_set_counter(ð_mac_stats->FrameCheckSequenceErrors, 44 &mac_stats->eth_mac.FrameCheckSequenceErrors); 45 fbnic_set_counter(ð_mac_stats->AlignmentErrors, 46 &mac_stats->eth_mac.AlignmentErrors); 47 fbnic_set_counter(ð_mac_stats->OctetsTransmittedOK, 48 &mac_stats->eth_mac.OctetsTransmittedOK); 49 fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACXmitError, 50 &mac_stats->eth_mac.FramesLostDueToIntMACXmitError); 51 fbnic_set_counter(ð_mac_stats->OctetsReceivedOK, 52 &mac_stats->eth_mac.OctetsReceivedOK); 53 fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACRcvError, 54 &mac_stats->eth_mac.FramesLostDueToIntMACRcvError); 55 fbnic_set_counter(ð_mac_stats->MulticastFramesXmittedOK, 56 &mac_stats->eth_mac.MulticastFramesXmittedOK); 57 fbnic_set_counter(ð_mac_stats->BroadcastFramesXmittedOK, 58 &mac_stats->eth_mac.BroadcastFramesXmittedOK); 59 fbnic_set_counter(ð_mac_stats->MulticastFramesReceivedOK, 60 &mac_stats->eth_mac.MulticastFramesReceivedOK); 61 fbnic_set_counter(ð_mac_stats->BroadcastFramesReceivedOK, 62 &mac_stats->eth_mac.BroadcastFramesReceivedOK); 63 fbnic_set_counter(ð_mac_stats->FrameTooLongErrors, 64 &mac_stats->eth_mac.FrameTooLongErrors); 65 } 66 67 static const struct ethtool_ops fbnic_ethtool_ops = { 68 .get_drvinfo = fbnic_get_drvinfo, 69 .get_eth_mac_stats = fbnic_get_eth_mac_stats, 70 }; 71 72 void fbnic_set_ethtool_ops(struct net_device *dev) 73 { 74 dev->ethtool_ops = &fbnic_ethtool_ops; 75 } 76