Message ID | 20210324154455.1899941-1-olteanv@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 110eccdb2469b9b54e509db1b3ea12a0626b7967 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,1/2] net: enetc: don't depend on system endianness in enetc_set_vlan_ht_filter | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | success | CCed 4 of 4 maintainers |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 21 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
>-----Original Message----- >From: Vladimir Oltean <olteanv@gmail.com> >Sent: Wednesday, March 24, 2021 5:45 PM >To: Jakub Kicinski <kuba@kernel.org>; David S. Miller ><davem@davemloft.net> >Cc: netdev@vger.kernel.org; Claudiu Manoil <claudiu.manoil@nxp.com>; >Vladimir Oltean <vladimir.oltean@nxp.com> >Subject: [PATCH net-next 1/2] net: enetc: don't depend on system >endianness in enetc_set_vlan_ht_filter > >From: Vladimir Oltean <vladimir.oltean@nxp.com> > >ENETC has a 64-entry hash table for VLAN RX filtering per Station >Interface, which is accessed through two 32-bit registers: VHFR0 holding >the low portion, and VHFR1 holding the high portion. > >The enetc_set_vlan_ht_filter function looks at the pf->vlan_ht_filter >bitmap, which is fundamentally an unsigned long variable, and casts it >to a u32 array of two elements. It puts the first u32 element into VHFR0 >and the second u32 element into VHFR1. > >It is easy to imagine that this will not work on big endian systems >(although, yes, we have bigger problems, because currently enetc assumes >that the CPU endianness is equal to the controller endianness, aka >little endian - but let's assume that we could add a cpu_to_le32 in >enetc_wd_reg and a le32_to_cpu in enetc_rd_reg). > >Let's use lower_32_bits and upper_32_bits which are designed to work >regardless of endianness. > >Tested that both the old and the new method produce the same results: > >$ ethtool -K eth1 rx-vlan-filter on >$ ip link add link eth1 name eth1.100 type vlan id 100 >enetc_set_vlan_ht_filter: method 1: si_idx 0 VHFR0 0x0 VHFR1 0x20 >enetc_set_vlan_ht_filter: method 2: si_idx 0 VHFR0 0x0 VHFR1 0x20 >$ ip link add link eth1 name eth1.101 type vlan id 101 >enetc_set_vlan_ht_filter: method 1: si_idx 0 VHFR0 0x0 VHFR1 0x30 >enetc_set_vlan_ht_filter: method 2: si_idx 0 VHFR0 0x0 VHFR1 0x30 >$ ip link add link eth1 name eth1.34 type vlan id 34 >enetc_set_vlan_ht_filter: method 1: si_idx 0 VHFR0 0x0 VHFR1 0x34 >enetc_set_vlan_ht_filter: method 2: si_idx 0 VHFR0 0x0 VHFR1 0x34 >$ ip link add link eth1 name eth1.1024 type vlan id 1024 >enetc_set_vlan_ht_filter: method 1: si_idx 0 VHFR0 0x1 VHFR1 0x34 >enetc_set_vlan_ht_filter: method 2: si_idx 0 VHFR0 0x1 VHFR1 0x34 > >Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Hello: This series was applied to netdev/net-next.git (refs/heads/master): On Wed, 24 Mar 2021 17:44:54 +0200 you wrote: > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > ENETC has a 64-entry hash table for VLAN RX filtering per Station > Interface, which is accessed through two 32-bit registers: VHFR0 holding > the low portion, and VHFR1 holding the high portion. > > The enetc_set_vlan_ht_filter function looks at the pf->vlan_ht_filter > bitmap, which is fundamentally an unsigned long variable, and casts it > to a u32 array of two elements. It puts the first u32 element into VHFR0 > and the second u32 element into VHFR1. > > [...] Here is the summary with links: - [net-next,1/2] net: enetc: don't depend on system endianness in enetc_set_vlan_ht_filter https://git.kernel.org/netdev/net-next/c/110eccdb2469 - [net-next,2/2] net: enetc: don't depend on system endianness in enetc_set_mac_ht_flt https://git.kernel.org/netdev/net-next/c/e366a39208e5 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 3a7a9102eccb..9c69ca516192 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -248,10 +248,10 @@ static void enetc_pf_set_rx_mode(struct net_device *ndev) } static void enetc_set_vlan_ht_filter(struct enetc_hw *hw, int si_idx, - u32 *hash) + unsigned long hash) { - enetc_port_wr(hw, ENETC_PSIVHFR0(si_idx), *hash); - enetc_port_wr(hw, ENETC_PSIVHFR1(si_idx), *(hash + 1)); + enetc_port_wr(hw, ENETC_PSIVHFR0(si_idx), lower_32_bits(hash)); + enetc_port_wr(hw, ENETC_PSIVHFR1(si_idx), upper_32_bits(hash)); } static int enetc_vid_hash_idx(unsigned int vid) @@ -279,7 +279,7 @@ static void enetc_sync_vlan_ht_filter(struct enetc_pf *pf, bool rehash) } } - enetc_set_vlan_ht_filter(&pf->si->hw, 0, (u32 *)pf->vlan_ht_filter); + enetc_set_vlan_ht_filter(&pf->si->hw, 0, *pf->vlan_ht_filter); } static int enetc_vlan_rx_add_vid(struct net_device *ndev, __be16 prot, u16 vid)