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.h52
1 files changed, 47 insertions, 5 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4307e764ef0a..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 *
@@ -1076,7 +1096,7 @@ static inline void __skb_queue_purge(struct sk_buff_head *list)
1076 * the headroom they think they need without accounting for the 1096 * the headroom they think they need without accounting for the
1077 * built in space. The built in space is used for optimisations. 1097 * built in space. The built in space is used for optimisations.
1078 * 1098 *
1079 * %NULL is returned in there is no free memory. 1099 * %NULL is returned if there is no free memory.
1080 */ 1100 */
1081static inline struct sk_buff *__dev_alloc_skb(unsigned int length, 1101static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1082 gfp_t gfp_mask) 1102 gfp_t gfp_mask)
@@ -1096,7 +1116,7 @@ static inline struct sk_buff *__dev_alloc_skb(unsigned int length,
1096 * the headroom they think they need without accounting for the 1116 * the headroom they think they need without accounting for the
1097 * built in space. The built in space is used for optimisations. 1117 * built in space. The built in space is used for optimisations.
1098 * 1118 *
1099 * %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
1100 * allocates memory it can be called from an interrupt. 1120 * allocates memory it can be called from an interrupt.
1101 */ 1121 */
1102static inline struct sk_buff *dev_alloc_skb(unsigned int length) 1122static inline struct sk_buff *dev_alloc_skb(unsigned int length)
@@ -1104,6 +1124,28 @@ static inline struct sk_buff *dev_alloc_skb(unsigned int length)
1104 return __dev_alloc_skb(length, GFP_ATOMIC); 1124 return __dev_alloc_skb(length, GFP_ATOMIC);
1105} 1125}
1106 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
1107/** 1149/**
1108 * skb_cow - copy header of skb when it is required 1150 * skb_cow - copy header of skb when it is required
1109 * @skb: buffer to cow 1151 * @skb: buffer to cow