Skip to content

Commit d324353

Browse files
Eyal Perrydavem330
authored andcommitted
net/vlan: Provide read access to the vlan egress map
Provide a method for read-only access to the vlan device egress mapping. Do this by refactoring vlan_dev_get_egress_qos_mask() such that now it receives as an argument the skb priority instead of pointer to the skb. Such an access is needed for the IBoE stack where the control plane goes through the network stack. This is an add-on step on top of commit d4a9686 "net/route: export symbol ip_tos2prio" which allowed the RDMA-CM to use ip_tos2prio. Signed-off-by: Eyal Perry <[email protected]> Signed-off-by: Hadar Hen Zion <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 85aec73 commit d324353

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

include/linux/if_vlan.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ extern struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
8888
__be16 vlan_proto, u16 vlan_id);
8989
extern struct net_device *vlan_dev_real_dev(const struct net_device *dev);
9090
extern u16 vlan_dev_vlan_id(const struct net_device *dev);
91-
91+
extern u16 vlan_dev_get_egress_qos_mask(struct net_device *dev,
92+
u32 skprio);
9293
extern bool vlan_do_receive(struct sk_buff **skb);
9394
extern struct sk_buff *vlan_untag(struct sk_buff *skb);
9495

@@ -121,6 +122,12 @@ static inline u16 vlan_dev_vlan_id(const struct net_device *dev)
121122
return 0;
122123
}
123124

125+
static inline u16 vlan_dev_get_egress_qos_mask(struct net_device *dev,
126+
u32 skprio)
127+
{
128+
return 0;
129+
}
130+
124131
static inline bool vlan_do_receive(struct sk_buff **skb)
125132
{
126133
return false;

net/8021q/vlan_dev.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ static int vlan_dev_rebuild_header(struct sk_buff *skb)
6969
}
7070

7171
static inline u16
72-
vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
72+
__vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio)
7373
{
7474
struct vlan_priority_tci_mapping *mp;
7575

7676
smp_rmb(); /* coupled with smp_wmb() in vlan_dev_set_egress_priority() */
7777

78-
mp = vlan_dev_priv(dev)->egress_priority_map[(skb->priority & 0xF)];
78+
mp = vlan_dev_priv(dev)->egress_priority_map[(skprio & 0xF)];
7979
while (mp) {
80-
if (mp->priority == skb->priority) {
80+
if (mp->priority == skprio) {
8181
return mp->vlan_qos; /* This should already be shifted
8282
* to mask correctly with the
8383
* VLAN's TCI */
@@ -87,6 +87,12 @@ vlan_dev_get_egress_qos_mask(struct net_device *dev, struct sk_buff *skb)
8787
return 0;
8888
}
8989

90+
u16 vlan_dev_get_egress_qos_mask(struct net_device *dev, u32 skprio)
91+
{
92+
return __vlan_dev_get_egress_qos_mask(dev, skprio);
93+
}
94+
EXPORT_SYMBOL(vlan_dev_get_egress_qos_mask);
95+
9096
/*
9197
* Create the VLAN header for an arbitrary protocol layer
9298
*
@@ -111,7 +117,7 @@ static int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
111117
vhdr = (struct vlan_hdr *) skb_push(skb, VLAN_HLEN);
112118

113119
vlan_tci = vlan->vlan_id;
114-
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
120+
vlan_tci |= __vlan_dev_get_egress_qos_mask(dev, skb->priority);
115121
vhdr->h_vlan_TCI = htons(vlan_tci);
116122

117123
/*
@@ -168,7 +174,7 @@ static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
168174
vlan->flags & VLAN_FLAG_REORDER_HDR) {
169175
u16 vlan_tci;
170176
vlan_tci = vlan->vlan_id;
171-
vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
177+
vlan_tci |= __vlan_dev_get_egress_qos_mask(dev, skb->priority);
172178
skb = __vlan_hwaccel_put_tag(skb, vlan->vlan_proto, vlan_tci);
173179
}
174180

@@ -253,7 +259,7 @@ int vlan_dev_set_egress_priority(const struct net_device *dev,
253259
np->vlan_qos = vlan_qos;
254260
/* Before inserting this element in hash table, make sure all its fields
255261
* are committed to memory.
256-
* coupled with smp_rmb() in vlan_dev_get_egress_qos_mask()
262+
* coupled with smp_rmb() in __vlan_dev_get_egress_qos_mask()
257263
*/
258264
smp_wmb();
259265
vlan->egress_priority_map[skb_prio & 0xF] = np;

0 commit comments

Comments
 (0)