From patchwork Fri Oct 18 08:39:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kurt Kanzenbach X-Patchwork-Id: 1998978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=YBJY/vB9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XVJ740rdKz1xth for ; Fri, 18 Oct 2024 19:40:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2DB94607CF; Fri, 18 Oct 2024 08:40:14 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BbZ4RNbBKnih; Fri, 18 Oct 2024 08:40:12 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org BB2736062F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1729240812; bh=YH+J2MPtO/wj9yAkFfnF7WQuIFDEVmwmmrLzdRgJhfU=; h=From:Date:References:In-Reply-To:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=YBJY/vB91r3MA+cgZasBff/yFvpTetM9N4NEz0WcXu7+09QYr2T7SFgwIhFcs4Hch UNMWUuWHTZLBsJYgVQON2y57B/VRHYh4mAiWFysj3S06FhOYeI2/M4AcNT/+nWt5Ka tjoyLA4/Ja7vDZD/EY1/K1PYLAilvaBUAjfe51DpYoP92Lq+xwG0fVEQdlFv2scJxO 5H8m6TIYOb+WBsehjlDcmDo0oEe14qgXqnsO0TbDX45ZY2gsfjlip0LT0XzsyjO2QR N7C8bzBZAWu/EW9DLoXOWpdafVY529oTnavAZU5irvf9NWNfuFELVW6xP5hp+jAFHi 7L/MtVkgCw1uQ== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp3.osuosl.org (Postfix) with ESMTP id BB2736062F; Fri, 18 Oct 2024 08:40:12 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists1.osuosl.org (Postfix) with ESMTP id 1488A2804 for ; Fri, 18 Oct 2024 08:40:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E9EA280BAA for ; Fri, 18 Oct 2024 08:40:10 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xNRrWyLLwG4t for ; Fri, 18 Oct 2024 08:40:10 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=193.142.43.55; helo=galois.linutronix.de; envelope-from=kurt@linutronix.de; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 09A0780BA9 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 09A0780BA9 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by smtp1.osuosl.org (Postfix) with ESMTPS id 09A0780BA9 for ; Fri, 18 Oct 2024 08:40:09 +0000 (UTC) From: Kurt Kanzenbach Date: Fri, 18 Oct 2024 10:39:58 +0200 MIME-Version: 1.0 Message-Id: <20241018-b4-igb_zero_copy-v9-2-da139d78d796@linutronix.de> References: <20241018-b4-igb_zero_copy-v9-0-da139d78d796@linutronix.de> In-Reply-To: <20241018-b4-igb_zero_copy-v9-0-da139d78d796@linutronix.de> To: Tony Nguyen , Przemek Kitszel Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Richard Cochran , Sriram Yagnaraman , Benjamin Steinke , Sebastian Andrzej Siewior , Maciej Fijalkowski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Sriram Yagnaraman , Kurt Kanzenbach X-Developer-Signature: v=1; a=openpgp-sha256; l=2664; i=kurt@linutronix.de; h=from:subject:message-id; bh=GFWHUeNYEWqXkX9ltUkdA/+XAecRGzYcafx3KgM4JRg=; b=owEBbQKS/ZANAwAKAcGT0fKqRnOCAcsmYgBnEh7iWBdazRMU4JURD596qWrbLmuPTJe7KgyMh Tu9nC75nSCJAjMEAAEKAB0WIQS8ub+yyMN909/bWZLBk9HyqkZzggUCZxIe4gAKCRDBk9HyqkZz gkY5D/0fRgM3Umiqa9cGgZY5jznEMK0Vx3JNKoex2Ak4YPeDVWWO5g6hI16zZQN03+CI3yj9iLR biwP1yl2TnsAvMB4nzY126PdamU1BTlOtdQZB5u2uJkUg3InecXIEjQEQP639KtkxPTICsM6pDQ RtKxhUZ3pGhfqBPtktEPWA1XQjzMjr7E4r4SaEkyP1zAcYQVNx2FJJBtEimLs6EEjtuUS+TFwh4 3VSehfshNCyDQ2lVqaUAWEhcIS7A7TVtYgJ1oTXASkVaiPJ75vogCcR/B47Z2fU7jVFuNIyTs/z G50M3Neo1H++WJgMkDDo4gO8lunuQ4ZFLp86XMAD/MY+CEDuCTdpJG/KqUzVmyDMVCNqw9fGhoz QnLGk22mx8deJW2MkbrZKi3picLY5W1ozdOKarxe521tzfUlqzMgogKs3kG43h5kGwo2QiO48Mx sb+/EiG2GkR0yQIi6eYCOC6pQ+i1hAA3GeI63qlXO0BL7GwBwqlGT4omU8CQClSRQ1Jy64gVB1t XqfmFZufJbmRT0Cv1VKQmkNS3KlYq1apnXL6sCd7+Y6HfwhiXEVDVjTgnjbSVf5N0YbbXL77jIU 4P0BrkTiK3r4R5jjwp7aDGK03egJ6gq5YDXxOhzncl1Vjr/p4cKpHfT44d2Ky5MGU7XmZZcWboL IB8LOlfZHmfwMdQ== X-Developer-Key: i=kurt@linutronix.de; a=openpgp; fpr=BCB9BFB2C8C37DD3DFDB5992C193D1F2AA467382 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1729240807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YH+J2MPtO/wj9yAkFfnF7WQuIFDEVmwmmrLzdRgJhfU=; b=Ul76rvv8zjvvP8ySRMZtT1vB3tIc/lBHZQSlhmC0/dlKwzc9vry6sekg4Qagq4XeIocK7M AD/kHS/Y9Hcl7dd7zLLRAFHil969q6LbvCqyq9D43JB90nDR5CgoqgGWhP8Faewn8uDOTa RVOGEjiB6676arPFGRn3Zo8wTYJMbBa16VM1qx17NntYXZnmeKmBhoMKB8BHXS38VqQV59 PUNRgeeRMzuXZVL6BH6iXeLWgzjCP+gs0psnp4vtCxK+rsTHEpK2jiB4us8FyUU4GEyLas UMamHiN3yauPwzlzCEPMXz8/SZML31+oCV+9NUrZRd7eYjrCi8L5OOiik4gB9w== X-Mailman-Original-DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1729240807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YH+J2MPtO/wj9yAkFfnF7WQuIFDEVmwmmrLzdRgJhfU=; b=ydfW1WGWqoDHjYkVZjC9fVwV0E+mmkilU1Nr6xJ2xpwFEjDcb8XDLHu+7goJ2XqzexHwiv KxMJKEWtxRJ8jvDQ== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=linutronix.de X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=Ul76rvv8; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=ydfW1WGW Subject: [Intel-wired-lan] [PATCH iwl-next v9 2/6] igb: Introduce igb_xdp_is_enabled() X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Sriram Yagnaraman Introduce igb_xdp_is_enabled() to check if an XDP program is assigned to the device. Use that wherever xdp_prog is read and evaluated. Signed-off-by: Sriram Yagnaraman [Kurt: Split patches and use READ_ONCE()] Signed-off-by: Kurt Kanzenbach Acked-by: Maciej Fijalkowski --- drivers/net/ethernet/intel/igb/igb.h | 5 +++++ drivers/net/ethernet/intel/igb/igb_main.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h index 1bfe703e73d9..6e2b61ecff68 100644 --- a/drivers/net/ethernet/intel/igb/igb.h +++ b/drivers/net/ethernet/intel/igb/igb.h @@ -826,6 +826,11 @@ static inline struct igb_ring *igb_xdp_tx_queue_mapping(struct igb_adapter *adap return adapter->tx_ring[r_idx]; } +static inline bool igb_xdp_is_enabled(struct igb_adapter *adapter) +{ + return !!READ_ONCE(adapter->xdp_prog); +} + int igb_add_filter(struct igb_adapter *adapter, struct igb_nfc_filter *input); int igb_erase_filter(struct igb_adapter *adapter, diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 5a44867bcb26..fc30966282c5 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2926,7 +2926,8 @@ int igb_xdp_xmit_back(struct igb_adapter *adapter, struct xdp_buff *xdp) /* During program transitions its possible adapter->xdp_prog is assigned * but ring has not been configured yet. In this case simply abort xmit. */ - tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL; + tx_ring = igb_xdp_is_enabled(adapter) ? + igb_xdp_tx_queue_mapping(adapter) : NULL; if (unlikely(!tx_ring)) return IGB_XDP_CONSUMED; @@ -2959,7 +2960,8 @@ static int igb_xdp_xmit(struct net_device *dev, int n, /* During program transitions its possible adapter->xdp_prog is assigned * but ring has not been configured yet. In this case simply abort xmit. */ - tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL; + tx_ring = igb_xdp_is_enabled(adapter) ? + igb_xdp_tx_queue_mapping(adapter) : NULL; if (unlikely(!tx_ring)) return -ENXIO; @@ -6593,7 +6595,7 @@ static int igb_change_mtu(struct net_device *netdev, int new_mtu) struct igb_adapter *adapter = netdev_priv(netdev); int max_frame = new_mtu + IGB_ETH_PKT_HDR_PAD; - if (adapter->xdp_prog) { + if (igb_xdp_is_enabled(adapter)) { int i; for (i = 0; i < adapter->num_rx_queues; i++) {