[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1358968194.2107.37.camel@joe-AO722>
Date: Wed, 23 Jan 2013 11:09:54 -0800
From: Joe Perches <joe@...ches.com>
To: "Choi, David" <David.Choi@...rel.Com>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"Doong, Ping" <Ping.Doong@...rel.Com>,
"davem@...emloft.net" <davem@...emloft.net>,
"bhutchings@...arflare.com" <bhutchings@...arflare.com>
Subject: Re: [PATCH net-next] drivers/net/ethernet/micrel/ks8851_mll:
Implement basic statistics
On Wed, 2013-01-23 at 18:46 +0000, Choi, David wrote:
> +++ net-next/drivers/net/ethernet/micrel/ks8851_mll.c 2013-01-23 10:31:24.000000000 -0800
> @@ -793,17 +793,35 @@ static void ks_rcv(struct ks_net *ks, st
> frame_hdr = ks->frame_head_info;
> while (ks->frame_cnt--) {
> skb = netdev_alloc_skb(netdev, frame_hdr->len + 16);
> - if (likely(skb && (frame_hdr->sts & RXFSHR_RXFV) &&
> + if (unlikely(!skb)) {
> + /* discard the packet from the device */
> + ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF);
> + netdev->stats.rx_dropped++;
> + }
> +
> + else if (likely((frame_hdr->sts & RXFSHR_RXFV) &&
Couple of trivial comments:
it' be nicer if the close brace and else
was on the same line
} else if (likely(...
> (frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) {
> 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);
> +
> + /* exclude the size of CRC */
> + skb_put(skb, frame_hdr->len - 4);
> skb->protocol = eth_type_trans(skb, netdev);
> netif_rx(skb);
> + netdev->stats.rx_packets++;
> +
> + /* crc field */
> + netdev->stats.rx_bytes += frame_hdr->len - 4;
> } else {
> - pr_err("%s: err:skb alloc\n", __func__);
> - ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
> + /* discard the packet from the device */
> + ks_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF);
> + netdev->stats.rx_dropped++;
> + if (frame_hdr->len >= RX_BUF_SIZE || !frame_hdr->len)
> + netdev->stats.rx_length_errors++;
> + if (!(frame_hdr->sts & RXFSHR_RXFV))
> + netdev->stats.rx_frame_errors++;
> +
> if (skb)
> dev_kfree_skb_irq(skb);
You don't need to test skb here anymore.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists