get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 51642,
    "url": "http://patchwork.dpdk.org/api/patches/51642/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1553533414-9911-2-git-send-email-viacheslavo@mellanox.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<1553533414-9911-2-git-send-email-viacheslavo@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1553533414-9911-2-git-send-email-viacheslavo@mellanox.com",
    "date": "2019-03-25T17:03:22",
    "name": "[v2,01/13] net/mlx5: add representor recognition on kernels 5.x",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "9c2bdd924c542b9367f882f3a587bca5bb8e67d4",
    "submitter": {
        "id": 1102,
        "url": "http://patchwork.dpdk.org/api/people/1102/?format=api",
        "name": "Slava Ovsiienko",
        "email": "viacheslavo@mellanox.com"
    },
    "delegate": {
        "id": 6624,
        "url": "http://patchwork.dpdk.org/api/users/6624/?format=api",
        "username": "shahafs",
        "first_name": "Shahaf",
        "last_name": "Shuler",
        "email": "shahafs@mellanox.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1553533414-9911-2-git-send-email-viacheslavo@mellanox.com/mbox/",
    "series": [
        {
            "id": 3902,
            "url": "http://patchwork.dpdk.org/api/series/3902/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=3902",
            "date": "2019-03-25T17:03:24",
            "name": "net/mlx5: add support for multiport IB devices",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/3902/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/51642/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/51642/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 05CDF4CA0;\n\tMon, 25 Mar 2019 18:04:02 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n\tby dpdk.org (Postfix) with ESMTP id 5580A2C39\n\tfor <dev@dpdk.org>; Mon, 25 Mar 2019 18:03:46 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n\tviacheslavo@mellanox.com)\n\twith ESMTPS (AES256-SHA encrypted); 25 Mar 2019 19:03:41 +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 x2PH3fbX020888;\n\tMon, 25 Mar 2019 19:03:41 +0200"
        ],
        "From": "Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "To": "dev@dpdk.org",
        "Cc": "shahafs@mellanox.com",
        "Date": "Mon, 25 Mar 2019 17:03:22 +0000",
        "Message-Id": "<1553533414-9911-2-git-send-email-viacheslavo@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>",
        "References": "<1553155888-27498-1-git-send-email-viacheslavo@mellanox.com>\n\t<1553533414-9911-1-git-send-email-viacheslavo@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH v2 01/13] net/mlx5: add representor recognition\n\ton kernels 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 drivers/net/mlx5/Makefile      | 10 ++++++++++\n drivers/net/mlx5/meson.build   |  4 ++++\n drivers/net/mlx5/mlx5.c        | 17 ++++++++++++++---\n drivers/net/mlx5/mlx5.h        |  1 +\n drivers/net/mlx5/mlx5_ethdev.c | 14 ++++++++++++--\n drivers/net/mlx5/mlx5_nl.c     | 37 ++++++++++++++++++++++++++++++++++---\n 6 files changed, 75 insertions(+), 8 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..032f1f2 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,9 +1000,21 @@\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;\n+\t/*\n+\t * Currently we support sinlge E-Switch per PF configurations\n+\t * only and representors_id field contains the vport index for\n+\t * corresponding VF, deduced from representor port name.\n+\t * For exapmple, let's have the IB device port 10, it has\n+\t * attached network device eth0, which has port name attribute\n+\t * pf0vf2, we can deduce the VF number as 2, and set vport index\n+\t * as 3 (2+1). This assigning schema should be changed if the\n+\t * multiple E-Switch instance per PF configurations or/and PCI\n+\t * subfunctions dded.\n+\t */\n+\tpriv->representor_id = switch_info->representor ?\n+\t\t\t       switch_info->port_name + 1 : -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/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 2e8a296..64c6b6f 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 \tint ret;\n \n@@ -1376,6 +1378,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@@ -1394,8 +1398,14 @@ 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+\tassert(!(data.master && data.representor));\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..9d0fcba 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,20 @@ 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+\tassert(!(data.master && data.representor));\n \tmemcpy(arg, &info, sizeof(info));\n \treturn 0;\n error:\n@@ -893,9 +915,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 +929,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": [
        "v2",
        "01/13"
    ]
}