Skip to content

Commit 90abde4

Browse files
Radu Pirea (NXP OSS)davem330
authored andcommitted
net: rename dsa_realloc_skb to skb_ensure_writable_head_tail
Rename dsa_realloc_skb to skb_ensure_writable_head_tail and move it to skbuff.c to use it as helper. Signed-off-by: Radu Pirea (NXP OSS) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c2b2ee3 commit 90abde4

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

include/linux/skbuff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4007,6 +4007,7 @@ struct sk_buff *skb_segment_list(struct sk_buff *skb, netdev_features_t features
40074007
unsigned int offset);
40084008
struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
40094009
int skb_ensure_writable(struct sk_buff *skb, unsigned int write_len);
4010+
int skb_ensure_writable_head_tail(struct sk_buff *skb, struct net_device *dev);
40104011
int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci);
40114012
int skb_vlan_pop(struct sk_buff *skb);
40124013
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);

net/core/skbuff.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5995,6 +5995,31 @@ int skb_ensure_writable(struct sk_buff *skb, unsigned int write_len)
59955995
}
59965996
EXPORT_SYMBOL(skb_ensure_writable);
59975997

5998+
int skb_ensure_writable_head_tail(struct sk_buff *skb, struct net_device *dev)
5999+
{
6000+
int needed_headroom = dev->needed_headroom;
6001+
int needed_tailroom = dev->needed_tailroom;
6002+
6003+
/* For tail taggers, we need to pad short frames ourselves, to ensure
6004+
* that the tail tag does not fail at its role of being at the end of
6005+
* the packet, once the conduit interface pads the frame. Account for
6006+
* that pad length here, and pad later.
6007+
*/
6008+
if (unlikely(needed_tailroom && skb->len < ETH_ZLEN))
6009+
needed_tailroom += ETH_ZLEN - skb->len;
6010+
/* skb_headroom() returns unsigned int... */
6011+
needed_headroom = max_t(int, needed_headroom - skb_headroom(skb), 0);
6012+
needed_tailroom = max_t(int, needed_tailroom - skb_tailroom(skb), 0);
6013+
6014+
if (likely(!needed_headroom && !needed_tailroom && !skb_cloned(skb)))
6015+
/* No reallocation needed, yay! */
6016+
return 0;
6017+
6018+
return pskb_expand_head(skb, needed_headroom, needed_tailroom,
6019+
GFP_ATOMIC);
6020+
}
6021+
EXPORT_SYMBOL(skb_ensure_writable_head_tail);
6022+
59986023
/* remove VLAN header from packet and update csum accordingly.
59996024
* expects a non skb_vlan_tag_present skb with a vlan tag payload
60006025
*/

net/dsa/user.c

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -920,30 +920,6 @@ netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev)
920920
}
921921
EXPORT_SYMBOL_GPL(dsa_enqueue_skb);
922922

923-
static int dsa_realloc_skb(struct sk_buff *skb, struct net_device *dev)
924-
{
925-
int needed_headroom = dev->needed_headroom;
926-
int needed_tailroom = dev->needed_tailroom;
927-
928-
/* For tail taggers, we need to pad short frames ourselves, to ensure
929-
* that the tail tag does not fail at its role of being at the end of
930-
* the packet, once the conduit interface pads the frame. Account for
931-
* that pad length here, and pad later.
932-
*/
933-
if (unlikely(needed_tailroom && skb->len < ETH_ZLEN))
934-
needed_tailroom += ETH_ZLEN - skb->len;
935-
/* skb_headroom() returns unsigned int... */
936-
needed_headroom = max_t(int, needed_headroom - skb_headroom(skb), 0);
937-
needed_tailroom = max_t(int, needed_tailroom - skb_tailroom(skb), 0);
938-
939-
if (likely(!needed_headroom && !needed_tailroom && !skb_cloned(skb)))
940-
/* No reallocation needed, yay! */
941-
return 0;
942-
943-
return pskb_expand_head(skb, needed_headroom, needed_tailroom,
944-
GFP_ATOMIC);
945-
}
946-
947923
static netdev_tx_t dsa_user_xmit(struct sk_buff *skb, struct net_device *dev)
948924
{
949925
struct dsa_user_priv *p = netdev_priv(dev);
@@ -956,13 +932,14 @@ static netdev_tx_t dsa_user_xmit(struct sk_buff *skb, struct net_device *dev)
956932
/* Handle tx timestamp if any */
957933
dsa_skb_tx_timestamp(p, skb);
958934

959-
if (dsa_realloc_skb(skb, dev)) {
935+
if (skb_ensure_writable_head_tail(skb, dev)) {
960936
dev_kfree_skb_any(skb);
961937
return NETDEV_TX_OK;
962938
}
963939

964940
/* needed_tailroom should still be 'warm' in the cache line from
965-
* dsa_realloc_skb(), which has also ensured that padding is safe.
941+
* skb_ensure_writable_head_tail(), which has also ensured that
942+
* padding is safe.
966943
*/
967944
if (dev->needed_tailroom)
968945
eth_skb_pad(skb);

0 commit comments

Comments
 (0)