From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 88EFB1F3 for ; Fri, 27 Sep 2013 10:29:48 +0200 (CEST) Received: by mail-wg0-f43.google.com with SMTP id z12so2282041wgg.34 for ; Fri, 27 Sep 2013 01:30:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=lEzZJ5ZER8Snhaku8uRAtqJUPyPqNpN4KRiEAUDw95I=; b=audu18ZrjKR0H6Z1HgSHWXX+B8omq4/eUXRue4l7IKzkutcNM1xW5V8zrrrB08fqtn MHGR6NoaKque0jZDShxLyHNDgvSwZjGWzZyXhmnFCRB6AzLPII3mTJAFymsnd+6YvK+C CyfoE2Z0HQ7EiPbgWaWe2OYs4Z8OSj/pwhPUxQ178BpVW3AQLXt4+IMQYdO/ZhAbFQJi mbeAsCvtbb2rWaXVkGamb7dJ1Yw2OoolkCcv+xE3+hkd1WmG4PY5vEYmA8VFe13N+rTD OjmLC5E4qc+3UVQnmCQDYq6FHGWisykYw6dODG15T02ZIRx4F55WRW+r+dImJibQPGxm UarQ== X-Gm-Message-State: ALoCoQkiIQJpbWaJ8c1Amd0RFs5zS/gGYlfvvvQbhHn7fB7MJctncsmC0oy3F0BozTlsoHt9jcr5 X-Received: by 10.180.189.132 with SMTP id gi4mr1557826wic.19.1380270629391; Fri, 27 Sep 2013 01:30:29 -0700 (PDT) Received: from [10.16.0.189] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id b11sm36169965wik.1.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 01:30:28 -0700 (PDT) Message-ID: <52454223.2090102@6wind.com> Date: Fri, 27 Sep 2013 10:30:27 +0200 From: Ivan Boule User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130827 Icedove/17.0.8 MIME-Version: 1.0 To: Qinglai Xiao References: <1380202484-4835-1-git-send-email-jigsaw@gmail.com> In-Reply-To: <1380202484-4835-1-git-send-email-jigsaw@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] Add support for Tx->Rx loopback mode for 82599. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Sep 2013 08:29:49 -0000 Acked-by: Ivan Boule On 09/26/2013 03:34 PM, Qinglai Xiao wrote: > 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 > --- > lib/librte_ether/rte_ethdev.h | 5 +++++ > lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 7 ++++++ > lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 5 +++++ > lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 42 +++++++++++++++++++++++++++++++++++ > 4 files changed, 59 insertions(+) > > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index 2d7385f..4c1b3c8 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -672,6 +672,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 9235f9d..efb8a3b 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c > +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c > @@ -1203,6 +1203,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; > @@ -1239,6 +1244,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 260622a..4884841 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h > +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h > @@ -62,6 +62,11 @@ > #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 5fba01d..5c8668e 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c > +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c > @@ -78,6 +78,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 > @@ -3252,6 +3253,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 */ > @@ -3432,6 +3440,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 > @@ -3509,6 +3545,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); > + > } > > -- Ivan Boule 6WIND Development Engineer