aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/if_vlan.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/if_vlan.h')
-rw-r--r--include/linux/if_vlan.h116
1 files changed, 26 insertions, 90 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index dc01681fbb42..44da4822bcab 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -91,25 +91,6 @@ struct vlan_group {
91 struct rcu_head rcu; 91 struct rcu_head rcu;
92}; 92};
93 93
94static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
95 u16 vlan_id)
96{
97 struct net_device **array;
98 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
99 return array ? array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] : NULL;
100}
101
102static inline void vlan_group_set_device(struct vlan_group *vg,
103 u16 vlan_id,
104 struct net_device *dev)
105{
106 struct net_device **array;
107 if (!vg)
108 return;
109 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
110 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
111}
112
113static inline int is_vlan_dev(struct net_device *dev) 94static inline int is_vlan_dev(struct net_device *dev)
114{ 95{
115 return dev->priv_flags & IFF_802_1Q_VLAN; 96 return dev->priv_flags & IFF_802_1Q_VLAN;
@@ -119,35 +100,18 @@ static inline int is_vlan_dev(struct net_device *dev)
119#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) 100#define vlan_tx_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
120 101
121#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 102#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
122/* Must be invoked with rcu_read_lock or with RTNL. */
123static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
124 u16 vlan_id)
125{
126 struct vlan_group *grp = rcu_dereference_rtnl(real_dev->vlgrp);
127
128 if (grp)
129 return vlan_group_get_device(grp, vlan_id);
130
131 return NULL;
132}
133 103
104extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
105 u16 vlan_id);
134extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); 106extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
135extern u16 vlan_dev_vlan_id(const struct net_device *dev); 107extern u16 vlan_dev_vlan_id(const struct net_device *dev);
136 108
137extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
138 u16 vlan_tci, int polling);
139extern bool vlan_do_receive(struct sk_buff **skb); 109extern bool vlan_do_receive(struct sk_buff **skb);
140extern struct sk_buff *vlan_untag(struct sk_buff *skb); 110extern struct sk_buff *vlan_untag(struct sk_buff *skb);
141extern gro_result_t
142vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
143 unsigned int vlan_tci, struct sk_buff *skb);
144extern gro_result_t
145vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
146 unsigned int vlan_tci);
147 111
148#else 112#else
149static inline struct net_device *vlan_find_dev(struct net_device *real_dev, 113static inline struct net_device *
150 u16 vlan_id) 114__vlan_find_dev_deep(struct net_device *real_dev, u16 vlan_id)
151{ 115{
152 return NULL; 116 return NULL;
153} 117}
@@ -164,13 +128,6 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
164 return 0; 128 return 0;
165} 129}
166 130
167static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
168 u16 vlan_tci, int polling)
169{
170 BUG();
171 return NET_XMIT_SUCCESS;
172}
173
174static inline bool vlan_do_receive(struct sk_buff **skb) 131static inline bool vlan_do_receive(struct sk_buff **skb)
175{ 132{
176 if ((*skb)->vlan_tci & VLAN_VID_MASK) 133 if ((*skb)->vlan_tci & VLAN_VID_MASK)
@@ -182,50 +139,10 @@ static inline struct sk_buff *vlan_untag(struct sk_buff *skb)
182{ 139{
183 return skb; 140 return skb;
184} 141}
185
186static inline gro_result_t
187vlan_gro_receive(struct napi_struct *napi, struct vlan_group *grp,
188 unsigned int vlan_tci, struct sk_buff *skb)
189{
190 return GRO_DROP;
191}
192
193static inline gro_result_t
194vlan_gro_frags(struct napi_struct *napi, struct vlan_group *grp,
195 unsigned int vlan_tci)
196{
197 return GRO_DROP;
198}
199#endif 142#endif
200 143
201/** 144/**
202 * vlan_hwaccel_rx - netif_rx wrapper for VLAN RX acceleration 145 * vlan_insert_tag - regular VLAN tag inserting
203 * @skb: buffer
204 * @grp: vlan group
205 * @vlan_tci: VLAN TCI as received from the card
206 */
207static inline int vlan_hwaccel_rx(struct sk_buff *skb,
208 struct vlan_group *grp,
209 u16 vlan_tci)
210{
211 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 0);
212}
213
214/**
215 * vlan_hwaccel_receive_skb - netif_receive_skb wrapper for VLAN RX acceleration
216 * @skb: buffer
217 * @grp: vlan group
218 * @vlan_tci: VLAN TCI as received from the card
219 */
220static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
221 struct vlan_group *grp,
222 u16 vlan_tci)
223{
224 return __vlan_hwaccel_rx(skb, grp, vlan_tci, 1);
225}
226
227/**
228 * __vlan_put_tag - regular VLAN tag inserting
229 * @skb: skbuff to tag 146 * @skb: skbuff to tag
230 * @vlan_tci: VLAN TCI to insert 147 * @vlan_tci: VLAN TCI to insert
231 * 148 *
@@ -234,8 +151,10 @@ static inline int vlan_hwaccel_receive_skb(struct sk_buff *skb,
234 * 151 *
235 * Following the skb_unshare() example, in case of error, the calling function 152 * Following the skb_unshare() example, in case of error, the calling function
236 * doesn't have to worry about freeing the original skb. 153 * doesn't have to worry about freeing the original skb.
154 *
155 * Does not change skb->protocol so this function can be used during receive.
237 */ 156 */
238static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci) 157static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, u16 vlan_tci)
239{ 158{
240 struct vlan_ethhdr *veth; 159 struct vlan_ethhdr *veth;
241 160
@@ -255,8 +174,25 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
255 /* now, the TCI */ 174 /* now, the TCI */
256 veth->h_vlan_TCI = htons(vlan_tci); 175 veth->h_vlan_TCI = htons(vlan_tci);
257 176
258 skb->protocol = htons(ETH_P_8021Q); 177 return skb;
178}
259 179
180/**
181 * __vlan_put_tag - regular VLAN tag inserting
182 * @skb: skbuff to tag
183 * @vlan_tci: VLAN TCI to insert
184 *
185 * Inserts the VLAN tag into @skb as part of the payload
186 * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
187 *
188 * Following the skb_unshare() example, in case of error, the calling function
189 * doesn't have to worry about freeing the original skb.
190 */
191static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, u16 vlan_tci)
192{
193 skb = vlan_insert_tag(skb, vlan_tci);
194 if (skb)
195 skb->protocol = htons(ETH_P_8021Q);
260 return skb; 196 return skb;
261} 197}
262 198