Skip to contentSkip to conversation

ixgbe: use skb_padto

PATCH In review Stephen Hemminger 3 participants 7 messages Jun 18, 2012 – Jun 19, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ixgbe: use skb_padto

The code to pad packets here is the same effective code as the existing inline function skb_padto(). There is a minor performance gain since skb_padto() also uses unlikely().

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -5
@@ -6389,11 +6389,8 @@ static netdev_tx_t ixgbe_xmit_frame(stru
 	 * 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))
-			return NETDEV_TX_OK;
-		skb->len = 17;
-	}
+	if (skb_padto(skb, 17))
+		return NETDEV_TX_OK;
 
 	tx_ring = adapter->tx_ring[skb->queue_mapping];
 	return ixgbe_xmit_frame_ring(skb, adapter, tx_ring);

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

#1 lore raw

PATCH 2/2 ixgbe: remove xmit length check

The check here is bogus. Since len is unsigned, it can never be negative. And it would be a bug in network stack to ever send a zero length packet to device.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -5
@@ -6380,11 +6380,6 @@ static netdev_tx_t ixgbe_xmit_frame(stru
 	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.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

#2 lore raw

Re: [PATCH 2/2 net-next] ixgbe: remove xmit length check

In reply to Stephen Hemminger
Quoted 5 lines · Stephen Hemminger

The check here is bogus. Since len is unsigned, it can never be negative. And it would be a bug in network stack to ever send a zero length packet to device.

Thanks, I have added this patch as well to my queue.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit http://communities.intel.com/community/wired

#4 lore raw
In reply to Stephen Hemminger
Quoted 13 lines · Stephen Hemminger

The code to pad packets here is the same effective code as the existing inline function skb_padto(). There is a minor performance gain since skb_padto() also uses unlikely().

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
@@ -6389,11 +6389,8 @@ static netdev_tx_t ixgbe_xmit_frame(stru
 	 * The minimum packet size for olinfo paylen is 17 so pad the skb
 	 * in order to meet this minimum size requirement.
 	 */

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static netdev_tx_t ixgbe_xmit_frame(stru · line 6396

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -5
-	if (skb->len < 17) {
-		if (skb_padto(skb, 17))
-			return NETDEV_TX_OK;
-		skb->len = 17;
-	}
+	if (skb_padto(skb, 17))
+		return NETDEV_TX_OK;
 
 	tx_ring = adapter->tx_ring[skb->queue_mapping];
 	return ixgbe_xmit_frame_ring(skb, adapter, tx_ring);

I don't think this will work. We need to update the skb->len and last I knew skb_padto doesn't do that.

Thanks,

Alex

#5 lore raw

PATCH 1/1 ixgbe: simplify padding and length checks (v2)

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.

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 -7
@@ -6380,17 +6380,12 @@ static netdev_tx_t ixgbe_xmit_frame(stru
 	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;
 	}
#6 lore raw

Re: [PATCH net-next] ixgbe: simplify padding and length checks (v2)

Quoted 8 lines · Stephen Hemminger

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.

I just realized I had not responded to this updated patch.

Thanks Stephen, I have dropped your previous 2 patch series and added this patch to my queue.