]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ethernet/intel: Use eth_skb_pad and skb_put_padto helpers
authorAlexander Duyck <alexander.h.duyck@redhat.com>
Wed, 3 Dec 2014 16:17:39 +0000 (08:17 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Dec 2014 01:47:42 +0000 (20:47 -0500)
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: Alexander Duyck <alexander.h.duyck@redhat.com>
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/e1000/e1000_main.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/fm10k/fm10k_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

index 24f3986cfae2950f582d3a5e4644c4e1b666391e..862d1989ae1c4adc9ca61d2dfa4ae7a1d213f707 100644 (file)
@@ -3136,12 +3136,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
         * packets may get corrupted during padding by HW.
         * To WA this issue, pad all small packets manually.
         */
-       if (skb->len < ETH_ZLEN) {
-               if (skb_pad(skb, ETH_ZLEN - skb->len))
-                       return NETDEV_TX_OK;
-               skb->len = ETH_ZLEN;
-               skb_set_tail_pointer(skb, ETH_ZLEN);
-       }
+       if (eth_skb_pad(skb))
+               return NETDEV_TX_OK;
 
        mss = skb_shinfo(skb)->gso_size;
        /* The controller does a simple calculation to
index 370cfa275ddbd0638f874105e8b15e0eb9430cbd..88936aa0029d72c2a7af75ccd13f86faa545eece 100644 (file)
@@ -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
         * pad skb in order to meet this minimum size requirement
         */
-       if (unlikely(skb->len < 17)) {
-               if (skb_pad(skb, 17 - skb->len))
-                       return NETDEV_TX_OK;
-               skb->len = 17;
-               skb_set_tail_pointer(skb, 17);
-       }
+       if (skb_put_padto(skb, 17))
+               return NETDEV_TX_OK;
 
        mss = skb_shinfo(skb)->gso_size;
        if (mss) {
index 73457ede53ec93e03a858ffe6efae0db0d784120..91516aed373e1db04085a85fff02b6e41d604703 100644 (file)
@@ -578,14 +578,9 @@ static bool fm10k_cleanup_headers(struct fm10k_ring *rx_ring,
        if (skb_is_nonlinear(skb))
                fm10k_pull_tail(rx_ring, rx_desc, skb);
 
-       /* if skb_pad returns an error the skb was freed */
-       if (unlikely(skb->len < 60)) {
-               int pad_len = 60 - skb->len;
-
-               if (skb_pad(skb, pad_len))
-                       return true;
-               __skb_put(skb, pad_len);
-       }
+       /* if eth_skb_pad returns an error the skb was freed */
+       if (eth_skb_pad(skb))
+               return true;
 
        return false;
 }
index 3195d82e49425369951185ccc1e664a8485ea716..04b441460bbda6e36cb64731d24247a1b954e506 100644 (file)
@@ -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
         * beyond this point
         */
-       if (unlikely(skb->len < I40E_MIN_TX_LEN)) {
-               if (skb_pad(skb, I40E_MIN_TX_LEN - skb->len))
-                       return NETDEV_TX_OK;
-               skb->len = I40E_MIN_TX_LEN;
-               skb_set_tail_pointer(skb, I40E_MIN_TX_LEN);
-       }
+       if (skb_put_padto(skb, I40E_MIN_TX_LEN))
+               return NETDEV_TX_OK;
 
        return i40e_xmit_frame_ring(skb, tx_ring);
 }
index 3c0221620c9dc8abae3bf4edb06102475bd27df9..f04ad13f715980d6677820679d60670bbd122f10 100644 (file)
@@ -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
         * in order to meet this minimum size requirement.
         */
-       if (unlikely(skb->len < 17)) {
-               if (skb_pad(skb, 17 - skb->len))
-                       return NETDEV_TX_OK;
-               skb->len = 17;
-               skb_set_tail_pointer(skb, 17);
-       }
+       if (skb_put_padto(skb, 17))
+               return NETDEV_TX_OK;
 
        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,
        if (skb_is_nonlinear(skb))
                igb_pull_tail(rx_ring, rx_desc, skb);
 
-       /* if skb_pad returns an error the skb was freed */
-       if (unlikely(skb->len < 60)) {
-               int pad_len = 60 - skb->len;
-
-               if (skb_pad(skb, pad_len))
-                       return true;
-               __skb_put(skb, pad_len);
-       }
+       /* if eth_skb_pad returns an error the skb was freed */
+       if (eth_skb_pad(skb))
+               return true;
 
        return false;
 }
index 82d418729dd48c182162d37de78a3b5899183cb8..fbd52924ee34a2b8395fa5d8581129cf5c94ac2b 100644 (file)
@@ -1774,14 +1774,9 @@ static bool ixgbe_cleanup_headers(struct ixgbe_ring *rx_ring,
                return false;
 
 #endif
-       /* if skb_pad returns an error the skb was freed */
-       if (unlikely(skb->len < 60)) {
-               int pad_len = 60 - skb->len;
-
-               if (skb_pad(skb, pad_len))
-                       return true;
-               __skb_put(skb, pad_len);
-       }
+       /* if eth_skb_pad returns an error the skb was freed */
+       if (eth_skb_pad(skb))
+               return true;
 
        return false;
 }
@@ -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
         * in order to meet this minimum size requirement.
         */
-       if (unlikely(skb->len < 17)) {
-               if (skb_pad(skb, 17 - skb->len))
-                       return NETDEV_TX_OK;
-               skb->len = 17;
-               skb_set_tail_pointer(skb, 17);
-       }
+       if (skb_put_padto(skb, 17))
+               return NETDEV_TX_OK;
 
        tx_ring = ring ? ring : adapter->tx_ring[skb->queue_mapping];
 
index 3b0ddf757fb666f4ccc8c2825c7a4187244df642..62a0d8e0f17da5ce75d48f9ff39fca5354c4447f 100644 (file)
@@ -616,14 +616,9 @@ static bool ixgbevf_cleanup_headers(struct ixgbevf_ring *rx_ring,
        if (skb_is_nonlinear(skb))
                ixgbevf_pull_tail(rx_ring, skb);
 
-       /* if skb_pad returns an error the skb was freed */
-       if (unlikely(skb->len < 60)) {
-               int pad_len = 60 - skb->len;
-
-               if (skb_pad(skb, pad_len))
-                       return true;
-               __skb_put(skb, pad_len);
-       }
+       /* if eth_skb_pad returns an error the skb was freed */
+       if (eth_skb_pad(skb))
+               return true;
 
        return false;
 }