Commit a94d9e22 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

ethernet/intel: Use eth_skb_pad and skb_put_padto helpers

Update the Intel Ethernet drivers to use eth_skb_pad() and skb_put_padto
instead of doing their own implementations of the function.

Also this cleans up two other spots where skb_pad was called but the length
and tail pointers were being manipulated directly instead of just having
the padding length added via __skb_put.

Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@redhat.com>
Acked-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9c0c1124
...@@ -3136,12 +3136,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, ...@@ -3136,12 +3136,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
* packets may get corrupted during padding by HW. * packets may get corrupted during padding by HW.
* To WA this issue, pad all small packets manually. * To WA this issue, pad all small packets manually.
*/ */
if (skb->len < ETH_ZLEN) { if (eth_skb_pad(skb))
if (skb_pad(skb, ETH_ZLEN - skb->len)) return NETDEV_TX_OK;
return NETDEV_TX_OK;
skb->len = ETH_ZLEN;
skb_set_tail_pointer(skb, ETH_ZLEN);
}
mss = skb_shinfo(skb)->gso_size; mss = skb_shinfo(skb)->gso_size;
/* The controller does a simple calculation to /* The controller does a simple calculation to
......
...@@ -5554,12 +5554,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, ...@@ -5554,12 +5554,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
/* The minimum packet size with TCTL.PSP set is 17 bytes so /* The minimum packet size with TCTL.PSP set is 17 bytes so
* pad skb in order to meet this minimum size requirement * pad skb in order to meet this minimum size requirement
*/ */
if (unlikely(skb->len < 17)) { if (skb_put_padto(skb, 17))
if (skb_pad(skb, 17 - skb->len)) return NETDEV_TX_OK;
return NETDEV_TX_OK;
skb->len = 17;
skb_set_tail_pointer(skb, 17);
}
mss = skb_shinfo(skb)->gso_size; mss = skb_shinfo(skb)->gso_size;
if (mss) { if (mss) {
......
...@@ -578,14 +578,9 @@ static bool fm10k_cleanup_headers(struct fm10k_ring *rx_ring, ...@@ -578,14 +578,9 @@ static bool fm10k_cleanup_headers(struct fm10k_ring *rx_ring,
if (skb_is_nonlinear(skb)) if (skb_is_nonlinear(skb))
fm10k_pull_tail(rx_ring, rx_desc, skb); fm10k_pull_tail(rx_ring, rx_desc, skb);
/* if skb_pad returns an error the skb was freed */ /* if eth_skb_pad returns an error the skb was freed */
if (unlikely(skb->len < 60)) { if (eth_skb_pad(skb))
int pad_len = 60 - skb->len; return true;
if (skb_pad(skb, pad_len))
return true;
__skb_put(skb, pad_len);
}
return false; return false;
} }
......
...@@ -2399,12 +2399,8 @@ netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev) ...@@ -2399,12 +2399,8 @@ netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
/* hardware can't handle really short frames, hardware padding works /* hardware can't handle really short frames, hardware padding works
* beyond this point * beyond this point
*/ */
if (unlikely(skb->len < I40E_MIN_TX_LEN)) { if (skb_put_padto(skb, I40E_MIN_TX_LEN))
if (skb_pad(skb, I40E_MIN_TX_LEN - skb->len)) return NETDEV_TX_OK;
return NETDEV_TX_OK;
skb->len = I40E_MIN_TX_LEN;
skb_set_tail_pointer(skb, I40E_MIN_TX_LEN);
}
return i40e_xmit_frame_ring(skb, tx_ring); return i40e_xmit_frame_ring(skb, tx_ring);
} }
...@@ -5091,12 +5091,8 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb, ...@@ -5091,12 +5091,8 @@ static netdev_tx_t igb_xmit_frame(struct sk_buff *skb,
/* The minimum packet size with TCTL.PSP set is 17 so pad the skb /* The minimum packet size with TCTL.PSP set is 17 so pad the skb
* in order to meet this minimum size requirement. * in order to meet this minimum size requirement.
*/ */
if (unlikely(skb->len < 17)) { if (skb_put_padto(skb, 17))
if (skb_pad(skb, 17 - skb->len)) return NETDEV_TX_OK;
return NETDEV_TX_OK;
skb->len = 17;
skb_set_tail_pointer(skb, 17);
}
return igb_xmit_frame_ring(skb, igb_tx_queue_mapping(adapter, skb)); return igb_xmit_frame_ring(skb, igb_tx_queue_mapping(adapter, skb));
} }
...@@ -6850,14 +6846,9 @@ static bool igb_cleanup_headers(struct igb_ring *rx_ring, ...@@ -6850,14 +6846,9 @@ static bool igb_cleanup_headers(struct igb_ring *rx_ring,
if (skb_is_nonlinear(skb)) if (skb_is_nonlinear(skb))
igb_pull_tail(rx_ring, rx_desc, skb); igb_pull_tail(rx_ring, rx_desc, skb);
/* if skb_pad returns an error the skb was freed */ /* if eth_skb_pad returns an error the skb was freed */
if (unlikely(skb->len < 60)) { if (eth_skb_pad(skb))
int pad_len = 60 - skb->len; return true;
if (skb_pad(skb, pad_len))
return true;
__skb_put(skb, pad_len);
}
return false; return false;
} }
......
...@@ -1774,14 +1774,9 @@ static bool ixgbe_cleanup_headers(struct ixgbe_ring *rx_ring, ...@@ -1774,14 +1774,9 @@ static bool ixgbe_cleanup_headers(struct ixgbe_ring *rx_ring,
return false; return false;
#endif #endif
/* if skb_pad returns an error the skb was freed */ /* if eth_skb_pad returns an error the skb was freed */
if (unlikely(skb->len < 60)) { if (eth_skb_pad(skb))
int pad_len = 60 - skb->len; return true;
if (skb_pad(skb, pad_len))
return true;
__skb_put(skb, pad_len);
}
return false; return false;
} }
...@@ -7334,12 +7329,8 @@ static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb, ...@@ -7334,12 +7329,8 @@ static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb,
* The minimum packet size for olinfo paylen is 17 so pad the skb * The minimum packet size for olinfo paylen is 17 so pad the skb
* in order to meet this minimum size requirement. * in order to meet this minimum size requirement.
*/ */
if (unlikely(skb->len < 17)) { if (skb_put_padto(skb, 17))
if (skb_pad(skb, 17 - skb->len)) return NETDEV_TX_OK;
return NETDEV_TX_OK;
skb->len = 17;
skb_set_tail_pointer(skb, 17);
}
tx_ring = ring ? ring : adapter->tx_ring[skb->queue_mapping]; tx_ring = ring ? ring : adapter->tx_ring[skb->queue_mapping];
......
...@@ -616,14 +616,9 @@ static bool ixgbevf_cleanup_headers(struct ixgbevf_ring *rx_ring, ...@@ -616,14 +616,9 @@ static bool ixgbevf_cleanup_headers(struct ixgbevf_ring *rx_ring,
if (skb_is_nonlinear(skb)) if (skb_is_nonlinear(skb))
ixgbevf_pull_tail(rx_ring, skb); ixgbevf_pull_tail(rx_ring, skb);
/* if skb_pad returns an error the skb was freed */ /* if eth_skb_pad returns an error the skb was freed */
if (unlikely(skb->len < 60)) { if (eth_skb_pad(skb))
int pad_len = 60 - skb->len; return true;
if (skb_pad(skb, pad_len))
return true;
__skb_put(skb, pad_len);
}
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment