aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-11-11 00:42:07 -0500
committerDavid S. Miller <davem@davemloft.net>2013-11-11 00:42:07 -0500
commite267cb960ab790c94a5019272c0e4dac95dc4dba (patch)
tree483785140f9ad26db0241f2aa22e9cd00b6f6828 /net/8021q
parent170e85430bcbe4d18e81b5a70bb163c741381092 (diff)
vlan: Implement vlan_dev_get_egress_qos_mask as an inline.
This is to avoid very silly Kconfig dependencies for modules using this routine. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r--net/8021q/vlan.h77
-rw-r--r--net/8021q/vlan_dev.c31
2 files changed, 3 insertions, 105 deletions
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index a2caf00b82cc..5704ed9c3a23 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -5,83 +5,6 @@
5#include <linux/u64_stats_sync.h> 5#include <linux/u64_stats_sync.h>
6#include <linux/list.h> 6#include <linux/list.h>
7 7
8
9/**
10 * struct vlan_priority_tci_mapping - vlan egress priority mappings
11 * @priority: skb priority
12 * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000
13 * @next: pointer to next struct
14 */
15struct vlan_priority_tci_mapping {
16 u32 priority;
17 u16 vlan_qos;
18 struct vlan_priority_tci_mapping *next;
19};
20
21
22/**
23 * struct vlan_pcpu_stats - VLAN percpu rx/tx stats
24 * @rx_packets: number of received packets
25 * @rx_bytes: number of received bytes
26 * @rx_multicast: number of received multicast packets
27 * @tx_packets: number of transmitted packets
28 * @tx_bytes: number of transmitted bytes
29 * @syncp: synchronization point for 64bit counters
30 * @rx_errors: number of rx errors
31 * @tx_dropped: number of tx drops
32 */
33struct vlan_pcpu_stats {
34 u64 rx_packets;
35 u64 rx_bytes;
36 u64 rx_multicast;
37 u64 tx_packets;
38 u64 tx_bytes;
39 struct u64_stats_sync syncp;
40 u32 rx_errors;
41 u32 tx_dropped;
42};
43
44struct netpoll;
45
46/**
47 * struct vlan_dev_priv - VLAN private device data
48 * @nr_ingress_mappings: number of ingress priority mappings
49 * @ingress_priority_map: ingress priority mappings
50 * @nr_egress_mappings: number of egress priority mappings
51 * @egress_priority_map: hash of egress priority mappings
52 * @vlan_proto: VLAN encapsulation protocol
53 * @vlan_id: VLAN identifier
54 * @flags: device flags
55 * @real_dev: underlying netdevice
56 * @real_dev_addr: address of underlying netdevice
57 * @dent: proc dir entry
58 * @vlan_pcpu_stats: ptr to percpu rx stats
59 */
60struct vlan_dev_priv {
61 unsigned int nr_ingress_mappings;
62 u32 ingress_priority_map[8];
63 unsigned int nr_egress_mappings;
64 struct vlan_priority_tci_mapping *egress_priority_map[16];
65
66 __be16 vlan_proto;
67 u16 vlan_id;
68 u16 flags;
69
70 struct net_device *real_dev;
71 unsigned char real_dev_addr[ETH_ALEN];
72
73 struct proc_dir_entry *dent;
74 struct vlan_pcpu_stats __percpu *vlan_pcpu_stats;
75#ifdef CONFIG_NET_POLL_CONTROLLER
76 struct netpoll *netpoll;
77#endif
78};
79
80static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev)
81{
82 return netdev_priv(dev);
83}
84
85/* if this changes, algorithm will have to be reworked because this 8/* if this changes, algorithm will have to be reworked because this
86 * depends on completely exhausting the VLAN identifier space. Thus 9 * depends on completely exhausting the VLAN identifier space. Thus
87 * it gives constant time look-up, but in many cases it wastes memory. 10 * it gives constant time look-up, but in many cases it wastes memory.
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 13904a414929..8db1b985dbf1 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -68,31 +68,6 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
68 return 0; 68 return 0;
69} 69}
70 70
71static inline u16
72__vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio)
73{
74 struct vlan_priority_tci_mapping *mp;
75
76 smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */
77
78 mp = vlan_dev_priv(dev)->egress_priority_map[(skprio & 0xF)];
79 while (mp) {
80 if (mp->priority == skprio) {
81 return mp->vlan_qos; /* This should already be shifted
82 * to mask correctly with the
83 * VLAN's TCI */
84 }
85 mp = mp->next;
86 }
87 return 0;
88}
89
90u16 vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio)
91{
92 return __vlan_dev_get_egress_qos_mask(dev, skprio);
93}
94EXPORT_SYMBOL(vlan_dev_get_egress_qos_mask);
95
96/* 71/*
97 * Create the VLAN header for an arbitrary protocol layer 72 * Create the VLAN header for an arbitrary protocol layer
98 * 73 *
@@ -117,7 +92,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
117 vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN); 92 vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
118 93
119 vlan_tci = vlan->vlan_id; 94 vlan_tci = vlan->vlan_id;
120 vlan_tci |= __vlan_dev_get_egress_qos_mask(dev, skb->priority); 95 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority);
121 vhdr->h_vlan_TCI = htons(vlan_tci); 96 vhdr->h_vlan_TCI = htons(vlan_tci);
122 97
123 /* 98 /*
@@ -174,7 +149,7 @@ static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
174 vlan->flags & VLAN_FLAG_REORDER_HDR) { 149 vlan->flags & VLAN_FLAG_REORDER_HDR) {
175 u16 vlan_tci; 150 u16 vlan_tci;
176 vlan_tci = vlan->vlan_id; 151 vlan_tci = vlan->vlan_id;
177 vlan_tci |= __vlan_dev_get_egress_qos_mask(dev, skb->priority); 152 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb->priority);
178 skb = __vlan_hwaccel_put_tag(skb, vlan->vlan_proto, vlan_tci); 153 skb = __vlan_hwaccel_put_tag(skb, vlan->vlan_proto, vlan_tci);
179 } 154 }
180 155
@@ -259,7 +234,7 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
259 np->vlan_qos = vlan_qos; 234 np->vlan_qos = vlan_qos;
260 /* Before inserting this element in hash table, make sure all its fields 235 /* Before inserting this element in hash table, make sure all its fields
261 * are committed to memory. 236 * are committed to memory.
262 * coupled with smp_rmb() in __vlan_dev_get_egress_qos_mask() 237 * coupled with smp_rmb() in vlan_dev_get_egress_qos_mask()
263 */ 238 */
264 smp_wmb(); 239 smp_wmb();
265 vlan->egress_priority_map[skb_prio & 0xF] = np; 240 vlan->egress_priority_map[skb_prio & 0xF] = np;