get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 70747,
    "url": "http://patchwork.dpdk.org/api/patches/70747/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1591113208-79169-1-git-send-email-matan@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": "<1591113208-79169-1-git-send-email-matan@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1591113208-79169-1-git-send-email-matan@mellanox.com",
    "date": "2020-06-02T15:53:27",
    "name": "[1/2] common/mlx5: share kernel interface name getter",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "777bcc363dd55534cb8002dde9588e3fa10e4181",
    "submitter": {
        "id": 796,
        "url": "http://patchwork.dpdk.org/api/people/796/?format=api",
        "name": "Matan Azrad",
        "email": "matan@mellanox.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patchwork.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1591113208-79169-1-git-send-email-matan@mellanox.com/mbox/",
    "series": [
        {
            "id": 10297,
            "url": "http://patchwork.dpdk.org/api/series/10297/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=10297",
            "date": "2020-06-02T15:53:27",
            "name": "[1/2] common/mlx5: share kernel interface name getter",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/10297/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/70747/comments/",
    "check": "fail",
    "checks": "http://patchwork.dpdk.org/api/patches/70747/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 012F8A0514;\n\tTue,  2 Jun 2020 17:53:35 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D71741BF73;\n\tTue,  2 Jun 2020 17:53:34 +0200 (CEST)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id 7EECD5F2F\n for <dev@dpdk.org>; Tue,  2 Jun 2020 17:53:33 +0200 (CEST)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n matan@mellanox.com)\n with ESMTPS (AES256-SHA encrypted); 2 Jun 2020 18:53:32 +0300",
            "from pegasus25.mtr.labs.mlnx. (pegasus25.mtr.labs.mlnx\n [10.210.16.10])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 052FrW5t015577;\n Tue, 2 Jun 2020 18:53:32 +0300"
        ],
        "From": "Matan Azrad <matan@mellanox.com>",
        "To": "Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "Cc": "dev@dpdk.org, Maxime Coquelin <maxime.coquelin@redhat.com>",
        "Date": "Tue,  2 Jun 2020 15:53:27 +0000",
        "Message-Id": "<1591113208-79169-1-git-send-email-matan@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "Subject": "[dpdk-dev] [PATCH 1/2] common/mlx5: share kernel interface name\n\tgetter",
        "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 <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": "Some configuration of the mlx5 port are done by the kernel net device\nassociated to the IB device represents the PCI device.\n\nThe DPDK mlx5 driver uses linux system calls, for example ioctl, in\norder to configure per port configurations requested by the DPDK user.\n\nOne of the basic knowledges required to access the correct kernel net\ndevice is its name.\n\nMove function to get interface name from IB device path to the common\nlibrary.\n\nSigned-off-by: Matan Azrad <matan@mellanox.com>\n---\n drivers/common/mlx5/mlx5_common.c               | 88 ++++++++++++++++++++++++\n drivers/common/mlx5/mlx5_common.h               |  3 +\n drivers/common/mlx5/rte_common_mlx5_version.map |  2 +\n drivers/net/mlx5/mlx5.c                         |  2 +-\n drivers/net/mlx5/mlx5.h                         |  1 -\n drivers/net/mlx5/mlx5_ethdev.c                  | 90 +------------------------\n 6 files changed, 96 insertions(+), 90 deletions(-)",
    "diff": "diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c\nindex 1c77763..3f0d8d3 100644\n--- a/drivers/common/mlx5/mlx5_common.c\n+++ b/drivers/common/mlx5/mlx5_common.c\n@@ -8,8 +8,10 @@\n #ifdef RTE_IBVERBS_LINK_DLOPEN\n #include <dlfcn.h>\n #endif\n+#include <dirent.h>\n \n #include <rte_errno.h>\n+#include <rte_string_fns.h>\n \n #include \"mlx5_common.h\"\n #include \"mlx5_common_utils.h\"\n@@ -167,6 +169,92 @@ enum mlx5_class\n \treturn;\n }\n \n+/**\n+ * Get kernel interface name from IB device path.\n+ *\n+ * @param[in] ibdev_path\n+ *   Pointer to IB device path.\n+ * @param[out] ifname\n+ *   Interface name output buffer.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+int\n+mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])\n+{\n+\tDIR *dir;\n+\tstruct dirent *dent;\n+\tunsigned int dev_type = 0;\n+\tunsigned int dev_port_prev = ~0u;\n+\tchar match[IF_NAMESIZE] = \"\";\n+\n+\tMLX5_ASSERT(ibdev_path);\n+\t{\n+\t\tMKSTR(path, \"%s/device/net\", ibdev_path);\n+\n+\t\tdir = opendir(path);\n+\t\tif (dir == NULL) {\n+\t\t\trte_errno = errno;\n+\t\t\treturn -rte_errno;\n+\t\t}\n+\t}\n+\twhile ((dent = readdir(dir)) != NULL) {\n+\t\tchar *name = dent->d_name;\n+\t\tFILE *file;\n+\t\tunsigned int dev_port;\n+\t\tint r;\n+\n+\t\tif ((name[0] == '.') &&\n+\t\t    ((name[1] == '\\0') ||\n+\t\t     ((name[1] == '.') && (name[2] == '\\0'))))\n+\t\t\tcontinue;\n+\n+\t\tMKSTR(path, \"%s/device/net/%s/%s\",\n+\t\t      ibdev_path, name,\n+\t\t      (dev_type ? \"dev_id\" : \"dev_port\"));\n+\n+\t\tfile = fopen(path, \"rb\");\n+\t\tif (file == NULL) {\n+\t\t\tif (errno != ENOENT)\n+\t\t\t\tcontinue;\n+\t\t\t/*\n+\t\t\t * Switch to dev_id when dev_port does not exist as\n+\t\t\t * is the case with Linux kernel versions < 3.15.\n+\t\t\t */\n+try_dev_id:\n+\t\t\tmatch[0] = '\\0';\n+\t\t\tif (dev_type)\n+\t\t\t\tbreak;\n+\t\t\tdev_type = 1;\n+\t\t\tdev_port_prev = ~0u;\n+\t\t\trewinddir(dir);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tr = fscanf(file, (dev_type ? \"%x\" : \"%u\"), &dev_port);\n+\t\tfclose(file);\n+\t\tif (r != 1)\n+\t\t\tcontinue;\n+\t\t/*\n+\t\t * Switch to dev_id when dev_port returns the same value for\n+\t\t * all ports. May happen when using a MOFED release older than\n+\t\t * 3.0 with a Linux kernel >= 3.15.\n+\t\t */\n+\t\tif (dev_port == dev_port_prev)\n+\t\t\tgoto try_dev_id;\n+\t\tdev_port_prev = dev_port;\n+\t\tif (dev_port == 0)\n+\t\t\tstrlcpy(match, name, sizeof(match));\n+\t}\n+\tclosedir(dir);\n+\tif (match[0] == '\\0') {\n+\t\trte_errno = ENOENT;\n+\t\treturn -rte_errno;\n+\t}\n+\tstrncpy(*ifname, match, sizeof(*ifname));\n+\treturn 0;\n+}\n+\n #ifdef MLX5_GLUE\n \n /**\ndiff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h\nindex 8cd3ea5..4f6373b 100644\n--- a/drivers/common/mlx5/mlx5_common.h\n+++ b/drivers/common/mlx5/mlx5_common.h\n@@ -6,6 +6,7 @@\n #define RTE_PMD_MLX5_COMMON_H_\n \n #include <stdio.h>\n+#include <net/if.h>\n \n #include <rte_pci.h>\n #include <rte_debug.h>\n@@ -212,6 +213,8 @@ enum mlx5_class {\n __rte_internal\n void mlx5_translate_port_name(const char *port_name_in,\n \t\t\t      struct mlx5_switch_info *port_info_out);\n+__rte_internal\n+int mlx5_get_ifname_sysfs(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);\n \n extern uint8_t haswell_broadwell_cpu;\n \ndiff --git a/drivers/common/mlx5/rte_common_mlx5_version.map b/drivers/common/mlx5/rte_common_mlx5_version.map\nindex b3410df..a62584d 100644\n--- a/drivers/common/mlx5/rte_common_mlx5_version.map\n+++ b/drivers/common/mlx5/rte_common_mlx5_version.map\n@@ -33,6 +33,8 @@ INTERNAL {\n \tmlx5_devx_cmd_query_virtq;\n \tmlx5_devx_get_out_command_status;\n \n+\tmlx5_get_ifname_sysfs;\n+\n \tmlx5_mp_init_primary;\n \tmlx5_mp_uninit_primary;\n \tmlx5_mp_init_secondary;\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 469ff73..91af47b 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -3570,7 +3570,7 @@ struct mlx5_flow_id_pool *\n \t\t\t\t\t */\n \t\t\t\t\tcontinue;\n \t\t\t\t}\n-\t\t\t\tret = mlx5_get_master_ifname\n+\t\t\t\tret = mlx5_get_ifname_sysfs\n \t\t\t\t\t(ibv_match[i]->ibdev_path, &ifname);\n \t\t\t\tif (!ret)\n \t\t\t\t\tlist[ns].ifindex =\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 2908c8b..536afae 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -645,7 +645,6 @@ int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,\n /* mlx5_ethdev.c */\n \n int mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[IF_NAMESIZE]);\n-int mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE]);\n unsigned int mlx5_ifindex(const struct rte_eth_dev *dev);\n int mlx5_ifreq(const struct rte_eth_dev *dev, int req, struct ifreq *ifr);\n int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu);\ndiff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c\nindex b837ce6..62344d1 100644\n--- a/drivers/net/mlx5/mlx5_ethdev.c\n+++ b/drivers/net/mlx5/mlx5_ethdev.c\n@@ -129,95 +129,9 @@ struct ethtool_link_settings {\n #endif\n \n /**\n- * Get master interface name from private structure.\n- *\n- * @param[in] dev\n- *   Pointer to Ethernet device.\n- * @param[out] ifname\n- *   Interface name output buffer.\n- *\n- * @return\n- *   0 on success, a negative errno value otherwise and rte_errno is set.\n- */\n-int\n-mlx5_get_master_ifname(const char *ibdev_path, char (*ifname)[IF_NAMESIZE])\n-{\n-\tDIR *dir;\n-\tstruct dirent *dent;\n-\tunsigned int dev_type = 0;\n-\tunsigned int dev_port_prev = ~0u;\n-\tchar match[IF_NAMESIZE] = \"\";\n-\n-\tMLX5_ASSERT(ibdev_path);\n-\t{\n-\t\tMKSTR(path, \"%s/device/net\", ibdev_path);\n-\n-\t\tdir = opendir(path);\n-\t\tif (dir == NULL) {\n-\t\t\trte_errno = errno;\n-\t\t\treturn -rte_errno;\n-\t\t}\n-\t}\n-\twhile ((dent = readdir(dir)) != NULL) {\n-\t\tchar *name = dent->d_name;\n-\t\tFILE *file;\n-\t\tunsigned int dev_port;\n-\t\tint r;\n-\n-\t\tif ((name[0] == '.') &&\n-\t\t    ((name[1] == '\\0') ||\n-\t\t     ((name[1] == '.') && (name[2] == '\\0'))))\n-\t\t\tcontinue;\n-\n-\t\tMKSTR(path, \"%s/device/net/%s/%s\",\n-\t\t      ibdev_path, name,\n-\t\t      (dev_type ? \"dev_id\" : \"dev_port\"));\n-\n-\t\tfile = fopen(path, \"rb\");\n-\t\tif (file == NULL) {\n-\t\t\tif (errno != ENOENT)\n-\t\t\t\tcontinue;\n-\t\t\t/*\n-\t\t\t * Switch to dev_id when dev_port does not exist as\n-\t\t\t * is the case with Linux kernel versions < 3.15.\n-\t\t\t */\n-try_dev_id:\n-\t\t\tmatch[0] = '\\0';\n-\t\t\tif (dev_type)\n-\t\t\t\tbreak;\n-\t\t\tdev_type = 1;\n-\t\t\tdev_port_prev = ~0u;\n-\t\t\trewinddir(dir);\n-\t\t\tcontinue;\n-\t\t}\n-\t\tr = fscanf(file, (dev_type ? \"%x\" : \"%u\"), &dev_port);\n-\t\tfclose(file);\n-\t\tif (r != 1)\n-\t\t\tcontinue;\n-\t\t/*\n-\t\t * Switch to dev_id when dev_port returns the same value for\n-\t\t * all ports. May happen when using a MOFED release older than\n-\t\t * 3.0 with a Linux kernel >= 3.15.\n-\t\t */\n-\t\tif (dev_port == dev_port_prev)\n-\t\t\tgoto try_dev_id;\n-\t\tdev_port_prev = dev_port;\n-\t\tif (dev_port == 0)\n-\t\t\tstrlcpy(match, name, sizeof(match));\n-\t}\n-\tclosedir(dir);\n-\tif (match[0] == '\\0') {\n-\t\trte_errno = ENOENT;\n-\t\treturn -rte_errno;\n-\t}\n-\tstrncpy(*ifname, match, sizeof(*ifname));\n-\treturn 0;\n-}\n-\n-/**\n  * Get interface name from private structure.\n  *\n- * This is a port representor-aware version of mlx5_get_master_ifname().\n+ * This is a port representor-aware version of mlx5_get_ifname_sysfs().\n  *\n  * @param[in] dev\n  *   Pointer to Ethernet device.\n@@ -238,7 +152,7 @@ struct ethtool_link_settings {\n \tifindex = mlx5_ifindex(dev);\n \tif (!ifindex) {\n \t\tif (!priv->representor)\n-\t\t\treturn mlx5_get_master_ifname(priv->sh->ibdev_path,\n+\t\t\treturn mlx5_get_ifname_sysfs(priv->sh->ibdev_path,\n \t\t\t\t\t\t      ifname);\n \t\trte_errno = ENXIO;\n \t\treturn -rte_errno;\n",
    "prefixes": [
        "1/2"
    ]
}