From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87E08606A322 for ; Sat, 5 Dec 2026 12:52:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=ceYB4hlo; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=NvdC3VMe Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6502E81E56; Sat, 5 Dec 2026 12:52:44 +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 lpBTVqvM18In; Sat, 5 Dec 2026 12:52:43 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 9EE62814B3 Authentication-Results: smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796475163; b=cyBkVKIb0zGMEUrTwOF87+wFDiDY0sztXTZL7HKeIz27Vy0C7sbAj0TUxiw+0ktUygzW 5FGJJM3CaDUqzyggOVVkfRMoqMVEQnMp+fYcP4XbnrVIBSR5T6qG9NOVCERbCfKBcnwr+ k9zinROVksb7HlZsskEKo1qJwxtcVTMQEYUhZ1sgg5E3OL7+4KKnrkE4J6i8JmOWGmwKu jtxHGUThfBcJv9teUgoIx/JeJFj5ea7NeRQKV6drztCQokpttrsDYOjtjEeNmCw5tGdK3 zeIuBZ+02Tlgcg1J1e2hpsKz64c98RoWvLCdKrnrA2htWM28YgQex5mJefWysKuXHIg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796475163; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type: X-BeenThere:X-Mailman-Version:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:Errors-To; bh=C6dbp3OZZuokmvC/R0+dTaz4LHMC1TDDQ5XkFrx1wt8=; b=sYMzBJOXF/A2mfe3Y/NCGZr0MWkzkXCCG45tqOilssUGiqih8bf1/NUN6JCRdfW0Sa0l d/n3oMcC5o5hEQp8ksfevjnLdRGNypjDOrzJLddxMsl1aziECRROk4ATy90rewW2fuChH e/zw3NNQNBRV/yzRUdvzPwg5V3vA6Cw8fYYVB2waeiUTIRrNT2YKAxC5FaWIk0NotFQZs r9qSJMwzqp/lwFIhB4LSoXnrJyQpuxHjl77pUOy6kMi1QxvPHNb8mShYjODybd6o9HT2K U70pb6OZFlVXiGK22jWTzb43zEDj5Y89YI2XgUnRCmvvSlzDcE7pX9JxaymfEkcDJ3A== ARC-Authentication-Results: i=1; smtp1.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 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-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1796475163; bh=C6dbp3OZZuokmvC/R0+dTaz4LHMC1TDDQ5XkFrx1wt8=; h=Date:In-Reply-To:References:Subject:From:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ceYB4hlo80rRrIfBsQ0+5zF+jYvEQh+/9FZscbRl/j2G8u+la18wsfjXrpvR/8Uaw 25es3Qic/wvC08SV5YR0wkvEDAN/qil85RkwCRdN9ykeItkGpFlWEW598wBlf5FDvb 0imoLXNroRBaXDWi6WW4dWLpJvgxkr5sOc4Tr2GmTMVB2ieMUVq/Ace14G85LwG2Nn nTFV4x+Z1M5uI3RsLNzJDvCblEar4n16yDQ1t9NmX54ePiNsZvDJQ+fsK2HACJgBG8 GD4QALOkkBPEyX0c1G6YkfRMQ2rxCm//jr9qkDlzjPOrJmonrhTPgsnjWRCHddbCG+ pEULvrLGEEfzg== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 9EE62814B3; Sat, 5 Dec 2026 12:52:43 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists1.osuosl.org (Postfix) with ESMTP id D240E95F for ; Sat, 5 Dec 2026 12:52:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C4833409EA for ; Sat, 5 Dec 2026 12:52:41 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ZFhcPn60zIaC for ; Sat, 5 Dec 2026 12:52:41 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org 07252409D8 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::1048" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::1048; helo=mail-pj1-x1048.google.com; envelope-from=3fwkuawykd9geohcsoaiiaf8.6igchn8f-qcl87-f4hfcmnm.imoimf.ila@flex--kuniyu.bounces.google.com; receiver= Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=NvdC3VMe Received: from mail-pj1-x1048.google.com (mail-pj1-x1048.google.com [IPv6:2607:f8b0:4864:20::1048]) by smtp4.osuosl.org (Postfix) with ESMTPS id 07252409D8 for ; Sat, 5 Dec 2026 12:52:40 +0000 (UTC) Received: by mail-pj1-x1048.google.com with SMTP id 98e67ed59e1d1-3b4b76a2b95so2299396a91.1 for ; Sat, 05 Dec 2026 04:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796475160; x=1797079960; darn=lists.osuosl.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C6dbp3OZZuokmvC/R0+dTaz4LHMC1TDDQ5XkFrx1wt8=; b=NvdC3VMefvgiUjCNN1/ycWkKpw4DMLCe44PTqLfRme5IAngylc7dJdAtgsnc8g8dj+ VZshzXjcB6sxj0Yyw9cvYPVCvEKaUNZyuC2eHDko2ByRppqyY6EXS//kroV296UITEw2 oCHa1iDY2ozSI6Y3AcHkd5PxKdQnV0IDhOY5cJPrNLBBhM4geT667Y/xvrwXnD77W9gU gA77nRcfq3NpaM4f96bqDqcs5Df13/MCNin/UUHI9E7dLGChKimH2AdG+eWer3qQdxO3 2FGN+wtRcXgeDjwTpRoOG4Yju3eTCDNVuNTxF4MK7uP8SOjWApa5DTyliZRge9oS3koJ hH0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796475160; x=1797079960; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=C6dbp3OZZuokmvC/R0+dTaz4LHMC1TDDQ5XkFrx1wt8=; b=mvP1508DkM1FcEuDVW7AUpp8mxKNreLEpiY+s7PQw42QSGHTArki6tg/9MnuGgs5kG +5GIyf/Ar7KuFs5iQd0fwgvm3WWNEMmLfZgxu8oVO6MwpcsX0S1WgJKYDWqdS5YG783E Bd9Z/ulkJxC/7XMo8Jz+WvoiU8YHfccdmsZ2IVctIETAGuh1BIDrXGGoT+5QE/d/JOzR Wb0jWaD8AJmxlmz4ib3XjkoMODIP893cki1yOPdGFggmL/8d6iu1G1Vak1hSyG1yA1av bw7M4oIGK8IOgBKCfP+5b6+AkrJ/ADPegjpNBpdZvpFLhWnnWOXvu1gCTofwLvzWIYeY i6WA== X-Forwarded-Encrypted: i=1; AL+hErGvLjixU1yAH0QLC8cOxGNpm+BQXSENtUFXlKhB2j410IImpSR60CrAzNFtshNDrrU2eP/XsrPBuM+AM8QLwpg=@lists.osuosl.org X-Gm-Message-State: AB4q+uGxithnym45QjLMXUqL5NVpPD1/UJ26iJZ5AkIAX6W+8a3of+qn gBE2EgJeeoD7aKitBoEdzbWABjZq6SI28ax/dHhjrGF20s4RwsRylF0aO1hHTaMJb8S3MAZTvu7 XFvx6tg== X-Received: from pjbrr8.prod.google.com ([2002:a17:90b:2b48:b0:3b4:1351:6107]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2d8e:b0:3ae:533e:7e40 with SMTP id 98e67ed59e1d1-3b5e0649eaamr4605701a91.23.1796475159862; Sat, 05 Dec 2026 04:52:39 -0800 (PST) Date: Sat, 5 Dec 2026 21:52:19 +0900 In-Reply-To: <20261205125237.2290932-1-kuniyu@google.com> X-Archived-By: Mime-Version: 1.0 References: <20261205125237.2290932-1-kuniyu@google.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261205125237.2290932-2-kuniyu@google.com> Subject: [PATCH v2 iwl-next 1/5] idpf: Reuse idpf_rx_update_bufq_desc() in idpf_rx_post_buf_desc(). From: Kuniyuki Iwashima To: Alexander Lobakin , Tony Nguyen , Przemek Kitszel , Jesper Dangaard Brouer , Ilias Apalodimas Cc: Brian Vazquez , David Decotigny , Li Li , Kuniyuki Iwashima , Kuniyuki Iwashima , intel-wired-lan@lists.osuosl.org Content-Type: text/plain; charset="UTF-8" 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-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-26.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 idpf_rx_post_buf_desc() and idpf_rx_update_bufq_desc() duplicate the same header and payload buffer allocation and descriptor setup logic, except that idpf_rx_post_buf_desc() allocates with GFP_KERNEL for the initial ring fill while idpf_rx_clean_refillq() allocates with GFP_ATOMIC from NAPI. Also, in later commits we will extend buffer allocation to support coherent header buffers and early DMA unmapping. Let's add a gfp_t gfp parameter to idpf_rx_update_bufq_desc(), move it up, and reuse it in idpf_rx_post_buf_desc(). Signed-off-by: Kuniyuki Iwashima --- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 123 ++++++++------------ 1 file changed, 50 insertions(+), 73 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c index 7d926d13e5e6..d6601272c9ba 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c @@ -596,48 +596,68 @@ static void idpf_post_buf_refill(struct idpf_sw_queue *refillq, u16 buf_id) } /** - * idpf_rx_post_buf_desc - Post buffer to bufq descriptor ring - * @bufq: buffer queue to post to - * @buf_id: buffer id to post - * - * Only used for the initial fill, from process context, so it allocates - * with GFP_KERNEL. + * idpf_rx_update_bufq_desc - Update buffer queue descriptor + * @bufq: Pointer to the buffer queue + * @buf_id: buffer ID + * @buf_desc: Buffer queue descriptor + * @gfp: allocation flags (GFP_KERNEL for initial fill, GFP_ATOMIC from NAPI) * - * Return: %false if buffer could not be allocated, %true otherwise. + * Return: 0 on success and negative on failure. */ -static bool idpf_rx_post_buf_desc(struct idpf_buf_queue *bufq, u16 buf_id) +static int idpf_rx_update_bufq_desc(struct idpf_buf_queue *bufq, u32 buf_id, + struct virtchnl2_splitq_rx_buf_desc *buf_desc, + gfp_t gfp) { - struct virtchnl2_splitq_rx_buf_desc *splitq_rx_desc = NULL; struct libeth_fq_fp fq = { - .count = bufq->desc_count, + .pp = bufq->pp, + .fqes = bufq->buf, + .truesize = bufq->truesize, + .count = bufq->desc_count, }; - u16 nta = bufq->next_to_alloc; dma_addr_t addr; - splitq_rx_desc = &bufq->split_buf[nta]; + addr = __libeth_rx_alloc(&fq, buf_id, gfp); + if (addr == DMA_MAPPING_ERROR) + return -ENOMEM; + + buf_desc->pkt_addr = cpu_to_le64(addr); + buf_desc->qword0.buf_id = cpu_to_le16(buf_id); - if (idpf_queue_has(HSPLIT_EN, bufq)) { - fq.pp = bufq->hdr_pp; - fq.fqes = bufq->hdr_buf; - fq.truesize = bufq->hdr_truesize; + if (!idpf_queue_has(HSPLIT_EN, bufq)) + return 0; - addr = __libeth_rx_alloc(&fq, buf_id, GFP_KERNEL); - if (addr == DMA_MAPPING_ERROR) - return false; + fq.pp = bufq->hdr_pp; + fq.fqes = bufq->hdr_buf; + fq.truesize = bufq->hdr_truesize; - splitq_rx_desc->hdr_addr = cpu_to_le64(addr); + addr = __libeth_rx_alloc(&fq, buf_id, gfp); + if (addr == DMA_MAPPING_ERROR) { + idpf_rx_page_rel(&bufq->buf[buf_id]); + return -ENOMEM; } - fq.pp = bufq->pp; - fq.fqes = bufq->buf; - fq.truesize = bufq->truesize; + buf_desc->hdr_addr = cpu_to_le64(addr); - addr = __libeth_rx_alloc(&fq, buf_id, GFP_KERNEL); - if (addr == DMA_MAPPING_ERROR) - return false; + return 0; +} - splitq_rx_desc->pkt_addr = cpu_to_le64(addr); - splitq_rx_desc->qword0.buf_id = cpu_to_le16(buf_id); +/** + * idpf_rx_post_buf_desc - Post buffer to bufq descriptor ring + * @bufq: buffer queue to post to + * @buf_id: buffer id to post + * + * Only used for the initial fill, from process context, so it allocates + * with GFP_KERNEL. + * + * Return: %false if buffer could not be allocated, %true otherwise. + */ +static bool idpf_rx_post_buf_desc(struct idpf_buf_queue *bufq, u16 buf_id) +{ + u16 nta = bufq->next_to_alloc; + + if (idpf_rx_update_bufq_desc(bufq, buf_id, &bufq->split_buf[nta], + GFP_KERNEL)) + return false; nta++; if (unlikely(nta == bufq->desc_count)) @@ -3770,50 +3790,6 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) return rs.packets; } -/** - * idpf_rx_update_bufq_desc - Update buffer queue descriptor - * @bufq: Pointer to the buffer queue - * @buf_id: buffer ID - * @buf_desc: Buffer queue descriptor - * - * Return: 0 on success and negative on failure. - */ -static int idpf_rx_update_bufq_desc(struct idpf_buf_queue *bufq, u32 buf_id, - struct virtchnl2_splitq_rx_buf_desc *buf_desc) -{ - struct libeth_fq_fp fq = { - .pp = bufq->pp, - .fqes = bufq->buf, - .truesize = bufq->truesize, - .count = bufq->desc_count, - }; - dma_addr_t addr; - - addr = libeth_rx_alloc(&fq, buf_id); - if (addr == DMA_MAPPING_ERROR) - return -ENOMEM; - - buf_desc->pkt_addr = cpu_to_le64(addr); - buf_desc->qword0.buf_id = cpu_to_le16(buf_id); - - if (!idpf_queue_has(HSPLIT_EN, bufq)) - return 0; - - fq.pp = bufq->hdr_pp; - fq.fqes = bufq->hdr_buf; - fq.truesize = bufq->hdr_truesize; - - addr = libeth_rx_alloc(&fq, buf_id); - if (addr == DMA_MAPPING_ERROR) { - idpf_rx_page_rel(&bufq->buf[buf_id]); - return -ENOMEM; - } - - buf_desc->hdr_addr = cpu_to_le64(addr); - - return 0; -} - /** * idpf_rx_clean_refillq - Clean refill queue buffers * @bufq: buffer queue to post buffers back to @@ -3841,7 +3817,8 @@ static void idpf_rx_clean_refillq(struct idpf_buf_queue *bufq, break; buf_id = FIELD_GET(IDPF_RFL_BI_BUFID_M, refill_desc); - failure = idpf_rx_update_bufq_desc(bufq, buf_id, buf_desc); + failure = idpf_rx_update_bufq_desc(bufq, buf_id, buf_desc, + GFP_ATOMIC); if (failure) break; -- 2.56.1.915.g69d5ec7298-goog