netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Choi, David" <David.Choi@Micrel.Com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"Doong, Ping" <Ping.Doong@Micrel.Com>,
	"bhutchings@solarflare.com" <bhutchings@solarflare.com>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next] drivers/net/ethernet/micrel/ks8851_mll: Implement basic statistics
Date: Tue, 29 Jan 2013 10:42:19 -0800	[thread overview]
Message-ID: <1359484939.15135.19.camel@joe-AO722> (raw)
In-Reply-To: <FD9AD8C5375B924CABC56D982DB3A802079D382B@EXMB1.micrel.com>

On Tue, 2013-01-29 at 18:24 +0000, Choi, David wrote:
> From: David J. Choi <david.choi@micrel.com>

Hello David.

When you resubmit a patch, please use a different
header for each resubmission.

This email subject line should have been

	[PATCH V3] ks8851_mll: Implement basic statistics

Also, don't use the complete path in the subject.
Read Documentation/SubmittingPatches Section 1, #15.

Please use git format-patch and git-send-email.

Please use a changelog describing what changes
you've made for each version.  The changelog is
generally placed after the --- separator that
git format-email produces.

More comments interspersed.

> +++ net-next/drivers/net/ethernet/micrel/ks8851_mll.c	2013-01-29 10:06:09.000000000 -0800
> @@ -793,19 +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) &&
> -			(frame_hdr->len < RX_BUF_SIZE) && frame_hdr->len)) {
> +		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) &&
> +				frame_hdr->len > 0 &&
> +				frame_hdr->len <= RX_BUF_SIZE)) {

OK, <= here

>  			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));
> -			if (skb)
> -				dev_kfree_skb_irq(skb);
> +			/* 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)

but >= here and !frame_hdr->len not frame_hdr-len == 0
Please be consistent.

> +				netdev->stats.rx_length_errors++;
> +			if (!(frame_hdr->sts & RXFSHR_RXFV))
> +				netdev->stats.rx_frame_errors++;
> +
> +			dev_kfree_skb_irq(skb);
>  		}
>  		frame_hdr++;
>  	}

It seems that a 0 length frame or an over length
frame is pretty unlikely and those should probably
be tested and accounted for before the
netdev_alloc_skb is done so that what seems an
unnecessary alloc/free is avoided.

  reply	other threads:[~2013-01-29 18:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29 18:24 [PATCH net-next] drivers/net/ethernet/micrel/ks8851_mll: Implement basic statistics Choi, David
2013-01-29 18:42 ` Joe Perches [this message]
2013-01-29 18:55 ` David Miller
2013-01-29 19:09   ` Joe Perches
2013-01-29 19:18     ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2013-01-23 18:46 Choi, David
2013-01-23 19:09 ` Joe Perches
2013-01-23 19:36   ` Choi, David
2013-01-29  1:34     ` Joe Perches
2013-01-28 23:39 ` David Miller
2013-01-29  1:21   ` Choi, David
2013-01-23  1:40 Choi, David
2013-01-23  1:51 ` David Miller
2013-01-23  3:57   ` Joe Perches
2013-01-23  4:17     ` David Miller
2013-01-23  4:27       ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359484939.15135.19.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=David.Choi@Micrel.Com \
    --cc=Ping.Doong@Micrel.Com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).