Patchwork [net-next] drivers/net/ethernet/micrel/ks8851_mll: Implement basic statistics

login
register
mail settings
Submitter Choi, David
Date Jan. 23, 2013, 1:40 a.m.
Message ID <FD9AD8C5375B924CABC56D982DB3A802079D32D1@EXMB1.micrel.com>
Download mbox | patch
Permalink /patch/214708/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Choi, David - Jan. 23, 2013, 1:40 a.m.
From: David J. Choi <david.choi@micrel.com>
 
Summary of changes:
  add codes to collect basic statistical information about Ethernet packets.
 
Signed-off-by: David J. Choi <david.choi@micrel.com>
---


---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 23, 2013, 1:51 a.m.
From: "Choi, David" <David.Choi@Micrel.Com>
Date: Wed, 23 Jan 2013 01:40:41 +0000

> From: David J. Choi <david.choi@micrel.com>
>  
> Summary of changes:
>   add codes to collect basic statistical information about Ethernet packets.
>  
> Signed-off-by: David J. Choi <david.choi@micrel.com>

A Subject prefix of "ks8851_mll: " is sufficient, people who want the
whole patch name can simply look at the patch.

> +			if (frame_hdr->sts & RXFSHR_RXFV) 

This line has trailing whitespace errors.

> +				netdev->stats.rx_frame_errors++;
>  			pr_err("%s: err:skb alloc\n", __func__);

BTW it's inappropriate to log an SKB allocation failure as an error in
the kernel logs like this.  This can be completely normal on a heavily
loaded system.  People can look at the device statistics to learn about
this event, or use a more sophisticated tool like the drop monitor.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches - Jan. 23, 2013, 3:57 a.m.
On Tue, 2013-01-22 at 20:51 -0500, David Miller wrote:
> BTW it's inappropriate to log an SKB allocation failure as an error in
> the kernel logs like this.  This can be completely normal on a heavily
> loaded system.  People can look at the device statistics to learn about
> this event, or use a more sophisticated tool like the drop monitor.

There are many of these still around, though
hardly any in modern drivers.

I get this file list in drivers/net/ of
alloc_skb failures followed by printks:

Almost all of these are pretty old and are
probably best described as "don't bother".

Maybe the realtek.

drivers/net/appletalk/cops.c
drivers/net/can/grcan.c
drivers/net/can/mcp251x.c
drivers/net/can/mscan/mscan.c
drivers/net/ethernet/adi/bfin_mac.c
drivers/net/ethernet/aeroflex/greth.c
drivers/net/ethernet/amd/7990.c
drivers/net/ethernet/amd/a2065.c
drivers/net/ethernet/amd/am79c961a.c
drivers/net/ethernet/amd/au1000_eth.c
drivers/net/ethernet/amd/declance.c
drivers/net/ethernet/amd/ni65.c
drivers/net/ethernet/amd/sunlance.c
drivers/net/ethernet/cadence/at91_ether.c
drivers/net/ethernet/cirrus/cs89x0.c
drivers/net/ethernet/cirrus/mac89x0.c
drivers/net/ethernet/ethoc.c
drivers/net/ethernet/freescale/fec.c
drivers/net/ethernet/freescale/fec_mpc52xx.c
drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
drivers/net/ethernet/fujitsu/fmvj18x_cs.c
drivers/net/ethernet/i825xx/82596.c
drivers/net/ethernet/i825xx/lib82596.c
drivers/net/ethernet/microchip/enc28j60.c
drivers/net/ethernet/natsemi/sonic.c
drivers/net/ethernet/netx-eth.c
drivers/net/ethernet/nuvoton/w90p910_ether.c
drivers/net/ethernet/realtek/8139too.c
drivers/net/ethernet/realtek/atp.c
drivers/net/ethernet/seeq/sgiseeq.c
drivers/net/ethernet/sis/sis900.c
drivers/net/ethernet/smsc/smc9194.c
drivers/net/ethernet/smsc/smc91c92_cs.c
drivers/net/ethernet/smsc/smc91x.c
drivers/net/ethernet/xilinx/xilinx_emaclite.c
drivers/net/ethernet/xircom/xirc2ps_cs.c
drivers/net/hamradio/baycom_epp.c
drivers/net/hamradio/hdlcdrv.c
drivers/net/hamradio/mkiss.c
drivers/net/hippi/rrunner.c
drivers/net/irda/pxaficp_ir.c
drivers/net/sb1000.c
drivers/net/slip/slip.c
drivers/net/usb/ipheth.c
drivers/net/wan/cosa.c
drivers/net/wan/sdla.c
drivers/net/wan/x25_asy.c
drivers/net/wan/z85230.c
drivers/net/wimax/i2400m/netdev.c
drivers/net/wireless/ray_cs.c
drivers/net/wireless/wl3501_cs.c



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 23, 2013, 4:17 a.m.
From: Joe Perches <joe@perches.com>
Date: Tue, 22 Jan 2013 19:57:34 -0800

