get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/104647/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 104647,
    "url": "http://patchwork.dpdk.org/api/patches/104647/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20211124081220.367596-1-dapengx.yu@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20211124081220.367596-1-dapengx.yu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20211124081220.367596-1-dapengx.yu@intel.com",
    "date": "2021-11-24T08:12:20",
    "name": "[v2] net/ice: track the DCF state of PF",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "0eeae6e4e0e7a19454aa4a98dca95596fcc28ab9",
    "submitter": {
        "id": 2042,
        "url": "http://patchwork.dpdk.org/api/people/2042/?format=api",
        "name": "Yu, DapengX",
        "email": "dapengx.yu@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "http://patchwork.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20211124081220.367596-1-dapengx.yu@intel.com/mbox/",
    "series": [
        {
            "id": 20731,
            "url": "http://patchwork.dpdk.org/api/series/20731/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=20731",
            "date": "2021-11-24T08:12:20",
            "name": "[v2] net/ice: track the DCF state of PF",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/20731/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/104647/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/104647/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id EA7CDA0C52;\n\tWed, 24 Nov 2021 09:12:56 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 76DCA40A4B;\n\tWed, 24 Nov 2021 09:12:56 +0100 (CET)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by mails.dpdk.org (Postfix) with ESMTP id A0DE740688;\n Wed, 24 Nov 2021 09:12:53 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Nov 2021 00:12:52 -0800",
            "from unknown (HELO localhost.localdomain) ([10.240.183.93])\n by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 24 Nov 2021 00:12:50 -0800"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10177\"; a=\"222104014\"",
            "E=Sophos;i=\"5.87,260,1631602800\"; d=\"scan'208\";a=\"222104014\"",
            "E=Sophos;i=\"5.87,260,1631602800\"; d=\"scan'208\";a=\"509782049\""
        ],
        "From": "dapengx.yu@intel.com",
        "To": "Qiming Yang <qiming.yang@intel.com>,\n\tQi Zhang <qi.z.zhang@intel.com>",
        "Cc": "dev@dpdk.org, haiyue.wang@intel.com, Dapeng Yu <dapengx.yu@intel.com>,\n stable@dpdk.org",
        "Subject": "[PATCH v2] net/ice: track the DCF state of PF",
        "Date": "Wed, 24 Nov 2021 16:12:20 +0800",
        "Message-Id": "<20211124081220.367596-1-dapengx.yu@intel.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20211122092913.262886-1-dapengx.yu@intel.com>",
        "References": "<20211122092913.262886-1-dapengx.yu@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Dapeng Yu <dapengx.yu@intel.com>\n\nWhen VF is reset, PF will change DCF state from ON to other state, if\nflow creation, destroy, or redirect command is sent to DCF at this\ntime, it will fail.\n\nThis patch tracks DCF state and returns try-again error to caller when\nDCF state is not ON.\n\nCc: stable@dpdk.org\n\nSigned-off-by: Dapeng Yu <dapengx.yu@intel.com>\n---\nV2:\n* Move DCF state flag to another position\n---\n drivers/net/ice/ice_dcf_ethdev.c    | 12 ++++++++\n drivers/net/ice/ice_dcf_ethdev.h    |  1 +\n drivers/net/ice/ice_dcf_parent.c    | 16 +++++++---\n drivers/net/ice/ice_ethdev.h        |  2 ++\n drivers/net/ice/ice_generic_flow.c  |  4 ++-\n drivers/net/ice/ice_switch_filter.c | 45 +++++++++++++++++++++++++++--\n 6 files changed, 73 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c\nindex 28f7f7fb72..0701300c25 100644\n--- a/drivers/net/ice/ice_dcf_ethdev.c\n+++ b/drivers/net/ice/ice_dcf_ethdev.c\n@@ -956,6 +956,13 @@ ice_dcf_link_update(struct rte_eth_dev *dev,\n \treturn rte_eth_linkstatus_set(dev, &new_link);\n }\n \n+bool\n+ice_dcf_adminq_need_retry(struct ice_adapter *ad)\n+{\n+\treturn ad->hw.dcf_enabled &&\n+\t       !__atomic_load_n(&ad->dcf_state_on, __ATOMIC_RELAXED);\n+}\n+\n /* Add UDP tunneling port */\n static int\n ice_dcf_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,\n@@ -1105,6 +1112,7 @@ static int\n ice_dcf_dev_init(struct rte_eth_dev *eth_dev)\n {\n \tstruct ice_dcf_adapter *adapter = eth_dev->data->dev_private;\n+\tstruct ice_adapter *parent_adapter = &adapter->parent;\n \n \teth_dev->dev_ops = &ice_dcf_eth_dev_ops;\n \teth_dev->rx_pkt_burst = ice_dcf_recv_pkts;\n@@ -1116,9 +1124,13 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)\n \tadapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;\n \tif (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {\n \t\tPMD_INIT_LOG(ERR, \"Failed to init DCF hardware\");\n+\t\t__atomic_store_n(&parent_adapter->dcf_state_on, false,\n+\t\t\t\t __ATOMIC_RELAXED);\n \t\treturn -1;\n \t}\n \n+\t__atomic_store_n(&parent_adapter->dcf_state_on, true, __ATOMIC_RELAXED);\n+\n \tif (ice_dcf_init_parent_adapter(eth_dev) != 0) {\n \t\tPMD_INIT_LOG(ERR, \"Failed to init DCF parent adapter\");\n \t\tice_dcf_uninit_hw(eth_dev, &adapter->real_hw);\ndiff --git a/drivers/net/ice/ice_dcf_ethdev.h b/drivers/net/ice/ice_dcf_ethdev.h\nindex 8510e37119..11a1305038 100644\n--- a/drivers/net/ice/ice_dcf_ethdev.h\n+++ b/drivers/net/ice/ice_dcf_ethdev.h\n@@ -64,5 +64,6 @@ int ice_dcf_vf_repr_init(struct rte_eth_dev *vf_rep_eth_dev, void *init_param);\n int ice_dcf_vf_repr_uninit(struct rte_eth_dev *vf_rep_eth_dev);\n int ice_dcf_vf_repr_init_vlan(struct rte_eth_dev *vf_rep_eth_dev);\n void ice_dcf_vf_repr_stop_all(struct ice_dcf_adapter *dcf_adapter);\n+bool ice_dcf_adminq_need_retry(struct ice_adapter *ad);\n \n #endif /* _ICE_DCF_ETHDEV_H_ */\ndiff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c\nindex 1ff2c47172..0c8c2ed6c7 100644\n--- a/drivers/net/ice/ice_dcf_parent.c\n+++ b/drivers/net/ice/ice_dcf_parent.c\n@@ -119,7 +119,9 @@ ice_dcf_vsi_update_service_handler(void *param)\n {\n \tstruct ice_dcf_reset_event_param *reset_param = param;\n \tstruct ice_dcf_hw *hw = reset_param->dcf_hw;\n-\tstruct ice_dcf_adapter *adapter;\n+\tstruct ice_dcf_adapter *adapter =\n+\t\tcontainer_of(hw, struct ice_dcf_adapter, real_hw);\n+\tstruct ice_adapter *parent_adapter = &adapter->parent;\n \n \tpthread_detach(pthread_self());\n \n@@ -127,11 +129,12 @@ ice_dcf_vsi_update_service_handler(void *param)\n \n \trte_spinlock_lock(&vsi_update_lock);\n \n-\tadapter = container_of(hw, struct ice_dcf_adapter, real_hw);\n-\n-\tif (!ice_dcf_handle_vsi_update_event(hw))\n+\tif (!ice_dcf_handle_vsi_update_event(hw)) {\n+\t\t__atomic_store_n(&parent_adapter->dcf_state_on, true,\n+\t\t\t\t __ATOMIC_RELAXED);\n \t\tice_dcf_update_vf_vsi_map(&adapter->parent.hw,\n \t\t\t\t\t  hw->num_vfs, hw->vf_vsi_map);\n+\t}\n \n \tif (reset_param->vfr && adapter->repr_infos) {\n \t\tstruct rte_eth_dev *vf_rep_eth_dev =\n@@ -224,6 +227,9 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,\n \t\t\t    uint8_t *msg, uint16_t msglen)\n {\n \tstruct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;\n+\tstruct ice_dcf_adapter *adapter =\n+\t\tcontainer_of(dcf_hw, struct ice_dcf_adapter, real_hw);\n+\tstruct ice_adapter *parent_adapter = &adapter->parent;\n \n \tif (msglen < sizeof(struct virtchnl_pf_event)) {\n \t\tPMD_DRV_LOG(DEBUG, \"Invalid event message length : %u\", msglen);\n@@ -258,6 +264,8 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,\n \t\tPMD_DRV_LOG(DEBUG, \"VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u\",\n \t\t\t    pf_msg->event_data.vf_vsi_map.vf_id,\n \t\t\t    pf_msg->event_data.vf_vsi_map.vsi_id);\n+\t\t__atomic_store_n(&parent_adapter->dcf_state_on, false,\n+\t\t\t\t __ATOMIC_RELAXED);\n \t\tstart_vsi_reset_thread(dcf_hw, true,\n \t\t\t\t       pf_msg->event_data.vf_vsi_map.vf_id);\n \t\tbreak;\ndiff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h\nindex 11f7eb4352..38b93a953d 100644\n--- a/drivers/net/ice/ice_ethdev.h\n+++ b/drivers/net/ice/ice_ethdev.h\n@@ -531,6 +531,8 @@ struct ice_adapter {\n \tuint64_t time_hw;\n \tstruct ice_fdir_prof_info fdir_prof_info[ICE_MAX_PTGS];\n \tstruct ice_rss_prof_info rss_prof_info[ICE_MAX_PTGS];\n+\t/* True if DCF state of the associated PF is on */\n+\tbool dcf_state_on;\n #ifdef RTE_ARCH_X86\n \tbool rx_use_avx2;\n \tbool rx_use_avx512;\ndiff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c\nindex c673feb7a6..406a0a953f 100644\n--- a/drivers/net/ice/ice_generic_flow.c\n+++ b/drivers/net/ice/ice_generic_flow.c\n@@ -2515,7 +2515,9 @@ ice_flow_flush(struct rte_eth_dev *dev,\n \t\tret = ice_flow_destroy(dev, p_flow, error);\n \t\tif (ret) {\n \t\t\tPMD_DRV_LOG(ERR, \"Failed to flush flows\");\n-\t\t\treturn -EINVAL;\n+\t\t\tif (ret != -EAGAIN)\n+\t\t\t\tret = -EINVAL;\n+\t\t\treturn ret;\n \t\t}\n \t}\n \ndiff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c\nindex ed29c00d77..bd805d9606 100644\n--- a/drivers/net/ice/ice_switch_filter.c\n+++ b/drivers/net/ice/ice_switch_filter.c\n@@ -400,6 +400,14 @@ ice_switch_create(struct ice_adapter *ad,\n \t\t\t\"lookup list should not be NULL\");\n \t\tgoto error;\n \t}\n+\n+\tif (ice_dcf_adminq_need_retry(ad)) {\n+\t\trte_flow_error_set(error, EAGAIN,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM, NULL,\n+\t\t\t\"DCF is not on\");\n+\t\tgoto error;\n+\t}\n+\n \tret = ice_add_adv_rule(hw, list, lkups_cnt, rule_info, &rule_added);\n \tif (!ret) {\n \t\tfilter_conf_ptr = rte_zmalloc(\"ice_switch_filter\",\n@@ -423,7 +431,12 @@ ice_switch_create(struct ice_adapter *ad,\n \n \t\tflow->rule = filter_conf_ptr;\n \t} else {\n-\t\trte_flow_error_set(error, EINVAL,\n+\t\tif (ice_dcf_adminq_need_retry(ad))\n+\t\t\tret = -EAGAIN;\n+\t\telse\n+\t\t\tret = -EINVAL;\n+\n+\t\trte_flow_error_set(error, -ret,\n \t\t\tRTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n \t\t\t\"switch filter create flow fail\");\n \t\tgoto error;\n@@ -475,9 +488,21 @@ ice_switch_destroy(struct ice_adapter *ad,\n \t\treturn -rte_errno;\n \t}\n \n+\tif (ice_dcf_adminq_need_retry(ad)) {\n+\t\trte_flow_error_set(error, EAGAIN,\n+\t\t\tRTE_FLOW_ERROR_TYPE_ITEM, NULL,\n+\t\t\t\"DCF is not on\");\n+\t\treturn -rte_errno;\n+\t}\n+\n \tret = ice_rem_adv_rule_by_id(hw, &filter_conf_ptr->sw_query_data);\n \tif (ret) {\n-\t\trte_flow_error_set(error, EINVAL,\n+\t\tif (ice_dcf_adminq_need_retry(ad))\n+\t\t\tret = -EAGAIN;\n+\t\telse\n+\t\t\tret = -EINVAL;\n+\n+\t\trte_flow_error_set(error, -ret,\n \t\t\tRTE_FLOW_ERROR_TYPE_HANDLE, NULL,\n \t\t\t\"fail to destroy switch filter rule\");\n \t\treturn -rte_errno;\n@@ -2016,6 +2041,12 @@ ice_switch_redirect(struct ice_adapter *ad,\n \t}\n \n rmv_rule:\n+\tif (ice_dcf_adminq_need_retry(ad)) {\n+\t\tPMD_DRV_LOG(WARNING, \"DCF is not on\");\n+\t\tret = -EAGAIN;\n+\t\tgoto out;\n+\t}\n+\n \t/* Remove the old rule */\n \tret = ice_rem_adv_rule(hw, lkups_ref, lkups_cnt, &rinfo);\n \tif (ret) {\n@@ -2028,6 +2059,12 @@ ice_switch_redirect(struct ice_adapter *ad,\n \t}\n \n add_rule:\n+\tif (ice_dcf_adminq_need_retry(ad)) {\n+\t\tPMD_DRV_LOG(WARNING, \"DCF is not on\");\n+\t\tret = -EAGAIN;\n+\t\tgoto out;\n+\t}\n+\n \t/* Update VSI context */\n \thw->vsi_ctx[rd->vsi_handle]->vsi_num = rd->new_vsi_num;\n \n@@ -2047,6 +2084,10 @@ ice_switch_redirect(struct ice_adapter *ad,\n \t}\n \n out:\n+\tif (ret == -EINVAL)\n+\t\tif (ice_dcf_adminq_need_retry(ad))\n+\t\t\tret = -EAGAIN;\n+\n \tice_free(hw, lkups_dp);\n \treturn ret;\n }\n",
    "prefixes": [
        "v2"
    ]
}