From patchwork Fri Sep 6 12:00:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Yahui" X-Patchwork-Id: 58713 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C8201F0F3; Fri, 6 Sep 2019 06:16:22 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 1E0F41F0E7 for ; Fri, 6 Sep 2019 06:16:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2019 21:16:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,472,1559545200"; d="scan'208";a="190709697" Received: from dpdk-yahui-skylake.sh.intel.com ([10.67.119.16]) by FMSMGA003.fm.intel.com with ESMTP; 05 Sep 2019 21:16:15 -0700 From: Yahui Cao To: Qiming Yang , Wenzhuo Lu Cc: dev@dpdk.org, Qi Zhang , Xiaolong Ye , Beilei Xing , Yahui Cao Date: Fri, 6 Sep 2019 20:00:48 +0800 Message-Id: <20190906120058.108073-3-yahui.cao@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190906120058.108073-1-yahui.cao@intel.com> References: <20190906120058.108073-1-yahui.cao@intel.com> Subject: [dpdk-dev] [dpdk-dev 02/12] net/ice: tear down flow director X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Beilei Xing Release resources on flow director, include: - Release queue. - Release VSI. Signed-off-by: Beilei Xing --- drivers/net/ice/ice_fdir_filter.c | 40 ++++++++++++++++++++++ drivers/net/ice/ice_rxtx.c | 57 +++++++++++++++++++++++++++++++ drivers/net/ice/ice_rxtx.h | 2 ++ 3 files changed, 99 insertions(+) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 03d143058..451ef92b2 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -117,6 +117,37 @@ ice_fdir_setup(struct ice_pf *pf) return err; } +/* + * ice_fdir_teardown - release the Flow Director resources + * @pf: board private structure + */ +static void +ice_fdir_teardown(struct ice_pf *pf) +{ + struct rte_eth_dev *eth_dev = pf->adapter->eth_dev; + struct ice_vsi *vsi; + int err; + + vsi = pf->fdir.fdir_vsi; + if (!vsi) + return; + + err = ice_fdir_tx_queue_stop(eth_dev, pf->fdir.txq->queue_id); + if (err) + PMD_DRV_LOG(ERR, "Failed to stop TX queue."); + + err = ice_fdir_rx_queue_stop(eth_dev, pf->fdir.rxq->queue_id); + if (err) + PMD_DRV_LOG(ERR, "Failed to stop RX queue."); + + ice_tx_queue_release(pf->fdir.txq); + pf->fdir.txq = NULL; + ice_rx_queue_release(pf->fdir.rxq); + pf->fdir.rxq = NULL; + ice_release_vsi(vsi); + pf->fdir.fdir_vsi = NULL; +} + static int ice_init_fdir_filter(struct ice_adapter *ad) { @@ -128,8 +159,17 @@ ice_init_fdir_filter(struct ice_adapter *ad) return ret; } +static void +ice_uninit_fdir_filter(struct ice_adapter *ad) +{ + struct ice_pf *pf = &ad->pf; + + ice_fdir_teardown(pf); +} + static struct ice_flow_engine ice_fdir_engine = { .init = ice_init_fdir_filter, + .uninit = ice_uninit_fdir_filter, .type = ICE_FLOW_ENGINE_FDIR, }; diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index bd802e350..e41fcb194 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -748,6 +748,63 @@ ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) return 0; } +int +ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) +{ + struct ice_rx_queue *rxq; + int err; + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + + rxq = pf->fdir.rxq; + + err = ice_switch_rx_queue(hw, rxq->reg_idx, FALSE); + if (err) { + PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u off", + rx_queue_id); + return -EINVAL; + } + ice_rx_queue_release_mbufs(rxq); + + return 0; +} + +int +ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) +{ + struct ice_tx_queue *txq; + struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_vsi *vsi = pf->main_vsi; + enum ice_status status; + uint16_t q_ids[1]; + uint32_t q_teids[1]; + uint16_t q_handle = tx_queue_id; + + txq = pf->fdir.txq; + if (!txq) { + PMD_DRV_LOG(ERR, "TX queue %u is not available", + tx_queue_id); + return -EINVAL; + } + vsi = txq->vsi; + + q_ids[0] = txq->reg_idx; + q_teids[0] = txq->q_teid; + + /* Fix me, we assume TC always 0 here */ + status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle, + q_ids, q_teids, ICE_NO_RESET, 0, NULL); + if (status != ICE_SUCCESS) { + PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue"); + return -EINVAL; + } + + ice_tx_queue_release_mbufs(txq); + + return 0; +} + int ice_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx, diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index 450db0244..24376c0d5 100644 --- a/drivers/net/ice/ice_rxtx.h +++ b/drivers/net/ice/ice_rxtx.h @@ -151,6 +151,8 @@ int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); +int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); +int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); void ice_rx_queue_release(void *rxq); void ice_tx_queue_release(void *txq); void ice_clear_queues(struct rte_eth_dev *dev);