get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 51452,
    "url": "http://patches.dpdk.org/api/patches/51452/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1553155888-27498-2-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": "<1553155888-27498-2-git-send-email-viacheslavo@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1553155888-27498-2-git-send-email-viacheslavo@mellanox.com",
    "date": "2019-03-21T08:11:15",
    "name": "[01/14] net/mlx5: add representor recognition on kernels 5.x",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "eb59745eed65baf767a5db892655ccca9b2d69ef",
    "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/1553155888-27498-2-git-send-email-viacheslavo@mellanox.com/mbox/",
    "series": [
        {
            "id": 3842,
            "url": "http://patches.dpdk.org/api/series/3842/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=3842",
            "date": "2019-03-21T08:11:18",
            "name": "net/mlx5: add support for multiport IB devices",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/3842/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/51452/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/51452/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 A743E1B463;\n\tThu, 21 Mar 2019 09:11:58 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id 994281B43D\n\tfor <dev@dpdk.org>; Thu, 21 Mar 2019 09:11:42 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tviacheslavo@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 21 Mar 2019 10:11:37 +0200",
            "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 x2L8Bahx003643;\n\tThu, 21 Mar 2019 10:11:36 +0200"
        ],
        "From": "Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "To": "dev@dpdk.org",
        "Cc": "shahafs@mellanox.com",
        "Date": "Thu, 21 Mar 2019 08:11:15 +0000",
        "Message-Id": "<1553155888-27498-2-git-send-email-viacheslavo@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1553155888-27498-1-git-send-email-viacheslavo@mellanox.com>",
        "References": "<1551376985-11096-1-git-send-email-viacheslavo@mellanox.com>\n\t<1553155888-27498-1-git-send-email-viacheslavo@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH 01/14] net/mlx5: add representor recognition on\n\tkernels 5.x",
        "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": "The master device and VF representors were distinguished by\npresence of port name, master device did not have one. The new Linux\nkernels starting from 5.0 provide the port name for master device\nand the implemented representor recognizing method does not work.\nThe new recognizing method is based on quiering the VF number,\ncreated on the base of the device.\n\nThe IFLA_NUM_VF attribute is returned by kernel if IFLA_EXT_MASK\nattribute is specified in the Netlink request message.\n\nAlso the presence of device symlink in device sysfs folder is\nadded to distinguish representors with sysfs based method.\n\nSigned-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n\n---\n\nv3: - rebased over new port naming http://patches.dpdk.org/patch/51245/\n    - master recognition is reinforced by checking vport for -1\n      for new port naming schema\n\nv2: - fopen replaced with opendir to detect whether directory exists\n\nv1: http://patches.dpdk.org/patch/50411/\n---\n drivers/net/mlx5/Makefile      | 10 ++++++++++\n drivers/net/mlx5/meson.build   |  4 ++++\n drivers/net/mlx5/mlx5.c        |  2 +-\n drivers/net/mlx5/mlx5.h        |  1 +\n drivers/net/mlx5/mlx5_ethdev.c | 13 +++++++++++--\n drivers/net/mlx5/mlx5_nl.c     | 36 +++++++++++++++++++++++++++++++++---\n 6 files changed, 60 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile\nindex 1ed299d..3dd7e38 100644\n--- a/drivers/net/mlx5/Makefile\n+++ b/drivers/net/mlx5/Makefile\n@@ -231,6 +231,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh\n \t\tenum RDMA_NLDEV_ATTR_NDEV_INDEX \\\n \t\t$(AUTOCONF_OUTPUT)\n \t$Q sh -- '$<' '$@' \\\n+\t\tHAVE_IFLA_NUM_VF \\\n+\t\tlinux/if_link.h \\\n+\t\tenum IFLA_NUM_VF \\\n+\t\t$(AUTOCONF_OUTPUT)\n+\t$Q sh -- '$<' '$@' \\\n+\t\tHAVE_IFLA_EXT_MASK \\\n+\t\tlinux/if_link.h \\\n+\t\tenum IFLA_EXT_MASK \\\n+\t\t$(AUTOCONF_OUTPUT)\n+\t$Q sh -- '$<' '$@' \\\n \t\tHAVE_IFLA_PHYS_SWITCH_ID \\\n \t\tlinux/if_link.h \\\n \t\tenum IFLA_PHYS_SWITCH_ID \\\ndiff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build\nindex 0cf2f08..e3cb9bc 100644\n--- a/drivers/net/mlx5/meson.build\n+++ b/drivers/net/mlx5/meson.build\n@@ -133,6 +133,10 @@ if build\n \t\t'ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT' ],\n \t\t[ 'HAVE_ETHTOOL_LINK_MODE_100G', 'linux/ethtool.h',\n \t\t'ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT' ],\n+\t\t[ 'HAVE_IFLA_NUM_VF', 'linux/if_link.h',\n+\t\t'IFLA_NUM_VF' ],\n+\t\t[ 'HAVE_IFLA_EXT_MASK', 'linux/if_link.h',\n+\t\t'IFLA_EXT_MASK' ],\n \t\t[ 'HAVE_IFLA_PHYS_SWITCH_ID', 'linux/if_link.h',\n \t\t'IFLA_PHYS_SWITCH_ID' ],\n \t\t[ 'HAVE_IFLA_PHYS_PORT_NAME', 'linux/if_link.h',\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex ad1975c..ea3d00c 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -13,7 +13,6 @@\n #include <errno.h>\n #include <net/if.h>\n #include <sys/mman.h>\n-#include <linux/netlink.h>\n #include <linux/rtnetlink.h>\n \n /* Verbs header. */\n@@ -1001,6 +1000,7 @@\n \tpriv->nl_socket_route =\tmlx5_nl_init(NETLINK_ROUTE);\n \tpriv->nl_sn = 0;\n \tpriv->representor = !!switch_info->representor;\n+\tpriv->master = !!switch_info->master;\n \tpriv->domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID;\n \tpriv->representor_id =\n \t\tswitch_info->representor ? switch_info->port_name : -1;\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex a88cb4a..58bc37f 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -214,6 +214,7 @@ struct mlx5_priv {\n \tuint16_t mtu; /* Configured MTU. */\n \tunsigned int isolated:1; /* Whether isolated mode is enabled. */\n \tunsigned int representor:1; /* Device is a port representor. */\n+\tunsigned int master:1; /* Device is a E-Switch master. */\n \tuint16_t domain_id; /* Switch domain identifier. */\n \tint32_t representor_id; /* Port representor identifier. */\n \t/* RX/TX queues. */\ndiff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c\nindex 84d761c..81f2a42 100644\n--- a/drivers/net/mlx5/mlx5_ethdev.c\n+++ b/drivers/net/mlx5/mlx5_ethdev.c\n@@ -1362,8 +1362,10 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\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 \n \tif (!if_indextoname(ifindex, ifname)) {\n@@ -1375,6 +1377,8 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n \t      ifname);\n \tMKSTR(phys_switch_id, \"/sys/class/net/%s/phys_switch_id\",\n \t      ifname);\n+\tMKSTR(pci_device, \"/sys/class/net/%s/device\",\n+\t      ifname);\n \n \tfile = fopen(phys_port_name, \"rb\");\n \tif (file != NULL) {\n@@ -1391,8 +1395,13 @@ int mlx5_fw_version_get(struct rte_eth_dev *dev, char *fw_ver, size_t fw_size)\n \t\tfscanf(file, \"%\" SCNx64 \"%c\", &data.switch_id, &c) == 2 &&\n \t\tc == '\\n';\n \tfclose(file);\n-\tdata.master = port_switch_id_set && !port_name_set;\n-\tdata.representor = port_switch_id_set && port_name_set;\n+\tdir = opendir(pci_device);\n+\tif (dir != NULL) {\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 \t*info = data;\n \treturn 0;\n }\ndiff --git a/drivers/net/mlx5/mlx5_nl.c b/drivers/net/mlx5/mlx5_nl.c\nindex 8a10109..aa49cb4 100644\n--- a/drivers/net/mlx5/mlx5_nl.c\n+++ b/drivers/net/mlx5/mlx5_nl.c\n@@ -65,6 +65,12 @@\n #endif\n \n /* These are normally found in linux/if_link.h. */\n+#ifndef HAVE_IFLA_NUM_VF\n+#define IFLA_NUM_VF 21\n+#endif\n+#ifndef HAVE_IFLA_EXT_MASK\n+#define IFLA_EXT_MASK 29\n+#endif\n #ifndef HAVE_IFLA_PHYS_SWITCH_ID\n #define IFLA_PHYS_SWITCH_ID 36\n #endif\n@@ -837,6 +843,7 @@ struct mlx5_nl_ifindex_data {\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 \tif (nh->nlmsg_type != RTM_NEWLINK)\n \t\tgoto error;\n@@ -848,6 +855,9 @@ struct mlx5_nl_ifindex_data {\n \t\tif (ra->rta_len > nh->nlmsg_len - off)\n \t\t\tgoto error;\n \t\tswitch (ra->rta_type) {\n+\t\tcase IFLA_NUM_VF:\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@@ -864,8 +874,19 @@ struct mlx5_nl_ifindex_data {\n \t\t}\n \t\toff += RTA_ALIGN(ra->rta_len);\n \t}\n-\tinfo.master = switch_id_set && !port_name_set;\n-\tinfo.representor = switch_id_set && port_name_set;\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\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}\n+\t}\n \tmemcpy(arg, &info, sizeof(info));\n \treturn 0;\n error:\n@@ -893,9 +914,13 @@ struct mlx5_nl_ifindex_data {\n \tstruct {\n \t\tstruct nlmsghdr nh;\n \t\tstruct ifinfomsg info;\n+\t\tstruct rtattr rta;\n+\t\tuint32_t extmask;\n \t} req = {\n \t\t.nh = {\n-\t\t\t.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)),\n+\t\t\t.nlmsg_len = NLMSG_LENGTH\n+\t\t\t\t\t(sizeof(req.info) +\n+\t\t\t\t\t RTA_LENGTH(sizeof(uint32_t))),\n \t\t\t.nlmsg_type = RTM_GETLINK,\n \t\t\t.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK,\n \t\t},\n@@ -903,6 +928,11 @@ struct mlx5_nl_ifindex_data {\n \t\t\t.ifi_family = AF_UNSPEC,\n \t\t\t.ifi_index = ifindex,\n \t\t},\n+\t\t.rta = {\n+\t\t\t.rta_type = IFLA_EXT_MASK,\n+\t\t\t.rta_len = RTA_LENGTH(sizeof(int32_t)),\n+\t\t},\n+\t\t.extmask = RTE_LE32(1),\n \t};\n \tint ret;\n \n",
    "prefixes": [
        "01/14"
    ]
}