From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0244144019 for ; Mon, 13 May 2024 13:12:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F05834028A; Mon, 13 May 2024 13:12:12 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B04924003C for ; Mon, 13 May 2024 13:12:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715598731; 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=lgEDKO+FFy0H+jTJuP7ss9dHxaVK6lOn8E0Y25zR3Jc=; b=eQguaiyW1ZPPAjPp50NaOQEUReRZg4jHkaI0iBakrLl1DKsMrKwBoAc73uhEtkwCz4V9J7 nDEqmATQXC+Z/CVrByxLNyehk1Zx5ojwMqYqrdxYj3g82mNix2IsAaovZYCj7yfusClKja /zXkKZhZVznAk6O7Mo9KKIHe0cj3d1g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-DE9vFbdOMZqKEW32K59M9w-1; Mon, 13 May 2024 07:12:10 -0400 X-MC-Unique: DE9vFbdOMZqKEW32K59M9w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5D7B800994; Mon, 13 May 2024 11:12:09 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDAC12026D68; Mon, 13 May 2024 11:12:08 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Yu Jiang , Bruce Richardson , stable@dpdk.org Subject: [PATCH v2] eal/unix: support ZSTD compression for firmware Date: Mon, 13 May 2024 13:12:04 +0200 Message-ID: <20240513111204.3120460-1-david.marchand@redhat.com> In-Reply-To: <20240508095214.2541115-1-david.marchand@redhat.com> References: <20240508095214.2541115-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Ubuntu 24.04 started to compress firmware files with ZSTD compression. Bugzilla ID: 1437 Cc: stable@dpdk.org Signed-off-by: David Marchand --- Chances since v1: - fixed link issue when libarchive is not available, - Cc'd stable@dpdk.org, --- lib/eal/unix/eal_firmware.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c index 1d47e879c8..31de027598 100644 --- a/lib/eal/unix/eal_firmware.c +++ b/lib/eal/unix/eal_firmware.c @@ -16,6 +16,8 @@ #include "eal_firmware.h" #include "eal_private.h" +static const char * const compression_algorithms[] = { "xz", "zst" }; + #ifdef RTE_HAS_LIBARCHIVE struct firmware_read_ctx { @@ -37,7 +39,11 @@ firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize) err = archive_read_support_filter_xz(ctx->a); if (err != ARCHIVE_OK && err != ARCHIVE_WARN) - goto error; + EAL_LOG(DEBUG, "could not initialise libarchive for xz compression"); + + err = archive_read_support_filter_zstd(ctx->a); + if (err != ARCHIVE_OK && err != ARCHIVE_WARN) + EAL_LOG(DEBUG, "could not initialise libarchive for zstd compression"); if (archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK) goto error; @@ -148,16 +154,22 @@ rte_firmware_read(const char *name, void **buf, size_t *bufsz) ret = firmware_read(name, buf, bufsz); if (ret < 0) { - snprintf(path, sizeof(path), "%s.xz", name); - path[PATH_MAX - 1] = '\0'; + unsigned int i; + + for (i = 0; i < RTE_DIM(compression_algorithms); i++) { + snprintf(path, sizeof(path), "%s.%s", name, + compression_algorithms[i]); + path[PATH_MAX - 1] = '\0'; + if (access(path, F_OK) != 0) + continue; #ifndef RTE_HAS_LIBARCHIVE - if (access(path, F_OK) == 0) { EAL_LOG(WARNING, "libarchive not linked, %s cannot be decompressed", path); - } #else - ret = firmware_read(path, buf, bufsz); + ret = firmware_read(path, buf, bufsz); #endif + break; + } } return ret; } -- 2.44.0