Skip to content

Commit

Permalink
Merge branch 'net_device_stats'
Browse files Browse the repository at this point in the history
Tobias Klauser says:

====================
Use net_device_stats from struct net_device

Along the lines of previous patches, switch (almost) all remaining net
drivers to use net_device_stats from net_device instead of including a
copy of it in their netdev_priv struct.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Apr 7, 2017
2 parents 7db4c0d + 82d8293 commit e2bbb96
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 212 deletions.
7 changes: 3 additions & 4 deletions drivers/net/ethernet/3com/typhoon.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ struct typhoon {
spinlock_t command_lock ____cacheline_aligned;
struct basic_ring cmdRing;
struct basic_ring respRing;
struct net_device_stats stats;
struct net_device_stats stats_saved;
struct typhoon_shared * shared;
dma_addr_t shared_dma;
Expand Down Expand Up @@ -898,7 +897,7 @@ typhoon_set_rx_mode(struct net_device *dev)
static int
typhoon_do_get_stats(struct typhoon *tp)
{
struct net_device_stats *stats = &tp->stats;
struct net_device_stats *stats = &tp->dev->stats;
struct net_device_stats *saved = &tp->stats_saved;
struct cmd_desc xp_cmd;
struct resp_desc xp_resp[7];
Expand Down Expand Up @@ -951,7 +950,7 @@ static struct net_device_stats *
typhoon_get_stats(struct net_device *dev)
{
struct typhoon *tp = netdev_priv(dev);
struct net_device_stats *stats = &tp->stats;
struct net_device_stats *stats = &tp->dev->stats;
struct net_device_stats *saved = &tp->stats_saved;

smp_rmb();
Expand Down Expand Up @@ -1991,7 +1990,7 @@ typhoon_stop_runtime(struct typhoon *tp, int wait_type)
tp->card_state = Sleeping;
smp_wmb();
typhoon_do_get_stats(tp);
memcpy(&tp->stats_saved, &tp->stats, sizeof(struct net_device_stats));
memcpy(&tp->stats_saved, &tp->dev->stats, sizeof(struct net_device_stats));

INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_HALT);
typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);
Expand Down
49 changes: 24 additions & 25 deletions drivers/net/ethernet/amd/nmclan_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ typedef struct _mace_statistics {

typedef struct _mace_private {
struct pcmcia_device *p_dev;
struct net_device_stats linux_stats; /* Linux statistics counters */
mace_statistics mace_stats; /* MACE chip statistics counters */

/* restore_multicast_list() state variables */
Expand Down Expand Up @@ -879,7 +878,7 @@ static netdev_tx_t mace_start_xmit(struct sk_buff *skb,
service a transmit interrupt while we are in here.
*/

lp->linux_stats.tx_bytes += skb->len;
dev->stats.tx_bytes += skb->len;
lp->tx_free_frames--;

/* WARNING: Write the _exact_ number of bytes written in the header! */
Expand Down Expand Up @@ -967,7 +966,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)

fifofc = inb(ioaddr + AM2150_MACE_BASE + MACE_FIFOFC);
if ((fifofc & MACE_FIFOFC_XMTFC)==0) {
lp->linux_stats.tx_errors++;
dev->stats.tx_errors++;
outb(0xFF, ioaddr + AM2150_XMT_SKIP);
}

Expand Down Expand Up @@ -1016,7 +1015,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)

} /* if (xmtfs & MACE_XMTFS_XMTSV) */

lp->linux_stats.tx_packets++;
dev->stats.tx_packets++;
lp->tx_free_frames++;
netif_wake_queue(dev);
} /* if (status & MACE_IR_XMTINT) */
Expand Down Expand Up @@ -1077,7 +1076,7 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt)
" 0x%X.\n", dev->name, rx_framecnt, rx_status);

if (rx_status & MACE_RCVFS_RCVSTS) { /* Error, update stats. */
lp->linux_stats.rx_errors++;
dev->stats.rx_errors++;
if (rx_status & MACE_RCVFS_OFLO) {
lp->mace_stats.oflo++;
}
Expand Down Expand Up @@ -1114,14 +1113,14 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt)

netif_rx(skb); /* Send the packet to the upper (protocol) layers. */

lp->linux_stats.rx_packets++;
lp->linux_stats.rx_bytes += pkt_len;
dev->stats.rx_packets++;
dev->stats.rx_bytes += pkt_len;
outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
continue;
} else {
pr_debug("%s: couldn't allocate a sk_buff of size"
" %d.\n", dev->name, pkt_len);
lp->linux_stats.rx_dropped++;
dev->stats.rx_dropped++;
}
}
outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
Expand Down Expand Up @@ -1231,36 +1230,36 @@ static void update_stats(unsigned int ioaddr, struct net_device *dev)
lp->mace_stats.rntpc += mace_read(lp, ioaddr, MACE_RNTPC);
lp->mace_stats.mpc += mace_read(lp, ioaddr, MACE_MPC);
/* At this point, mace_stats is fully updated for this call.
We may now update the linux_stats. */
We may now update the netdev stats. */

