Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[linux-drm-fsl-dcu.git] / include / linux / skbuff.h
index 215b5ea1cb302c43f0e8b9532fbe3ce59ff0f612..77c7aae1c6b20d7d72baff3fa0f6de05851b44ba 100644 (file)
@@ -2392,6 +2392,24 @@ static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
        return buffer;
 }
 
+/**
+ *     skb_needs_linearize - check if we need to linearize a given skb
+ *                           depending on the given device features.
+ *     @skb: socket buffer to check
+ *     @features: net device features
+ *
+ *     Returns true if either:
+ *     1. skb has frag_list and the device doesn't support FRAGLIST, or
+ *     2. skb is fragmented and the device does not support SG.
+ */
+static inline bool skb_needs_linearize(struct sk_buff *skb,
+                                      netdev_features_t features)
+{
+       return skb_is_nonlinear(skb) &&
+              ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
+               (skb_shinfo(skb)->nr_frags && !(features & NETIF_F_SG)));
+}
+
 static inline void skb_copy_from_linear_data(const struct sk_buff *skb,
                                             void *to,
                                             const unsigned int len)