get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 70705,
    "url": "http://patchwork.dpdk.org/api/patches/70705/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20200601055047.5108-4-ophirmu@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": "<20200601055047.5108-4-ophirmu@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200601055047.5108-4-ophirmu@mellanox.com",
    "date": "2020-06-01T05:50:47",
    "name": "[v2,3/3] common/mlx5: split common file under Linux directory",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "db545814ceeecb097ac0396cfd7b51190444ef7b",
    "submitter": {
        "id": 793,
        "url": "http://patchwork.dpdk.org/api/people/793/?format=api",
        "name": "Ophir Munk",
        "email": "ophirmu@mellanox.com"
    },
    "delegate": {
        "id": 3268,
        "url": "http://patchwork.dpdk.org/api/users/3268/?format=api",
        "username": "rasland",
        "first_name": "Raslan",
        "last_name": "Darawsheh",
        "email": "rasland@nvidia.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20200601055047.5108-4-ophirmu@mellanox.com/mbox/",
    "series": [
        {
            "id": 10278,
            "url": "http://patchwork.dpdk.org/api/series/10278/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=10278",
            "date": "2020-06-01T05:50:44",
            "name": "Linux specific files moved & split",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/10278/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/70705/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/70705/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 3238EA04EF;\n\tMon,  1 Jun 2020 07:51:21 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 625DF1D529;\n\tMon,  1 Jun 2020 07:51:00 +0200 (CEST)",
            "from EUR05-DB8-obe.outbound.protection.outlook.com\n (mail-db8eur05on2083.outbound.protection.outlook.com [40.107.20.83])\n by dpdk.org (Postfix) with ESMTP id 296EF1D451\n for <dev@dpdk.org>; Mon,  1 Jun 2020 07:50:58 +0200 (CEST)",
            "from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22)\n by AM0PR05MB5953.eurprd05.prod.outlook.com (2603:10a6:208:12f::14)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.21; Mon, 1 Jun\n 2020 05:50:56 +0000",
            "from AM0PR05MB4209.eurprd05.prod.outlook.com\n ([fe80::1068:89a9:41d3:b14a]) by AM0PR05MB4209.eurprd05.prod.outlook.com\n ([fe80::1068:89a9:41d3:b14a%3]) with mapi id 15.20.3045.024; Mon, 1 Jun 2020\n 05:50:56 +0000",
            "from mellanox.com (37.142.13.130) by\n AM0PR06CA0110.eurprd06.prod.outlook.com (2603:10a6:208:ab::15) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.3045.17 via Frontend Transport; Mon, 1 Jun 2020 05:50:55 +0000"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;\n b=UnWcrRfOFCahdb2K2G+LgqdX6nJWJJtYgm472eLxQhoQRW/YpM9U6WPcgAZUa61LiNEiedE2kjKO+CQ9COH27lHeDdv2i8AZOpElTcH8Gc655rzZPOLcz6vsDTyisas7PoEFoy5BVvW494BZ6oKCoG3/XScLZRbhvKbPvNRXyxq2GgOUtgulUvq4vepskd3kVPhBIIxnq5erOM7C68Wailgnpj7Dg/QwJ8IsqECx7pTJUhfz8Bt1Sl5Kkgh72Vk1+BzB2BAWGO4USXhFdDdcxnQzv97Qg1euVW2c0Is8ET4xo1TPx6yIGGpXj2i2ooVa3qwFgryjHGGCsIeVpQ2eCA==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector9901;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=DxeSoul1I/MHmMhmeDLMIIqTS8R3ccHCo+xaM1lmkys=;\n b=oAwyt9X8vvvGA9HnuMV+A33gQTO1yBEtQ5HMfAxFMYTVishixPqU2AFlKcX8xs70jfySOfYpIUx74lMBoHUGKfE+aUxWC7coA/oN57xbcVQupz+g0atGK0sS9pyiB8u1eZN4tb8jmRCG0KZSmwUH2ch9s1+04SUhdPIyaWBdh3Gyua66ZXZ8WbxvEmbtU7q99PqdoF/MwK0qyBbkiAmrTU4FQ9+K5crm105nj7AZbbaO3u5bhBfT/tugtigR5IxQrPr+1OtZvR5IHzVKLNM/Lp9+Bb3hWlRPahFskp0Bmqe+hGaWqZD78VC+Zg8j78xDTNtQahOmOkNDN9rnuVJpaA==",
        "ARC-Authentication-Results": "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com;\n dkim=pass header.d=mellanox.com; arc=none",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com;\n s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=DxeSoul1I/MHmMhmeDLMIIqTS8R3ccHCo+xaM1lmkys=;\n b=YdXYXR41sRstP7FNF//V3ehSw5/GTBLK2ZmxzrDkojRgwbBS/5rOAWcBEb2l0BDY1HH2cAj3hMBzVRR1gSj2gMt6H2qOg9TByJOind45NGnAuyYuVLKPqZsbCOaNKMxqQk9X7zO5NDxP7fj48xsgz/NW9ES4P9bbCdv9drqO4H4=",
        "Authentication-Results": "dpdk.org; dkim=none (message not signed)\n header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com;",
        "From": "Ophir Munk <ophirmu@mellanox.com>",
        "To": "dev@dpdk.org,\n\tMatan Azrad <matan@mellanox.com>",
        "Cc": "Ophir Munk <ophirmu@mellanox.com>",
        "Date": "Mon,  1 Jun 2020 05:50:47 +0000",
        "Message-Id": "<20200601055047.5108-4-ophirmu@mellanox.com>",
        "X-Mailer": [
            "git-send-email 2.8.4",
            "git-send-email 2.8.4"
        ],
        "In-Reply-To": "<20200601055047.5108-1-ophirmu@mellanox.com>",
        "References": "<20200527161425.22944-1-ophirmu@mellanox.com>\n <20200601055047.5108-1-ophirmu@mellanox.com>",
        "Content-Type": "text/plain",
        "X-ClientProxiedBy": "AM0PR06CA0110.eurprd06.prod.outlook.com\n (2603:10a6:208:ab::15) To AM0PR05MB4209.eurprd05.prod.outlook.com\n (2603:10a6:208:61::22)",
        "MIME-Version": "1.0",
        "X-MS-Exchange-MessageSentRepresentingType": "1",
        "X-Originating-IP": "[37.142.13.130]",
        "X-MS-PublicTrafficType": "Email",
        "X-MS-Office365-Filtering-HT": "Tenant",
        "X-MS-Office365-Filtering-Correlation-Id": "1db35432-05e7-4735-e2d7-08d805efc06c",
        "X-MS-TrafficTypeDiagnostic": "AM0PR05MB5953:",
        "X-MS-Exchange-Transport-Forked": "True",
        "X-Microsoft-Antispam-PRVS": "\n <AM0PR05MB59534B9459EF4CBEB9EB9991D18A0@AM0PR05MB5953.eurprd05.prod.outlook.com>",
        "X-MS-Oob-TLC-OOBClassifiers": "OLM:265;",
        "X-Forefront-PRVS": "0421BF7135",
        "X-MS-Exchange-SenderADCheck": "1",
        "X-Microsoft-Antispam": "BCL:0;",
        "X-Microsoft-Antispam-Message-Info": "\n rq52jgZS6KBM1/is0QaQ++jvGZbT7q38jPok7MEBiGNnUUwA+wvg1twd4bqmwRfTKmLCEuK7xMRNg67CZwMdJZrzlcUv9NlroLXXI2aXZ/FTxS7rt5ABopsrjJC8uRvzzdqp4wW6YVQ+IqwsIKQ55uMWp60XFsImMdrp6ORkzZWdJ22ue36pZPSmxXpCxMluI539kvwXTo1FIg9IzZOf4GjdszW/QEC7yFpyh90cIL9jm4bE6iob0XDT7GTSLwy3T2JPmZiU09Mu+p9sihdx4GIy0WMSULludWVYmbnGgLjgaeDSvZ3aoaIJbR3ZTw339yPf02Wxgr/7erXDO4ESmg==",
        "X-Forefront-Antispam-Report": "CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE;\n SFTY:;\n SFS:(4636009)(396003)(376002)(346002)(136003)(366004)(39860400002)(6666004)(36756003)(6862004)(66556008)(66476007)(37006003)(7696005)(52116002)(8886007)(1076003)(66946007)(107886003)(83380400001)(8936002)(86362001)(30864003)(2616005)(5660300002)(316002)(26005)(8676002)(16526019)(478600001)(186003)(956004)(4326008)(6636002)(55016002)(2906002);\n DIR:OUT; SFP:1101;",
        "X-MS-Exchange-AntiSpam-MessageData": "\n aihS1mrqMznQeb1Lkp1sv4uGJiHITClxaL5xBQyakhOjHSqQKCDwWdYpsV+YuO+55Gfpr8mM8lPd9DKVEuerg5pGO8yPS3In4xRUVUub9EUsWkjIQOBv2zLqPCPFhy9Fk1FSIhnF/Ne5dsMDBsMcc21LoI9yFbJIlJ4govVgMynMrYtGpMPHYktk9NNnB4E0jHs1zYk4WigMEHtfsA5PXnv/VXIfRCZ13GowrCKccTaRPGIB57d23xhPyX2FB8T2t8K4XDaOWeKqEyqssVZ4rXxO8JUth3Xpd/Je7W+9U40VcdJr43bqNlxw3JU7nP4OjWmP6cbBB6WgwtsKsM0kKiSUMgyCIp6ZVvQchE8U2tYK0k8dFgbC0clr9V9s1THoGoCgp87hsZoodFReYj4aaS9nuSGrjWrkB+vRUNkyTOxcmjFZ0Bw2RhiRrEksaJGJ7bPecapdhRnJlw3E7S+qTmjMAcEDwzdxFwV5Q8eErsPHLabnB09gkvQowPu9BA9N",
        "X-OriginatorOrg": "Mellanox.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 1db35432-05e7-4735-e2d7-08d805efc06c",
        "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "01 Jun 2020 05:50:55.9227 (UTC)",
        "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted",
        "X-MS-Exchange-CrossTenant-Id": "a652971c-7d2e-4d9b-a6a4-d149256f461b",
        "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED",
        "X-MS-Exchange-CrossTenant-UserPrincipalName": "\n jwdZddr1yFGcvzWvlD+mCw1Ov0xMCI5g6hfZFbDi/kCQ83oDiGkxPLwklhW9fmFr+yhubm6iuxJuHLswkFWy8w==",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "AM0PR05MB5953",
        "Subject": "[dpdk-dev] [PATCH v2 3/3] common/mlx5: split common file under\n\tLinux directory",
        "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": "File mlx5_common.c includes both specific and non-specific Linux APIs.\nMove the Linux specific APIS into a new file named linux/mlx5_common_os.c.\n\nSigned-off-by: Ophir Munk <ophirmu@mellanox.com>\n---\n drivers/common/mlx5/Makefile               |   1 +\n drivers/common/mlx5/linux/meson.build      |   1 +\n drivers/common/mlx5/linux/mlx5_common_os.c | 305 +++++++++++++++++++++++++++++\n drivers/common/mlx5/mlx5_common.c          | 286 +--------------------------\n drivers/common/mlx5/mlx5_common.h          |   1 +\n 5 files changed, 310 insertions(+), 284 deletions(-)\n create mode 100644 drivers/common/mlx5/linux/mlx5_common_os.c",
    "diff": "diff --git a/drivers/common/mlx5/Makefile b/drivers/common/mlx5/Makefile\nindex 40bf2a5..e9863b5 100644\n--- a/drivers/common/mlx5/Makefile\n+++ b/drivers/common/mlx5/Makefile\n@@ -16,6 +16,7 @@ SRCS-y += linux/mlx5_glue.c\n endif\n SRCS-y += mlx5_devx_cmds.c\n SRCS-y += mlx5_common.c\n+SRCS-y += linux/mlx5_common_os.c\n SRCS-y += linux/mlx5_nl.c\n SRCS-y += mlx5_common_mp.c\n SRCS-y += mlx5_common_mr.c\ndiff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build\nindex 04f7e03..f0016fa 100644\n--- a/drivers/common/mlx5/linux/meson.build\n+++ b/drivers/common/mlx5/linux/meson.build\n@@ -46,6 +46,7 @@ if static_ibverbs\n endif\n \n sources += files('mlx5_nl.c')\n+sources += files('mlx5_common_os.c')\n if not dlopen_ibverbs\n \tsources += files('mlx5_glue.c')\n endif\ndiff --git a/drivers/common/mlx5/linux/mlx5_common_os.c b/drivers/common/mlx5/linux/mlx5_common_os.c\nnew file mode 100644\nindex 0000000..4e04d70\n--- /dev/null\n+++ b/drivers/common/mlx5/linux/mlx5_common_os.c\n@@ -0,0 +1,305 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright 2020 Mellanox Technologies, Ltd\n+ */\n+\n+#include <unistd.h>\n+#include <string.h>\n+#include <stdio.h>\n+#ifdef RTE_IBVERBS_LINK_DLOPEN\n+#include <dlfcn.h>\n+#endif\n+\n+#include <rte_errno.h>\n+\n+#include \"mlx5_common.h\"\n+#include \"mlx5_common_utils.h\"\n+#include \"mlx5_glue.h\"\n+\n+#ifdef MLX5_GLUE\n+const struct mlx5_glue *mlx5_glue;\n+#endif\n+\n+/**\n+ * Get PCI information by sysfs device path.\n+ *\n+ * @param dev_path\n+ *   Pointer to device sysfs folder name.\n+ * @param[out] pci_addr\n+ *   PCI bus address output buffer.\n+ *\n+ * @return\n+ *   0 on success, a negative errno value otherwise and rte_errno is set.\n+ */\n+int\n+mlx5_dev_to_pci_addr(const char *dev_path,\n+\t\t     struct rte_pci_addr *pci_addr)\n+{\n+\tFILE *file;\n+\tchar line[32];\n+\tMKSTR(path, \"%s/device/uevent\", dev_path);\n+\n+\tfile = fopen(path, \"rb\");\n+\tif (file == NULL) {\n+\t\trte_errno = errno;\n+\t\treturn -rte_errno;\n+\t}\n+\twhile (fgets(line, sizeof(line), file) == line) {\n+\t\tsize_t len = strlen(line);\n+\t\tint ret;\n+\n+\t\t/* Truncate long lines. */\n+\t\tif (len == (sizeof(line) - 1))\n+\t\t\twhile (line[(len - 1)] != '\\n') {\n+\t\t\t\tret = fgetc(file);\n+\t\t\t\tif (ret == EOF)\n+\t\t\t\t\tbreak;\n+\t\t\t\tline[(len - 1)] = ret;\n+\t\t\t}\n+\t\t/* Extract information. */\n+\t\tif (sscanf(line,\n+\t\t\t   \"PCI_SLOT_NAME=\"\n+\t\t\t   \"%\" SCNx32 \":%\" SCNx8 \":%\" SCNx8 \".%\" SCNx8 \"\\n\",\n+\t\t\t   &pci_addr->domain,\n+\t\t\t   &pci_addr->bus,\n+\t\t\t   &pci_addr->devid,\n+\t\t\t   &pci_addr->function) == 4) {\n+\t\t\tret = 0;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tfclose(file);\n+\treturn 0;\n+}\n+\n+/**\n+ * Extract port name, as a number, from sysfs or netlink information.\n+ *\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 and port name\n+ *   type if recognized\n+ *\n+ * @return\n+ *   port_name field set according to recognized name format.\n+ */\n+void\n+mlx5_translate_port_name(const char *port_name_in,\n+\t\t\t struct mlx5_switch_info *port_info_out)\n+{\n+\tchar pf_c1, pf_c2, vf_c1, vf_c2;\n+\tchar *end;\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 or OFED ver >= 4.6).\n+\t */\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;\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;\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;\n+\t}\n+\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;\n+}\n+\n+#ifdef MLX5_GLUE\n+\n+/**\n+ * Suffix RTE_EAL_PMD_PATH with \"-glue\".\n+ *\n+ * This function performs a sanity check on RTE_EAL_PMD_PATH before\n+ * suffixing its last component.\n+ *\n+ * @param buf[out]\n+ *   Output buffer, should be large enough otherwise NULL is returned.\n+ * @param size\n+ *   Size of @p out.\n+ *\n+ * @return\n+ *   Pointer to @p buf or @p NULL in case suffix cannot be appended.\n+ */\n+static char *\n+mlx5_glue_path(char *buf, size_t size)\n+{\n+\tstatic const char *const bad[] = { \"/\", \".\", \"..\", NULL };\n+\tconst char *path = RTE_EAL_PMD_PATH;\n+\tsize_t len = strlen(path);\n+\tsize_t off;\n+\tint i;\n+\n+\twhile (len && path[len - 1] == '/')\n+\t\t--len;\n+\tfor (off = len; off && path[off - 1] != '/'; --off)\n+\t\t;\n+\tfor (i = 0; bad[i]; ++i)\n+\t\tif (!strncmp(path + off, bad[i], (int)(len - off)))\n+\t\t\tgoto error;\n+\ti = snprintf(buf, size, \"%.*s-glue\", (int)len, path);\n+\tif (i == -1 || (size_t)i >= size)\n+\t\tgoto error;\n+\treturn buf;\n+error:\n+\tRTE_LOG(ERR, PMD, \"unable to append \\\"-glue\\\" to last component of\"\n+\t\t\" RTE_EAL_PMD_PATH (\\\"\" RTE_EAL_PMD_PATH \"\\\"), please\"\n+\t\t\" re-configure DPDK\");\n+\treturn NULL;\n+}\n+\n+static int\n+mlx5_glue_dlopen(void)\n+{\n+\tchar glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof(\"-glue\")];\n+\tvoid *handle = NULL;\n+\n+\tchar const *path[] = {\n+\t\t/*\n+\t\t * A basic security check is necessary before trusting\n+\t\t * MLX5_GLUE_PATH, which may override RTE_EAL_PMD_PATH.\n+\t\t */\n+\t\t(geteuid() == getuid() && getegid() == getgid() ?\n+\t\t getenv(\"MLX5_GLUE_PATH\") : NULL),\n+\t\t/*\n+\t\t * When RTE_EAL_PMD_PATH is set, use its glue-suffixed\n+\t\t * variant, otherwise let dlopen() look up libraries on its\n+\t\t * own.\n+\t\t */\n+\t\t(*RTE_EAL_PMD_PATH ?\n+\t\t mlx5_glue_path(glue_path, sizeof(glue_path)) : \"\"),\n+\t};\n+\tunsigned int i = 0;\n+\tvoid **sym;\n+\tconst char *dlmsg;\n+\n+\twhile (!handle && i != RTE_DIM(path)) {\n+\t\tconst char *end;\n+\t\tsize_t len;\n+\t\tint ret;\n+\n+\t\tif (!path[i]) {\n+\t\t\t++i;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tend = strpbrk(path[i], \":;\");\n+\t\tif (!end)\n+\t\t\tend = path[i] + strlen(path[i]);\n+\t\tlen = end - path[i];\n+\t\tret = 0;\n+\t\tdo {\n+\t\t\tchar name[ret + 1];\n+\n+\t\t\tret = snprintf(name, sizeof(name), \"%.*s%s\" MLX5_GLUE,\n+\t\t\t\t       (int)len, path[i],\n+\t\t\t\t       (!len || *(end - 1) == '/') ? \"\" : \"/\");\n+\t\t\tif (ret == -1)\n+\t\t\t\tbreak;\n+\t\t\tif (sizeof(name) != (size_t)ret + 1)\n+\t\t\t\tcontinue;\n+\t\t\tDRV_LOG(DEBUG, \"Looking for rdma-core glue as \"\n+\t\t\t\t\"\\\"%s\\\"\", name);\n+\t\t\thandle = dlopen(name, RTLD_LAZY);\n+\t\t\tbreak;\n+\t\t} while (1);\n+\t\tpath[i] = end + 1;\n+\t\tif (!*end)\n+\t\t\t++i;\n+\t}\n+\tif (!handle) {\n+\t\trte_errno = EINVAL;\n+\t\tdlmsg = dlerror();\n+\t\tif (dlmsg)\n+\t\t\tDRV_LOG(WARNING, \"Cannot load glue library: %s\", dlmsg);\n+\t\tgoto glue_error;\n+\t}\n+\tsym = dlsym(handle, \"mlx5_glue\");\n+\tif (!sym || !*sym) {\n+\t\trte_errno = EINVAL;\n+\t\tdlmsg = dlerror();\n+\t\tif (dlmsg)\n+\t\t\tDRV_LOG(ERR, \"Cannot resolve glue symbol: %s\", dlmsg);\n+\t\tgoto glue_error;\n+\t}\n+\tmlx5_glue = *sym;\n+\treturn 0;\n+\n+glue_error:\n+\tif (handle)\n+\t\tdlclose(handle);\n+\treturn -1;\n+}\n+\n+#endif\n+\n+/**\n+ * Initialization routine for run-time dependency on rdma-core.\n+ */\n+void\n+mlx5_glue_constructor(void)\n+{\n+\t/*\n+\t * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use\n+\t * huge pages. Calling ibv_fork_init() during init allows\n+\t * applications to use fork() safely for purposes other than\n+\t * using this PMD, which is not supported in forked processes.\n+\t */\n+\tsetenv(\"RDMAV_HUGEPAGES_SAFE\", \"1\", 1);\n+\t/* Match the size of Rx completion entry to the size of a cacheline. */\n+\tif (RTE_CACHE_LINE_SIZE == 128)\n+\t\tsetenv(\"MLX5_CQE_SIZE\", \"128\", 0);\n+\t/*\n+\t * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to\n+\t * cleanup all the Verbs resources even when the device was removed.\n+\t */\n+\tsetenv(\"MLX5_DEVICE_FATAL_CLEANUP\", \"1\", 1);\n+\n+#ifdef MLX5_GLUE\n+\tif (mlx5_glue_dlopen() != 0)\n+\t\tgoto glue_error;\n+#endif\n+\n+#ifdef RTE_LIBRTE_MLX5_DEBUG\n+\t/* Glue structure must not contain any NULL pointers. */\n+\t{\n+\t\tunsigned int i;\n+\n+\t\tfor (i = 0; i != sizeof(*mlx5_glue) / sizeof(void *); ++i)\n+\t\t\tMLX5_ASSERT(((const void *const *)mlx5_glue)[i]);\n+\t}\n+#endif\n+\tif (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) {\n+\t\trte_errno = EINVAL;\n+\t\tDRV_LOG(ERR, \"rdma-core glue \\\"%s\\\" mismatch: \\\"%s\\\" is \"\n+\t\t\t\"required\", mlx5_glue->version, MLX5_GLUE_VERSION);\n+\t\tgoto glue_error;\n+\t}\n+\tmlx5_glue->fork_init();\n+\treturn;\n+\n+glue_error:\n+\tDRV_LOG(WARNING, \"Cannot initialize MLX5 common due to missing\"\n+\t\t\" run-time dependency on rdma-core libraries (libibverbs,\"\n+\t\t\" libmlx5)\");\n+\tmlx5_glue = NULL;\n+}\ndiff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c\nindex 1c77763..db94d4a 100644\n--- a/drivers/common/mlx5/mlx5_common.c\n+++ b/drivers/common/mlx5/mlx5_common.c\n@@ -5,16 +5,11 @@\n #include <unistd.h>\n #include <string.h>\n #include <stdio.h>\n-#ifdef RTE_IBVERBS_LINK_DLOPEN\n-#include <dlfcn.h>\n-#endif\n \n #include <rte_errno.h>\n \n #include \"mlx5_common.h\"\n #include \"mlx5_common_utils.h\"\n-#include \"mlx5_glue.h\"\n-\n \n int mlx5_common_logtype;\n \n@@ -24,58 +19,6 @@ const struct mlx5_glue *mlx5_glue;\n \n uint8_t haswell_broadwell_cpu;\n \n-/**\n- * Get PCI information by sysfs device path.\n- *\n- * @param dev_path\n- *   Pointer to device sysfs folder name.\n- * @param[out] pci_addr\n- *   PCI bus address output buffer.\n- *\n- * @return\n- *   0 on success, a negative errno value otherwise and rte_errno is set.\n- */\n-int\n-mlx5_dev_to_pci_addr(const char *dev_path,\n-\t\t     struct rte_pci_addr *pci_addr)\n-{\n-\tFILE *file;\n-\tchar line[32];\n-\tMKSTR(path, \"%s/device/uevent\", dev_path);\n-\n-\tfile = fopen(path, \"rb\");\n-\tif (file == NULL) {\n-\t\trte_errno = errno;\n-\t\treturn -rte_errno;\n-\t}\n-\twhile (fgets(line, sizeof(line), file) == line) {\n-\t\tsize_t len = strlen(line);\n-\t\tint ret;\n-\n-\t\t/* Truncate long lines. */\n-\t\tif (len == (sizeof(line) - 1))\n-\t\t\twhile (line[(len - 1)] != '\\n') {\n-\t\t\t\tret = fgetc(file);\n-\t\t\t\tif (ret == EOF)\n-\t\t\t\t\tbreak;\n-\t\t\t\tline[(len - 1)] = ret;\n-\t\t\t}\n-\t\t/* Extract information. */\n-\t\tif (sscanf(line,\n-\t\t\t   \"PCI_SLOT_NAME=\"\n-\t\t\t   \"%\" SCNx32 \":%\" SCNx8 \":%\" SCNx8 \".%\" SCNx8 \"\\n\",\n-\t\t\t   &pci_addr->domain,\n-\t\t\t   &pci_addr->bus,\n-\t\t\t   &pci_addr->devid,\n-\t\t\t   &pci_addr->function) == 4) {\n-\t\t\tret = 0;\n-\t\t\tbreak;\n-\t\t}\n-\t}\n-\tfclose(file);\n-\treturn 0;\n-}\n-\n static int\n mlx5_class_check_handler(__rte_unused const char *key, const char *value,\n \t\t\t void *opaque)\n@@ -112,187 +55,6 @@ mlx5_class_get(struct rte_devargs *devargs)\n \treturn ret;\n }\n \n-/**\n- * Extract port name, as a number, from sysfs or netlink information.\n- *\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 and port name\n- *   type if recognized\n- *\n- * @return\n- *   port_name field set according to recognized name format.\n- */\n-void\n-mlx5_translate_port_name(const char *port_name_in,\n-\t\t\t struct mlx5_switch_info *port_info_out)\n-{\n-\tchar pf_c1, pf_c2, vf_c1, vf_c2;\n-\tchar *end;\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 or OFED ver >= 4.6).\n-\t */\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;\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;\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;\n-\t}\n-\tport_info_out->name_type = MLX5_PHYS_PORT_NAME_TYPE_UNKNOWN;\n-\treturn;\n-}\n-\n-#ifdef MLX5_GLUE\n-\n-/**\n- * Suffix RTE_EAL_PMD_PATH with \"-glue\".\n- *\n- * This function performs a sanity check on RTE_EAL_PMD_PATH before\n- * suffixing its last component.\n- *\n- * @param buf[out]\n- *   Output buffer, should be large enough otherwise NULL is returned.\n- * @param size\n- *   Size of @p out.\n- *\n- * @return\n- *   Pointer to @p buf or @p NULL in case suffix cannot be appended.\n- */\n-static char *\n-mlx5_glue_path(char *buf, size_t size)\n-{\n-\tstatic const char *const bad[] = { \"/\", \".\", \"..\", NULL };\n-\tconst char *path = RTE_EAL_PMD_PATH;\n-\tsize_t len = strlen(path);\n-\tsize_t off;\n-\tint i;\n-\n-\twhile (len && path[len - 1] == '/')\n-\t\t--len;\n-\tfor (off = len; off && path[off - 1] != '/'; --off)\n-\t\t;\n-\tfor (i = 0; bad[i]; ++i)\n-\t\tif (!strncmp(path + off, bad[i], (int)(len - off)))\n-\t\t\tgoto error;\n-\ti = snprintf(buf, size, \"%.*s-glue\", (int)len, path);\n-\tif (i == -1 || (size_t)i >= size)\n-\t\tgoto error;\n-\treturn buf;\n-error:\n-\tRTE_LOG(ERR, PMD, \"unable to append \\\"-glue\\\" to last component of\"\n-\t\t\" RTE_EAL_PMD_PATH (\\\"\" RTE_EAL_PMD_PATH \"\\\"), please\"\n-\t\t\" re-configure DPDK\");\n-\treturn NULL;\n-}\n-\n-static int\n-mlx5_glue_dlopen(void)\n-{\n-\tchar glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof(\"-glue\")];\n-\tvoid *handle = NULL;\n-\n-\tconst char *path[] = {\n-\t\t/*\n-\t\t * A basic security check is necessary before trusting\n-\t\t * MLX5_GLUE_PATH, which may override RTE_EAL_PMD_PATH.\n-\t\t */\n-\t\t(geteuid() == getuid() && getegid() == getgid() ?\n-\t\t getenv(\"MLX5_GLUE_PATH\") : NULL),\n-\t\t/*\n-\t\t * When RTE_EAL_PMD_PATH is set, use its glue-suffixed\n-\t\t * variant, otherwise let dlopen() look up libraries on its\n-\t\t * own.\n-\t\t */\n-\t\t(*RTE_EAL_PMD_PATH ?\n-\t\t mlx5_glue_path(glue_path, sizeof(glue_path)) : \"\"),\n-\t};\n-\tunsigned int i = 0;\n-\tvoid **sym;\n-\tconst char *dlmsg;\n-\n-\twhile (!handle && i != RTE_DIM(path)) {\n-\t\tconst char *end;\n-\t\tsize_t len;\n-\t\tint ret;\n-\n-\t\tif (!path[i]) {\n-\t\t\t++i;\n-\t\t\tcontinue;\n-\t\t}\n-\t\tend = strpbrk(path[i], \":;\");\n-\t\tif (!end)\n-\t\t\tend = path[i] + strlen(path[i]);\n-\t\tlen = end - path[i];\n-\t\tret = 0;\n-\t\tdo {\n-\t\t\tchar name[ret + 1];\n-\n-\t\t\tret = snprintf(name, sizeof(name), \"%.*s%s\" MLX5_GLUE,\n-\t\t\t\t       (int)len, path[i],\n-\t\t\t\t       (!len || *(end - 1) == '/') ? \"\" : \"/\");\n-\t\t\tif (ret == -1)\n-\t\t\t\tbreak;\n-\t\t\tif (sizeof(name) != (size_t)ret + 1)\n-\t\t\t\tcontinue;\n-\t\t\tDRV_LOG(DEBUG, \"Looking for rdma-core glue as \"\n-\t\t\t\t\"\\\"%s\\\"\", name);\n-\t\t\thandle = dlopen(name, RTLD_LAZY);\n-\t\t\tbreak;\n-\t\t} while (1);\n-\t\tpath[i] = end + 1;\n-\t\tif (!*end)\n-\t\t\t++i;\n-\t}\n-\tif (!handle) {\n-\t\trte_errno = EINVAL;\n-\t\tdlmsg = dlerror();\n-\t\tif (dlmsg)\n-\t\t\tDRV_LOG(WARNING, \"Cannot load glue library: %s\", dlmsg);\n-\t\tgoto glue_error;\n-\t}\n-\tsym = dlsym(handle, \"mlx5_glue\");\n-\tif (!sym || !*sym) {\n-\t\trte_errno = EINVAL;\n-\t\tdlmsg = dlerror();\n-\t\tif (dlmsg)\n-\t\t\tDRV_LOG(ERR, \"Cannot resolve glue symbol: %s\", dlmsg);\n-\t\tgoto glue_error;\n-\t}\n-\tmlx5_glue = *sym;\n-\treturn 0;\n-\n-glue_error:\n-\tif (handle)\n-\t\tdlclose(handle);\n-\treturn -1;\n-}\n-\n-#endif\n \n /* In case this is an x86_64 intel processor to check if\n  * we should use relaxed ordering.\n@@ -325,55 +87,11 @@ RTE_INIT_PRIO(mlx5_log_init, LOG)\n }\n \n /**\n- * Initialization routine for run-time dependency on rdma-core.\n+ * Initialization routine for run-time dependency on glue library.\n  */\n RTE_INIT_PRIO(mlx5_glue_init, CLASS)\n {\n-\t/*\n-\t * RDMAV_HUGEPAGES_SAFE tells ibv_fork_init() we intend to use\n-\t * huge pages. Calling ibv_fork_init() during init allows\n-\t * applications to use fork() safely for purposes other than\n-\t * using this PMD, which is not supported in forked processes.\n-\t */\n-\tsetenv(\"RDMAV_HUGEPAGES_SAFE\", \"1\", 1);\n-\t/* Match the size of Rx completion entry to the size of a cacheline. */\n-\tif (RTE_CACHE_LINE_SIZE == 128)\n-\t\tsetenv(\"MLX5_CQE_SIZE\", \"128\", 0);\n-\t/*\n-\t * MLX5_DEVICE_FATAL_CLEANUP tells ibv_destroy functions to\n-\t * cleanup all the Verbs resources even when the device was removed.\n-\t */\n-\tsetenv(\"MLX5_DEVICE_FATAL_CLEANUP\", \"1\", 1);\n-\n-#ifdef MLX5_GLUE\n-\tif (mlx5_glue_dlopen() != 0)\n-\t\tgoto glue_error;\n-#endif\n-\n-#ifdef RTE_LIBRTE_MLX5_DEBUG\n-\t/* Glue structure must not contain any NULL pointers. */\n-\t{\n-\t\tunsigned int i;\n-\n-\t\tfor (i = 0; i != sizeof(*mlx5_glue) / sizeof(void *); ++i)\n-\t\t\tMLX5_ASSERT(((const void *const *)mlx5_glue)[i]);\n-\t}\n-#endif\n-\tif (strcmp(mlx5_glue->version, MLX5_GLUE_VERSION)) {\n-\t\trte_errno = EINVAL;\n-\t\tDRV_LOG(ERR, \"rdma-core glue \\\"%s\\\" mismatch: \\\"%s\\\" is \"\n-\t\t\t\"required\", mlx5_glue->version, MLX5_GLUE_VERSION);\n-\t\tgoto glue_error;\n-\t}\n-\tmlx5_glue->fork_init();\n-\treturn;\n-\n-glue_error:\n-\tDRV_LOG(WARNING, \"Cannot initialize MLX5 common due to missing\"\n-\t\t\" run-time dependency on rdma-core libraries (libibverbs,\"\n-\t\t\" libmlx5)\");\n-\tmlx5_glue = NULL;\n-\treturn;\n+\tmlx5_glue_constructor();\n }\n \n /**\ndiff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h\nindex 8cd3ea5..8e679c6 100644\n--- a/drivers/common/mlx5/mlx5_common.h\n+++ b/drivers/common/mlx5/mlx5_common.h\n@@ -212,6 +212,7 @@ enum mlx5_class mlx5_class_get(struct rte_devargs *devargs);\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+void mlx5_glue_constructor(void);\n \n extern uint8_t haswell_broadwell_cpu;\n \n",
    "prefixes": [
        "v2",
        "3/3"
    ]
}