cregit-Linux how code gets into the kernel

Release 4.7 drivers/net/vmxnet3/vmxnet3_ethtool.c

/*
 * Linux driver for VMware's vmxnet3 ethernet NIC.
 *
 * Copyright (C) 2008-2009, VMware, Inc. All Rights Reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; version 2 of the License and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 * NON INFRINGEMENT.  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".
 *
 * Maintained by: Shreyas Bhatewara <pv-drivers@vmware.com>
 *
 */


#include "vmxnet3_int.h"


struct vmxnet3_stat_desc {
	
char desc[ETH_GSTRING_LEN];
	
int  offset;
};


/* per tq stats maintained by the device */
static const struct vmxnet3_stat_desc

vmxnet3_tq_dev_stats[] = {
	/* description,         offset */
	{ "Tx Queue#",        0 },
	{ "  TSO pkts tx",	offsetof(struct UPT1_TxStats, TSOPktsTxOK) },
	{ "  TSO bytes tx",	offsetof(struct UPT1_TxStats, TSOBytesTxOK) },
	{ "  ucast pkts tx",	offsetof(struct UPT1_TxStats, ucastPktsTxOK) },
	{ "  ucast bytes tx",	offsetof(struct UPT1_TxStats, ucastBytesTxOK) },
	{ "  mcast pkts tx",	offsetof(struct UPT1_TxStats, mcastPktsTxOK) },
	{ "  mcast bytes tx",	offsetof(struct UPT1_TxStats, mcastBytesTxOK) },
	{ "  bcast pkts tx",	offsetof(struct UPT1_TxStats, bcastPktsTxOK) },
	{ "  bcast bytes tx",	offsetof(struct UPT1_TxStats, bcastBytesTxOK) },
	{ "  pkts tx err",	offsetof(struct UPT1_TxStats, pktsTxError) },
	{ "  pkts tx discard",	offsetof(struct UPT1_TxStats, pktsTxDiscard) },
};

/* per tq stats maintained by the driver */
static const struct vmxnet3_stat_desc

vmxnet3_tq_driver_stats[] = {
	/* description,         offset */
	{"  drv dropped tx total",	offsetof(struct vmxnet3_tq_driver_stats,
						 drop_total) },
	{ "     too many frags", offsetof(struct vmxnet3_tq_driver_stats,
					  drop_too_many_frags) },
	{ "     giant hdr",	offsetof(struct vmxnet3_tq_driver_stats,
					 drop_oversized_hdr) },
	{ "     hdr err",	offsetof(struct vmxnet3_tq_driver_stats,
					 drop_hdr_inspect_err) },
	{ "     tso",		offsetof(struct vmxnet3_tq_driver_stats,
					 drop_tso) },
	{ "  ring full",	offsetof(struct vmxnet3_tq_driver_stats,
					 tx_ring_full) },
	{ "  pkts linearized",	offsetof(struct vmxnet3_tq_driver_stats,
					 linearized) },
	{ "  hdr cloned",	offsetof(struct vmxnet3_tq_driver_stats,
					 copy_skb_header) },
	{ "  giant hdr",	offsetof(struct vmxnet3_tq_driver_stats,
					 oversized_hdr) },
};

/* per rq stats maintained by the device */
static const struct vmxnet3_stat_desc

vmxnet3_rq_dev_stats[] = {
	{ "Rx Queue#",        0 },
	{ "  LRO pkts rx",	offsetof(struct UPT1_RxStats, LROPktsRxOK) },
	{ "  LRO byte rx",	offsetof(struct UPT1_RxStats, LROBytesRxOK) },
	{ "  ucast pkts rx",	offsetof(struct UPT1_RxStats, ucastPktsRxOK) },
	{ "  ucast bytes rx",	offsetof(struct UPT1_RxStats, ucastBytesRxOK) },
	{ "  mcast pkts rx",	offsetof(struct UPT1_RxStats, mcastPktsRxOK) },
	{ "  mcast bytes rx",	offsetof(struct UPT1_RxStats, mcastBytesRxOK) },
	{ "  bcast pkts rx",	offsetof(struct UPT1_RxStats, bcastPktsRxOK) },
	{ "  bcast bytes rx",	offsetof(struct UPT1_RxStats, bcastBytesRxOK) },
	{ "  pkts rx OOB",	offsetof(struct UPT1_RxStats, pktsRxOutOfBuf) },
	{ "  pkts rx err",	offsetof(struct UPT1_RxStats, pktsRxError) },
};

