Skip to content

Commit e2bbb96

Browse files
committed
Merge branch 'net_device_stats'
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 <[email protected]>
2 parents 7db4c0d + 82d8293 commit e2bbb96

File tree

23 files changed

+156
-212
lines changed

23 files changed

+156
-212
lines changed

drivers/net/ethernet/3com/typhoon.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ struct typhoon {
283283
spinlock_t command_lock ____cacheline_aligned;
284284
struct basic_ring cmdRing;
285285
struct basic_ring respRing;
286-
struct net_device_stats stats;
287286
struct net_device_stats stats_saved;
288287
struct typhoon_shared * shared;
289288
dma_addr_t shared_dma;
@@ -898,7 +897,7 @@ typhoon_set_rx_mode(struct net_device *dev)
898897
static int
899898
typhoon_do_get_stats(struct typhoon *tp)
900899
{
901-
struct net_device_stats *stats = &tp->stats;
900+
struct net_device_stats *stats = &tp->dev->stats;
902901
struct net_device_stats *saved = &tp->stats_saved;
903902
struct cmd_desc xp_cmd;
904903
struct resp_desc xp_resp[7];
@@ -951,7 +950,7 @@ static struct net_device_stats *
951950
typhoon_get_stats(struct net_device *dev)
952951
{
953952
struct typhoon *tp = netdev_priv(dev);
954-
struct net_device_stats *stats = &tp->stats;
953+
struct net_device_stats *stats = &tp->dev->stats;
955954
struct net_device_stats *saved = &tp->stats_saved;
956955

957956
smp_rmb();
@@ -1991,7 +1990,7 @@ typhoon_stop_runtime(struct typhoon *tp, int wait_type)
19911990
tp->card_state = Sleeping;
19921991
smp_wmb();
19931992
typhoon_do_get_stats(tp);
1994-
memcpy(&tp->stats_saved, &tp->stats, sizeof(struct net_device_stats));
1993+
memcpy(&tp->stats_saved, &tp->dev->stats, sizeof(struct net_device_stats));
19951994

19961995
INIT_COMMAND_NO_RESPONSE(&xp_cmd, TYPHOON_CMD_HALT);
19971996
typhoon_issue_command(tp, 1, &xp_cmd, 0, NULL);

drivers/net/ethernet/amd/nmclan_cs.c

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ typedef struct _mace_statistics {
359359

360360
typedef struct _mace_private {
361361
struct pcmcia_device *p_dev;
362-
struct net_device_stats linux_stats; /* Linux statistics counters */
363362
mace_statistics mace_stats; /* MACE chip statistics counters */
364363

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

882-
lp->linux_stats.tx_bytes += skb->len;
881+
dev->stats.tx_bytes += skb->len;
883882
lp->tx_free_frames--;
884883

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

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

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

10171016
} /* if (xmtfs & MACE_XMTFS_XMTSV) */
10181017

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

10791078
if (rx_status & MACE_RCVFS_RCVSTS) { /* Error, update stats. */
1080-
lp->linux_stats.rx_errors++;
1079+
dev->stats.rx_errors++;
10811080
if (rx_status & MACE_RCVFS_OFLO) {
10821081
lp->mace_stats.oflo++;
10831082
}
@@ -1114,14 +1113,14 @@ static int mace_rx(struct net_device *dev, unsigned char RxCnt)
11141113

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

1117-
lp->linux_stats.rx_packets++;
1118-
lp->linux_stats.rx_bytes += pkt_len;
1116+
dev->stats.rx_packets++;
1117+
dev->stats.rx_bytes += pkt_len;
11191118
outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
11201119
continue;
11211120
} else {
11221121
pr_debug("%s: couldn't allocate a sk_buff of size"
11231122
" %d.\n", dev->name, pkt_len);
1124-
lp->linux_stats.rx_dropped++;
1123+
dev->stats.rx_dropped++;
11251124
}
11261125
}
11271126
outb(0xFF, ioaddr + AM2150_RCV_NEXT); /* skip to next frame */
@@ -1231,36 +1230,36 @@ static void update_stats(unsigned int ioaddr, struct net_device *dev)
12311230
lp->mace_stats.rntpc += mace_read(lp, ioaddr, MACE_RNTPC);
12321231
lp->mace_stats.mpc += mace_read(lp, ioaddr, MACE_MPC);
12331232
/* At this point, mace_stats is fully updated for this call.
1234-
We may now update the linux_stats. */
1233+
We may now update the netdev stats. */
12351234

1236-
/* The MACE has no equivalent for linux_stats field which are commented
1235+
/* The MACE has no equivalent for netdev stats field which are commented
12371236
out. */
12381237

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

12471246
/* detailed rx_errors: */
1248-
lp->linux_stats.rx_length_errors =
1247+
dev->stats.rx_length_errors =
12491248
lp->mace_stats.rntpco * 256 + lp->mace_stats.rntpc;
1250-
/* lp->linux_stats.rx_over_errors */
1251-
lp->linux_stats.rx_crc_errors = lp->mace_stats.fcs;
1252-
lp->linux_stats.rx_frame_errors = lp->mace_stats.fram;
1253-
lp->linux_stats.rx_fifo_errors = lp->mace_stats.oflo;
1254-
lp->linux_stats.rx_missed_errors =
1249+
/* dev->stats.rx_over_errors */
1250+
dev->stats.rx_crc_errors = lp->mace_stats.fcs;
1251+
dev->stats.rx_frame_errors = lp->mace_stats.fram;
1252+
dev->stats.rx_fifo_errors = lp->mace_stats.oflo;
1253+
dev->stats.rx_missed_errors =
12551254
lp->mace_stats.mpco * 256 + lp->mace_stats.mpc;
12561255

12571256
/* detailed tx_errors */
1258-
lp->linux_stats.tx_aborted_errors = lp->mace_stats.rtry;
1259-
lp->linux_stats.tx_carrier_errors = lp->mace_stats.lcar;
1257+
dev->stats.tx_aborted_errors = lp->mace_stats.rtry;
1258+
dev->stats.tx_carrier_errors = lp->mace_stats.lcar;
12601259
/* LCAR usually results from bad cabling. */
1261-
lp->linux_stats.tx_fifo_errors = lp->mace_stats.uflo;
1262-
lp->linux_stats.tx_heartbeat_errors = lp->mace_stats.cerr;
1263-
/* lp->linux_stats.tx_window_errors; */
1260+
dev->stats.tx_fifo_errors = lp->mace_stats.uflo;
1261+
dev->stats.tx_heartbeat_errors = lp->mace_stats.cerr;
1262+
/* dev->stats.tx_window_errors; */
12641263
} /* update_stats */
12651264

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

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

1280-
return &lp->linux_stats;
1279+
return &dev->stats;
12811280
} /* net_device_stats */
12821281

12831282
/* ----------------------------------------------------------------------------

drivers/net/ethernet/cadence/macb.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ static void macb_tx_error_task(struct work_struct *work)
684684
netdev_vdbg(bp->dev, "txerr skb %u (data %p) TX complete\n",
685685
macb_tx_ring_wrap(bp, tail),
686686
skb->data);
687-
bp->stats.tx_packets++;
688-
bp->stats.tx_bytes += skb->len;
687+
bp->dev->stats.tx_packets++;
688+
bp->dev->stats.tx_bytes += skb->len;
689689
}
690690
} else {
691691
/* "Buffers exhausted mid-frame" errors may only happen
@@ -778,8 +778,8 @@ static void macb_tx_interrupt(struct macb_queue *queue)
778778
netdev_vdbg(bp->dev, "skb %u (data %p) TX complete\n",
779779
macb_tx_ring_wrap(bp, tail),
780780
skb->data);
781-
bp->stats.tx_packets++;
782-
bp->stats.tx_bytes += skb->len;
781+
bp->dev->stats.tx_packets++;
782+
bp->dev->stats.tx_bytes += skb->len;
783783
}
784784

785785
/* Now we can safely release resources */
@@ -911,14 +911,14 @@ static int gem_rx(struct macb *bp, int budget)
911911
if (!(ctrl & MACB_BIT(RX_SOF) && ctrl & MACB_BIT(RX_EOF))) {
912912
netdev_err(bp->dev,
913913
"not whole frame pointed by descriptor\n");
914-
bp->stats.rx_dropped++;
914+
bp->dev->stats.rx_dropped++;
915915
break;
916916
}
917917
skb = bp->rx_skbuff[entry];
918918
if (unlikely(!skb)) {
919919
netdev_err(bp->dev,
920920
"inconsistent Rx descriptor chain\n");
921-
bp->stats.rx_dropped++;
921+
bp->dev->stats.rx_dropped++;
922922
break;
923923
}
924924
/* now everything is ready for receiving packet */
@@ -938,8 +938,8 @@ static int gem_rx(struct macb *bp, int budget)
938938
GEM_BFEXT(RX_CSUM, ctrl) & GEM_RX_CSUM_CHECKED_MASK)
939939
skb->ip_summed = CHECKSUM_UNNECESSARY;
940940

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

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

