get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 52725,
    "url": "http://patches.dpdk.org/api/patches/52725/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1555084107-24692-1-git-send-email-viacheslavo@mellanox.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": "<1555084107-24692-1-git-send-email-viacheslavo@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1555084107-24692-1-git-send-email-viacheslavo@mellanox.com",
    "date": "2019-04-12T15:48:27",
    "name": "[1/1] net/mlx5: add support for PF representor",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ccc62e8595113164fbe89c19bfeb30b5a65bfec4",
    "submitter": {
        "id": 1102,
        "url": "http://patches.dpdk.org/api/people/1102/?format=api",
        "name": "Slava Ovsiienko",
        "email": "viacheslavo@mellanox.com"
    },
    "delegate": {
        "id": 6624,
        "url": "http://patches.dpdk.org/api/users/6624/?format=api",
        "username": "shahafs",
        "first_name": "Shahaf",
        "last_name": "Shuler",
        "email": "shahafs@mellanox.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1555084107-24692-1-git-send-email-viacheslavo@mellanox.com/mbox/",
    "series": [
        {
            "id": 4292,
            "url": "http://patches.dpdk.org/api/series/4292/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=4292",
            "date": "2019-04-12T15:48:27",
            "name": "[1/1] net/mlx5: add support for PF representor",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/4292/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/52725/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/52725/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 90EF71B21A;\n\tFri, 12 Apr 2019 17:48:40 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id 39DF71B1F6\n\tfor <dev@dpdk.org>; Fri, 12 Apr 2019 17:48:39 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tviacheslavo@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 12 Apr 2019 18:48:35 +0300",
            "from pegasus12.mtr.labs.mlnx. (pegasus12.mtr.labs.mlnx\n\t[10.210.17.40])\n\tby labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x3CFmZV7020109;\n\tFri, 12 Apr 2019 18:48:35 +0300"
        ],
        "From": "Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "To": "dev@dpdk.org",
        "Cc": "shahafs@mellanox.com",
        "Date": "Fri, 12 Apr 2019 15:48:27 +0000",
        "Message-Id": "<1555084107-24692-1-git-send-email-viacheslavo@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "Subject": "[dpdk-dev] [PATCH 1/1] net/mlx5: add support for PF representor",
        "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\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "On BlueField platform we have the new entity - PF representor.\nThis one represents the PCI PF attached to external host on the\nside of ARM. The traffic sent by the external host to the NIC\nvia PF will be seem by ARM on this PF representor.\n\nThis patch extends port recognizing capability on the base of\nphysical port name. The following naming formats are supported:\n\n  - missing physical port name (no sysfs/netlink key) at all,\n    this is old style (before kernel 5.0) format, master assumed\n  - 1 (decimal digits) - old style (before kernel 5.0) format,\n    exists only for representors, master does not have physical\n    port name at all (see above)\n  - p0 (\"p\" followed by decimal digits), new style (kernel version\n    is 5.0 or higher, Mellanox OFED 4.6 or higher) name format\n    for uplink representor, plays the role of master\n  - pf0vf0 (\"pf\" followed by PF index concatenated with \"vf\"\n    followed by VF index),  new style (kernel version  is 5.0\n    or higher, Mellanox OFED 4.6 or higher) name format for\n    VF representor. If index of VF is \"-1\" it is a special case\n    of host PF representor, this representor must be indexed in\n    devargs as 65535, for example representor=[0-3,65535] will\n    allow representors for VF0, VF1, VF2, VF3 and host PF.\n    Note: do not specify representor=[0-65535] it causes devargs\n    processing error, because number of ports (rte_eth_dev) is\n    limited.\n\nApplications should distinguish representors and master devices\nexclusively by device flag RTE_ETH_DEV_REPRESENTOR and do not\nrely on switch port_id (mlx5 PMD deduces ones from representor_id)\nvalues returned by dev_infos_get() API.\n\nSigned-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n---\n drivers/net/mlx5/mlx5.h        | 11 ++++++-\n drivers/net/mlx5/mlx5_ethdev.c | 68 +++++++++++++++++++++++++++---------------\n drivers/net/mlx5/mlx5_nl.c     | 42 +++++++++++++++++---------\n 3 files changed, 82 insertions(+), 39 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 8eb1019..81c02ce 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -80,11 +80,20 @@ struct mlx5_mp_param {\n /** Key string for IPC. */\n #define MLX5_MP_NAME \"net_mlx5_mp\"\n \n+/* Recognized Infiniband device physical port name types. */\n+enum mlx5_phys_port_name_type {\n+\tMLX5_PHYS_PORT_NAME_TYPE_UNKNOWN = 0, /* Unrecognized. */\n+\tMLX5_PHYS_PORT_NAME_TYPE_LEGACY, /* before kernel ver < 5.0 */\n+\tMLX5_PHYS_PORT_NAME_TYPE_UPLINK, /* p0, kernel ver >= 5.0 */\n+\tMLX5_PHYS_PORT_NAME_TYPE_PFVF, /* pf0vf0, kernel ver >= 5.0 */\n+};\n+\n /** Switch information returned by mlx5_nl_switch_info(). */\n struct mlx5_switch_info {\n \tuint32_t master:1; /**< Master device. */\n \tuint32_t representor:1; /**< Representor device. */\n-\tuint32_t port_name_new:1; /**< Rep. port name is in new format. */\n+\tenum mlx5_phys_port_name_type name_type; /** < Port name type. */\n+\tint32_t pf_num; /**< PF number (valid for pfxvfx format only). */\n \tint32_t port_name; /**< Representor port name. */\n \tuint64_t switch_id; /**< Switch identifier. */\n };\ndiff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c\nindex 3992918..371989f 100644\n--- a/drivers/net/mlx5/mlx5_ethdev.c\n+++ b/drivers/net/mlx5/mlx5_ethdev.c\n@@ -1395,12 +1395,11 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n \tstruct mlx5_switch_info data = {\n \t\t.master = 0,\n \t\t.representor = 0,\n-\t\t.port_name_new = 0,\n+\t\t.name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN,\n \t\t.port_name = 0,\n \t\t.switch_id = 0,\n \t};\n \tDIR *dir;\n-\tbool port_name_set = false;\n \tbool port_switch_id_set = false;\n \tbool device_dir = false;\n \tchar c;\n@@ -1423,8 +1422,7 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n \t\tret = fscanf(file, \"%s\", port_name);\n \t\tfclose(file);\n \t\tif (ret == 1)\n-\t\t\tport_name_set = mlx5_translate_port_name(port_name,\n-\t\t\t\t\t\t\t\t &data);\n+\t\t\tmlx5_translate_port_name(port_name, &data);\n \t}\n \tfile = fopen(phys_switch_id, \"rb\");\n \tif (file == NULL) {\n@@ -1440,8 +1438,15 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n \t\tclosedir(dir);\n \t\tdevice_dir = true;\n \t}\n-\tdata.master = port_switch_id_set && (!port_name_set || device_dir);\n-\tdata.representor = port_switch_id_set && port_name_set && !device_dir;\n+\tif (port_switch_id_set) {\n+\t\tdata.master =\n+\t\t\tdevice_dir ||\n+\t\t\tdata.name_type == MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN ||\n+\t\t\tdata.name_type == MLX5_PHYS_PORT_NAME_TYPE_UPLINK;\n+\t\tdata.representor = !device_dir &&\n+\t\t\t(data.name_type == MLX5_PHYS_PORT_NAME_TYPE_LEGACY ||\n+\t\t\t data.name_type == MLX5_PHYS_PORT_NAME_TYPE_PFVF);\n+\t}\n \t*info = data;\n \tassert(!(data.master && data.representor));\n \tif (data.master && data.representor) {\n@@ -1459,10 +1464,11 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n  * @param[in] port_name_in\n  *   String representing the port name.\n  * @param[out] port_info_out\n- *   Port information, including port name as a number.\n+ *   Port information, including port name as a number and port name\n+ *   type if recognized\n  *\n  * @return\n- *   true on success, false otherwise.\n+ *   true on success (if name format recognized), false otherwise.\n  */\n bool\n mlx5_translate_port_name(const char *port_name_in,\n@@ -1470,25 +1476,39 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n {\n \tchar pf_c1, pf_c2, vf_c1, vf_c2;\n \tchar *end;\n-\tint32_t pf_num;\n-\tbool port_name_set = false;\n+\tint sc_items;\n \n \t/*\n \t * Check for port-name as a string of the form pf0vf0\n-\t * (support kernel ver >= 5.0)\n+\t * (support kernel ver >= 5.0 or OFED ver >= 4.6).\n \t */\n-\tport_name_set =\t(sscanf(port_name_in, \"%c%c%d%c%c%d\", &pf_c1, &pf_c2,\n-\t\t\t\t&pf_num, &vf_c1, &vf_c2,\n-\t\t\t\t&port_info_out->port_name) == 6);\n-\tif (port_name_set) {\n-\t\tport_info_out->port_name_new = 1;\n-\t} else {\n-\t\t/* Check for port-name as a number (support kernel ver < 5.0 */\n-\t\terrno = 0;\n-\t\tport_info_out->port_name = strtol(port_name_in, &end, 0);\n-\t\tif (!errno &&\n-\t\t    (size_t)(end - port_name_in) == strlen(port_name_in))\n-\t\t\tport_name_set = true;\n+\tsc_items = sscanf(port_name_in, \"%c%c%d%c%c%d\",\n+\t\t\t  &pf_c1, &pf_c2, &port_info_out->pf_num,\n+\t\t\t  &vf_c1, &vf_c2, &port_info_out->port_name);\n+\tif (sc_items == 6 &&\n+\t    pf_c1 == 'p' && pf_c2 == 'f' &&\n+\t    vf_c1 == 'v' && vf_c2 == 'f') {\n+\t\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_PFVF;\n+\t\treturn true;\n+\t}\n+\t/*\n+\t * Check for port-name as a string of the form p0\n+\t * (support kernel ver >= 5.0, or OFED ver >= 4.6).\n+\t */\n+\tsc_items = sscanf(port_name_in, \"%c%d\",\n+\t\t\t  &pf_c1, &port_info_out->port_name);\n+\tif (sc_items == 2 && pf_c1 == 'p') {\n+\t\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UPLINK;\n+\t\treturn true;\n+\t}\n+\t/* Check for port-name as a number (support kernel ver < 5.0 */\n+\terrno = 0;\n+\tport_info_out->port_name = strtol(port_name_in, &end, 0);\n+\tif (!errno &&\n+\t    (size_t)(end - port_name_in) == strlen(port_name_in)) {\n+\t\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_LEGACY;\n+\t\treturn  true;\n \t}\n-\treturn port_name_set;\n+\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;\n+\treturn false;\n }\ndiff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c\nindex fd9226b..669de76 100644\n--- a/drivers/net/mlx5/mlx5_nl.c\n+++ b/drivers/net/mlx5/mlx5_nl.c\n@@ -887,12 +887,11 @@ struct mlx5_nl_ifindex_data {\n \tstruct mlx5_switch_info info = {\n \t\t.master = 0,\n \t\t.representor = 0,\n-\t\t.port_name_new = 0,\n+\t\t.name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN,\n \t\t.port_name = 0,\n \t\t.switch_id = 0,\n \t};\n \tsize_t off = NLMSG_LENGTH(sizeof(struct ifinfomsg));\n-\tbool port_name_set = false;\n \tbool switch_id_set = false;\n \tbool num_vf_set = false;\n \n@@ -910,9 +909,7 @@ struct mlx5_nl_ifindex_data {\n \t\t\tnum_vf_set = true;\n \t\t\tbreak;\n \t\tcase IFLA_PHYS_PORT_NAME:\n-\t\t\tport_name_set =\n-\t\t\t\tmlx5_translate_port_name((char *)payload,\n-\t\t\t\t\t\t\t &info);\n+\t\t\tmlx5_translate_port_name((char *)payload, &info);\n \t\t\tbreak;\n \t\tcase IFLA_PHYS_SWITCH_ID:\n \t\t\tinfo.switch_id = 0;\n@@ -926,16 +923,33 @@ struct mlx5_nl_ifindex_data {\n \t\toff += RTA_ALIGN(ra->rta_len);\n \t}\n \tif (switch_id_set) {\n-\t\tif (info.port_name_new) {\n-\t\t\t/* New representors naming schema. */\n-\t\t\tif (port_name_set) {\n-\t\t\t\tinfo.master = (info.port_name == -1);\n-\t\t\t\tinfo.representor = (info.port_name != -1);\n-\t\t\t}\n-\t\t} else {\n+\t\t/* We have some E-Switch configuration. */\n+\t\tswitch (info.name_type) {\n+\t\tcase MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN:\n+\t\t\t/*\n+\t\t\t * Name is not recognized or not set,\n+\t\t\t * it can not be representor, check\n+\t\t\t * VF number to see if it is a master.\n+\t\t\t */\n+\t\t\tinfo.master = num_vf_set;\n+\t\t\tbreak;\n+\t\tcase MLX5_PHYS_PORT_NAME_TYPE_LEGACY:\n \t\t\t/* Legacy representors naming schema. */\n-\t\t\tinfo.master = (!port_name_set || num_vf_set);\n-\t\t\tinfo.representor = port_name_set && !num_vf_set;\n+\t\t\tinfo.representor = !num_vf_set;\n+\t\t\tbreak;\n+\t\tcase MLX5_PHYS_PORT_NAME_TYPE_UPLINK:\n+\t\t\t/* New uplink naming schema. */\n+\t\t\tinfo.master = 1;\n+\t\t\tbreak;\n+\t\tcase MLX5_PHYS_PORT_NAME_TYPE_PFVF:\n+\t\t\t/* New representors naming schema. */\n+\t\t\tinfo.representor = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t\tif (!info.master && !info.representor) {\n+\t\t\tDRV_LOG(INFO,\n+\t\t\t\t\"unable to recognize master/representors\"\n+\t\t\t\t\" on the device in switch domain\");\n \t\t}\n \t}\n \tassert(!(info.master && info.representor));\n",
    "prefixes": [
        "1/1"
    ]
}