mfd: Add SuperH Mobile SDHI platform driver
[safe/jmp/linux-2.6] / drivers / net / loopback.c
index b7d438a..1bc654a 100644 (file)
 struct pcpu_lstats {
        unsigned long packets;
        unsigned long bytes;
+       unsigned long drops;
 };
 
 /*
  * The higher levels take care of making this non-reentrant (it's
  * called with bh's disabled).
  */
-static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t loopback_xmit(struct sk_buff *skb,
+                                struct net_device *dev)
 {
        struct pcpu_lstats *pcpu_lstats, *lb_stats;
+       int len;
 
        skb_orphan(skb);
 
-       skb->protocol = eth_type_trans(skb,dev);
+       skb->protocol = eth_type_trans(skb, dev);
 
        /* it's OK to use per_cpu_ptr() because BHs are off */
        pcpu_lstats = dev->ml_priv;
        lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
-       lb_stats->bytes += skb->len;
-       lb_stats->packets++;
 
-       netif_rx(skb);
+       len = skb->len;
+       if (likely(netif_rx(skb) == NET_RX_SUCCESS)) {
+               lb_stats->bytes += len;
+               lb_stats->packets++;
+       } else
+               lb_stats->drops++;
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static struct net_device_stats *loopback_get_stats(struct net_device *dev)
@@ -93,6 +99,7 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
        struct net_device_stats *stats = &dev->stats;
        unsigned long bytes = 0;
        unsigned long packets = 0;
+       unsigned long drops = 0;
        int i;
 
        pcpu_lstats = dev->ml_priv;
@@ -102,11 +109,14 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
                lb_stats = per_cpu_ptr(pcpu_lstats, i);
                bytes   += lb_stats->bytes;
                packets += lb_stats->packets;
+               drops   += lb_stats->drops;
        }
        stats->rx_packets = packets;
        stats->tx_packets = packets;
-       stats->rx_bytes = bytes;
-       stats->tx_bytes = bytes;
+       stats->rx_dropped = drops;
+       stats->rx_errors  = drops;
+       stats->rx_bytes   = bytes;
+       stats->tx_bytes   = bytes;
        return stats;
 }
 
@@ -161,6 +171,7 @@ static void loopback_setup(struct net_device *dev)
        dev->tx_queue_len       = 0;
        dev->type               = ARPHRD_LOOPBACK;      /* 0x0001*/
        dev->flags              = IFF_LOOPBACK;
+       dev->priv_flags        &= ~IFF_XMIT_DST_RELEASE;
        dev->features           = NETIF_F_SG | NETIF_F_FRAGLIST
                | NETIF_F_TSO
                | NETIF_F_NO_CSUM