Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: Remove usage of net_device last_rx member

The network stack no longer uses the last_rx member of struct net_device
since the bonding driver switched to use its own private last_rx in
commit 9f242738376d ("bonding: use last_arp_rx in slave_last_rx()").

However, some drivers still (ab)use the field for their own purposes and
some driver just update it without actually using it.

Previously, there was an accompanying comment for the last_rx member
added in commit 4dc89133f49b ("net: add a comment on netdev->last_rx")
which asked drivers not to update is, unless really needed. However,
this commend was removed in commit f8ff080dacec ("bonding: remove
useless updating of slave->dev->last_rx"), so some drivers added later
on still did update last_rx.

Remove all usage of last_rx and switch three drivers (sky2, atp and
smc91c92_cs) which actually read and write it to use their own private
copy in netdev_priv.

Compile-tested with allyesconfig and allmodconfig on x86 and arm.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jay Vosburgh <j.vosburgh@gmail.com>
Cc: Veaceslav Falico <vfalico@gmail.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Mirko Lindner <mlindner@marvell.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Jay Vosburgh <jay.vosburgh@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Tobias Klauser and committed by
David S. Miller
4a7c9726 9520ed8f

+22 -46
-1
arch/m68k/emu/nfeth.c
··· 124 124 125 125 skb->protocol = eth_type_trans(skb, dev); 126 126 netif_rx(skb); 127 - dev->last_rx = jiffies; 128 127 dev->stats.rx_packets++; 129 128 dev->stats.rx_bytes += pktlen; 130 129
-1
drivers/net/ethernet/cavium/liquidio/lio_main.c
··· 2360 2360 if (packet_was_received) { 2361 2361 droq->stats.rx_bytes_received += len; 2362 2362 droq->stats.rx_pkts_received++; 2363 - netdev->last_rx = jiffies; 2364 2363 } else { 2365 2364 droq->stats.rx_dropped++; 2366 2365 netif_info(lio, rx_err, lio->netdev,
-1
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
··· 1571 1571 if (packet_was_received) { 1572 1572 droq->stats.rx_bytes_received += len; 1573 1573 droq->stats.rx_pkts_received++; 1574 - netdev->last_rx = jiffies; 1575 1574 } else { 1576 1575 droq->stats.rx_dropped++; 1577 1576 netif_info(lio, rx_err, lio->netdev,
-1
drivers/net/ethernet/hisilicon/hns/hns_enet.c
··· 797 797 798 798 skb->protocol = eth_type_trans(skb, ndev); 799 799 (void)napi_gro_receive(&ring_data->napi, skb); 800 - ndev->last_rx = jiffies; 801 800 } 802 801 803 802 static int hns_desc_unused(struct hnae_ring *ring)
+3 -3
drivers/net/ethernet/intel/e1000e/netdev.c
··· 240 240 /* Print netdevice Info */ 241 241 if (netdev) { 242 242 dev_info(&adapter->pdev->dev, "Net device Info\n"); 243 - pr_info("Device Name state trans_start last_rx\n"); 244 - pr_info("%-15s %016lX %016lX %016lX\n", netdev->name, 245 - netdev->state, dev_trans_start(netdev), netdev->last_rx); 243 + pr_info("Device Name state trans_start\n"); 244 + pr_info("%-15s %016lX %016lX\n", netdev->name, 245 + netdev->state, dev_trans_start(netdev)); 246 246 } 247 247 248 248 /* Print Registers */
+3 -3
drivers/net/ethernet/intel/igb/igb_main.c
··· 383 383 /* Print netdevice Info */ 384 384 if (netdev) { 385 385 dev_info(&adapter->pdev->dev, "Net device Info\n"); 386 - pr_info("Device Name state trans_start last_rx\n"); 387 - pr_info("%-15s %016lX %016lX %016lX\n", netdev->name, 388 - netdev->state, dev_trans_start(netdev), netdev->last_rx); 386 + pr_info("Device Name state trans_start\n"); 387 + pr_info("%-15s %016lX %016lX\n", netdev->name, 388 + netdev->state, dev_trans_start(netdev)); 389 389 } 390 390 391 391 /* Print Registers */
+3 -4
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
··· 611 611 if (netdev) { 612 612 dev_info(&adapter->pdev->dev, "Net device Info\n"); 613 613 pr_info("Device Name state " 614 - "trans_start last_rx\n"); 615 - pr_info("%-15s %016lX %016lX %016lX\n", 614 + "trans_start\n"); 615 + pr_info("%-15s %016lX %016lX\n", 616 616 netdev->name, 617 617 netdev->state, 618 - dev_trans_start(netdev), 619 - netdev->last_rx); 618 + dev_trans_start(netdev)); 620 619 } 621 620 622 621 /* Print Registers */
+3 -3
drivers/net/ethernet/marvell/sky2.c
··· 2666 2666 sky2->rx_stats.bytes += bytes; 2667 2667 u64_stats_update_end(&sky2->rx_stats.syncp); 2668 2668 2669 - dev->last_rx = jiffies; 2669 + sky2->last_rx = jiffies; 2670 2670 sky2_rx_update(netdev_priv(dev), rxqaddr[port]); 2671 2671 } 2672 2672 ··· 2953 2953 u8 fifo_lev = sky2_read8(hw, Q_ADDR(rxq, Q_RL)); 2954 2954 2955 2955 /* If idle and MAC or PCI is stuck */ 2956 - if (sky2->check.last == dev->last_rx && 2956 + if (sky2->check.last == sky2->last_rx && 2957 2957 ((mac_rp == sky2->check.mac_rp && 2958 2958 mac_lev != 0 && mac_lev >= sky2->check.mac_lev) || 2959 2959 /* Check if the PCI RX hang */ ··· 2965 2965 fifo_rp, sky2_read8(hw, Q_ADDR(rxq, Q_WP))); 2966 2966 return 1; 2967 2967 } else { 2968 - sky2->check.last = dev->last_rx; 2968 + sky2->check.last = sky2->last_rx; 2969 2969 sky2->check.mac_rp = mac_rp; 2970 2970 sky2->check.mac_lev = mac_lev; 2971 2971 sky2->check.fifo_rp = fifo_rp;
+1
drivers/net/ethernet/marvell/sky2.h
··· 2247 2247 u16 rx_data_size; 2248 2248 u16 rx_nfrags; 2249 2249 2250 + unsigned long last_rx; 2250 2251 struct { 2251 2252 unsigned long last; 2252 2253 u32 mac_rp;
-1
drivers/net/ethernet/qualcomm/emac/emac-mac.c
··· 1213 1213 emac_receive_skb(rx_q, skb, (u16)RRD_CVALN_TAG(&rrd), 1214 1214 (bool)RRD_CVTAG(&rrd)); 1215 1215 1216 - netdev->last_rx = jiffies; 1217 1216 (*num_pkts)++; 1218 1217 } while (*num_pkts < max_pkts); 1219 1218
+3 -4
drivers/net/ethernet/realtek/atp.c
··· 170 170 spinlock_t lock; 171 171 struct net_device *next_module; 172 172 struct timer_list timer; /* Media selection timer. */ 173 - long last_rx_time; /* Last Rx, in jiffies, to handle Rx hang. */ 173 + unsigned long last_rx_time; /* Last Rx, in jiffies, to handle Rx hang. */ 174 174 int saved_tx_size; 175 175 unsigned int tx_unit_busy:1; 176 176 unsigned char re_tx, /* Number of packet retransmissions. */ ··· 668 668 } 669 669 num_tx_since_rx++; 670 670 } else if (num_tx_since_rx > 8 && 671 - time_after(jiffies, dev->last_rx + HZ)) { 671 + time_after(jiffies, lp->last_rx_time + HZ)) { 672 672 if (net_debug > 2) 673 673 printk(KERN_DEBUG "%s: Missed packet? No Rx after %d Tx and " 674 674 "%ld jiffies status %02x CMR1 %02x.\n", dev->name, 675 - num_tx_since_rx, jiffies - dev->last_rx, status, 675 + num_tx_since_rx, jiffies - lp->last_rx_time, status, 676 676 (read_nibble(ioaddr, CMR1) >> 3) & 15); 677 677 dev->stats.rx_missed_errors++; 678 678 hardware_init(dev); ··· 789 789 read_block(ioaddr, pkt_len, skb_put(skb,pkt_len), dev->if_port); 790 790 skb->protocol = eth_type_trans(skb, dev); 791 791 netif_rx(skb); 792 - dev->last_rx = jiffies; 793 792 dev->stats.rx_packets++; 794 793 dev->stats.rx_bytes += pkt_len; 795 794 }
+4 -2
drivers/net/ethernet/smsc/smc91c92_cs.c
··· 113 113 struct mii_if_info mii_if; 114 114 int duplex; 115 115 int rx_ovrn; 116 + unsigned long last_rx; 116 117 }; 117 118 118 119 /* Special definitions for Megahertz multifunction cards */ ··· 1492 1491 if (!(rx_status & RS_ERRORS)) { 1493 1492 /* do stuff to make a new packet */ 1494 1493 struct sk_buff *skb; 1494 + struct smc_private *smc = netdev_priv(dev); 1495 1495 1496 1496 /* Note: packet_length adds 5 or 6 extra bytes here! */ 1497 1497 skb = netdev_alloc_skb(dev, packet_length+2); ··· 1511 1509 skb->protocol = eth_type_trans(skb, dev); 1512 1510 1513 1511 netif_rx(skb); 1514 - dev->last_rx = jiffies; 1512 + smc->last_rx = jiffies; 1515 1513 dev->stats.rx_packets++; 1516 1514 dev->stats.rx_bytes += packet_length; 1517 1515 if (rx_status & RS_MULTICAST) ··· 1792 1790 } 1793 1791 1794 1792 /* Ignore collisions unless we've had no rx's recently */ 1795 - if (time_after(jiffies, dev->last_rx + HZ)) { 1793 + if (time_after(jiffies, smc->last_rx + HZ)) { 1796 1794 if (smc->tx_err || (smc->media_status & EPH_16COL)) 1797 1795 media |= EPH_16COL; 1798 1796 }
+2 -3
drivers/net/irda/bfin_sir.c
··· 22 22 static int max_rate = 115200; 23 23 #endif 24 24 25 - static void turnaround_delay(unsigned long last_jif, int mtt) 25 + static void turnaround_delay(int mtt) 26 26 { 27 27 long ticks; 28 28 ··· 209 209 UART_CLEAR_LSR(port); 210 210 ch = UART_GET_CHAR(port); 211 211 async_unwrap_char(dev, &self->stats, &self->rx_buff, ch); 212 - dev->last_rx = jiffies; 213 212 } 214 213 215 214 static irqreturn_t bfin_sir_rx_int(int irq, void *dev_id) ··· 509 510 int tx_cnt = 10; 510 511 511 512 while (bfin_sir_is_receiving(dev) && --tx_cnt) 512 - turnaround_delay(dev->last_rx, self->mtt); 513 + turnaround_delay(self->mtt); 513 514 514 515 bfin_sir_stop_rx(port); 515 516
-1
drivers/net/irda/sh_sir.c
··· 547 547 548 548 async_unwrap_char(self->ndev, &self->ndev->stats, 549 549 &self->rx_buff, (u8)data); 550 - self->ndev->last_rx = jiffies; 551 550 552 551 if (EOFD & sh_sir_read(self, IRIF_SIR_FRM)) 553 552 continue;
-2
drivers/staging/ks7010/ks_hostif.c
··· 461 461 skb->protocol = eth_type_trans(skb, skb->dev); 462 462 priv->nstats.rx_packets++; 463 463 priv->nstats.rx_bytes += rx_ind_size; 464 - skb->dev->last_rx = jiffies; 465 464 netif_rx(skb); 466 465 } else { 467 466 priv->nstats.rx_dropped++; ··· 493 494 skb->protocol = eth_type_trans(skb, skb->dev); 494 495 priv->nstats.rx_packets++; 495 496 priv->nstats.rx_bytes += rx_ind_size; 496 - skb->dev->last_rx = jiffies; 497 497 netif_rx(skb); 498 498 } else { 499 499 priv->nstats.rx_dropped++;
-1
drivers/staging/netlogic/xlr_net.c
··· 155 155 skb_reserve(skb, BYTE_OFFSET); 156 156 skb_put(skb, length); 157 157 skb->protocol = eth_type_trans(skb, skb->dev); 158 - skb->dev->last_rx = jiffies; 159 158 netif_rx(skb); 160 159 /* Fill rx ring */ 161 160 skb_data = xlr_alloc_skb();
-1
drivers/staging/rtl8192e/rtllib_rx.c
··· 1375 1375 ieee->LinkDetectInfo.NumRecvDataInPeriod++; 1376 1376 ieee->LinkDetectInfo.NumRxOkInPeriod++; 1377 1377 } 1378 - dev->last_rx = jiffies; 1379 1378 1380 1379 /* Data frame - extract src/dst addresses */ 1381 1380 rtllib_rx_extract_addr(ieee, hdr, dst, src, bssid);
-4
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
··· 1103 1103 stats = hostap_get_stats(dev); 1104 1104 from_assoc_ap = 1; 1105 1105 } 1106 - #endif 1107 1106 1108 - dev->last_rx = jiffies; 1109 - 1110 - #ifdef NOT_YET 1111 1107 if ((ieee->iw_mode == IW_MODE_MASTER || 1112 1108 ieee->iw_mode == IW_MODE_REPEAT) && 1113 1109 !from_assoc_ap) {
-1
drivers/staging/wlan-ng/hfa384x_usb.c
··· 3409 3409 &usbin->rxfrm.desc.frame_control, hdrlen); 3410 3410 3411 3411 skb->dev = wlandev->netdev; 3412 - skb->dev->last_rx = jiffies; 3413 3412 3414 3413 /* And set the frame length properly */ 3415 3414 skb_trim(skb, data_len + hdrlen);
-2
drivers/staging/wlan-ng/p80211netdev.c
··· 252 252 } 253 253 254 254 if (skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0) { 255 - skb->dev->last_rx = jiffies; 256 255 wlandev->netdev->stats.rx_packets++; 257 256 wlandev->netdev->stats.rx_bytes += skb->len; 258 257 netif_rx_ni(skb); ··· 286 287 skb->ip_summed = CHECKSUM_NONE; 287 288 skb->pkt_type = PACKET_OTHERHOST; 288 289 skb->protocol = htons(ETH_P_80211_RAW); 289 - dev->last_rx = jiffies; 290 290 291 291 dev->stats.rx_packets++; 292 292 dev->stats.rx_bytes += skb->len;
-3
include/linux/netdevice.h
··· 1551 1551 * @ax25_ptr: AX.25 specific data 1552 1552 * @ieee80211_ptr: IEEE 802.11 specific data, assign before registering 1553 1553 * 1554 - * @last_rx: Time of last Rx 1555 1554 * @dev_addr: Hw address (before bcast, 1556 1555 * because most packets are unicast) 1557 1556 * ··· 1776 1777 /* 1777 1778 * Cache lines mostly used on receive path (including eth_type_trans()) 1778 1779 */ 1779 - unsigned long last_rx; 1780 - 1781 1780 /* Interface address info used in eth_type_trans() */ 1782 1781 unsigned char *dev_addr; 1783 1782
-1
net/batman-adv/bridge_loop_avoidance.c
··· 449 449 batadv_inc_counter(bat_priv, BATADV_CNT_RX); 450 450 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, 451 451 skb->len + ETH_HLEN); 452 - soft_iface->last_rx = jiffies; 453 452 454 453 netif_rx(skb); 455 454 out:
-1
net/batman-adv/distributed-arp-table.c
··· 1050 1050 bat_priv->soft_iface); 1051 1051 bat_priv->stats.rx_packets++; 1052 1052 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; 1053 - bat_priv->soft_iface->last_rx = jiffies; 1054 1053 1055 1054 netif_rx(skb_new); 1056 1055 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
-2
net/batman-adv/soft-interface.c
··· 481 481 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, 482 482 skb->len + ETH_HLEN); 483 483 484 - soft_iface->last_rx = jiffies; 485 - 486 484 /* Let the bridge loop avoidance check the packet. If will 487 485 * not handle it, we can safely push it up. 488 486 */