Skip to content

Commit fa938b0

Browse files
hormsgregkh
authored andcommitted
net: stmmac: Correct byte order of perfect_match
[ Upstream commit e9dbeba ] 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 <horms@kernel.org> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent dd66c60 commit fa938b0

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

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

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

984984
static void dwmac4_update_vlan_hash(struct mac_device_info *hw, u32 hash,
985-
__le16 perfect_match, bool is_double)
985+
u16 perfect_match, bool is_double)
986986
{
987987
void __iomem *ioaddr = hw->pcsr;
988988
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
@@ -394,7 +394,7 @@ struct stmmac_ops {
394394
struct stmmac_rss *cfg, u32 num_rxq);
395395
/* VLAN */
396396
void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash,
397-
__le16 perfect_match, bool is_double);
397+
u16 perfect_match, bool is_double);
398398
void (*enable_vlan)(struct mac_device_info *hw, u32 type);
399399
void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc,
400400
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
@@ -6640,7 +6640,7 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)
66406640
static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)
66416641
{
66426642
u32 crc, hash = 0;
6643-
__le16 pmatch = 0;
6643+
u16 pmatch = 0;
66446644
int count = 0;
66456645
u16 vid = 0;
66466646

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

6658-
pmatch = cpu_to_le16(vid);
6658+
pmatch = vid;
66596659
hash = 0;
66606660
}
66616661

0 commit comments

Comments
 (0)