/* per rq stats maintained by the driver */
static const struct vmxnet3_stat_desc

vmxnet3_rq_driver_stats[] = {
	/* description,         offset */
	{ "  drv dropped rx total", offsetof(struct vmxnet3_rq_driver_stats,
					     drop_total) },
	{ "     err",		offsetof(struct vmxnet3_rq_driver_stats,
					 drop_err) },
	{ "     fcs",		offsetof(struct vmxnet3_rq_driver_stats,
					 drop_fcs) },
	{ "  rx buf alloc fail", offsetof(struct vmxnet3_rq_driver_stats,
					  rx_buf_alloc_failure) },
};

/* global stats maintained by the driver */
static const struct vmxnet3_stat_desc

vmxnet3_global_stats[] = {
	/* description,         offset */
	{ "tx timeout count",	offsetof(struct vmxnet3_adapter,
					 tx_timeout_count) }
};



struct rtnl_link_stats64 * vmxnet3_get_stats64(struct net_device *netdev, struct rtnl_link_stats64 *stats) { struct vmxnet3_adapter *adapter; struct vmxnet3_tq_driver_stats *drvTxStats; struct vmxnet3_rq_driver_stats *drvRxStats; struct UPT1_TxStats *devTxStats; struct UPT1_RxStats *devRxStats; unsigned long flags; int i; adapter = netdev_priv(netdev); /* Collect the dev stats into the shared area */ spin_lock_irqsave(&adapter->cmd_lock, flags); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); spin_unlock_irqrestore(&adapter->cmd_lock, flags); for (i = 0; i < adapter->num_tx_queues; i++) { devTxStats = &adapter->tqd_start[i].stats; drvTxStats = &adapter->tx_queue[i].stats; stats->tx_packets += devTxStats->ucastPktsTxOK + devTxStats->mcastPktsTxOK + devTxStats->bcastPktsTxOK; stats->tx_bytes += devTxStats->ucastBytesTxOK + devTxStats->mcastBytesTxOK + devTxStats->bcastBytesTxOK; stats->tx_errors += devTxStats->pktsTxError; stats->tx_dropped += drvTxStats->drop_total; } for (i = 0; i < adapter->num_rx_queues; i++) { devRxStats = &adapter->rqd_start[i].stats; drvRxStats = &adapter->rx_queue[i].stats; stats->rx_packets += devRxStats->ucastPktsRxOK + devRxStats->mcastPktsRxOK + devRxStats->bcastPktsRxOK; stats->rx_bytes += devRxStats->ucastBytesRxOK + devRxStats->mcastBytesRxOK + devRxStats->bcastBytesRxOK; stats->rx_errors += devRxStats->pktsRxError; stats->rx_dropped += drvRxStats->drop_total; stats->multicast += devRxStats->mcastPktsRxOK; } return stats; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara25893.82%375.00%
stephen hemmingerstephen hemminger176.18%125.00%
Total275100.00%4100.00%


static int vmxnet3_get_sset_count(struct net_device *netdev, int sset) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); switch (sset) { case ETH_SS_STATS: return (ARRAY_SIZE(vmxnet3_tq_dev_stats) + ARRAY_SIZE(vmxnet3_tq_driver_stats)) * adapter->num_tx_queues + (ARRAY_SIZE(vmxnet3_rq_dev_stats) + ARRAY_SIZE(vmxnet3_rq_driver_stats)) * adapter->num_rx_queues + ARRAY_SIZE(vmxnet3_global_stats); default: return -EOPNOTSUPP; } }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara76100.00%2100.00%
Total76100.00%2100.00%