> On Tue, 2013-01-22 at 20:51 -0500, David Miller wrote:
>> BTW it's inappropriate to log an SKB allocation failure as an error in
>> the kernel logs like this.  This can be completely normal on a heavily
>> loaded system.  People can look at the device statistics to learn about
>> this event, or use a more sophisticated tool like the drop monitor.
> 
> There are many of these still around, though
> hardly any in modern drivers.

Right.

> I get this file list in drivers/net/ of
> alloc_skb failures followed by printks:
> 
> Almost all of these are pretty old and are
> probably best described as "don't bother".

Be also careful to not match the ones that are done to
do something like the initial RX ring filling during
device open.

If such an allocation failure causes device open to fail,
that's a legitimate situation in which to log.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- net-next/drivers/net/ethernet/micrel/ks8851_mll.c.orig	2013-01-22 17:25:59.000000000 -0800
+++ net-next/drivers/net/ethernet/micrel/ks8851_mll.c	2013-01-22 17:27:57.000000000 -0800
@@ -798,10 +798,17 @@  static void ks_rcv(struct ks_net *ks, st
 			skb_reserve(skb, 2);
 			/* read data block including CRC 4 bytes */
 			ks_read_qmu(ks, (u16 *)skb->data, frame_hdr->len);
-			skb_put(skb, frame_hdr->len);
+			skb_put(skb, frame_hdr->len - 4); /*exclude size of CRC */
 			skb->protocol = eth_type_trans(skb, netdev);
 			netif_rx(skb);
+			netdev->stats.rx_packets++;
+			netdev->stats.rx_bytes += (frame_hdr->len - 4); /*crc field*/
 		} else {
+			netdev->stats.rx_dropped++;
+			if ((frame_hdr->len >= RX_BUF_SIZE) || (frame_hdr->len == 0))
+				netdev->stats.rx_length_errors++;
+			if (frame_hdr->sts & RXFSHR_RXFV) 
+				netdev->stats.rx_frame_errors++;
 			pr_err("%s: err:skb alloc\n", __func__);
 			ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
 			if (skb)
@@ -876,6 +883,8 @@  static irqreturn_t ks_irq(int irq, void 
 		pmecr &= ~PMECR_WKEVT_MASK;
 		ks_wrreg16(ks, KS_PMECR, pmecr | PMECR_WKEVT_LINK);
 	}
+	if (unlikely(status & IRQ_RXOI))
+		ks->netdev->stats.rx_over_errors++;
 
 	/* this should be the last in IRQ handler*/
 	ks_restore_cmd_reg(ks);
@@ -1015,6 +1024,8 @@  static int ks_start_xmit(struct sk_buff 
 
 	if (likely(ks_tx_fifo_space(ks) >= skb->len + 12)) {
 		ks_write_qmu(ks, skb->data, skb->len);
+		netdev->stats.tx_bytes += skb->len;
+		netdev->stats.tx_packets++;
 		dev_kfree_skb(skb);
 	} else
 		retv = NETDEV_TX_BUSY;