From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 7A6C61B440 for ; Tue, 12 Feb 2019 07:37:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 22:37:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,361,1544515200"; d="scan'208";a="117197771" Received: from pgsmsx108.gar.corp.intel.com ([10.221.44.103]) by orsmga008.jf.intel.com with ESMTP; 11 Feb 2019 22:37:17 -0800 Received: from pgsmsx110.gar.corp.intel.com (10.221.44.111) by PGSMSX108.gar.corp.intel.com (10.221.44.103) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 12 Feb 2019 14:37:15 +0800 Received: from pgsmsx103.gar.corp.intel.com ([169.254.2.6]) by PGSMSX110.gar.corp.intel.com ([169.254.13.64]) with mapi id 14.03.0415.000; Tue, 12 Feb 2019 14:37:15 +0800 From: "Zhao1, Wei" To: Julien Meunier , "Ananyev, Konstantin" , "Lu, Wenzhuo" , "Zhang, Qi Z" CC: "dev@dpdk.org" Thread-Topic: [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550 Thread-Index: AQHUvwrpAlkimOeoGUeLeAfwKpt5HaXbuUIg Date: Tue, 12 Feb 2019 06:37:14 +0000 Message-ID: References: <20190102160055.30301-1-julien.meunier@nokia.com> <20190207173005.38372-1-julien.meunier@nokia.com> <20190207173005.38372-2-julien.meunier@nokia.com> In-Reply-To: <20190207173005.38372-2-julien.meunier@nokia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [172.30.20.206] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Feb 2019 06:37:20 -0000 HI, Meunier && qi > -----Original Message----- > From: Julien Meunier [mailto:julien.meunier@nokia.com] > Sent: Friday, February 8, 2019 1:30 AM > To: Ananyev, Konstantin ; Lu, Wenzhuo > ; Zhao1, Wei ; Zhang, Qi Z > > Cc: dev@dpdk.org > Subject: [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550 >=20 > 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 t= he 82599. >=20 > Signed-off-by: Julien Meunier > --- > 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(-) >=20 > 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 Is it possible to add these two function of ixgbe_setup_phy_autoneg_x540 an= d=20 ixgbe_setup_phy_autoneg_x550 in a file out of base folder? We need to avoid change code in that, is that right? @qi And also, it seems these 2 function do not have much difference,=20 can we use one instead of two function?(This point is not so important) > @@ -1032,3 +1032,29 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw > *hw, u32 index) >=20 > 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 =3D IXGBE_SUCCESS; > + u16 autoneg_reg =3D 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 |=3D IXGBE_MII_AUTONEG_ENABLE; > + else > + autoneg_reg &=3D ~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); >=20 > 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); The Space line seems not needed. > #endif /* _IXGBE_X540_H_ */ >=20 > 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) >=20 > 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 =3D IXGBE_SUCCESS; > + u16 autoneg_reg =3D 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 |=3D IXGBE_MII_AUTONEG_ENABLE; > + else > + autoneg_reg &=3D ~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 */ >=20 > /* 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. > +*/ >=20 > #define IXGBE_MAX_JUMBO_FRAME_SIZE 0x2600 /* Maximum Jumbo > frame size. */ >=20 > diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxt= x.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" >=20 > #ifdef RTE_LIBRTE_IEEE1588 > @@ -3174,6 +3176,7 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev) > unsigned i; > struct ixgbe_adapter *adapter =3D > (struct ixgbe_adapter *)dev->data->dev_private; > + struct ixgbe_hw *hw =3D IXGBE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); >=20 > PMD_INIT_FUNC_TRACE(); >=20 > @@ -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 !=3D 0) { > + if (hw->mac.type =3D=3D ixgbe_mac_X540) > + ixgbe_setup_phy_autoneg_x540(hw, true); > + else if (hw->mac.type =3D=3D ixgbe_mac_X550 || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_x || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_a) > + ixgbe_setup_phy_autoneg_x550(hw, true); > + } > } >=20 > void > @@ -5074,8 +5086,12 @@ ixgbe_check_supported_loopback_mode(struct > rte_eth_dev *dev) { > struct ixgbe_hw *hw =3D IXGBE_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); >=20 > - if (dev->data->dev_conf.lpbk_mode =3D=3D IXGBE_LPBK_82599_TX_RX) > - if (hw->mac.type =3D=3D ixgbe_mac_82599EB) > + if (dev->data->dev_conf.lpbk_mode =3D=3D IXGBE_LPBK_TX_RX) > + if (hw->mac.type =3D=3D ixgbe_mac_82599EB || > + hw->mac.type =3D=3D ixgbe_mac_X540 || > + hw->mac.type =3D=3D ixgbe_mac_X550 || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_x || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_a) > return 0; >=20 > return -ENOTSUP; > @@ -5108,6 +5124,41 @@ ixgbe_setup_loopback_link_82599(struct > ixgbe_hw *hw) > msec_delay(50); > } >=20 > +/* > + * 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 =3D 1 (force link up) */ > + macc =3D IXGBE_READ_REG(hw, IXGBE_MACC); > + macc |=3D 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 =3D 1 (force link up) */ > + macc =3D IXGBE_READ_REG(hw, IXGBE_MACC); > + macc |=3D IXGBE_MACC_FLU; > + IXGBE_WRITE_REG(hw, IXGBE_MACC, macc); } >=20 > /* > * 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 !=3D 0) { > if (hw->mac.type =3D=3D ixgbe_mac_82599EB) > ixgbe_setup_loopback_link_82599(hw); > + else if (hw->mac.type =3D=3D ixgbe_mac_X540) > + ixgbe_setup_loopback_link_x540(hw); > + else if (hw->mac.type =3D=3D ixgbe_mac_X550 || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_x || > + hw->mac.type =3D=3D ixgbe_mac_X550EM_a) > + ixgbe_setup_loopback_link_x550(hw); The same, why do we have 2 branch for x540 and x550? > } >=20 > #ifdef RTE_LIBRTE_SECURITY > -- > 2.10.2