/* This is a version 2 of the vmxnet3 ethtool_regs which goes hand in hand with * the version 2 of the vmxnet3 support for ethtool(8) --register-dump. * Therefore, if any registers are added, removed or modified, then a version * bump and a corresponding change in the vmxnet3 support for ethtool(8) * --register-dump would be required. */
static int vmxnet3_get_regs_len(struct net_device *netdev) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); return ((9 /* BAR1 registers */ + (1 + adapter->intr.num_intrs) + (1 + adapter->num_tx_queues * 17 /* Tx queue registers */) + (1 + adapter->num_rx_queues * 23 /* Rx queue registers */)) * sizeof(u32)); }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara3959.09%266.67%
shrikrishna khareshrikrishna khare2740.91%133.33%
Total66100.00%3100.00%


static void vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver)); strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT, sizeof(drvinfo->version)); strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), sizeof(drvinfo->bus_info)); }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara7392.41%150.00%
jiri pirkojiri pirko67.59%150.00%
Total79100.00%2100.00%


static void vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); if (stringset == ETH_SS_STATS) { int i, j; for (j = 0; j < adapter->num_tx_queues; j++) { for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) { memcpy(buf, vmxnet3_tq_dev_stats[i].desc, ETH_GSTRING_LEN); buf += ETH_GSTRING_LEN; } for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) { memcpy(buf, vmxnet3_tq_driver_stats[i].desc, ETH_GSTRING_LEN); buf += ETH_GSTRING_LEN; } } for (j = 0; j < adapter->num_rx_queues; j++) { for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) { memcpy(buf, vmxnet3_rq_dev_stats[i].desc, ETH_GSTRING_LEN); buf += ETH_GSTRING_LEN; } for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) { memcpy(buf, vmxnet3_rq_driver_stats[i].desc, ETH_GSTRING_LEN); buf += ETH_GSTRING_LEN; } } for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) { memcpy(buf, vmxnet3_global_stats[i].desc, ETH_GSTRING_LEN); buf += ETH_GSTRING_LEN; } } }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara255100.00%2100.00%
Total255100.00%2100.00%


int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); unsigned long flags; netdev_features_t changed = features ^ netdev->features; if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_CTAG_RX)) { if (features & NETIF_F_RXCSUM) adapter->shared->devRead.misc.uptFeatures |= UPT1_F_RXCSUM; else adapter->shared->devRead.misc.uptFeatures &= ~UPT1_F_RXCSUM; /* update hardware LRO capability accordingly */ if (features & NETIF_F_LRO) adapter->shared->devRead.misc.uptFeatures |= UPT1_F_LRO; else adapter->shared->devRead.misc.uptFeatures &= ~UPT1_F_LRO; if (features & NETIF_F_HW_VLAN_CTAG_RX) adapter->shared->devRead.misc.uptFeatures |= UPT1_F_RXVLAN; else adapter->shared->devRead.misc.uptFeatures &= ~UPT1_F_RXVLAN; spin_lock_irqsave(&adapter->cmd_lock, flags); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_FEATURE); spin_unlock_irqrestore(&adapter->cmd_lock, flags); } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara9351.96%333.33%
michal miroslawmichal miroslaw4826.82%222.22%
jesse grossjesse gross3217.88%111.11%
stanislaw gruszkastanislaw gruszka31.68%111.11%
patrick mchardypatrick mchardy21.12%111.11%
stephen hemmingerstephen hemminger10.56%111.11%
Total179100.00%9100.00%


