aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid J. Choi <david.choi@micrel.com>2013-03-11 12:22:54 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-12 11:49:31 -0400
commitc1ad32af5ec281bf30d2ca4fa20415bd2edef181 (patch)
tree2a9b9e277fd680e71127e53a661804037bff93a2
parentf754e913e51709b7d842a9c5e17184198e83b2c8 (diff)
ks8851_mll: basic ethernet statistics
Implement to collect ethernet statistical information on ks8851_mll device. Signed-off-by: David J. Choi <david.choi@micrel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/micrel/ks8851_mll.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
index a343066f7b43..ddaf138ce0d4 100644
--- a/drivers/net/ethernet/micrel/ks8851_mll.c
+++ b/drivers/net/ethernet/micrel/ks8851_mll.c
@@ -792,20 +792,35 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
792 792
793 frame_hdr = ks->frame_head_info; 793 frame_hdr = ks->frame_head_info;
794 while (ks->frame_cnt--) { 794 while (ks->frame_cnt--) {
795 if (unlikely(!(frame_hdr->sts & RXFSHR_RXFV) ||
796 frame_hdr->len >= RX_BUF_SIZE ||
797 frame_hdr->len <= 0)) {
798
799 /* discard an invalid packet */
800 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
801 netdev->stats.rx_dropped++;
802 if (!(frame_hdr->sts & RXFSHR_RXFV))
803 netdev->stats.rx_frame_errors++;
804 else
805 netdev->stats.rx_length_errors++;
806 frame_hdr++;
807 continue;
808 }
809
795 skb = netdev_alloc_skb(netdev, frame_hdr->len + 16); 810 skb = netdev_alloc_skb(netdev, frame_hdr->len + 16);
796 if (likely(skb && (frame_hdr->sts & RXFSHR_RXFV) && 811 if (likely(skb)) {
797 (frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) {
798 skb_reserve(skb, 2); 812 skb_reserve(skb, 2);
799 /* read data block including CRC 4 bytes */ 813 /* read data block including CRC 4 bytes */
800 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len); 814 ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len);
801 skb_put(skb, frame_hdr->len); 815 skb_put(skb, frame_hdr->len - 4);
802 skb->protocol = eth_type_trans(skb, netdev); 816 skb->protocol = eth_type_trans(skb, netdev);
803 netif_rx(skb); 817 netif_rx(skb);
818 /* exclude CRC size */
819 netdev->stats.rx_bytes += frame_hdr->len - 4;
820 netdev->stats.rx_packets++;
804 } else { 821 } else {
805 pr_err("%s: err:skb alloc\n", __func__);
806 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); 822 ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
807 if (skb) 823 netdev->stats.rx_dropped++;
808 dev_kfree_skb_irq(skb);
809 } 824 }
810 frame_hdr++; 825 frame_hdr++;
811 } 826 }
@@ -877,6 +892,8 @@ static irqreturn_t ks_irq(int irq, void *pw)
877 ks_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK); 892 ks_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK);
878 } 893 }
879 894
895 if (unlikely(status & IRQ_RXOI))
896 ks->netdev->stats.rx_over_errors++;
880 /* this should be the last in IRQ handler*/ 897 /* this should be the last in IRQ handler*/
881 ks_restore_cmd_reg(ks); 898 ks_restore_cmd_reg(ks);
882 return IRQ_HANDLED; 899 return IRQ_HANDLED;
@@ -1015,6 +1032,9 @@ static int ks_start_xmit(struct sk_buff *skb, struct net_device *netdev)
1015 1032
1016 if (likely(ks_tx_fifo_space(ks) >= skb->len + 12)) { 1033 if (likely(ks_tx_fifo_space(ks) >= skb->len + 12)) {
1017 ks_write_qmu(ks, skb->data, skb->len); 1034 ks_write_qmu(ks, skb->data, skb->len);
1035 /* add tx statistics */
1036 netdev->stats.tx_bytes += skb->len;
1037 netdev->stats.tx_packets++;
1018 dev_kfree_skb(skb); 1038 dev_kfree_skb(skb);
1019 } else 1039 } else
1020 retv = NETDEV_TX_BUSY; 1040 retv = NETDEV_TX_BUSY;