Skip to content

Commit 810f19b

Browse files
françois romieudavem330
authored andcommitted
via-rhine: add consistent memory barrier in vlan receive code.
The NAPI receive path depends on desc->rx_status but it does not enforce any explicit receive barrier. Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 62ca1ba commit 810f19b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

drivers/net/ethernet/via/via-rhine.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,18 @@ static inline u16 rhine_get_vlan_tci(struct sk_buff *skb, int data_size)
19931993
return be16_to_cpup((__be16 *)trailer);
19941994
}
19951995

1996+
static inline void rhine_rx_vlan_tag(struct sk_buff *skb, struct rx_desc *desc,
1997+
int data_size)
1998+
{
1999+
dma_rmb();
2000+
if (unlikely(desc->desc_length & cpu_to_le32(DescTag))) {
2001+
u16 vlan_tci;
2002+
2003+
vlan_tci = rhine_get_vlan_tci(skb, data_size);
2004+
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
2005+
}
2006+
}
2007+
19962008
/* Process up to limit frames from receive ring */
19972009
static int rhine_rx(struct net_device *dev, int limit)
19982010
{
@@ -2008,7 +2020,6 @@ static int rhine_rx(struct net_device *dev, int limit)
20082020
for (count = 0; count < limit; ++count) {
20092021
struct rx_desc *desc = rp->rx_ring + entry;
20102022
u32 desc_status = le32_to_cpu(desc->rx_status);
2011-
u32 desc_length = le32_to_cpu(desc->desc_length);
20122023
int data_size = desc_status >> 16;
20132024

20142025
if (desc_status & DescOwn)
@@ -2048,7 +2059,6 @@ static int rhine_rx(struct net_device *dev, int limit)
20482059
/* Length should omit the CRC */
20492060
int pkt_len = data_size - 4;
20502061
struct sk_buff *skb;
2051-
u16 vlan_tci = 0;
20522062

20532063
/* Check if the packet is long enough to accept without
20542064
copying to a minimally-sized skbuff. */
@@ -2086,14 +2096,10 @@ static int rhine_rx(struct net_device *dev, int limit)
20862096
}
20872097

20882098
skb_put(skb, pkt_len);
2089-
2090-
if (unlikely(desc_length & DescTag))
2091-
vlan_tci = rhine_get_vlan_tci(skb, data_size);
2092-
20932099
skb->protocol = eth_type_trans(skb, dev);
20942100

2095-
if (unlikely(desc_length & DescTag))
2096-
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
2101+
rhine_rx_vlan_tag(skb, desc, data_size);
2102+
20972103
netif_receive_skb(skb);
20982104

20992105
u64_stats_update_begin(&rp->rx_stats.syncp);

0 commit comments

Comments
 (0)