static void vmxnet3_get_ethtool_stats(struct net_device *netdev, struct ethtool_stats *stats, u64 *buf) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); unsigned long flags; u8 *base; int i; int j = 0; spin_lock_irqsave(&adapter->cmd_lock, flags); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS); spin_unlock_irqrestore(&adapter->cmd_lock, flags); /* this does assume each counter is 64-bit wide */ for (j = 0; j < adapter->num_tx_queues; j++) { base = (u8 *)&adapter->tqd_start[j].stats; *buf++ = (u64)j; for (i = 1; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) *buf++ = *(u64 *)(base + vmxnet3_tq_dev_stats[i].offset); base = (u8 *)&adapter->tx_queue[j].stats; for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++) *buf++ = *(u64 *)(base + vmxnet3_tq_driver_stats[i].offset); } for (j = 0; j < adapter->num_rx_queues; j++) { base = (u8 *)&adapter->rqd_start[j].stats; *buf++ = (u64) j; for (i = 1; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) *buf++ = *(u64 *)(base + vmxnet3_rq_dev_stats[i].offset); base = (u8 *)&adapter->rx_queue[j].stats; for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++) *buf++ = *(u64 *)(base + vmxnet3_rq_driver_stats[i].offset); } base = (u8 *)adapter; for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) *buf++ = *(u64 *)(base + vmxnet3_global_stats[i].offset); }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara37999.74%480.00%
shrikrishna khareshrikrishna khare10.26%120.00%
Total380100.00%5100.00%

/* This is a version 2 of the vmxnet3 ethtool_regs which goes hand in hand with * the version 2 of the vmxnet3 support for ethtool(8) --register-dump. * Therefore, if any registers are added, removed or modified, then a version * bump and a corresponding change in the vmxnet3 support for ethtool(8) * --register-dump would be required. */
static void vmxnet3_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); u32 *buf = p; int i = 0, j = 0; memset(p, 0, vmxnet3_get_regs_len(netdev)); regs->version = 2; /* Update vmxnet3_get_regs_len if we want to dump more registers */ buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_UVRS); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_DSAL); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_DSAH); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACL); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACH); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ICR); buf[j++] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ECR); buf[j++] = adapter->intr.num_intrs; for (i = 0; i < adapter->intr.num_intrs; i++) { buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_IMR + i * VMXNET3_REG_ALIGN); } buf[j++] = adapter->num_tx_queues; for (i = 0; i < adapter->num_tx_queues; i++) { struct vmxnet3_tx_queue *tq = &adapter->tx_queue[i]; buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_TXPROD + i * VMXNET3_REG_ALIGN); buf[j++] = VMXNET3_GET_ADDR_LO(tq->tx_ring.basePA); buf[j++] = VMXNET3_GET_ADDR_HI(tq->tx_ring.basePA); buf[j++] = tq->tx_ring.size; buf[j++] = tq->tx_ring.next2fill; buf[j++] = tq->tx_ring.next2comp; buf[j++] = tq->tx_ring.gen; buf[j++] = VMXNET3_GET_ADDR_LO(tq->data_ring.basePA); buf[j++] = VMXNET3_GET_ADDR_HI(tq->data_ring.basePA); buf[j++] = tq->data_ring.size; /* transmit data ring buffer size */ buf[j++] = VMXNET3_HDR_COPY_SIZE; buf[j++] = VMXNET3_GET_ADDR_LO(tq->comp_ring.basePA); buf[j++] = VMXNET3_GET_ADDR_HI(tq->comp_ring.basePA); buf[j++] = tq->comp_ring.size; buf[j++] = tq->comp_ring.next2proc; buf[j++] = tq->comp_ring.gen; buf[j++] = tq->stopped; } buf[j++] = adapter->num_rx_queues; for (i = 0; i < adapter->num_rx_queues; i++) { struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_RXPROD + i * VMXNET3_REG_ALIGN); buf[j++] = VMXNET3_READ_BAR0_REG(adapter, VMXNET3_REG_RXPROD2 + i * VMXNET3_REG_ALIGN); buf[j++] = VMXNET3_GET_ADDR_LO(rq->rx_ring[0].basePA); buf[j++] = VMXNET3_GET_ADDR_HI(rq->rx_ring[0].basePA); buf[j++] = rq->rx_ring[0].size; buf[j++] = rq->rx_ring[0].next2fill; buf[j++] = rq->rx_ring[0].next2comp; buf[j++] = rq->rx_ring[0].gen; buf[j++] = VMXNET3_GET_ADDR_LO(rq->rx_ring[1].basePA); buf[j++] = VMXNET3_GET_ADDR_HI(rq->rx_ring[1].basePA); buf[j++] = rq->rx_ring[1].size; buf[j++] = rq->rx_ring[1].next2fill; buf[j++] = rq->rx_ring[1].next2comp; buf[j++] = rq->rx_ring[1].gen; /* receive data ring */ buf[j++] = 0; buf[j++] = 0; buf[j++] = 0; buf[j++] = 0; buf[j++] = VMXNET3_GET_ADDR_LO(rq->comp_ring.basePA); buf[j++] = VMXNET3_GET_ADDR_HI(rq->comp_ring.basePA); buf[j++] = rq->comp_ring.size; buf[j++] = rq->comp_ring.next2proc; buf[j++] = rq->comp_ring.gen; } }

