diff options
author | Paulius Zaleckas <paulius.zaleckas@teltonika.lt> | 2008-05-06 16:50:30 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-14 16:29:48 -0400 |
commit | 736bc924fe7183dd27182a9148e78f250c1637ee (patch) | |
tree | d42972d1e02486fc51546335229990129662227e | |
parent | 06a5223d68a7c48bf72a05aad533ea0e8a3453be (diff) |
atmel: use netstats in net_device structure
Use net_device_stats from net_device structure instead of local.
Kill atmel_get_stats function, because by default it is used
identical internal_stats function from net/core/dev.c
No need to memset stats to 0, because they are allocated by kzalloc.
P.S. Someone should cleanup init_atmel_card function from unneeded
initializations to 0/NULL. Out of scope for this patch.
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/atmel.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index ef2da4023d68..f978a9d5190b 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -433,7 +433,6 @@ struct atmel_private { | |||
433 | struct net_device *dev; | 433 | struct net_device *dev; |
434 | struct device *sys_dev; | 434 | struct device *sys_dev; |
435 | struct iw_statistics wstats; | 435 | struct iw_statistics wstats; |
436 | struct net_device_stats stats; // device stats | ||
437 | spinlock_t irqlock, timerlock; // spinlocks | 436 | spinlock_t irqlock, timerlock; // spinlocks |
438 | enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type; | 437 | enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type; |
439 | enum { | 438 | enum { |
@@ -694,9 +693,9 @@ static void tx_done_irq(struct atmel_private *priv) | |||
694 | 693 | ||
695 | if (type == TX_PACKET_TYPE_DATA) { | 694 | if (type == TX_PACKET_TYPE_DATA) { |
696 | if (status == TX_STATUS_SUCCESS) | 695 | if (status == TX_STATUS_SUCCESS) |
697 | priv->stats.tx_packets++; | 696 | priv->dev->stats.tx_packets++; |
698 | else | 697 | else |
699 | priv->stats.tx_errors++; | 698 | priv->dev->stats.tx_errors++; |
700 | netif_wake_queue(priv->dev); | 699 | netif_wake_queue(priv->dev); |
701 | } | 700 | } |
702 | } | 701 | } |
@@ -792,13 +791,13 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
792 | 791 | ||
793 | if (priv->card && priv->present_callback && | 792 | if (priv->card && priv->present_callback && |
794 | !(*priv->present_callback)(priv->card)) { | 793 | !(*priv->present_callback)(priv->card)) { |
795 | priv->stats.tx_errors++; | 794 | dev->stats.tx_errors++; |
796 | dev_kfree_skb(skb); | 795 | dev_kfree_skb(skb); |
797 | return 0; | 796 | return 0; |
798 | } | 797 | } |
799 | 798 | ||
800 | if (priv->station_state != STATION_STATE_READY) { | 799 | if (priv->station_state != STATION_STATE_READY) { |
801 | priv->stats.tx_errors++; | 800 | dev->stats.tx_errors++; |
802 | dev_kfree_skb(skb); | 801 | dev_kfree_skb(skb); |
803 | return 0; | 802 | return 0; |
804 | } | 803 | } |
@@ -815,7 +814,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
815 | initial + 18 (+30-12) */ | 814 | initial + 18 (+30-12) */ |
816 | 815 | ||
817 | if (!(buff = find_tx_buff(priv, len + 18))) { | 816 | if (!(buff = find_tx_buff(priv, len + 18))) { |
818 | priv->stats.tx_dropped++; | 817 | dev->stats.tx_dropped++; |
819 | spin_unlock_irqrestore(&priv->irqlock, flags); | 818 | spin_unlock_irqrestore(&priv->irqlock, flags); |
820 | spin_unlock_bh(&priv->timerlock); | 819 | spin_unlock_bh(&priv->timerlock); |
821 | netif_stop_queue(dev); | 820 | netif_stop_queue(dev); |
@@ -851,7 +850,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
851 | /* low bit of first byte of destination tells us if broadcast */ | 850 | /* low bit of first byte of destination tells us if broadcast */ |
852 | tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA); | 851 | tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA); |
853 | dev->trans_start = jiffies; | 852 | dev->trans_start = jiffies; |
854 | priv->stats.tx_bytes += len; | 853 | dev->stats.tx_bytes += len; |
855 | 854 | ||
856 | spin_unlock_irqrestore(&priv->irqlock, flags); | 855 | spin_unlock_irqrestore(&priv->irqlock, flags); |
857 | spin_unlock_bh(&priv->timerlock); | 856 | spin_unlock_bh(&priv->timerlock); |
@@ -895,7 +894,7 @@ static void fast_rx_path(struct atmel_private *priv, | |||
895 | } | 894 | } |
896 | 895 | ||
897 | if (!(skb = dev_alloc_skb(msdu_size + 14))) { | 896 | if (!(skb = dev_alloc_skb(msdu_size + 14))) { |
898 | priv->stats.rx_dropped++; | 897 | priv->dev->stats.rx_dropped++; |
899 | return; | 898 | return; |
900 | } | 899 | } |
901 | 900 | ||
@@ -908,7 +907,7 @@ static void fast_rx_path(struct atmel_private *priv, | |||
908 | crc = crc32_le(crc, skbp + 12, msdu_size); | 907 | crc = crc32_le(crc, skbp + 12, msdu_size); |
909 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + 30 + msdu_size, 4); | 908 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + 30 + msdu_size, 4); |
910 | if ((crc ^ 0xffffffff) != netcrc) { | 909 | if ((crc ^ 0xffffffff) != netcrc) { |
911 | priv->stats.rx_crc_errors++; | 910 | priv->dev->stats.rx_crc_errors++; |
912 | dev_kfree_skb(skb); | 911 | dev_kfree_skb(skb); |
913 | return; | 912 | return; |
914 | } | 913 | } |
@@ -924,8 +923,8 @@ static void fast_rx_path(struct atmel_private *priv, | |||
924 | skb->protocol = eth_type_trans(skb, priv->dev); | 923 | skb->protocol = eth_type_trans(skb, priv->dev); |
925 | skb->ip_summed = CHECKSUM_NONE; | 924 | skb->ip_summed = CHECKSUM_NONE; |
926 | netif_rx(skb); | 925 | netif_rx(skb); |
927 | priv->stats.rx_bytes += 12 + msdu_size; | 926 | priv->dev->stats.rx_bytes += 12 + msdu_size; |
928 | priv->stats.rx_packets++; | 927 | priv->dev->stats.rx_packets++; |
929 | } | 928 | } |
930 | 929 | ||
931 | /* Test to see if the packet in card memory at packet_loc has a valid CRC | 930 | /* Test to see if the packet in card memory at packet_loc has a valid CRC |
@@ -991,7 +990,7 @@ static void frag_rx_path(struct atmel_private *priv, | |||
991 | crc = crc32_le(crc, &priv->rx_buf[12], msdu_size); | 990 | crc = crc32_le(crc, &priv->rx_buf[12], msdu_size); |
992 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); | 991 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); |
993 | if ((crc ^ 0xffffffff) != netcrc) { | 992 | if ((crc ^ 0xffffffff) != netcrc) { |
994 | priv->stats.rx_crc_errors++; | 993 | priv->dev->stats.rx_crc_errors++; |
995 | memset(priv->frag_source, 0xff, 6); | 994 | memset(priv->frag_source, 0xff, 6); |
996 | } | 995 | } |
997 | } | 996 | } |
@@ -1009,7 +1008,7 @@ static void frag_rx_path(struct atmel_private *priv, | |||
1009 | msdu_size); | 1008 | msdu_size); |
1010 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); | 1009 | atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); |
1011 | if ((crc ^ 0xffffffff) != netcrc) { | 1010 | if ((crc ^ 0xffffffff) != netcrc) { |
1012 | priv->stats.rx_crc_errors++; | 1011 | priv->dev->stats.rx_crc_errors++; |
1013 | memset(priv->frag_source, 0xff, 6); | 1012 | memset(priv->frag_source, 0xff, 6); |
1014 | more_frags = 1; /* don't send broken assembly */ | 1013 | more_frags = 1; /* don't send broken assembly */ |
1015 | } | 1014 | } |
@@ -1021,7 +1020,7 @@ static void frag_rx_path(struct atmel_private *priv, | |||
1021 | if (!more_frags) { /* last one */ | 1020 | if (!more_frags) { /* last one */ |
1022 | memset(priv->frag_source, 0xff, 6); | 1021 | memset(priv->frag_source, 0xff, 6); |
1023 | if (!(skb = dev_alloc_skb(priv->frag_len + 14))) { | 1022 | if (!(skb = dev_alloc_skb(priv->frag_len + 14))) { |
1024 | priv->stats.rx_dropped++; | 1023 | priv->dev->stats.rx_dropped++; |
1025 | } else { | 1024 | } else { |
1026 | skb_reserve(skb, 2); | 1025 | skb_reserve(skb, 2); |
1027 | memcpy(skb_put(skb, priv->frag_len + 12), | 1026 | memcpy(skb_put(skb, priv->frag_len + 12), |
@@ -1031,8 +1030,8 @@ static void frag_rx_path(struct atmel_private *priv, | |||
1031 | skb->protocol = eth_type_trans(skb, priv->dev); | 1030 | skb->protocol = eth_type_trans(skb, priv->dev); |
1032 | skb->ip_summed = CHECKSUM_NONE; | 1031 | skb->ip_summed = CHECKSUM_NONE; |
1033 | netif_rx(skb); | 1032 | netif_rx(skb); |
1034 | priv->stats.rx_bytes += priv->frag_len + 12; | 1033 | priv->dev->stats.rx_bytes += priv->frag_len + 12; |
1035 | priv->stats.rx_packets++; | 1034 | priv->dev->stats.rx_packets++; |
1036 | } | 1035 | } |
1037 | } | 1036 | } |
1038 | } else | 1037 | } else |
@@ -1057,7 +1056,7 @@ static void rx_done_irq(struct atmel_private *priv) | |||
1057 | if (status == 0xc1) /* determined by experiment */ | 1056 | if (status == 0xc1) /* determined by experiment */ |
1058 | priv->wstats.discard.nwid++; | 1057 | priv->wstats.discard.nwid++; |
1059 | else | 1058 | else |
1060 | priv->stats.rx_errors++; | 1059 | priv->dev->stats.rx_errors++; |
1061 | goto next; | 1060 | goto next; |
1062 | } | 1061 | } |
1063 | 1062 | ||
@@ -1065,7 +1064,7 @@ static void rx_done_irq(struct atmel_private *priv) | |||
1065 | rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head)); | 1064 | rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head)); |
1066 | 1065 | ||
1067 | if (msdu_size < 30) { | 1066 | if (msdu_size < 30) { |
1068 | priv->stats.rx_errors++; | 1067 | priv->dev->stats.rx_errors++; |
1069 | goto next; | 1068 | goto next; |
1070 | } | 1069 | } |
1071 | 1070 | ||
@@ -1123,7 +1122,7 @@ static void rx_done_irq(struct atmel_private *priv) | |||
1123 | msdu_size -= 4; | 1122 | msdu_size -= 4; |
1124 | crc = crc32_le(crc, (unsigned char *)&priv->rx_buf, msdu_size); | 1123 | crc = crc32_le(crc, (unsigned char *)&priv->rx_buf, msdu_size); |
1125 | if ((crc ^ 0xffffffff) != (*((u32 *)&priv->rx_buf[msdu_size]))) { | 1124 | if ((crc ^ 0xffffffff) != (*((u32 *)&priv->rx_buf[msdu_size]))) { |
1126 | priv->stats.rx_crc_errors++; | 1125 | priv->dev->stats.rx_crc_errors++; |
1127 | goto next; | 1126 | goto next; |
1128 | } | 1127 | } |
1129 | } | 1128 | } |
@@ -1250,12 +1249,6 @@ static irqreturn_t service_interrupt(int irq, void *dev_id) | |||
1250 | } | 1249 | } |
1251 | } | 1250 | } |
1252 | 1251 | ||
1253 | static struct net_device_stats *atmel_get_stats(struct net_device *dev) | ||
1254 | { | ||
1255 | struct atmel_private *priv = netdev_priv(dev); | ||
1256 | return &priv->stats; | ||
1257 | } | ||
1258 | |||
1259 | static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev) | 1252 | static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev) |
1260 | { | 1253 | { |
1261 | struct atmel_private *priv = netdev_priv(dev); | 1254 | struct atmel_private *priv = netdev_priv(dev); |
@@ -1518,8 +1511,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, | |||
1518 | priv->crc_ok_cnt = priv->crc_ko_cnt = 0; | 1511 | priv->crc_ok_cnt = priv->crc_ko_cnt = 0; |
1519 | } else | 1512 | } else |
1520 | priv->probe_crc = 0; | 1513 | priv->probe_crc = 0; |
1521 | memset(&priv->stats, 0, sizeof(priv->stats)); | ||
1522 | memset(&priv->wstats, 0, sizeof(priv->wstats)); | ||
1523 | priv->last_qual = jiffies; | 1514 | priv->last_qual = jiffies; |
1524 | priv->last_beacon_timestamp = 0; | 1515 | priv->last_beacon_timestamp = 0; |
1525 | memset(priv->frag_source, 0xff, sizeof(priv->frag_source)); | 1516 | memset(priv->frag_source, 0xff, sizeof(priv->frag_source)); |
@@ -1568,7 +1559,6 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, | |||
1568 | dev->change_mtu = atmel_change_mtu; | 1559 | dev->change_mtu = atmel_change_mtu; |
1569 | dev->set_mac_address = atmel_set_mac_address; | 1560 | dev->set_mac_address = atmel_set_mac_address; |
1570 | dev->hard_start_xmit = start_tx; | 1561 | dev->hard_start_xmit = start_tx; |
1571 | dev->get_stats = atmel_get_stats; | ||
1572 | dev->wireless_handlers = (struct iw_handler_def *)&atmel_handler_def; | 1562 | dev->wireless_handlers = (struct iw_handler_def *)&atmel_handler_def; |
1573 | dev->do_ioctl = atmel_ioctl; | 1563 | dev->do_ioctl = atmel_ioctl; |
1574 | dev->irq = irq; | 1564 | dev->irq = irq; |