net: enetc: replace PCVLANR1/2 with SICVLANR1/2 and remove dead branch
Wei Fang
maintainerPATCH v2 1/1 net: enetc: replace PCVLANR1/2 with SICVLANR1/2 and remove dead branch
Both PF and VF have rx-vlan-offload enabled, however, the PCVLANR1/2 registers are resources controlled by PF, so VF cannot access these two registers. Fortunately, the hardware provides SICVLANR1/2 registers for each SI to reflect the value of PCVLANR1/2 registers. Therefore, use SICVLANR1/2 instead of PCVLANR1/2. Note that this is not an issue in actual use, because the current driver does not support custom TPID, the driver will not access these two registers in actual use, so this modification is just an optimization.
In addition, since ENETC_RXBD_FLAG_TPID is defined as GENMASK(1, 0), the possible values are only 0, 1, 2, 3, so the default branch will never be true, so remove the default branch.
---
v1 link: https://lore.kernel.org/imx/[email protected]/
v2 changes:
1. Change target tree to net-next and modify the subject
2. Add a description in the commit message that the current patch is just an optimization.
3. The definitions of ENETC_PCVLANR1 and ENETC_PCVLANR2 are retained
--- drivers/net/ethernet/freescale/enetc/enetc.c | 12 +++++------- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/freescale/enetc/enetc.c +5 -7
@@ -1375,6 +1375,7 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring, }if (le16_to_cpu (rxbd->r.flags) &ENETC_RXBD_FLAG_VLAN ) { +struct enetc_hw *hw = &priv->si->hw;__be16 tpid =0 ;switch (le16_to_cpu (rxbd->r.flags) &ENETC_RXBD_FLAG_TPID ) {
@@ -1385,15 +1386,12 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring, tpid =htons (ETH_P_8021AD );break ;case 2 : - tpid =htons (enetc_port_rd (&priv->si->hw, -ENETC_PCVLANR1 )); + tpid =htons (enetc_rd_hot (hw,ENETC_SICVLANR1 ) & +SICVLANR_ETYPE );break ;case 3 : - tpid =htons (enetc_port_rd (&priv->si->hw, -ENETC_PCVLANR2 )); -break ; -default : -break ; + tpid =htons (enetc_rd_hot (hw,ENETC_SICVLANR2 ) & +SICVLANR_ETYPE ); }__vlan_hwaccel_put_tag (skb, tpid,le16_to_cpu (rxbd->r.vlan_opt));
drivers/net/ethernet/freescale/enetc/enetc_hw.h +3 -0
@@ -43,6 +43,9 @@#define ENETC_SIPMAR0 0x80#define ENETC_SIPMAR1 0x84 +#define ENETC_SICVLANR1 0x90 +#define ENETC_SICVLANR2 0x94 +#define SICVLANR_ETYPE GENMASK(15, 0)/* VF-PF Message passing */ #define ENETC_DEFAULT_MSG_SIZE 1024/* and max size */
Signature · 1 line
2.34.1
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 10 lines · On Fri, 13 Jun 2025 17:36:05 +0800 you wrote:
Both PF and VF have rx-vlan-offload enabled, however, the PCVLANR1/2 registers are resources controlled by PF, so VF cannot access these two registers. Fortunately, the hardware provides SICVLANR1/2 registers for each SI to reflect the value of PCVLANR1/2 registers. Therefore, use SICVLANR1/2 instead of PCVLANR1/2. Note that this is not an issue in actual use, because the current driver does not support custom TPID, the driver will not access these two registers in actual use, so this modification is just an optimization.
[...]
Here is the summary with links:
- [v2,net-next] net: enetc: replace PCVLANR1/2 with SICVLANR1/2 and remove dead branch
https://git.kernel.org/netdev/net-next/c/dd4a5780f7d9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html