This patch is for the network loopback driver:
1: Removes unnecessary include with misleading comment.
2: Optimizes device stats update in the transmit routine
(saves 2 loads, one add, one increment per packet sent.)
Why is there no stats counting in the TSO code in
emulate_large_send_offload()?
Signed-off-by: Chuck Ebbert <[email protected]>
--- 267.0/drivers/net/loopback.c 2004-06-21 16:09:45.000000000 -0400
+++ 267.1/drivers/net/loopback.c 2004-06-21 16:16:20.000000000 -0400
@@ -51,7 +51,6 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/checksum.h>
-#include <linux/if_ether.h> /* For the statistics structure. */
#include <linux/if_arp.h> /* For ARPHRD_ETHER */
#include <linux/ip.h>
#include <linux/tcp.h>
@@ -143,10 +142,14 @@ static int loopback_xmit(struct sk_buff
dev->last_rx = jiffies;
if (likely(stats)) {
- stats->rx_bytes+=skb->len;
- stats->tx_bytes+=skb->len;
- stats->rx_packets++;
- stats->tx_packets++;
+ /*
+ * Transmit/receive stats are identical;
+ * rx_packets is first in struct.
+ */
+ stats->tx_packets = ++stats->rx_packets;
+
+ stats->rx_bytes += skb->len;
+ stats->tx_bytes = stats->rx_bytes;
}
netif_rx(skb);