Contributors

PersonTokensPropCommitsCommitProp
shrikrishna khareshrikrishna khare51960.63%125.00%
shreyas bhatewarashreyas bhatewara33739.37%375.00%
Total856100.00%4100.00%


static void vmxnet3_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); wol->supported = WAKE_UCAST | WAKE_ARP | WAKE_MAGIC; wol->wolopts = adapter->wol; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara44100.00%1100.00%
Total44100.00%1100.00%


static int vmxnet3_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); if (wol->wolopts & (WAKE_PHY | WAKE_MCAST | WAKE_BCAST | WAKE_MAGICSECURE)) { return -EOPNOTSUPP; } adapter->wol = wol->wolopts; device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara73100.00%1100.00%
Total73100.00%1100.00%


static int vmxnet3_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); ecmd->supported = SUPPORTED_10000baseT_Full | SUPPORTED_1000baseT_Full | SUPPORTED_TP; ecmd->advertising = ADVERTISED_TP; ecmd->port = PORT_TP; ecmd->transceiver = XCVR_INTERNAL; if (adapter->link_speed) { ethtool_cmd_speed_set(ecmd, adapter->link_speed); ecmd->duplex = DUPLEX_FULL; } else { ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); ecmd->duplex = DUPLEX_UNKNOWN; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara8689.58%133.33%
david decotignydavid decotigny88.33%133.33%
jiri pirkojiri pirko22.08%133.33%
Total96100.00%3100.00%


static void vmxnet3_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *param) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); param->rx_max_pending = VMXNET3_RX_RING_MAX_SIZE; param->tx_max_pending = VMXNET3_TX_RING_MAX_SIZE; param->rx_mini_max_pending = 0; param->rx_jumbo_max_pending = VMXNET3_RX_RING2_MAX_SIZE; param->rx_pending = adapter->rx_ring_size; param->tx_pending = adapter->tx_ring_size; param->rx_mini_pending = 0; param->rx_jumbo_pending = adapter->rx_ring2_size; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara7492.50%250.00%
shrikrishna khareshrikrishna khare45.00%125.00%
neil hormanneil horman22.50%125.00%
Total80100.00%4100.00%


