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 A36F0A0524; Wed, 2 Jun 2021 17:46:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 299474069F; Wed, 2 Jun 2021 17:46:52 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id E477740689 for ; Wed, 2 Jun 2021 17:46:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622648810; 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: in-reply-to:in-reply-to:references:references; bh=ai0M4+0Y9/jchSkHgOPJdCMtHpe5M8SOuryzgzasY8Y=; b=No1H/TF7HQWZ3rt3xu+chxq3ORLC1X+HA3b+A7eTfXwhdRNBSoGyI3jk93qEAWtkwZeLsq ALmD39bykp66IQmkhDZaQ6kzMJteC5/xiIx1an2bq166hE7XFLtoWEMPxqUZqe+nR8IhdH uaAIvwJt6geGq6hWAjfgwK/jWCUgobo= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-ymHG-gTGNoOGlNJ3zuQB_g-1; Wed, 02 Jun 2021 11:46:49 -0400 X-MC-Unique: ymHG-gTGNoOGlNJ3zuQB_g-1 Received: by mail-vs1-f72.google.com with SMTP id x76-20020a677c4f0000b0290258a100e1c0so717029vsc.17 for ; Wed, 02 Jun 2021 08:46:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ai0M4+0Y9/jchSkHgOPJdCMtHpe5M8SOuryzgzasY8Y=; b=Wn9grRceafFwe+pCu5kPW1PUPoVacl7DLWyHrjc0g6cnA1RFlGbVJXtV8eXMC9JcGR hr+WjoGAZfpWue6mvxDffvxkBD+IlOy8Q6bf2HFPzUmk+yTEYqNouCGE+bedJLO/Iif9 9bM3lGeZZvem/Ta4XYVZGUYcyTmeQIuwJ1Jv6SPTVzCI6Dly63zSRY/b1Dp7k+T9ecnT 3dxD/cyP3pJIbmFLnmDf8NDO80t1Ac1beI8/jgwoGO3UtWuGIAEBqKX2QXOEcIwzFHMK QhgryZfEtGX0GYvnifT9stiB/HjdFnj/f4bgQh0JKFPpl8FI5+ED0DDGeZ8kMuYutRp+ UUqg== X-Gm-Message-State: AOAM531jRVyfxLouusbRZXNOLyFLrpNspYAm/zzLgIQzcX614xxs7Dlf TxSPj+x8BF39UJSverD3RBqmbFaLE6vogjVSZpX8B5MUtktHD+D41eHSwR5uPA68cOsHyjJLns9 eB834j4KF61F1n3k+xAw= X-Received: by 2002:a05:6102:67a:: with SMTP id z26mr9584099vsf.10.1622648808578; Wed, 02 Jun 2021 08:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnEAE+ask4pKlMCBoLqdX1hLi4mlf26WiNbeYDLvIgg+JZVI/lY03oxGAM5mYh/qZp3CyvjS+cweMmYmPflS4= X-Received: by 2002:a05:6102:67a:: with SMTP id z26mr9584061vsf.10.1622648808379; Wed, 02 Jun 2021 08:46:48 -0700 (PDT) MIME-Version: 1.0 References: <20210602095836.24901-1-david.marchand@redhat.com> <20210602095836.24901-3-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Wed, 2 Jun 2021 17:46:36 +0200 Message-ID: To: Jerin Jacob Cc: dpdk-dev , Aaron Conole , Michael Santana , Bruce Richardson , Rasesh Mody , Shahed Shaikh , Qiming Yang , Qi Zhang , Heinrich Kuhn , Devendra Singh Rawat , Igor Russkikh , Ray Kinsella , Neil Horman , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 2/2] eal: handle compressed firmwares X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jun 2, 2021 at 1:13 PM Jerin Jacob wrote: > > +static int > > +firmware_read(const char *name, void **buf, size_t *bufsz) > > +{ > > + const size_t blocksize = 4096; > > + int ret = -1; > > + int err; > > +#ifdef RTE_HAS_LIBARCHIVE > > > I think, better to have small inline functions for libarchive variant > vs normal file accessors > in the group for open, access, read etc to avoid the ifdef clutter and > manage with one ifdef. That may be a bit artificial, since there is no reuse of such helpers for now. I'll have a try and see how it looks. > > +int > > +rte_firmware_read(const char *name, void **buf, size_t *bufsz) > > +{ > > + char path[PATH_MAX]; > > + int ret; > > + > > + ret = firmware_read(name, buf, bufsz); > > + if (ret < 0) { > > + snprintf(path, sizeof(path), "%s.xz", name); > > + path[PATH_MAX - 1] = '\0'; > > +#ifndef RTE_HAS_LIBARCHIVE > > See above There is nothing to abstract here. If you don't have libarchive, returning the .xz content to a driver is wrong. I prefer to leave this block as is. > > > + if (access(path, F_OK) == 0) { > > + RTE_LOG(WARNING, EAL, "libarchive not available, %s cannot be decompressed\n", > > + path); > > + } > > +#else > > + ret = firmware_read(path, buf, bufsz); > > +#endif > > > -- David Marchand