Skip to content

Commit

Permalink
net: nmlan_cs: Use net_device_stats from struct net_device
Browse files Browse the repository at this point in the history
Instead of using a private copy of struct net_device_stats in struct
_mace_private, use stats from struct net_device.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tobias Klauser authored and David S. Miller committed Apr 7, 2017
1 parent 8bf66b9 commit 71ef3cb
Showing 1 changed file with 24 additions and 25 deletions.
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

0 comments on commit 71ef3cb

Please sign in to comment.