diff options
| author | David S. Miller <davem@davemloft.net> | 2013-11-11 00:42:07 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-11-11 00:42:07 -0500 |
| commit | e267cb960ab790c94a5019272c0e4dac95dc4dba (patch) | |
| tree | 483785140f9ad26db0241f2aa22e9cd00b6f6828 /include | |
| parent | 170e85430bcbe4d18e81b5a70bb163c741381092 (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 'include')
| -rw-r--r-- | include/linux/if_vlan.h | 98 |
1 files changed, 96 insertions, 2 deletions
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index f3088a0112cf..f252deb99454 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h | |||
| @@ -88,8 +88,102 @@ extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev, | |||
| 88 | __be16 vlan_proto, u16 vlan_id); | 88 | __be16 vlan_proto, u16 vlan_id); |
| 89 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); | 89 | extern struct net_device *vlan_dev_real_dev(const struct net_device *dev); |
| 90 | extern u16 vlan_dev_vlan_id(const struct net_device *dev); | 90 | extern u16 vlan_dev_vlan_id(const struct net_device *dev); |
| 91 | extern u16 vlan_dev_get_egress_qos_mask(struct net_device *dev, | 91 | |
| 92 | u32 skprio); | 92 | /** |
| 93 | * struct vlan_priority_tci_mapping - vlan egress priority mappings | ||
| 94 | * @priority: skb priority | ||
| 95 | * @vlan_qos: vlan priority: (skb->priority << 13) & 0xE000 | ||
| 96 | * @next: pointer to next struct | ||
| 97 | */ | ||
| 98 | struct vlan_priority_tci_mapping { | ||
| 99 | u32 priority; | ||
| 100 | u16 vlan_qos; | ||
| 101 | struct vlan_priority_tci_mapping *next; | ||
| 102 | }; | ||
| 103 | |||
| 104 | /** | ||
| 105 | * struct vlan_pcpu_stats - VLAN percpu rx/tx stats | ||
| 106 | * @rx_packets: number of received packets | ||
| 107 | * @rx_bytes: number of received bytes | ||
| 108 | * @rx_multicast: number of received multicast packets | ||
| 109 | * @tx_packets: number of transmitted packets | ||
| 110 | * @tx_bytes: number of transmitted bytes | ||
| 111 | * @syncp: synchronization point for 64bit counters | ||
| 112 | * @rx_errors: number of rx errors | ||
| 113 | * @tx_dropped: number of tx drops | ||
| 114 | */ | ||
| 115 | struct vlan_pcpu_stats { | ||
| 116 | u64 rx_packets; | ||
| 117 | u64 rx_bytes; | ||
| 118 | u64 rx_multicast; | ||
| 119 | u64 tx_packets; | ||
| 120 | u64 tx_bytes; | ||
| 121 | struct u64_stats_sync syncp; | ||
| 122 | u32 rx_errors; | ||
| 123 | u32 tx_dropped; | ||
| 124 | }; | ||
| 125 | |||
| 126 | struct proc_dir_entry; | ||
| 127 | struct netpoll; | ||
| 128 | |||
| 129 | /** | ||
| 130 | * struct vlan_dev_priv - VLAN private device data | ||
| 131 | * @nr_ingress_mappings: number of ingress priority mappings | ||
| 132 | * @ingress_priority_map: ingress priority mappings | ||
| 133 | * @nr_egress_mappings: number of egress priority mappings | ||
| 134 | * @egress_priority_map: hash of egress priority mappings | ||
| 135 | * @vlan_proto: VLAN encapsulation protocol | ||
| 136 | * @vlan_id: VLAN identifier | ||
| 137 | * @flags: device flags | ||
| 138 | * @real_dev: underlying netdevice | ||
| 139 | * @real_dev_addr: address of underlying netdevice | ||
| 140 | * @dent: proc dir entry | ||
| 141 | * @vlan_pcpu_stats: ptr to percpu rx stats | ||
| 142 | */ | ||
| 143 | struct vlan_dev_priv { | ||
| 144 | unsigned int nr_ingress_mappings; | ||
| 145 | u32 ingress_priority_map[8]; | ||
| 146 | unsigned int nr_egress_mappings; | ||
| 147 | struct vlan_priority_tci_mapping *egress_priority_map[16]; | ||
| 148 | |||
| 149 | __be16 vlan_proto; | ||
| 150 | u16 vlan_id; | ||
| 151 | u16 flags; | ||
| 152 | |||
| 153 | struct net_device *real_dev; | ||
| 154 | unsigned char real_dev_addr[ETH_ALEN]; | ||
| 155 | |||
| 156 | struct proc_dir_entry *dent; | ||
| 157 | struct vlan_pcpu_stats __percpu *vlan_pcpu_stats; | ||
| 158 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
| 159 | struct netpoll *netpoll; | ||
| 160 | #endif | ||
| 161 | }; | ||
| 162 | |||
| 163 | static inline struct vlan_dev_priv *vlan_dev_priv(const struct net_device *dev) | ||
| 164 | { | ||
| 165 | return netdev_priv(dev); | ||
| 166 | } | ||
| 167 | |||
| 168 | static inline u16 | ||
| 169 | vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio) | ||
| 170 | { | ||
| 171 | struct vlan_priority_tci_mapping *mp; | ||
| 172 | |||
| 173 | smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */ | ||
| 174 | |||
| 175 | mp = vlan_dev_priv(dev)->egress_priority_map[(skprio & 0xF)]; | ||
| 176 | while (mp) { | ||
| 177 | if (mp->priority == skprio) { | ||
| 178 | return mp->vlan_qos; /* This should already be shifted | ||
| 179 | * to mask correctly with the | ||
| 180 | * VLAN's TCI */ | ||
| 181 | } | ||
| 182 | mp = mp->next; | ||
| 183 | } | ||
| 184 | return 0; | ||
| 185 | } | ||
| 186 | |||
| 93 | extern bool vlan_do_receive(struct sk_buff **skb); | 187 | extern bool vlan_do_receive(struct sk_buff **skb); |
| 94 | extern struct sk_buff *vlan_untag(struct sk_buff *skb); | 188 | extern struct sk_buff *vlan_untag(struct sk_buff *skb); |
| 95 | 189 | ||
