get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 967282,
    "url": "http://patchwork.ozlabs.org/api/patches/967282/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180907081848.5438-4-bjorn.topel@gmail.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20180907081848.5438-4-bjorn.topel@gmail.com>",
    "list_archive_url": null,
    "date": "2018-09-07T08:18:47",
    "name": "[v2,3/4] i40e: clean zero-copy XDP Rx ring on shutdown/reset",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b204858553f40aa6df0d64631a52468eb75a36db",
    "submitter": {
        "id": 70569,
        "url": "http://patchwork.ozlabs.org/api/people/70569/?format=api",
        "name": "Björn Töpel",
        "email": "bjorn.topel@gmail.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180907081848.5438-4-bjorn.topel@gmail.com/mbox/",
    "series": [
        {
            "id": 64562,
            "url": "http://patchwork.ozlabs.org/api/series/64562/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=64562",
            "date": "2018-09-07T08:18:44",
            "name": "i40e AF_XDP zero-copy buffer leak fixes",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/64562/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/967282/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/967282/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=gmail.com"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4269b21bZSz9s47\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  7 Sep 2018 18:29:18 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 7CE532EEC0;\n\tFri,  7 Sep 2018 08:29:16 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id UsWxTJxPLdSK; Fri,  7 Sep 2018 08:29:14 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 6A2172EE3D;\n\tFri,  7 Sep 2018 08:29:14 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 2526E1C0180\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  7 Sep 2018 08:29:13 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id E2CDB87F9B\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  7 Sep 2018 08:29:12 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id eKrXCLeYZ7wF for <intel-wired-lan@lists.osuosl.org>;\n\tFri,  7 Sep 2018 08:29:06 +0000 (UTC)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id 972E187DD9\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri,  7 Sep 2018 08:29:05 +0000 (UTC)",
            "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Sep 2018 01:19:34 -0700",
            "from btopel-mobl1.isw.intel.com ([10.103.211.147])\n\tby orsmga001.jf.intel.com with ESMTP; 07 Sep 2018 01:19:24 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "from auto-whitelisted by SQLgrey-1.7.6",
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,341,1531810800\"; d=\"scan'208\";a=\"88438115\"",
        "From": "=?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn.topel@gmail.com>",
        "To": "ast@kernel.org, daniel@iogearbox.net, jeffrey.t.kirsher@intel.com,\n\tintel-wired-lan@lists.osuosl.org, jakub.kicinski@netronome.com",
        "Date": "Fri,  7 Sep 2018 10:18:47 +0200",
        "Message-Id": "<20180907081848.5438-4-bjorn.topel@gmail.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20180907081848.5438-1-bjorn.topel@gmail.com>",
        "References": "<20180907081848.5438-1-bjorn.topel@gmail.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH v2 3/4] i40e: clean zero-copy XDP Rx ring\n\ton shutdown/reset",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.24",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "netdev@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?=\n\t<bjorn.topel@intel.com>, magnus.karlsson@gmail.com,\n\tmagnus.karlsson@intel.com",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "From: Björn Töpel <bjorn.topel@intel.com>\n\nOutstanding Rx descriptors are temporarily stored on a stash/reuse\nqueue. When/if the HW rings comes up again, entries from the stash are\nused to re-populate the ring.\n\nThe latter required some restructuring of the allocation scheme for\nthe AF_XDP zero-copy implementation. There is now a fast, and a slow\nallocation. The \"fast allocation\" is used from the fast-path and\nobtains free buffers from the fill ring and the internal recycle\nmechanism. The \"slow allocation\" is only used in ring setup, and\nobtains buffers from the fill ring and the stash (if any).\n\nSigned-off-by: Björn Töpel <bjorn.topel@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e_txrx.c   |   4 +-\n .../ethernet/intel/i40e/i40e_txrx_common.h    |   1 +\n drivers/net/ethernet/intel/i40e/i40e_xsk.c    | 100 ++++++++++++++++--\n 3 files changed, 96 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\nindex 7f85d4ba8b54..740ea58ba938 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n@@ -1355,8 +1355,10 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)\n \t\trx_ring->skb = NULL;\n \t}\n \n-\tif (rx_ring->xsk_umem)\n+\tif (rx_ring->xsk_umem) {\n+\t\ti40e_xsk_clean_rx_ring(rx_ring);\n \t\tgoto skip_free;\n+\t}\n \n \t/* Free all the Rx ring sk_buffs */\n \tfor (i = 0; i < rx_ring->count; i++) {\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx_common.h b/drivers/net/ethernet/intel/i40e/i40e_txrx_common.h\nindex 29c68b29d36f..8d46acff6f2e 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx_common.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx_common.h\n@@ -87,6 +87,7 @@ static inline void i40e_arm_wb(struct i40e_ring *tx_ring,\n \t}\n }\n \n+void i40e_xsk_clean_rx_ring(struct i40e_ring *rx_ring);\n void i40e_xsk_clean_tx_ring(struct i40e_ring *tx_ring);\n \n #endif /* I40E_TXRX_COMMON_ */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c\nindex 99116277c4d2..e4b62e871afc 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c\n@@ -140,6 +140,7 @@ static void i40e_xsk_umem_dma_unmap(struct i40e_vsi *vsi, struct xdp_umem *umem)\n static int i40e_xsk_umem_enable(struct i40e_vsi *vsi, struct xdp_umem *umem,\n \t\t\t\tu16 qid)\n {\n+\tstruct xdp_umem_fq_reuse *reuseq;\n \tbool if_running;\n \tint err;\n \n@@ -156,6 +157,12 @@ static int i40e_xsk_umem_enable(struct i40e_vsi *vsi, struct xdp_umem *umem,\n \t\t\treturn -EBUSY;\n \t}\n \n+\treuseq = xsk_reuseq_prepare(vsi->rx_rings[0]->count);\n+\tif (!reuseq)\n+\t\treturn -ENOMEM;\n+\n+\txsk_reuseq_free(xsk_reuseq_swap(umem, reuseq));\n+\n \terr = i40e_xsk_umem_dma_map(vsi, umem);\n \tif (err)\n \t\treturn err;\n@@ -353,16 +360,46 @@ static bool i40e_alloc_buffer_zc(struct i40e_ring *rx_ring,\n }\n \n /**\n- * i40e_alloc_rx_buffers_zc - Allocates a number of Rx buffers\n+ * i40e_alloc_buffer_slow_zc - Allocates an i40e_rx_buffer\n  * @rx_ring: Rx ring\n- * @count: The number of buffers to allocate\n+ * @bi: Rx buffer to populate\n  *\n- * This function allocates a number of Rx buffers and places them on\n- * the Rx ring.\n+ * This function allocates an Rx buffer. The buffer can come from fill\n+ * queue, or via the reuse queue.\n  *\n  * Returns true for a successful allocation, false otherwise\n  **/\n-bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)\n+static bool i40e_alloc_buffer_slow_zc(struct i40e_ring *rx_ring,\n+\t\t\t\t      struct i40e_rx_buffer *bi)\n+{\n+\tstruct xdp_umem *umem = rx_ring->xsk_umem;\n+\tu64 handle, hr;\n+\n+\tif (!xsk_umem_peek_addr_rq(umem, &handle)) {\n+\t\trx_ring->rx_stats.alloc_page_failed++;\n+\t\treturn false;\n+\t}\n+\n+\thandle &= rx_ring->xsk_umem->chunk_mask;\n+\n+\thr = umem->headroom + XDP_PACKET_HEADROOM;\n+\n+\tbi->dma = xdp_umem_get_dma(umem, handle);\n+\tbi->dma += hr;\n+\n+\tbi->addr = xdp_umem_get_data(umem, handle);\n+\tbi->addr += hr;\n+\n+\tbi->handle = handle + umem->headroom;\n+\n+\txsk_umem_discard_addr_rq(umem);\n+\treturn true;\n+}\n+\n+static __always_inline bool __i40e_alloc_rx_buffers_zc(\n+\tstruct i40e_ring *rx_ring, u16 count,\n+\tbool alloc(struct i40e_ring *rx_ring,\n+\t\t   struct i40e_rx_buffer *bi))\n {\n \tu16 ntu = rx_ring->next_to_use;\n \tunion i40e_rx_desc *rx_desc;\n@@ -372,7 +409,7 @@ bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)\n \trx_desc = I40E_RX_DESC(rx_ring, ntu);\n \tbi = &rx_ring->rx_bi[ntu];\n \tdo {\n-\t\tif (!i40e_alloc_buffer_zc(rx_ring, bi)) {\n+\t\tif (!alloc(rx_ring, bi)) {\n \t\t\tok = false;\n \t\t\tgoto no_buffers;\n \t\t}\n@@ -404,6 +441,38 @@ bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)\n \treturn ok;\n }\n \n+/**\n+ * i40e_alloc_rx_buffers_zc - Allocates a number of Rx buffers\n+ * @rx_ring: Rx ring\n+ * @count: The number of buffers to allocate\n+ *\n+ * This function allocates a number of Rx buffers from the reuse queue\n+ * or fill ring and places them on the Rx ring.\n+ *\n+ * Returns true for a successful allocation, false otherwise\n+ **/\n+bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)\n+{\n+\treturn __i40e_alloc_rx_buffers_zc(rx_ring, count,\n+\t\t\t\t\t  i40e_alloc_buffer_slow_zc);\n+}\n+\n+/**\n+ * i40e_alloc_rx_buffers_fast_zc - Allocates a number of Rx buffers\n+ * @rx_ring: Rx ring\n+ * @count: The number of buffers to allocate\n+ *\n+ * This function allocates a number of Rx buffers from the fill ring\n+ * or the internal recycle mechanism and places them on the Rx ring.\n+ *\n+ * Returns true for a successful allocation, false otherwise\n+ **/\n+static bool i40e_alloc_rx_buffers_fast_zc(struct i40e_ring *rx_ring, u16 count)\n+{\n+\treturn __i40e_alloc_rx_buffers_zc(rx_ring, count,\n+\t\t\t\t\t  i40e_alloc_buffer_zc);\n+}\n+\n /**\n  * i40e_get_rx_buffer_zc - Return the current Rx buffer\n  * @rx_ring: Rx ring\n@@ -571,8 +640,8 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)\n \n \t\tif (cleaned_count >= I40E_RX_BUFFER_WRITE) {\n \t\t\tfailure = failure ||\n-\t\t\t\t  !i40e_alloc_rx_buffers_zc(rx_ring,\n-\t\t\t\t\t\t\t    cleaned_count);\n+\t\t\t\t  !i40e_alloc_rx_buffers_fast_zc(rx_ring,\n+\t\t\t\t\t\t\t\t cleaned_count);\n \t\t\tcleaned_count = 0;\n \t\t}\n \n@@ -831,6 +900,21 @@ int i40e_xsk_async_xmit(struct net_device *dev, u32 queue_id)\n \treturn 0;\n }\n \n+void i40e_xsk_clean_rx_ring(struct i40e_ring *rx_ring)\n+{\n+\tu16 i;\n+\n+\tfor (i = 0; i < rx_ring->count; i++) {\n+\t\tstruct i40e_rx_buffer *rx_bi = &rx_ring->rx_bi[i];\n+\n+\t\tif (!rx_bi->addr)\n+\t\t\tcontinue;\n+\n+\t\txsk_umem_fq_reuse(rx_ring->xsk_umem, rx_bi->handle);\n+\t\trx_bi->addr = NULL;\n+\t}\n+}\n+\n /**\n  * i40e_xsk_clean_xdp_ring - Clean the XDP Tx ring on shutdown\n  * @xdp_ring: XDP Tx ring\n",
    "prefixes": [
        "v2",
        "3/4"
    ]
}