Skip to content

Commit e9dbeba

Browse files
hormsdavem330
authored andcommitted
net: stmmac: Correct byte order of perfect_match
The perfect_match parameter of the update_vlan_hash operation is __le16, and is correctly converted from host byte-order in the lone caller, stmmac_vlan_update(). However, the implementations of this caller, dwxgmac2_update_vlan_hash() and dwxgmac2_update_vlan_hash(), both treat this parameter as host byte order, using the following pattern: u32 value = ... ... writel(value | perfect_match, ...); This is not correct because both: 1) value is host byte order; and 2) writel expects a host byte order value as it's first argument I believe that this will break on big endian systems. And I expect it has gone unnoticed by only being exercised on little endian systems. The approach taken by this patch is to update the callback, and it's caller to simply use a host byte order value. Flagged by Sparse. Compile tested only. Fixes: c7ab0b8 ("net: stmmac: Fallback to VLAN Perfect filtering if HASH is not available") Signed-off-by: Simon Horman <[email protected]> Reviewed-by: Maxime Chevallier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 863ff54 commit e9dbeba

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable)
977977
}
978978

979979
static void dwmac4_update_vlan_hash(struct mac_device_info *hw, u32 hash,
980-
__le16 perfect_match, bool is_double)
980+
u16 perfect_match, bool is_double)
981981
{
982982
void __iomem *ioaddr = hw->pcsr;
983983
u32 value;

drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int dwxgmac2_rss_configure(struct mac_device_info *hw,
615615
}
616616

617617
static void dwxgmac2_update_vlan_hash(struct mac_device_info *hw, u32 hash,
618-
__le16 perfect_match, bool is_double)
618+
u16 perfect_match, bool is_double)
619619
{
620620
void __iomem *ioaddr = hw->pcsr;
621621

drivers/net/ethernet/stmicro/stmmac/hwif.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ struct stmmac_ops {
393393
struct stmmac_rss *cfg, u32 num_rxq);
394394
/* VLAN */
395395
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
396-
__le16 perfect_match, bool is_double);
396+
u16 perfect_match, bool is_double);
397397
void (*enable_vlan)(struct mac_device_info *hw, u32 type);
398398
void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc,
399399
struct sk_buff *skb);

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6641,7 +6641,7 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)
66416641
static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
66426642
{
66436643
u32 crc, hash = 0;
6644-
__le16 pmatch = 0;
6644+
u16 pmatch = 0;
66456645
int count = 0;
66466646
u16 vid = 0;
66476647

@@ -6656,7 +6656,7 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
66566656
if (count > 2) /* VID = 0 always passes filter */
66576657
return -EOPNOTSUPP;
66586658

6659-
pmatch = cpu_to_le16(vid);
6659+
pmatch = vid;
66606660
hash = 0;
66616661
}
66626662

0 commit comments

Comments
 (0)