30 #include <linux/netdevice.h>
31 #include <linux/ethtool.h>
32 #include <linux/pci.h>
37 #include <linux/if_vlan.h>
47 #define IGBVF_STAT(current, base) \
48 sizeof(((struct igbvf_adapter *)0)->current), \
49 offsetof(struct igbvf_adapter, current), \
50 offsetof(struct igbvf_adapter, base)
52 static const struct igbvf_stats igbvf_gstrings_stats[] = {
60 {
"tx_restart_queue",
IGBVF_STAT(restart_queue, zero_base) },
62 {
"rx_csum_offload_good",
IGBVF_STAT(hw_csum_good, zero_base) },
63 {
"rx_csum_offload_errors",
IGBVF_STAT(hw_csum_err, zero_base) },
64 {
"rx_header_split",
IGBVF_STAT(rx_hdr_split, zero_base) },
65 {
"alloc_rx_buff_failed",
IGBVF_STAT(alloc_rx_buff_failed, zero_base) },
68 #define IGBVF_GLOBAL_STATS_LEN ARRAY_SIZE(igbvf_gstrings_stats)
71 "Link test (on/offline)"
74 #define IGBVF_TEST_LEN ARRAY_SIZE(igbvf_gstrings_test)
76 static int igbvf_get_settings(
struct net_device *netdev,
97 ethtool_cmd_speed_set(ecmd,
SPEED_10);
104 ethtool_cmd_speed_set(ecmd, -1);
113 static int igbvf_set_settings(
struct net_device *netdev,
119 static void igbvf_get_pauseparam(
struct net_device *netdev,
125 static int igbvf_set_pauseparam(
struct net_device *netdev,
145 #define IGBVF_REGS_LEN 8
156 memset(p, 0, IGBVF_REGS_LEN *
sizeof(
u32));
158 regs->
version = (1 << 24) | (adapter->
pdev->revision << 16) |
159 adapter->
pdev->device;
164 regs_buff[2] =
er32(RDLEN(0));
165 regs_buff[3] =
er32(RDH(0));
166 regs_buff[4] =
er32(RDT(0));
168 regs_buff[5] =
er32(TDLEN(0));
169 regs_buff[6] =
er32(TDH(0));
170 regs_buff[7] =
er32(TDT(0));
173 static int igbvf_get_eeprom_len(
struct net_device *netdev)
178 static int igbvf_get_eeprom(
struct net_device *netdev,
184 static int igbvf_set_eeprom(
struct net_device *netdev,
190 static void igbvf_get_drvinfo(
struct net_device *netdev,
201 drvinfo->
eedump_len = igbvf_get_eeprom_len(netdev);
204 static void igbvf_get_ringparam(
struct net_device *netdev,
217 static int igbvf_set_ringparam(
struct net_device *netdev,
223 u32 new_rx_count, new_tx_count;
236 if ((new_tx_count == adapter->tx_ring->count) &&
237 (new_rx_count == adapter->
rx_ring->count)) {
245 if (!netif_running(adapter->
netdev)) {
246 adapter->tx_ring->count = new_tx_count;
247 adapter->
rx_ring->count = new_rx_count;
264 if (new_tx_count != adapter->tx_ring->count) {
267 temp_ring->
count = new_tx_count;
277 if (new_rx_count != adapter->
rx_ring->count) {
280 temp_ring->
count = new_rx_count;
302 hw->
mac.ops.check_for_link(hw);
310 static void igbvf_diag_test(
struct net_device *netdev,
321 if (igbvf_link_test(adapter, &data[0]))
328 static void igbvf_get_wol(
struct net_device *netdev,
335 static int igbvf_set_wol(
struct net_device *netdev,
341 static int igbvf_get_coalesce(
struct net_device *netdev,
354 static int igbvf_set_coalesce(
struct net_device *netdev,
389 static int igbvf_nway_reset(
struct net_device *netdev)
392 if (netif_running(netdev))
398 static void igbvf_get_ethtool_stats(
struct net_device *netdev,
407 char *p = (
char *)adapter +
408 igbvf_gstrings_stats[i].stat_offset;
409 char *
b = (
char *)adapter +
410 igbvf_gstrings_stats[i].base_stat_offset;
418 static int igbvf_get_sset_count(
struct net_device *
dev,
int stringset)
430 static void igbvf_get_strings(
struct net_device *netdev,
u32 stringset,
438 memcpy(data, *igbvf_gstrings_test,
sizeof(igbvf_gstrings_test));
442 memcpy(p, igbvf_gstrings_stats[i].stat_string,
450 static const struct ethtool_ops igbvf_ethtool_ops = {
451 .get_settings = igbvf_get_settings,
452 .set_settings = igbvf_set_settings,
453 .get_drvinfo = igbvf_get_drvinfo,
454 .get_regs_len = igbvf_get_regs_len,
455 .get_regs = igbvf_get_regs,
456 .get_wol = igbvf_get_wol,
457 .set_wol = igbvf_set_wol,
458 .get_msglevel = igbvf_get_msglevel,
459 .set_msglevel = igbvf_set_msglevel,
460 .nway_reset = igbvf_nway_reset,
462 .get_eeprom_len = igbvf_get_eeprom_len,
463 .get_eeprom = igbvf_get_eeprom,
464 .set_eeprom = igbvf_set_eeprom,
465 .get_ringparam = igbvf_get_ringparam,
466 .set_ringparam = igbvf_set_ringparam,
467 .get_pauseparam = igbvf_get_pauseparam,
468 .set_pauseparam = igbvf_set_pauseparam,
469 .self_test = igbvf_diag_test,
470 .get_sset_count = igbvf_get_sset_count,
471 .get_strings = igbvf_get_strings,
472 .get_ethtool_stats = igbvf_get_ethtool_stats,
473 .get_coalesce = igbvf_get_coalesce,
474 .set_coalesce = igbvf_set_coalesce,