get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1315039,
    "url": "http://patchwork.ozlabs.org/api/patches/1315039/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1592905458-850-2-git-send-email-magnus.karlsson@intel.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": "<1592905458-850-2-git-send-email-magnus.karlsson@intel.com>",
    "list_archive_url": null,
    "date": "2020-06-23T09:44:16",
    "name": "[net-next,v2,1/3] i40e: optimize AF_XDP Tx completion path",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f9238fcf257d102b3b7a54f73e89c0049e8511e5",
    "submitter": {
        "id": 72726,
        "url": "http://patchwork.ozlabs.org/api/people/72726/?format=api",
        "name": "Magnus Karlsson",
        "email": "magnus.karlsson@intel.com"
    },
    "delegate": {
        "id": 109701,
        "url": "http://patchwork.ozlabs.org/api/users/109701/?format=api",
        "username": "anguy11",
        "first_name": "Anthony",
        "last_name": "Nguyen",
        "email": "anthony.l.nguyen@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1592905458-850-2-git-send-email-magnus.karlsson@intel.com/mbox/",
    "series": [
        {
            "id": 185220,
            "url": "http://patchwork.ozlabs.org/api/series/185220/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=185220",
            "date": "2020-06-23T09:44:15",
            "name": "i40e: improve AF_XDP performance",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/185220/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1315039/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1315039/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 spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.137; helo=fraxinus.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=<UNKNOWN>)",
            "ozlabs.org;\n dmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 49rhFb6Cw8z9sQx\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 23 Jun 2020 19:44:35 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 71BF786DE9;\n\tTue, 23 Jun 2020 09:44:34 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id yT9K3v7Sy3KF; Tue, 23 Jun 2020 09:44:33 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id 6BF3B86A3C;\n\tTue, 23 Jun 2020 09:44:33 +0000 (UTC)",
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n by ash.osuosl.org (Postfix) with ESMTP id 34C2A1BF294\n for <intel-wired-lan@lists.osuosl.org>; Tue, 23 Jun 2020 09:44:31 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by hemlock.osuosl.org (Postfix) with ESMTP id 2EC0388FB0\n for <intel-wired-lan@lists.osuosl.org>; Tue, 23 Jun 2020 09:44:31 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id M6rLLU9PsFn0 for <intel-wired-lan@lists.osuosl.org>;\n Tue, 23 Jun 2020 09:44:30 +0000 (UTC)",
            "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n by hemlock.osuosl.org (Postfix) with ESMTPS id 6825788D67\n for <intel-wired-lan@lists.osuosl.org>; Tue, 23 Jun 2020 09:44:30 +0000 (UTC)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 23 Jun 2020 02:44:30 -0700",
            "from mkarlsso-mobl.ger.corp.intel.com (HELO localhost.localdomain)\n ([10.252.33.84])\n by orsmga004.jf.intel.com with ESMTP; 23 Jun 2020 02:44:26 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "IronPort-SDR": [
            "\n y0EbsBNfPfegBIyW8IZhx29hDsSNpf1R+ykT2e+yKt1tEsUKGjQcWlXz2v/xcgaEvg33ChoMzz\n KAT1q6H+IkBA==",
            "\n WEkt9pPNp4ZSw+ReL6cU2fpVaz9xAAvx9rrcRVIZh3/ycltOaOIg4iqvsBDYcoirvpwmOdsnce\n WIgDGhgJWp8A=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9660\"; a=\"162099554\"",
            "E=Sophos;i=\"5.75,270,1589266800\"; d=\"scan'208\";a=\"162099554\"",
            "E=Sophos;i=\"5.75,270,1589266800\"; d=\"scan'208\";a=\"422947142\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Magnus Karlsson <magnus.karlsson@intel.com>",
        "To": "magnus.karlsson@intel.com, bjorn.topel@intel.com,\n intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com,\n sridhar.samudrala@intel.com",
        "Date": "Tue, 23 Jun 2020 11:44:16 +0200",
        "Message-Id": "<1592905458-850-2-git-send-email-magnus.karlsson@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1592905458-850-1-git-send-email-magnus.karlsson@intel.com>",
        "References": "<1592905458-850-1-git-send-email-magnus.karlsson@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH net-next v2 1/3] i40e: optimize AF_XDP Tx\n completion path",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <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 <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "maciejromanfijalkowski@gmail.com, maciej.fijalkowski@intel.com,\n netdev@vger.kernel.org",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "Improve the performance of the AF_XDP zero-copy Tx completion\npath. When there are no XDP buffers being sent using XDP_TX or\nXDP_REDIRECT, we do not have go through the SW ring to clean up any\nentries since the AF_XDP path does not use these. In these cases, just\nfast forward the next-to-use counter and skip going through the SW\nring. The limit on the maximum number of entries to complete is also\nremoved since the algorithm is now O(1). To simplify the code path, the\nmaximum number of entries to complete for the XDP path is therefore\nalso increased from 256 to 512 (the default number of Tx HW\ndescriptors). This should be fine since the completion in the XDP path\nis faster than in the SKB path that has 256 as the maximum number.\n\nThis patch provides around 4% throughput improvement for the l2fwd\napplication in xdpsock on my machine.\n\nSigned-off-by: Magnus Karlsson <magnus.karlsson@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e_txrx.c |  3 +-\n drivers/net/ethernet/intel/i40e/i40e_txrx.h |  1 +\n drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 43 +++++++++++++++--------------\n drivers/net/ethernet/intel/i40e/i40e_xsk.h  |  3 +-\n 4 files changed, 27 insertions(+), 23 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\nindex f9555c8..9334abd 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n@@ -2580,7 +2580,7 @@ int i40e_napi_poll(struct napi_struct *napi, int budget)\n \t */\n \ti40e_for_each_ring(ring, q_vector->tx) {\n \t\tbool wd = ring->xsk_umem ?\n-\t\t\t  i40e_clean_xdp_tx_irq(vsi, ring, budget) :\n+\t\t\t  i40e_clean_xdp_tx_irq(vsi, ring) :\n \t\t\t  i40e_clean_tx_irq(vsi, ring, budget);\n \n \t\tif (!wd) {\n@@ -3538,6 +3538,7 @@ static int i40e_xmit_xdp_ring(struct xdp_frame *xdpf,\n \t */\n \tsmp_wmb();\n \n+\txdp_ring->xdp_tx_active++;\n \ti++;\n \tif (i == xdp_ring->count)\n \t\ti = 0;\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\nindex 5c25597..c16fcd9 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n@@ -371,6 +371,7 @@ struct i40e_ring {\n \t/* used in interrupt processing */\n \tu16 next_to_use;\n \tu16 next_to_clean;\n+\tu16 xdp_tx_active;\n \n \tu8 atr_sample_rate;\n \tu8 atr_count;\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c\nindex 7276580..86635f5 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c\n@@ -378,6 +378,7 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)\n  **/\n static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)\n {\n+\tunsigned int sent_frames = 0, total_bytes = 0;\n \tstruct i40e_tx_desc *tx_desc = NULL;\n \tstruct i40e_tx_buffer *tx_bi;\n \tbool work_done = true;\n@@ -408,6 +409,9 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)\n \t\t\t\t   | I40E_TX_DESC_CMD_EOP,\n \t\t\t\t   0, desc.len, 0);\n \n+\t\tsent_frames++;\n+\t\ttotal_bytes += tx_bi->bytecount;\n+\n \t\txdp_ring->next_to_use++;\n \t\tif (xdp_ring->next_to_use == xdp_ring->count)\n \t\t\txdp_ring->next_to_use = 0;\n@@ -420,6 +424,7 @@ static bool i40e_xmit_zc(struct i40e_ring *xdp_ring, unsigned int budget)\n \t\ti40e_xdp_ring_update_tail(xdp_ring);\n \n \t\txsk_umem_consume_tx_done(xdp_ring->xsk_umem);\n+\t\ti40e_update_tx_stats(xdp_ring, sent_frames, total_bytes);\n \t}\n \n \treturn !!budget && work_done;\n@@ -434,6 +439,7 @@ static void i40e_clean_xdp_tx_buffer(struct i40e_ring *tx_ring,\n \t\t\t\t     struct i40e_tx_buffer *tx_bi)\n {\n \txdp_return_frame(tx_bi->xdpf);\n+\ttx_ring->xdp_tx_active--;\n \tdma_unmap_single(tx_ring->dev,\n \t\t\t dma_unmap_addr(tx_bi, dma),\n \t\t\t dma_unmap_len(tx_bi, len), DMA_TO_DEVICE);\n@@ -447,27 +453,25 @@ static void i40e_clean_xdp_tx_buffer(struct i40e_ring *tx_ring,\n  *\n  * Returns true if cleanup/tranmission is done.\n  **/\n-bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,\n-\t\t\t   struct i40e_ring *tx_ring, int napi_budget)\n+bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi, struct i40e_ring *tx_ring)\n {\n-\tunsigned int ntc, total_bytes = 0, budget = vsi->work_limit;\n-\tu32 i, completed_frames, frames_ready, xsk_frames = 0;\n+\tunsigned int ntc, budget = vsi->work_limit;\n \tstruct xdp_umem *umem = tx_ring->xsk_umem;\n+\tu32 i, completed_frames, xsk_frames = 0;\n \tu32 head_idx = i40e_get_head(tx_ring);\n-\tbool work_done = true, xmit_done;\n \tstruct i40e_tx_buffer *tx_bi;\n+\tbool xmit_done;\n \n \tif (head_idx < tx_ring->next_to_clean)\n \t\thead_idx += tx_ring->count;\n-\tframes_ready = head_idx - tx_ring->next_to_clean;\n+\tcompleted_frames = head_idx - tx_ring->next_to_clean;\n \n-\tif (frames_ready == 0) {\n+\tif (completed_frames == 0)\n \t\tgoto out_xmit;\n-\t} else if (frames_ready > budget) {\n-\t\tcompleted_frames = budget;\n-\t\twork_done = false;\n-\t} else {\n-\t\tcompleted_frames = frames_ready;\n+\n+\tif (likely(!tx_ring->xdp_tx_active)) {\n+\t\txsk_frames = completed_frames;\n+\t\tgoto skip;\n \t}\n \n \tntc = tx_ring->next_to_clean;\n@@ -475,18 +479,18 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,\n \tfor (i = 0; i < completed_frames; i++) {\n \t\ttx_bi = &tx_ring->tx_bi[ntc];\n \n-\t\tif (tx_bi->xdpf)\n+\t\tif (tx_bi->xdpf) {\n \t\t\ti40e_clean_xdp_tx_buffer(tx_ring, tx_bi);\n-\t\telse\n+\t\t\ttx_bi->xdpf = NULL;\n+\t\t} else {\n \t\t\txsk_frames++;\n-\n-\t\ttx_bi->xdpf = NULL;\n-\t\ttotal_bytes += tx_bi->bytecount;\n+\t\t}\n \n \t\tif (++ntc >= tx_ring->count)\n \t\t\tntc = 0;\n \t}\n \n+skip:\n \ttx_ring->next_to_clean += completed_frames;\n \tif (unlikely(tx_ring->next_to_clean >= tx_ring->count))\n \t\ttx_ring->next_to_clean -= tx_ring->count;\n@@ -494,8 +498,7 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,\n \tif (xsk_frames)\n \t\txsk_umem_complete_tx(umem, xsk_frames);\n \n-\ti40e_arm_wb(tx_ring, vsi, budget);\n-\ti40e_update_tx_stats(tx_ring, completed_frames, total_bytes);\n+\ti40e_arm_wb(tx_ring, vsi, completed_frames);\n \n out_xmit:\n \tif (xsk_umem_uses_need_wakeup(tx_ring->xsk_umem))\n@@ -503,7 +506,7 @@ bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,\n \n \txmit_done = i40e_xmit_zc(tx_ring, budget);\n \n-\treturn work_done && xmit_done;\n+\treturn xmit_done;\n }\n \n /**\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.h b/drivers/net/ethernet/intel/i40e/i40e_xsk.h\nindex ea919a7d..c524c14 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_xsk.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.h\n@@ -15,8 +15,7 @@ int i40e_xsk_umem_setup(struct i40e_vsi *vsi, struct xdp_umem *umem,\n bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 cleaned_count);\n int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget);\n \n-bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi,\n-\t\t\t   struct i40e_ring *tx_ring, int napi_budget);\n+bool i40e_clean_xdp_tx_irq(struct i40e_vsi *vsi, struct i40e_ring *tx_ring);\n int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags);\n int i40e_alloc_rx_bi_zc(struct i40e_ring *rx_ring);\n void i40e_clear_rx_bi_zc(struct i40e_ring *rx_ring);\n",
    "prefixes": [
        "net-next",
        "v2",
        "1/3"
    ]
}