summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorQinglai Xiao <jigsaw@gmail.com>2013-09-26 16:34:44 +0300
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-01-15 18:11:18 +0100
commita0d491a92af743363546e3319f13e537583b3d56 (patch)
treebf00f0ad6ef44cbd55d35db967b98fece578a44a /lib
parent5abefef2387f3b9f44772a6bf0bb596d3a253421 (diff)
downloaddpdk-a0d491a92af743363546e3319f13e537583b3d56.zip
dpdk-a0d491a92af743363546e3319f13e537583b3d56.tar.gz
dpdk-a0d491a92af743363546e3319f13e537583b3d56.tar.xz
ixgbe: add Tx->Rx loopback mode for 82599
82599 has two loopback operation modes, Tx->Rx and Rx->Tx. For the time being only Tx->Rx is supported. The new field lpbk_mode added in struct rte_eth_conf defines loopback operation mode for certain ethernet controller. By default the value of lpbk_mode is 0, meaning loopback mode disabled. Since each ethernet controller has its own definition of loopback modes, API user has to check both datasheet and implementation of certain driver so as to understand what are valid values to be set, and what are the expected behaviors. Check IXGBE_LPBK_82599_XXX which are defined in ixgbe_ethdev.h for valid values of 82599 loopback mode. Signed-off-by: Qinglai Xiao <jigsaw@gmail.com> Acked-by: Ivan Boule <ivan.boule@6wind.com> Acked-by: Venky Venkatesan <venky.venkatesan@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/librte_ether/rte_ethdev.h5
-rw-r--r--lib/librte_pmd_ixgbe/ixgbe_ethdev.c7
-rw-r--r--lib/librte_pmd_ixgbe/ixgbe_ethdev.h4
-rw-r--r--lib/librte_pmd_ixgbe/ixgbe_rxtx.c42
4 files changed, 58 insertions, 0 deletions
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b177b64..302d378 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -729,6 +729,11 @@ struct rte_eth_conf {
/**< ETH_LINK_[HALF_DUPLEX|FULL_DUPLEX], or 0 for autonegotation */
struct rte_eth_rxmode rxmode; /**< Port RX configuration. */
struct rte_eth_txmode txmode; /**< Port TX configuration. */
+ uint32_t lpbk_mode; /**< Loopback operation mode. By default the value
+ is 0, meaning the loopback mode is disabled.
+ Read the datasheet of given ethernet controller
+ for details. The possible values of this field
+ are defined in implementation of each driver. */
union {
struct rte_eth_rss_conf rss_conf; /**< Port RSS configuration */
struct rte_eth_vmdq_dcb_conf vmdq_dcb_conf;
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
index c01eaa9..787ed23 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c
@@ -1282,6 +1282,11 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
/* Turn on the laser */
ixgbe_enable_tx_laser(hw);
+ /* Skip link setup if loopback mode is enabled for 82599. */
+ if (hw->mac.type == ixgbe_mac_82599EB &&
+ dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
+ goto skip_link_setup;
+
err = ixgbe_check_link(hw, &speed, &link_up, 0);
if (err)
goto error;
@@ -1318,6 +1323,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
if (err)
goto error;
+skip_link_setup:
+
/* check if lsc interrupt is enabled */
if (dev->data->dev_conf.intr_conf.lsc != 0)
ixgbe_dev_lsc_interrupt_setup(dev);
diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
index adbecca..c6273f8 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
+++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h
@@ -62,6 +62,10 @@
#endif
#define IXGBE_HWSTRIP_BITMAP_SIZE (IXGBE_MAX_RX_QUEUE_NUM / (sizeof(uint32_t) * NBBY))
+/* 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. */
/*
* Information about the fdir mode.
diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
index 9b7cb7c..bb092ad 100644
--- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
+++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c
@@ -77,6 +77,7 @@
#include "ixgbe/ixgbe_vf.h"
#include "ixgbe_ethdev.h"
#include "ixgbe/ixgbe_dcb.h"
+#include "ixgbe/ixgbe_common.h"
#define RTE_PMD_IXGBE_TX_MAX_BURST 32
@@ -3374,6 +3375,13 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
} else
hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
+ /*
+ * If loopback mode is configured for 82599, set LPBK bit.
+ */
+ if (hw->mac.type == ixgbe_mac_82599EB &&
+ dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
+ hlreg0 |= IXGBE_HLREG0_LPBK;
+
IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
/* Setup RX queues */
@@ -3554,6 +3562,34 @@ ixgbe_dev_tx_init(struct rte_eth_dev *dev)
}
/*
+ * Set up link for 82599 loopback mode Tx->Rx.
+ */
+static inline void
+ixgbe_setup_loopback_link_82599(struct ixgbe_hw *hw)
+{
+ DEBUGFUNC("ixgbe_setup_loopback_link_82599");
+
+ if (ixgbe_verify_lesm_fw_enabled_82599(hw)) {
+ if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM) !=
+ IXGBE_SUCCESS) {
+ PMD_INIT_LOG(ERR, "Could not enable loopback mode\n");
+ /* ignore error */
+ return;
+ }
+ }
+
+ /* Restart link */
+ IXGBE_WRITE_REG(hw,
+ IXGBE_AUTOC,
+ IXGBE_AUTOC_LMS_10G_LINK_NO_AN | IXGBE_AUTOC_FLU);
+ ixgbe_reset_pipeline_82599(hw);
+
+ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_MAC_CSR_SM);
+ msec_delay(50);
+}
+
+
+/*
* Start Transmit and Receive Units.
*/
void
@@ -3631,6 +3667,12 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev)
rxctrl |= IXGBE_RXCTRL_DMBYPS;
rxctrl |= IXGBE_RXCTRL_RXEN;
hw->mac.ops.enable_rx_dma(hw, rxctrl);
+
+ /* If loopback mode is enabled for 82599, set up the link accordingly */
+ if (hw->mac.type == ixgbe_mac_82599EB &&
+ dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX)
+ ixgbe_setup_loopback_link_82599(hw);
+
}