/* The MACE has no equivalent for linux_stats field which are commented
/* The MACE has no equivalent for netdev stats field which are commented
out. */

/* lp->linux_stats.multicast; */
lp->linux_stats.collisions =
/* dev->stats.multicast; */
dev->stats.collisions =
lp->mace_stats.rcvcco * 256 + lp->mace_stats.rcvcc;
/* Collision: The MACE may retry sending a packet 15 times
before giving up. The retry count is in XMTRC.
Does each retry constitute a collision?
If so, why doesn't the RCVCC record these collisions? */

/* detailed rx_errors: */
lp->linux_stats.rx_length_errors =
dev->stats.rx_length_errors =
lp->mace_stats.rntpco * 256 + lp->mace_stats.rntpc;
/* lp->linux_stats.rx_over_errors */
lp->linux_stats.rx_crc_errors = lp->mace_stats.fcs;
lp->linux_stats.rx_frame_errors = lp->mace_stats.fram;
lp->linux_stats.rx_fifo_errors = lp->mace_stats.oflo;
lp->linux_stats.rx_missed_errors =
/* dev->stats.rx_over_errors */
dev->stats.rx_crc_errors = lp->mace_stats.fcs;
dev->stats.rx_frame_errors = lp->mace_stats.fram;
dev->stats.rx_fifo_errors = lp->mace_stats.oflo;
dev->stats.rx_missed_errors =
lp->mace_stats.mpco * 256 + lp->mace_stats.mpc;

/* detailed tx_errors */
lp->linux_stats.tx_aborted_errors = lp->mace_stats.rtry;
lp->linux_stats.tx_carrier_errors = lp->mace_stats.lcar;
dev->stats.tx_aborted_errors = lp->mace_stats.rtry;
dev->stats.tx_carrier_errors = lp->mace_stats.lcar;
/* LCAR usually results from bad cabling. */
lp->linux_stats.tx_fifo_errors = lp->mace_stats.uflo;
lp->linux_stats.tx_heartbeat_errors = lp->mace_stats.cerr;
/* lp->linux_stats.tx_window_errors; */
dev->stats.tx_fifo_errors = lp->mace_stats.uflo;
dev->stats.tx_heartbeat_errors = lp->mace_stats.cerr;
/* dev->stats.tx_window_errors; */
} /* update_stats */

/* ----------------------------------------------------------------------------
Expand All @@ -1274,10 +1273,10 @@ static struct net_device_stats *mace_get_stats(struct net_device *dev)
update_stats(dev->base_addr, dev);

pr_debug("%s: updating the statistics.\n", dev->name);
pr_linux_stats(&lp->linux_stats);
pr_linux_stats(&dev->stats);
pr_mace_stats(&lp->mace_stats);

return &lp->linux_stats;
return &dev->stats;
} /* net_device_stats */

/* ----------------------------------------------------------------------------
Expand Down
40 changes: 20 additions & 20 deletions drivers/net/ethernet/cadence/macb.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ static void macb_tx_error_task(struct work_struct *work)
netdev_vdbg(bp->dev, "txerr skb %u (data %p) TX complete\n",
macb_tx_ring_wrap(bp, tail),
skb->data);
bp->stats.tx_packets++;
bp->stats.tx_bytes += skb->len;
bp->dev->stats.tx_packets++;
bp->dev->stats.tx_bytes += skb->len;
}
} else {
/* "Buffers exhausted mid-frame" errors may only happen
Expand Down Expand Up @@ -778,8 +778,8 @@ static void macb_tx_interrupt(struct macb_queue *queue)
netdev_vdbg(bp->dev, "skb %u (data %p) TX complete\n",
macb_tx_ring_wrap(bp, tail),
skb->data);
bp->stats.tx_packets++;
bp->stats.tx_bytes += skb->len;
bp->dev->stats.tx_packets++;
bp->dev->stats.tx_bytes += skb->len;
}

/* Now we can safely release resources */
Expand Down Expand Up @@ -911,14 +911,14 @@ static int gem_rx(struct macb *bp, int budget)
if (!(ctrl & MACB_BIT(RX_SOF) && ctrl & MACB_BIT(RX_EOF))) {
netdev_err(bp->dev,
"not whole frame pointed by descriptor\n");
bp->stats.rx_dropped++;
bp->dev->stats.rx_dropped++;
break;
}
skb = bp->rx_skbuff[entry];
if (unlikely(!skb)) {
netdev_err(bp->dev,
"inconsistent Rx descriptor chain\n");
bp->stats.rx_dropped++;
bp->dev->stats.rx_dropped++;
break;
}
/* now everything is ready for receiving packet */
Expand All @@ -938,8 +938,8 @@ static int gem_rx(struct macb *bp, int budget)
GEM_BFEXT(RX_CSUM, ctrl) & GEM_RX_CSUM_CHECKED_MASK)
skb->ip_summed = CHECKSUM_UNNECESSARY;

