2018-03-23 01:08:48 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2018-04-26 23:08:09 +08:00
|
|
|
/* Copyright(c) 2009 - 2018 Intel Corporation. */
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
/* ethtool support for igbvf */
|
|
|
|
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#include "igbvf.h"
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
|
|
|
|
struct igbvf_stats {
|
|
|
|
char stat_string[ETH_GSTRING_LEN];
|
|
|
|
int sizeof_stat;
|
|
|
|
int stat_offset;
|
|
|
|
int base_stat_offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IGBVF_STAT(current, base) \
|
|
|
|
sizeof(((struct igbvf_adapter *)0)->current), \
|
|
|
|
offsetof(struct igbvf_adapter, current), \
|
|
|
|
offsetof(struct igbvf_adapter, base)
|
|
|
|
|
|
|
|
static const struct igbvf_stats igbvf_gstrings_stats[] = {
|
|
|
|
{ "rx_packets", IGBVF_STAT(stats.gprc, stats.base_gprc) },
|
|
|
|
{ "tx_packets", IGBVF_STAT(stats.gptc, stats.base_gptc) },
|
|
|
|
{ "rx_bytes", IGBVF_STAT(stats.gorc, stats.base_gorc) },
|
|
|
|
{ "tx_bytes", IGBVF_STAT(stats.gotc, stats.base_gotc) },
|
|
|
|
{ "multicast", IGBVF_STAT(stats.mprc, stats.base_mprc) },
|
|
|
|
{ "lbrx_bytes", IGBVF_STAT(stats.gorlbc, stats.base_gorlbc) },
|
|
|
|
{ "lbrx_packets", IGBVF_STAT(stats.gprlbc, stats.base_gprlbc) },
|
|
|
|
{ "tx_restart_queue", IGBVF_STAT(restart_queue, zero_base) },
|
|
|
|
{ "rx_long_byte_count", IGBVF_STAT(stats.gorc, stats.base_gorc) },
|
|
|
|
{ "rx_csum_offload_good", IGBVF_STAT(hw_csum_good, zero_base) },
|
|
|
|
{ "rx_csum_offload_errors", IGBVF_STAT(hw_csum_err, zero_base) },
|
|
|
|
{ "rx_header_split", IGBVF_STAT(rx_hdr_split, zero_base) },
|
|
|
|
{ "alloc_rx_buff_failed", IGBVF_STAT(alloc_rx_buff_failed, zero_base) },
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IGBVF_GLOBAL_STATS_LEN ARRAY_SIZE(igbvf_gstrings_stats)
|
|
|
|
|
|
|
|
static const char igbvf_gstrings_test[][ETH_GSTRING_LEN] = {
|
|
|
|
"Link test (on/offline)"
|
|
|
|
};
|
|
|
|
|
|
|
|
#define IGBVF_TEST_LEN ARRAY_SIZE(igbvf_gstrings_test)
|
|
|
|
|
2017-02-06 06:55:19 +08:00
|
|
|
static int igbvf_get_link_ksettings(struct net_device *netdev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
|
|
|
u32 status;
|
|
|
|
|
2017-02-06 06:55:19 +08:00
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, supported);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, supported, 1000baseT_Full);
|
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
|
|
|
|
ethtool_link_ksettings_add_link_mode(cmd, advertising, 1000baseT_Full);
|
2009-04-07 22:37:34 +08:00
|
|
|
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.port = -1;
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
status = er32(STATUS);
|
|
|
|
if (status & E1000_STATUS_LU) {
|
|
|
|
if (status & E1000_STATUS_SPEED_1000)
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.speed = SPEED_1000;
|
2009-04-07 22:37:34 +08:00
|
|
|
else if (status & E1000_STATUS_SPEED_100)
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.speed = SPEED_100;
|
2009-04-07 22:37:34 +08:00
|
|
|
else
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.speed = SPEED_10;
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
if (status & E1000_STATUS_FD)
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.duplex = DUPLEX_FULL;
|
2009-04-07 22:37:34 +08:00
|
|
|
else
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.duplex = DUPLEX_HALF;
|
2009-04-07 22:37:34 +08:00
|
|
|
} else {
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.speed = SPEED_UNKNOWN;
|
|
|
|
cmd->base.duplex = DUPLEX_UNKNOWN;
|
2009-04-07 22:37:34 +08:00
|
|
|
}
|
|
|
|
|
2017-02-06 06:55:19 +08:00
|
|
|
cmd->base.autoneg = AUTONEG_DISABLE;
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-06 06:55:19 +08:00
|
|
|
static int igbvf_set_link_ksettings(struct net_device *netdev,
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_pauseparam(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_pauseparam *pause)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_set_pauseparam(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_pauseparam *pause)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 igbvf_get_msglevel(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
2015-01-21 17:57:50 +08:00
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
return adapter->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_set_msglevel(struct net_device *netdev, u32 data)
|
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
2015-01-21 17:57:50 +08:00
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
adapter->msg_enable = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_get_regs_len(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
#define IGBVF_REGS_LEN 8
|
|
|
|
return IGBVF_REGS_LEN * sizeof(u32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_regs(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_regs *regs, void *p)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
|
|
|
u32 *regs_buff = p;
|
|
|
|
|
|
|
|
memset(p, 0, IGBVF_REGS_LEN * sizeof(u32));
|
|
|
|
|
2016-04-14 07:08:31 +08:00
|
|
|
regs->version = (1u << 24) |
|
|
|
|
(adapter->pdev->revision << 16) |
|
2011-03-01 03:57:33 +08:00
|
|
|
adapter->pdev->device;
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
regs_buff[0] = er32(CTRL);
|
|
|
|
regs_buff[1] = er32(STATUS);
|
|
|
|
|
|
|
|
regs_buff[2] = er32(RDLEN(0));
|
|
|
|
regs_buff[3] = er32(RDH(0));
|
|
|
|
regs_buff[4] = er32(RDT(0));
|
|
|
|
|
|
|
|
regs_buff[5] = er32(TDLEN(0));
|
|
|
|
regs_buff[6] = er32(TDH(0));
|
|
|
|
regs_buff[7] = er32(TDT(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_get_eeprom_len(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_get_eeprom(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_eeprom *eeprom, u8 *bytes)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_set_eeprom(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_eeprom *eeprom, u8 *bytes)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_drvinfo(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_drvinfo *drvinfo)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2011-11-14 16:13:25 +08:00
|
|
|
strlcpy(drvinfo->driver, igbvf_driver_name, sizeof(drvinfo->driver));
|
|
|
|
strlcpy(drvinfo->version, igbvf_driver_version,
|
|
|
|
sizeof(drvinfo->version));
|
|
|
|
strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
|
|
|
|
sizeof(drvinfo->bus_info));
|
2009-04-07 22:37:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_ringparam(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_ringparam *ring)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct igbvf_ring *tx_ring = adapter->tx_ring;
|
|
|
|
struct igbvf_ring *rx_ring = adapter->rx_ring;
|
|
|
|
|
|
|
|
ring->rx_max_pending = IGBVF_MAX_RXD;
|
|
|
|
ring->tx_max_pending = IGBVF_MAX_TXD;
|
|
|
|
ring->rx_pending = rx_ring->count;
|
|
|
|
ring->tx_pending = tx_ring->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_set_ringparam(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_ringparam *ring)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct igbvf_ring *temp_ring;
|
2009-10-26 19:32:25 +08:00
|
|
|
int err = 0;
|
2009-04-07 22:37:34 +08:00
|
|
|
u32 new_rx_count, new_tx_count;
|
|
|
|
|
|
|
|
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2015-02-21 12:55:56 +08:00
|
|
|
new_rx_count = max_t(u32, ring->rx_pending, IGBVF_MIN_RXD);
|
|
|
|
new_rx_count = min_t(u32, new_rx_count, IGBVF_MAX_RXD);
|
2009-04-07 22:37:34 +08:00
|
|
|
new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
|
|
|
|
|
2015-02-21 12:55:56 +08:00
|
|
|
new_tx_count = max_t(u32, ring->tx_pending, IGBVF_MIN_TXD);
|
|
|
|
new_tx_count = min_t(u32, new_tx_count, IGBVF_MAX_TXD);
|
2009-04-07 22:37:34 +08:00
|
|
|
new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
|
|
|
|
|
|
|
|
if ((new_tx_count == adapter->tx_ring->count) &&
|
|
|
|
(new_rx_count == adapter->rx_ring->count)) {
|
|
|
|
/* nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state))
|
2015-02-21 12:55:56 +08:00
|
|
|
usleep_range(1000, 2000);
|
2009-04-07 22:37:34 +08:00
|
|
|
|
2009-10-26 19:32:25 +08:00
|
|
|
if (!netif_running(adapter->netdev)) {
|
|
|
|
adapter->tx_ring->count = new_tx_count;
|
|
|
|
adapter->rx_ring->count = new_rx_count;
|
|
|
|
goto clear_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
temp_ring = vmalloc(sizeof(struct igbvf_ring));
|
|
|
|
if (!temp_ring) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto clear_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
igbvf_down(adapter);
|
2009-04-07 22:37:34 +08:00
|
|
|
|
2015-01-21 17:57:50 +08:00
|
|
|
/* We can't just free everything and then setup again,
|
2009-04-07 22:37:34 +08:00
|
|
|
* because the ISRs in MSI-X mode get passed pointers
|
2015-01-21 17:57:50 +08:00
|
|
|
* to the Tx and Rx ring structs.
|
2009-04-07 22:37:34 +08:00
|
|
|
*/
|
|
|
|
if (new_tx_count != adapter->tx_ring->count) {
|
|
|
|
memcpy(temp_ring, adapter->tx_ring, sizeof(struct igbvf_ring));
|
|
|
|
|
|
|
|
temp_ring->count = new_tx_count;
|
|
|
|
err = igbvf_setup_tx_resources(adapter, temp_ring);
|
|
|
|
if (err)
|
|
|
|
goto err_setup;
|
|
|
|
|
|
|
|
igbvf_free_tx_resources(adapter->tx_ring);
|
|
|
|
|
|
|
|
memcpy(adapter->tx_ring, temp_ring, sizeof(struct igbvf_ring));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_rx_count != adapter->rx_ring->count) {
|
|
|
|
memcpy(temp_ring, adapter->rx_ring, sizeof(struct igbvf_ring));
|
|
|
|
|
|
|
|
temp_ring->count = new_rx_count;
|
|
|
|
err = igbvf_setup_rx_resources(adapter, temp_ring);
|
|
|
|
if (err)
|
|
|
|
goto err_setup;
|
|
|
|
|
|
|
|
igbvf_free_rx_resources(adapter->rx_ring);
|
|
|
|
|
2015-01-21 17:57:50 +08:00
|
|
|
memcpy(adapter->rx_ring, temp_ring, sizeof(struct igbvf_ring));
|
2009-04-07 22:37:34 +08:00
|
|
|
}
|
|
|
|
err_setup:
|
2009-10-26 19:32:25 +08:00
|
|
|
igbvf_up(adapter);
|
2009-04-07 22:37:34 +08:00
|
|
|
vfree(temp_ring);
|
2009-10-26 19:32:25 +08:00
|
|
|
clear_reset:
|
|
|
|
clear_bit(__IGBVF_RESETTING, &adapter->state);
|
2009-04-07 22:37:34 +08:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_link_test(struct igbvf_adapter *adapter, u64 *data)
|
|
|
|
{
|
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
|
|
|
*data = 0;
|
|
|
|
|
2017-07-21 00:00:57 +08:00
|
|
|
spin_lock_bh(&hw->mbx_lock);
|
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
hw->mac.ops.check_for_link(hw);
|
|
|
|
|
2017-07-21 00:00:57 +08:00
|
|
|
spin_unlock_bh(&hw->mbx_lock);
|
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
if (!(er32(STATUS) & E1000_STATUS_LU))
|
|
|
|
*data = 1;
|
|
|
|
|
|
|
|
return *data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_diag_test(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_test *eth_test, u64 *data)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
set_bit(__IGBVF_TESTING, &adapter->state);
|
|
|
|
|
2015-01-21 17:57:50 +08:00
|
|
|
/* Link test performed before hardware reset so autoneg doesn't
|
2009-04-07 22:37:34 +08:00
|
|
|
* interfere with test result
|
|
|
|
*/
|
|
|
|
if (igbvf_link_test(adapter, &data[0]))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
|
|
|
|
clear_bit(__IGBVF_TESTING, &adapter->state);
|
|
|
|
msleep_interruptible(4 * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_wol(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_wolinfo *wol)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
wol->supported = 0;
|
|
|
|
wol->wolopts = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_set_wol(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_wolinfo *wol)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_get_coalesce(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_coalesce *ec)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2012-01-14 16:10:50 +08:00
|
|
|
if (adapter->requested_itr <= 3)
|
|
|
|
ec->rx_coalesce_usecs = adapter->requested_itr;
|
2009-04-07 22:37:34 +08:00
|
|
|
else
|
2012-01-14 16:10:50 +08:00
|
|
|
ec->rx_coalesce_usecs = adapter->current_itr >> 2;
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_set_coalesce(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_coalesce *ec)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct e1000_hw *hw = &adapter->hw;
|
|
|
|
|
2012-06-30 08:23:19 +08:00
|
|
|
if ((ec->rx_coalesce_usecs >= IGBVF_MIN_ITR_USECS) &&
|
2015-01-21 17:57:50 +08:00
|
|
|
(ec->rx_coalesce_usecs <= IGBVF_MAX_ITR_USECS)) {
|
2012-06-30 08:23:19 +08:00
|
|
|
adapter->current_itr = ec->rx_coalesce_usecs << 2;
|
|
|
|
adapter->requested_itr = 1000000000 /
|
|
|
|
(adapter->current_itr * 256);
|
|
|
|
} else if ((ec->rx_coalesce_usecs == 3) ||
|
|
|
|
(ec->rx_coalesce_usecs == 2)) {
|
2012-01-14 16:10:50 +08:00
|
|
|
adapter->current_itr = IGBVF_START_ITR;
|
|
|
|
adapter->requested_itr = ec->rx_coalesce_usecs;
|
2012-06-30 08:23:19 +08:00
|
|
|
} else if (ec->rx_coalesce_usecs == 0) {
|
2015-01-21 17:57:50 +08:00
|
|
|
/* The user's desire is to turn off interrupt throttling
|
2012-06-30 08:23:19 +08:00
|
|
|
* altogether, but due to HW limitations, we can't do that.
|
|
|
|
* Instead we set a very small value in EITR, which would
|
|
|
|
* allow ~967k interrupts per second, but allow the adapter's
|
|
|
|
* internal clocking to still function properly.
|
|
|
|
*/
|
|
|
|
adapter->current_itr = 4;
|
2012-01-14 16:10:50 +08:00
|
|
|
adapter->requested_itr = 1000000000 /
|
|
|
|
(adapter->current_itr * 256);
|
2015-01-21 17:57:50 +08:00
|
|
|
} else {
|
2012-06-30 08:23:19 +08:00
|
|
|
return -EINVAL;
|
2015-01-21 17:57:50 +08:00
|
|
|
}
|
2009-04-07 22:37:34 +08:00
|
|
|
|
2012-01-14 16:10:50 +08:00
|
|
|
writel(adapter->current_itr,
|
|
|
|
hw->hw_addr + adapter->rx_ring->itr_register);
|
2009-04-07 22:37:34 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int igbvf_nway_reset(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
2015-01-21 17:57:50 +08:00
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
if (netif_running(netdev))
|
|
|
|
igbvf_reinit_locked(adapter);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void igbvf_get_ethtool_stats(struct net_device *netdev,
|
2015-01-21 17:57:50 +08:00
|
|
|
struct ethtool_stats *stats,
|
|
|
|
u64 *data)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
struct igbvf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
igbvf_update_stats(adapter);
|
|
|
|
for (i = 0; i < IGBVF_GLOBAL_STATS_LEN; i++) {
|
|
|
|
char *p = (char *)adapter +
|
2015-01-21 17:57:50 +08:00
|
|
|
igbvf_gstrings_stats[i].stat_offset;
|
2009-04-07 22:37:34 +08:00
|
|
|
char *b = (char *)adapter +
|
2015-01-21 17:57:50 +08:00
|
|
|
igbvf_gstrings_stats[i].base_stat_offset;
|
2009-04-07 22:37:34 +08:00
|
|
|
data[i] = ((igbvf_gstrings_stats[i].sizeof_stat ==
|
2015-01-21 17:57:50 +08:00
|
|
|
sizeof(u64)) ? (*(u64 *)p - *(u64 *)b) :
|
|
|
|
(*(u32 *)p - *(u32 *)b));
|
2009-04-07 22:37:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-01 19:58:24 +08:00
|
|
|
static int igbvf_get_sset_count(struct net_device *dev, int stringset)
|
|
|
|
{
|
2015-01-21 17:57:50 +08:00
|
|
|
switch (stringset) {
|
2009-10-01 19:58:24 +08:00
|
|
|
case ETH_SS_TEST:
|
|
|
|
return IGBVF_TEST_LEN;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
return IGBVF_GLOBAL_STATS_LEN;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-07 22:37:34 +08:00
|
|
|
static void igbvf_get_strings(struct net_device *netdev, u32 stringset,
|
2015-01-21 17:57:50 +08:00
|
|
|
u8 *data)
|
2009-04-07 22:37:34 +08:00
|
|
|
{
|
|
|
|
u8 *p = data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
memcpy(data, *igbvf_gstrings_test, sizeof(igbvf_gstrings_test));
|
|
|
|
break;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
for (i = 0; i < IGBVF_GLOBAL_STATS_LEN; i++) {
|
|
|
|
memcpy(p, igbvf_gstrings_stats[i].stat_string,
|
|
|
|
ETH_GSTRING_LEN);
|
|
|
|
p += ETH_GSTRING_LEN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ethtool_ops igbvf_ethtool_ops = {
|
|
|
|
.get_drvinfo = igbvf_get_drvinfo,
|
|
|
|
.get_regs_len = igbvf_get_regs_len,
|
|
|
|
.get_regs = igbvf_get_regs,
|
|
|
|
.get_wol = igbvf_get_wol,
|
|
|
|
.set_wol = igbvf_set_wol,
|
|
|
|
.get_msglevel = igbvf_get_msglevel,
|
|
|
|
.set_msglevel = igbvf_set_msglevel,
|
|
|
|
.nway_reset = igbvf_nway_reset,
|
2010-12-09 20:10:25 +08:00
|
|
|
.get_link = ethtool_op_get_link,
|
2009-04-07 22:37:34 +08:00
|
|
|
.get_eeprom_len = igbvf_get_eeprom_len,
|
|
|
|
.get_eeprom = igbvf_get_eeprom,
|
|
|
|
.set_eeprom = igbvf_set_eeprom,
|
|
|
|
.get_ringparam = igbvf_get_ringparam,
|
|
|
|
.set_ringparam = igbvf_set_ringparam,
|
|
|
|
.get_pauseparam = igbvf_get_pauseparam,
|
|
|
|
.set_pauseparam = igbvf_set_pauseparam,
|
|
|
|
.self_test = igbvf_diag_test,
|
2009-10-01 19:58:24 +08:00
|
|
|
.get_sset_count = igbvf_get_sset_count,
|
2009-04-07 22:37:34 +08:00
|
|
|
.get_strings = igbvf_get_strings,
|
|
|
|
.get_ethtool_stats = igbvf_get_ethtool_stats,
|
|
|
|
.get_coalesce = igbvf_get_coalesce,
|
|
|
|
.set_coalesce = igbvf_set_coalesce,
|
2017-02-06 06:55:19 +08:00
|
|
|
.get_link_ksettings = igbvf_get_link_ksettings,
|
|
|
|
.set_link_ksettings = igbvf_set_link_ksettings,
|
2009-04-07 22:37:34 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void igbvf_set_ethtool_ops(struct net_device *netdev)
|
|
|
|
{
|
2014-05-11 08:12:32 +08:00
|
|
|
netdev->ethtool_ops = &igbvf_ethtool_ops;
|
2009-04-07 22:37:34 +08:00
|
|
|
}
|