get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 87916,
    "url": "https://patches.dpdk.org/api/patches/87916/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1613272907-22563-9-git-send-email-xuemingl@nvidia.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<1613272907-22563-9-git-send-email-xuemingl@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1613272907-22563-9-git-send-email-xuemingl@nvidia.com",
    "date": "2021-02-14T03:21:38",
    "name": "[v6,8/9] ethdev: representor iterator compare complete info",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "a1540a8067679174ac097ec3136e7b64fdf7d592",
    "submitter": {
        "id": 1904,
        "url": "https://patches.dpdk.org/api/people/1904/?format=api",
        "name": "Xueming Li",
        "email": "xuemingl@nvidia.com"
    },
    "delegate": {
        "id": 319,
        "url": "https://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1613272907-22563-9-git-send-email-xuemingl@nvidia.com/mbox/",
    "series": [
        {
            "id": 15258,
            "url": "https://patches.dpdk.org/api/series/15258/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=15258",
            "date": "2021-02-14T03:21:30",
            "name": "ethdev: support SubFunction representor",
            "version": 6,
            "mbox": "https://patches.dpdk.org/series/15258/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/87916/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/87916/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 3365DA0546;\n\tSun, 14 Feb 2021 04:24:17 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 6A7CE22A256;\n\tSun, 14 Feb 2021 04:23:54 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id CF74322A25F\n for <dev@dpdk.org>; Sun, 14 Feb 2021 04:23:52 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n xuemingl@nvidia.com) with SMTP; 14 Feb 2021 05:23:47 +0200",
            "from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 11E3MYvU008525;\n Sun, 14 Feb 2021 05:23:47 +0200"
        ],
        "From": "Xueming Li <xuemingl@nvidia.com>",
        "To": "",
        "Cc": "dev@dpdk.org, Viacheslav Ovsiienko <viacheslavo@nvidia.com>,\n xuemingl@nvidia.com, Asaf Penso <asafp@nvidia.com>,\n Thomas Monjalon <thomas@monjalon.net>,\n Ferruh Yigit <ferruh.yigit@intel.com>,\n Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Ray Kinsella <mdr@ashroe.eu>, Neil Horman <nhorman@tuxdriver.com>",
        "Date": "Sun, 14 Feb 2021 03:21:38 +0000",
        "Message-Id": "<1613272907-22563-9-git-send-email-xuemingl@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<1613272907-22563-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "References": [
            "<1613272907-22563-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v6 8/9] ethdev: representor iterator compare\n complete info",
        "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",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "The NIC can have multiple PCIe links and can be attached to multiple\nhosts, for example the same single NIC can be shared for multiple server\nunits in the rack. On each PCIe link NIC can provide multiple PFs and\nVFs/SFs based on these ones. The full representor identifier consists of\nthree indices - controller index, PF index, and VF or SF index (if any).\n\nSR-IOV and SubFunction are created on top of PF. PF index is introduced\nbecause there might be multiple PFs in the bonding configuration and\nonly bonding device is probed.\n\nIn eth representor comparator callback, ethdev representor ID was\ncompared with devarg. Since controller index and PF index not compared,\ncallback returned representor from other PF or controller.\n\nThis patch adds new API to convert representor controller, pf and vf/sf\nindex to representor ID. Representor comparer callback convert\nrepresentor info into ID and compare with device representor ID.\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\n---\n lib/librte_ethdev/ethdev_driver.h | 32 ++++++++++++\n lib/librte_ethdev/rte_class_eth.c | 38 ++++++++++----\n lib/librte_ethdev/rte_ethdev.c    | 83 +++++++++++++++++++++++++++++++\n lib/librte_ethdev/version.map     |  1 +\n 4 files changed, 145 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/lib/librte_ethdev/ethdev_driver.h b/lib/librte_ethdev/ethdev_driver.h\nindex abcbc3112d..23342f1be2 100644\n--- a/lib/librte_ethdev/ethdev_driver.h\n+++ b/lib/librte_ethdev/ethdev_driver.h\n@@ -1243,6 +1243,38 @@ struct rte_eth_devargs {\n \tenum rte_eth_representor_type type; /* type of representor */\n };\n \n+/**\n+ * PMD helper function to convert representor ID from location detail\n+ *\n+ * Convert representor ID from controller, pf and (sf or vf).\n+ * The mapping is retrieved from rte_eth_representor_info_get().\n+ *\n+ * If PMD doesn't return representor range info, simply ignore controller\n+ * and pf to keep backward compatibility.\n+ *\n+ * @param ethdev\n+ *  Handle of ethdev port.\n+ * @param id\n+ *  Pointer to converted representor ID.\n+ * @param type\n+ *  Representor type.\n+ * @param controller\n+ *  Controller ID, -1 if unspecified.\n+ * @param pf\n+ *  PF port ID, -1 if unspecified.\n+ * @param representor_port\n+ *  Representor port ID, -1 if unspecified.\n+ *\n+ * @return\n+ *  Negative errno value on error, 0 on success.\n+ */\n+__rte_internal\n+int\n+rte_eth_representor_id_convert(const struct rte_eth_dev *ethdev,\n+\t\t\t       uint16_t *id,\n+\t\t\t       enum rte_eth_representor_type type,\n+\t\t\t       int controller, int pf, int representor_port);\n+\n /**\n  * PMD helper function to parse ethdev arguments\n  *\ndiff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c\nindex 051c892b40..f7b7e659e7 100644\n--- a/lib/librte_ethdev/rte_class_eth.c\n+++ b/lib/librte_ethdev/rte_class_eth.c\n@@ -65,9 +65,10 @@ eth_representor_cmp(const char *key __rte_unused,\n {\n \tint ret;\n \tchar *values;\n-\tconst struct rte_eth_dev_data *data = opaque;\n-\tstruct rte_eth_devargs representors;\n-\tuint16_t index;\n+\tconst struct rte_eth_dev *edev = opaque;\n+\tconst struct rte_eth_dev_data *data = edev->data;\n+\tstruct rte_eth_devargs eth_da;\n+\tuint16_t id, nc, np, nf, i, c, p, f;\n \n \tif ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0)\n \t\treturn -1; /* not a representor port */\n@@ -76,17 +77,36 @@ eth_representor_cmp(const char *key __rte_unused,\n \tvalues = strdup(value);\n \tif (values == NULL)\n \t\treturn -1;\n-\tmemset(&representors, 0, sizeof(representors));\n-\tret = rte_eth_devargs_parse_representor_ports(values, &representors);\n+\tmemset(&eth_da, 0, sizeof(eth_da));\n+\tret = rte_eth_devargs_parse_representor_ports(values, &eth_da);\n \tfree(values);\n \tif (ret != 0)\n \t\treturn -1; /* invalid devargs value */\n \n+\tif (eth_da.nb_mh_controllers == 0 && eth_da.nb_ports == 0 &&\n+\t    eth_da.nb_representor_ports == 0)\n+\t\treturn -1;\n+\tnc = eth_da.nb_mh_controllers > 0 ? eth_da.nb_mh_controllers : 1;\n+\tnp = eth_da.nb_ports > 0 ? eth_da.nb_ports : 1;\n+\tnf = eth_da.nb_representor_ports > 0 ? eth_da.nb_representor_ports : 1;\n+\n \t/* Return 0 if representor id is matching one of the values. */\n-\tfor (index = 0; index < representors.nb_representor_ports; index++)\n-\t\tif (data->representor_id ==\n-\t\t\t\trepresentors.representor_ports[index])\n+\tfor (i = 0; i < nc * np * nf; ++i) {\n+\t\tc = i / (np * nf);\n+\t\tp = (i / nf) % np;\n+\t\tf = i % nf;\n+\t\tif (rte_eth_representor_id_convert(edev,\n+\t\t\t&id,\n+\t\t\teth_da.type,\n+\t\t\teth_da.nb_mh_controllers == 0 ? -1 :\n+\t\t\t\t\teth_da.mh_controllers[c],\n+\t\t\teth_da.nb_ports == 0 ? -1 : eth_da.ports[p],\n+\t\t\teth_da.nb_representor_ports == 0 ? -1 :\n+\t\t\t\t\teth_da.representor_ports[f]) < 0)\n+\t\t\tcontinue;\n+\t\tif (data->representor_id == id)\n \t\t\treturn 0;\n+\t}\n \treturn -1; /* no match */\n }\n \n@@ -112,7 +132,7 @@ eth_dev_match(const struct rte_eth_dev *edev,\n \n \tret = rte_kvargs_process(kvlist,\n \t\t\teth_params_keys[RTE_ETH_PARAM_REPRESENTOR],\n-\t\t\teth_representor_cmp, edev->data);\n+\t\t\teth_representor_cmp, (void *)(uintptr_t)edev);\n \tif (ret != 0)\n \t\treturn -1;\n \t/* search for representor key */\ndiff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c\nindex 07c6debb58..da0cf1a920 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -5617,6 +5617,89 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)\n \treturn result;\n }\n \n+int\n+rte_eth_representor_id_convert(const struct rte_eth_dev *ethdev,\n+\t\t\t       uint16_t *id,\n+\t\t\t       enum rte_eth_representor_type type,\n+\t\t\t       int controller, int pf, int representor_port)\n+{\n+\tint ret, n, i, count;\n+\tstruct rte_eth_representor_info *info = NULL;\n+\tsize_t size;\n+\n+\tif (type == RTE_ETH_REPRESENTOR_NONE)\n+\t\treturn 0;\n+\tif (id == NULL)\n+\t\treturn -EINVAL;\n+\n+\t/* Get PMD representor range info. */\n+\tret = rte_eth_representor_info_get(ethdev->data->port_id, NULL);\n+\tif (ret < 0) {\n+\t\t/* Fallback to direct mapping for compatibility. */\n+\t\t*id = representor_port;\n+\t}\n+\tn = ret;\n+\tsize = sizeof(*info) + n * sizeof(info->ranges[0]);\n+\tinfo = calloc(1, size);\n+\tif (info == NULL)\n+\t\treturn -ENOMEM;\n+\tret = rte_eth_representor_info_get(ethdev->data->port_id, info);\n+\tif (ret < 0)\n+\t\tgoto out;\n+\n+\t/* Default controller and pf to caller. */\n+\tif (controller == -1)\n+\t\tcontroller = info->controller;\n+\tif (pf == -1)\n+\t\tpf = info->pf;\n+\n+\t/* Locate representor ID. */\n+\tfor (i = 0; i < n; ++i) {\n+\t\tif (info->ranges[i].type != type)\n+\t\t\tcontinue;\n+\t\t/* PMD hit: ignore controller if -1. */\n+\t\tif (info->ranges[i].controller != -1 &&\n+\t\t    info->ranges[i].controller != (uint16_t)controller)\n+\t\t\tcontinue;\n+\t\tcount = info->ranges[i].id_end - info->ranges[i].id_base + 1;\n+\t\tif (info->ranges[i].type == RTE_ETH_REPRESENTOR_PF) {\n+\t\t\t/* PF. */\n+\t\t\tif (pf >= info->ranges[i].pf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*id = info->ranges[i].id_base +\n+\t\t\t      (pf - info->ranges[i].pf);\n+\t\t\tgoto out;\n+\t\t}\n+\t\t/* VF or SF. */\n+\t\t/* PMD hit: ignore pf if -1. */\n+\t\tif (info->ranges[i].pf != -1 &&\n+\t\t    info->ranges[i].pf != (uint16_t)pf)\n+\t\t\tcontinue;\n+\t\tif (info->ranges[i].type == RTE_ETH_REPRESENTOR_VF) {\n+\t\t\t/* VF. */\n+\t\t\tif (representor_port >= info->ranges[i].vf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*id = info->ranges[i].id_base +\n+\t\t\t      (representor_port - info->ranges[i].vf);\n+\t\t\tgoto out;\n+\t\t} else if (info->ranges[i].type == RTE_ETH_REPRESENTOR_SF) {\n+\t\t\t/* SF. */\n+\t\t\tif (representor_port >= info->ranges[i].sf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*id = info->ranges[i].id_base +\n+\t\t\t      (representor_port - info->ranges[i].sf);\n+\t\t\tgoto out;\n+\t\t}\n+\t}\n+\t/* Not matching representor ID range. */\n+\tret = -ENOENT;\n+\n+out:\n+\tif (info != NULL)\n+\t\tfree(info);\n+\treturn ret;\n+}\n+\n static int\n eth_dev_handle_port_list(const char *cmd __rte_unused,\n \t\tconst char *params __rte_unused,\ndiff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map\nindex bb6f7436c2..2891f5734e 100644\n--- a/lib/librte_ethdev/version.map\n+++ b/lib/librte_ethdev/version.map\n@@ -268,6 +268,7 @@ INTERNAL {\n \trte_eth_hairpin_queue_peer_bind;\n \trte_eth_hairpin_queue_peer_unbind;\n \trte_eth_hairpin_queue_peer_update;\n+\trte_eth_representor_id_convert;\n \trte_eth_switch_domain_alloc;\n \trte_eth_switch_domain_free;\n };\n",
    "prefixes": [
        "v6",
        "8/9"
    ]
}