Initial import
[openvswitch] / datapath / linux-2.4 / compat-2.4 / include / linux / skbuff.h
1 #ifndef __LINUX_SKBUFF_WRAPPER_H
2 #define __LINUX_SKBUFF_WRAPPER_H 1
3
4 #include_next <linux/skbuff.h>
5
6
7 #define mac_header mac.raw
8 #define network_header nh.raw
9
10 /* Emulate Linux 2.6 behavior, in which kfree_skb silently ignores null pointer
11  * arguments. */
12 #define kfree_skb(skb) kfree_skb_maybe_null(skb)
13 static inline void kfree_skb_maybe_null(struct sk_buff *skb) 
14 {
15         if (likely(skb != NULL))
16                 (kfree_skb)(skb);
17 }
18
19 /* Note that CHECKSUM_PARTIAL is not implemented, but this allows us to at
20  * least test against it: see update_csum() in forward.c. */
21 #define CHECKSUM_PARTIAL 3
22 #define CHECKSUM_COMPLETE CHECKSUM_HW
23
24 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
25 {
26         return skb->h.raw;
27 }
28
29 static inline void skb_reset_transport_header(struct sk_buff *skb)
30 {
31         skb->h.raw = skb->data;
32 }
33
34 static inline void skb_set_transport_header(struct sk_buff *skb,
35                                             const int offset)
36 {
37         skb->h.raw = skb->data + offset;
38 }
39
40 static inline unsigned char *skb_network_header(const struct sk_buff *skb)
41 {
42         return skb->nh.raw;
43 }
44
45 static inline void skb_reset_network_header(struct sk_buff *skb)
46 {
47         skb->nh.raw = skb->data;
48 }
49
50 static inline void skb_set_network_header(struct sk_buff *skb, const int offset)
51 {
52         skb->nh.raw = skb->data + offset;
53 }
54
55 static inline unsigned char *skb_mac_header(const struct sk_buff *skb)
56 {
57         return skb->mac.raw;
58 }
59
60 static inline int skb_mac_header_was_set(const struct sk_buff *skb)
61 {
62         return skb->mac.raw != NULL;
63 }
64
65 static inline void skb_reset_mac_header(struct sk_buff *skb)
66 {
67         skb->mac.raw = skb->data;
68 }
69
70 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
71 {
72         skb->mac.raw = skb->data + offset;
73 }
74 static inline int skb_transport_offset(const struct sk_buff *skb)
75 {
76         return skb_transport_header(skb) - skb->data;
77 }
78
79 static inline u32 skb_network_header_len(const struct sk_buff *skb)
80 {
81         return skb->h.raw - skb->nh.raw;
82 }
83
84 static inline int skb_network_offset(const struct sk_buff *skb)
85 {
86         return skb_network_header(skb) - skb->data;
87 }
88
89 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
90 {
91         return skb->tail;
92 }
93
94 static inline void skb_reset_tail_pointer(struct sk_buff *skb)
95 {
96         skb->tail = skb->data;
97 }
98
99 static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
100 {
101         skb->tail = skb->data + offset;
102 }
103
104 /*
105  * CPUs often take a performance hit when accessing unaligned memory
106  * locations. The actual performance hit varies, it can be small if the
107  * hardware handles it or large if we have to take an exception and fix it
108  * in software.
109  *
110  * Since an ethernet header is 14 bytes network drivers often end up with
111  * the IP header at an unaligned offset. The IP header can be aligned by
112  * shifting the start of the packet by 2 bytes. Drivers should do this
113  * with:
114  *
115  * skb_reserve(NET_IP_ALIGN);
116  *
117  * The downside to this alignment of the IP header is that the DMA is now
118  * unaligned. On some architectures the cost of an unaligned DMA is high
119  * and this cost outweighs the gains made by aligning the IP header.
120  *
121  * Since this trade off varies between architectures, we allow NET_IP_ALIGN
122  * to be overridden.
123  */
124 #ifndef NET_IP_ALIGN
125 #define NET_IP_ALIGN    2
126 #endif
127
128
129
130 #endif