2010-01-09 10:24:10 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
|
|
|
|
Intel 82599 Virtual Function driver
|
2014-03-04 11:02:29 +08:00
|
|
|
Copyright(c) 1999 - 2014 Intel Corporation.
|
2010-01-09 10:24:10 +08:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms and conditions of the GNU General Public License,
|
|
|
|
version 2, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
The full GNU General Public License is included in this distribution in
|
|
|
|
the file called "COPYING".
|
|
|
|
|
|
|
|
Contact Information:
|
|
|
|
e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
|
|
|
|
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
/* ethtool support for ixgbevf */
|
|
|
|
|
2011-10-22 03:38:18 +08:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2010-01-09 10:24:10 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-01-09 10:24:10 +08:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
|
|
|
|
#include "ixgbevf.h"
|
|
|
|
|
|
|
|
#define IXGBE_ALL_RAR_ENTRIES 16
|
|
|
|
|
|
|
|
struct ixgbe_stats {
|
|
|
|
char stat_string[ETH_GSTRING_LEN];
|
2013-09-25 16:03:09 +08:00
|
|
|
struct {
|
|
|
|
int sizeof_stat;
|
|
|
|
int stat_offset;
|
|
|
|
int base_stat_offset;
|
|
|
|
int saved_reset_offset;
|
|
|
|
};
|
2010-01-09 10:24:10 +08:00
|
|
|
};
|
|
|
|
|
2013-09-25 16:03:09 +08:00
|
|
|
#define IXGBEVF_STAT(m, b, r) { \
|
|
|
|
.sizeof_stat = FIELD_SIZEOF(struct ixgbevf_adapter, m), \
|
|
|
|
.stat_offset = offsetof(struct ixgbevf_adapter, m), \
|
|
|
|
.base_stat_offset = offsetof(struct ixgbevf_adapter, b), \
|
|
|
|
.saved_reset_offset = offsetof(struct ixgbevf_adapter, r) \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IXGBEVF_ZSTAT(m) { \
|
|
|
|
.sizeof_stat = FIELD_SIZEOF(struct ixgbevf_adapter, m), \
|
|
|
|
.stat_offset = offsetof(struct ixgbevf_adapter, m), \
|
|
|
|
.base_stat_offset = -1, \
|
|
|
|
.saved_reset_offset = -1 \
|
|
|
|
}
|
2012-01-19 06:13:32 +08:00
|
|
|
|
|
|
|
static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
|
2010-03-19 10:59:52 +08:00
|
|
|
{"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
|
|
|
|
stats.saved_reset_vfgprc)},
|
|
|
|
{"tx_packets", IXGBEVF_STAT(stats.vfgptc, stats.base_vfgptc,
|
|
|
|
stats.saved_reset_vfgptc)},
|
|
|
|
{"rx_bytes", IXGBEVF_STAT(stats.vfgorc, stats.base_vfgorc,
|
|
|
|
stats.saved_reset_vfgorc)},
|
|
|
|
{"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc,
|
|
|
|
stats.saved_reset_vfgotc)},
|
2013-09-25 16:03:09 +08:00
|
|
|
{"tx_busy", IXGBEVF_ZSTAT(tx_busy)},
|
2014-01-18 10:30:02 +08:00
|
|
|
{"tx_restart_queue", IXGBEVF_ZSTAT(restart_queue)},
|
|
|
|
{"tx_timeout_count", IXGBEVF_ZSTAT(tx_timeout_count)},
|
2010-03-19 10:59:52 +08:00
|
|
|
{"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc,
|
|
|
|
stats.saved_reset_vfmprc)},
|
2013-09-25 16:03:09 +08:00
|
|
|
{"rx_csum_offload_errors", IXGBEVF_ZSTAT(hw_csum_rx_error)},
|
2013-09-21 14:24:25 +08:00
|
|
|
#ifdef BP_EXTENDED_STATS
|
2013-09-25 16:03:09 +08:00
|
|
|
{"rx_bp_poll_yield", IXGBEVF_ZSTAT(bp_rx_yields)},
|
|
|
|
{"rx_bp_cleaned", IXGBEVF_ZSTAT(bp_rx_cleaned)},
|
|
|
|
{"rx_bp_misses", IXGBEVF_ZSTAT(bp_rx_missed)},
|
|
|
|
{"tx_bp_napi_yield", IXGBEVF_ZSTAT(bp_tx_yields)},
|
|
|
|
{"tx_bp_cleaned", IXGBEVF_ZSTAT(bp_tx_cleaned)},
|
|
|
|
{"tx_bp_misses", IXGBEVF_ZSTAT(bp_tx_missed)},
|
2013-09-21 14:24:25 +08:00
|
|
|
#endif
|
2010-01-09 10:24:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IXGBE_QUEUE_STATS_LEN 0
|
|
|
|
#define IXGBE_GLOBAL_STATS_LEN ARRAY_SIZE(ixgbe_gstrings_stats)
|
|
|
|
|
|
|
|
#define IXGBEVF_STATS_LEN (IXGBE_GLOBAL_STATS_LEN + IXGBE_QUEUE_STATS_LEN)
|
|
|
|
static const char ixgbe_gstrings_test[][ETH_GSTRING_LEN] = {
|
|
|
|
"Register test (offline)",
|
|
|
|
"Link test (on/offline)"
|
|
|
|
};
|
|
|
|
#define IXGBE_TEST_LEN (sizeof(ixgbe_gstrings_test) / ETH_GSTRING_LEN)
|
|
|
|
|
|
|
|
static int ixgbevf_get_settings(struct net_device *netdev,
|
|
|
|
struct ethtool_cmd *ecmd)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct ixgbe_hw *hw = &adapter->hw;
|
|
|
|
u32 link_speed = 0;
|
|
|
|
bool link_up;
|
|
|
|
|
|
|
|
ecmd->supported = SUPPORTED_10000baseT_Full;
|
|
|
|
ecmd->autoneg = AUTONEG_DISABLE;
|
|
|
|
ecmd->transceiver = XCVR_DUMMY1;
|
|
|
|
ecmd->port = -1;
|
|
|
|
|
2013-01-24 12:54:48 +08:00
|
|
|
hw->mac.get_link_status = 1;
|
2010-01-09 10:24:10 +08:00
|
|
|
hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
|
|
|
|
|
|
|
|
if (link_up) {
|
2012-04-10 09:56:37 +08:00
|
|
|
__u32 speed = SPEED_10000;
|
|
|
|
switch (link_speed) {
|
|
|
|
case IXGBE_LINK_SPEED_10GB_FULL:
|
|
|
|
speed = SPEED_10000;
|
|
|
|
break;
|
|
|
|
case IXGBE_LINK_SPEED_1GB_FULL:
|
|
|
|
speed = SPEED_1000;
|
|
|
|
break;
|
|
|
|
case IXGBE_LINK_SPEED_100_FULL:
|
|
|
|
speed = SPEED_100;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ethtool_cmd_speed_set(ecmd, speed);
|
2010-01-09 10:24:10 +08:00
|
|
|
ecmd->duplex = DUPLEX_FULL;
|
|
|
|
} else {
|
2011-04-28 02:32:40 +08:00
|
|
|
ethtool_cmd_speed_set(ecmd, -1);
|
2010-01-09 10:24:10 +08:00
|
|
|
ecmd->duplex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 ixgbevf_get_msglevel(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
return adapter->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_set_msglevel(struct net_device *netdev, u32 data)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
adapter->msg_enable = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IXGBE_GET_STAT(_A_, _R_) (_A_->stats._R_)
|
|
|
|
|
|
|
|
static int ixgbevf_get_regs_len(struct net_device *netdev)
|
|
|
|
{
|
2013-10-01 19:33:48 +08:00
|
|
|
#define IXGBE_REGS_LEN 45
|
|
|
|
return IXGBE_REGS_LEN * sizeof(u32);
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_get_regs(struct net_device *netdev,
|
|
|
|
struct ethtool_regs *regs,
|
|
|
|
void *p)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct ixgbe_hw *hw = &adapter->hw;
|
|
|
|
u32 *regs_buff = p;
|
|
|
|
u32 regs_len = ixgbevf_get_regs_len(netdev);
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
memset(p, 0, regs_len);
|
|
|
|
|
|
|
|
regs->version = (1 << 24) | hw->revision_id << 16 | hw->device_id;
|
|
|
|
|
|
|
|
/* General Registers */
|
|
|
|
regs_buff[0] = IXGBE_READ_REG(hw, IXGBE_VFCTRL);
|
|
|
|
regs_buff[1] = IXGBE_READ_REG(hw, IXGBE_VFSTATUS);
|
|
|
|
regs_buff[2] = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
|
|
|
|
regs_buff[3] = IXGBE_READ_REG(hw, IXGBE_VFRXMEMWRAP);
|
2011-03-05 16:02:18 +08:00
|
|
|
regs_buff[4] = IXGBE_READ_REG(hw, IXGBE_VFFRTIMER);
|
2010-01-09 10:24:10 +08:00
|
|
|
|
|
|
|
/* Interrupt */
|
|
|
|
/* don't read EICR because it can clear interrupt causes, instead
|
|
|
|
* read EICS which is a shadow but doesn't clear EICR */
|
|
|
|
regs_buff[5] = IXGBE_READ_REG(hw, IXGBE_VTEICS);
|
|
|
|
regs_buff[6] = IXGBE_READ_REG(hw, IXGBE_VTEICS);
|
|
|
|
regs_buff[7] = IXGBE_READ_REG(hw, IXGBE_VTEIMS);
|
|
|
|
regs_buff[8] = IXGBE_READ_REG(hw, IXGBE_VTEIMC);
|
|
|
|
regs_buff[9] = IXGBE_READ_REG(hw, IXGBE_VTEIAC);
|
|
|
|
regs_buff[10] = IXGBE_READ_REG(hw, IXGBE_VTEIAM);
|
|
|
|
regs_buff[11] = IXGBE_READ_REG(hw, IXGBE_VTEITR(0));
|
|
|
|
regs_buff[12] = IXGBE_READ_REG(hw, IXGBE_VTIVAR(0));
|
|
|
|
regs_buff[13] = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
|
|
|
|
|
|
|
|
/* Receive DMA */
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[14 + i] = IXGBE_READ_REG(hw, IXGBE_VFRDBAL(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[16 + i] = IXGBE_READ_REG(hw, IXGBE_VFRDBAH(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[18 + i] = IXGBE_READ_REG(hw, IXGBE_VFRDLEN(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[20 + i] = IXGBE_READ_REG(hw, IXGBE_VFRDH(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[22 + i] = IXGBE_READ_REG(hw, IXGBE_VFRDT(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[24 + i] = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[26 + i] = IXGBE_READ_REG(hw, IXGBE_VFSRRCTL(i));
|
|
|
|
|
|
|
|
/* Receive */
|
|
|
|
regs_buff[28] = IXGBE_READ_REG(hw, IXGBE_VFPSRTYPE);
|
|
|
|
|
|
|
|
/* Transmit */
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[29 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDBAL(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[31 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDBAH(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[33 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDLEN(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[35 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDH(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[37 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDT(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[39 + i] = IXGBE_READ_REG(hw, IXGBE_VFTXDCTL(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[41 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDWBAL(i));
|
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
regs_buff[43 + i] = IXGBE_READ_REG(hw, IXGBE_VFTDWBAH(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_get_drvinfo(struct net_device *netdev,
|
|
|
|
struct ethtool_drvinfo *drvinfo)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2011-11-21 18:54:05 +08:00
|
|
|
strlcpy(drvinfo->driver, ixgbevf_driver_name, sizeof(drvinfo->driver));
|
|
|
|
strlcpy(drvinfo->version, ixgbevf_driver_version,
|
|
|
|
sizeof(drvinfo->version));
|
|
|
|
strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
|
|
|
|
sizeof(drvinfo->bus_info));
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_get_ringparam(struct net_device *netdev,
|
|
|
|
struct ethtool_ringparam *ring)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
ring->rx_max_pending = IXGBEVF_MAX_RXD;
|
|
|
|
ring->tx_max_pending = IXGBEVF_MAX_TXD;
|
2012-07-19 08:18:05 +08:00
|
|
|
ring->rx_pending = adapter->rx_ring_count;
|
|
|
|
ring->tx_pending = adapter->tx_ring_count;
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_set_ringparam(struct net_device *netdev,
|
|
|
|
struct ethtool_ringparam *ring)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct ixgbevf_ring *tx_ring = NULL, *rx_ring = NULL;
|
|
|
|
u32 new_rx_count, new_tx_count;
|
2012-07-19 08:18:05 +08:00
|
|
|
int i, err = 0;
|
2010-01-09 10:24:10 +08:00
|
|
|
|
|
|
|
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
new_tx_count = max_t(u32, ring->tx_pending, IXGBEVF_MIN_TXD);
|
|
|
|
new_tx_count = min_t(u32, new_tx_count, IXGBEVF_MAX_TXD);
|
2010-01-09 10:24:10 +08:00
|
|
|
new_tx_count = ALIGN(new_tx_count, IXGBE_REQ_TX_DESCRIPTOR_MULTIPLE);
|
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
new_rx_count = max_t(u32, ring->rx_pending, IXGBEVF_MIN_RXD);
|
|
|
|
new_rx_count = min_t(u32, new_rx_count, IXGBEVF_MAX_RXD);
|
|
|
|
new_rx_count = ALIGN(new_rx_count, IXGBE_REQ_RX_DESCRIPTOR_MULTIPLE);
|
|
|
|
|
|
|
|
/* if nothing to do return success */
|
|
|
|
if ((new_tx_count == adapter->tx_ring_count) &&
|
|
|
|
(new_rx_count == adapter->rx_ring_count))
|
2010-01-09 10:24:10 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
while (test_and_set_bit(__IXGBEVF_RESETTING, &adapter->state))
|
2012-07-19 08:18:05 +08:00
|
|
|
usleep_range(1000, 2000);
|
2010-01-09 10:24:10 +08:00
|
|
|
|
2010-09-23 20:46:25 +08:00
|
|
|
if (!netif_running(adapter->netdev)) {
|
|
|
|
for (i = 0; i < adapter->num_tx_queues; i++)
|
2014-01-16 18:30:08 +08:00
|
|
|
adapter->tx_ring[i]->count = new_tx_count;
|
2010-09-23 20:46:25 +08:00
|
|
|
for (i = 0; i < adapter->num_rx_queues; i++)
|
2014-01-16 18:30:08 +08:00
|
|
|
adapter->rx_ring[i]->count = new_rx_count;
|
2010-09-23 20:46:25 +08:00
|
|
|
adapter->tx_ring_count = new_tx_count;
|
|
|
|
adapter->rx_ring_count = new_rx_count;
|
|
|
|
goto clear_reset;
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
if (new_tx_count != adapter->tx_ring_count) {
|
|
|
|
tx_ring = vmalloc(adapter->num_tx_queues * sizeof(*tx_ring));
|
|
|
|
if (!tx_ring) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto clear_reset;
|
|
|
|
}
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
for (i = 0; i < adapter->num_tx_queues; i++) {
|
|
|
|
/* clone ring and setup updated count */
|
2014-01-16 18:30:08 +08:00
|
|
|
tx_ring[i] = *adapter->tx_ring[i];
|
2012-07-19 08:18:05 +08:00
|
|
|
tx_ring[i].count = new_tx_count;
|
2014-01-18 10:29:59 +08:00
|
|
|
err = ixgbevf_setup_tx_resources(&tx_ring[i]);
|
|
|
|
if (err) {
|
|
|
|
while (i) {
|
|
|
|
i--;
|
|
|
|
ixgbevf_free_tx_resources(&tx_ring[i]);
|
|
|
|
}
|
2012-07-19 08:18:05 +08:00
|
|
|
|
2014-01-18 10:29:59 +08:00
|
|
|
vfree(tx_ring);
|
|
|
|
tx_ring = NULL;
|
2012-07-19 08:18:05 +08:00
|
|
|
|
2014-01-18 10:29:59 +08:00
|
|
|
goto clear_reset;
|
|
|
|
}
|
2010-09-23 20:46:25 +08:00
|
|
|
}
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
if (new_rx_count != adapter->rx_ring_count) {
|
|
|
|
rx_ring = vmalloc(adapter->num_rx_queues * sizeof(*rx_ring));
|
|
|
|
if (!rx_ring) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto clear_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < adapter->num_rx_queues; i++) {
|
|
|
|
/* clone ring and setup updated count */
|
2014-01-16 18:30:08 +08:00
|
|
|
rx_ring[i] = *adapter->rx_ring[i];
|
2012-07-19 08:18:05 +08:00
|
|
|
rx_ring[i].count = new_rx_count;
|
2014-01-18 10:29:59 +08:00
|
|
|
err = ixgbevf_setup_rx_resources(&rx_ring[i]);
|
|
|
|
if (err) {
|
|
|
|
while (i) {
|
|
|
|
i--;
|
|
|
|
ixgbevf_free_rx_resources(&rx_ring[i]);
|
|
|
|
}
|
2012-07-19 08:18:05 +08:00
|
|
|
|
2014-01-18 10:29:59 +08:00
|
|
|
vfree(rx_ring);
|
|
|
|
rx_ring = NULL;
|
2012-07-19 08:18:05 +08:00
|
|
|
|
2014-01-18 10:29:59 +08:00
|
|
|
goto clear_reset;
|
|
|
|
}
|
2010-09-23 20:46:25 +08:00
|
|
|
}
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
/* bring interface down to prepare for update */
|
|
|
|
ixgbevf_down(adapter);
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
/* Tx */
|
|
|
|
if (tx_ring) {
|
|
|
|
for (i = 0; i < adapter->num_tx_queues; i++) {
|
2014-01-18 10:29:59 +08:00
|
|
|
ixgbevf_free_tx_resources(adapter->tx_ring[i]);
|
2014-01-16 18:30:08 +08:00
|
|
|
*adapter->tx_ring[i] = tx_ring[i];
|
2012-07-19 08:18:05 +08:00
|
|
|
}
|
|
|
|
adapter->tx_ring_count = new_tx_count;
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
vfree(tx_ring);
|
|
|
|
tx_ring = NULL;
|
|
|
|
}
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
/* Rx */
|
|
|
|
if (rx_ring) {
|
|
|
|
for (i = 0; i < adapter->num_rx_queues; i++) {
|
2014-01-18 10:29:59 +08:00
|
|
|
ixgbevf_free_rx_resources(adapter->rx_ring[i]);
|
2014-01-16 18:30:08 +08:00
|
|
|
*adapter->rx_ring[i] = rx_ring[i];
|
2012-07-19 08:18:05 +08:00
|
|
|
}
|
|
|
|
adapter->rx_ring_count = new_rx_count;
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
vfree(rx_ring);
|
|
|
|
rx_ring = NULL;
|
|
|
|
}
|
2010-09-23 20:46:25 +08:00
|
|
|
|
2012-07-19 08:18:05 +08:00
|
|
|
/* restore interface using new values */
|
|
|
|
ixgbevf_up(adapter);
|
2010-01-09 10:24:10 +08:00
|
|
|
|
2010-09-23 20:46:25 +08:00
|
|
|
clear_reset:
|
2012-07-19 08:18:05 +08:00
|
|
|
/* free Tx resources if Rx error is encountered */
|
|
|
|
if (tx_ring) {
|
|
|
|
for (i = 0; i < adapter->num_tx_queues; i++)
|
2014-01-18 10:29:59 +08:00
|
|
|
ixgbevf_free_tx_resources(&tx_ring[i]);
|
2012-07-19 08:18:05 +08:00
|
|
|
vfree(tx_ring);
|
|
|
|
}
|
|
|
|
|
2010-01-09 10:24:10 +08:00
|
|
|
clear_bit(__IXGBEVF_RESETTING, &adapter->state);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_get_sset_count(struct net_device *dev, int stringset)
|
|
|
|
{
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
return IXGBE_TEST_LEN;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
return IXGBE_GLOBAL_STATS_LEN;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
|
|
|
|
struct ethtool_stats *stats, u64 *data)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
2013-09-25 16:03:09 +08:00
|
|
|
char *base = (char *) adapter;
|
2010-01-09 10:24:10 +08:00
|
|
|
int i;
|
2013-09-21 14:24:25 +08:00
|
|
|
#ifdef BP_EXTENDED_STATS
|
|
|
|
u64 rx_yields = 0, rx_cleaned = 0, rx_missed = 0,
|
|
|
|
tx_yields = 0, tx_cleaned = 0, tx_missed = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < adapter->num_rx_queues; i++) {
|
2014-01-18 10:30:00 +08:00
|
|
|
rx_yields += adapter->rx_ring[i]->stats.yields;
|
|
|
|
rx_cleaned += adapter->rx_ring[i]->stats.cleaned;
|
|
|
|
rx_yields += adapter->rx_ring[i]->stats.yields;
|
2013-09-21 14:24:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < adapter->num_tx_queues; i++) {
|
2014-01-18 10:30:00 +08:00
|
|
|
tx_yields += adapter->tx_ring[i]->stats.yields;
|
|
|
|
tx_cleaned += adapter->tx_ring[i]->stats.cleaned;
|
|
|
|
tx_yields += adapter->tx_ring[i]->stats.yields;
|
2013-09-21 14:24:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
adapter->bp_rx_yields = rx_yields;
|
|
|
|
adapter->bp_rx_cleaned = rx_cleaned;
|
|
|
|
adapter->bp_rx_missed = rx_missed;
|
|
|
|
|
|
|
|
adapter->bp_tx_yields = tx_yields;
|
|
|
|
adapter->bp_tx_cleaned = tx_cleaned;
|
|
|
|
adapter->bp_tx_missed = tx_missed;
|
|
|
|
#endif
|
2010-01-09 10:24:10 +08:00
|
|
|
|
|
|
|
ixgbevf_update_stats(adapter);
|
|
|
|
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
|
2013-09-25 16:03:09 +08:00
|
|
|
char *p = base + ixgbe_gstrings_stats[i].stat_offset;
|
|
|
|
char *b = base + ixgbe_gstrings_stats[i].base_stat_offset;
|
|
|
|
char *r = base + ixgbe_gstrings_stats[i].saved_reset_offset;
|
|
|
|
|
|
|
|
if (ixgbe_gstrings_stats[i].sizeof_stat == sizeof(u64)) {
|
|
|
|
if (ixgbe_gstrings_stats[i].base_stat_offset >= 0)
|
|
|
|
data[i] = *(u64 *)p - *(u64 *)b + *(u64 *)r;
|
|
|
|
else
|
|
|
|
data[i] = *(u64 *)p;
|
|
|
|
} else {
|
|
|
|
if (ixgbe_gstrings_stats[i].base_stat_offset >= 0)
|
|
|
|
data[i] = *(u32 *)p - *(u32 *)b + *(u32 *)r;
|
|
|
|
else
|
|
|
|
data[i] = *(u32 *)p;
|
|
|
|
}
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_get_strings(struct net_device *netdev, u32 stringset,
|
|
|
|
u8 *data)
|
|
|
|
{
|
|
|
|
char *p = (char *)data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch (stringset) {
|
|
|
|
case ETH_SS_TEST:
|
|
|
|
memcpy(data, *ixgbe_gstrings_test,
|
|
|
|
IXGBE_TEST_LEN * ETH_GSTRING_LEN);
|
|
|
|
break;
|
|
|
|
case ETH_SS_STATS:
|
|
|
|
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
|
|
|
|
memcpy(p, ixgbe_gstrings_stats[i].stat_string,
|
|
|
|
ETH_GSTRING_LEN);
|
|
|
|
p += ETH_GSTRING_LEN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_link_test(struct ixgbevf_adapter *adapter, u64 *data)
|
|
|
|
{
|
|
|
|
struct ixgbe_hw *hw = &adapter->hw;
|
|
|
|
bool link_up;
|
|
|
|
u32 link_speed = 0;
|
|
|
|
*data = 0;
|
|
|
|
|
|
|
|
hw->mac.ops.check_link(hw, &link_speed, &link_up, true);
|
|
|
|
if (!link_up)
|
|
|
|
*data = 1;
|
|
|
|
|
|
|
|
return *data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ethtool register test data */
|
|
|
|
struct ixgbevf_reg_test {
|
|
|
|
u16 reg;
|
|
|
|
u8 array_len;
|
|
|
|
u8 test_type;
|
|
|
|
u32 mask;
|
|
|
|
u32 write;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* In the hardware, registers are laid out either singly, in arrays
|
|
|
|
* spaced 0x40 bytes apart, or in contiguous tables. We assume
|
|
|
|
* most tests take place on arrays or single registers (handled
|
|
|
|
* as a single-element array) and special-case the tables.
|
|
|
|
* Table tests are always pattern tests.
|
|
|
|
*
|
|
|
|
* We also make provision for some required setup steps by specifying
|
|
|
|
* registers to be written without any read-back testing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PATTERN_TEST 1
|
|
|
|
#define SET_READ_TEST 2
|
|
|
|
#define WRITE_NO_TEST 3
|
|
|
|
#define TABLE32_TEST 4
|
|
|
|
#define TABLE64_TEST_LO 5
|
|
|
|
#define TABLE64_TEST_HI 6
|
|
|
|
|
|
|
|
/* default VF register test */
|
2010-12-02 03:59:50 +08:00
|
|
|
static const struct ixgbevf_reg_test reg_test_vf[] = {
|
2010-01-09 10:24:10 +08:00
|
|
|
{ IXGBE_VFRDBAL(0), 2, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFF80 },
|
|
|
|
{ IXGBE_VFRDBAH(0), 2, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
|
|
|
|
{ IXGBE_VFRDLEN(0), 2, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
|
|
|
|
{ IXGBE_VFRXDCTL(0), 2, WRITE_NO_TEST, 0, IXGBE_RXDCTL_ENABLE },
|
|
|
|
{ IXGBE_VFRDT(0), 2, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
|
|
|
|
{ IXGBE_VFRXDCTL(0), 2, WRITE_NO_TEST, 0, 0 },
|
|
|
|
{ IXGBE_VFTDBAL(0), 2, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
|
|
|
|
{ IXGBE_VFTDBAH(0), 2, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
|
|
|
|
{ IXGBE_VFTDLEN(0), 2, PATTERN_TEST, 0x000FFF80, 0x000FFF80 },
|
|
|
|
{ 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
2010-12-02 03:59:50 +08:00
|
|
|
static const u32 register_test_patterns[] = {
|
|
|
|
0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
|
|
|
|
};
|
|
|
|
|
2014-03-04 11:02:29 +08:00
|
|
|
static bool reg_pattern_test(struct ixgbevf_adapter *adapter, u64 *data,
|
|
|
|
int reg, u32 mask, u32 write)
|
|
|
|
{
|
|
|
|
u32 pat, val, before;
|
|
|
|
|
|
|
|
for (pat = 0; pat < ARRAY_SIZE(register_test_patterns); pat++) {
|
|
|
|
before = ixgbe_read_reg(&adapter->hw, reg);
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg,
|
|
|
|
register_test_patterns[pat] & write);
|
|
|
|
val = ixgbe_read_reg(&adapter->hw, reg);
|
|
|
|
if (val != (register_test_patterns[pat] & write & mask)) {
|
|
|
|
hw_dbg(&adapter->hw,
|
|
|
|
"pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
|
|
|
|
reg, val,
|
|
|
|
register_test_patterns[pat] & write & mask);
|
|
|
|
*data = reg;
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg, before);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg, before);
|
|
|
|
}
|
|
|
|
return false;
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
2014-03-04 11:02:29 +08:00
|
|
|
static bool reg_set_and_check(struct ixgbevf_adapter *adapter, u64 *data,
|
|
|
|
int reg, u32 mask, u32 write)
|
|
|
|
{
|
|
|
|
u32 val, before;
|
|
|
|
|
|
|
|
before = ixgbe_read_reg(&adapter->hw, reg);
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg, write & mask);
|
|
|
|
val = ixgbe_read_reg(&adapter->hw, reg);
|
|
|
|
if ((write & mask) != (val & mask)) {
|
|
|
|
pr_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
|
|
|
|
reg, (val & mask), write & mask);
|
|
|
|
*data = reg;
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg, before);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
ixgbe_write_reg(&adapter->hw, reg, before);
|
|
|
|
return false;
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_reg_test(struct ixgbevf_adapter *adapter, u64 *data)
|
|
|
|
{
|
2010-12-02 03:59:50 +08:00
|
|
|
const struct ixgbevf_reg_test *test;
|
2010-01-09 10:24:10 +08:00
|
|
|
u32 i;
|
|
|
|
|
|
|
|
test = reg_test_vf;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform the register test, looping through the test table
|
|
|
|
* until we either fail or reach the null entry.
|
|
|
|
*/
|
|
|
|
while (test->reg) {
|
|
|
|
for (i = 0; i < test->array_len; i++) {
|
2014-03-04 11:02:29 +08:00
|
|
|
bool b = false;
|
|
|
|
|
2010-01-09 10:24:10 +08:00
|
|
|
switch (test->test_type) {
|
|
|
|
case PATTERN_TEST:
|
2014-03-04 11:02:29 +08:00
|
|
|
b = reg_pattern_test(adapter, data,
|
|
|
|
test->reg + (i * 0x40),
|
|
|
|
test->mask,
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
case SET_READ_TEST:
|
2014-03-04 11:02:29 +08:00
|
|
|
b = reg_set_and_check(adapter, data,
|
|
|
|
test->reg + (i * 0x40),
|
|
|
|
test->mask,
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
case WRITE_NO_TEST:
|
2014-03-04 11:02:29 +08:00
|
|
|
ixgbe_write_reg(&adapter->hw,
|
|
|
|
test->reg + (i * 0x40),
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
case TABLE32_TEST:
|
2014-03-04 11:02:29 +08:00
|
|
|
b = reg_pattern_test(adapter, data,
|
|
|
|
test->reg + (i * 4),
|
|
|
|
test->mask,
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
case TABLE64_TEST_LO:
|
2014-03-04 11:02:29 +08:00
|
|
|
b = reg_pattern_test(adapter, data,
|
|
|
|
test->reg + (i * 8),
|
|
|
|
test->mask,
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
case TABLE64_TEST_HI:
|
2014-03-04 11:02:29 +08:00
|
|
|
b = reg_pattern_test(adapter, data,
|
|
|
|
test->reg + 4 + (i * 8),
|
|
|
|
test->mask,
|
|
|
|
test->write);
|
2010-01-09 10:24:10 +08:00
|
|
|
break;
|
|
|
|
}
|
2014-03-04 11:02:29 +08:00
|
|
|
if (b)
|
|
|
|
return 1;
|
2010-01-09 10:24:10 +08:00
|
|
|
}
|
|
|
|
test++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*data = 0;
|
|
|
|
return *data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ixgbevf_diag_test(struct net_device *netdev,
|
|
|
|
struct ethtool_test *eth_test, u64 *data)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
bool if_running = netif_running(netdev);
|
|
|
|
|
|
|
|
set_bit(__IXGBEVF_TESTING, &adapter->state);
|
|
|
|
if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
|
|
|
|
/* Offline tests */
|
|
|
|
|
|
|
|
hw_dbg(&adapter->hw, "offline testing starting\n");
|
|
|
|
|
|
|
|
/* Link test performed before hardware reset so autoneg doesn't
|
|
|
|
* interfere with test result */
|
|
|
|
if (ixgbevf_link_test(adapter, &data[1]))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
|
|
|
|
if (if_running)
|
|
|
|
/* indicate we're in test mode */
|
|
|
|
dev_close(netdev);
|
|
|
|
else
|
|
|
|
ixgbevf_reset(adapter);
|
|
|
|
|
|
|
|
hw_dbg(&adapter->hw, "register testing starting\n");
|
|
|
|
if (ixgbevf_reg_test(adapter, &data[0]))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
|
|
|
|
ixgbevf_reset(adapter);
|
|
|
|
|
|
|
|
clear_bit(__IXGBEVF_TESTING, &adapter->state);
|
|
|
|
if (if_running)
|
|
|
|
dev_open(netdev);
|
|
|
|
} else {
|
|
|
|
hw_dbg(&adapter->hw, "online testing starting\n");
|
|
|
|
/* Online tests */
|
|
|
|
if (ixgbevf_link_test(adapter, &data[1]))
|
|
|
|
eth_test->flags |= ETH_TEST_FL_FAILED;
|
|
|
|
|
|
|
|
/* Online tests aren't run; pass by default */
|
|
|
|
data[0] = 0;
|
|
|
|
|
|
|
|
clear_bit(__IXGBEVF_TESTING, &adapter->state);
|
|
|
|
}
|
|
|
|
msleep_interruptible(4 * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_nway_reset(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
2012-05-11 16:32:19 +08:00
|
|
|
if (netif_running(netdev))
|
|
|
|
ixgbevf_reinit_locked(adapter);
|
2010-01-09 10:24:10 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-22 14:19:18 +08:00
|
|
|
static int ixgbevf_get_coalesce(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *ec)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
|
|
|
|
/* only valid if in constant ITR mode */
|
|
|
|
if (adapter->rx_itr_setting <= 1)
|
|
|
|
ec->rx_coalesce_usecs = adapter->rx_itr_setting;
|
|
|
|
else
|
|
|
|
ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2;
|
|
|
|
|
|
|
|
/* if in mixed tx/rx queues per vector mode, report only rx settings */
|
|
|
|
if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* only valid if in constant ITR mode */
|
|
|
|
if (adapter->tx_itr_setting <= 1)
|
|
|
|
ec->tx_coalesce_usecs = adapter->tx_itr_setting;
|
|
|
|
else
|
|
|
|
ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ixgbevf_set_coalesce(struct net_device *netdev,
|
|
|
|
struct ethtool_coalesce *ec)
|
|
|
|
{
|
|
|
|
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
|
|
|
|
struct ixgbevf_q_vector *q_vector;
|
|
|
|
int num_vectors, i;
|
|
|
|
u16 tx_itr_param, rx_itr_param;
|
|
|
|
|
|
|
|
/* don't accept tx specific changes if we've got mixed RxTx vectors */
|
|
|
|
if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count
|
|
|
|
&& ec->tx_coalesce_usecs)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
|
|
|
|
if ((ec->rx_coalesce_usecs > (IXGBE_MAX_EITR >> 2)) ||
|
|
|
|
(ec->tx_coalesce_usecs > (IXGBE_MAX_EITR >> 2)))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (ec->rx_coalesce_usecs > 1)
|
|
|
|
adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2;
|
|
|
|
else
|
|
|
|
adapter->rx_itr_setting = ec->rx_coalesce_usecs;
|
|
|
|
|
|
|
|
if (adapter->rx_itr_setting == 1)
|
|
|
|
rx_itr_param = IXGBE_20K_ITR;
|
|
|
|
else
|
|
|
|
rx_itr_param = adapter->rx_itr_setting;
|
|
|
|
|
|
|
|
|
|
|
|
if (ec->tx_coalesce_usecs > 1)
|
|
|
|
adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2;
|
|
|
|
else
|
|
|
|
adapter->tx_itr_setting = ec->tx_coalesce_usecs;
|
|
|
|
|
|
|
|
if (adapter->tx_itr_setting == 1)
|
|
|
|
tx_itr_param = IXGBE_10K_ITR;
|
|
|
|
else
|
|
|
|
tx_itr_param = adapter->tx_itr_setting;
|
|
|
|
|
|
|
|
num_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
|
|
|
|
|
|
|
|
for (i = 0; i < num_vectors; i++) {
|
|
|
|
q_vector = adapter->q_vector[i];
|
|
|
|
if (q_vector->tx.count && !q_vector->rx.count)
|
|
|
|
/* tx only */
|
|
|
|
q_vector->itr = tx_itr_param;
|
|
|
|
else
|
|
|
|
/* rx only or mixed */
|
|
|
|
q_vector->itr = rx_itr_param;
|
|
|
|
ixgbevf_write_eitr(q_vector);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-19 06:13:32 +08:00
|
|
|
static const struct ethtool_ops ixgbevf_ethtool_ops = {
|
2010-01-09 10:24:10 +08:00
|
|
|
.get_settings = ixgbevf_get_settings,
|
|
|
|
.get_drvinfo = ixgbevf_get_drvinfo,
|
|
|
|
.get_regs_len = ixgbevf_get_regs_len,
|
|
|
|
.get_regs = ixgbevf_get_regs,
|
|
|
|
.nway_reset = ixgbevf_nway_reset,
|
|
|
|
.get_link = ethtool_op_get_link,
|
|
|
|
.get_ringparam = ixgbevf_get_ringparam,
|
|
|
|
.set_ringparam = ixgbevf_set_ringparam,
|
|
|
|
.get_msglevel = ixgbevf_get_msglevel,
|
|
|
|
.set_msglevel = ixgbevf_set_msglevel,
|
|
|
|
.self_test = ixgbevf_diag_test,
|
|
|
|
.get_sset_count = ixgbevf_get_sset_count,
|
|
|
|
.get_strings = ixgbevf_get_strings,
|
|
|
|
.get_ethtool_stats = ixgbevf_get_ethtool_stats,
|
2013-10-22 14:19:18 +08:00
|
|
|
.get_coalesce = ixgbevf_get_coalesce,
|
|
|
|
.set_coalesce = ixgbevf_set_coalesce,
|
2010-01-09 10:24:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void ixgbevf_set_ethtool_ops(struct net_device *netdev)
|
|
|
|
{
|
|
|
|
SET_ETHTOOL_OPS(netdev, &ixgbevf_ethtool_ops);
|
|
|
|
}
|