Loopback mode is also supported on X540 and X550 NICs, according to their datasheet (section 15.2). The way to set it up is a little different of the 82599.
Signed-off-by: Julien Meunier <julien.meun...@nokia.com> --- v2: - disable / enable autoneg when loopback is requested for X540 / X550 --- drivers/net/ixgbe/base/ixgbe_type.h | 1 + drivers/net/ixgbe/base/ixgbe_x540.c | 26 ++++++++++++++++ drivers/net/ixgbe/base/ixgbe_x540.h | 2 ++ drivers/net/ixgbe/base/ixgbe_x550.c | 26 ++++++++++++++++ drivers/net/ixgbe/base/ixgbe_x550.h | 1 + drivers/net/ixgbe/ixgbe_ethdev.h | 5 ++- drivers/net/ixgbe/ixgbe_rxtx.c | 61 +++++++++++++++++++++++++++++++++++-- 7 files changed, 117 insertions(+), 5 deletions(-) diff --git a/drivers/net/ixgbe/base/ixgbe_type.h b/drivers/net/ixgbe/base/ixgbe_type.h index 077b8f0..c4af31e 100644 --- a/drivers/net/ixgbe/base/ixgbe_type.h +++ b/drivers/net/ixgbe/base/ixgbe_type.h @@ -1649,6 +1649,7 @@ struct ixgbe_dmac_config { #define IXGBE_MII_5GBASE_T_ADVERTISE 0x0800 #define IXGBE_MII_100BASE_T_ADVERTISE 0x0100 /* full duplex, bit:8 */ #define IXGBE_MII_100BASE_T_ADVERTISE_HALF 0x0080 /* half duplex, bit:7 */ +#define IXGBE_MII_AUTONEG_ENABLE 0x1000 #define IXGBE_MII_RESTART 0x200 #define IXGBE_MII_AUTONEG_COMPLETE 0x20 #define IXGBE_MII_AUTONEG_LINK_UP 0x04 diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c b/drivers/net/ixgbe/base/ixgbe_x540.c index f00f0ea..a241d41 100644 --- a/drivers/net/ixgbe/base/ixgbe_x540.c +++ b/drivers/net/ixgbe/base/ixgbe_x540.c @@ -1032,3 +1032,29 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index) return IXGBE_SUCCESS; } + +/* + * ixgbe_setup_phy_link_x540 - Enable/disable the autoneg + * @hw: pointer to hardware structure + * enable: enable/disable the autoneg + **/ +s32 ixgbe_setup_phy_autoneg_x540(struct ixgbe_hw *hw, bool enable) +{ + s32 status = IXGBE_SUCCESS; + u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; + + DEBUGFUNC("ixgbe_setup_phy_autoneg_x540"); + + hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg); + + if (enable) + autoneg_reg |= IXGBE_MII_AUTONEG_ENABLE; + else + autoneg_reg &= ~IXGBE_MII_AUTONEG_ENABLE; + + hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg); + + return status; +} diff --git a/drivers/net/ixgbe/base/ixgbe_x540.h b/drivers/net/ixgbe/base/ixgbe_x540.h index 231dfe5..ef939ce 100644 --- a/drivers/net/ixgbe/base/ixgbe_x540.h +++ b/drivers/net/ixgbe/base/ixgbe_x540.h @@ -34,5 +34,7 @@ void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw); s32 ixgbe_blink_led_start_X540(struct ixgbe_hw *hw, u32 index); s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index); + +s32 ixgbe_setup_phy_autoneg_x540(struct ixgbe_hw *hw, bool enable); #endif /* _IXGBE_X540_H_ */ diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c b/drivers/net/ixgbe/base/ixgbe_x550.c index a920a14..f4ee188 100644 --- a/drivers/net/ixgbe/base/ixgbe_x550.c +++ b/drivers/net/ixgbe/base/ixgbe_x550.c @@ -4652,3 +4652,29 @@ bool ixgbe_fw_recovery_mode_X550(struct ixgbe_hw *hw) return !!(fwsm & IXGBE_FWSM_FW_NVM_RECOVERY_MODE); } + +/* + * ixgbe_setup_phy_link_x550 - Enable/disable the autoneg + * @hw: pointer to hardware structure + * enable: enable/disable the autoneg + **/ +s32 ixgbe_setup_phy_autoneg_x550(struct ixgbe_hw *hw, bool enable) +{ + s32 status = IXGBE_SUCCESS; + u16 autoneg_reg = IXGBE_MII_AUTONEG_REG; + + DEBUGFUNC("ixgbe_setup_phy_autoneg_x550"); + + hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg); + + if (enable) + autoneg_reg |= IXGBE_MII_AUTONEG_ENABLE; + else + autoneg_reg &= ~IXGBE_MII_AUTONEG_ENABLE; + + hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL, + IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg); + + return status; +} diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h b/drivers/net/ixgbe/base/ixgbe_x550.h index 3bd98f2..dd4fa18 100644 --- a/drivers/net/ixgbe/base/ixgbe_x550.h +++ b/drivers/net/ixgbe/base/ixgbe_x550.h @@ -93,4 +93,5 @@ s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw); s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx); s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx); bool ixgbe_fw_recovery_mode_X550(struct ixgbe_hw *hw); +s32 ixgbe_setup_phy_autoneg_x550(struct ixgbe_hw *hw, bool enable); #endif /* _IXGBE_X550_H_ */ diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 565c69c..c60a697 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -65,9 +65,8 @@ #define IXGBE_QUEUE_ITR_INTERVAL_DEFAULT 500 /* 500us */ /* Loopback operation modes */ -/* 82599 specific loopback operation types */ -#define IXGBE_LPBK_82599_NONE 0x0 /* Default value. Loopback is disabled. */ -#define IXGBE_LPBK_82599_TX_RX 0x1 /* Tx->Rx loopback operation is enabled. */ +#define IXGBE_LPBK_NONE 0x0 /* Default value. Loopback is disabled. */ +#define IXGBE_LPBK_TX_RX 0x1 /* Tx->Rx loopback operation is enabled. */ #define IXGBE_MAX_JUMBO_FRAME_SIZE 0x2600 /* Maximum Jumbo frame size. */ diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index c9a70a8..1472d13 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -49,6 +49,8 @@ #include "ixgbe_ethdev.h" #include "base/ixgbe_dcb.h" #include "base/ixgbe_common.h" +#include "base/ixgbe_x540.h" +#include "base/ixgbe_x550.h" #include "ixgbe_rxtx.h" #ifdef RTE_LIBRTE_IEEE1588 @@ -3174,6 +3176,7 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev) unsigned i; struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)dev->data->dev_private; + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); PMD_INIT_FUNC_TRACE(); @@ -3194,6 +3197,15 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev) ixgbe_reset_rx_queue(adapter, rxq); } } + /* If loopback mode was enabled, reconfigure the link accordingly */ + if (dev->data->dev_conf.lpbk_mode != 0) { + if (hw->mac.type == ixgbe_mac_X540) + ixgbe_setup_phy_autoneg_x540(hw, true); + else if (hw->mac.type == ixgbe_mac_X550 || + hw->mac.type == ixgbe_mac_X550EM_x || + hw->mac.type == ixgbe_mac_X550EM_a) + ixgbe_setup_phy_autoneg_x550(hw, true); + } } void @@ -5074,8 +5086,12 @@ ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if (dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX) - if (hw->mac.type == ixgbe_mac_82599EB) + if (dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_TX_RX) + if (hw->mac.type == ixgbe_mac_82599EB || + hw->mac.type == ixgbe_mac_X540 || + hw->mac.type == ixgbe_mac_X550 || + hw->mac.type == ixgbe_mac_X550EM_x || + hw->mac.type == ixgbe_mac_X550EM_a) return 0; return -ENOTSUP; @@ -5108,6 +5124,41 @@ ixgbe_setup_loopback_link_82599(struct ixgbe_hw *hw) msec_delay(50); } +/* + * Set up link loopback for X540 mode Tx->Rx. + */ +static inline void __attribute__((cold)) +ixgbe_setup_loopback_link_x540(struct ixgbe_hw *hw) +{ + uint32_t macc; + PMD_INIT_FUNC_TRACE(); + + /* datasheet 15.2.1: disable AUTONEG (PHY Bit 7.0.C) */ + ixgbe_setup_phy_autoneg_x540(hw, false); + + /* datasheet 15.2.1: MACC.FLU = 1 (force link up) */ + macc = IXGBE_READ_REG(hw, IXGBE_MACC); + macc |= IXGBE_MACC_FLU; + IXGBE_WRITE_REG(hw, IXGBE_MACC, macc); +} + +/* + * Set up link loopback for X550 mode Tx->Rx. + */ +static inline void __attribute__((cold)) +ixgbe_setup_loopback_link_x550(struct ixgbe_hw *hw) +{ + uint32_t macc; + PMD_INIT_FUNC_TRACE(); + + /* datasheet 15.2.1: disable AUTONEG (PHY Bit 7.0.C) */ + ixgbe_setup_phy_autoneg_x550(hw, false); + + /* datasheet 15.2.1: MACC.FLU = 1 (force link up) */ + macc = IXGBE_READ_REG(hw, IXGBE_MACC); + macc |= IXGBE_MACC_FLU; + IXGBE_WRITE_REG(hw, IXGBE_MACC, macc); +} /* * Start Transmit and Receive Units. @@ -5172,6 +5223,12 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev) if (dev->data->dev_conf.lpbk_mode != 0) { if (hw->mac.type == ixgbe_mac_82599EB) ixgbe_setup_loopback_link_82599(hw); + else if (hw->mac.type == ixgbe_mac_X540) + ixgbe_setup_loopback_link_x540(hw); + else if (hw->mac.type == ixgbe_mac_X550 || + hw->mac.type == ixgbe_mac_X550EM_x || + hw->mac.type == ixgbe_mac_X550EM_a) + ixgbe_setup_loopback_link_x550(hw); } #ifdef RTE_LIBRTE_SECURITY -- 2.10.2