bp->stats.rx_packets++;
bp->stats.rx_bytes += skb->len;
bp->dev->stats.rx_packets++;
bp->dev->stats.rx_bytes += skb->len;

#if defined(DEBUG) && defined(VERBOSE_DEBUG)
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
Expand Down Expand Up @@ -984,7 +984,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
*/
skb = netdev_alloc_skb(bp->dev, len + NET_IP_ALIGN);
if (!skb) {
bp->stats.rx_dropped++;
bp->dev->stats.rx_dropped++;
for (frag = first_frag; ; frag++) {
desc = macb_rx_desc(bp, frag);
desc->addr &= ~MACB_BIT(RX_USED);
Expand Down Expand Up @@ -1030,8 +1030,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
__skb_pull(skb, NET_IP_ALIGN);
skb->protocol = eth_type_trans(skb, bp->dev);

bp->stats.rx_packets++;
bp->stats.rx_bytes += skb->len;
bp->dev->stats.rx_packets++;
bp->dev->stats.rx_bytes += skb->len;
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
skb->len, skb->csum);
netif_receive_skb(skb);
Expand Down Expand Up @@ -2210,7 +2210,7 @@ static void gem_update_stats(struct macb *bp)
static struct net_device_stats *gem_get_stats(struct macb *bp)
{
struct gem_stats *hwstat = &bp->hw_stats.gem;
struct net_device_stats *nstat = &bp->stats;
struct net_device_stats *nstat = &bp->dev->stats;

gem_update_stats(bp);

Expand Down Expand Up @@ -2281,7 +2281,7 @@ static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
static struct net_device_stats *macb_get_stats(struct net_device *dev)
{
struct macb *bp = netdev_priv(dev);
struct net_device_stats *nstat = &bp->stats;
struct net_device_stats *nstat = &bp->dev->stats;
struct macb_stats *hwstat = &bp->hw_stats.macb;

if (macb_is_gem(bp))
Expand Down Expand Up @@ -2993,15 +2993,15 @@ static void at91ether_rx(struct net_device *dev)
memcpy(skb_put(skb, pktlen), p_recv, pktlen);

skb->protocol = eth_type_trans(skb, dev);
lp->stats.rx_packets++;
lp->stats.rx_bytes += pktlen;
dev->stats.rx_packets++;
dev->stats.rx_bytes += pktlen;
netif_rx(skb);
} else {
lp->stats.rx_dropped++;
dev->stats.rx_dropped++;
}

if (desc->ctrl & MACB_BIT(RX_MHASH_MATCH))
lp->stats.multicast++;
dev->stats.multicast++;

/* reset ownership bit */
desc->addr &= ~MACB_BIT(RX_USED);
Expand Down Expand Up @@ -3036,15 +3036,15 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
if (intstatus & MACB_BIT(TCOMP)) {
/* The TCOM bit is set even if the transmission failed */
if (intstatus & (MACB_BIT(ISR_TUND) | MACB_BIT(ISR_RLE)))
lp->stats.tx_errors++;
dev->stats.tx_errors++;

if (lp->skb) {
dev_kfree_skb_irq(lp->skb);
lp->skb = NULL;
dma_unmap_single(NULL, lp->skb_physaddr,
lp->skb_length, DMA_TO_DEVICE);
lp->stats.tx_packets++;
lp->stats.tx_bytes += lp->skb_length;
dev->stats.tx_packets++;
dev->stats.tx_bytes += lp->skb_length;
}
netif_wake_queue(dev);
}
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/cadence/macb.h
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,6 @@ struct macb {
struct clk *rx_clk;
struct net_device *dev;
struct napi_struct napi;
struct net_device_stats stats;
union {
struct macb_stats macb;
struct gem_stats gem;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ struct port_info {
struct cmac *mac;
struct cphy *phy;
struct link_config link_config;
struct net_device_stats netstats;
};

struct sge;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb/cxgb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static struct net_device_stats *t1_get_stats(struct net_device *dev)
{
struct adapter *adapter = dev->ml_priv;
struct port_info *p = &adapter->port[dev->if_port];
struct net_device_stats *ns = &p->netstats;
struct net_device_stats *ns = &dev->stats;
const struct cmac_statistics *pstats;

/* Do a full update of the MAC stats */
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/chelsio/cxgb3/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ struct port_info {
struct cphy phy;
struct cmac mac;
struct link_config link_config;
struct net_device_stats netstats;
int activity;
__be32 iscsi_ipv4addr;
struct iscsi_config iscsic;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adapter = pi->adapter;
struct net_device_stats *ns = &pi->netstats;
struct net_device_stats *ns = &dev->stats;
const struct mac_stats *pstats;

spin_lock(&adapter->stats_lock);
Expand Down
Loading

0 comments on commit e2bbb96

Please sign in to comment.