* Re: [Intel-wired-lan] [PATCH intel-net] ixgbe: allow toggling loopback mode via ndo_set_features callback [not found] <20230321003524.700353-1-maxwillma0713@gmail.com> @ 2023-04-04 9:35 ` Maciej Fijalkowski 0 siblings, 0 replies; 2+ messages in thread From: Maciej Fijalkowski @ 2023-04-04 9:35 UTC (permalink / raw) To: Hao Ma Cc: Hao Ma, netdev, jesse.brandeburg, anthony.l.nguyen, intel-wired-lan, magnus.karlsson On Tue, Mar 21, 2023 at 08:35:24AM +0800, Hao Ma wrote: > From: Hao Ma <hao.ma@intel.com> > > Add support for NETIF_F_LOOPBACK. This feature can be set via: > $ ethtool -K eth0 loopback <on|off> > > This sets the MAC Tx->Rx loopback used by selftests/bpf/xskxceiver Can you resend this patch please? It seems it didn't arrive to iwl nor netdev. > > Signed-off-by: Hao Ma <hao.ma@intel.com> > --- > .../net/ethernet/intel/ixgbe/ixgbe_common.c | 4 +- > drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 73 +++++++++++++++++++ > drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 + > 3 files changed, 76 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > index 38c4609bd429..a39dd2d11bc8 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > @@ -3336,7 +3336,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, > > if (link_up_wait_to_complete) { > for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { > - if (links_reg & IXGBE_LINKS_UP) { > + if (links_reg & IXGBE_LINKS_UP || hw->loopback_on) { > *link_up = true; > break; > } else { > @@ -3346,7 +3346,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, > links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); > } > } else { > - if (links_reg & IXGBE_LINKS_UP) > + if (links_reg & IXGBE_LINKS_UP || hw->loopback_on) > *link_up = true; > else > *link_up = false; > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > index ab8370c413f3..e5624d1fc6c3 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > @@ -8874,6 +8874,57 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, > return NETDEV_TX_OK; > } > > +static int ixgbe_force_loopback(struct ixgbe_adapter *adapter, bool on) > +{ struct ixgbe_hw *hw = &adapter->hw; > + u32 reg_data; > + > + hw->loopback_on = on; > + /* Setup MAC loopback */ > + reg_data = IXGBE_READ_REG(hw, IXGBE_HLREG0); > + if (on) > + reg_data |= IXGBE_HLREG0_LPBK; > + else > + reg_data &= ~IXGBE_HLREG0_LPBK; > + IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_data); > + > + reg_data = IXGBE_READ_REG(hw, IXGBE_FCTRL); > + if (on) > + reg_data |= IXGBE_FCTRL_SBP | IXGBE_FCTRL_MPE; > + else > + reg_data &= ~(IXGBE_FCTRL_SBP | IXGBE_FCTRL_MPE); > + reg_data &= ~(IXGBE_FCTRL_BAM); > + IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg_data); > + > + /* X540 and X550 needs to set the MACC.FLU bit to force link up */ > + switch (adapter->hw.mac.type) { > + case ixgbe_mac_X540: > + case ixgbe_mac_X550: > + case ixgbe_mac_X550EM_x: > + case ixgbe_mac_x550em_a: > + reg_data = IXGBE_READ_REG(hw, IXGBE_MACC); > + if (on) > + reg_data |= IXGBE_MACC_FLU; > + else > + reg_data &= ~IXGBE_MACC_FLU; > + IXGBE_WRITE_REG(hw, IXGBE_MACC, reg_data); > + break; > + default: > + if (hw->mac.orig_autoc) { > + if (on) > + reg_data = hw->mac.orig_autoc | IXGBE_AUTOC_FLU; > + else > + reg_data = hw->mac.orig_autoc & ~IXGBE_AUTOC_FLU; > + IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_data); > + } else { > + return 10; > + } > + } > + > + IXGBE_WRITE_FLUSH(hw); > + > + return 0; > +} > + > static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb, > struct net_device *netdev, > struct ixgbe_ring *ring) > @@ -9923,6 +9974,15 @@ static int ixgbe_set_features(struct net_device *netdev, > if (changed & NETIF_F_RXALL) > need_reset = true; > > + if (changed & NETIF_F_LOOPBACK) { > + if (features & NETIF_F_LOOPBACK) { > + ixgbe_force_loopback(adapter, true); > + } else { > + ixgbe_force_loopback(adapter, false); > + need_reset = true; > + } > + } > + > netdev->features = features; > > if ((changed & NETIF_F_HW_L2FW_DOFFLOAD) && adapter->num_rx_pools > 1) > @@ -10296,6 +10356,17 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) > /* Wait until ndo_xsk_wakeup completes. */ > synchronize_rcu(); > err = ixgbe_setup_tc(dev, adapter->hw_tcs); > + if (adapter->hw.loopback_on) { > + u32 reg_data; > + > + reg_data = IXGBE_READ_REG(&adapter->hw, IXGBE_HLREG0); > + reg_data |= IXGBE_HLREG0_LPBK; > + IXGBE_WRITE_REG(&adapter->hw, IXGBE_HLREG0, reg_data); > + > + reg_data = IXGBE_READ_REG(&adapter->hw, IXGBE_MACC); > + reg_data |= IXGBE_MACC_FLU; > + IXGBE_WRITE_REG(&adapter->hw, IXGBE_MACC, reg_data); > + } > > if (err) { > rcu_assign_pointer(adapter->xdp_prog, old_prog); > @@ -10979,6 +11050,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > if (hw->mac.type >= ixgbe_mac_82599EB) > netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_GSO_UDP_L4; > > + netdev->features |= NETIF_F_LOOPBACK; > + > #ifdef CONFIG_IXGBE_IPSEC > #define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \ > NETIF_F_HW_ESP_TX_CSUM | \ > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > index 2b00db92b08f..ca50ccd59b50 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > @@ -3652,6 +3652,7 @@ struct ixgbe_hw { > bool allow_unsupported_sfp; > bool wol_enabled; > bool need_crosstalk_fix; > + bool loopback_on; > }; > > struct ixgbe_info { > -- > 2.34.1 > _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH intel-net] ixgbe: allow toggling loopback mode via ndo_set_features callback @ 2023-04-04 9:35 ` Maciej Fijalkowski 0 siblings, 0 replies; 2+ messages in thread From: Maciej Fijalkowski @ 2023-04-04 9:35 UTC (permalink / raw) To: Hao Ma Cc: intel-wired-lan, anthony.l.nguyen, jesse.brandeburg, netdev, magnus.karlsson, Hao Ma On Tue, Mar 21, 2023 at 08:35:24AM +0800, Hao Ma wrote: > From: Hao Ma <hao.ma@intel.com> > > Add support for NETIF_F_LOOPBACK. This feature can be set via: > $ ethtool -K eth0 loopback <on|off> > > This sets the MAC Tx->Rx loopback used by selftests/bpf/xskxceiver Can you resend this patch please? It seems it didn't arrive to iwl nor netdev. > > Signed-off-by: Hao Ma <hao.ma@intel.com> > --- > .../net/ethernet/intel/ixgbe/ixgbe_common.c | 4 +- > drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 73 +++++++++++++++++++ > drivers/net/ethernet/intel/ixgbe/ixgbe_type.h | 1 + > 3 files changed, 76 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > index 38c4609bd429..a39dd2d11bc8 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c > @@ -3336,7 +3336,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, > > if (link_up_wait_to_complete) { > for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { > - if (links_reg & IXGBE_LINKS_UP) { > + if (links_reg & IXGBE_LINKS_UP || hw->loopback_on) { > *link_up = true; > break; > } else { > @@ -3346,7 +3346,7 @@ s32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw, ixgbe_link_speed *speed, > links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS); > } > } else { > - if (links_reg & IXGBE_LINKS_UP) > + if (links_reg & IXGBE_LINKS_UP || hw->loopback_on) > *link_up = true; > else > *link_up = false; > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > index ab8370c413f3..e5624d1fc6c3 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c > @@ -8874,6 +8874,57 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb, > return NETDEV_TX_OK; > } > > +static int ixgbe_force_loopback(struct ixgbe_adapter *adapter, bool on) > +{ struct ixgbe_hw *hw = &adapter->hw; > + u32 reg_data; > + > + hw->loopback_on = on; > + /* Setup MAC loopback */ > + reg_data = IXGBE_READ_REG(hw, IXGBE_HLREG0); > + if (on) > + reg_data |= IXGBE_HLREG0_LPBK; > + else > + reg_data &= ~IXGBE_HLREG0_LPBK; > + IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg_data); > + > + reg_data = IXGBE_READ_REG(hw, IXGBE_FCTRL); > + if (on) > + reg_data |= IXGBE_FCTRL_SBP | IXGBE_FCTRL_MPE; > + else > + reg_data &= ~(IXGBE_FCTRL_SBP | IXGBE_FCTRL_MPE); > + reg_data &= ~(IXGBE_FCTRL_BAM); > + IXGBE_WRITE_REG(hw, IXGBE_FCTRL, reg_data); > + > + /* X540 and X550 needs to set the MACC.FLU bit to force link up */ > + switch (adapter->hw.mac.type) { > + case ixgbe_mac_X540: > + case ixgbe_mac_X550: > + case ixgbe_mac_X550EM_x: > + case ixgbe_mac_x550em_a: > + reg_data = IXGBE_READ_REG(hw, IXGBE_MACC); > + if (on) > + reg_data |= IXGBE_MACC_FLU; > + else > + reg_data &= ~IXGBE_MACC_FLU; > + IXGBE_WRITE_REG(hw, IXGBE_MACC, reg_data); > + break; > + default: > + if (hw->mac.orig_autoc) { > + if (on) > + reg_data = hw->mac.orig_autoc | IXGBE_AUTOC_FLU; > + else > + reg_data = hw->mac.orig_autoc & ~IXGBE_AUTOC_FLU; > + IXGBE_WRITE_REG(hw, IXGBE_AUTOC, reg_data); > + } else { > + return 10; > + } > + } > + > + IXGBE_WRITE_FLUSH(hw); > + > + return 0; > +} > + > static netdev_tx_t __ixgbe_xmit_frame(struct sk_buff *skb, > struct net_device *netdev, > struct ixgbe_ring *ring) > @@ -9923,6 +9974,15 @@ static int ixgbe_set_features(struct net_device *netdev, > if (changed & NETIF_F_RXALL) > need_reset = true; > > + if (changed & NETIF_F_LOOPBACK) { > + if (features & NETIF_F_LOOPBACK) { > + ixgbe_force_loopback(adapter, true); > + } else { > + ixgbe_force_loopback(adapter, false); > + need_reset = true; > + } > + } > + > netdev->features = features; > > if ((changed & NETIF_F_HW_L2FW_DOFFLOAD) && adapter->num_rx_pools > 1) > @@ -10296,6 +10356,17 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog) > /* Wait until ndo_xsk_wakeup completes. */ > synchronize_rcu(); > err = ixgbe_setup_tc(dev, adapter->hw_tcs); > + if (adapter->hw.loopback_on) { > + u32 reg_data; > + > + reg_data = IXGBE_READ_REG(&adapter->hw, IXGBE_HLREG0); > + reg_data |= IXGBE_HLREG0_LPBK; > + IXGBE_WRITE_REG(&adapter->hw, IXGBE_HLREG0, reg_data); > + > + reg_data = IXGBE_READ_REG(&adapter->hw, IXGBE_MACC); > + reg_data |= IXGBE_MACC_FLU; > + IXGBE_WRITE_REG(&adapter->hw, IXGBE_MACC, reg_data); > + } > > if (err) { > rcu_assign_pointer(adapter->xdp_prog, old_prog); > @@ -10979,6 +11050,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) > if (hw->mac.type >= ixgbe_mac_82599EB) > netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_GSO_UDP_L4; > > + netdev->features |= NETIF_F_LOOPBACK; > + > #ifdef CONFIG_IXGBE_IPSEC > #define IXGBE_ESP_FEATURES (NETIF_F_HW_ESP | \ > NETIF_F_HW_ESP_TX_CSUM | \ > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > index 2b00db92b08f..ca50ccd59b50 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h > @@ -3652,6 +3652,7 @@ struct ixgbe_hw { > bool allow_unsupported_sfp; > bool wol_enabled; > bool need_crosstalk_fix; > + bool loopback_on; > }; > > struct ixgbe_info { > -- > 2.34.1 > ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-04 9:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230321003524.700353-1-maxwillma0713@gmail.com>
2023-04-04 9:35 ` [Intel-wired-lan] [PATCH intel-net] ixgbe: allow toggling loopback mode via ndo_set_features callback Maciej Fijalkowski
2023-04-04 9:35 ` Maciej Fijalkowski
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.