get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 86860,
    "url": "http://patches.dpdk.org/api/patches/86860/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1611040501-11666-7-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": "<1611040501-11666-7-git-send-email-xuemingl@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1611040501-11666-7-git-send-email-xuemingl@nvidia.com",
    "date": "2021-01-19T07:14:59",
    "name": "[v5,7/9] devarg: change representor ID to bitmap",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e89712bbe7337cb0f487474f7af3a907a92fc56a",
    "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/1611040501-11666-7-git-send-email-xuemingl@nvidia.com/mbox/",
    "series": [
        {
            "id": 14834,
            "url": "http://patches.dpdk.org/api/series/14834/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=14834",
            "date": "2021-01-19T07:14:53",
            "name": "[v5,1/9] ethdev: introduce representor type",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/14834/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/86860/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/86860/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 73CCFA0A03;\n\tTue, 19 Jan 2021 08:16:25 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2B0B5140D99;\n\tTue, 19 Jan 2021 08:15: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 08AC3140D60\n for <dev@dpdk.org>; Tue, 19 Jan 2021 08:15:46 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n xuemingl@nvidia.com) with SMTP; 19 Jan 2021 09:15:43 +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 10J7FfYg003537;\n Tue, 19 Jan 2021 09:15:43 +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 Ajit Khaparde <ajit.khaparde@broadcom.com>,\n Somnath Kotur <somnath.kotur@broadcom.com>,\n John Daley <johndale@cisco.com>, Hyong Youb Kim <hyonkim@cisco.com>,\n Beilei Xing <beilei.xing@intel.com>, Jeff Guo <jia.guo@intel.com>,\n Haiyue Wang <haiyue.wang@intel.com>, Matan Azrad <matan@nvidia.com>,\n Shahaf Shuler <shahafs@nvidia.com>, 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": "Tue, 19 Jan 2021 07:14:59 +0000",
        "Message-Id": "<1611040501-11666-7-git-send-email-xuemingl@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<1611040501-11666-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "References": [
            "<1611040501-11666-1-git-send-email-xuemingl@nvidia.com>",
            "<1608303356-13089-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v5 7/9] devarg: change representor ID to bitmap",
        "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 was compared with devarg.\nSince ethdev representor port didn't contain controller index and PF\nindex information, callback returned representor from other PF or\ncontroller.\n\nThis patch changes representor ID to bitmap so that the ethdev\nrepresentor comparer callback returns correct ethdev by comparing full\nrepresentor information including: controller index, PF index,\nrepresentor type, SF or VF index.\n\nRepresentor ID bitmap definition:\n xxxx xxxx xxxx xxxx\n |||| |LLL LLLL LLLL vf/sf id\n |||| L 1:sf, 0:vf\n ||LL pf id\n LL controller(host) id\n\nThis approach keeps binary compatibility with all drivers, VF\nrepresentor id matches with simple id for non-bonding and non-multi-host\nconfigurations.\n\nIn the future, the representor ID field and each section should extend\nto bigger width to support more devices.\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>\nAcked-by: Thomas Monjalon <thomas@monjalon.net>\n---\n drivers/net/bnxt/bnxt_reps.c             |  3 +-\n drivers/net/enic/enic_vf_representor.c   |  3 +-\n drivers/net/i40e/i40e_vf_representor.c   |  3 +-\n drivers/net/ixgbe/ixgbe_vf_representor.c |  3 +-\n drivers/net/mlx5/linux/mlx5_os.c         |  4 +-\n lib/librte_ethdev/rte_class_eth.c        | 38 +++++++++++++----\n lib/librte_ethdev/rte_ethdev.c           | 26 ++++++++++++\n lib/librte_ethdev/rte_ethdev_driver.h    | 53 ++++++++++++++++++++++++\n lib/librte_ethdev/version.map            |  2 +\n 9 files changed, 122 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c\nindex f7bbf77d3f..34febc2d1e 100644\n--- a/drivers/net/bnxt/bnxt_reps.c\n+++ b/drivers/net/bnxt/bnxt_reps.c\n@@ -186,7 +186,8 @@ int bnxt_representor_init(struct rte_eth_dev *eth_dev, void *params)\n \n \teth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |\n \t\t\t\t\tRTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;\n-\teth_dev->data->representor_id = rep_params->vf_id;\n+\teth_dev->data->representor_id = rte_eth_representor_id_encode(\n+\t\t0, 0, RTE_ETH_REPRESENTOR_VF, rep_params->vf_id);\n \n \trte_eth_random_addr(vf_rep_bp->dflt_mac_addr);\n \tmemcpy(vf_rep_bp->mac_addr, vf_rep_bp->dflt_mac_addr,\ndiff --git a/drivers/net/enic/enic_vf_representor.c b/drivers/net/enic/enic_vf_representor.c\nindex c2c03c0281..632317af15 100644\n--- a/drivers/net/enic/enic_vf_representor.c\n+++ b/drivers/net/enic/enic_vf_representor.c\n@@ -674,7 +674,8 @@ int enic_vf_representor_init(struct rte_eth_dev *eth_dev, void *init_params)\n \teth_dev->dev_ops = &enic_vf_representor_dev_ops;\n \teth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |\n \t\t\t\t\tRTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;\n-\teth_dev->data->representor_id = vf->vf_id;\n+\teth_dev->data->representor_id = rte_eth_representor_id_encode(\n+\t\t0, 0, RTE_ETH_REPRESENTOR_VF, vf->vf_id);\n \teth_dev->data->mac_addrs = rte_zmalloc(\"enic_mac_addr_vf\",\n \t\tsizeof(struct rte_ether_addr) *\n \t\tENIC_UNICAST_PERFECT_FILTERS, 0);\ndiff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c\nindex 9e40406a3d..d90d0fdb9d 100644\n--- a/drivers/net/i40e/i40e_vf_representor.c\n+++ b/drivers/net/i40e/i40e_vf_representor.c\n@@ -510,7 +510,8 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)\n \n \tethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR |\n \t\t\t\t\tRTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;\n-\tethdev->data->representor_id = representor->vf_id;\n+\tethdev->data->representor_id = rte_eth_representor_id_encode(\n+\t\t\t0, 0, RTE_ETH_REPRESENTOR_VF, representor->vf_id);\n \n \t/* Setting the number queues allocated to the VF */\n \tethdev->data->nb_rx_queues = vf->vsi->nb_qps;\ndiff --git a/drivers/net/ixgbe/ixgbe_vf_representor.c b/drivers/net/ixgbe/ixgbe_vf_representor.c\nindex 8185f0d3bb..e15b794761 100644\n--- a/drivers/net/ixgbe/ixgbe_vf_representor.c\n+++ b/drivers/net/ixgbe/ixgbe_vf_representor.c\n@@ -196,7 +196,8 @@ ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)\n \t\treturn -ENODEV;\n \n \tethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;\n-\tethdev->data->representor_id = representor->vf_id;\n+\tethdev->data->representor_id = rte_eth_representor_id_encode(\n+\t\t\t0, 0, RTE_ETH_REPRESENTOR_VF, representor->vf_id);\n \n \t/* Set representor device ops */\n \tethdev->dev_ops = &ixgbe_vf_representor_dev_ops;\ndiff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex caead107b0..4d7940bcca 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -1025,7 +1025,9 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n #endif\n \t/* representor_id field keeps the unmodified VF index. */\n \tpriv->representor_id = switch_info->representor ?\n-\t\t\t       switch_info->port_name : -1;\n+\t\trte_eth_representor_id_encode(0, 0, RTE_ETH_REPRESENTOR_VF,\n+\t\t\t\t\t      switch_info->port_name) :\n+\t\t-1;\n \t/*\n \t * Look for sibling devices in order to reuse their switch domain\n \t * if any, otherwise allocate one.\ndiff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c\nindex efe6149df5..994db96960 100644\n--- a/lib/librte_ethdev/rte_class_eth.c\n+++ b/lib/librte_ethdev/rte_class_eth.c\n@@ -66,8 +66,8 @@ eth_representor_cmp(const char *key __rte_unused,\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+\tstruct rte_eth_devargs eth_da;\n+\tuint16_t index, 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 +76,39 @@ 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+\t/* Set default values. */\n+\tif (eth_da.nb_mh_controllers == 0) {\n+\t\teth_da.nb_mh_controllers = 1;\n+\t\teth_da.mh_controllers[0] = 0;\n+\t}\n+\tif (eth_da.nb_ports == 0) {\n+\t\teth_da.nb_ports = 1;\n+\t\teth_da.ports[0] = 0;\n+\t}\n+\tif (eth_da.nb_representor_ports == 0) {\n+\t\teth_da.nb_representor_ports = 1;\n+\t\teth_da.representor_ports[0] = 0;\n+\t}\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-\t\t\treturn 0;\n+\tfor (c = 0; c < eth_da.nb_mh_controllers; ++c) {\n+\t\tfor (p = 0; p < eth_da.nb_ports; ++p) {\n+\t\t\tfor (f = 0; f < eth_da.nb_representor_ports; ++f) {\n+\t\t\t\tindex = rte_eth_representor_id_encode(\n+\t\t\t\t\teth_da.mh_controllers[c],\n+\t\t\t\t\teth_da.ports[p],\n+\t\t\t\t\teth_da.type,\n+\t\t\t\t\teth_da.representor_ports[f]);\n+\t\t\t\tif (data->representor_id == index)\n+\t\t\t\t\treturn 0;\n+\t\t\t}\n+\t\t}\n+\t}\n \treturn -1; /* no match */\n }\n \ndiff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c\nindex 91b3263338..2cac0ccfbd 100644\n--- a/lib/librte_ethdev/rte_ethdev.c\n+++ b/lib/librte_ethdev/rte_ethdev.c\n@@ -5575,6 +5575,32 @@ rte_eth_devargs_parse(const char *dargs, struct rte_eth_devargs *eth_da)\n \treturn result;\n }\n \n+uint16_t\n+rte_eth_representor_id_encode(uint16_t controller, uint16_t pf,\n+\t\t\t      enum rte_eth_representor_type type,\n+\t\t\t      uint16_t representor_port)\n+{\n+\treturn (((controller & 3) << 14) |\n+\t\t((pf & 3) << 12) |\n+\t\t(!!(type == RTE_ETH_REPRESENTOR_SF) << 11) |\n+\t\t(representor_port & 0x7ff));\n+}\n+\n+uint16_t\n+rte_eth_representor_id_parse(const uint16_t representor_id,\n+\t\t\t     uint16_t *controller, uint16_t *pf,\n+\t\t\t     enum rte_eth_representor_type *type)\n+{\n+\tif (controller)\n+\t\t*controller = (representor_id >> 14) & 3;\n+\tif (pf)\n+\t\t*pf = (representor_id >> 12) & 3;\n+\tif (type)\n+\t\t*type = ((representor_id >> 11) & 1) ?\n+\t\t\tRTE_ETH_REPRESENTOR_SF : RTE_ETH_REPRESENTOR_VF;\n+\treturn representor_id & 0x7ff;\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/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h\nindex b01f118965..57253c8f90 100644\n--- a/lib/librte_ethdev/rte_ethdev_driver.h\n+++ b/lib/librte_ethdev/rte_ethdev_driver.h\n@@ -1218,6 +1218,59 @@ struct rte_eth_devargs {\n \tenum rte_eth_representor_type type; /* type of representor */\n };\n \n+#define RTE_NO_REPRESENTOR_ID UINT16_MAX /**< No representor ID. */\n+\n+/**\n+ * PMD helper function to encode representor ID\n+ *\n+ * The compact format is used for device iterator that comparing\n+ * ethdev representor ID with target devargs.\n+ *\n+ * xxxx xxxx xxxx xxxx\n+ * |||| |LLL LLLL LLLL vf/sf id\n+ * |||| L 1:sf, 0:vf\n+ * ||LL pf id\n+ * LL controller(host) id\n+ *\n+ * @param controller\n+ *  Controller ID.\n+ * @param pf\n+ *  PF port ID.\n+ * @param type\n+ *  Representor type.\n+ * @param representor_port\n+ *  Representor port ID.\n+ *\n+ * @return\n+ *   Encoded representor ID.\n+ */\n+__rte_internal\n+uint16_t\n+rte_eth_representor_id_encode(uint16_t controller, uint16_t pf,\n+\t\t\t      enum rte_eth_representor_type type,\n+\t\t\t      uint16_t representor_port);\n+\n+/**\n+ * PMD helper function to parse representor ID\n+ *\n+ * @param representor_id\n+ *  Representor ID.\n+ * @param controller\n+ *  Parsed controller ID.\n+ * @param pf\n+ *  Parsed PF port ID.\n+ * @param type\n+ *  Parsed representor type.\n+ *\n+ * @return\n+ *   Parsed representor port ID.\n+ */\n+__rte_internal\n+uint16_t\n+rte_eth_representor_id_parse(const uint16_t representor_id,\n+\t\t\t     uint16_t *controller, uint16_t *pf,\n+\t\t\t     enum rte_eth_representor_type *type);\n+\n /**\n  * PMD helper function to parse ethdev arguments\n  *\ndiff --git a/lib/librte_ethdev/version.map b/lib/librte_ethdev/version.map\nindex d3f5410806..44edaed507 100644\n--- a/lib/librte_ethdev/version.map\n+++ b/lib/librte_ethdev/version.map\n@@ -257,6 +257,8 @@ INTERNAL {\n \trte_eth_dev_release_port;\n \trte_eth_dev_internal_reset;\n \trte_eth_devargs_parse;\n+\trte_eth_representor_id_encode;\n+\trte_eth_representor_id_parse;\n \trte_eth_dma_zone_free;\n \trte_eth_dma_zone_reserve;\n \trte_eth_hairpin_queue_peer_bind;\n",
    "prefixes": [
        "v5",
        "7/9"
    ]
}