From patchwork Wed Sep 1 05:26:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 97654 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1E8E4A0C53; Wed, 1 Sep 2021 07:26:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97C2C4013F; Wed, 1 Sep 2021 07:26:48 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 160FB40041 for ; Wed, 1 Sep 2021 07:26:46 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10093"; a="282347152" X-IronPort-AV: E=Sophos;i="5.84,368,1620716400"; d="scan'208";a="282347152" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2021 22:26:45 -0700 X-IronPort-AV: E=Sophos;i="5.84,368,1620716400"; d="scan'208";a="531767747" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2021 22:26:44 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, Dapeng Yu Date: Wed, 1 Sep 2021 13:26:04 +0800 Message-Id: <20210901052605.829969-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] net/ice: enable CVL DCF device reset API 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" From: Dapeng Yu DCF PMD needs to support rte_eth_dev_reset, the reason is when a DCF instance is killed, all the flow rules still exists in hardware, when DCF gets to reconnect, it already lost the flow context, and if the application wants to create new rules, it may fail due to firmware reports rules already exist. The rte_eth_dev_reset API provides a more elegant way for the application to reset DCF when reconnect happens. Signed-off-by: Dapeng Yu Acked-by: Qi Zhang --- drivers/net/ice/ice_dcf.c | 28 ++++++++++++++++++++++ drivers/net/ice/ice_dcf.h | 2 ++ drivers/net/ice/ice_dcf_ethdev.c | 41 ++++++++++++++++++++++++++++++++ drivers/net/ice/ice_dcf_parent.c | 5 ++++ 4 files changed, 76 insertions(+) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 4c2e0c7216..878fef0a68 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -337,6 +337,9 @@ ice_dcf_mode_disable(struct ice_dcf_hw *hw) { int err; + if (hw->resetting) + return 0; + err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE, NULL, 0); if (err) { @@ -721,11 +724,25 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) iavf_shutdown_adminq(&hw->avf); rte_free(hw->arq_buf); + hw->arq_buf = NULL; + rte_free(hw->vf_vsi_map); + hw->vf_vsi_map = NULL; + rte_free(hw->vf_res); + hw->vf_res = NULL; + rte_free(hw->rss_lut); + hw->rss_lut = NULL; + rte_free(hw->rss_key); + hw->rss_key = NULL; + rte_free(hw->qos_bw_cfg); + hw->qos_bw_cfg = NULL; + + rte_free(hw->ets_config); + hw->ets_config = NULL; } static int @@ -1009,6 +1026,9 @@ ice_dcf_disable_queues(struct ice_dcf_hw *hw) struct dcf_virtchnl_cmd args; int err; + if (hw->resetting) + return 0; + memset(&queue_select, 0, sizeof(queue_select)); queue_select.vsi_id = hw->vsi_res->vsi_id; @@ -1063,6 +1083,14 @@ ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, bool add) struct dcf_virtchnl_cmd args; int len, err = 0; + if (hw->resetting) { + if (!add) + return 0; + + PMD_DRV_LOG(ERR, "fail to add all MACs for VF resetting"); + return -EIO; + } + len = sizeof(struct virtchnl_ether_addr_list); addr = hw->eth_dev->data->mac_addrs; len += sizeof(struct virtchnl_ether_addr); diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index 36c2d0965e..6ec766ebda 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -111,6 +111,8 @@ struct ice_dcf_hw { /* Link status */ bool link_up; uint32_t link_speed; + + bool resetting; }; int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw, diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index cab7c4da87..94c6a6e61c 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -32,6 +32,12 @@ static int ice_dcf_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, struct rte_eth_udp_tunnel *udp_tunnel); +static int +ice_dcf_dev_init(struct rte_eth_dev *eth_dev); + +static int +ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev); + static uint16_t ice_dcf_recv_pkts(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **bufs, @@ -511,6 +517,12 @@ ice_dcf_dev_start(struct rte_eth_dev *dev) struct ice_dcf_hw *hw = &dcf_ad->real_hw; int ret; + if (hw->resetting) { + PMD_DRV_LOG(ERR, + "The DCF has been reset by PF, please reinit first"); + return -EIO; + } + ad->pf.adapter_stopped = 0; hw->num_queue_pairs = RTE_MAX(dev->data->nb_rx_queues, @@ -585,6 +597,7 @@ ice_dcf_stop_queues(struct rte_eth_dev *dev) txq->tx_rel_mbufs(txq); reset_tx_queue(txq); dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + dev->data->tx_queues[i] = NULL; } for (i = 0; i < dev->data->nb_rx_queues; i++) { rxq = dev->data->rx_queues[i]; @@ -593,6 +606,7 @@ ice_dcf_stop_queues(struct rte_eth_dev *dev) rxq->rx_rel_mbufs(rxq); reset_rx_queue(rxq); dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; + dev->data->rx_queues[i] = NULL; } } @@ -805,6 +819,12 @@ ice_dcf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) struct virtchnl_eth_stats pstats; int ret; + if (hw->resetting) { + PMD_DRV_LOG(ERR, + "The DCF has been reset by PF, please reinit first"); + return -EIO; + } + ret = ice_dcf_query_stats(hw, &pstats); if (ret == 0) { ice_dcf_update_stats(&hw->eth_stats_offset, &pstats); @@ -831,6 +851,9 @@ ice_dcf_stats_reset(struct rte_eth_dev *dev) struct virtchnl_eth_stats pstats; int ret; + if (hw->resetting) + return 0; + /* read stat values to clear hardware registers */ ret = ice_dcf_query_stats(hw, &pstats); if (ret != 0) @@ -874,6 +897,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + (void)ice_dcf_dev_stop(dev); + ice_dcf_free_repr_info(adapter); ice_dcf_uninit_parent_adapter(dev); ice_dcf_uninit_hw(dev, &adapter->real_hw); @@ -1006,10 +1031,25 @@ ice_dcf_tm_ops_get(struct rte_eth_dev *dev __rte_unused, return 0; } +static int +ice_dcf_dev_reset(struct rte_eth_dev *dev) +{ + int ret; + + ret = ice_dcf_dev_uninit(dev); + if (ret) + return ret; + + ret = ice_dcf_dev_init(dev); + + return ret; +} + static const struct eth_dev_ops ice_dcf_eth_dev_ops = { .dev_start = ice_dcf_dev_start, .dev_stop = ice_dcf_dev_stop, .dev_close = ice_dcf_dev_close, + .dev_reset = ice_dcf_dev_reset, .dev_configure = ice_dcf_dev_configure, .dev_infos_get = ice_dcf_dev_info_get, .rx_queue_setup = ice_rx_queue_setup, @@ -1038,6 +1078,7 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) { struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; + adapter->real_hw.resetting = false; eth_dev->dev_ops = &ice_dcf_eth_dev_ops; eth_dev->rx_pkt_burst = ice_dcf_recv_pkts; eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts; diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index f461318f96..04078345eb 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -234,6 +234,7 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, case VIRTCHNL_EVENT_RESET_IMPENDING: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event"); start_vsi_reset_thread(dcf_hw, false, 0); + dcf_hw->resetting = true; break; case VIRTCHNL_EVENT_LINK_CHANGE: PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event"); @@ -357,6 +358,7 @@ ice_dcf_init_parent_hw(struct ice_hw *hw) err_unroll_alloc: ice_free(hw, hw->port_info); hw->port_info = NULL; + hw->switch_info = NULL; return status; } @@ -370,6 +372,7 @@ static void ice_dcf_uninit_parent_hw(struct ice_hw *hw) ice_free(hw, hw->port_info); hw->port_info = NULL; + hw->switch_info = NULL; ice_clear_all_vsi_ctx(hw); } @@ -485,6 +488,8 @@ ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev) struct ice_hw *parent_hw = &parent_adapter->hw; eth_dev->data->mac_addrs = NULL; + rte_free(parent_adapter->pf.main_vsi); + parent_adapter->pf.main_vsi = NULL; ice_flow_uninit(parent_adapter); ice_dcf_uninit_parent_hw(parent_hw);