diff options
author | Brian King <brking@linux.vnet.ibm.com> | 2007-08-17 10:16:43 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:44 -0400 |
commit | ddbb4de9672097da2c0f19c6ebca0ebb5672e9b8 (patch) | |
tree | 9569ed9b89cd75302ecd53b76bad554669afc3fa /drivers/net/ibmveth.c | |
parent | 80e536770c2fcb8d2b7be9f5a36b85c36fd5943a (diff) |
ibmveth: Add ethtool driver stats hooks
Add ethtool hooks to ibmveth to retrieve driver statistics.
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/ibmveth.c')
-rw-r--r-- | drivers/net/ibmveth.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 9bf0f92d3a50..40cb00e37df6 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -113,6 +113,28 @@ MODULE_DESCRIPTION("IBM i/pSeries Virtual Ethernet Driver"); | |||
113 | MODULE_LICENSE("GPL"); | 113 | MODULE_LICENSE("GPL"); |
114 | MODULE_VERSION(ibmveth_driver_version); | 114 | MODULE_VERSION(ibmveth_driver_version); |
115 | 115 | ||
116 | struct ibmveth_stat { | ||
117 | char name[ETH_GSTRING_LEN]; | ||
118 | int offset; | ||
119 | }; | ||
120 | |||
121 | #define IBMVETH_STAT_OFF(stat) offsetof(struct ibmveth_adapter, stat) | ||
122 | #define IBMVETH_GET_STAT(a, off) *((u64 *)(((unsigned long)(a)) + off)) | ||
123 | |||
124 | struct ibmveth_stat ibmveth_stats[] = { | ||
125 | { "replenish_task_cycles", IBMVETH_STAT_OFF(replenish_task_cycles) }, | ||
126 | { "replenish_no_mem", IBMVETH_STAT_OFF(replenish_no_mem) }, | ||
127 | { "replenish_add_buff_failure", IBMVETH_STAT_OFF(replenish_add_buff_failure) }, | ||
128 | { "replenish_add_buff_success", IBMVETH_STAT_OFF(replenish_add_buff_success) }, | ||
129 | { "rx_invalid_buffer", IBMVETH_STAT_OFF(rx_invalid_buffer) }, | ||
130 | { "rx_no_buffer", IBMVETH_STAT_OFF(rx_no_buffer) }, | ||
131 | { "tx_multidesc_send", IBMVETH_STAT_OFF(tx_multidesc_send) }, | ||
132 | { "tx_linearized", IBMVETH_STAT_OFF(tx_linearized) }, | ||
133 | { "tx_linearize_failed", IBMVETH_STAT_OFF(tx_linearize_failed) }, | ||
134 | { "tx_map_failed", IBMVETH_STAT_OFF(tx_map_failed) }, | ||
135 | { "tx_send_failed", IBMVETH_STAT_OFF(tx_send_failed) }, | ||
136 | }; | ||
137 | |||
116 | /* simple methods of getting data from the current rxq entry */ | 138 | /* simple methods of getting data from the current rxq entry */ |
117 | static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) | 139 | static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter) |
118 | { | 140 | { |
@@ -769,6 +791,32 @@ static u32 ibmveth_get_rx_csum(struct net_device *dev) | |||
769 | return adapter->rx_csum; | 791 | return adapter->rx_csum; |
770 | } | 792 | } |
771 | 793 | ||
794 | static void ibmveth_get_strings(struct net_device *dev, u32 stringset, u8 *data) | ||
795 | { | ||
796 | int i; | ||
797 | |||
798 | if (stringset != ETH_SS_STATS) | ||
799 | return; | ||
800 | |||
801 | for (i = 0; i < ARRAY_SIZE(ibmveth_stats); i++, data += ETH_GSTRING_LEN) | ||
802 | memcpy(data, ibmveth_stats[i].name, ETH_GSTRING_LEN); | ||
803 | } | ||
804 | |||
805 | static int ibmveth_get_stats_count(struct net_device *dev) | ||
806 | { | ||
807 | return ARRAY_SIZE(ibmveth_stats); | ||
808 | } | ||
809 | |||
810 | static void ibmveth_get_ethtool_stats(struct net_device *dev, | ||
811 | struct ethtool_stats *stats, u64 *data) | ||
812 | { | ||
813 | int i; | ||
814 | struct ibmveth_adapter *adapter = dev->priv; | ||
815 | |||
816 | for (i = 0; i < ARRAY_SIZE(ibmveth_stats); i++) | ||
817 | data[i] = IBMVETH_GET_STAT(adapter, ibmveth_stats[i].offset); | ||
818 | } | ||
819 | |||
772 | static const struct ethtool_ops netdev_ethtool_ops = { | 820 | static const struct ethtool_ops netdev_ethtool_ops = { |
773 | .get_drvinfo = netdev_get_drvinfo, | 821 | .get_drvinfo = netdev_get_drvinfo, |
774 | .get_settings = netdev_get_settings, | 822 | .get_settings = netdev_get_settings, |
@@ -780,6 +828,9 @@ static const struct ethtool_ops netdev_ethtool_ops = { | |||
780 | .set_rx_csum = ibmveth_set_rx_csum, | 828 | .set_rx_csum = ibmveth_set_rx_csum, |
781 | .get_tso = ethtool_op_get_tso, | 829 | .get_tso = ethtool_op_get_tso, |
782 | .get_ufo = ethtool_op_get_ufo, | 830 | .get_ufo = ethtool_op_get_ufo, |
831 | .get_strings = ibmveth_get_strings, | ||
832 | .get_stats_count = ibmveth_get_stats_count, | ||
833 | .get_ethtool_stats = ibmveth_get_ethtool_stats, | ||
783 | }; | 834 | }; |
784 | 835 | ||
785 | static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 836 | static int ibmveth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |