get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64810,
    "url": "http://patchwork.dpdk.org/api/patches/64810/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1579179869-32508-3-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": "<1579179869-32508-3-git-send-email-viacheslavo@mellanox.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1579179869-32508-3-git-send-email-viacheslavo@mellanox.com",
    "date": "2020-01-16T13:04:26",
    "name": "[v4,2/5] mbuf: detach mbuf with pinned external buffer",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1b470ab8f86885da962495ffaf50c0b47ad868f7",
    "submitter": {
        "id": 1102,
        "url": "http://patchwork.dpdk.org/api/people/1102/?format=api",
        "name": "Slava Ovsiienko",
        "email": "viacheslavo@mellanox.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1579179869-32508-3-git-send-email-viacheslavo@mellanox.com/mbox/",
    "series": [
        {
            "id": 8174,
            "url": "http://patchwork.dpdk.org/api/series/8174/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=8174",
            "date": "2020-01-16T13:04:25",
            "name": "mbuf: detach mbuf with pinned external buffer",
            "version": 4,
            "mbox": "http://patchwork.dpdk.org/series/8174/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/64810/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/64810/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 0432AA0352;\n\tThu, 16 Jan 2020 14:05:00 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B8ECA1D534;\n\tThu, 16 Jan 2020 14:04:48 +0100 (CET)",
            "from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])\n by dpdk.org (Postfix) with ESMTP id B5E351D533\n for <dev@dpdk.org>; Thu, 16 Jan 2020 14:04:46 +0100 (CET)",
            "from Internal Mail-Server by MTLPINE1 (envelope-from\n viacheslavo@mellanox.com)\n with ESMTPS (AES256-SHA encrypted); 16 Jan 2020 15:04:42 +0200",
            "from pegasus11.mtr.labs.mlnx (pegasus11.mtr.labs.mlnx\n [10.210.16.104])\n by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 00GD4fsA008252;\n Thu, 16 Jan 2020 15:04:41 +0200",
            "from pegasus11.mtr.labs.mlnx (localhost [127.0.0.1])\n by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id 00GD4fmp000859;\n Thu, 16 Jan 2020 13:04:41 GMT",
            "(from viacheslavo@localhost)\n by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id 00GD4f8h000858;\n Thu, 16 Jan 2020 13:04:41 GMT"
        ],
        "X-Authentication-Warning": "pegasus11.mtr.labs.mlnx: viacheslavo set sender to\n viacheslavo@mellanox.com using -f",
        "From": "Viacheslav Ovsiienko <viacheslavo@mellanox.com>",
        "To": "dev@dpdk.org",
        "Cc": "matan@mellanox.com, rasland@mellanox.com, orika@mellanox.com,\n shahafs@mellanox.com, olivier.matz@6wind.com,\n stephen@networkplumber.org, thomas@mellanox.net",
        "Date": "Thu, 16 Jan 2020 13:04:26 +0000",
        "Message-Id": "<1579179869-32508-3-git-send-email-viacheslavo@mellanox.com>",
        "X-Mailer": "git-send-email 1.8.3.1",
        "In-Reply-To": "<1579179869-32508-1-git-send-email-viacheslavo@mellanox.com>",
        "References": "<20191118094938.192850-1-shahafs@mellanox.com>\n <1579179869-32508-1-git-send-email-viacheslavo@mellanox.com>",
        "Subject": "[dpdk-dev] [PATCH v4 2/5] mbuf: detach mbuf with pinned external\n\tbuffer",
        "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": "Update detach routine to check the mbuf pool type.\nIntroduce the special internal version of detach routine to handle\nthe special case of pinned external bufferon mbuf freeing.\n\nSigned-off-by: Shahaf Shuler <shahafs@mellanox.com>\nSigned-off-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>\n---\n lib/librte_mbuf/rte_mbuf.h | 95 ++++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 88 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex e9f6fa9..52d57d1 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -323,6 +323,24 @@ struct rte_pktmbuf_pool_private {\n \treturn mbp_priv->flags;\n }\n \n+/**\n+ * When set pktmbuf mempool will hold only mbufs with pinned external\n+ * buffer. The external buffer will be attached on the mbuf at the\n+ * memory pool creation and will never be detached by the mbuf free calls.\n+ * mbuf should not contain any room for data after the mbuf structure.\n+ */\n+#define RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF (1 << 0)\n+\n+/**\n+ * Returns non zero if given mbuf has an pinned external buffer, or zero\n+ * otherwise. The pinned external buffer is allocated at pool creation\n+ * time and should not be freed on mbuf freeing.\n+ *\n+ * External buffer is a user-provided anonymous buffer.\n+ */\n+#define RTE_MBUF_HAS_PINNED_EXTBUF(mb) \\\n+\t(rte_pktmbuf_priv_flags(mb->pool) & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF)\n+\n #ifdef RTE_LIBRTE_MBUF_DEBUG\n \n /**  check mbuf type in debug mode */\n@@ -588,7 +606,8 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp)\n static __rte_always_inline void\n rte_mbuf_raw_free(struct rte_mbuf *m)\n {\n-\tRTE_ASSERT(RTE_MBUF_DIRECT(m));\n+\tRTE_ASSERT(!RTE_MBUF_CLONED(m) &&\n+\t\t  (!RTE_MBUF_HAS_EXTBUF(m) || RTE_MBUF_HAS_PINNED_EXTBUF(m)));\n \tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);\n \tRTE_ASSERT(m->next == NULL);\n \tRTE_ASSERT(m->nb_segs == 1);\n@@ -794,7 +813,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m)\n \tm->nb_segs = 1;\n \tm->port = MBUF_INVALID_PORT;\n \n-\tm->ol_flags = 0;\n+\tm->ol_flags &= EXT_ATTACHED_MBUF;\n \tm->packet_type = 0;\n \trte_pktmbuf_reset_headroom(m);\n \n@@ -1158,11 +1177,26 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n \tuint32_t mbuf_size, buf_len;\n \tuint16_t priv_size;\n \n-\tif (RTE_MBUF_HAS_EXTBUF(m))\n+\tif (RTE_MBUF_HAS_EXTBUF(m)) {\n+\t\t/*\n+\t\t * The mbuf has the external attached buffer,\n+\t\t * we should check the type of the memory pool where\n+\t\t * the mbuf was allocated from to detect the pinned\n+\t\t * external buffer.\n+\t\t */\n+\t\tuint32_t flags = rte_pktmbuf_priv_flags(mp);\n+\n+\t\tif (flags & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF) {\n+\t\t\t/*\n+\t\t\t * The pinned external buffer should not be\n+\t\t\t * detached from its backing mbuf, just exit.\n+\t\t\t */\n+\t\t\treturn;\n+\t\t}\n \t\t__rte_pktmbuf_free_extbuf(m);\n-\telse\n+\t} else {\n \t\t__rte_pktmbuf_free_direct(m);\n-\n+\t}\n \tpriv_size = rte_pktmbuf_priv_size(mp);\n \tmbuf_size = (uint32_t)(sizeof(struct rte_mbuf) + priv_size);\n \tbuf_len = rte_pktmbuf_data_room_size(mp);\n@@ -1177,6 +1211,51 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n }\n \n /**\n+ * @internal version of rte_pktmbuf_detach() to be used on mbuf freeing.\n+ * For indirect and regular (not pinned) external mbufs the standard\n+ * rte_pktmbuf is involved, for pinned external buffer mbufs the special\n+ * handling is performed:\n+ *\n+ *  - return zero if reference counter in shinfo is one. It means there is\n+ *  no more references to this pinned buffer and mbuf can be returned to\n+ *  the pool\n+ *\n+ *  - otherwise (if reference counter is not one), decrement reference\n+ *  counter and return non-zero value to prevent freeing the backing mbuf.\n+ *\n+ * Returns non zero if mbuf should not be freed.\n+ */\n+static inline uint16_t __rte_pktmbuf_detach_on_free(struct rte_mbuf *m)\n+{\n+\tif (RTE_MBUF_HAS_EXTBUF(m)) {\n+\t\tuint32_t flags = rte_pktmbuf_priv_flags(m->pool);\n+\n+\t\tif (flags & RTE_PKTMBUF_POOL_F_PINNED_EXT_BUF) {\n+\t\t\tstruct rte_mbuf_ext_shared_info *shinfo;\n+\n+\t\t\t/* Clear flags, mbuf is being freed. */\n+\t\t\tm->ol_flags = EXT_ATTACHED_MBUF;\n+\t\t\tshinfo = m->shinfo;\n+\t\t\t/* Optimize for performance - do not dec/reinit */\n+\t\t\tif (likely(rte_mbuf_ext_refcnt_read(shinfo) == 1))\n+\t\t\t\treturn 0;\n+\t\t\t/*\n+\t\t\t * Direct usage of add primitive to avoid\n+\t\t\t * duplication of comparing with one.\n+\t\t\t */\n+\t\t\tif (likely(rte_atomic16_add_return\n+\t\t\t\t\t(&shinfo->refcnt_atomic, -1)))\n+\t\t\t\treturn 1;\n+\t\t\t/* Reinitialize counter before mbuf freeing. */\n+\t\t\trte_mbuf_ext_refcnt_set(shinfo, 1);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\trte_pktmbuf_detach(m);\n+\treturn 0;\n+}\n+\n+/**\n  * Decrease reference counter and unlink a mbuf segment\n  *\n  * This function does the same than a free, except that it does not\n@@ -1198,7 +1277,8 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n \tif (likely(rte_mbuf_refcnt_read(m) == 1)) {\n \n \t\tif (!RTE_MBUF_DIRECT(m))\n-\t\t\trte_pktmbuf_detach(m);\n+\t\t\tif (__rte_pktmbuf_detach_on_free(m))\n+\t\t\t\treturn NULL;\n \n \t\tif (m->next != NULL) {\n \t\t\tm->next = NULL;\n@@ -1210,7 +1290,8 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m)\n \t} else if (__rte_mbuf_refcnt_update(m, -1) == 0) {\n \n \t\tif (!RTE_MBUF_DIRECT(m))\n-\t\t\trte_pktmbuf_detach(m);\n+\t\t\tif (__rte_pktmbuf_detach_on_free(m))\n+\t\t\t\treturn NULL;\n \n \t\tif (m->next != NULL) {\n \t\t\tm->next = NULL;\n",
    "prefixes": [
        "v4",
        "2/5"
    ]
}