All of lore.kernel.org
 help / color / mirror / Atom feed
* [net] ixgbe: simplify padding and length checks
@ 2012-06-21 12:15 Jeff Kirsher
  2012-06-21 20:38 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2012-06-21 12:15 UTC (permalink / raw)
  To: davem; +Cc: Stephen Hemminger, netdev, gospo, sassmann, Jeff Kirsher

From: Stephen Hemminger <shemminger@vyatta.com>

The check for length <= 0 is bogus because length is unsigned, and network
stack never sends zero length packets (unless it is totally broken).

The check for really small packets can be optimized (using unlikely)
and calling skb_pad directly.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index cbb05d6..9afe0cb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -6383,17 +6383,12 @@ static netdev_tx_t ixgbe_xmit_frame(struct sk_buff *skb,
 	struct ixgbe_adapter *adapter = netdev_priv(netdev);
 	struct ixgbe_ring *tx_ring;
 
-	if (skb->len <= 0) {
-		dev_kfree_skb_any(skb);
-		return NETDEV_TX_OK;
-	}
-
 	/*
 	 * The minimum packet size for olinfo paylen is 17 so pad the skb
 	 * in order to meet this minimum size requirement.
 	 */
-	if (skb->len < 17) {
-		if (skb_padto(skb, 17))
+	if (unlikely(skb->len < 17)) {
+		if (skb_pad(skb, 17 - skb->len))
 			return NETDEV_TX_OK;
 		skb->len = 17;
 	}
-- 
1.7.10.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [net] ixgbe: simplify padding and length checks
  2012-06-21 12:15 [net] ixgbe: simplify padding and length checks Jeff Kirsher
@ 2012-06-21 20:38 ` David Miller
  2012-06-21 21:28   ` Jeff Kirsher
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2012-06-21 20:38 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: shemminger, netdev, gospo, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu, 21 Jun 2012 05:15:10 -0700

> From: Stephen Hemminger <shemminger@vyatta.com>
> 
> The check for length <= 0 is bogus because length is unsigned, and network
> stack never sends zero length packets (unless it is totally broken).
> 
> The check for really small packets can be optimized (using unlikely)
> and calling skb_pad directly.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Not really fixing anything and more of a cleanup, so maybe 'net-next'
instead of 'net' for this guy instead?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [net] ixgbe: simplify padding and length checks
  2012-06-21 20:38 ` David Miller
@ 2012-06-21 21:28   ` Jeff Kirsher
  2012-06-21 22:04     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2012-06-21 21:28 UTC (permalink / raw)
  To: David Miller; +Cc: shemminger, netdev, gospo, sassmann

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

On Thu, 2012-06-21 at 13:38 -0700, David Miller wrote:
> From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Date: Thu, 21 Jun 2012 05:15:10 -0700
> 
> > From: Stephen Hemminger <shemminger@vyatta.com>
> > 
> > The check for length <= 0 is bogus because length is unsigned, and network
> > stack never sends zero length packets (unless it is totally broken).
> > 
> > The check for really small packets can be optimized (using unlikely)
> > and calling skb_pad directly.
> > 
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> > Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
> > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> 
> Not really fixing anything and more of a cleanup, so maybe 'net-next'
> instead of 'net' for this guy instead?

Yeah, net-next is fine.  I just verified that the patch applies cleanly
to net-next as well.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [net] ixgbe: simplify padding and length checks
  2012-06-21 21:28   ` Jeff Kirsher
@ 2012-06-21 22:04     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-06-21 22:04 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: shemminger, netdev, gospo, sassmann

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu, 21 Jun 2012 14:28:09 -0700

> On Thu, 2012-06-21 at 13:38 -0700, David Miller wrote:
>> From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> Date: Thu, 21 Jun 2012 05:15:10 -0700
>> 
>> > From: Stephen Hemminger <shemminger@vyatta.com>
>> > 
>> > The check for length <= 0 is bogus because length is unsigned, and network
>> > stack never sends zero length packets (unless it is totally broken).
>> > 
>> > The check for really small packets can be optimized (using unlikely)
>> > and calling skb_pad directly.
>> > 
>> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>> > Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
>> > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>> 
>> Not really fixing anything and more of a cleanup, so maybe 'net-next'
>> instead of 'net' for this guy instead?
> 
> Yeah, net-next is fine.  I just verified that the patch applies cleanly
> to net-next as well.

Great, applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-21 22:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-21 12:15 [net] ixgbe: simplify padding and length checks Jeff Kirsher
2012-06-21 20:38 ` David Miller
2012-06-21 21:28   ` Jeff Kirsher
2012-06-21 22:04     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.