get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66487,
    "url": "http://patches.dpdk.org/api/patches/66487/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200310065029.40966-8-haiyue.wang@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20200310065029.40966-8-haiyue.wang@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200310065029.40966-8-haiyue.wang@intel.com",
    "date": "2020-03-10T06:50:29",
    "name": "[v2,7/7] net/ice: get the VF hardware index in DCF",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "17fe337559d24ae25f6b43e32dd6219cb72cbfc6",
    "submitter": {
        "id": 1044,
        "url": "http://patches.dpdk.org/api/people/1044/?format=api",
        "name": "Wang, Haiyue",
        "email": "haiyue.wang@intel.com"
    },
    "delegate": {
        "id": 31221,
        "url": "http://patches.dpdk.org/api/users/31221/?format=api",
        "username": "yexl",
        "first_name": "xiaolong",
        "last_name": "ye",
        "email": "xiaolong.ye@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200310065029.40966-8-haiyue.wang@intel.com/mbox/",
    "series": [
        {
            "id": 8859,
            "url": "http://patches.dpdk.org/api/series/8859/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8859",
            "date": "2020-03-10T06:50:22",
            "name": "add Intel DCF PMD support",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/8859/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66487/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/66487/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 1FF69A0563;\n\tTue, 10 Mar 2020 07:59:38 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 1C0671C07B;\n\tTue, 10 Mar 2020 07:58:38 +0100 (CET)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by dpdk.org (Postfix) with ESMTP id 4C76C1C05C\n for <dev@dpdk.org>; Tue, 10 Mar 2020 07:58:33 +0100 (CET)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 09 Mar 2020 23:58:32 -0700",
            "from npg-dpdk-haiyue-1.sh.intel.com ([10.67.119.213])\n by orsmga001.jf.intel.com with ESMTP; 09 Mar 2020 23:58:30 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.70,518,1574150400\"; d=\"scan'208\";a=\"321693994\"",
        "From": "Haiyue Wang <haiyue.wang@intel.com>",
        "To": "dev@dpdk.org, xiaolong.ye@intel.com, qi.z.zhang@intel.com,\n qiming.yang@intel.com, beilei.xing@intel.com",
        "Cc": "wei.zhao1@intel.com,\n\tHaiyue Wang <haiyue.wang@intel.com>",
        "Date": "Tue, 10 Mar 2020 14:50:29 +0800",
        "Message-Id": "<20200310065029.40966-8-haiyue.wang@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200310065029.40966-1-haiyue.wang@intel.com>",
        "References": "<20200309141437.11800-1-haiyue.wang@intel.com>\n <20200310065029.40966-1-haiyue.wang@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v2 7/7] net/ice: get the VF hardware index in DCF",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The DCF (Device Config Function) needs the hardware index of the VFs to\ncontrol the flow setting. And also if the VF resets, the index may be\nchanged, so it should handle this in VF reset event.\n\nSigned-off-by: Haiyue Wang <haiyue.wang@intel.com>\n---\n drivers/net/ice/ice_dcf.c        | 81 +++++++++++++++++++++++++++++++\n drivers/net/ice/ice_dcf.h        |  4 ++\n drivers/net/ice/ice_dcf_parent.c | 83 +++++++++++++++++++++++++++++++-\n 3 files changed, 167 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c\nindex 480c449f5..1d3c8fa95 100644\n--- a/drivers/net/ice/ice_dcf.c\n+++ b/drivers/net/ice/ice_dcf.c\n@@ -269,6 +269,63 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)\n \treturn 0;\n }\n \n+static int\n+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)\n+{\n+\tstruct virtchnl_dcf_vsi_map *vsi_map;\n+\tuint16_t len;\n+\tint err;\n+\n+\terr = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,\n+\t\t\t\t\t  NULL, 0);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Fail to send msg OP_DCF_GET_VSI_MAP\");\n+\t\treturn err;\n+\t}\n+\n+\terr = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,\n+\t\t\t\t\t  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,\n+\t\t\t\t\t  &len);\n+\tif (err) {\n+\t\tPMD_DRV_LOG(ERR, \"Fail to get response of OP_DCF_GET_VSI_MAP\");\n+\t\treturn err;\n+\t}\n+\n+\tvsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;\n+\tif (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||\n+\t    len < sizeof(*vsi_map) +\n+\t\t\t(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {\n+\t\tPMD_DRV_LOG(ERR, \"invalid vf vsi map response with length %u\",\n+\t\t\t    len);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {\n+\t\tPMD_DRV_LOG(ERR, \"The number VSI map (%u) doesn't match the number of VFs (%u)\",\n+\t\t\t    vsi_map->num_vfs, hw->num_vfs);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tlen = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);\n+\tif (!hw->vf_vsi_map) {\n+\t\thw->num_vfs = vsi_map->num_vfs;\n+\t\thw->vf_vsi_map = rte_zmalloc(\"vf_vsi_ctx\", len, 0);\n+\t}\n+\n+\tif (!hw->vf_vsi_map) {\n+\t\tPMD_DRV_LOG(ERR, \"Fail to alloc memory for VSI context\");\n+\t\treturn -ENOMEM;\n+\t}\n+\n+\tif (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {\n+\t\tPMD_DRV_LOG(DEBUG, \"VF VSI map doesn't change\");\n+\t\treturn 1;\n+\t}\n+\n+\trte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);\n+\treturn 0;\n+}\n+\n static int\n ice_dcf_mode_disable(struct ice_dcf_hw *hw)\n {\n@@ -467,6 +524,23 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,\n \treturn err;\n }\n \n+int\n+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)\n+{\n+\tint err = 0;\n+\n+\trte_spinlock_lock(&hw->vc_cmd_send_lock);\n+\tice_dcf_disable_irq0(hw);\n+\n+\tif (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))\n+\t\terr = -1;\n+\n+\tice_dcf_enable_irq0(hw);\n+\trte_spinlock_unlock(&hw->vc_cmd_send_lock);\n+\n+\treturn err;\n+}\n+\n int\n ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)\n {\n@@ -534,6 +608,12 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)\n \t\tgoto err_alloc;\n \t}\n \n+\tif (ice_dcf_get_vf_vsi_map(hw) < 0) {\n+\t\tPMD_INIT_LOG(ERR, \"Failed to get VF VSI map\");\n+\t\tice_dcf_mode_disable(hw);\n+\t\tgoto err_alloc;\n+\t}\n+\n \trte_intr_callback_register(&pci_dev->intr_handle,\n \t\t\t\t   ice_dcf_dev_interrupt_handler, hw);\n \trte_intr_enable(&pci_dev->intr_handle);\n@@ -566,5 +646,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)\n \tiavf_shutdown_adminq(&hw->avf);\n \n \trte_free(hw->arq_buf);\n+\trte_free(hw->vf_vsi_map);\n \trte_free(hw->vf_res);\n }\ndiff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h\nindex ecd6303a0..12bef4a2a 100644\n--- a/drivers/net/ice/ice_dcf.h\n+++ b/drivers/net/ice/ice_dcf.h\n@@ -41,6 +41,9 @@ struct ice_dcf_hw {\n \n \tuint8_t *arq_buf;\n \n+\tuint16_t num_vfs;\n+\tuint16_t *vf_vsi_map;\n+\n \tstruct virtchnl_version_info virtchnl_version;\n \tstruct virtchnl_vf_resource *vf_res; /* VF resource */\n \tstruct virtchnl_vsi_resource *vsi_res; /* LAN VSI */\n@@ -51,6 +54,7 @@ int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,\n \t\t\t\t struct dcf_virtchnl_cmd *cmd);\n int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,\n \t\t\tvoid *buf, uint16_t buf_size);\n+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);\n int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);\n void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);\n \ndiff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c\nindex 4c3bb68b1..2735221e9 100644\n--- a/drivers/net/ice/ice_dcf_parent.c\n+++ b/drivers/net/ice/ice_dcf_parent.c\n@@ -5,10 +5,76 @@\n #include <sys/stat.h>\n #include <unistd.h>\n \n+#include <rte_alarm.h>\n+\n #include \"ice_dcf_ethdev.h\"\n \n+#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL\t100000 /* us */\n+\n+static __rte_always_inline void\n+ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,\n+\t\t       uint16_t vsi_map)\n+{\n+\tstruct ice_vsi_ctx *vsi_ctx;\n+\n+\tif (unlikely(vsi_handle >= ICE_MAX_VSI)) {\n+\t\tPMD_DRV_LOG(ERR, \"Invalid vsi handle %u\", vsi_handle);\n+\t\treturn;\n+\t}\n+\n+\tvsi_ctx = hw->vsi_ctx[vsi_handle];\n+\n+\tif (vsi_map & VIRTCHNL_DCF_VF_VSI_VALID) {\n+\t\tif (!vsi_ctx)\n+\t\t\tvsi_ctx = ice_malloc(hw, sizeof(*vsi_ctx));\n+\n+\t\tif (!vsi_ctx) {\n+\t\t\tPMD_DRV_LOG(ERR, \"No memory for vsi context %u\",\n+\t\t\t\t    vsi_handle);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tvsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>\n+\t\t\t\t\t      VIRTCHNL_DCF_VF_VSI_ID_S;\n+\t\thw->vsi_ctx[vsi_handle] = vsi_ctx;\n+\n+\t\tPMD_DRV_LOG(DEBUG, \"VF%u is assigned with vsi number %u\",\n+\t\t\t    vsi_handle, vsi_ctx->vsi_num);\n+\t} else {\n+\t\thw->vsi_ctx[vsi_handle] = NULL;\n+\n+\t\tice_free(hw, vsi_ctx);\n+\n+\t\tPMD_DRV_LOG(NOTICE, \"VF%u is disabled\", vsi_handle);\n+\t}\n+}\n+\n+static void\n+ice_dcf_update_vf_vsi_map(struct ice_hw *hw, uint16_t num_vfs,\n+\t\t\t  uint16_t *vf_vsi_map)\n+{\n+\tuint16_t vf_id;\n+\n+\tfor (vf_id = 0; vf_id < num_vfs; vf_id++)\n+\t\tice_dcf_update_vsi_ctx(hw, vf_id, vf_vsi_map[vf_id]);\n+}\n+\n+static void\n+ice_dcf_vsi_update_service_handler(void *param)\n+{\n+\tstruct ice_dcf_hw *hw = param;\n+\n+\tif (!ice_dcf_handle_vsi_update_event(hw)) {\n+\t\tstruct ice_dcf_adapter *dcf_ad =\n+\t\t\tcontainer_of(hw, struct ice_dcf_adapter, real_hw);\n+\n+\t\tice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw,\n+\t\t\t\t\t  hw->num_vfs, hw->vf_vsi_map);\n+\t}\n+}\n+\n void\n-ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,\n+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@@ -21,6 +87,8 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,\n \tswitch (pf_msg->event) {\n \tcase VIRTCHNL_EVENT_RESET_IMPENDING:\n \t\tPMD_DRV_LOG(DEBUG, \"VIRTCHNL_EVENT_RESET_IMPENDING event\");\n+\t\trte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL * 2,\n+\t\t\t\t  ice_dcf_vsi_update_service_handler, dcf_hw);\n \t\tbreak;\n \tcase VIRTCHNL_EVENT_LINK_CHANGE:\n \t\tPMD_DRV_LOG(DEBUG, \"VIRTCHNL_EVENT_LINK_CHANGE event\");\n@@ -28,6 +96,13 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,\n \tcase VIRTCHNL_EVENT_PF_DRIVER_CLOSE:\n \t\tPMD_DRV_LOG(DEBUG, \"VIRTCHNL_EVENT_PF_DRIVER_CLOSE event\");\n \t\tbreak;\n+\tcase VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE:\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\trte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL,\n+\t\t\t\t  ice_dcf_vsi_update_service_handler, dcf_hw);\n+\t\tbreak;\n \tdefault:\n \t\tPMD_DRV_LOG(ERR, \"Unknown event received %u\", pf_msg->event);\n \t\tbreak;\n@@ -235,6 +310,9 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)\n \t}\n \tparent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);\n \n+\tice_dcf_update_vf_vsi_map(parent_hw,\n+\t\t\t\t  hw->num_vfs, hw->vf_vsi_map);\n+\n \tmac = (const struct rte_ether_addr *)hw->avf.mac.addr;\n \tif (rte_is_valid_assigned_ether_addr(mac))\n \t\trte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);\n@@ -259,5 +337,8 @@ ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)\n \n \teth_dev->data->mac_addrs = NULL;\n \n+\trte_eal_alarm_cancel(ice_dcf_vsi_update_service_handler,\n+\t\t\t     &adapter->real_hw);\n+\n \tice_dcf_uninit_parent_hw(parent_hw);\n }\n",
    "prefixes": [
        "v2",
        "7/7"
    ]
}