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 D3D52A0032 for ; Fri, 18 Feb 2022 13:40:16 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF2A540141; Fri, 18 Feb 2022 13:40:16 +0100 (CET) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mails.dpdk.org (Postfix) with ESMTP id 66F8740141 for ; Fri, 18 Feb 2022 13:40:16 +0100 (CET) Received: by mail-wr1-f50.google.com with SMTP id e3so14450782wra.0 for ; Fri, 18 Feb 2022 04:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EOyXUmMLecMIf3p5DfW4vVgv2nLwmlkpAFA0vEfMmKQ=; b=q4Lpa6i4pfCspvEFC9dxAKik+T46+15Y6lvXHKdYtg/X+mS4AlmXWFbvFT8590Cli+ AqO3tXdwT/6QIawNuay/KGDB2b9UW/gr7VTCMgCfDh1FJkP1urjfPUFttz84Dom2V6XF Jw4MHj5PtTPMreRRUoEqzRTU/MbpzmfuZ74V2DSQvOWDkFtqZPYVbW63drYb1cPzfjba YzNjwKILuysUERJbm+LZKhbMroARTw03MW8SFdkEDKK+kBSvgDk417Gr4zhpkylbqPQZ mzdCCzug108rfzXbH7ZbHegGDr3HaRdysu8pCJiehVmfDxTSeHHwSanBEfL10Oq3hb27 t5qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EOyXUmMLecMIf3p5DfW4vVgv2nLwmlkpAFA0vEfMmKQ=; b=yPZgAlvPOcxf8VzQmTqQ3B16X2/gDPdcvBsxOOIv4f7hrbjPJ0C9y3ElGp3dUmUHct 20e8xb5P0dVRinW28IX7aTcEGheeiRTl97rjWI+I/uBcSkSjkRinZpDh0gCoE8VNuI0+ ewhOvBHZDBpzvEf8eEPwEp4e54bt9GPEpVXDclPxQ4oTGujXdGomuJIEd2ZOiGGE+y+9 c7jMjY1e+QMyilTkRy6BMjCErpPVE74m29Pg/vCU+5pm07UA3IJ9rORq1judAojEY2rT O+h5m3BXgcXjdMkJFaHjCBzX0FbeQXlcb0Em0/OHVytgFeQDc9DgYpMtBCgEtFSc7VH6 k11A== X-Gm-Message-State: AOAM531EzXmXlcMKeXEvE9znzW+3OpwWhKQlQOndWzxrV44pqvM0Efjg QzNCC2UmeRgmeQtqoP0opd+eJIiaJ98ZJQ== X-Google-Smtp-Source: ABdhPJxuisSUTYfH+0ihrbYTJOw0PtWr8LB6QAfjbt80emJRtliSRto+DemyuFRxj1ddWja+rAzH8w== X-Received: by 2002:adf:fd06:0:b0:1e3:22b6:e740 with SMTP id e6-20020adffd06000000b001e322b6e740mr5671113wrr.473.1645188016026; Fri, 18 Feb 2022 04:40:16 -0800 (PST) Received: from localhost ([2a01:4b00:f41a:3600:360b:9754:2e3a:c344]) by smtp.gmail.com with ESMTPSA id y16sm4840646wrp.1.2022.02.18.04.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 04:40:15 -0800 (PST) From: luca.boccassi@gmail.com To: Dapeng Yu Cc: Haiyue Wang , dpdk stable Subject: patch 'net/ice: track DCF state of PF' has been queued to stable release 20.11.5 Date: Fri, 18 Feb 2022 12:37:44 +0000 Message-Id: <20220218123931.1749595-15-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220218123931.1749595-1-luca.boccassi@gmail.com> References: <20220218123931.1749595-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/20/22. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/8577641fca0ff858c9ffe16c6d5801ea9fbff55c Thanks. Luca Boccassi --- >From 8577641fca0ff858c9ffe16c6d5801ea9fbff55c Mon Sep 17 00:00:00 2001 From: Dapeng Yu Date: Wed, 24 Nov 2021 16:12:20 +0800 Subject: [PATCH] net/ice: track DCF state of PF [ upstream commit 285f63fc6bb72a07594af9a7652f5bae3a95eb52 ] When VF is reset, PF will change DCF state from ON to other state, if flow creation, destroy, or redirect command is sent to DCF at this time, it will fail. This patch tracks DCF state and returns try-again error to caller when DCF state is not ON. Signed-off-by: Dapeng Yu Acked-by: Haiyue Wang --- drivers/net/ice/ice_dcf_ethdev.c | 12 ++++++++ drivers/net/ice/ice_dcf_ethdev.h | 1 + drivers/net/ice/ice_dcf_parent.c | 10 +++++++ drivers/net/ice/ice_ethdev.h | 2 ++ drivers/net/ice/ice_generic_flow.c | 4 ++- drivers/net/ice/ice_switch_filter.c | 45 +++++++++++++++++++++++++++-- 6 files changed, 71 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index a90dff9a46..1793d8cbd3 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -870,6 +870,13 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) return 0; } +bool +ice_dcf_adminq_need_retry(struct ice_adapter *ad) +{ + return ad->hw.dcf_enabled && + !__atomic_load_n(&ad->dcf_state_on, __ATOMIC_RELAXED); +} + static int ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev, __rte_unused int wait_to_complete) @@ -905,6 +912,7 @@ static int ice_dcf_dev_init(struct rte_eth_dev *eth_dev) { struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; + struct ice_adapter *parent_adapter = &adapter->parent; eth_dev->dev_ops = &ice_dcf_eth_dev_ops; eth_dev->rx_pkt_burst = ice_dcf_recv_pkts; @@ -916,9 +924,13 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg; if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) { PMD_INIT_LOG(ERR, "Failed to init DCF hardware"); + __atomic_store_n(&parent_adapter->dcf_state_on, false, + __ATOMIC_RELAXED); return -1; } + __atomic_store_n(&parent_adapter->dcf_state_on, true, __ATOMIC_RELAXED); + if (ice_dcf_init_parent_adapter(eth_dev) != 0) { PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter"); ice_dcf_uninit_hw(eth_dev, &adapter->real_hw); diff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h index b54528beae..0d25ff315e 100644 --- a/drivers/net/ice/ice_dcf_ethdev.h +++ b/drivers/net/ice/ice_dcf_ethdev.h @@ -26,5 +26,6 @@ void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, uint8_t *msg, uint16_t msglen); int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev); void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev); +bool ice_dcf_adminq_need_retry(struct ice_adapter *ad); #endif /* _ICE_DCF_ETHDEV_H_ */ diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index 903e4db616..ad94953932 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -111,6 +111,9 @@ static void* ice_dcf_vsi_update_service_handler(void *param) { struct ice_dcf_hw *hw = param; + struct ice_dcf_adapter *adapter = + container_of(hw, struct ice_dcf_adapter, real_hw); + struct ice_adapter *parent_adapter = &adapter->parent; pthread_detach(pthread_self()); usleep(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); @@ -122,6 +125,8 @@ ice_dcf_vsi_update_service_handler(void *param) struct ice_dcf_adapter *dcf_ad = container_of(hw, struct ice_dcf_adapter, real_hw); + __atomic_store_n(&parent_adapter->dcf_state_on, true, + __ATOMIC_RELAXED); ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw, hw->num_vfs, hw->vf_vsi_map); } @@ -137,6 +142,9 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, { struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg; pthread_t thread; + struct ice_dcf_adapter *adapter = + container_of(dcf_hw, struct ice_dcf_adapter, real_hw); + struct ice_adapter *parent_adapter = &adapter->parent; if (msglen < sizeof(struct virtchnl_pf_event)) { PMD_DRV_LOG(DEBUG, "Invalid event message length : %u", msglen); @@ -161,6 +169,8 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, pf_msg->event_data.vf_vsi_map.vsi_id); pthread_create(&thread, NULL, ice_dcf_vsi_update_service_handler, dcf_hw); + __atomic_store_n(&parent_adapter->dcf_state_on, false, + __ATOMIC_RELAXED); break; default: PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event); diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index b3e518fcbc..fd81ede8a1 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -478,6 +478,8 @@ struct ice_adapter { struct ice_devargs devargs; enum ice_pkg_type active_pkg_type; /* loaded ddp package type */ uint16_t fdir_ref_cnt; + /* True if DCF state of the associated PF is on */ + bool dcf_state_on; #ifdef RTE_ARCH_X86 bool rx_use_avx2; bool rx_use_avx512; diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c index ca401c7703..311fd7d162 100644 --- a/drivers/net/ice/ice_generic_flow.c +++ b/drivers/net/ice/ice_generic_flow.c @@ -2323,7 +2323,9 @@ ice_flow_flush(struct rte_eth_dev *dev, ret = ice_flow_destroy(dev, p_flow, error); if (ret) { PMD_DRV_LOG(ERR, "Failed to flush flows"); - return -EINVAL; + if (ret != -EAGAIN) + ret = -EINVAL; + return ret; } } diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index f41a57acf4..ea5ced60a7 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -438,6 +438,14 @@ ice_switch_create(struct ice_adapter *ad, "lookup list should not be NULL"); goto error; } + + if (ice_dcf_adminq_need_retry(ad)) { + rte_flow_error_set(error, EAGAIN, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "DCF is not on"); + goto error; + } + ret = ice_add_adv_rule(hw, list, lkups_cnt, rule_info, &rule_added); if (!ret) { filter_conf_ptr = rte_zmalloc("ice_switch_filter", @@ -461,7 +469,12 @@ ice_switch_create(struct ice_adapter *ad, flow->rule = filter_conf_ptr; } else { - rte_flow_error_set(error, EINVAL, + if (ice_dcf_adminq_need_retry(ad)) + ret = -EAGAIN; + else + ret = -EINVAL; + + rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "switch filter create flow fail"); goto error; @@ -513,9 +526,21 @@ ice_switch_destroy(struct ice_adapter *ad, return -rte_errno; } + if (ice_dcf_adminq_need_retry(ad)) { + rte_flow_error_set(error, EAGAIN, + RTE_FLOW_ERROR_TYPE_ITEM, NULL, + "DCF is not on"); + return -rte_errno; + } + ret = ice_rem_adv_rule_by_id(hw, &filter_conf_ptr->sw_query_data); if (ret) { - rte_flow_error_set(error, EINVAL, + if (ice_dcf_adminq_need_retry(ad)) + ret = -EAGAIN; + else + ret = -EINVAL; + + rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "fail to destroy switch filter rule"); return -rte_errno; @@ -1904,6 +1929,12 @@ ice_switch_redirect(struct ice_adapter *ad, } rmv_rule: + if (ice_dcf_adminq_need_retry(ad)) { + PMD_DRV_LOG(WARNING, "DCF is not on"); + ret = -EAGAIN; + goto out; + } + /* Remove the old rule */ ret = ice_rem_adv_rule(hw, lkups_ref, lkups_cnt, &rinfo); if (ret) { @@ -1916,6 +1947,12 @@ rmv_rule: } add_rule: + if (ice_dcf_adminq_need_retry(ad)) { + PMD_DRV_LOG(WARNING, "DCF is not on"); + ret = -EAGAIN; + goto out; + } + /* Update VSI context */ hw->vsi_ctx[rd->vsi_handle]->vsi_num = rd->new_vsi_num; @@ -1935,6 +1972,10 @@ add_rule: } out: + if (ret == -EINVAL) + if (ice_dcf_adminq_need_retry(ad)) + ret = -EAGAIN; + ice_free(hw, lkups_dp); return ret; } -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-02-18 12:37:38.748849154 +0000 +++ 0015-net-ice-track-DCF-state-of-PF.patch 2022-02-18 12:37:37.526788258 +0000 @@ -1 +1 @@ -From 285f63fc6bb72a07594af9a7652f5bae3a95eb52 Mon Sep 17 00:00:00 2001 +From 8577641fca0ff858c9ffe16c6d5801ea9fbff55c Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 285f63fc6bb72a07594af9a7652f5bae3a95eb52 ] + @@ -13,2 +14,0 @@ -Cc: stable@dpdk.org - @@ -20 +20 @@ - drivers/net/ice/ice_dcf_parent.c | 16 +++++++--- + drivers/net/ice/ice_dcf_parent.c | 10 +++++++ @@ -24 +24 @@ - 6 files changed, 73 insertions(+), 7 deletions(-) + 6 files changed, 71 insertions(+), 3 deletions(-) @@ -27 +27 @@ -index a1f11c01d9..59610e058f 100644 +index a90dff9a46..1793d8cbd3 100644 @@ -30,2 +30,2 @@ -@@ -957,6 +957,13 @@ ice_dcf_link_update(struct rte_eth_dev *dev, - return rte_eth_linkstatus_set(dev, &new_link); +@@ -870,6 +870,13 @@ ice_dcf_dev_close(struct rte_eth_dev *dev) + return 0; @@ -41 +40,0 @@ - /* Add UDP tunneling port */ @@ -43,2 +42,3 @@ - ice_dcf_dev_udp_tunnel_port_add(struct rte_eth_dev *dev, -@@ -1106,6 +1113,7 @@ static int + ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev, + __rte_unused int wait_to_complete) +@@ -905,6 +912,7 @@ static int @@ -52 +52 @@ -@@ -1117,9 +1125,13 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) +@@ -916,9 +924,13 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev) @@ -67 +67 @@ -index 8510e37119..11a1305038 100644 +index b54528beae..0d25ff315e 100644 @@ -70,4 +70,4 @@ -@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param); - int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev); - int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev); - void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter); +@@ -26,5 +26,6 @@ void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, + uint8_t *msg, uint16_t msglen); + int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev); + void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev); @@ -78 +78 @@ -index 1ff2c47172..0c8c2ed6c7 100644 +index 903e4db616..ad94953932 100644 @@ -81 +81,2 @@ -@@ -119,7 +119,9 @@ ice_dcf_vsi_update_service_handler(void *param) +@@ -111,6 +111,9 @@ static void* + ice_dcf_vsi_update_service_handler(void *param) @@ -83,3 +84 @@ - struct ice_dcf_reset_event_param *reset_param = param; - struct ice_dcf_hw *hw = reset_param->dcf_hw; -- struct ice_dcf_adapter *adapter; + struct ice_dcf_hw *hw = param; @@ -90,0 +90,4 @@ + usleep(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); +@@ -122,6 +125,8 @@ ice_dcf_vsi_update_service_handler(void *param) + struct ice_dcf_adapter *dcf_ad = + container_of(hw, struct ice_dcf_adapter, real_hw); @@ -92,8 +94,0 @@ -@@ -127,11 +129,12 @@ ice_dcf_vsi_update_service_handler(void *param) - - rte_spinlock_lock(&vsi_update_lock); - -- adapter = container_of(hw, struct ice_dcf_adapter, real_hw); -- -- if (!ice_dcf_handle_vsi_update_event(hw)) -+ if (!ice_dcf_handle_vsi_update_event(hw)) { @@ -102 +97 @@ - ice_dcf_update_vf_vsi_map(&adapter->parent.hw, + ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw, @@ -104,6 +99,2 @@ -+ } - - if (reset_param->vfr && adapter->repr_infos) { - struct rte_eth_dev *vf_rep_eth_dev = -@@ -224,6 +227,9 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, - uint8_t *msg, uint16_t msglen) + } +@@ -137,6 +142,9 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, @@ -111,0 +103 @@ + pthread_t thread; @@ -118,3 +110 @@ -@@ -258,6 +264,8 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, - PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u", - pf_msg->event_data.vf_vsi_map.vf_id, +@@ -161,6 +169,8 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, @@ -121,0 +112,2 @@ + pthread_create(&thread, NULL, + ice_dcf_vsi_update_service_handler, dcf_hw); @@ -124,2 +115,0 @@ - start_vsi_reset_thread(dcf_hw, true, - pf_msg->event_data.vf_vsi_map.vf_id); @@ -126,0 +117,2 @@ + default: + PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event); @@ -128 +120 @@ -index 2e3e45f3d7..1242177b42 100644 +index b3e518fcbc..fd81ede8a1 100644 @@ -131,4 +123,4 @@ -@@ -531,6 +531,8 @@ struct ice_adapter { - uint64_t time_hw; - struct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS]; - struct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS]; +@@ -478,6 +478,8 @@ struct ice_adapter { + struct ice_devargs devargs; + enum ice_pkg_type active_pkg_type; /* loaded ddp package type */ + uint16_t fdir_ref_cnt; @@ -141 +133 @@ -index c673feb7a6..406a0a953f 100644 +index ca401c7703..311fd7d162 100644 @@ -144 +136 @@ -@@ -2515,7 +2515,9 @@ ice_flow_flush(struct rte_eth_dev *dev, +@@ -2323,7 +2323,9 @@ ice_flow_flush(struct rte_eth_dev *dev, @@ -156 +148 @@ -index ed29c00d77..bd805d9606 100644 +index f41a57acf4..ea5ced60a7 100644 @@ -159 +151 @@ -@@ -400,6 +400,14 @@ ice_switch_create(struct ice_adapter *ad, +@@ -438,6 +438,14 @@ ice_switch_create(struct ice_adapter *ad, @@ -174 +166 @@ -@@ -423,7 +431,12 @@ ice_switch_create(struct ice_adapter *ad, +@@ -461,7 +469,12 @@ ice_switch_create(struct ice_adapter *ad, @@ -188 +180 @@ -@@ -475,9 +488,21 @@ ice_switch_destroy(struct ice_adapter *ad, +@@ -513,9 +526,21 @@ ice_switch_destroy(struct ice_adapter *ad, @@ -211 +203 @@ -@@ -2016,6 +2041,12 @@ ice_switch_redirect(struct ice_adapter *ad, +@@ -1904,6 +1929,12 @@ ice_switch_redirect(struct ice_adapter *ad, @@ -224 +216 @@ -@@ -2028,6 +2059,12 @@ rmv_rule: +@@ -1916,6 +1947,12 @@ rmv_rule: @@ -237 +229 @@ -@@ -2047,6 +2084,10 @@ add_rule: +@@ -1935,6 +1972,10 @@ add_rule: