From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 45DABA0547; Thu, 21 Oct 2021 11:52:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CE384123F; Thu, 21 Oct 2021 11:51:03 +0200 (CEST) Received: from smtpproxy21.qq.com (smtpbg704.qq.com [203.205.195.105]) by mails.dpdk.org (Postfix) with ESMTP id 3690241220 for ; Thu, 21 Oct 2021 11:50:58 +0200 (CEST) X-QQ-mid: bizesmtp38t1634809854t5nmyre2 Received: from jiawenwu.trustnetic.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Thu, 21 Oct 2021 17:50:54 +0800 (CST) X-QQ-SSF: 01400000000000E0I000000A0000000 X-QQ-FEAT: MbM5FzJm02OzwHKuze6qx+jefVe0/wwNiLLdk1vif4qoLh9ilQe8cwCma6zH7 lPu/ws6jqoyC6LRvZcChkFfCDPLF+0Ldf2KHw7RZjqcoJtupPnxhjv+3c69ERCT3RYpybnQ LlrqOlQFYk6Rajk8mIbYm2aeN/+5ea8jyg5Ae7exovF0/74QFdDIGJO0AMemJRLUiP6mU3s zD09jHGIf/OcGJmkIfob6RLlnJXLqXVJT2LeukbXtUYwL8DMFe23CkpsGrOyAbcyEVCedc3 LgZGTRWBPpou2400LbllfcjslIdNi4zxGq7PeKVbEUrhkV8HKHUnUa4IHa0Oj4tnXHXyWIj dUYmIMcwYrN5a8a9lJB7MdXhLceDEHI8QmNZDNhktZL11MpPoU= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Thu, 21 Oct 2021 17:50:11 +0800 Message-Id: <20211021095023.18288-15-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20211021095023.18288-1-jiawenwu@trustnetic.com> References: <20211021095023.18288-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v2 14/26] net/ngbe: add loopback mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Support loopback operation mode. Signed-off-by: Jiawen Wu --- drivers/net/ngbe/ngbe_ethdev.c | 6 ++++++ drivers/net/ngbe/ngbe_rxtx.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 121e78973e..b91437840e 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -926,6 +926,10 @@ ngbe_dev_start(struct rte_eth_dev *dev) goto error; } + /* Skip link setup if loopback mode is enabled. */ + if (hw->is_pf && dev->data->dev_conf.lpbk_mode) + goto skip_link_setup; + err = hw->mac.check_link(hw, &speed, &link_up, 0); if (err != 0) goto error; @@ -969,6 +973,8 @@ ngbe_dev_start(struct rte_eth_dev *dev) if (err != 0) goto error; +skip_link_setup: + if (rte_intr_allow_others(intr_handle)) { ngbe_dev_misc_interrupt_setup(dev); /* check if lsc interrupt is enabled */ diff --git a/drivers/net/ngbe/ngbe_rxtx.c b/drivers/net/ngbe/ngbe_rxtx.c index 9bcd2612fc..f2bc90b7e7 100644 --- a/drivers/net/ngbe/ngbe_rxtx.c +++ b/drivers/net/ngbe/ngbe_rxtx.c @@ -2468,6 +2468,17 @@ ngbe_dev_rx_init(struct rte_eth_dev *dev) wr32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK, NGBE_FRMSZ_MAX(dev->data->mtu + NGBE_ETH_OVERHEAD)); + /* + * If loopback mode is configured, set LPBK bit. + */ + hlreg0 = rd32(hw, NGBE_PSRCTL); + if (hw->is_pf && dev->data->dev_conf.lpbk_mode) + hlreg0 |= NGBE_PSRCTL_LBENA; + else + hlreg0 &= ~NGBE_PSRCTL_LBENA; + + wr32(hw, NGBE_PSRCTL, hlreg0); + /* * Assume no header split and no VLAN strip support * on any Rx queue first . @@ -2586,6 +2597,19 @@ ngbe_dev_tx_init(struct rte_eth_dev *dev) } } +/* + * Set up link loopback mode Tx->Rx. + */ +static inline void +ngbe_setup_loopback_link(struct ngbe_hw *hw) +{ + PMD_INIT_FUNC_TRACE(); + + wr32m(hw, NGBE_MACRXCFG, NGBE_MACRXCFG_LB, NGBE_MACRXCFG_LB); + + msec_delay(50); +} + /* * Start Transmit and Receive Units. */ @@ -2640,6 +2664,10 @@ ngbe_dev_rxtx_start(struct rte_eth_dev *dev) rxctrl |= NGBE_PBRXCTL_ENA; hw->mac.enable_rx_dma(hw, rxctrl); + /* If loopback mode is enabled, set up the link accordingly */ + if (hw->is_pf && dev->data->dev_conf.lpbk_mode) + ngbe_setup_loopback_link(hw); + return 0; } -- 2.21.0.windows.1