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 52862606A31A for ; Wed, 2 Dec 2026 06:57:45 +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=W9UT2xhG; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=GnUWwwrU Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 340B080F32; Wed, 2 Dec 2026 06:57:45 +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 35Bf7Qon7hfg; Wed, 2 Dec 2026 06:57:44 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp1.osuosl.org 6A0E280EF4 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=1796194664; b=BfWsYA5inA2qgpQruEwDeBe5GqKbg5ZoFqeEr54CpudE6qTqKfUAODygNiRDeqvbB2Ol 18gkVWX9Tuw3YAz9/OQ8C4eQFvFiuYlMs3e+LDrAqHhhxSAyFdWxJ24HzLyAubPG6DFfr KBd0Rmdr9cqJLQnkD6QuXqZSmMFaGZg+7ra29viDVYRbSMBm0euI/HYZNqd8twus7tMsZ cXlVC3Wn6bT5bAeuEMvbqUzcn7cdMetnHjkRj/wZHyLVn0PHb2uFk/sWeiNzd44aQPQYA 3AsYNBNdTB1jG6cENgrkCK9jCoGBA0Oeb4hmph/ocje37e9mTYb9eKtvbA469HugX2w== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796194664; 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=72nQ3HaA+zqTgB2Zr0CRhE7MtUTl+VujIHfTJ1LP2KM=; b=PiNqx/dIYoUOrNhvw0QBPcbEM8EGu1Ly5XYu/adEUKyPBwKO34sgbCjUkfV2LANEy76k DP8xpf+cn7wRb0ePD4BhEPgRvnkwrfDGzXBAnbNbl+YF1HGR60Wjuyr+ax85nJs+G4en9 XwhNiTVACfaKROUH8z7KlJmQF41Re0WzX+Xra+/mE1SszHzYZyCytw3OyUMgt9EhPMG5h eSujmnngcAjy4Lij3uiw0Ue0BX78QxqW99VKimh/O7FFbXypHNL1RY8G0EsEK5ZhVd4d8 sCA1qdP31i+0AQP7lzBN+NLu1i1Yf/2LPZHe/fCzpEjZG7q20awWHvaw6g48YNxlw7g== 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=1796194664; bh=72nQ3HaA+zqTgB2Zr0CRhE7MtUTl+VujIHfTJ1LP2KM=; h=Date:In-Reply-To:References:Subject:From:To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=W9UT2xhGQJX8wx1wPq/RWp13TEww+mh1T5aaDkyRyrpJsbHjT5lorASJUwTLyn8Bp xAMSNdlZg0TC9l+OhJjo4EcEKCBBrYyVELVjf/5wG69AHvW1X4CpM5X1gv14J4BiRz lhxVpRhlLkW1/FbNNGZi+YLjJ6cQtZ8A9QihmIJreWHgASgJxos/94/Wf05oWLXFyk hz21MovW/9YRFHXpraezQH4PpZ0kDhywmQzC5yozZiyPObZlSAv8LvXIGOunTfhHER MFWbOJnKR83pruuILu9x7I7ny7mM2o+pWoDWSSVy2lv2ge+QJmBXOXgc3zvPgoMFWI ljsQ/juM97RGw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 6A0E280EF4; Wed, 2 Dec 2026 06:57:44 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id C97072FF for ; Wed, 2 Dec 2026 06:57:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BB98A4038B for ; Wed, 2 Dec 2026 06:57:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id g1QkmN9nSp_7 for ; Wed, 2 Dec 2026 06:57:42 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org 0621A40179 Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::548" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::548; helo=mail-pg1-x548.google.com; envelope-from=3zmepawykd4ut3wr73pxxpun.lxvrw2nu-5r0nm-ujwur121.x13x1u.x0p@flex--kuniyu.bounces.google.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=GnUWwwrU Received: from mail-pg1-x548.google.com (mail-pg1-x548.google.com [IPv6:2607:f8b0:4864:20::548]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0621A40179 for ; Wed, 2 Dec 2026 06:57:41 +0000 (UTC) Received: by mail-pg1-x548.google.com with SMTP id 41be03b00d2f7-cdb45b4ed6bso6927832a12.3 for ; Tue, 01 Dec 2026 22:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796194661; x=1796799461; 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=72nQ3HaA+zqTgB2Zr0CRhE7MtUTl+VujIHfTJ1LP2KM=; b=GnUWwwrUJJFvTw91b57d6BeKZggrLEf3M1lmC9j5pM7rQCeViC+zh6k4ERGeRugSCH amk32PS7ZH4QTQAr11jkUO4VpUkAOB6smPQpN/t1Vav8nW/Kn5hnV7QXgCVfBhAxzMXJ /tH5cIgDj+ws83CAq4uTBqTa5MlPRfk6Iv5NoLHHbaYe0bzGgXWeB6VXwyNdWpkhGwzq 1nPDs85T27+026JudyzNQZU5sdNajyeTn1u62k2J0+mOJNyHAJlqa8e0qqZCfEEu6ErD XsZ5ZCOJJBeVk/NxlrphVuh9fehB0JsA1qCcHKYUKc44zYTyp4TXDq/U79MSSCptFDz0 8F/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796194661; x=1796799461; 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=72nQ3HaA+zqTgB2Zr0CRhE7MtUTl+VujIHfTJ1LP2KM=; b=YVrKGjmo9uNbZ6Tz7wgV5XSuENlLns2Ad17PgIF8zbpdqmeWHFubhc0fNOARqM2FRr XJiHk8kF2OcoB7PTS7gPjtK6OsS2bkrZXX0i0bcEbQps+ZH7/+6i0Lmlvkx3b3JSpgBp zN5UtjVdGYtQfts0jVK3eGRCPIOuqae8GLYYco8USv7oNwl0b4lHGZ2OMBWhNw+p9JoF hGcnMxomzKq93BLsn7CHeT231LAEjpLiqAT62Ja1Wxg7KpOQOH/GGBl++Wh35LTd18T9 IZB8Fi31gizGzTvdK7IrLfNrojddC5K4H23ggUjT4CBEAKHh3itG3pz3yhJmlEMNeICr CxXw== X-Forwarded-Encrypted: i=1; AL+hErH/Tp1XBA3LjWg0CzH0o7gOdpEIOvGsElfTipu/ZcJjW8wK2yPYExy9kiOnd6kzhAsoZLHh8Myi1UGgX1Qn0qg=@lists.osuosl.org X-Gm-Message-State: APuU4Z927R6euIpcq3kTxPoXK3O4YmAGK4Q8OOFo5xMCgIzAmScKmafJ GvXbN/h20WbfGhnoDerTRGDZ9a8Bv/EPNVWE4twOWEaNyRZRxEtCm2yxabL13LWFrK3jDMfCGMg +lNVDaw== X-Received: from plgo10.prod.google.com ([2002:a17:902:d4ca:b0:2ea:7f9c:2ce]) (user=kuniyu job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:19cb:b0:2e9:3dd0:c8d with SMTP id d9443c01a7336-2f03f1cf44emr441614425ad.14.1796194660647; Tue, 01 Dec 2026 22:57:40 -0800 (PST) Date: Wed, 2 Dec 2026 15:57:19 +0900 In-Reply-To: <20261202065737.207610-1-kuniyu@google.com> X-Archived-By: Mime-Version: 1.0 References: <20261202065737.207610-1-kuniyu@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202065737.207610-2-kuniyu@google.com> Subject: [PATCH v1 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 Cc: 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.4 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 custom DMA mapping. 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 b1f072ac2cea..7a33ab913069 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c +++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c @@ -595,48 +595,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)) @@ -3759,50 +3779,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 @@ -3830,7 +3806,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.911.g883d8bcb20-goog