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 89A0CA054F; Sat, 24 Sep 2022 04:47:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D5B642C2E; Sat, 24 Sep 2022 04:46:16 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 697B0400D4 for ; Sat, 24 Sep 2022 04:46:00 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1004) id 239ED20C32C1; Fri, 23 Sep 2022 19:46:00 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 239ED20C32C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1663987560; bh=4OKB/LmLLK2nrZ9/ncFBFDErl2/5ghUCrZT/xp799o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To:From; b=nnScQT/W3gXigq2xViv1MBtn6ipx811B2dJyCHH7hcA1srr9l74HQQyv4ZetDEGYk 9z8cHna7ew8KZnRLjDRpnUWz8mXTAFIxMj4Y1YE8+8XZuRi7F9W3kLc/+Mu+bI9f3M 8qfBQxEvB+eC8yHWUUuTxma0N2BFXzbATxmThCSU= From: longli@linuxonhyperv.com To: Ferruh Yigit Cc: dev@dpdk.org, Ajay Sharma , Stephen Hemminger , Long Li Subject: [Patch v9 16/18] net/mana: start/stop device Date: Fri, 23 Sep 2022 19:45:44 -0700 Message-Id: <1663987546-15982-17-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1663987546-15982-1-git-send-email-longli@linuxonhyperv.com> References: <1662674189-29524-1-git-send-email-longli@linuxonhyperv.com> <1663987546-15982-1-git-send-email-longli@linuxonhyperv.com> 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: , Reply-To: longli@microsoft.com Errors-To: dev-bounces@dpdk.org From: Long Li Add support for starting/stopping the device. Signed-off-by: Long Li --- Change log: v2: Use spinlock for memory registration cache. Add prefix mana_ to all function names. v6: Roll back device state on error in mana_dev_start() drivers/net/mana/mana.c | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index d0214725e6..c43212950f 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -105,6 +105,81 @@ mana_dev_configure(struct rte_eth_dev *dev) static int mana_intr_uninstall(struct mana_priv *priv); +static int +mana_dev_start(struct rte_eth_dev *dev) +{ + int ret; + struct mana_priv *priv = dev->data->dev_private; + + rte_spinlock_init(&priv->mr_btree_lock); + ret = mana_mr_btree_init(&priv->mr_btree, MANA_MR_BTREE_CACHE_N, + dev->device->numa_node); + if (ret) { + DRV_LOG(ERR, "Failed to init device MR btree %d", ret); + return ret; + } + + ret = mana_start_tx_queues(dev); + if (ret) { + DRV_LOG(ERR, "failed to start tx queues %d", ret); + goto failed_tx; + } + + ret = mana_start_rx_queues(dev); + if (ret) { + DRV_LOG(ERR, "failed to start rx queues %d", ret); + goto failed_rx; + } + + rte_wmb(); + + dev->tx_pkt_burst = mana_tx_burst; + dev->rx_pkt_burst = mana_rx_burst; + + DRV_LOG(INFO, "TX/RX queues have started"); + + /* Enable datapath for secondary processes */ + mana_mp_req_on_rxtx(dev, MANA_MP_REQ_START_RXTX); + + return 0; + +failed_rx: + mana_stop_tx_queues(dev); + +failed_tx: + mana_mr_btree_free(&priv->mr_btree); + + return ret; +} + +static int +mana_dev_stop(struct rte_eth_dev *dev __rte_unused) +{ + int ret; + + dev->tx_pkt_burst = mana_tx_burst_removed; + dev->rx_pkt_burst = mana_rx_burst_removed; + + /* Stop datapath on secondary processes */ + mana_mp_req_on_rxtx(dev, MANA_MP_REQ_STOP_RXTX); + + rte_wmb(); + + ret = mana_stop_tx_queues(dev); + if (ret) { + DRV_LOG(ERR, "failed to stop tx queues"); + return ret; + } + + ret = mana_stop_rx_queues(dev); + if (ret) { + DRV_LOG(ERR, "failed to stop tx queues"); + return ret; + } + + return 0; +} + static int mana_dev_close(struct rte_eth_dev *dev) { @@ -453,6 +528,8 @@ mana_dev_link_update(struct rte_eth_dev *dev, static const struct eth_dev_ops mana_dev_ops = { .dev_configure = mana_dev_configure, + .dev_start = mana_dev_start, + .dev_stop = mana_dev_stop, .dev_close = mana_dev_close, .dev_infos_get = mana_dev_info_get, .txq_info_get = mana_dev_tx_queue_info, -- 2.17.1