get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64766,
    "url": "http://patchwork.dpdk.org/api/patches/64766/",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/bb1d6c5a94dc36464caefa2f0260e75df3ae5f11.1579168182.git.jackmin@mellanox.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/",
        "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": "<bb1d6c5a94dc36464caefa2f0260e75df3ae5f11.1579168182.git.jackmin@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/bb1d6c5a94dc36464caefa2f0260e75df3ae5f11.1579168182.git.jackmin@mellanox.com",
    "date": "2020-01-16T10:14:16",
    "name": "[4/5] net/mlx5: add socket server for external tools",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3a252ae929be891df069a89920a716eca946883b",
    "submitter": {
        "id": 1065,
        "url": "http://patchwork.dpdk.org/api/people/1065/",
        "name": "Xiaoyu Min",
        "email": "jackmin@mellanox.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patchwork.dpdk.org/api/users/319/",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@intel.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/bb1d6c5a94dc36464caefa2f0260e75df3ae5f11.1579168182.git.jackmin@mellanox.com/mbox/",
    "series": [
        {
            "id": 8154,
            "url": "http://patchwork.dpdk.org/api/series/8154/",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=8154",
            "date": "2020-01-16T10:14:12",
            "name": "ethdev: add API to dump device internal flow info",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/8154/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/64766/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/64766/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 04E5EA0352;\n\tThu, 16 Jan 2020 11:16:17 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id F18AC1C1FC;\n\tThu, 16 Jan 2020 11:15:51 +0100 (CET)",
            "from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130])\n by dpdk.org (Postfix) with ESMTP id 2A5191C1E6\n for <dev@dpdk.org>; Thu, 16 Jan 2020 11:15:47 +0100 (CET)"
        ],
        "X-Mailman-Version": "2.1.15",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "To": "jerinjacobk@gmail.com, orika@mellanox.com, viacheslavo@mellanox.com,\n matan@mellanox.com, rasland@mellanox.com,\n Shahaf Shuler <shahafs@mellanox.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "References": "<cover.1579168182.git.jackmin@mellanox.com>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Content-Transfer-Encoding": "8bit",
        "Message-Id": "\n <bb1d6c5a94dc36464caefa2f0260e75df3ae5f11.1579168182.git.jackmin@mellanox.com>",
        "Precedence": "list",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH 4/5] net/mlx5: add socket server for external\n\ttools",
        "MIME-Version": "1.0",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Date": "Thu, 16 Jan 2020 12:14:16 +0200",
        "In-Reply-To": "<cover.1579168182.git.jackmin@mellanox.com>",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailer": "git-send-email 2.21.0",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Cc": "dev@dpdk.org,\n\tXueming Li <xuemingl@mellanox.com>",
        "From": "Xiaoyu Min <jackmin@mellanox.com>"
    },
    "content": "From: Xueming Li <xuemingl@mellanox.com>\n\nAdd pmd unix socket server to enable external tool applications to\ntrigger flow dump.\n\nSocket path:\n\t/var/tmp/dpdk_mlx5_<pid>\nSocket format:\n\tio_raw: port_id of uint16\n\tfile: file descriptor of int\n\nSigned-off-by: Xueming Li <xuemingl@mellanox.com>\nSigned-off-by: Xiaoyu Min <jackmin@mellanox.com>\n---\n drivers/net/mlx5/Makefile      |   1 +\n drivers/net/mlx5/meson.build   |   1 +\n drivers/net/mlx5/mlx5.c        |   2 +\n drivers/net/mlx5/mlx5.h        |   5 +\n drivers/net/mlx5/mlx5_socket.c | 227 +++++++++++++++++++++++++++++++++\n 5 files changed, 236 insertions(+)\n create mode 100644 drivers/net/mlx5/mlx5_socket.c",
    "diff": "diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile\nindex 6e5921b292..397e29dcbb 100644\n--- a/drivers/net/mlx5/Makefile\n+++ b/drivers/net/mlx5/Makefile\n@@ -39,6 +39,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mp.c\n SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_nl.c\n SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_devx_cmds.c\n SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_utils.c\n+SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c\n \n ifeq ($(CONFIG_RTE_IBVERBS_LINK_DLOPEN),y)\n INSTALL-$(CONFIG_RTE_LIBRTE_MLX5_PMD)-lib += $(LIB_GLUE)\ndiff --git a/drivers/net/mlx5/meson.build b/drivers/net/mlx5/meson.build\nindex d7ef032afb..cb2fb90495 100644\n--- a/drivers/net/mlx5/meson.build\n+++ b/drivers/net/mlx5/meson.build\n@@ -61,6 +61,7 @@ if build\n \t\t'mlx5_vlan.c',\n \t\t'mlx5_devx_cmds.c',\n \t\t'mlx5_utils.c',\n+\t\t'mlx5_socket.c',\n \t)\n \tif (dpdk_conf.has('RTE_ARCH_X86_64')\n \t\tor dpdk_conf.has('RTE_ARCH_ARM64')\ndiff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c\nindex 50960c91ce..ffee39c1a0 100644\n--- a/drivers/net/mlx5/mlx5.c\n+++ b/drivers/net/mlx5/mlx5.c\n@@ -2954,6 +2954,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,\n \tstruct mlx5_dev_config dev_config;\n \tint ret;\n \n+\tif (rte_eal_process_type() == RTE_PROC_PRIMARY)\n+\t\tmlx5_pmd_socket_init();\n \tret = mlx5_init_once();\n \tif (ret) {\n \t\tDRV_LOG(ERR, \"unable to init PMD global data: %s\",\ndiff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h\nindex 047181b32e..ceb6de821e 100644\n--- a/drivers/net/mlx5/mlx5.h\n+++ b/drivers/net/mlx5/mlx5.h\n@@ -990,6 +990,11 @@ void mlx5_mp_uninit_primary(void);\n int mlx5_mp_init_secondary(void);\n void mlx5_mp_uninit_secondary(void);\n \n+/* mlx5_socket.c */\n+\n+int mlx5_pmd_socket_init(void);\n+void mlx5_pmd_socket_uninit(void);\n+\n /* mlx5_nl.c */\n \n int mlx5_nl_init(int protocol);\ndiff --git a/drivers/net/mlx5/mlx5_socket.c b/drivers/net/mlx5/mlx5_socket.c\nnew file mode 100644\nindex 0000000000..e4c93c4312\n--- /dev/null\n+++ b/drivers/net/mlx5/mlx5_socket.c\n@@ -0,0 +1,227 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright 2019 Mellanox Technologies, Ltd\n+ */\n+\n+#ifndef _GNU_SOURCE\n+#define _GNU_SOURCE\n+#endif\n+\n+#include <sys/types.h>\n+#include <sys/socket.h>\n+#include <sys/un.h>\n+#include <fcntl.h>\n+#include <stdio.h>\n+#include <unistd.h>\n+#include <sys/stat.h>\n+\n+#include \"rte_eal.h\"\n+#include \"mlx5_utils.h\"\n+#include \"mlx5.h\"\n+\n+/* PMD socket service for tools. */\n+\n+int server_socket; /* Unix socket for primary process. */\n+struct rte_intr_handle server_intr_handle; /* Interrupt handler. */\n+\n+static void\n+mlx5_pmd_make_path(struct sockaddr_un *addr, int pid)\n+{\n+\tsnprintf(addr->sun_path, sizeof(addr->sun_path), \"/var/tmp/dpdk_%s_%d\",\n+\t\t MLX5_DRIVER_NAME, pid);\n+}\n+\n+/**\n+ * Handle server pmd socket interrupts.\n+ */\n+static void\n+mlx5_pmd_socket_handle(void *cb __rte_unused)\n+{\n+\tint conn_sock;\n+\tint ret = -1;\n+\tstruct cmsghdr *cmsg = NULL;\n+\tint data;\n+\tchar buf[CMSG_SPACE(sizeof(int))] = { 0 };\n+\tstruct iovec io = {\n+\t\t.iov_base = &data,\n+\t\t.iov_len = sizeof(data),\n+\t};\n+\tstruct msghdr msg = {\n+\t\t.msg_iov = &io,\n+\t\t.msg_iovlen = 1,\n+\t\t.msg_control = buf,\n+\t\t.msg_controllen = sizeof(buf),\n+\t};\n+\tuint16_t port_id;\n+\tint fd;\n+\tFILE *file = NULL;\n+\tstruct rte_eth_dev *dev;\n+\n+\t/* Accept the connection from the client. */\n+\tconn_sock = accept(server_socket, NULL, NULL);\n+\tif (conn_sock < 0) {\n+\t\tDRV_LOG(WARNING, \"connection failed: %s\", strerror(errno));\n+\t\treturn;\n+\t}\n+\tret = recvmsg(conn_sock, &msg, MSG_WAITALL);\n+\tif (ret < 0) {\n+\t\tDRV_LOG(WARNING, \"wrong message received: %s\",\n+\t\t\tstrerror(errno));\n+\t\tgoto error;\n+\t}\n+\t/* Receive file descriptor. */\n+\tcmsg = CMSG_FIRSTHDR(&msg);\n+\tif (cmsg == NULL || cmsg->cmsg_type != SCM_RIGHTS ||\n+\t    cmsg->cmsg_len < sizeof(int)) {\n+\t\tDRV_LOG(WARNING, \"invalid file descriptor message\");\n+\t\tgoto error;\n+\t}\n+\tmemcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));\n+\tfile = fdopen(fd, \"w\");\n+\tif (!file) {\n+\t\tDRV_LOG(WARNING, \"Failed to open file\");\n+\t\tgoto error;\n+\t}\n+\t/* Receive port number. */\n+\tif (msg.msg_iovlen != 1 || msg.msg_iov->iov_len < sizeof(uint16_t)) {\n+\t\tDRV_LOG(WARNING, \"wrong port number message\");\n+\t\tgoto error;\n+\t}\n+\tmemcpy(&port_id, msg.msg_iov->iov_base, sizeof(port_id));\n+\t/* Dump flow. */\n+\tdev = &rte_eth_devices[port_id];\n+\tret = mlx5_flow_dev_dump(dev, file, NULL);\n+\t/* Set-up the ancillary data and reply. */\n+\tmsg.msg_controllen = 0;\n+\tmsg.msg_control = NULL;\n+\tmsg.msg_iovlen = 1;\n+\tmsg.msg_iov = &io;\n+\tdata = -ret;\n+\tio.iov_len = sizeof(data);\n+\tio.iov_base = &data;\n+\tdo {\n+\t\tret = sendmsg(conn_sock, &msg, 0);\n+\t} while (ret < 0 && errno == EINTR);\n+\tif (ret < 0)\n+\t\tDRV_LOG(WARNING, \"failed to send response %s\",\n+\t\t\tstrerror(errno));\n+error:\n+\tif (conn_sock > 0)\n+\t\tclose(conn_sock);\n+\tif (file)\n+\t\tfclose(file);\n+}\n+\n+/**\n+ * Install interrupt handler.\n+ *\n+ * @param dev\n+ *   Pointer to Ethernet device.\n+ * @return\n+ *   0 on success, a negative errno value otherwise.\n+ */\n+static int\n+mlx5_pmd_interrupt_handler_install(void)\n+{\n+\tassert(server_socket);\n+\tserver_intr_handle.fd = server_socket;\n+\tserver_intr_handle.type = RTE_INTR_HANDLE_EXT;\n+\treturn rte_intr_callback_register(&server_intr_handle,\n+\t\t\t\t\t  mlx5_pmd_socket_handle, NULL);\n+}\n+\n+/**\n+ * Uninstall interrupt handler.\n+ */\n+static void\n+mlx5_pmd_interrupt_handler_uninstall(void)\n+{\n+\tif (server_socket) {\n+\t\tmlx5_intr_callback_unregister(&server_intr_handle,\n+\t\t\t\t\t      mlx5_pmd_socket_handle,\n+\t\t\t\t\t      NULL);\n+\t}\n+\tserver_intr_handle.fd = 0;\n+\tserver_intr_handle.type = RTE_INTR_HANDLE_UNKNOWN;\n+}\n+\n+/**\n+ * Initialise the socket to communicate with the secondary process\n+ *\n+ * @param[in] dev\n+ *   Pointer to Ethernet device.\n+ *\n+ * @return\n+ *   0 on success, a negative value otherwise.\n+ */\n+int\n+mlx5_pmd_socket_init(void)\n+{\n+\tstruct sockaddr_un sun = {\n+\t\t.sun_family = AF_UNIX,\n+\t};\n+\tint ret = -1;\n+\tint flags;\n+\n+\tassert(rte_eal_process_type() == RTE_PROC_PRIMARY);\n+\tif (server_socket)\n+\t\treturn 0;\n+\t/*\n+\t * Initialize the socket to communicate with the secondary\n+\t * process.\n+\t */\n+\tret = socket(AF_UNIX, SOCK_STREAM, 0);\n+\tif (ret < 0) {\n+\t\tDRV_LOG(WARNING, \"Failed to open mlx5 socket: %s\",\n+\t\t\tstrerror(errno));\n+\t\tgoto error;\n+\t}\n+\tserver_socket = ret;\n+\tflags = fcntl(server_socket, F_GETFL, 0);\n+\tif (flags == -1)\n+\t\tgoto error;\n+\tret = fcntl(server_socket, F_SETFL, flags | O_NONBLOCK);\n+\tif (ret < 0)\n+\t\tgoto error;\n+\tmlx5_pmd_make_path(&sun, getpid());\n+\tremove(sun.sun_path);\n+\tret = bind(server_socket, (const struct sockaddr *)&sun, sizeof(sun));\n+\tif (ret < 0) {\n+\t\tDRV_LOG(WARNING,\n+\t\t\t\"cannot bind mlx5 socket: %s\", strerror(errno));\n+\t\tgoto close;\n+\t}\n+\tret = listen(server_socket, 0);\n+\tif (ret < 0) {\n+\t\tDRV_LOG(WARNING, \"cannot listen on mlx5 socket: %s\",\n+\t\t\tstrerror(errno));\n+\t\tgoto close;\n+\t}\n+\tif (mlx5_pmd_interrupt_handler_install()) {\n+\t\tDRV_LOG(WARNING, \"cannot register interrupt handler for mlx5 socket: %s\",\n+\t\t\tstrerror(errno));\n+\t\tgoto close;\n+\t}\n+\treturn 0;\n+close:\n+\tremove(sun.sun_path);\n+error:\n+\tclaim_zero(close(server_socket));\n+\tserver_socket = 0;\n+\tDRV_LOG(ERR, \"Cannot initialize socket: %s\", strerror(errno));\n+\treturn -errno;\n+}\n+\n+/**\n+ * Un-Initialize the pmd socket\n+ */\n+void __attribute__((destructor))\n+mlx5_pmd_socket_uninit(void)\n+{\n+\tif (!server_socket)\n+\t\treturn;\n+\tmlx5_pmd_interrupt_handler_uninstall();\n+\tMKSTR(path, \"/var/tmp/dpdk_%s_%d\", MLX5_DRIVER_NAME, getpid());\n+\tclaim_zero(close(server_socket));\n+\tserver_socket = 0;\n+\tclaim_zero(remove(path));\n+}\n",
    "prefixes": [
        "4/5"
    ]
}