DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhao1, Wei" <wei.zhao1@intel.com>
To: Julien Meunier <julien.meunier@nokia.com>,
	"Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
	"Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
	"Zhang, Qi Z" <qi.z.zhang@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550
Date: Tue, 12 Feb 2019 06:37:14 +0000	[thread overview]
Message-ID: <A2573D2ACFCADC41BB3BE09C6DE313CA07EB1E9A@PGSMSX103.gar.corp.intel.com> (raw)
In-Reply-To: <20190207173005.38372-2-julien.meunier@nokia.com>

HI,  Meunier && qi

> -----Original Message-----
> From: Julien Meunier [mailto:julien.meunier@nokia.com]
> Sent: Friday, February 8, 2019 1:30 AM
> To: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; Zhao1, Wei <wei.zhao1@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550
> 
> 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.meunier@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


Is it possible to add these two function of ixgbe_setup_phy_autoneg_x540 and 
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, 
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)
> 
>  	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);

The Space line seems not needed.

>  #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);

The same, why do we have 2 branch for x540 and x550?

>  	}
> 
>  #ifdef RTE_LIBRTE_SECURITY
> --
> 2.10.2

  reply	other threads:[~2019-02-12  6:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 16:00 [dpdk-dev] [PATCH] " Julien Meunier
2019-01-07  6:53 ` Zhang, Qi Z
2019-01-07 15:53   ` Meunier, Julien (Nokia - FR/Paris-Saclay)
2019-01-08 10:10     ` Zhao1, Wei
2019-01-08 12:39       ` Zhang, Qi Z
2019-01-08 20:18         ` Meunier, Julien (Nokia - FR/Paris-Saclay)
2019-01-09  1:30         ` Zhao1, Wei
2019-01-07 10:05 ` Zhao1, Wei
2019-01-07 16:04   ` Meunier, Julien (Nokia - FR/Paris-Saclay)
2019-01-08  3:10     ` Zhao1, Wei
2019-02-07 17:30 ` [dpdk-dev] [PATCH 1/2] net/ixgbe: do not start on unsupported loopback mode Julien Meunier
2019-02-07 17:30   ` [dpdk-dev] [PATCH 2/2] net/ixgbe: add support of loopback for X540/X550 Julien Meunier
2019-02-12  6:37     ` Zhao1, Wei [this message]
2019-02-18 11:20       ` Meunier, Julien (Nokia - FR/Paris-Saclay)
2019-02-12  6:36   ` [dpdk-dev] [PATCH 1/2] net/ixgbe: do not start on unsupported loopback mode Zhao1, Wei
2019-02-20 21:05 ` [dpdk-dev] [PATCH v3 " Julien Meunier
2019-02-20 21:05   ` [dpdk-dev] [PATCH v3 2/2] net/ixgbe: add support of loopback for X540/X550 Julien Meunier
2019-02-21  2:30     ` Zhao1, Wei
2019-03-01  7:46       ` Zhang, Qi Z
2019-03-01  7:45   ` [dpdk-dev] [PATCH v3 1/2] net/ixgbe: do not start on unsupported loopback mode Zhang, Qi Z

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A2573D2ACFCADC41BB3BE09C6DE313CA07EB1E9A@PGSMSX103.gar.corp.intel.com \
    --to=wei.zhao1@intel.com \
    --cc=dev@dpdk.org \
    --cc=julien.meunier@nokia.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).