[I/OAT]: Utility functions for offloading sk_buff to iovec copies
[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
17#include <linux/config.h>
18#include <linux/kernel.h>
19#include <linux/compiler.h>
20#include <linux/time.h>
21#include <linux/cache.h>
22
23#include <asm/atomic.h>
24#include <asm/types.h>
25#include <linux/spinlock.h>
26#include <linux/mm.h>
27#include <linux/highmem.h>
28#include <linux/poll.h>
29#include <linux/net.h>
3fc7e8a6 30#include <linux/textsearch.h>
1da177e4
LT
31#include <net/checksum.h>
32
33#define HAVE_ALLOC_SKB /* For the drivers to know */
34#define HAVE_ALIGNABLE_SKB /* Ditto 8) */
1da177e4
LT
35
36#define CHECKSUM_NONE 0
37#define CHECKSUM_HW 1
38#define CHECKSUM_UNNECESSARY 2
39
40#define SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \
41 ~(SMP_CACHE_BYTES - 1))
42#define SKB_MAX_ORDER(X, ORDER) (((PAGE_SIZE << (ORDER)) - (X) - \
43 sizeof(struct skb_shared_info)) & \
44 ~(SMP_CACHE_BYTES - 1))
45#define SKB_MAX_HEAD(X) (SKB_MAX_ORDER((X), 0))
46#define SKB_MAX_ALLOC (SKB_MAX_ORDER(0, 2))
47
48/* A. Checksumming of received packets by device.
49 *
50 * NONE: device failed to checksum this packet.
51 * skb->csum is undefined.
52 *
53 * UNNECESSARY: device parsed packet and wouldbe verified checksum.
54 * skb->csum is undefined.
55 * It is bad option, but, unfortunately, many of vendors do this.
56 * Apparently with secret goal to sell you new device, when you
57 * will add new protocol to your host. F.e. IPv6. 8)
58 *
59 * HW: the most generic way. Device supplied checksum of _all_
60 * the packet as seen by netif_rx in skb->csum.
61 * NOTE: Even if device supports only some protocols, but
62 * is able to produce some skb->csum, it MUST use HW,
63 * not UNNECESSARY.
64 *
65 * B. Checksumming on output.
66 *
67 * NONE: skb is checksummed by protocol or csum is not required.
68 *
69 * HW: device is required to csum packet as seen by hard_start_xmit
70 * from skb->h.raw to the end and to record the checksum
71 * at skb->h.raw+skb->csum.
72 *
73 * Device must show its capabilities in dev->features, set
74 * at device setup time.
75 * NETIF_F_HW_CSUM - it is clever device, it is able to checksum
76 * everything.
77 * NETIF_F_NO_CSUM - loopback or reliable single hop media.
78 * NETIF_F_IP_CSUM - device is dumb. It is able to csum only
79 * TCP/UDP over IPv4. Sigh. Vendors like this
80 * way by an unknown reason. Though, see comment above
81 * about CHECKSUM_UNNECESSARY. 8)
82 *
83 * Any questions? No questions, good. --ANK
84 */
85
1da177e4
LT
86struct net_device;
87
88#ifdef CONFIG_NETFILTER
89struct nf_conntrack {
90 atomic_t use;
91 void (*destroy)(struct nf_conntrack *);
92};
93
94#ifdef CONFIG_BRIDGE_NETFILTER
95struct nf_bridge_info {
96 atomic_t use;
97 struct net_device *physindev;
98 struct net_device *physoutdev;
99#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
100 struct net_device *netoutdev;
101#endif
102 unsigned int mask;
103 unsigned long data[32 / sizeof(unsigned long)];
104};
105#endif
106
107#endif
108
109struct sk_buff_head {
110 /* These two members must be first. */
111 struct sk_buff *next;
112 struct sk_buff *prev;
113
114 __u32 qlen;
115 spinlock_t lock;
116};
117
118struct sk_buff;
119
120/* To allow 64K frame to be packed as single skb without frag_list */
121#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
122
123typedef struct skb_frag_struct skb_frag_t;
124
125struct skb_frag_struct {
126 struct page *page;
127 __u16 page_offset;
128 __u16 size;
129};
130
131/* This data is invariant across clones and lives at
132 * the end of the header data, ie. at skb->end.
133 */
134struct skb_shared_info {
135 atomic_t dataref;
4947d3ef 136 unsigned short nr_frags;
1da177e4
LT
137 unsigned short tso_size;
138 unsigned short tso_segs;
e89e9cf5
AR
139 unsigned short ufo_size;
140 unsigned int ip6_frag_id;
1da177e4
LT
141 struct sk_buff *frag_list;
142 skb_frag_t frags[MAX_SKB_FRAGS];
143};
144
145/* We divide dataref into two halves. The higher 16 bits hold references
146 * to the payload part of skb->data. The lower 16 bits hold references to
147 * the entire skb->data. It is up to the users of the skb to agree on
148 * where the payload starts.
149 *
150 * All users must obey the rule that the skb->data reference count must be
151 * greater than or equal to the payload reference count.
152 *
153 * Holding a reference to the payload part means that the user does not
154 * care about modifications to the header part of skb->data.
155 */
156#define SKB_DATAREF_SHIFT 16
157#define SKB_DATAREF_MASK ((1 << SKB_DATAREF_SHIFT) - 1)
158
a61bbcf2
PM
159struct skb_timeval {
160 u32 off_sec;
161 u32 off_usec;
162};
163
d179cd12
DM
164
165enum {
166 SKB_FCLONE_UNAVAILABLE,
167 SKB_FCLONE_ORIG,
168 SKB_FCLONE_CLONE,
169};
170
1da177e4
LT
171/**
172 * struct sk_buff - socket buffer
173 * @next: Next buffer in list
174 * @prev: Previous buffer in list
1da177e4 175 * @sk: Socket we are owned by
325ed823 176 * @tstamp: Time we arrived
1da177e4
LT
177 * @dev: Device we arrived on/are leaving by
178 * @input_dev: Device we arrived on
1da177e4
LT
179 * @h: Transport layer header
180 * @nh: Network layer header
181 * @mac: Link layer header
67be2dd1
MW
182 * @dst: destination entry
183 * @sp: the security path, used for xfrm
1da177e4
LT
184 * @cb: Control buffer. Free for use by every layer. Put private vars here
185 * @len: Length of actual data
186 * @data_len: Data length
187 * @mac_len: Length of link layer header
188 * @csum: Checksum
67be2dd1 189 * @local_df: allow local fragmentation
1da177e4
LT
190 * @cloned: Head may be cloned (check refcnt to be sure)
191 * @nohdr: Payload reference only, must not modify header
192 * @pkt_type: Packet class
c83c2486 193 * @fclone: skbuff clone status
1da177e4
LT
194 * @ip_summed: Driver fed us an IP checksum
195 * @priority: Packet queueing priority
196 * @users: User count - see {datagram,tcp}.c
197 * @protocol: Packet protocol from driver
1da177e4
LT
198 * @truesize: Buffer size
199 * @head: Head of buffer
200 * @data: Data head pointer
201 * @tail: Tail pointer
202 * @end: End pointer
203 * @destructor: Destruct function
204 * @nfmark: Can be used for communication between hooks
1da177e4 205 * @nfct: Associated connection, if any
c83c2486 206 * @ipvs_property: skbuff is owned by ipvs
1da177e4 207 * @nfctinfo: Relationship of this skb to the connection
461ddf3b 208 * @nfct_reasm: netfilter conntrack re-assembly pointer
1da177e4 209 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
1da177e4
LT
210 * @tc_index: Traffic control index
211 * @tc_verd: traffic control verdict
1da177e4
LT
212 */
213
214struct sk_buff {
215 /* These two members must be first. */
216 struct sk_buff *next;
217 struct sk_buff *prev;
218
1da177e4 219 struct sock *sk;
a61bbcf2 220 struct skb_timeval tstamp;
1da177e4
LT
221 struct net_device *dev;
222 struct net_device *input_dev;
1da177e4
LT
223
224 union {
225 struct tcphdr *th;
226 struct udphdr *uh;
227 struct icmphdr *icmph;
228 struct igmphdr *igmph;
229 struct iphdr *ipiph;
230 struct ipv6hdr *ipv6h;
231 unsigned char *raw;
232 } h;
233
234 union {
235 struct iphdr *iph;
236 struct ipv6hdr *ipv6h;
237 struct arphdr *arph;
238 unsigned char *raw;
239 } nh;
240
241 union {
242 unsigned char *raw;
243 } mac;
244
245 struct dst_entry *dst;
246 struct sec_path *sp;
247
248 /*
249 * This is the control buffer. It is free to use for every
250 * layer. Please put your private variables there. If you
251 * want to keep them across layers you have to do a skb_clone()
252 * first. This is owned by whoever has the skb queued ATM.
253 */
3e3850e9 254 char cb[48];
1da177e4
LT
255
256 unsigned int len,
257 data_len,
258 mac_len,
259 csum;
1da177e4 260 __u32 priority;
1cbb3380
TG
261 __u8 local_df:1,
262 cloned:1,
263 ip_summed:2,
6869c4d8
HW
264 nohdr:1,
265 nfctinfo:3;
d179cd12 266 __u8 pkt_type:3,
b84f4cc9
PM
267 fclone:2,
268 ipvs_property:1;
a0d3bea3 269 __be16 protocol;
1da177e4
LT
270
271 void (*destructor)(struct sk_buff *skb);
272#ifdef CONFIG_NETFILTER
1da177e4 273 struct nf_conntrack *nfct;
9fb9cbb1
YK
274#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
275 struct sk_buff *nfct_reasm;
276#endif
1da177e4
LT
277#ifdef CONFIG_BRIDGE_NETFILTER
278 struct nf_bridge_info *nf_bridge;
279#endif
77d2ca35 280 __u32 nfmark;
1da177e4 281#endif /* CONFIG_NETFILTER */
1da177e4 282#ifdef CONFIG_NET_SCHED
b6b99eb5 283 __u16 tc_index; /* traffic control index */
1da177e4 284#ifdef CONFIG_NET_CLS_ACT
b6b99eb5 285 __u16 tc_verd; /* traffic control verdict */
1da177e4 286#endif
1da177e4
LT
287#endif
288
289
290 /* These elements must be at the end, see alloc_skb() for details. */
291 unsigned int truesize;
292 atomic_t users;
293 unsigned char *head,
294 *data,
295 *tail,
296 *end;
297};
298
299#ifdef __KERNEL__
300/*
301 * Handling routines are only of interest to the kernel
302 */
303#include <linux/slab.h>
304
305#include <asm/system.h>
306