get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 88960,
    "url": "http://patches.dpdk.org/api/patches/88960/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1615468416-10115-10-git-send-email-xuemingl@nvidia.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": "<1615468416-10115-10-git-send-email-xuemingl@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1615468416-10115-10-git-send-email-xuemingl@nvidia.com",
    "date": "2021-03-11T13:13:32",
    "name": "[v9,09/10] ethdev: representor iterator compare complete info",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "7537a3fec07bb6398205a177c0c2c52110038d9c",
    "submitter": {
        "id": 1904,
        "url": "http://patches.dpdk.org/api/people/1904/?format=api",
        "name": "Xueming Li",
        "email": "xuemingl@nvidia.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1615468416-10115-10-git-send-email-xuemingl@nvidia.com/mbox/",
    "series": [
        {
            "id": 15613,
            "url": "http://patches.dpdk.org/api/series/15613/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=15613",
            "date": "2021-03-11T13:13:23",
            "name": "ethdev: support SubFunction representor",
            "version": 9,
            "mbox": "http://patches.dpdk.org/series/15613/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/88960/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/88960/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 9F8F6A0575;\n\tThu, 11 Mar 2021 14:15:06 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id D0A9722A511;\n\tThu, 11 Mar 2021 14:14:34 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id 4421322A511\n for <dev@dpdk.org>; Thu, 11 Mar 2021 14:14:33 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n xuemingl@nvidia.com) with SMTP; 11 Mar 2021 15:14:31 +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 12BDDkZB023953;\n Thu, 11 Mar 2021 15:14:30 +0200"
        ],
        "From": "Xueming Li <xuemingl@nvidia.com>",
        "To": "Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,\n Ferruh Yigit <ferruh.yigit@intel.com>",
        "Cc": "dev@dpdk.org, Viacheslav Ovsiienko <viacheslavo@nvidia.com>,\n xuemingl@nvidia.com, Asaf Penso <asafp@nvidia.com>,\n Thomas Monjalon <thomas@monjalon.net>, Ray Kinsella <mdr@ashroe.eu>,\n Neil Horman <nhorman@tuxdriver.com>",
        "Date": "Thu, 11 Mar 2021 13:13:32 +0000",
        "Message-Id": "<1615468416-10115-10-git-send-email-xuemingl@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<1615468416-10115-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "References": [
            "<1615468416-10115-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v9 09/10] 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 get representor ID from controller, pf and\nvf/sf index. Representor comparer callback get representor ID then\ncompare with device representor ID.\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\nReviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>\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    | 93 +++++++++++++++++++++++++++++++\n lib/librte_ethdev/version.map     |  1 +\n 4 files changed, 155 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/lib/librte_ethdev/ethdev_driver.h b/lib/librte_ethdev/ethdev_driver.h\nindex 067be38f33..cdd4b4376c 100644\n--- a/lib/librte_ethdev/ethdev_driver.h\n+++ b/lib/librte_ethdev/ethdev_driver.h\n@@ -1264,6 +1264,38 @@ struct rte_eth_devargs {\n \tenum rte_eth_representor_type type; /* type of representor */\n };\n \n+/**\n+ * PMD helper function to get representor ID from location detail.\n+ *\n+ * Get representor ID from controller, pf and (sf or vf).\n+ * The mapping is retrieved from rte_eth_representor_info_get().\n+ *\n+ * For backward compatibility, if no representor info, direct\n+ * map legacy VF (no controller and pf).\n+ *\n+ * @param ethdev\n+ *  Handle of ethdev port.\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+ *  VF or SF representor port number, -1 if unspecified.\n+ * @param repr_id\n+ *  Pointer to output representor ID.\n+ *\n+ * @return\n+ *  Negative errno value on error, 0 on success.\n+ */\n+__rte_internal\n+int\n+rte_eth_representor_id_get(const struct rte_eth_dev *ethdev,\n+\t\t\t   enum rte_eth_representor_type type,\n+\t\t\t   int controller, int pf, int representor_port,\n+\t\t\t   uint16_t *repr_id);\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..1fe5fa1f36 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_get(edev,\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],\n+\t\t\t&id) < 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 3d4ec8ad5c..3059aa55b3 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -5609,6 +5609,99 @@ 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_get(const struct rte_eth_dev *ethdev,\n+\t\t\t   enum rte_eth_representor_type type,\n+\t\t\t   int controller, int pf, int representor_port,\n+\t\t\t   uint16_t *repr_id)\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 (repr_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 == -ENOTSUP && type == RTE_ETH_REPRESENTOR_VF &&\n+\t    controller == -1 && pf == -1) {\n+\t\t/* Direct mapping for legacy VF representor. */\n+\t\t*repr_id = representor_port;\n+\t\treturn 0;\n+\t} else if (ret < 0) {\n+\t\treturn ret;\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+\tret = -ENOENT;\n+\tfor (i = 0; i < n; ++i) {\n+\t\tif (info->ranges[i].type != type)\n+\t\t\tcontinue;\n+\t\tif (info->ranges[i].controller != controller)\n+\t\t\tcontinue;\n+\t\tif (info->ranges[i].id_end < info->ranges[i].id_base) {\n+\t\t\tRTE_LOG(WARNING, EAL, \"Port %hu invalid representor ID Range %u - %u, entry %d\\n\",\n+\t\t\t\tethdev->data->port_id, info->ranges[i].id_base,\n+\t\t\t\tinfo->ranges[i].id_end, i);\n+\t\t\tcontinue;\n+\n+\t\t}\n+\t\tcount = info->ranges[i].id_end - info->ranges[i].id_base + 1;\n+\t\tswitch (info->ranges[i].type) {\n+\t\tcase RTE_ETH_REPRESENTOR_PF:\n+\t\t\tif (pf < info->ranges[i].pf ||\n+\t\t\t    pf >= info->ranges[i].pf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*repr_id = info->ranges[i].id_base +\n+\t\t\t\t   (pf - info->ranges[i].pf);\n+\t\t\tret = 0;\n+\t\t\tgoto out;\n+\t\tcase RTE_ETH_REPRESENTOR_VF:\n+\t\t\tif (info->ranges[i].pf != pf)\n+\t\t\t\tcontinue;\n+\t\t\tif (representor_port < info->ranges[i].vf ||\n+\t\t\t    representor_port >= info->ranges[i].vf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*repr_id = info->ranges[i].id_base +\n+\t\t\t\t   (representor_port - info->ranges[i].vf);\n+\t\t\tret = 0;\n+\t\t\tgoto out;\n+\t\tcase RTE_ETH_REPRESENTOR_SF:\n+\t\t\tif (info->ranges[i].pf != pf)\n+\t\t\t\tcontinue;\n+\t\t\tif (representor_port < info->ranges[i].sf ||\n+\t\t\t    representor_port >= info->ranges[i].sf + count)\n+\t\t\t\tcontinue;\n+\t\t\t*repr_id = info->ranges[i].id_base +\n+\t\t\t      (representor_port - info->ranges[i].sf);\n+\t\t\tret = 0;\n+\t\t\tgoto out;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+out:\n+\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..93ad388e96 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_get;\n \trte_eth_switch_domain_alloc;\n \trte_eth_switch_domain_free;\n };\n",
    "prefixes": [
        "v9",
        "09/10"
    ]
}