aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/skbuff.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r--include/linux/skbuff.h65
1 files changed, 54 insertions, 11 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 3597b4f14389..755e9cddac47 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -604,12 +604,17 @@ static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
604 return list_->qlen; 604 return list_->qlen;
605} 605}
606 606
607extern struct lock_class_key skb_queue_lock_key; 607/*
608 608 * This function creates a split out lock class for each invocation;
609 * this is needed for now since a whole lot of users of the skb-queue
610 * infrastructure in drivers have different locking usage (in hardirq)
611 * than the networking core (in softirq only). In the long run either the
612 * network layer or drivers should need annotation to consolidate the
613 * main types of usage into 3 classes.
614 */
609static inline void skb_queue_head_init(struct sk_buff_head *list) 615static inline void skb_queue_head_init(struct sk_buff_head *list)
610{ 616{
611 spin_lock_init(&list->lock); 617 spin_lock_init(&list->lock);
612 lockdep_set_class(&list->lock, &skb_queue_lock_key);
613 list->prev = list->next = (struct sk_buff *)list; 618 list->prev = list->next = (struct sk_buff *)list;
614 list->qlen = 0; 619 list->qlen = 0;
615} 620}
@@ -1035,6 +1040,21 @@ static inline int pskb_trim(struct sk_buff *skb, unsigned int len)
1035} 1040}
1036 1041
1037/** 1042/**
1043 * pskb_trim_unique - remove end from a paged unique (not cloned) buffer
1044 * @skb: buffer to alter
1045 * @len: new length
1046 *
1047 * This is identical to pskb_trim except that the caller knows that
1048 * the skb is not cloned so we should never get an error due to out-
1049 * of-memory.
1050 */
1051static inline void pskb_trim_unique(struct sk_buff *skb, unsigned int len)
1052{
1053 int err = pskb_trim(skb, len);
1054 BUG_ON(err);
1055}
1056
1057/**
1038 * skb_orphan - orphan a buffer 1058 * skb_orphan - orphan a buffer
1039 * @skb: buffer to orphan 1059 * @skb: buffer to orphan
1040 * 1060 *
@@ -1066,9 +1086,8 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
1066 kfree_skb(skb); 1086 kfree_skb(skb);
1067} 1087}
1068 1088
1069#ifndef CONFIG_HAVE_ARCH_DEV_ALLOC_SKB
1070/** 1089/**
1071 * __dev_alloc_skb - allocate an skbuff for sending 1090 * __dev_alloc_skb - allocate an skbuff for receiving
1072 * @length: length to allocate 1091 * @length: length to allocate
1073 * @gfp_mask: get_free_pages mask, passed to alloc_skb 1092 * @gfp_mask: get_free_pages mask, passed to alloc_skb
1074 * 1093 *
@@ -1077,7 +1096,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
1077 * the headroom they think they need without accounting for the 1096 * the headroom they think they need without accounting for the
1078 * built in space. The built in space is used for optimisations. 1097 * built in space. The built in space is used for optimisations.
1079 * 1098 *
1080 * %NULL is returned in there is no free memory. 1099 * %NULL is returned if there is no free memory.
1081 */ 1100 */
1082static inline struct sk_buff *__dev_alloc_skb(unsigned int length, 1101static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1083 gfp_t gfp_mask) 1102 gfp_t gfp_mask)
@@ -1087,12 +1106,9 @@ static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1087 skb_reserve(skb, NET_SKB_PAD); 1106 skb_reserve(skb, NET_SKB_PAD);
1088 return skb; 1107 return skb;
1089} 1108}
1090#else
1091extern struct sk_buff *__dev_alloc_skb(unsigned int length, int gfp_mask);
1092#endif
1093 1109
1094/** 1110/**
1095 * dev_alloc_skb - allocate an skbuff for sending 1111 * dev_alloc_skb - allocate an skbuff for receiving
1096 * @length: length to allocate 1112 * @length: length to allocate
1097 * 1113 *
1098 * Allocate a new &sk_buff and assign it a usage count of one. The 1114 * Allocate a new &sk_buff and assign it a usage count of one. The
@@ -1100,7 +1116,7 @@ extern struct sk_buff *__dev_alloc_skb(unsigned int length, int gfp_mask);
1100 * the headroom they think they need without accounting for the 1116 * the headroom they think they need without accounting for the
1101 * built in space. The built in space is used for optimisations. 1117 * built in space. The built in space is used for optimisations.
1102 * 1118 *
1103 * %NULL is returned in there is no free memory. Although this function 1119 * %NULL is returned if there is no free memory. Although this function
1104 * allocates memory it can be called from an interrupt. 1120 * allocates memory it can be called from an interrupt.
1105 */ 1121 */
1106static inline struct sk_buff *dev_alloc_skb(unsigned int length) 1122static inline struct sk_buff *dev_alloc_skb(unsigned int length)
@@ -1108,6 +1124,28 @@ static inline struct sk_buff *dev_alloc_skb(unsigned int length)
1108 return __dev_alloc_skb(length, GFP_ATOMIC); 1124 return __dev_alloc_skb(length, GFP_ATOMIC);
1109} 1125}
1110 1126
1127extern struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
1128 unsigned int length, gfp_t gfp_mask);
1129
1130/**
1131 * netdev_alloc_skb - allocate an skbuff for rx on a specific device
1132 * @dev: network device to receive on
1133 * @length: length to allocate
1134 *
1135 * Allocate a new &sk_buff and assign it a usage count of one. The
1136 * buffer has unspecified headroom built in. Users should allocate
1137 * the headroom they think they need without accounting for the
1138 * built in space. The built in space is used for optimisations.
1139 *
1140 * %NULL is returned if there is no free memory. Although this function
1141 * allocates memory it can be called from an interrupt.
1142 */
1143static inline struct sk_buff *netdev_alloc_skb(struct net_device *dev,
1144 unsigned int length)
1145{
1146 return __netdev_alloc_skb(dev, length, GFP_ATOMIC);
1147}
1148
1111/** 1149/**
1112 * skb_cow - copy header of skb when it is required 1150 * skb_cow - copy header of skb when it is required
1113 * @skb: buffer to cow 1151 * @skb: buffer to cow
@@ -1455,5 +1493,10 @@ static inline void skb_init_secmark(struct sk_buff *skb)
1455{ } 1493{ }
1456#endif 1494#endif
1457 1495
1496static inline int skb_is_gso(const struct sk_buff *skb)
1497{
1498 return skb_shinfo(skb)->gso_size;
1499}
1500
1458#endif /* __KERNEL__ */ 1501#endif /* __KERNEL__ */
1459#endif /* _LINUX_SKBUFF_H */ 1502#endif /* _LINUX_SKBUFF_H */