From patchwork Tue Feb 12 08:52:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 1040455 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Hv+oBV37"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zGfR0ZwFz9sMl for ; Tue, 12 Feb 2019 19:53:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9C93084B08; Tue, 12 Feb 2019 08:53:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1_-i3TYy89Js; Tue, 12 Feb 2019 08:53:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id EB72D858FB; Tue, 12 Feb 2019 08:53:28 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id E46AD1BF964 for ; Tue, 12 Feb 2019 08:52:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E10A722794 for ; Tue, 12 Feb 2019 08:52:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IbrOJTAmujjc for ; Tue, 12 Feb 2019 08:52:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by silver.osuosl.org (Postfix) with ESMTPS id 303EB2263E for ; Tue, 12 Feb 2019 08:52:34 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id z15so241588pfa.2 for ; Tue, 12 Feb 2019 00:52:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2BpwbKu37r4ICnJFpO01tcc8bs7Y4w/gT82xHbJR6nE=; b=Hv+oBV37sFyZRwsaM/K+qfnkEv9JTCqCQldESCX9sfi1UILd+lQDwh0ZJYi+GSfdKM AjB/utikFbjt7M0n0/DWVttdRqrJ6CSw5+i4hm0AgN7D1mtFVp7xdU99JWvVGjgbweig q3Ys23M6Z6r6CdffGn6COOVOAJ2/xefAsV2CILymKqr2NPEdakyNgWfwMZczVe02rH8W 81oWomvO6lJ+mPj+3MiVEBXwpbaPv5hzNXPQRVz1DNfwMGQUD15ZOs8Jgy/iMfIRTZos U2nywZ0IfLvD6gqLdiJKeJQ/QPOcjsegLr8p8bEq00raxngI+uF+uPdO5lHXfYMrvDsn pVrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2BpwbKu37r4ICnJFpO01tcc8bs7Y4w/gT82xHbJR6nE=; b=aOtqwzRFOETne5bD3sUL2PJ66FxvvmksT1In+TMMDh2cX5cYsZjbFhsgGjMG4COqUh /ELcgagRoMQ8wkbsDSJ/LVsoF5WmYVzPcsoJ6QNiKJd9jmslAMknryDD07JL6iOVllTD ZauRJap/lQm1/l5D34JYZCk+qBjIBplxRO3k0voKETQk3A3RD+ZvG7Bt3P0bDAj7PP8a 7f4yqIdjm7x/90hmO6R2VuGwdYSYKezyzah/Zdm3/sUO6PEis4Ge2t+4nezoDb/KwWXB k9y06lq4nOMVAvFlWrpfpnAsGDTivrVW4UJwgrpMw2wCmCOCD5T3f/VVNP90i3oMdFBN Fk8Q== X-Gm-Message-State: AHQUAuZkOwOCvPS9gfa0HnyhE6PerKsfao3WSgDNm1iGCrEO2KPfde5v pj2UDDSW2CE50Cq98mg5eSdLW7G8HmuMjA== X-Google-Smtp-Source: AHgI3IYaLRItC9NcP5n4GOF6YSA0x3A/OyOt+WRZvUOKJzY4Y6lMu3XG+u4IHZt6ES5sM5WgQvueEA== X-Received: by 2002:a62:569b:: with SMTP id h27mr2815161pfj.163.1549961553643; Tue, 12 Feb 2019 00:52:33 -0800 (PST) Received: from btopel-mobl.ger.intel.com ([134.134.139.83]) by smtp.gmail.com with ESMTPSA id u73sm24461606pfa.169.2019.02.12.00.52.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 00:52:33 -0800 (PST) From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: intel-wired-lan@lists.osuosl.org Date: Tue, 12 Feb 2019 09:52:04 +0100 Message-Id: <20190212085205.7848-2-bjorn.topel@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190212085205.7848-1-bjorn.topel@gmail.com> References: <20190212085205.7848-1-bjorn.topel@gmail.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 1/2] i40e: move i40e_xsk_umem function X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , magnus.karlsson@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Björn Töpel The i40e_xsk_umem function was explicitly inlined in i40e.h. There is no reason for that, so move it to i40e_main.c instead. Signed-off-by: Björn Töpel Tested-by: Aaron Brown --- drivers/net/ethernet/intel/i40e/i40e.h | 14 -------------- drivers/net/ethernet/intel/i40e/i40e_main.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index d684998ba2b0..cc583ad5236b 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -1096,20 +1096,6 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi) return !!vsi->xdp_prog; } -static inline struct xdp_umem *i40e_xsk_umem(struct i40e_ring *ring) -{ - bool xdp_on = i40e_enabled_xdp_vsi(ring->vsi); - int qid = ring->queue_index; - - if (ring_is_xdp(ring)) - qid -= ring->vsi->alloc_queue_pairs; - - if (!xdp_on) - return NULL; - - return xdp_get_umem_from_qid(ring->vsi->netdev, qid); -} - int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch); int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate); int i40e_add_del_cloud_filter(struct i40e_vsi *vsi, diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 44856a84738d..ba1a84a2c8e5 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -3063,6 +3063,26 @@ static void i40e_config_xps_tx_ring(struct i40e_ring *ring) ring->queue_index); } +/** + * i40e_xsk_umem - Retrieve the AF_XDP ZC if XDP and ZC is enabled + * @ring: The Tx or Rx ring + * + * Returns the UMEM or NULL. + **/ +static struct xdp_umem *i40e_xsk_umem(struct i40e_ring *ring) +{ + bool xdp_on = i40e_enabled_xdp_vsi(ring->vsi); + int qid = ring->queue_index; + + if (ring_is_xdp(ring)) + qid -= ring->vsi->alloc_queue_pairs; + + if (!xdp_on) + return NULL; + + return xdp_get_umem_from_qid(ring->vsi->netdev, qid); +} + /** * i40e_configure_tx_ring - Configure a transmit ring context and rest * @ring: The Tx ring to configure From patchwork Tue Feb 12 08:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 1040456 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kEG77YXe"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43zGfb0Zycz9sMx for ; Tue, 12 Feb 2019 19:53:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3812684B08; Tue, 12 Feb 2019 08:53:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YdcsVizYAqTC; Tue, 12 Feb 2019 08:53:47 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id C4F6C85A84; Tue, 12 Feb 2019 08:53:37 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id AFA941BF2A0 for ; Tue, 12 Feb 2019 08:52:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id AC47722794 for ; Tue, 12 Feb 2019 08:52:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id En8k8WgHZ2aX for ; Tue, 12 Feb 2019 08:52:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by silver.osuosl.org (Postfix) with ESMTPS id 01CCB2263E for ; Tue, 12 Feb 2019 08:52:37 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id f90so971409plb.10 for ; Tue, 12 Feb 2019 00:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x3H3dvcVPzIeaeu47sYZtsBs/Rjy1TgqKkKpqTtk0XQ=; b=kEG77YXen8pPuOjwre5suhtxR87f5E1p7BUg6Nz+U1YAfMaJPMTmzKL74/0RzuLHGp FathksUCtEGlS126A3y8QpqIwigtgUAVH9ElMF0zhGu2Gw7UiYKWWGcA6osKYgz8Lfm5 pvrTTSVp4daz45YE70uMZyK8hFEtDWzT8+zw1YsciX9WHQGgDw5tSLe5BTT1kv4WEhZe c1KoG75BAHbcNo9Og5ikuACmX0/pnMAcCZBvANYslfEtdbCzhJvxuT01K4Dztpxi+6IF M2a1XZf4A2kW1T7YCFQGmZsQbagBNugz8TKVP3udSQq8/OLLX2owQtCdCZ6lkQinMwZF khLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x3H3dvcVPzIeaeu47sYZtsBs/Rjy1TgqKkKpqTtk0XQ=; b=YmDOmKdJfVIBht9HDJyBNTUYGdIyaMfbcxgxcq5UOs2xT5YfRm/nznYD+/O+2q41// izw11lhC3K7M9vCQQl8NdALHrDjOrj0iMcoIKb7XKbPgMiqEK4ON+CeqmlGyHYk6z0il GbjwImttDpnKxmQf7YTGrwMOzj8QsG3/HkiW6YVICegBT+kIJsQodyLFCtg5EB5NjEkL XU6Q1QNThd+X9+lPQqeSCogUQ6wjzVy1IxY+8aJrgIsS1qczF4ythsgBQEpf6HYXMKjK 6xmzzwsR/itXpzc2YP6OpiCPEuFEJffS5QzjWT0VAPYWuGnyc04U/IMSAcKvUoFLuoNJ bVcg== X-Gm-Message-State: AHQUAuZ4NlVudNwey5iXolDr5TPR7zhtP+6zdyhQgvmDwhy5HThd5XG+ E+ZpOOJMMktdtj4rJ3Z1gtol5D50bxXdAQ== X-Google-Smtp-Source: AHgI3IZofi1S9Qoc/NlNtPsXJjxc+fGxbXJ9eZV5vyQS1lw5DsP4IhQ/GGZA2MwHP/mvse3mut8oTg== X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr2883424pls.177.1549961557334; Tue, 12 Feb 2019 00:52:37 -0800 (PST) Received: from btopel-mobl.ger.intel.com ([134.134.139.83]) by smtp.gmail.com with ESMTPSA id u73sm24461606pfa.169.2019.02.12.00.52.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 00:52:36 -0800 (PST) From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: intel-wired-lan@lists.osuosl.org Date: Tue, 12 Feb 2019 09:52:05 +0100 Message-Id: <20190212085205.7848-3-bjorn.topel@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190212085205.7848-1-bjorn.topel@gmail.com> References: <20190212085205.7848-1-bjorn.topel@gmail.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 2/2] i40e: add tracking of AF_XDP ZC state for each queue pair X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , magnus.karlsson@intel.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Björn Töpel In commit f3fef2b6e1cc ("i40e: Remove umem from VSI") a regression was introduced; When the VSI was reset, the setup code would try to enable AF_XDP ZC unconditionally (as long as there was a umem placed in the netdev._rx struct). Here, we add a bitmap to the VSI that tracks if a certain queue pair has been "zero-copy enabled" via the ndo_bpf. The bitmap is used in i40e_xsk_umem, and enables zero-copy if and only if XDP is enabled, the corresponding qid in the bitmap is set and the umem is non-NULL. Fixes: f3fef2b6e1cc ("i40e: Remove umem from VSI") Signed-off-by: Björn Töpel Tested-by: Aaron Brown --- drivers/net/ethernet/intel/i40e/i40e.h | 2 ++ drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++++- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h index cc583ad5236b..d3cc3427caad 100644 --- a/drivers/net/ethernet/intel/i40e/i40e.h +++ b/drivers/net/ethernet/intel/i40e/i40e.h @@ -790,6 +790,8 @@ struct i40e_vsi { /* VSI specific handlers */ irqreturn_t (*irq_handler)(int irq, void *data); + + unsigned long *af_xdp_zc_qps; /* tracks AF_XDP ZC enabled qps */ } ____cacheline_internodealigned_in_smp; struct i40e_netdev_priv { diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index ba1a84a2c8e5..0dd00d58c524 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -3077,7 +3077,7 @@ static struct xdp_umem *i40e_xsk_umem(struct i40e_ring *ring) if (ring_is_xdp(ring)) qid -= ring->vsi->alloc_queue_pairs; - if (!xdp_on) + if (!xdp_on || !test_bit(qid, ring->vsi->af_xdp_zc_qps)) return NULL; return xdp_get_umem_from_qid(ring->vsi->netdev, qid); @@ -10076,6 +10076,12 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) hash_init(vsi->mac_filter_hash); vsi->irqs_ready = false; + if (type == I40E_VSI_MAIN) { + vsi->af_xdp_zc_qps = bitmap_zalloc(pf->num_lan_qps, GFP_KERNEL); + if (!vsi->af_xdp_zc_qps) + goto err_rings; + } + ret = i40e_set_num_rings_in_vsi(vsi); if (ret) goto err_rings; @@ -10094,6 +10100,7 @@ static int i40e_vsi_mem_alloc(struct i40e_pf *pf, enum i40e_vsi_type type) goto unlock_pf; err_rings: + bitmap_free(vsi->af_xdp_zc_qps); pf->next_vsi = i - 1; kfree(vsi); unlock_pf: @@ -10174,6 +10181,7 @@ static int i40e_vsi_clear(struct i40e_vsi *vsi) i40e_put_lump(pf->qp_pile, vsi->base_queue, vsi->idx); i40e_put_lump(pf->irq_pile, vsi->base_vector, vsi->idx); + bitmap_free(vsi->af_xdp_zc_qps); i40e_vsi_free_arrays(vsi, true); i40e_clear_rss_config_user(vsi); diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c index 96d849460d9b..2737fee338c4 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c @@ -102,6 +102,8 @@ static int i40e_xsk_umem_enable(struct i40e_vsi *vsi, struct xdp_umem *umem, if (err) return err; + set_bit(qid, vsi->af_xdp_zc_qps); + if_running = netif_running(vsi->netdev) && i40e_enabled_xdp_vsi(vsi); if (if_running) { @@ -143,6 +145,7 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid) return err; } + clear_bit(qid, vsi->af_xdp_zc_qps); i40e_xsk_umem_dma_unmap(vsi, umem); if (if_running) {