static int vmxnet3_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *param) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); u32 new_tx_ring_size, new_rx_ring_size, new_rx_ring2_size; u32 sz; int err = 0; if (param->tx_pending == 0 || param->tx_pending > VMXNET3_TX_RING_MAX_SIZE) return -EINVAL; if (param->rx_pending == 0 || param->rx_pending > VMXNET3_RX_RING_MAX_SIZE) return -EINVAL; if (param->rx_jumbo_pending == 0 || param->rx_jumbo_pending > VMXNET3_RX_RING2_MAX_SIZE) return -EINVAL; /* if adapter not yet initialized, do nothing */ if (adapter->rx_buf_per_pkt == 0) { netdev_err(netdev, "adapter not completely initialized, " "ring size cannot be changed yet\n"); return -EOPNOTSUPP; } /* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */ new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) & ~VMXNET3_RING_SIZE_MASK; new_tx_ring_size = min_t(u32, new_tx_ring_size, VMXNET3_TX_RING_MAX_SIZE); if (new_tx_ring_size > VMXNET3_TX_RING_MAX_SIZE || (new_tx_ring_size % VMXNET3_RING_SIZE_ALIGN) != 0) return -EINVAL; /* ring0 has to be a multiple of * rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN */ sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN; new_rx_ring_size = (param->rx_pending + sz - 1) / sz * sz; new_rx_ring_size = min_t(u32, new_rx_ring_size, VMXNET3_RX_RING_MAX_SIZE / sz * sz); if (new_rx_ring_size > VMXNET3_RX_RING_MAX_SIZE || (new_rx_ring_size % sz) != 0) return -EINVAL; /* ring2 has to be a multiple of VMXNET3_RING_SIZE_ALIGN */ new_rx_ring2_size = (param->rx_jumbo_pending + VMXNET3_RING_SIZE_MASK) & ~VMXNET3_RING_SIZE_MASK; new_rx_ring2_size = min_t(u32, new_rx_ring2_size, VMXNET3_RX_RING2_MAX_SIZE); if (new_tx_ring_size == adapter->tx_ring_size && new_rx_ring_size == adapter->rx_ring_size && new_rx_ring2_size == adapter->rx_ring2_size) { return 0; } /* * Reset_work may be in the middle of resetting the device, wait for its * completion. */ while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) msleep(1); if (netif_running(netdev)) { vmxnet3_quiesce_dev(adapter); vmxnet3_reset_dev(adapter); /* recreate the rx queue and the tx queue based on the * new sizes */ vmxnet3_tq_destroy_all(adapter); vmxnet3_rq_destroy_all(adapter); err = vmxnet3_create_queues(adapter, new_tx_ring_size, new_rx_ring_size, new_rx_ring2_size); if (err) { /* failed, most likely because of OOM, try default * size */ netdev_err(netdev, "failed to apply new sizes, " "try the default ones\n"); new_rx_ring_size = VMXNET3_DEF_RX_RING_SIZE; new_rx_ring2_size = VMXNET3_DEF_RX_RING2_SIZE; new_tx_ring_size = VMXNET3_DEF_TX_RING_SIZE; err = vmxnet3_create_queues(adapter, new_tx_ring_size, new_rx_ring_size, new_rx_ring2_size); if (err) { netdev_err(netdev, "failed to create queues " "with default sizes. Closing it\n"); goto out; } } err = vmxnet3_activate_dev(adapter); if (err) netdev_err(netdev, "failed to re-activate, error %d." " Closing it\n", err); } adapter->tx_ring_size = new_tx_ring_size; adapter->rx_ring_size = new_rx_ring_size; adapter->rx_ring2_size = new_rx_ring2_size; out: clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); if (err) vmxnet3_force_close(adapter); return err; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara32872.89%233.33%
shrikrishna khareshrikrishna khare6514.44%116.67%
bhavesh davdabhavesh davda235.11%116.67%
neil hormanneil horman224.89%116.67%
stephen hemmingerstephen hemminger122.67%116.67%
Total450100.00%6100.00%


static int vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info, u32 *rules) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); switch (info->cmd) { case ETHTOOL_GRXRINGS: info->data = adapter->num_rx_queues; return 0; } return -EOPNOTSUPP; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara5598.21%150.00%
ben hutchingsben hutchings11.79%150.00%
Total56100.00%2100.00%

