aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-07-08 06:23:57 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-08 06:23:57 -0400
commit22d1ba74bbafa96d3f425cc12714d3fe8675183f (patch)
tree5fdc18001037a667e95229dbc34130b7210e8c8c
parent7750f403cbe56971336d575b354365190b4e3227 (diff)
vlan: move struct vlan_dev_info to private header
Hide struct vlan_dev_info from drivers to prevent them from growing more creative ways to use it. Provide accessors for the two drivers that currently use it. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/cxgb3/l2t.c2
-rw-r--r--drivers/s390/net/qeth_l3_main.c4
-rw-r--r--include/linux/if_vlan.h56
-rw-r--r--net/8021q/vlan.c4
-rw-r--r--net/8021q/vlan.h50
-rw-r--r--net/8021q/vlan_core.c12
-rw-r--r--net/8021q/vlan_dev.c5
7 files changed, 80 insertions, 53 deletions
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index f510140885ae..825e510bd9ed 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -337,7 +337,7 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct neighbour *neigh,
337 atomic_set(&e->refcnt, 1); 337 atomic_set(&e->refcnt, 1);
338 neigh_replace(e, neigh); 338 neigh_replace(e, neigh);
339 if (neigh->dev->priv_flags & IFF_802_1Q_VLAN) 339 if (neigh->dev->priv_flags & IFF_802_1Q_VLAN)
340 e->vlan = vlan_dev_info(neigh->dev)->vlan_id; 340 e->vlan = vlan_dev_vlan_id(neigh->dev);
341 else 341 else
342 e->vlan = VLAN_NONE; 342 e->vlan = VLAN_NONE;
343 spin_unlock(&e->lock); 343 spin_unlock(&e->lock);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 999552c83bbe..85be40abdda9 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -2020,7 +2020,7 @@ static int qeth_l3_verify_vlan_dev(struct net_device *dev,
2020 } 2020 }
2021 } 2021 }
2022 2022
2023 if (rc && !(netdev_priv(vlan_dev_info(dev)->real_dev) == (void *)card)) 2023 if (rc && !(netdev_priv(vlan_dev_real_dev(dev)) == (void *)card))
2024 return 0; 2024 return 0;
2025 2025
2026 return rc; 2026 return rc;
@@ -2056,7 +2056,7 @@ static struct qeth_card *qeth_l3_get_card_from_dev(struct net_device *dev)
2056 if (rc == QETH_REAL_CARD) 2056 if (rc == QETH_REAL_CARD)
2057 card = netdev_priv(dev); 2057 card = netdev_priv(dev);
2058 else if (rc == QETH_VLAN_CARD) 2058 else if (rc == QETH_VLAN_CARD)
2059 card = netdev_priv(vlan_dev_info(dev)->real_dev); 2059 card = netdev_priv(vlan_dev_real_dev(dev));
2060 if (card && card->options.layer2) 2060 if (card && card->options.layer2)
2061 card = NULL; 2061 card = NULL;
2062 QETH_DBF_TEXT_(TRACE, 4, "%d", rc); 2062 QETH_DBF_TEXT_(TRACE, 4, "%d", rc);
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 594cd35b0074..cb2e6b480882 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -109,47 +109,6 @@ static inline void vlan_group_set_device(struct vlan_group *vg,
109 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev; 109 array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
110} 110}
111 111
112struct vlan_priority_tci_mapping {
113 u32 priority;
114 unsigned short vlan_qos; /* This should be shifted when first set, so we only do it
115 * at provisioning time.
116 * ((skb->priority << 13) & 0xE000)
117 */
118 struct vlan_priority_tci_mapping *next;
119};
120
121/* Holds information that makes sense if this device is a VLAN device. */
122struct vlan_dev_info {
123 /** This will be the mapping that correlates skb->priority to
124 * 3 bits of VLAN QOS tags...
125 */
126 unsigned int nr_ingress_mappings;
127 u32 ingress_priority_map[8];
128
129 unsigned int nr_egress_mappings;
130 struct vlan_priority_tci_mapping *egress_priority_map[16]; /* hash table */
131
132 unsigned short vlan_id; /* The VLAN Identifier for this interface. */
133 unsigned short flags; /* (1 << 0) re_order_header This option will cause the
134 * VLAN code to move around the ethernet header on
135 * ingress to make the skb look **exactly** like it
136 * came in from an ethernet port. This destroys some of
137 * the VLAN information in the skb, but it fixes programs
138 * like DHCP that use packet-filtering and don't understand
139 * 802.1Q
140 */
141 struct net_device *real_dev; /* the underlying device/interface */
142 unsigned char real_dev_addr[ETH_ALEN];
143 struct proc_dir_entry *dent; /* Holds the proc data */
144 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
145 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
146};
147
148static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
149{
150 return netdev_priv(dev);
151}
152
153/* VLAN tx hw acceleration helpers. */ 112/* VLAN tx hw acceleration helpers. */
154struct vlan_skb_tx_cookie { 113struct vlan_skb_tx_cookie {
155 u32 magic; 114 u32 magic;
@@ -163,9 +122,24 @@ struct vlan_skb_tx_cookie {
163#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag) 122#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
164 123
165#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 124#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
125extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
126extern u16 vlan_dev_vlan_id(const struct net_device *dev);
127
166extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 128extern int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
167 unsigned short vlan_tag, int polling); 129 unsigned short vlan_tag, int polling);
168#else 130#else
131static inline struct net_device *vlan_dev_real_dev(const struct net_device *dev)
132{
133 BUG();
134 return NULL;
135}
136
137static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
138{
139 BUG();
140 return 0;
141}
142
169static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, 143static inline int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
170 unsigned short vlan_tag, int polling) 144 unsigned short vlan_tag, int polling)
171{ 145{
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 8141e2dc510b..7a2625d2f9a0 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -543,7 +543,6 @@ static struct notifier_block vlan_notifier_block __read_mostly = {
543static int vlan_ioctl_handler(struct net *net, void __user *arg) 543static int vlan_ioctl_handler(struct net *net, void __user *arg)
544{ 544{
545 int err; 545 int err;
546 unsigned short vid = 0;
547 struct vlan_ioctl_args args; 546 struct vlan_ioctl_args args;
548 struct net_device *dev = NULL; 547 struct net_device *dev = NULL;
549 548
@@ -644,8 +643,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
644 643
645 case GET_VLAN_VID_CMD: 644 case GET_VLAN_VID_CMD:
646 err = 0; 645 err = 0;
647 vlan_dev_get_vid(dev, &vid); 646 args.u.VID = vlan_dev_vlan_id(dev);
648 args.u.VID = vid;
649 if (copy_to_user(arg, &args, 647 if (copy_to_user(arg, &args,
650 sizeof(struct vlan_ioctl_args))) 648 sizeof(struct vlan_ioctl_args)))
651 err = -EFAULT; 649 err = -EFAULT;
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 7cc1a97c42fc..14c421e033f2 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -3,6 +3,55 @@
3 3
4#include <linux/if_vlan.h> 4#include <linux/if_vlan.h>
5 5
6
7/**
8 * struct vlan_priority_tci_mapping - vlan egress priority mappings
9 * @priority: skb priority
10 * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
11 * @next: pointer to next struct
12 */
13struct vlan_priority_tci_mapping {
14 u32 priority;
15 unsigned short vlan_qos;
16 struct vlan_priority_tci_mapping *next;
17};
18
19/**
20 * struct vlan_dev_info - VLAN private device data
21 * @nr_ingress_mappings: number of ingress priority mappings
22 * @ingress_priority_map: ingress priority mappings
23 * @nr_egress_mappings: number of egress priority mappings
24 * @egress_priority_map: hash of egress priority mappings
25 * @vlan_id: VLAN identifier
26 * @flags: device flags
27 * @real_dev: underlying netdevice
28 * @real_dev_addr: address of underlying netdevice
29 * @dent: proc dir entry
30 * @cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
31 * @cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
32 */
33struct vlan_dev_info {
34 unsigned int nr_ingress_mappings;
35 u32 ingress_priority_map[8];
36 unsigned int nr_egress_mappings;
37 struct vlan_priority_tci_mapping *egress_priority_map[16];
38
39 unsigned short vlan_id;
40 unsigned short flags;
41
42 struct net_device *real_dev;
43 unsigned char real_dev_addr[ETH_ALEN];
44
45 struct proc_dir_entry *dent;
46 unsigned long cnt_inc_headroom_on_tx;
47 unsigned long cnt_encap_on_xmit;
48};
49
50static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
51{
52 return netdev_priv(dev);
53}
54
6#define VLAN_GRP_HASH_SHIFT 5 55#define VLAN_GRP_HASH_SHIFT 5
7#define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT) 56#define VLAN_GRP_HASH_SIZE (1 << VLAN_GRP_HASH_SHIFT)
8#define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1) 57#define VLAN_GRP_HASH_MASK (VLAN_GRP_HASH_SIZE - 1)
@@ -30,7 +79,6 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
30 u32 skb_prio, short vlan_prio); 79 u32 skb_prio, short vlan_prio);
31int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask); 80int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask);
32void vlan_dev_get_realdev_name(const struct net_device *dev, char *result); 81void vlan_dev_get_realdev_name(const struct net_device *dev, char *result);
33void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result);
34 82
35int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id); 83int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id);
36void vlan_setup(struct net_device *dev); 84void vlan_setup(struct net_device *dev);
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index 85c94edb000f..f980b9154cc3 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -46,3 +46,15 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp,
46 return (polling ? netif_receive_skb(skb) : netif_rx(skb)); 46 return (polling ? netif_receive_skb(skb) : netif_rx(skb));
47} 47}
48EXPORT_SYMBOL(__vlan_hwaccel_rx); 48EXPORT_SYMBOL(__vlan_hwaccel_rx);
49
50struct net_device *vlan_dev_real_dev(const struct net_device *dev)
51{
52 return vlan_dev_info(dev)->real_dev;
53}
54EXPORT_SYMBOL_GPL(vlan_dev_real_dev);
55
56u16 vlan_dev_vlan_id(const struct net_device *dev)
57{
58 return vlan_dev_info(dev)->vlan_id;
59}
60EXPORT_SYMBOL_GPL(vlan_dev_vlan_id);
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 722697d31e4f..2aab294c5744 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -531,11 +531,6 @@ void vlan_dev_get_realdev_name(const struct net_device *dev, char *result)
531 strncpy(result, vlan_dev_info(dev)->real_dev->name, 23); 531 strncpy(result, vlan_dev_info(dev)->real_dev->name, 23);
532} 532}
533 533
534void vlan_dev_get_vid(const struct net_device *dev, unsigned short *result)
535{
536 *result = vlan_dev_info(dev)->vlan_id;
537}
538
539static int vlan_dev_open(struct net_device *dev) 534static int vlan_dev_open(struct net_device *dev)
540{ 535{
541 struct vlan_dev_info *vlan = vlan_dev_info(dev); 536 struct vlan_dev_info *vlan = vlan_dev_info(dev);