get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 77012,
    "url": "http://patches.dpdk.org/api/patches/77012/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200909072028.16726-2-ting.xu@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": "<20200909072028.16726-2-ting.xu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200909072028.16726-2-ting.xu@intel.com",
    "date": "2020-09-09T07:20:27",
    "name": "[v1,1/2] net/iavf: add IAVF request queues",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1eb03c6e0123831d1a3af0398975e61bf1adb1e7",
    "submitter": {
        "id": 1363,
        "url": "http://patches.dpdk.org/api/people/1363/?format=api",
        "name": "Xu, Ting",
        "email": "ting.xu@intel.com"
    },
    "delegate": {
        "id": 1540,
        "url": "http://patches.dpdk.org/api/users/1540/?format=api",
        "username": "qzhan15",
        "first_name": "Qi",
        "last_name": "Zhang",
        "email": "qi.z.zhang@intel.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200909072028.16726-2-ting.xu@intel.com/mbox/",
    "series": [
        {
            "id": 12046,
            "url": "http://patches.dpdk.org/api/series/12046/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12046",
            "date": "2020-09-09T07:20:26",
            "name": "enable large VF configuration",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/12046/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/77012/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/77012/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 97DA8A04B1;\n\tWed,  9 Sep 2020 09:17:01 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 189711C0D9;\n\tWed,  9 Sep 2020 09:16:54 +0200 (CEST)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n by dpdk.org (Postfix) with ESMTP id 612441B9B7\n for <dev@dpdk.org>; Wed,  9 Sep 2020 09:16:51 +0200 (CEST)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 09 Sep 2020 00:16:46 -0700",
            "from dpdk-xuting-second.sh.intel.com ([10.67.116.154])\n by fmsmga004.fm.intel.com with ESMTP; 09 Sep 2020 00:16:45 -0700"
        ],
        "IronPort-SDR": [
            "\n swt9/m61ZUL9w0GJr27T+LZmW3n+xYpC9nhQqMTOnTFudwquZt9SbaPbHtl0neFNgmnrUnguCW\n 4JavJZ2Be9ZA==",
            "\n pfUzTb22KSYKnaMBFx/q30IguAzrsg1AVTlj7RVa9vaE7A7XySL/7g+kynR3Gg9uJjpb2kKizO\n gOxZvWcNF/zQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9738\"; a=\"219840804\"",
            "E=Sophos;i=\"5.76,408,1592895600\"; d=\"scan'208\";a=\"219840804\"",
            "E=Sophos;i=\"5.76,408,1592895600\"; d=\"scan'208\";a=\"328804527\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Ting Xu <ting.xu@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "qi.z.zhang@intel.com, jingjing.wu@intel.com, Ting Xu <ting.xu@intel.com>",
        "Date": "Wed,  9 Sep 2020 15:20:27 +0800",
        "Message-Id": "<20200909072028.16726-2-ting.xu@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200909072028.16726-1-ting.xu@intel.com>",
        "References": "<20200909072028.16726-1-ting.xu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v1 1/2] net/iavf: add IAVF request queues",
        "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": "Add support for IAVF request queues from PF. VF sends desired queue\npairs number to PF to ask for queue allocation. If the request succeeds,\nVF should reset. If fails, PF will return available queue pairs number.\n\nSigned-off-by: Ting Xu <ting.xu@intel.com>\n---\n drivers/net/iavf/iavf.h        |  17 +++++\n drivers/net/iavf/iavf_ethdev.c |  12 +++-\n drivers/net/iavf/iavf_vchnl.c  | 117 +++++++++++++++++++++++++++++----\n 3 files changed, 131 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h\nindex 9ad331ee9..1a42936a0 100644\n--- a/drivers/net/iavf/iavf.h\n+++ b/drivers/net/iavf/iavf.h\n@@ -107,6 +107,21 @@ struct iavf_fdir_info {\n /* TODO: is that correct to assume the max number to be 16 ?*/\n #define IAVF_MAX_MSIX_VECTORS   16\n \n+/* Event status from PF */\n+enum pending_msg {\n+\tPFMSG_LINK_CHANGE = 0x1,\n+\tPFMSG_RESET_IMPENDING = 0x2,\n+\tPFMSG_DRIVER_CLOSE = 0x4,\n+};\n+\n+/* Message type read in admin queue from PF */\n+enum iavf_aq_result {\n+\tIAVF_MSG_ERR = -1, /* Meet error when accessing admin queue */\n+\tIAVF_MSG_NON,      /* Read nothing from admin queue */\n+\tIAVF_MSG_SYS,      /* Read system msg from admin queue */\n+\tIAVF_MSG_CMD,      /* Read async command result */\n+};\n+\n /* Structure to store private data specific for VF instance. */\n struct iavf_info {\n \tuint16_t num_queue_pairs;\n@@ -123,6 +138,7 @@ struct iavf_info {\n \tvolatile enum virtchnl_ops pend_cmd; /* pending command not finished */\n \tuint32_t cmd_retval; /* return value of the cmd response from PF */\n \tuint8_t *aq_resp; /* buffer to store the adminq response from PF */\n+\tuint16_t pend_msg; /* flags indicates events from pf not handled yet */\n \n \t/* Event from pf */\n \tbool dev_closed;\n@@ -279,4 +295,5 @@ int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,\n int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,\n \t\t\tstruct rte_ether_addr *mc_addrs,\n \t\t\tuint32_t mc_addrs_num, bool add);\n+int iavf_request_queues(struct rte_eth_dev *dev, uint16_t num);\n #endif /* _IAVF_ETHDEV_H_ */\ndiff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c\nindex 8e1d8a8d3..48e474f53 100644\n--- a/drivers/net/iavf/iavf_ethdev.c\n+++ b/drivers/net/iavf/iavf_ethdev.c\n@@ -1196,7 +1196,7 @@ iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)\n }\n \n static int\n-iavf_check_vf_reset_done(struct iavf_hw *hw)\n+iavf_check_vf_reset_done(struct iavf_hw *hw, struct iavf_info *vf)\n {\n \tint i, reset;\n \n@@ -1213,6 +1213,10 @@ iavf_check_vf_reset_done(struct iavf_hw *hw)\n \tif (i >= IAVF_RESET_WAIT_CNT)\n \t\treturn -1;\n \n+\t/* VF is not in reset or reset is completed */\n+\tvf->vf_reset = false;\n+\tvf->pend_msg &= ~PFMSG_RESET_IMPENDING;\n+\n \treturn 0;\n }\n \n@@ -1231,7 +1235,7 @@ iavf_init_vf(struct rte_eth_dev *dev)\n \t\tgoto err;\n \t}\n \n-\terr = iavf_check_vf_reset_done(hw);\n+\terr = iavf_check_vf_reset_done(hw, vf);\n \tif (err) {\n \t\tPMD_INIT_LOG(ERR, \"VF is still resetting\");\n \t\tgoto err;\n@@ -1473,7 +1477,9 @@ iavf_dev_close(struct rte_eth_dev *dev)\n \n \tiavf_dev_stop(dev);\n \tiavf_flow_flush(dev, NULL);\n-\tiavf_flow_uninit(adapter);\n+\t/* if VF is in reset, adminq is disabled, skip the process via adminq */\n+\tif (!vf->vf_reset)\n+\t\tiavf_flow_uninit(adapter);\n \tiavf_shutdown_adminq(hw);\n \t/* disable uio intr before callback unregister */\n \trte_intr_disable(intr_handle);\ndiff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c\nindex 34c31a153..eab2f2a22 100644\n--- a/drivers/net/iavf/iavf_vchnl.c\n+++ b/drivers/net/iavf/iavf_vchnl.c\n@@ -17,6 +17,7 @@\n #include <rte_eal.h>\n #include <rte_ether.h>\n #include <rte_ethdev_driver.h>\n+#include <rte_ethdev_pci.h>\n #include <rte_dev.h>\n #include <rte_bus_pci.h>\n \n@@ -27,13 +28,14 @@\n #define ASQ_DELAY_MS  10\n \n /* Read data in admin queue to get msg from pf driver */\n-static enum iavf_status\n+static enum iavf_aq_result\n iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,\n \t\t     uint8_t *buf)\n {\n \tstruct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);\n \tstruct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);\n \tstruct iavf_arq_event_info event;\n+\tenum iavf_aq_result result = IAVF_MSG_NON;\n \tenum virtchnl_ops opcode;\n \tint ret;\n \n@@ -43,7 +45,9 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,\n \t/* Can't read any msg from adminQ */\n \tif (ret) {\n \t\tPMD_DRV_LOG(DEBUG, \"Can't read msg from AQ\");\n-\t\treturn ret;\n+\t\tif (ret != IAVF_ERR_ADMIN_QUEUE_NO_WORK)\n+\t\t\tresult = IAVF_MSG_ERR;\n+\t\treturn result;\n \t}\n \n \topcode = (enum virtchnl_ops)rte_le_to_cpu_32(event.desc.cookie_high);\n@@ -53,16 +57,46 @@ iavf_read_msg_from_pf(struct iavf_adapter *adapter, uint16_t buf_len,\n \tPMD_DRV_LOG(DEBUG, \"AQ from pf carries opcode %u, retval %d\",\n \t\t    opcode, vf->cmd_retval);\n \n-\tif (opcode != vf->pend_cmd) {\n-\t\tif (opcode != VIRTCHNL_OP_EVENT) {\n-\t\t\tPMD_DRV_LOG(WARNING,\n-\t\t\t\t    \"command mismatch, expect %u, get %u\",\n-\t\t\t\t    vf->pend_cmd, opcode);\n+\tif (opcode == VIRTCHNL_OP_EVENT) {\n+\t\tstruct virtchnl_pf_event *vpe =\n+\t\t\t(struct virtchnl_pf_event *)event.msg_buf;\n+\n+\t\tresult = IAVF_MSG_SYS;\n+\t\tswitch (vpe->event) {\n+\t\tcase VIRTCHNL_EVENT_LINK_CHANGE:\n+\t\t\tvf->link_up =\n+\t\t\t\tvpe->event_data.link_event.link_status;\n+\t\t\tvf->link_speed =\n+\t\t\t\tvpe->event_data.link_event.link_speed;\n+\t\t\tvf->pend_msg |= PFMSG_LINK_CHANGE;\n+\t\t\tPMD_DRV_LOG(INFO, \"Link status update:%s\",\n+\t\t\t\t\tvf->link_up ? \"up\" : \"down\");\n+\t\t\tbreak;\n+\t\tcase VIRTCHNL_EVENT_RESET_IMPENDING:\n+\t\t\tvf->vf_reset = true;\n+\t\t\tvf->pend_msg |= PFMSG_RESET_IMPENDING;\n+\t\t\tPMD_DRV_LOG(INFO, \"vf is reseting\");\n+\t\t\tbreak;\n+\t\tcase VIRTCHNL_EVENT_PF_DRIVER_CLOSE:\n+\t\t\tvf->dev_closed = true;\n+\t\t\tvf->pend_msg |= PFMSG_DRIVER_CLOSE;\n+\t\t\tPMD_DRV_LOG(INFO, \"PF driver closed\");\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tPMD_DRV_LOG(ERR, \"%s: Unknown event %d from pf\",\n+\t\t\t\t\t__func__, vpe->event);\n+\t\t}\n+\t}  else {\n+\t\t/* async reply msg on command issued by vf previously */\n+\t\tresult = IAVF_MSG_CMD;\n+\t\tif (opcode != vf->pend_cmd) {\n+\t\t\tPMD_DRV_LOG(WARNING, \"command mismatch, expect %u, get %u\",\n+\t\t\t\t\tvf->pend_cmd, opcode);\n+\t\t\tresult = IAVF_MSG_ERR;\n \t\t}\n-\t\treturn IAVF_ERR_OPCODE_MISMATCH;\n \t}\n \n-\treturn IAVF_SUCCESS;\n+\treturn result;\n }\n \n static int\n@@ -70,6 +104,7 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)\n {\n \tstruct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter);\n \tstruct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);\n+\tenum iavf_aq_result result;\n \tenum iavf_status ret;\n \tint err = 0;\n \tint i = 0;\n@@ -95,9 +130,9 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)\n \tcase VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:\n \t\t/* for init virtchnl ops, need to poll the response */\n \t\tdo {\n-\t\t\tret = iavf_read_msg_from_pf(adapter, args->out_size,\n+\t\t\tresult = iavf_read_msg_from_pf(adapter, args->out_size,\n \t\t\t\t\t\t   args->out_buffer);\n-\t\t\tif (ret == IAVF_SUCCESS)\n+\t\t\tif (result == IAVF_MSG_CMD)\n \t\t\t\tbreak;\n \t\t\trte_delay_ms(ASQ_DELAY_MS);\n \t\t} while (i++ < MAX_TRY_TIMES);\n@@ -109,7 +144,33 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args)\n \t\t}\n \t\t_clear_cmd(vf);\n \t\tbreak;\n-\n+\tcase VIRTCHNL_OP_REQUEST_QUEUES:\n+\t\t/*\n+\t\t * ignore async reply, only wait for system message,\n+\t\t * vf_reset = true if get VIRTCHNL_EVENT_RESET_IMPENDING,\n+\t\t * if not, means request queues failed.\n+\t\t */\n+\t\tdo {\n+\t\t\tresult = iavf_read_msg_from_pf(adapter, args->out_size,\n+\t\t\t\t\t\t   args->out_buffer);\n+\t\t\tif (result == IAVF_MSG_SYS && vf->vf_reset) {\n+\t\t\t\tbreak;\n+\t\t\t} else if (result == IAVF_MSG_CMD ||\n+\t\t\t\tresult == IAVF_MSG_ERR) {\n+\t\t\t\terr = -1;\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t\trte_delay_ms(ASQ_DELAY_MS);\n+\t\t\t/* If don't read msg or read sys event, continue */\n+\t\t} while (i++ < MAX_TRY_TIMES);\n+\t\tif (i >= MAX_TRY_TIMES ||\n+\t\t    vf->cmd_retval != VIRTCHNL_STATUS_SUCCESS) {\n+\t\t\terr = -1;\n+\t\t\tPMD_DRV_LOG(ERR, \"No response or return failure (%d)\"\n+\t\t\t\t    \" for cmd %d\", vf->cmd_retval, args->ops);\n+\t\t}\n+\t\t_clear_cmd(vf);\n+\t\tbreak;\n \tdefault:\n \t\t/* For other virtchnl ops in running time,\n \t\t * wait for the cmd done flag.\n@@ -1168,3 +1229,35 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,\n \n \treturn 0;\n }\n+\n+int\n+iavf_request_queues(struct rte_eth_dev *dev, uint16_t num)\n+{\n+\tstruct iavf_adapter *ad =\n+\t\tIAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);\n+\tstruct iavf_info *vf =  IAVF_DEV_PRIVATE_TO_VF(ad);\n+\tstruct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);\n+\tstruct virtchnl_vf_res_request vfres;\n+\tstruct iavf_cmd_info args;\n+\tint err;\n+\n+\tvfres.num_queue_pairs = num;\n+\n+\targs.ops = VIRTCHNL_OP_REQUEST_QUEUES;\n+\targs.in_args = (u8 *)&vfres;\n+\targs.in_args_size = sizeof(vfres);\n+\targs.out_buffer = vf->aq_resp;\n+\targs.out_size = IAVF_AQ_BUF_SZ;\n+\n+\t/*\n+\t * disable interrupt to avoid the admin queue message to be read\n+\t * before iavf_read_msg_from_pf.\n+\t */\n+\trte_intr_disable(&pci_dev->intr_handle);\n+\terr = iavf_execute_vf_cmd(ad, &args);\n+\tif (err)\n+\t\tPMD_DRV_LOG(ERR, \"fail to execute command OP_REQUEST_QUEUES\");\n+\trte_intr_enable(&pci_dev->intr_handle);\n+\n+\treturn err;\n+}\n",
    "prefixes": [
        "v1",
        "1/2"
    ]
}