#ifdef VMXNET3_RSS
static u32 vmxnet3_get_rss_indir_size(struct net_device *netdev) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); struct UPT1_RSSConf *rssConf = adapter->rss_conf; return rssConf->indTableSize; }

Contributors

PersonTokensPropCommitsCommitProp
ben hutchingsben hutchings3497.14%150.00%
shreyas bhatewarashreyas bhatewara12.86%150.00%
Total35100.00%2100.00%


static int vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 *key, u8 *hfunc) { struct vmxnet3_adapter *adapter = netdev_priv(netdev); struct UPT1_RSSConf *rssConf = adapter->rss_conf; unsigned int n = rssConf->indTableSize; if (hfunc) *hfunc = ETH_RSS_HASH_TOP; if (!p) return 0; while (n--) p[n] = rssConf->indTable[n]; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara5866.67%125.00%
eyal perryeyal perry2124.14%125.00%
ben hutchingsben hutchings89.20%250.00%
Total87100.00%4100.00%


static int vmxnet3_set_rss(struct net_device *netdev, const u32 *p, const u8 *key, const u8 hfunc) { unsigned int i; unsigned long flags; struct vmxnet3_adapter *adapter = netdev_priv(netdev); struct UPT1_RSSConf *rssConf = adapter->rss_conf; /* We do not allow change in unsupported parameters */ if (key || (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)) return -EOPNOTSUPP; if (!p) return 0; for (i = 0; i < rssConf->indTableSize; i++) rssConf->indTable[i] = p[i]; spin_lock_irqsave(&adapter->cmd_lock, flags); VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_UPDATE_RSSIDT); spin_unlock_irqrestore(&adapter->cmd_lock, flags); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara10072.46%240.00%
eyal perryeyal perry3122.46%120.00%
ben hutchingsben hutchings75.07%240.00%
Total138100.00%5100.00%

#endif static const struct ethtool_ops vmxnet3_ethtool_ops = { .get_settings = vmxnet3_get_settings, .get_drvinfo = vmxnet3_get_drvinfo, .get_regs_len = vmxnet3_get_regs_len, .get_regs = vmxnet3_get_regs, .get_wol = vmxnet3_get_wol, .set_wol = vmxnet3_set_wol, .get_link = ethtool_op_get_link, .get_strings = vmxnet3_get_strings, .get_sset_count = vmxnet3_get_sset_count, .get_ethtool_stats = vmxnet3_get_ethtool_stats, .get_ringparam = vmxnet3_get_ringparam, .set_ringparam = vmxnet3_set_ringparam, .get_rxnfc = vmxnet3_get_rxnfc, #ifdef VMXNET3_RSS .get_rxfh_indir_size = vmxnet3_get_rss_indir_size, .get_rxfh = vmxnet3_get_rss, .set_rxfh = vmxnet3_set_rss, #endif };
void vmxnet3_set_ethtool_ops(struct net_device *netdev) { netdev->ethtool_ops = &vmxnet3_ethtool_ops; }

Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara1482.35%150.00%
wilfried klaebewilfried klaebe317.65%150.00%
Total17100.00%2100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
shreyas bhatewarashreyas bhatewara287775.69%517.86%
shrikrishna khareshrikrishna khare61816.26%310.71%
ben hutchingsben hutchings591.55%310.71%
eyal perryeyal perry521.37%13.57%
michal miroslawmichal miroslaw481.26%27.14%
jesse grossjesse gross320.84%13.57%
stephen hemmingerstephen hemminger320.84%414.29%
neil hormanneil horman240.63%13.57%
bhavesh davdabhavesh davda230.61%13.57%
scott j. goldmanscott j. goldman120.32%13.57%
david decotignydavid decotigny80.21%13.57%
jiri pirkojiri pirko80.21%27.14%
stanislaw gruszkastanislaw gruszka30.08%13.57%
wilfried klaebewilfried klaebe30.08%13.57%
patrick mchardypatrick mchardy20.05%13.57%
Total3801100.00%28100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}