1033-
bp->stats.rx_packets++;
1034-
bp->stats.rx_bytes += skb->len;
1033+
bp->dev->stats.rx_packets++;
1034+
bp->dev->stats.rx_bytes += skb->len;
10351035
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
10361036
skb->len, skb->csum);
10371037
netif_receive_skb(skb);
@@ -2210,7 +2210,7 @@ static void gem_update_stats(struct macb *bp)
22102210
static struct net_device_stats *gem_get_stats(struct macb *bp)
22112211
{
22122212
struct gem_stats *hwstat = &bp->hw_stats.gem;
2213-
struct net_device_stats *nstat = &bp->stats;
2213+
struct net_device_stats *nstat = &bp->dev->stats;
22142214

22152215
gem_update_stats(bp);
22162216

@@ -2281,7 +2281,7 @@ static void gem_get_ethtool_strings(struct net_device *dev, u32 sset, u8 *p)
22812281
static struct net_device_stats *macb_get_stats(struct net_device *dev)
22822282
{
22832283
struct macb *bp = netdev_priv(dev);
2284-
struct net_device_stats *nstat = &bp->stats;
2284+
struct net_device_stats *nstat = &bp->dev->stats;
22852285
struct macb_stats *hwstat = &bp->hw_stats.macb;
22862286

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

29952995
skb->protocol = eth_type_trans(skb, dev);
2996-
lp->stats.rx_packets++;
2997-
lp->stats.rx_bytes += pktlen;
2996+
dev->stats.rx_packets++;
2997+
dev->stats.rx_bytes += pktlen;
29982998
netif_rx(skb);
29992999
} else {
3000-
lp->stats.rx_dropped++;
3000+
dev->stats.rx_dropped++;
30013001
}
30023002

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

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

30413041
if (lp->skb) {
30423042
dev_kfree_skb_irq(lp->skb);
30433043
lp->skb = NULL;
30443044
dma_unmap_single(NULL, lp->skb_physaddr,
30453045
lp->skb_length, DMA_TO_DEVICE);
3046-
lp->stats.tx_packets++;
3047-
lp->stats.tx_bytes += lp->skb_length;
3046+
dev->stats.tx_packets++;
3047+
dev->stats.tx_bytes += lp->skb_length;
30483048
}
30493049
netif_wake_queue(dev);
30503050
}

