[NET]: qdisc_restart - couple of optimizations.
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / skbuff.h
CommitLineData
1da177e4
LT
1/*
2 * Definitions for the 'struct sk_buff' memory handlers.
3 *
4 * Authors:
5 * Alan Cox, <gw4pts@gw4pts.ampr.org>
6 * Florian La Roche, <rzsfl@rz.uni-sb.de>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef _LINUX_SKBUFF_H
15#define _LINUX_SKBUFF_H
16
1da177e4
LT
17#include <linux/kernel.h>
18#include <linux/compiler.h>
19#include <linux/time.h>
20#include <linux/cache.h>
21
22#include <asm/atomic.h>
23#include <asm/types.h>
24#include <linux/spinlock.h>
1da177e4 25#include <linux/net.h>
3fc7e8a6 26#include <linux/textsearch.h>
1da177e4 27#include <net/checksum.h>
a80958f4 28#include <linux/rcupdate.h>
97fc2f08 29#include <linux/dmaengine.h>
b7aa0bf7 30#include <linux/hrtimer.h>
1da177e4
LT
31
32#define HAVE_ALLOC_SKB /* For the drivers to know */
33#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
1da177e4 34
60476372 35/* Don't change this without changing skb_csum_unnecessary! */
1da177e4 36#define CHECKSUM_NONE 0
60476372
HX
37#define CHECKSUM_UNNECESSARY 1
38#define CHECKSUM_COMPLETE 2
39#define CHECKSUM_PARTIAL 3
1da177e4
LT
40
41#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
42 ~(SMP_CACHE_BYTES - 1))
fc910a27
DM
43#define SKB_WITH_OVERHEAD(X) \
44 (((X) - sizeof(struct skb_shared_info)) & \
45 ~(SMP_CACHE_BYTES - 1))
46#define SKB_MAX_ORDER(X, ORDER) \
47 SKB_WITH_OVERHEAD((PAGE_SIZE << (ORDER)) - (X))
1da177e4
LT
48#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
49#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
50
51/* A. Checksumming of received packets by device.
52 *
53 * NONE: device failed to checksum this packet.
54 * skb->csum is undefined.
55 *
56 * UNNECESSARY: device parsed packet and wouldbe verified checksum.
57 * skb->csum is undefined.
58 * It is bad option, but, unfortunately, many of vendors do this.
59 * Apparently with secret goal to sell you new device, when you
60 * will add new protocol to your host. F.e. IPv6. 8)
61 *
84fa7933 62 * COMPLETE: the most generic way. Device supplied checksum of _all_
1da177e4
LT
63 * the packet as seen by netif_rx in skb->csum.
64 * NOTE: Even if device supports only some protocols, but
84fa7933 65 * is able to produce some skb->csum, it MUST use COMPLETE,
1da177e4
LT
66 * not UNNECESSARY.
67 *
68 * B. Checksumming on output.
69 *
70 * NONE: skb is checksummed by protocol or csum is not required.
71 *
84fa7933 72 * PARTIAL: device is required to csum packet as seen by hard_start_xmit
b0e380b1
ACM
73 * from skb->transport_header to the end and to record the checksum
74 * at skb->transport_header + skb->csum.
1da177e4
LT
75 *
76 * Device must show its capabilities in dev->features, set
77 * at device setup time.
78 * NETIF_F_HW_CSUM - it is clever device, it is able to checksum
79 * everything.
80 * NETIF_F_NO_CSUM - loopback or reliable single hop media.
81 * NETIF_F_IP_CSUM - device is dumb. It is able to csum only
82 * TCP/UDP over IPv4. Sigh. Vendors like this
83 * way by an unknown reason. Though, see comment above
84 * about CHECKSUM_UNNECESSARY. 8)
85 *
86 * Any questions? No questions, good. --ANK
87 */
88
1da177e4 89struct net_device;
716ea3a7 90struct scatterlist;
1da177e4 91
5f79e0f9 92#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
1da177e4
LT
93struct nf_conntrack {
94 atomic_t use;
1da177e4 95};
5f79e0f9 96#endif
1da177e4
LT
97
98#ifdef CONFIG_BRIDGE_NETFILTER
99struct nf_bridge_info {
100 atomic_t use;
101 struct net_device *physindev;
102 struct net_device *physoutdev;
103#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
104 struct net_device *netoutdev;
105#endif
106 unsigned int mask;
107 unsigned long data[32 / sizeof(unsigned long)];
108};
109#endif
110
1da177e4
LT
111struct sk_buff_head {
112 /* These two members must be first. */
113 struct sk_buff *next;
114 struct sk_buff *prev;
115
116 __u32 qlen;
117 spinlock_t lock;
118};
119
120struct sk_buff;
121
122/* To allow 64K frame to be packed as single skb without frag_list */
123#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
124
125typedef struct skb_frag_struct skb_frag_t;
126
127struct skb_frag_struct {
128 struct page *page;
129 __u16 page_offset;
130 __u16 size;
131};
132
133/* This data is invariant across clones and lives at
134 * the end of the header data, ie. at skb->end.
135 */
136struct skb_shared_info {
137 atomic_t dataref;
4947d3ef 138 unsigned short nr_frags;
7967168c
HX
139 unsigned short gso_size;
140 /* Warning: this field is not always filled in (UFO)! */
141 unsigned short gso_segs;
142 unsigned short gso_type;
ae08e1f0 143 __be32 ip6_frag_id;
1da177e4
LT
144 struct sk_buff *frag_list;
145 skb_frag_t frags[MAX_SKB_FRAGS];
146};
147
148/* We divide dataref into two halves. The higher 16 bits hold references
149 * to the payload part of skb->data. The lower 16 bits hold references to
150 * the entire skb->data. It is up to the users of the skb to agree on
151 * where the payload starts.
152 *
153 * All users must obey the rule that the skb->data reference count must be
154 * greater than or equal to the payload reference count.
155 *
156 * Holding a reference to the payload part means that the user does not
157 * care about modifications to the header part of skb->data.
158 */
159#define SKB_DATAREF_SHIFT 16
160#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
161
d179cd12
DM
162
163enum {
164 SKB_FCLONE_UNAVAILABLE,
165 SKB_FCLONE_ORIG,
166 SKB_FCLONE_CLONE,
167};
168
7967168c
HX
169enum {
170 SKB_GSO_TCPV4 = 1 << 0,
f83ef8c0 171 SKB_GSO_UDP = 1 << 1,
576a30eb
HX
172
173 /* This indicates the skb is from an untrusted source. */
174 SKB_GSO_DODGY = 1 << 2,
b0da8537
MC
175
176 /* This indicates the tcp segment has CWR set. */
f83ef8c0
HX
177 SKB_GSO_TCP_ECN = 1 << 3,
178
179 SKB_GSO_TCPV6 = 1 << 4,
7967168c
HX
180};
181
2e07fa9c
ACM
182#if BITS_PER_LONG > 32
183#define NET_SKBUFF_DATA_USES_OFFSET 1
184#endif
185
186#ifdef NET_SKBUFF_DATA_USES_OFFSET
187typedef unsigned int sk_buff_data_t;
188#else
189typedef unsigned char *sk_buff_data_t;
190#endif
191
1da177e4
LT
192/**
193 * struct sk_buff - socket buffer
194 * @next: Next buffer in list
195 * @prev: Previous buffer in list
1da177e4 196 * @sk: Socket we are owned by
325ed823 197 * @tstamp: Time we arrived
1da177e4 198 * @dev: Device we arrived on/are leaving by
c01003c2 199 * @iif: ifindex of device we arrived on
be52178b 200 * @transport_header: Transport layer header
b0e380b1
ACM
201 * @network_header: Network layer header
202 * @mac_header: Link layer header
67be2dd1
MW
203 * @dst: destination entry
204 * @sp: the security path, used for xfrm
1da177e4
LT
205 * @cb: Control buffer. Free for use by every layer. Put private vars here
206 * @len: Length of actual data
207 * @data_len: Data length
208 * @mac_len: Length of link layer header
663ead3b
HX
209 * @csum: Checksum (must include start/offset pair)
210 * @csum_start: Offset from skb->head where checksumming should start
211 * @csum_offset: Offset from csum_start where checksum should be stored
67be2dd1 212 * @local_df: allow local fragmentation
1da177e4
LT
213 * @cloned: Head may be cloned (check refcnt to be sure)
214 * @nohdr: Payload reference only, must not modify header
215 * @pkt_type: Packet class
c83c2486 216 * @fclone: skbuff clone status
1da177e4
LT
217 * @ip_summed: Driver fed us an IP checksum
218 * @priority: Packet queueing priority
219 * @users: User count - see {datagram,tcp}.c
220 * @protocol: Packet protocol from driver
1da177e4
LT
221 * @truesize: Buffer size
222 * @head: Head of buffer
223 * @data: Data head pointer
224 * @tail: Tail pointer
225 * @end: End pointer
226 * @destructor: Destruct function
82e91ffe 227 * @mark: Generic packet mark
1da177e4 228 * @nfct: Associated connection, if any
c83c2486 229 * @ipvs_property: skbuff is owned by ipvs
1da177e4 230 * @nfctinfo: Relationship of this skb to the connection
461ddf3b 231 * @nfct_reasm: netfilter conntrack re-assembly pointer
1da177e4 232 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
1da177e4
LT
233 * @tc_index: Traffic control index
234 * @tc_verd: traffic control verdict
f4b8ea78
RD
235 * @dma_cookie: a cookie to one of several possible DMA operations
236 * done by skb DMA functions
984bc16c 237 * @secmark: security marking
1da177e4
LT
238 */
239
240struct sk_buff {
241 /* These two members must be first. */
242 struct sk_buff *next;
243 struct sk_buff *prev;
244
1da177e4 245 struct sock *sk;
b7aa0bf7 246 ktime_t tstamp;
1da177e4 247 struct net_device *dev;
c01003c2
PM
248 int iif;
249 /* 4 byte hole on 64 bit*/
1da177e4 250
1da177e4
LT
251 struct dst_entry *dst;
252 struct sec_path *sp;
253
254 /*
255 * This is the control buffer. It is free to use for every
256 * layer. Please put your private variables there. If you
257 * want to keep them across layers you have to do a skb_clone()
258 * first. This is owned by whoever has the skb queued ATM.
259 */
3e3850e9 260 char cb[48];
1da177e4
LT
261
262 unsigned int len,
263 data_len,
1f61ab5c 264 mac_len;
ff1dcadb
AV
265 union {
266 __wsum csum;
663ead3b
HX
267 struct {
268 __u16 csum_start;
269 __u16 csum_offset;
270 };
ff1dcadb 271 };
1da177e4 272 __u32 priority;
1cbb3380
TG
273 __u8 local_df:1,
274 cloned:1,
275 ip_summed:2,
6869c4d8
HW
276 nohdr:1,
277 nfctinfo:3;
d179cd12 278 __u8 pkt_type:3,
b84f4cc9
PM
279 fclone:2,
280 ipvs_property:1;
a0d3bea3 281 __be16 protocol;
1da177e4
LT
282
283 void (*destructor)(struct sk_buff *skb);
9fb9cbb1 284#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
5f79e0f9 285 struct nf_conntrack *nfct;
9fb9cbb1
YK
286 struct sk_buff *nfct_reasm;
287#endif
1da177e4
LT
288#ifdef CONFIG_BRIDGE_NETFILTER
289 struct nf_bridge_info *nf_bridge;
290#endif
1da177e4 291#ifdef CONFIG_NET_SCHED
b6b99eb5 292 __u16 tc_index; /* traffic control index */
1da177e4 293#ifdef CONFIG_NET_CLS_ACT
b6b99eb5 294 __u16 tc_verd; /* traffic control verdict */
1da177e4 295#endif
1da177e4 296#endif
97fc2f08
CL
297#ifdef CONFIG_NET_DMA
298 dma_cookie_t dma_cookie;
299#endif
984bc16c
JM
300#ifdef CONFIG_NETWORK_SECMARK
301 __u32 secmark;
302#endif
1da177e4 303
82e91ffe 304 __u32 mark;
1da177e4 305
27a884dc
ACM
306 sk_buff_data_t transport_header;
307 sk_buff_data_t network_header;
308 sk_buff_data_t mac_header;
1da177e4 309 /* These elements must be at the end, see alloc_skb() for details. */
27a884dc 310 sk_buff_data_t tail;
4305b541 311 sk_buff_data_t end;
1da177e4 312 unsigned char *head,
4305b541 313 *data;
27a884dc
ACM
314 unsigned int truesize;
315 atomic_t users;
1da177e4
LT
316};
317
318#ifdef __KERNEL__
319/*
320 * Handling routines are only of interest to the kernel
321 */
322#include <linux/slab.h>
323
324#include <asm/system.h>
325