get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 86798,
    "url": "https://patches.dpdk.org/api/patches/86798/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1610969353-31938-3-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": "<1610969353-31938-3-git-send-email-xuemingl@nvidia.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1610969353-31938-3-git-send-email-xuemingl@nvidia.com",
    "date": "2021-01-18T11:29:06",
    "name": "[v3,2/9] net/mlx5: support representor of sub function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "6a74c5beee9a4249946740095fbc8736cad5e4f6",
    "submitter": {
        "id": 1904,
        "url": "https://patches.dpdk.org/api/people/1904/?format=api",
        "name": "Xueming Li",
        "email": "xuemingl@nvidia.com"
    },
    "delegate": {
        "id": 3268,
        "url": "https://patches.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/1610969353-31938-3-git-send-email-xuemingl@nvidia.com/mbox/",
    "series": [
        {
            "id": 14810,
            "url": "https://patches.dpdk.org/api/series/14810/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=14810",
            "date": "2021-01-18T11:29:04",
            "name": "net/mlx5: support SubFunction representor",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/14810/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/86798/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/86798/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 BB009A0A03;\n\tMon, 18 Jan 2021 12:30:05 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7A33E140E09;\n\tMon, 18 Jan 2021 12:29:29 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by mails.dpdk.org (Postfix) with ESMTP id 5BE9E140DE3\n for <dev@dpdk.org>; Mon, 18 Jan 2021 12:29:24 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n xuemingl@nvidia.com) with SMTP; 18 Jan 2021 13:29:15 +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 10IBTFec026901;\n Mon, 18 Jan 2021 13:29:15 +0200"
        ],
        "From": "Xueming Li <xuemingl@nvidia.com>",
        "To": "Viacheslav Ovsiienko <viacheslavo@nvidia.com>",
        "Cc": "dev@dpdk.org, Matan Azrad <matan@nvidia.com>,\n Shahaf Shuler <shahafs@nvidia.com>,\n Thomas Monjalon <thomas@monjalon.net>, xuemingl@nvidia.com,\n Asaf Penso <asafp@nvidia.com>",
        "Date": "Mon, 18 Jan 2021 11:29:06 +0000",
        "Message-Id": "<1610969353-31938-3-git-send-email-xuemingl@nvidia.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": [
            "<1610969353-31938-1-git-send-email-xuemingl@nvidia.com>",
            "<1608304614-13908-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "References": [
            "<1610969353-31938-1-git-send-email-xuemingl@nvidia.com>",
            "<1608304614-13908-2-git-send-email-xuemingl@nvidia.com>"
        ],
        "Subject": "[dpdk-dev] [PATCH v3 2/9] net/mlx5: support representor of sub\n function",
        "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": "This patch adds support for SF representor. Similar to VF representor,\nswitch port name of SF representor in phys_port_name sysfs key is\n\"pf<x>sf<y>\".\n\nDevice representor argumnt is \"representors=sf[list]\", list member could\nbe mix of instance and range. Example:\n  representors=sf[0,2,4,8-12,-1]\n\nTo probe VF representor and SF representor, need to separate into 2\ndevices:\n  -a <BDF>,representor=vf[list] -a <BDF>,representor=sf[list]\n\nSigned-off-by: Xueming Li <xuemingl@nvidia.com>\nAcked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>\n---\n doc/guides/nics/mlx5.rst                |  58 +++++++++--\n drivers/net/mlx5/linux/mlx5_ethdev_os.c |   2 +\n drivers/net/mlx5/linux/mlx5_os.c        | 123 ++++++++++++++++++++----\n drivers/net/mlx5/mlx5_ethdev.c          |   2 +\n 4 files changed, 154 insertions(+), 31 deletions(-)",
    "diff": "diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst\nindex db0c8b6c20..c7829007a4 100644\n--- a/doc/guides/nics/mlx5.rst\n+++ b/doc/guides/nics/mlx5.rst\n@@ -871,14 +871,18 @@ Driver options\n - ``representor`` parameter [list]\n \n   This parameter can be used to instantiate DPDK Ethernet devices from\n-  existing port (or VF) representors configured on the device.\n+  existing port (PF, VF or SF) representors configured on the device.\n \n   It is a standard parameter whose format is described in\n   :ref:`ethernet_device_standard_device_arguments`.\n \n-  For instance, to probe port representors 0 through 2::\n+  For instance, to probe VF port representors 0 through 2::\n \n-    representor=[0-2]\n+    representor=vf[0-2]\n+\n+  To probe SF port representors 0 through 2::\n+\n+    representor=sf[0-2]\n \n - ``max_dump_files_num`` parameter [int]\n \n@@ -1287,15 +1291,15 @@ Quick Start Guide on OFED/EN\n Enable switchdev mode\n ---------------------\n \n-Switchdev mode is a mode in E-Switch, that binds between representor and VF.\n-Representor is a port in DPDK that is connected to a VF in such a way\n-that assuming there are no offload flows, each packet that is sent from the VF\n-will be received by the corresponding representor. While each packet that is\n-sent to a representor will be received by the VF.\n+Switchdev mode is a mode in E-Switch, that binds between representor and VF or SF.\n+Representor is a port in DPDK that is connected to a VF or SF in such a way\n+that assuming there are no offload flows, each packet that is sent from the VF or SF\n+will be received by the corresponding representor. While each packet that is or SF\n+sent to a representor will be received by the VF or SF.\n This is very useful in case of SRIOV mode, where the first packet that is sent\n-by the VF will be received by the DPDK application which will decide if this\n+by the VF or SF will be received by the DPDK application which will decide if this\n flow should be offloaded to the E-Switch. After offloading the flow packet\n-that the VF that are matching the flow will not be received any more by\n+that the VF or SF that are matching the flow will not be received any more by\n the DPDK application.\n \n 1. Enable SRIOV mode::\n@@ -1322,6 +1326,40 @@ the DPDK application.\n \n         echo switchdev > /sys/class/net/<net device>/compat/devlink/mode\n \n+SubFunction representor support\n+-------------------------------\n+SubFunction is a portion of the PCI device, a SF netdev has its own\n+dedicated queues(txq, rxq). A SF netdev supports E-Switch representation\n+offload similar to existing PF and VF representors. A SF shares PCI\n+level resources with other SFs and/or with its parent PCI function.\n+\n+1. Configure SF feature::\n+\n+        mlxconfig -d <mst device> set PF_BAR2_SIZE=<0/1/2/3> PF_BAR2_ENABLE=1\n+\n+        Value of PF_BAR2_SIZE:\n+\n+            0: 8 SFs\n+            1: 16 SFs\n+            2: 32 SFs\n+            3: 64 SFs\n+\n+2. Reset the FW::\n+\n+        mlxfwreset -d <mst device> reset\n+\n+3. Enable switchdev mode::\n+\n+        echo switchdev > /sys/class/net/<net device>/compat/devlink/mode\n+\n+4. Create SF::\n+\n+        mlnx-sf -d <PCI_BDF> -a create\n+\n+5. Probe SF representor::\n+\n+        testpmd> port attach <PCI_BDF>,representor=sf0,dv_flow_en=1\n+\n Performance tuning\n ------------------\n \ndiff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c\nindex 1b37970c21..ac311de46d 100644\n--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c\n@@ -1010,6 +1010,8 @@ mlx5_sysfs_check_switch_info(bool device_dir,\n \tcase MLX5_PHYS_PORT_NAME_TYPE_PFHPF:\n \t\t/* Fallthrough */\n \tcase MLX5_PHYS_PORT_NAME_TYPE_PFVF:\n+\t\t/* Fallthrough */\n+\tcase MLX5_PHYS_PORT_NAME_TYPE_PFSF:\n \t\t/* New representors naming schema. */\n \t\tswitch_info->representor = 1;\n \t\tbreak;\ndiff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c\nindex 4d7940bcca..b2776c080a 100644\n--- a/drivers/net/mlx5/linux/mlx5_os.c\n+++ b/drivers/net/mlx5/linux/mlx5_os.c\n@@ -654,6 +654,8 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)\n  *   Verbs device parameters (name, port, switch_info) to spawn.\n  * @param config\n  *   Device configuration parameters.\n+ * @param config\n+ *   Device arguments.\n  *\n  * @return\n  *   A valid Ethernet device object on success, NULL otherwise and rte_errno\n@@ -665,7 +667,8 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)\n static struct rte_eth_dev *\n mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t       struct mlx5_dev_spawn_data *spawn,\n-\t       struct mlx5_dev_config *config)\n+\t       struct mlx5_dev_config *config,\n+\t       struct rte_eth_devargs *eth_da)\n {\n \tconst struct mlx5_switch_info *switch_info = &spawn->info;\n \tstruct mlx5_dev_ctx_shared *sh = NULL;\n@@ -696,34 +699,82 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \n \t/* Determine if this port representor is supposed to be spawned. */\n \tif (switch_info->representor && dpdk_dev->devargs) {\n-\t\tstruct rte_eth_devargs eth_da;\n-\n-\t\terr = rte_eth_devargs_parse(dpdk_dev->devargs->args, &eth_da);\n-\t\tif (err) {\n-\t\t\trte_errno = -err;\n-\t\t\tDRV_LOG(ERR, \"failed to process device arguments: %s\",\n-\t\t\t\tstrerror(rte_errno));\n-\t\t\treturn NULL;\n-\t\t}\n-\t\tif (eth_da.type != RTE_ETH_REPRESENTOR_NONE) {\n-\t\t\t/* Representor not specified. */\n+\t\tswitch (eth_da->type) {\n+\t\tcase RTE_ETH_REPRESENTOR_SF:\n+\t\t\tif (switch_info->name_type !=\n+\t\t\t\t\tMLX5_PHYS_PORT_NAME_TYPE_PFSF) {\n+\t\t\t\trte_errno = EBUSY;\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\tbreak;\n+\t\tcase RTE_ETH_REPRESENTOR_VF:\n+\t\t\t/* Allows HPF representor index -1 as exception. */\n+\t\t\tif (!(spawn->info.port_name == -1 &&\n+\t\t\t      switch_info->name_type ==\n+\t\t\t\t\tMLX5_PHYS_PORT_NAME_TYPE_PFHPF) &&\n+\t\t\t    switch_info->name_type !=\n+\t\t\t\t\tMLX5_PHYS_PORT_NAME_TYPE_PFVF) {\n+\t\t\t\trte_errno = EBUSY;\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\tbreak;\n+\t\tcase RTE_ETH_REPRESENTOR_NONE:\n \t\t\trte_errno = EBUSY;\n \t\t\treturn NULL;\n-\t\t}\n-\t\tif (eth_da.type != RTE_ETH_REPRESENTOR_VF) {\n+\t\t\tbreak;\n+\t\tdefault:\n \t\t\trte_errno = ENOTSUP;\n \t\t\tDRV_LOG(ERR, \"unsupported representor type: %s\",\n \t\t\t\tdpdk_dev->devargs->args);\n \t\t\treturn NULL;\n \t\t}\n-\t\tfor (i = 0; i < eth_da.nb_representor_ports; ++i)\n-\t\t\tif (eth_da.representor_ports[i] ==\n+\t\t/* Check controller ID: */\n+\t\tfor (i = 0; i < eth_da->nb_mh_controllers; ++i)\n+\t\t\tif (eth_da->mh_controllers[i] ==\n+\t\t\t    (uint16_t)switch_info->ctrl_num)\n+\t\t\t\tbreak;\n+\t\tif (eth_da->nb_mh_controllers &&\n+\t\t    i == eth_da->nb_mh_controllers) {\n+\t\t\trte_errno = EBUSY;\n+\t\t\treturn NULL;\n+\t\t}\n+\t\t/* Check SF/VF ID: */\n+\t\tfor (i = 0; i < eth_da->nb_representor_ports; ++i)\n+\t\t\tif (eth_da->representor_ports[i] ==\n \t\t\t    (uint16_t)switch_info->port_name)\n \t\t\t\tbreak;\n-\t\tif (i == eth_da.nb_representor_ports) {\n+\t\tif (eth_da->type != RTE_ETH_REPRESENTOR_PF &&\n+\t\t    i == eth_da->nb_representor_ports) {\n \t\t\trte_errno = EBUSY;\n \t\t\treturn NULL;\n \t\t}\n+\t\t/* Check PF ID. Check after repr port to avoid warning flood. */\n+\t\tif (spawn->pf_bond >= 0) {\n+\t\t\tfor (i = 0; i < eth_da->nb_ports; ++i)\n+\t\t\t\tif (eth_da->ports[i] ==\n+\t\t\t\t    (uint16_t)switch_info->pf_num)\n+\t\t\t\t\tbreak;\n+\t\t\tif (eth_da->nb_ports && i == eth_da->nb_ports) {\n+\t\t\t\t/* For backward compatibility, bonding\n+\t\t\t\t * representor syntax supported with limitation,\n+\t\t\t\t * device iterator won't find it:\n+\t\t\t\t *    <PF1_BDF>,representor=#\n+\t\t\t\t */\n+\t\t\t\tif (switch_info->pf_num > 0 &&\n+\t\t\t\t    eth_da->ports[0] == 0) {\n+\t\t\t\t\tDRV_LOG(WARNING, \"Representor on Bonding PF should use pf#vf# format: %s\",\n+\t\t\t\t\t\tdpdk_dev->devargs->args);\n+\t\t\t\t} else {\n+\t\t\t\t\trte_errno = EBUSY;\n+\t\t\t\t\treturn NULL;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t} else if (eth_da->nb_ports > 1 || eth_da->ports[0]) {\n+\t\t\trte_errno = EINVAL;\n+\t\t\tDRV_LOG(ERR, \"PF id not supported by non-bond device: %s\",\n+\t\t\t\tdpdk_dev->devargs->args);\n+\t\t\treturn NULL;\n+\t\t}\n \t}\n \t/* Build device name. */\n \tif (spawn->pf_bond <  0) {\n@@ -731,8 +782,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t\tif (!switch_info->representor)\n \t\t\tstrlcpy(name, dpdk_dev->name, sizeof(name));\n \t\telse\n-\t\t\tsnprintf(name, sizeof(name), \"%s_representor_%u\",\n-\t\t\t\t dpdk_dev->name, switch_info->port_name);\n+\t\t\tsnprintf(name, sizeof(name), \"%s_representor_%s%u\",\n+\t\t\t\t dpdk_dev->name,\n+\t\t\t\t switch_info->name_type ==\n+\t\t\t\t MLX5_PHYS_PORT_NAME_TYPE_PFSF ? \"sf\" : \"vf\",\n+\t\t\t\t switch_info->port_name);\n \t} else {\n \t\t/* Bonding device. */\n \t\tif (!switch_info->representor)\n@@ -740,9 +794,11 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,\n \t\t\t\t dpdk_dev->name,\n \t\t\t\t mlx5_os_get_dev_device_name(spawn->phys_dev));\n \t\telse\n-\t\t\tsnprintf(name, sizeof(name), \"%s_%s_representor_%u\",\n+\t\t\tsnprintf(name, sizeof(name), \"%s_%s_representor_%s%u\",\n \t\t\t\t dpdk_dev->name,\n \t\t\t\t mlx5_os_get_dev_device_name(spawn->phys_dev),\n+\t\t\t\t switch_info->name_type ==\n+\t\t\t\t MLX5_PHYS_PORT_NAME_TYPE_PFSF ? \"sf\" : \"vf\",\n \t\t\t\t switch_info->port_name);\n \t}\n \t/* check if the device is already spawned */\n@@ -1790,6 +1846,7 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \tstruct mlx5_dev_spawn_data *list = NULL;\n \tstruct mlx5_dev_config dev_config;\n \tunsigned int dev_config_vf;\n+\tstruct rte_eth_devargs eth_da = { .type = RTE_ETH_REPRESENTOR_NONE };\n \tint ret;\n \n \tif (rte_eal_process_type() == RTE_PROC_PRIMARY)\n@@ -1800,6 +1857,27 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\tstrerror(rte_errno));\n \t\treturn -rte_errno;\n \t}\n+\tif (pci_dev->device.devargs) {\n+\t\t/* Parse representor information from device argument. */\n+\t\tif (pci_dev->device.devargs->cls_str)\n+\t\t\tret = rte_eth_devargs_parse(\n+\t\t\t\tpci_dev->device.devargs->cls_str, &eth_da);\n+\t\tif (ret) {\n+\t\t\tDRV_LOG(ERR, \"failed to parse device arguments: %s\",\n+\t\t\t\tpci_dev->device.devargs->cls_str);\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t\tif (eth_da.type == RTE_ETH_REPRESENTOR_NONE) {\n+\t\t\t/* Support legacy device argument */\n+\t\t\tret = rte_eth_devargs_parse(\n+\t\t\t\tpci_dev->device.devargs->args, &eth_da);\n+\t\t\tif (ret) {\n+\t\t\t\tDRV_LOG(ERR, \"failed to parse device arguments: %s\",\n+\t\t\t\t\tpci_dev->device.devargs->args);\n+\t\t\t\treturn -rte_errno;\n+\t\t\t}\n+\t\t}\n+\t}\n \terrno = 0;\n \tibv_list = mlx5_glue->get_device_list(&ret);\n \tif (!ibv_list) {\n@@ -1972,6 +2050,8 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\t\t\tcase MLX5_PHYS_PORT_NAME_TYPE_PFHPF:\n \t\t\t\t\t/* Fallthrough */\n \t\t\t\tcase MLX5_PHYS_PORT_NAME_TYPE_PFVF:\n+\t\t\t\t\t/* Fallthrough */\n+\t\t\t\tcase MLX5_PHYS_PORT_NAME_TYPE_PFSF:\n \t\t\t\t\tif (list[ns].info.pf_num == bd)\n \t\t\t\t\t\tns++;\n \t\t\t\t\tbreak;\n@@ -2149,7 +2229,8 @@ mlx5_os_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \t\tdev_config.log_hp_size = MLX5_ARG_UNSET;\n \t\tlist[i].eth_dev = mlx5_dev_spawn(&pci_dev->device,\n \t\t\t\t\t\t &list[i],\n-\t\t\t\t\t\t &dev_config);\n+\t\t\t\t\t\t &dev_config,\n+\t\t\t\t\t\t &eth_da);\n \t\tif (!list[i].eth_dev) {\n \t\t\tif (rte_errno != EBUSY && rte_errno != EEXIST)\n \t\t\t\tbreak;\ndiff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c\nindex 45ee7e4488..ad6aacc329 100644\n--- a/drivers/net/mlx5/mlx5_ethdev.c\n+++ b/drivers/net/mlx5/mlx5_ethdev.c\n@@ -374,6 +374,8 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)\n \t\t\tbreak;\n \t\t}\n \t}\n+\tif (priv->master)\n+\t\tinfo->dev_capa = RTE_ETH_DEV_CAPA_REPRESENTOR_SF;\n \treturn 0;\n }\n \n",
    "prefixes": [
        "v3",
        "2/9"
    ]
}