From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=XRYx18fV; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 9F8D75A061B for ; Wed, 12 Mar 2025 04:07:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1741748820; bh=nKpaGzD14/O8GXM9hUxcWspDY7NqGvOUL5gRg/ZG0VQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRYx18fVIl9fQz5q6u0+RbPlLxW0QZJmKKHkA3o4poB3RQ4KKfvPv4D1uUrmLNsYm oeD7zbeFW6Hck9QIG4D4pRMf237rCQV7BMfYoqtVvfQybKBGyHcuZq8XGqY6BN0ffF AdK/a5hC5/k197k2O+NXyYxxgzg4MCQ03f4FN2M7JcgYzFlMmmxaqdDoXWlKgdfgj4 xrz98L1XF7MRekfE+9Fx/qsVwHE7bnwzHJDJTYkmEkZYEyAZBDTIXi/IsT3/u2rTS/ aOpdsxyaYm6AOwmU8JY/qBVz5yBlYtJfhir31J52ZCwqmCrOnpWzXeomhrGC+kCaeq tusTKGUgyPhvg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZCFsc5fkfz4xHV; Wed, 12 Mar 2025 14:07:00 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 7/9] Simplify sizing of pkt_buf Date: Wed, 12 Mar 2025 13:18:37 +1100 Message-ID: <20250312021839.2405877-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250312021839.2405877-1-david@gibson.dropbear.id.au> References: <20250312021839.2405877-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: NIQJWPS4IEMNNHU5ZJVMDTOWKAPR2XCQ X-Message-ID-Hash: NIQJWPS4IEMNNHU5ZJVMDTOWKAPR2XCQ X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: We define the size of pkt_buf as large enough to hold 128 maximum size packets. Well, approximately, since we round down to the page size. We don't have any specific reliance on how many packets can fit in the buffer, we just want it to be big enough to allow reasonable batching. The current definition relies on the confusingly named ETH_MAX_MTU and adds in sizeof(uint32_t) rather non-obviously for the pseudo-physical header used by the qemu socket (passt mode) protocol. Instead, just define it to be 8MiB, which is what that complex calculation works out to. Signed-off-by: David Gibson --- passt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/passt.h b/passt.h index 6b248051..8f450912 100644 --- a/passt.h +++ b/passt.h @@ -69,8 +69,8 @@ union epoll_ref { static_assert(sizeof(union epoll_ref) <= sizeof(union epoll_data), "epoll_ref must have same size as epoll_data"); -#define PKT_BUF_BYTES \ - ROUND_DOWN(((ETH_MAX_MTU + sizeof(uint32_t)) * 128), PAGE_SIZE) +/* Large enough for ~128 maximum size frames */ +#define PKT_BUF_BYTES (8UL << 20) #define TAP_MSGS \ DIV_ROUND_UP(PKT_BUF_BYTES, ETH_ZLEN - 2 * ETH_ALEN + sizeof(uint32_t)) -- 2.48.1