DPDK patches and discussions
 help / color / mirror / Atom feed
From: Julien Meunier <julien.meunier@nokia.com>
To: <wei.zhao1@intel.com>, <qi.z.zhang@intel.com>,
	Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Konstantin Ananyev <konstantin.ananyev@intel.com>
Cc: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v3 2/2] net/ixgbe: add support of loopback for X540/X550
Date: Wed, 20 Feb 2019 23:05:30 +0200	[thread overview]
Message-ID: <20190220210531.48322-2-julien.meunier@nokia.com> (raw)
In-Reply-To: <20190220210531.48322-1-julien.meunier@nokia.com>

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>
---
v3:
- reorganize and merge common code
- restore MACC_FLU on stop
v2:
- disable / enable autoneg when loopback is requested for X540 / X550
---
 drivers/net/ixgbe/ixgbe_ethdev.h |  7 +++---
 drivers/net/ixgbe/ixgbe_rxtx.c   | 53 ++++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 565c69c..99a5077 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h
+++ b/drivers/net/ixgbe/ixgbe_ethdev.h
@@ -65,9 +65,10 @@
 #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. */
+/* X540-X550 specific loopback operations */
+#define IXGBE_MII_AUTONEG_ENABLE        0x1000 /* Auto-negociation enable (default = 1) */
 
 #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..e92a70f 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -3168,12 +3168,44 @@ ixgbe_dev_tx_descriptor_status(void *tx_queue, uint16_t offset)
 	return RTE_ETH_TX_DESC_FULL;
 }
 
+/*
+ * Set up link loopback for X540/X550 mode Tx->Rx.
+ */
+static inline void __attribute__((cold))
+ixgbe_setup_loopback_link_x540_x550(struct ixgbe_hw *hw, bool enable)
+{
+	uint32_t macc;
+	PMD_INIT_FUNC_TRACE();
+
+	u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
+
+	hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+			     IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
+	macc = IXGBE_READ_REG(hw, IXGBE_MACC);
+
+	if (enable) {
+		/* datasheet 15.2.1: disable AUTONEG (PHY Bit 7.0.C) */
+		autoneg_reg |= IXGBE_MII_AUTONEG_ENABLE;
+		/* datasheet 15.2.1: MACC.FLU = 1 (force link up) */
+		macc |= IXGBE_MACC_FLU;
+	} else {
+		autoneg_reg &= ~IXGBE_MII_AUTONEG_ENABLE;
+		macc &= ~IXGBE_MACC_FLU;
+	}
+
+	hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
+			      IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
+
+	IXGBE_WRITE_REG(hw, IXGBE_MACC, macc);
+}
+
 void __attribute__((cold))
 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 +3226,14 @@ 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 ||
+		     hw->mac.type == ixgbe_mac_X550 ||
+		     hw->mac.type == ixgbe_mac_X550EM_x ||
+		     hw->mac.type == ixgbe_mac_X550EM_a)
+			ixgbe_setup_loopback_link_x540_x550(hw, false);
+	}
 }
 
 void
@@ -5074,8 +5114,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;
@@ -5172,6 +5216,11 @@ 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 ||
+		     hw->mac.type == ixgbe_mac_X550 ||
+		     hw->mac.type == ixgbe_mac_X550EM_x ||
+		     hw->mac.type == ixgbe_mac_X550EM_a)
+			ixgbe_setup_loopback_link_x540_x550(hw, true);
 	}
 
 #ifdef RTE_LIBRTE_SECURITY
-- 
2.10.2

  reply	other threads:[~2019-02-20 21:05 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
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   ` Julien Meunier [this message]
2019-02-21  2:30     ` [dpdk-dev] [PATCH v3 2/2] net/ixgbe: add support of loopback for X540/X550 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=20190220210531.48322-2-julien.meunier@nokia.com \
    --to=julien.meunier@nokia.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=wei.zhao1@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).