diff options
author | amit salecha <amit.salecha@qlogic.com> | 2010-10-17 21:47:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-18 10:22:50 -0400 |
commit | 3666e0b04f092f9d9da8a6d6a3820de6c870407c (patch) | |
tree | b77871dff6a81b58aadc5d22f617724499238bda /drivers/net | |
parent | 27a954bd560f3e385bbed38fde3051fe718b8d75 (diff) |
qlcnic: update ethtool stats
Added statistics for Nic Partition supported adapter.
These statistics are maintined in device.
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/qlcnic/qlcnic_ethtool.c | 73 |
1 files changed, 70 insertions, 3 deletions
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c index 2568aa665024..25e93a53fca0 100644 --- a/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/qlcnic/qlcnic_ethtool.c | |||
@@ -78,7 +78,25 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = { | |||
78 | 78 | ||
79 | }; | 79 | }; |
80 | 80 | ||
81 | static const char qlcnic_device_gstrings_stats[][ETH_GSTRING_LEN] = { | ||
82 | "rx unicast frames", | ||
83 | "rx multicast frames", | ||
84 | "rx broadcast frames", | ||
85 | "rx dropped frames", | ||
86 | "rx errors", | ||
87 | "rx local frames", | ||
88 | "rx numbytes", | ||
89 | "tx unicast frames", | ||
90 | "tx multicast frames", | ||
91 | "tx broadcast frames", | ||
92 | "tx dropped frames", | ||
93 | "tx errors", | ||
94 | "tx local frames", | ||
95 | "tx numbytes", | ||
96 | }; | ||
97 | |||
81 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) | 98 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) |
99 | #define QLCNIC_DEVICE_STATS_LEN ARRAY_SIZE(qlcnic_device_gstrings_stats) | ||
82 | 100 | ||
83 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { | 101 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { |
84 | "Register_Test_on_offline", | 102 | "Register_Test_on_offline", |
@@ -625,10 +643,13 @@ static int qlcnic_reg_test(struct net_device *dev) | |||
625 | 643 | ||
626 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) | 644 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) |
627 | { | 645 | { |
646 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
628 | switch (sset) { | 647 | switch (sset) { |
629 | case ETH_SS_TEST: | 648 | case ETH_SS_TEST: |
630 | return QLCNIC_TEST_LEN; | 649 | return QLCNIC_TEST_LEN; |
631 | case ETH_SS_STATS: | 650 | case ETH_SS_STATS: |
651 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) | ||
652 | return QLCNIC_STATS_LEN + QLCNIC_DEVICE_STATS_LEN; | ||
632 | return QLCNIC_STATS_LEN; | 653 | return QLCNIC_STATS_LEN; |
633 | default: | 654 | default: |
634 | return -EOPNOTSUPP; | 655 | return -EOPNOTSUPP; |
@@ -795,7 +816,8 @@ qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | |||
795 | static void | 816 | static void |
796 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | 817 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) |
797 | { | 818 | { |
798 | int index; | 819 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
820 | int index, i; | ||
799 | 821 | ||
800 | switch (stringset) { | 822 | switch (stringset) { |
801 | case ETH_SS_TEST: | 823 | case ETH_SS_TEST: |
@@ -808,16 +830,43 @@ qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |||
808 | qlcnic_gstrings_stats[index].stat_string, | 830 | qlcnic_gstrings_stats[index].stat_string, |
809 | ETH_GSTRING_LEN); | 831 | ETH_GSTRING_LEN); |
810 | } | 832 | } |
811 | break; | 833 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
834 | return; | ||
835 | for (i = 0; i < QLCNIC_DEVICE_STATS_LEN; index++, i++) { | ||
836 | memcpy(data + index * ETH_GSTRING_LEN, | ||
837 | qlcnic_device_gstrings_stats[i], | ||
838 | ETH_GSTRING_LEN); | ||
839 | } | ||
812 | } | 840 | } |
813 | } | 841 | } |
814 | 842 | ||
843 | #define QLCNIC_FILL_ESWITCH_STATS(VAL1) \ | ||
844 | (((VAL1) == QLCNIC_ESW_STATS_NOT_AVAIL) ? 0 : VAL1) | ||
845 | |||
846 | static void | ||
847 | qlcnic_fill_device_stats(int *index, u64 *data, | ||
848 | struct __qlcnic_esw_statistics *stats) | ||
849 | { | ||
850 | int ind = *index; | ||
851 | |||
852 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->unicast_frames); | ||
853 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->multicast_frames); | ||
854 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->broadcast_frames); | ||
855 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->dropped_frames); | ||
856 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->errors); | ||
857 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->local_frames); | ||
858 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->numbytes); | ||
859 | |||
860 | *index = ind; | ||
861 | } | ||
862 | |||
815 | static void | 863 | static void |
816 | qlcnic_get_ethtool_stats(struct net_device *dev, | 864 | qlcnic_get_ethtool_stats(struct net_device *dev, |
817 | struct ethtool_stats *stats, u64 * data) | 865 | struct ethtool_stats *stats, u64 * data) |
818 | { | 866 | { |
819 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 867 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
820 | int index; | 868 | struct qlcnic_esw_statistics port_stats; |
869 | int index, ret; | ||
821 | 870 | ||
822 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { | 871 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { |
823 | char *p = | 872 | char *p = |
@@ -827,6 +876,24 @@ qlcnic_get_ethtool_stats(struct net_device *dev, | |||
827 | (qlcnic_gstrings_stats[index].sizeof_stat == | 876 | (qlcnic_gstrings_stats[index].sizeof_stat == |
828 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); | 877 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); |
829 | } | 878 | } |
879 | |||
880 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) | ||
881 | return; | ||
882 | |||
883 | memset(&port_stats, 0, sizeof(struct qlcnic_esw_statistics)); | ||
884 | ret = qlcnic_get_port_stats(adapter, adapter->ahw.pci_func, | ||
885 | QLCNIC_QUERY_RX_COUNTER, &port_stats.rx); | ||
886 | if (ret) | ||
887 | return; | ||
888 | |||
889 | qlcnic_fill_device_stats(&index, data, &port_stats.rx); | ||
890 | |||
891 | ret = qlcnic_get_port_stats(adapter, adapter->ahw.pci_func, | ||
892 | QLCNIC_QUERY_TX_COUNTER, &port_stats.tx); | ||
893 | if (ret) | ||
894 | return; | ||
895 | |||
896 | qlcnic_fill_device_stats(&index, data, &port_stats.tx); | ||
830 | } | 897 | } |
831 | 898 | ||
832 | static int qlcnic_set_tx_csum(struct net_device *dev, u32 data) | 899 | static int qlcnic_set_tx_csum(struct net_device *dev, u32 data) |