dect
/
linux-2.6
Archived
13
0
Fork 0

enic: fixes for review items from Ben Hutchings

Fixes for review items from Ben Hutchings:
 - use netdev->net_stats rather than private net_stats
 - use ethtool op .get_sset_count rather than .get_stats_count
 - err out if setting Tx/Rx csum or TSO using ethtool and setting is
   not enabled for device.
 - pass in jiffies + constant to round_jiffies
 - return err if new MTU is out-of-bounds

Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
This commit is contained in:
Scott Feldman 2008-09-24 11:23:32 -07:00 committed by Jeff Garzik
parent d9c3c57ffc
commit 25f0a061d9
2 changed files with 37 additions and 26 deletions

View File

@ -75,7 +75,6 @@ struct enic {
struct vnic_enet_config config;
struct vnic_dev_bar bar0;
struct vnic_dev *vdev;
struct net_device_stats net_stats;
struct timer_list notify_timer;
struct work_struct reset;
struct msix_entry msix_entry[ENIC_MSIX_MAX];

View File

@ -43,7 +43,6 @@
#include "enic.h"
#define ENIC_NOTIFY_TIMER_PERIOD (2 * HZ)
#define ENIC_JUMBO_FIRST_BUF_SIZE 256
/* Supported devices */
static struct pci_device_id enic_id_table[] = {
@ -167,9 +166,14 @@ static void enic_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
}
}
static int enic_get_stats_count(struct net_device *netdev)
static int enic_get_sset_count(struct net_device *netdev, int sset)
{
return enic_n_tx_stats + enic_n_rx_stats;
switch (sset) {
case ETH_SS_STATS:
return enic_n_tx_stats + enic_n_rx_stats;
default:
return -EOPNOTSUPP;
}
}
static void enic_get_ethtool_stats(struct net_device *netdev,
@ -199,8 +203,10 @@ static int enic_set_rx_csum(struct net_device *netdev, u32 data)
{
struct enic *enic = netdev_priv(netdev);
enic->csum_rx_enabled =
(data && ENIC_SETTING(enic, RXCSUM)) ? 1 : 0;
if (data && !ENIC_SETTING(enic, RXCSUM))
return -EINVAL;
enic->csum_rx_enabled = !!data;
return 0;
}
@ -209,7 +215,10 @@ static int enic_set_tx_csum(struct net_device *netdev, u32 data)
{
struct enic *enic = netdev_priv(netdev);
if (data && ENIC_SETTING(enic, TXCSUM))
if (data && !ENIC_SETTING(enic, TXCSUM))
return -EINVAL;
if (data)
netdev->features |= NETIF_F_HW_CSUM;
else
netdev->features &= ~NETIF_F_HW_CSUM;
@ -221,7 +230,10 @@ static int enic_set_tso(struct net_device *netdev, u32 data)
{
struct enic *enic = netdev_priv(netdev);
if (data && ENIC_SETTING(enic, TSO))
if (data && !ENIC_SETTING(enic, TSO))
return -EINVAL;
if (data)
netdev->features |=
NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN;
else
@ -250,7 +262,7 @@ static struct ethtool_ops enic_ethtool_ops = {
.set_msglevel = enic_set_msglevel,
.get_link = ethtool_op_get_link,
.get_strings = enic_get_strings,
.get_stats_count = enic_get_stats_count,
.get_sset_count = enic_get_sset_count,
.get_ethtool_stats = enic_get_ethtool_stats,
.get_rx_csum = enic_get_rx_csum,
.set_rx_csum = enic_set_rx_csum,
@ -652,25 +664,26 @@ static int enic_hard_start_xmit(struct sk_buff *skb, struct net_device *netdev)
static struct net_device_stats *enic_get_stats(struct net_device *netdev)
{
struct enic *enic = netdev_priv(netdev);
struct net_device_stats *net_stats = &netdev->stats;
struct vnic_stats *stats;
spin_lock(&enic->devcmd_lock);
vnic_dev_stats_dump(enic->vdev, &stats);
spin_unlock(&enic->devcmd_lock);
enic->net_stats.tx_packets = stats->tx.tx_frames_ok;
enic->net_stats.tx_bytes = stats->tx.tx_bytes_ok;
enic->net_stats.tx_errors = stats->tx.tx_errors;
enic->net_stats.tx_dropped = stats->tx.tx_drops;
net_stats->tx_packets = stats->tx.tx_frames_ok;
net_stats->tx_bytes = stats->tx.tx_bytes_ok;
net_stats->tx_errors = stats->tx.tx_errors;
net_stats->tx_dropped = stats->tx.tx_drops;
enic->net_stats.rx_packets = stats->rx.rx_frames_ok;
enic->net_stats.rx_bytes = stats->rx.rx_bytes_ok;
enic->net_stats.rx_errors = stats->rx.rx_errors;
enic->net_stats.multicast = stats->rx.rx_multicast_frames_ok;
enic->net_stats.rx_crc_errors = stats->rx.rx_crc_errors;
enic->net_stats.rx_dropped = stats->rx.rx_no_bufs;
net_stats->rx_packets = stats->rx.rx_frames_ok;
net_stats->rx_bytes = stats->rx.rx_bytes_ok;
net_stats->rx_errors = stats->rx.rx_errors;
net_stats->multicast = stats->rx.rx_multicast_frames_ok;
net_stats->rx_crc_errors = stats->rx.rx_crc_errors;
net_stats->rx_dropped = stats->rx.rx_no_bufs;
return &enic->net_stats;
return net_stats;
}
static void enic_reset_mcaddrs(struct enic *enic)
@ -1109,7 +1122,8 @@ static void enic_notify_timer(unsigned long data)
enic_notify_check(enic);
mod_timer(&enic->notify_timer, round_jiffies(ENIC_NOTIFY_TIMER_PERIOD));
mod_timer(&enic->notify_timer,
round_jiffies(jiffies + ENIC_NOTIFY_TIMER_PERIOD));
}
static void enic_free_intr(struct enic *enic)
@ -1313,14 +1327,12 @@ static int enic_change_mtu(struct net_device *netdev, int new_mtu)
struct enic *enic = netdev_priv(netdev);
int running = netif_running(netdev);
if (new_mtu < ENIC_MIN_MTU || new_mtu > ENIC_MAX_MTU)
return -EINVAL;
if (running)
enic_stop(netdev);
if (new_mtu < ENIC_MIN_MTU)
new_mtu = ENIC_MIN_MTU;
if (new_mtu > ENIC_MAX_MTU)
new_mtu = ENIC_MAX_MTU;
netdev->mtu = new_mtu;
if (netdev->mtu > enic->port_mtu)