Show a patch.

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

{
    "id": 44084,
    "url": "http://patches.dpdk.org/api/patches/44084/",
    "web_url": "http://patches.dpdk.org/patch/44084/",
    "project": {
        "id": 1,
        "url": "http://patches.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"
    },
    "msgid": "<20180831092038.23051-5-adrien.mazarguil@6wind.com>",
    "date": "2018-08-31T09:57:34",
    "name": "[4/8] net/mlx5: enhance TC flow rule send/ack function",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b4adbff77a2d8f5a45151f7b400f437e01c6843c",
    "submitter": {
        "id": 165,
        "url": "http://patches.dpdk.org/api/people/165/",
        "name": "Adrien Mazarguil",
        "email": "adrien.mazarguil@6wind.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/patch/44084/mbox/",
    "series": [
        {
            "id": 1126,
            "url": "http://patches.dpdk.org/api/series/1126/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1126",
            "date": "2018-08-31T09:57:25",
            "name": "net/mlx5: add switch offload for VXLAN encap/decap",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1126/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44084/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44084/checks/",
    "tags": {},
    "headers": {
        "X-Mailman-Version": "2.1.15",
        "In-Reply-To": "<20180831092038.23051-1-adrien.mazarguil@6wind.com>",
        "Errors-To": "dev-bounces@dpdk.org",
        "X-Mailer": "git-send-email 2.11.0",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 03F9D4F94;\n\tFri, 31 Aug 2018 11:57:54 +0200 (CEST)",
            "from mail-wm0-f68.google.com (mail-wm0-f68.google.com\n\t[74.125.82.68]) by dpdk.org (Postfix) with ESMTP id CD5FC4CC3\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 11:57:50 +0200 (CEST)",
            "by mail-wm0-f68.google.com with SMTP id r1-v6so800896wmh.0\n\tfor <dev@dpdk.org>; Fri, 31 Aug 2018 02:57:50 -0700 (PDT)",
            "from 6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\tr1-v6sm4995965wmg.9.2018.08.31.02.57.49\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 31 Aug 2018 02:57:49 -0700 (PDT)"
        ],
        "References": "<20180831092038.23051-1-adrien.mazarguil@6wind.com>",
        "X-Google-Smtp-Source": "ANB0VdbN0VHaYcr4h1QzzlVtrivYwvnH6vCf/BZ1+tNMwO4il+2F06Fii8W8MOuxH18WBdb7ao+BOQ==",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to;\n\tbh=cj0hMPuuZ8uy7+SYxlK6j9pIQLbCY1Yk/imHufSRXCs=;\n\tb=kW1QA3mudUSbjpJRAvkTsVkGoPLQbmx2KM2FnQoZ/vpBZ1eoW4G9PKZE7+CB0Zqszh\n\t9Gk5afieJR/dKlJda0kr0Pa4hM8+1dv5N0x89I26VXVJL5GgOfzYqWgWn2pR5kG9kXMu\n\twKuIqTQHC1OkA3QMFZcNLmWuLkLFXYToOxohZL6OyqVAvuRrSi/dr27hg7lolpABSYaU\n\tBdA39ftkDLZcngn4rDtRWzvrOb1WW1csbXmdXnYklnC9FOicpMimR/zr5bLbL/zsUhYT\n\tDDHwnzyQg9aQ26SqovUg8KEGIsZ/289kPyYwzzJfwqbcWje/Cn1Wp2MHoNyZzKlzi0/8\n\tWJag==",
        "MIME-Version": "1.0",
        "X-Received": "by 2002:a1c:889:: with SMTP id\n\t131-v6mr4091422wmi.142.1535709470530; \n\tFri, 31 Aug 2018 02:57:50 -0700 (PDT)",
        "Message-ID": "<20180831092038.23051-5-adrien.mazarguil@6wind.com>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to;\n\tbh=cj0hMPuuZ8uy7+SYxlK6j9pIQLbCY1Yk/imHufSRXCs=;\n\tb=UOS6lNbi33e+LV3ODN420rZn5/iPLMKeXS2xxfMWcvP9ubn+PtqwyfK0NQ4lVBx4NU\n\tyxnB2tMbkZ1pexcv+JSqHH/VMYtrwuyKfP/F8Jrln85rxQGkT5D00vZ0RKeXY1xJB/63\n\tTm5ZeFDvfGMaQZ12f3CZ+Sls+wgCtzKSBZarM02BCZJvFH7aDPF8cEJhx7Pwg1RdnxTD\n\tk9g9HAfOdfthHXEvwDInNXEOxZLHnUkcjO8GQGEbY96PHneaYH+pKe8Lo8CSpikqat2k\n\tjWHYt/82+9HSXjZA4OIAMqSDnp1suSbZtnamCVrO6tCToYMsMQNKDyWTZNC+ryKZyLc6\n\thgLw==",
        "Delivered-To": "patchwork@dpdk.org",
        "Precedence": "list",
        "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "X-Original-To": "patchwork@dpdk.org",
        "Content-Type": "text/plain; charset=us-ascii",
        "Content-Disposition": "inline",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "To": "Shahaf Shuler <shahafs@mellanox.com>, Yongseok Koh <yskoh@mellanox.com>, \n\tSlava Ovsiienko <viacheslavo@mellanox.com>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "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>",
        "Date": "Fri, 31 Aug 2018 11:57:34 +0200",
        "X-Gm-Message-State": "APzg51DvNx1De3F61xcDpBcD8m6eWx0cc6EI7+Bl4Wv4DUB9GWD6Sdqm\n\tYXZ4q84E69hPs2OG0rYxamP+/w==",
        "Cc": "dev@dpdk.org",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-BeenThere": "dev@dpdk.org",
        "Subject": "[dpdk-dev] [PATCH 4/8] net/mlx5: enhance TC flow rule send/ack\n\tfunction"
    },
    "content": "A callback parameter to process replies will be useful for subsequent work\nin this area. It implies the following:\n\n- Replies may be much larger than requests. In fact their size cannot\n  really be known in advance. Using MNL_SOCKET_BUFFER_SIZE (at least 8192\n  bytes) is the recommended approach to make truncation less likely (look\n  for NLMSG_GOODSIZE in Linux).\n\n- Multipart replies are made of several messages. A loop is needed to\n  process these.\n\n- In case of truncated message (since one cannot really be sure),\n  its remaining parts must be flushed to prevent their reception by\n  subsequent queries.\n\n- Using rte_get_tsc_cycles() instead of random() for message sequence\n  numbers is faster yet unlikely to pick the same number twice in a row.\n\n- mlx5_nl_flow_init() can be simplified since the query message is never\n  written over (it was already the case actually).\n\nSigned-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\n---\n drivers/net/mlx5/mlx5_nl_flow.c | 73 ++++++++++++++++++++++++------------\n 1 file changed, 48 insertions(+), 25 deletions(-)",
    "diff": "diff --git a/drivers/net/mlx5/mlx5_nl_flow.c b/drivers/net/mlx5/mlx5_nl_flow.c\nindex 9ea2a1b55..e720728b7 100644\n--- a/drivers/net/mlx5/mlx5_nl_flow.c\n+++ b/drivers/net/mlx5/mlx5_nl_flow.c\n@@ -22,6 +22,7 @@\n #include <sys/socket.h>\n \n #include <rte_byteorder.h>\n+#include <rte_cycles.h>\n #include <rte_errno.h>\n #include <rte_ether.h>\n #include <rte_flow.h>\n@@ -1050,38 +1051,63 @@ mlx5_nl_flow_brand(void *buf, uint32_t handle)\n }\n \n /**\n- * Send Netlink message with acknowledgment.\n+ * Send Netlink message with acknowledgment and process reply.\n  *\n  * @param nl\n  *   Libmnl socket to use.\n  * @param nlh\n- *   Message to send. This function always raises the NLM_F_ACK flag before\n- *   sending.\n+ *   Message to send. This function always raises the NLM_F_ACK flag and\n+ *   sets its sequence number before sending.\n+ * @param cb\n+ *   Callback handler for received message.\n+ * @param arg\n+ *   Data pointer for callback handler.\n  *\n  * @return\n  *   0 on success, a negative errno value otherwise and rte_errno is set.\n  */\n static int\n-mlx5_nl_flow_nl_ack(struct mnl_socket *nl, struct nlmsghdr *nlh)\n+mlx5_nl_flow_chat(struct mnl_socket *nl, struct nlmsghdr *nlh,\n+\t\t  mnl_cb_t cb, void *arg)\n {\n \talignas(struct nlmsghdr)\n-\tuint8_t ans[mnl_nlmsg_size(sizeof(struct nlmsgerr)) +\n-\t\t    nlh->nlmsg_len - sizeof(*nlh)];\n-\tuint32_t seq = random();\n+\tuint8_t ans[MNL_SOCKET_BUFFER_SIZE];\n+\tunsigned int portid = mnl_socket_get_portid(nl);\n+\tuint32_t seq = rte_get_tsc_cycles();\n+\tint err = 0;\n \tint ret;\n \n \tnlh->nlmsg_flags |= NLM_F_ACK;\n \tnlh->nlmsg_seq = seq;\n \tret = mnl_socket_sendto(nl, nlh, nlh->nlmsg_len);\n-\tif (ret != -1)\n+\tnlh = (void *)ans;\n+\t/*\n+\t * The following loop postpones non-fatal errors until multipart\n+\t * messages are complete.\n+\t */\n+\twhile (ret > 0) {\n \t\tret = mnl_socket_recvfrom(nl, ans, sizeof(ans));\n-\tif (ret != -1)\n-\t\tret = mnl_cb_run\n-\t\t\t(ans, ret, seq, mnl_socket_get_portid(nl), NULL, NULL);\n-\tif (!ret)\n+\t\tif (ret == -1) {\n+\t\t\terr = errno;\n+\t\t\tif (err != ENOSPC)\n+\t\t\t\tbreak;\n+\t\t\tret = sizeof(*nlh);\n+\t\t}\n+\t\tif (!err) {\n+\t\t\tret = mnl_cb_run(nlh, ret, seq, portid, cb, arg);\n+\t\t\tif (ret < 0)\n+\t\t\t\terr = -ret;\n+\t\t}\n+\t\tif (!(nlh->nlmsg_flags & NLM_F_MULTI) ||\n+\t\t    nlh->nlmsg_type == NLMSG_DONE)\n+\t\t\tret = -err;\n+\t\telse\n+\t\t\tret = 1;\n+\t}\n+\tif (!err)\n \t\treturn 0;\n-\trte_errno = errno;\n-\treturn -rte_errno;\n+\trte_errno = err;\n+\treturn -err;\n }\n \n /**\n@@ -1105,7 +1131,7 @@ mlx5_nl_flow_create(struct mnl_socket *nl, void *buf,\n \n \tnlh->nlmsg_type = RTM_NEWTFILTER;\n \tnlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;\n-\tif (!mlx5_nl_flow_nl_ack(nl, nlh))\n+\tif (!mlx5_nl_flow_chat(nl, nlh, NULL, NULL))\n \t\treturn 0;\n \treturn rte_flow_error_set\n \t\t(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n@@ -1133,7 +1159,7 @@ mlx5_nl_flow_destroy(struct mnl_socket *nl, void *buf,\n \n \tnlh->nlmsg_type = RTM_DELTFILTER;\n \tnlh->nlmsg_flags = NLM_F_REQUEST;\n-\tif (!mlx5_nl_flow_nl_ack(nl, nlh))\n+\tif (!mlx5_nl_flow_chat(nl, nlh, NULL, NULL))\n \t\treturn 0;\n \treturn rte_flow_error_set\n \t\t(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,\n@@ -1171,23 +1197,20 @@ mlx5_nl_flow_ifindex_init(struct mnl_socket *nl, unsigned int ifindex,\n \ttcm->tcm_ifindex = ifindex;\n \ttcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);\n \ttcm->tcm_parent = TC_H_INGRESS;\n+\tif (!mnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, \"ingress\"))\n+\t\treturn rte_flow_error_set\n+\t\t\t(error, ENOBUFS, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n+\t\t\t NULL, \"netlink: not enough space for message\");\n \t/* Ignore errors when qdisc is already absent. */\n-\tif (mlx5_nl_flow_nl_ack(nl, nlh) &&\n+\tif (mlx5_nl_flow_chat(nl, nlh, NULL, NULL) &&\n \t    rte_errno != EINVAL && rte_errno != ENOENT)\n \t\treturn rte_flow_error_set\n \t\t\t(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n \t\t\t NULL, \"netlink: failed to remove ingress qdisc\");\n \t/* Create fresh ingress qdisc. */\n-\tnlh = mnl_nlmsg_put_header(buf);\n \tnlh->nlmsg_type = RTM_NEWQDISC;\n \tnlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;\n-\ttcm = mnl_nlmsg_put_extra_header(nlh, sizeof(*tcm));\n-\ttcm->tcm_family = AF_UNSPEC;\n-\ttcm->tcm_ifindex = ifindex;\n-\ttcm->tcm_handle = TC_H_MAKE(TC_H_INGRESS, 0);\n-\ttcm->tcm_parent = TC_H_INGRESS;\n-\tmnl_attr_put_strz_check(nlh, sizeof(buf), TCA_KIND, \"ingress\");\n-\tif (mlx5_nl_flow_nl_ack(nl, nlh))\n+\tif (mlx5_nl_flow_chat(nl, nlh, NULL, NULL))\n \t\treturn rte_flow_error_set\n \t\t\t(error, rte_errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED,\n \t\t\t NULL, \"netlink: failed to create ingress qdisc\");\n",
    "prefixes": [
        "4/8"
    ]
}