Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/include/linux/if_vlan.h (Version 2.6.31.13) and /linux/include/linux/if_vlan.h (Version 2.6.25.8)


  1 /*                                                  1 /*
  2  * VLAN         An implementation of 802.1Q VL      2  * VLAN         An implementation of 802.1Q VLAN tagging.
  3  *                                                  3  *
  4  * Authors:     Ben Greear <greearb@candelatec      4  * Authors:     Ben Greear <greearb@candelatech.com>
  5  *                                                  5  *
  6  *              This program is free software;      6  *              This program is free software; you can redistribute it and/or
  7  *              modify it under the terms of t      7  *              modify it under the terms of the GNU General Public License
  8  *              as published by the Free Softw      8  *              as published by the Free Software Foundation; either version
  9  *              2 of the License, or (at your       9  *              2 of the License, or (at your option) any later version.
 10  *                                                 10  *
 11  */                                                11  */
 12                                                    12 
 13 #ifndef _LINUX_IF_VLAN_H_                          13 #ifndef _LINUX_IF_VLAN_H_
 14 #define _LINUX_IF_VLAN_H_                          14 #define _LINUX_IF_VLAN_H_
 15                                                    15 
 16 #ifdef __KERNEL__                                  16 #ifdef __KERNEL__
                                                   >>  17 
                                                   >>  18 /* externally defined structs */
                                                   >>  19 struct hlist_node;
                                                   >>  20 
 17 #include <linux/netdevice.h>                       21 #include <linux/netdevice.h>
 18 #include <linux/etherdevice.h>                     22 #include <linux/etherdevice.h>
 19                                                    23 
 20 #define VLAN_HLEN       4               /* The     24 #define VLAN_HLEN       4               /* The additional bytes (on top of the Ethernet header)
 21                                          * tha     25                                          * that VLAN requires.
 22                                          */        26                                          */
 23 #define VLAN_ETH_ALEN   6               /* Oct     27 #define VLAN_ETH_ALEN   6               /* Octets in one ethernet addr   */
 24 #define VLAN_ETH_HLEN   18              /* Tot     28 #define VLAN_ETH_HLEN   18              /* Total octets in header.       */
 25 #define VLAN_ETH_ZLEN   64              /* Min     29 #define VLAN_ETH_ZLEN   64              /* Min. octets in frame sans FCS */
 26                                                    30 
 27 /*                                                 31 /*
 28  * According to 802.3ac, the packet can be 4 b     32  * According to 802.3ac, the packet can be 4 bytes longer. --Klika Jan
 29  */                                                33  */
 30 #define VLAN_ETH_DATA_LEN       1500    /* Max     34 #define VLAN_ETH_DATA_LEN       1500    /* Max. octets in payload        */
 31 #define VLAN_ETH_FRAME_LEN      1518    /* Max     35 #define VLAN_ETH_FRAME_LEN      1518    /* Max. octets in frame sans FCS */
 32                                                    36 
 33 /*                                                 37 /*
 34  *      struct vlan_hdr - vlan header              38  *      struct vlan_hdr - vlan header
 35  *      @h_vlan_TCI: priority and VLAN ID          39  *      @h_vlan_TCI: priority and VLAN ID
 36  *      @h_vlan_encapsulated_proto: packet typ     40  *      @h_vlan_encapsulated_proto: packet type ID or len
 37  */                                                41  */
 38 struct vlan_hdr {                                  42 struct vlan_hdr {
 39         __be16  h_vlan_TCI;                        43         __be16  h_vlan_TCI;
 40         __be16  h_vlan_encapsulated_proto;         44         __be16  h_vlan_encapsulated_proto;
 41 };                                                 45 };
 42                                                    46 
 43 /**                                                47 /**
 44  *      struct vlan_ethhdr - vlan ethernet hea     48  *      struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
 45  *      @h_dest: destination ethernet address      49  *      @h_dest: destination ethernet address
 46  *      @h_source: source ethernet address         50  *      @h_source: source ethernet address
 47  *      @h_vlan_proto: ethernet protocol (alwa     51  *      @h_vlan_proto: ethernet protocol (always 0x8100)
 48  *      @h_vlan_TCI: priority and VLAN ID          52  *      @h_vlan_TCI: priority and VLAN ID
 49  *      @h_vlan_encapsulated_proto: packet typ     53  *      @h_vlan_encapsulated_proto: packet type ID or len
 50  */                                                54  */
 51 struct vlan_ethhdr {                               55 struct vlan_ethhdr {
 52         unsigned char   h_dest[ETH_ALEN];          56         unsigned char   h_dest[ETH_ALEN];
 53         unsigned char   h_source[ETH_ALEN];        57         unsigned char   h_source[ETH_ALEN];
 54         __be16          h_vlan_proto;              58         __be16          h_vlan_proto;
 55         __be16          h_vlan_TCI;                59         __be16          h_vlan_TCI;
 56         __be16          h_vlan_encapsulated_pr     60         __be16          h_vlan_encapsulated_proto;
 57 };                                                 61 };
 58                                                    62 
 59 #include <linux/skbuff.h>                          63 #include <linux/skbuff.h>
 60                                                    64 
 61 static inline struct vlan_ethhdr *vlan_eth_hdr     65 static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
 62 {                                                  66 {
 63         return (struct vlan_ethhdr *)skb_mac_h     67         return (struct vlan_ethhdr *)skb_mac_header(skb);
 64 }                                                  68 }
 65                                                    69 
 66 #define VLAN_VID_MASK   0xfff                      70 #define VLAN_VID_MASK   0xfff
 67                                                    71 
 68 /* found in socket.c */                            72 /* found in socket.c */
 69 extern void vlan_ioctl_set(int (*hook)(struct      73 extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
 70                                                    74 
 71 /* if this changes, algorithm will have to be      75 /* if this changes, algorithm will have to be reworked because this
 72  * depends on completely exhausting the VLAN i     76  * depends on completely exhausting the VLAN identifier space.  Thus
 73  * it gives constant time look-up, but in many     77  * it gives constant time look-up, but in many cases it wastes memory.
 74  */                                                78  */
 75 #define VLAN_GROUP_ARRAY_LEN          4096         79 #define VLAN_GROUP_ARRAY_LEN          4096
 76 #define VLAN_GROUP_ARRAY_SPLIT_PARTS  8            80 #define VLAN_GROUP_ARRAY_SPLIT_PARTS  8
 77 #define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_GR     81 #define VLAN_GROUP_ARRAY_PART_LEN     (VLAN_GROUP_ARRAY_LEN/VLAN_GROUP_ARRAY_SPLIT_PARTS)
 78                                                    82 
 79 struct vlan_group {                                83 struct vlan_group {
 80         struct net_device       *real_dev; /*  !!  84         int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
 81                                             *  << 
 82                                             */ << 
 83         unsigned int            nr_vlans;          85         unsigned int            nr_vlans;
 84         struct hlist_node       hlist;  /* lin     86         struct hlist_node       hlist;  /* linked list */
 85         struct net_device **vlan_devices_array     87         struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
 86         struct rcu_head         rcu;               88         struct rcu_head         rcu;
 87 };                                                 89 };
 88                                                    90 
 89 static inline struct net_device *vlan_group_ge     91 static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
 90                                                !!  92                                                        unsigned int vlan_id)
 91 {                                                  93 {
 92         struct net_device **array;                 94         struct net_device **array;
 93         array = vg->vlan_devices_arrays[vlan_i     95         array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
 94         return array ? array[vlan_id % VLAN_GR !!  96         return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN];
 95 }                                                  97 }
 96                                                    98 
 97 static inline void vlan_group_set_device(struc     99 static inline void vlan_group_set_device(struct vlan_group *vg,
 98                                          u16 v !! 100                                          unsigned int vlan_id,
 99                                          struc    101                                          struct net_device *dev)
100 {                                                 102 {
101         struct net_device **array;                103         struct net_device **array;
102         if (!vg)                                  104         if (!vg)
103                 return;                           105                 return;
104         array = vg->vlan_devices_arrays[vlan_i    106         array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
105         array[vlan_id % VLAN_GROUP_ARRAY_PART_    107         array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
106 }                                                 108 }
107                                                   109 
108 #define vlan_tx_tag_present(__skb)      ((__sk !! 110 struct vlan_priority_tci_mapping {
109 #define vlan_tx_tag_get(__skb)          ((__sk !! 111         u32 priority;
110                                                !! 112         unsigned short vlan_qos; /* This should be shifted when first set, so we only do it
111 #if defined(CONFIG_VLAN_8021Q) || defined(CONF !! 113                                   * at provisioning time.
112 extern struct net_device *vlan_dev_real_dev(co !! 114                                   * ((skb->priority << 13) & 0xE000)
113 extern u16 vlan_dev_vlan_id(const struct net_d !! 115                                   */
                                                   >> 116         struct vlan_priority_tci_mapping *next;
                                                   >> 117 };
114                                                   118 
115 extern int __vlan_hwaccel_rx(struct sk_buff *s !! 119 /* Holds information that makes sense if this device is a VLAN device. */
116                              u16 vlan_tci, int !! 120 struct vlan_dev_info {
117 extern int vlan_hwaccel_do_receive(struct sk_b !! 121         /** This will be the mapping that correlates skb->priority to
118 extern int vlan_gro_receive(struct napi_struct !! 122          * 3 bits of VLAN QOS tags...
119                             unsigned int vlan_ !! 123          */
120 extern int vlan_gro_frags(struct napi_struct * !! 124         unsigned int nr_ingress_mappings;
121                           unsigned int vlan_tc !! 125         u32 ingress_priority_map[8];
                                                   >> 126 
                                                   >> 127         unsigned int nr_egress_mappings;
                                                   >> 128         struct vlan_priority_tci_mapping *egress_priority_map[16]; /* hash table */
                                                   >> 129 
                                                   >> 130         unsigned short vlan_id;        /*  The VLAN Identifier for this interface. */
                                                   >> 131         unsigned short flags;          /* (1 << 0) re_order_header   This option will cause the
                                                   >> 132                                         *   VLAN code to move around the ethernet header on
                                                   >> 133                                         *   ingress to make the skb look **exactly** like it
                                                   >> 134                                         *   came in from an ethernet port.  This destroys some of
                                                   >> 135                                         *   the VLAN information in the skb, but it fixes programs
                                                   >> 136                                         *   like DHCP that use packet-filtering and don't understand
                                                   >> 137                                         *   802.1Q
                                                   >> 138                                         */
                                                   >> 139         struct net_device *real_dev;    /* the underlying device/interface */
                                                   >> 140         unsigned char real_dev_addr[ETH_ALEN];
                                                   >> 141         struct proc_dir_entry *dent;    /* Holds the proc data */
                                                   >> 142         unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
                                                   >> 143         unsigned long cnt_encap_on_xmit;      /* How many times did we have to encapsulate the skb on TX. */
                                                   >> 144 };
122                                                   145 
123 #else                                          !! 146 static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
124 static inline struct net_device *vlan_dev_real << 
125 {                                                 147 {
126         BUG();                                 !! 148         return netdev_priv(dev);
127         return NULL;                           << 
128 }                                                 149 }
129                                                   150 
130 static inline u16 vlan_dev_vlan_id(const struc !! 151 /* inline functions */
                                                   >> 152 static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
                                                   >> 153                                               unsigned short vlan_tag)
131 {                                                 154 {
132         BUG();                                 !! 155         struct vlan_dev_info *vip = vlan_dev_info(dev);
133         return 0;                              << 
134 }                                              << 
135                                                   156 
136 static inline int __vlan_hwaccel_rx(struct sk_ !! 157         return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
137                                     u16 vlan_t << 
138 {                                              << 
139         BUG();                                 << 
140         return NET_XMIT_SUCCESS;               << 
141 }                                                 158 }
142                                                   159 
143 static inline int vlan_hwaccel_do_receive(stru !! 160 /* VLAN tx hw acceleration helpers. */
144 {                                              !! 161 struct vlan_skb_tx_cookie {
145         return 0;                              !! 162         u32     magic;
146 }                                              !! 163         u32     vlan_tag;
                                                   >> 164 };
147                                                   165 
148 static inline int vlan_gro_receive(struct napi !! 166 #define VLAN_TX_COOKIE_MAGIC    0x564c414e      /* "VLAN" in ascii. */
149                                    struct vlan !! 167 #define VLAN_TX_SKB_CB(__skb)   ((struct vlan_skb_tx_cookie *)&((__skb)->cb[0]))
150                                    unsigned in !! 168 #define vlan_tx_tag_present(__skb) \
151 {                                              !! 169         (VLAN_TX_SKB_CB(__skb)->magic == VLAN_TX_COOKIE_MAGIC)
152         return NET_RX_DROP;                    !! 170 #define vlan_tx_tag_get(__skb)  (VLAN_TX_SKB_CB(__skb)->vlan_tag)
153 }                                              !! 171 
                                                   >> 172 /* VLAN rx hw acceleration helper.  This acts like netif_{rx,receive_skb}(). */
                                                   >> 173 static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
                                                   >> 174                                     struct vlan_group *grp,
                                                   >> 175                                     unsigned short vlan_tag, int polling)
                                                   >> 176 {
                                                   >> 177         struct net_device_stats *stats;
                                                   >> 178 
                                                   >> 179         if (skb_bond_should_drop(skb)) {
                                                   >> 180                 dev_kfree_skb_any(skb);
                                                   >> 181                 return NET_RX_DROP;
                                                   >> 182         }
154                                                   183 
155 static inline int vlan_gro_frags(struct napi_s !! 184         skb->dev = vlan_group_get_device(grp, vlan_tag & VLAN_VID_MASK);
156                                  struct vlan_g !! 185         if (skb->dev == NULL) {
157 {                                              !! 186                 dev_kfree_skb_any(skb);
158         return NET_RX_DROP;                    !! 187 
                                                   >> 188                 /* Not NET_RX_DROP, this is not being dropped
                                                   >> 189                  * due to congestion.
                                                   >> 190                  */
                                                   >> 191                 return 0;
                                                   >> 192         }
                                                   >> 193 
                                                   >> 194         skb->dev->last_rx = jiffies;
                                                   >> 195 
                                                   >> 196         stats = &skb->dev->stats;
                                                   >> 197         stats->rx_packets++;
                                                   >> 198         stats->rx_bytes += skb->len;
                                                   >> 199 
                                                   >> 200         skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
                                                   >> 201         switch (skb->pkt_type) {
                                                   >> 202         case PACKET_BROADCAST:
                                                   >> 203                 break;
                                                   >> 204 
                                                   >> 205         case PACKET_MULTICAST:
                                                   >> 206                 stats->multicast++;
                                                   >> 207                 break;
                                                   >> 208 
                                                   >> 209         case PACKET_OTHERHOST:
                                                   >> 210                 /* Our lower layer thinks this is not local, let's make sure.
                                                   >> 211                  * This allows the VLAN to have a different MAC than the underlying
                                                   >> 212                  * device, and still route correctly.
                                                   >> 213                  */
                                                   >> 214                 if (!compare_ether_addr(eth_hdr(skb)->h_dest,
                                                   >> 215                                         skb->dev->dev_addr))
                                                   >> 216                         skb->pkt_type = PACKET_HOST;
                                                   >> 217                 break;
                                                   >> 218         };
                                                   >> 219 
                                                   >> 220         return (polling ? netif_receive_skb(skb) : netif_rx(skb));
159 }                                                 221 }
160 #endif                                         << 
161                                                   222 
162 /**                                            << 
163  * vlan_hwaccel_rx - netif_rx wrapper for VLAN << 
164  * @skb: buffer                                << 
165  * @grp: vlan group                            << 
166  * @vlan_tci: VLAN TCI as received from the ca << 
167  */                                            << 
168 static inline int vlan_hwaccel_rx(struct sk_bu    223 static inline int vlan_hwaccel_rx(struct sk_buff *skb,
169                                   struct vlan_    224                                   struct vlan_group *grp,
170                                   u16 vlan_tci !! 225                                   unsigned short vlan_tag)
171 {                                                 226 {
172         return __vlan_hwaccel_rx(skb, grp, vla !! 227         return __vlan_hwaccel_rx(skb, grp, vlan_tag, 0);
173 }                                                 228 }
174                                                   229 
175 /**                                            << 
176  * vlan_hwaccel_receive_skb - netif_receive_sk << 
177  * @skb: buffer                                << 
178  * @grp: vlan group                            << 
179  * @vlan_tci: VLAN TCI as received from the ca << 
180  */                                            << 
181 static inline int vlan_hwaccel_receive_skb(str    230 static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
182                                            str    231                                            struct vlan_group *grp,
183                                            u16 !! 232                                            unsigned short vlan_tag)
184 {                                                 233 {
185         return __vlan_hwaccel_rx(skb, grp, vla !! 234         return __vlan_hwaccel_rx(skb, grp, vlan_tag, 1);
186 }                                                 235 }
187                                                   236 
188 /**                                               237 /**
189  * __vlan_put_tag - regular VLAN tag inserting    238  * __vlan_put_tag - regular VLAN tag inserting
190  * @skb: skbuff to tag                            239  * @skb: skbuff to tag
191  * @vlan_tci: VLAN TCI to insert               !! 240  * @tag: VLAN tag to insert
192  *                                                241  *
193  * Inserts the VLAN tag into @skb as part of t    242  * Inserts the VLAN tag into @skb as part of the payload
194  * Returns a VLAN tagged skb. If a new skb is     243  * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
195  *                                             !! 244  * 
196  * Following the skb_unshare() example, in cas    245  * Following the skb_unshare() example, in case of error, the calling function
197  * doesn't have to worry about freeing the ori    246  * doesn't have to worry about freeing the original skb.
198  */                                               247  */
199 static inline struct sk_buff *__vlan_put_tag(s !! 248 static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
200 {                                                 249 {
201         struct vlan_ethhdr *veth;                 250         struct vlan_ethhdr *veth;
202                                                   251 
203         if (skb_cow_head(skb, VLAN_HLEN) < 0)  !! 252         if (skb_headroom(skb) < VLAN_HLEN) {
204                 kfree_skb(skb);                !! 253                 struct sk_buff *sk_tmp = skb;
205                 return NULL;                   !! 254                 skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
                                                   >> 255                 kfree_skb(sk_tmp);
                                                   >> 256                 if (!skb) {
                                                   >> 257                         printk(KERN_ERR "vlan: failed to realloc headroom\n");
                                                   >> 258                         return NULL;
                                                   >> 259                 }
                                                   >> 260         } else {
                                                   >> 261                 skb = skb_unshare(skb, GFP_ATOMIC);
                                                   >> 262                 if (!skb) {
                                                   >> 263                         printk(KERN_ERR "vlan: failed to unshare skbuff\n");
                                                   >> 264                         return NULL;
                                                   >> 265                 }
206         }                                         266         }
                                                   >> 267 
207         veth = (struct vlan_ethhdr *)skb_push(    268         veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
208                                                   269 
209         /* Move the mac addresses to the begin    270         /* Move the mac addresses to the beginning of the new header. */
210         memmove(skb->data, skb->data + VLAN_HL    271         memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
211         skb->mac_header -= VLAN_HLEN;          << 
212                                                   272 
213         /* first, the ethernet type */            273         /* first, the ethernet type */
214         veth->h_vlan_proto = htons(ETH_P_8021Q    274         veth->h_vlan_proto = htons(ETH_P_8021Q);
215                                                   275 
216         /* now, the TCI */                     !! 276         /* now, the tag */
217         veth->h_vlan_TCI = htons(vlan_tci);    !! 277         veth->h_vlan_TCI = htons(tag);
218                                                   278 
219         skb->protocol = htons(ETH_P_8021Q);       279         skb->protocol = htons(ETH_P_8021Q);
                                                   >> 280         skb->mac_header -= VLAN_HLEN;
                                                   >> 281         skb->network_header -= VLAN_HLEN;
220                                                   282 
221         return skb;                               283         return skb;
222 }                                                 284 }
223                                                   285 
224 /**                                               286 /**
225  * __vlan_hwaccel_put_tag - hardware accelerat    287  * __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
226  * @skb: skbuff to tag                            288  * @skb: skbuff to tag
227  * @vlan_tci: VLAN TCI to insert               !! 289  * @tag: VLAN tag to insert
228  *                                                290  *
229  * Puts the VLAN TCI in @skb->vlan_tci and let !! 291  * Puts the VLAN tag in @skb->cb[] and lets the device do the rest
230  */                                               292  */
231 static inline struct sk_buff *__vlan_hwaccel_p !! 293 static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb, unsigned short tag)
232                                                << 
233 {                                                 294 {
234         skb->vlan_tci = vlan_tci;              !! 295         struct vlan_skb_tx_cookie *cookie;
                                                   >> 296 
                                                   >> 297         cookie = VLAN_TX_SKB_CB(skb);
                                                   >> 298         cookie->magic = VLAN_TX_COOKIE_MAGIC;
                                                   >> 299         cookie->vlan_tag = tag;
                                                   >> 300 
235         return skb;                               301         return skb;
236 }                                                 302 }
237                                                   303 
238 #define HAVE_VLAN_PUT_TAG                         304 #define HAVE_VLAN_PUT_TAG
239                                                   305 
240 /**                                               306 /**
241  * vlan_put_tag - inserts VLAN tag according t    307  * vlan_put_tag - inserts VLAN tag according to device features
242  * @skb: skbuff to tag                            308  * @skb: skbuff to tag
243  * @vlan_tci: VLAN TCI to insert               !! 309  * @tag: VLAN tag to insert
244  *                                                310  *
245  * Assumes skb->dev is the target that will xm    311  * Assumes skb->dev is the target that will xmit this frame.
246  * Returns a VLAN tagged skb.                     312  * Returns a VLAN tagged skb.
247  */                                               313  */
248 static inline struct sk_buff *vlan_put_tag(str !! 314 static inline struct sk_buff *vlan_put_tag(struct sk_buff *skb, unsigned short tag)
249 {                                                 315 {
250         if (skb->dev->features & NETIF_F_HW_VL    316         if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
251                 return __vlan_hwaccel_put_tag( !! 317                 return __vlan_hwaccel_put_tag(skb, tag);
252         } else {                                  318         } else {
253                 return __vlan_put_tag(skb, vla !! 319                 return __vlan_put_tag(skb, tag);
254         }                                         320         }
255 }                                                 321 }
256                                                   322 
257 /**                                               323 /**
258  * __vlan_get_tag - get the VLAN ID that is pa    324  * __vlan_get_tag - get the VLAN ID that is part of the payload
259  * @skb: skbuff to query                          325  * @skb: skbuff to query
260  * @vlan_tci: buffer to store vlaue            !! 326  * @tag: buffer to store vlaue
261  *                                             !! 327  * 
262  * Returns error if the skb is not of VLAN typ    328  * Returns error if the skb is not of VLAN type
263  */                                               329  */
264 static inline int __vlan_get_tag(const struct  !! 330 static inline int __vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
265 {                                                 331 {
266         struct vlan_ethhdr *veth = (struct vla    332         struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
267                                                   333 
268         if (veth->h_vlan_proto != htons(ETH_P_    334         if (veth->h_vlan_proto != htons(ETH_P_8021Q)) {
269                 return -EINVAL;                   335                 return -EINVAL;
270         }                                         336         }
271                                                   337 
272         *vlan_tci = ntohs(veth->h_vlan_TCI);   !! 338         *tag = ntohs(veth->h_vlan_TCI);
                                                   >> 339 
273         return 0;                                 340         return 0;
274 }                                                 341 }
275                                                   342 
276 /**                                               343 /**
277  * __vlan_hwaccel_get_tag - get the VLAN ID th    344  * __vlan_hwaccel_get_tag - get the VLAN ID that is in @skb->cb[]
278  * @skb: skbuff to query                          345  * @skb: skbuff to query
279  * @vlan_tci: buffer to store vlaue            !! 346  * @tag: buffer to store vlaue
280  *                                             !! 347  * 
281  * Returns error if @skb->vlan_tci is not set  !! 348  * Returns error if @skb->cb[] is not set correctly
282  */                                               349  */
283 static inline int __vlan_hwaccel_get_tag(const    350 static inline int __vlan_hwaccel_get_tag(const struct sk_buff *skb,
284                                          u16 * !! 351                                          unsigned short *tag)
285 {                                                 352 {
286         if (vlan_tx_tag_present(skb)) {        !! 353         struct vlan_skb_tx_cookie *cookie;
287                 *vlan_tci = skb->vlan_tci;     !! 354 
                                                   >> 355         cookie = VLAN_TX_SKB_CB(skb);
                                                   >> 356         if (cookie->magic == VLAN_TX_COOKIE_MAGIC) {
                                                   >> 357                 *tag = cookie->vlan_tag;
288                 return 0;                         358                 return 0;
289         } else {                                  359         } else {
290                 *vlan_tci = 0;                 !! 360                 *tag = 0;
291                 return -EINVAL;                   361                 return -EINVAL;
292         }                                         362         }
293 }                                                 363 }
294                                                   364 
295 #define HAVE_VLAN_GET_TAG                         365 #define HAVE_VLAN_GET_TAG
296                                                   366 
297 /**                                               367 /**
298  * vlan_get_tag - get the VLAN ID from the skb    368  * vlan_get_tag - get the VLAN ID from the skb
299  * @skb: skbuff to query                          369  * @skb: skbuff to query
300  * @vlan_tci: buffer to store vlaue            !! 370  * @tag: buffer to store vlaue
301  *                                             !! 371  * 
302  * Returns error if the skb is not VLAN tagged    372  * Returns error if the skb is not VLAN tagged
303  */                                               373  */
304 static inline int vlan_get_tag(const struct sk !! 374 static inline int vlan_get_tag(const struct sk_buff *skb, unsigned short *tag)
305 {                                                 375 {
306         if (skb->dev->features & NETIF_F_HW_VL    376         if (skb->dev->features & NETIF_F_HW_VLAN_TX) {
307                 return __vlan_hwaccel_get_tag( !! 377                 return __vlan_hwaccel_get_tag(skb, tag);
308         } else {                                  378         } else {
309                 return __vlan_get_tag(skb, vla !! 379                 return __vlan_get_tag(skb, tag);
310         }                                         380         }
311 }                                                 381 }
312                                                   382 
313 #endif /* __KERNEL__ */                           383 #endif /* __KERNEL__ */
314                                                   384 
315 /* VLAN IOCTLs are found in sockios.h */          385 /* VLAN IOCTLs are found in sockios.h */
316                                                   386 
317 /* Passed in vlan_ioctl_args structure to dete    387 /* Passed in vlan_ioctl_args structure to determine behaviour. */
318 enum vlan_ioctl_cmds {                            388 enum vlan_ioctl_cmds {
319         ADD_VLAN_CMD,                             389         ADD_VLAN_CMD,
320         DEL_VLAN_CMD,                             390         DEL_VLAN_CMD,
321         SET_VLAN_INGRESS_PRIORITY_CMD,            391         SET_VLAN_INGRESS_PRIORITY_CMD,
322         SET_VLAN_EGRESS_PRIORITY_CMD,             392         SET_VLAN_EGRESS_PRIORITY_CMD,
323         GET_VLAN_INGRESS_PRIORITY_CMD,            393         GET_VLAN_INGRESS_PRIORITY_CMD,
324         GET_VLAN_EGRESS_PRIORITY_CMD,             394         GET_VLAN_EGRESS_PRIORITY_CMD,
325         SET_VLAN_NAME_TYPE_CMD,                   395         SET_VLAN_NAME_TYPE_CMD,
326         SET_VLAN_FLAG_CMD,                        396         SET_VLAN_FLAG_CMD,
327         GET_VLAN_REALDEV_NAME_CMD, /* If this     397         GET_VLAN_REALDEV_NAME_CMD, /* If this works, you know it's a VLAN device, btw */
328         GET_VLAN_VID_CMD /* Get the VID of thi    398         GET_VLAN_VID_CMD /* Get the VID of this VLAN (specified by name) */
329 };                                                399 };
330                                                   400 
331 enum vlan_flags {                                 401 enum vlan_flags {
332         VLAN_FLAG_REORDER_HDR   = 0x1,            402         VLAN_FLAG_REORDER_HDR   = 0x1,
333         VLAN_FLAG_GVRP          = 0x2,         << 
334 };                                                403 };
335                                                   404 
336 enum vlan_name_types {                            405 enum vlan_name_types {
337         VLAN_NAME_TYPE_PLUS_VID, /* Name will     406         VLAN_NAME_TYPE_PLUS_VID, /* Name will look like:  vlan0005 */
338         VLAN_NAME_TYPE_RAW_PLUS_VID, /* name w    407         VLAN_NAME_TYPE_RAW_PLUS_VID, /* name will look like:  eth1.0005 */
339         VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Nam    408         VLAN_NAME_TYPE_PLUS_VID_NO_PAD, /* Name will look like:  vlan5 */
340         VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /*    409         VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, /* Name will look like:  eth0.5 */
341         VLAN_NAME_TYPE_HIGHEST                    410         VLAN_NAME_TYPE_HIGHEST
342 };                                                411 };
343                                                   412 
344 struct vlan_ioctl_args {                          413 struct vlan_ioctl_args {
345         int cmd; /* Should be one of the vlan_    414         int cmd; /* Should be one of the vlan_ioctl_cmds enum above. */
346         char device1[24];                         415         char device1[24];
347                                                   416 
348         union {                                   417         union {
349                 char device2[24];                 418                 char device2[24];
350                 int VID;                          419                 int VID;
351                 unsigned int skb_priority;        420                 unsigned int skb_priority;
352                 unsigned int name_type;           421                 unsigned int name_type;
353                 unsigned int bind_type;           422                 unsigned int bind_type;
354                 unsigned int flag; /* Matches     423                 unsigned int flag; /* Matches vlan_dev_info flags */
355         } u;                                      424         } u;
356                                                   425 
357         short vlan_qos;                           426         short vlan_qos;   
358 };                                                427 };
359                                                   428 
360 #endif /* !(_LINUX_IF_VLAN_H_) */                 429 #endif /* !(_LINUX_IF_VLAN_H_) */
361                                                   430 
  This page was automatically generated by the LXR engine.