drivers/net/ethernet/cadence/macb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,6 @@ struct macb {
919919
struct clk *rx_clk;
920920
struct net_device *dev;
921921
struct napi_struct napi;
922-
struct net_device_stats stats;
923922
union {
924923
struct macb_stats macb;
925924
struct gem_stats gem;

drivers/net/ethernet/chelsio/cxgb/common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ struct port_info {
223223
struct cmac *mac;
224224
struct cphy *phy;
225225
struct link_config link_config;
226-
struct net_device_stats netstats;
227226
};
228227

229228
struct sge;

drivers/net/ethernet/chelsio/cxgb/cxgb2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static struct net_device_stats *t1_get_stats(struct net_device *dev)
296296
{
297297
struct adapter *adapter = dev->ml_priv;
298298
struct port_info *p = &adapter->port[dev->if_port];
299-
struct net_device_stats *ns = &p->netstats;
299+
struct net_device_stats *ns = &dev->stats;
300300
const struct cmac_statistics *pstats;
301301

302302
/* Do a full update of the MAC stats */

drivers/net/ethernet/chelsio/cxgb3/adapter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct port_info {
7272
struct cphy phy;
7373
struct cmac mac;
7474
struct link_config link_config;
75-
struct net_device_stats netstats;
7675
int activity;
7776
__be32 iscsi_ipv4addr;
7877
struct iscsi_config iscsic;

drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ static struct net_device_stats *cxgb_get_stats(struct net_device *dev)
14891489
{
14901490
struct port_info *pi = netdev_priv(dev);
14911491
struct adapter *adapter = pi->adapter;
1492-
struct net_device_stats *ns = &pi->netstats;
1492+
struct net_device_stats *ns = &dev->stats;
14931493
const struct mac_stats *pstats;
14941494

14951495
spin_lock(&adapter->stats_lock);

0 commit comments

Comments
 (0)