Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1680758lqz; Mon, 1 Apr 2024 13:46:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXklZS2nl6jhYSdfxW1soDMNDoiKHnhF9NbS5ENAZH3c8iQA1k4yt+gCn43tatZeiE7PMsAdQTwk/BV/dt05y7o+QzwqR8wM1cGEWLVBA== X-Google-Smtp-Source: AGHT+IHe7cvM/z118EQ54qKJoc/DRyIW2Tnnr9iCD+/ewgWOt4IzpRQaYaWSbTgApI/m6Az9LvoG X-Received: by 2002:a05:6358:2624:b0:183:630a:a88d with SMTP id l36-20020a056358262400b00183630aa88dmr13398146rwc.9.1712004410155; Mon, 01 Apr 2024 13:46:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712004410; cv=pass; d=google.com; s=arc-20160816; b=KMsKAtkeyGIYOhHgzVm/lZYYvFpRLWfQ9e7ZBbbx7p+fPyckGNSIOdhB7WRbRqLcTa W5SaB8kwJgNJOjrVBF/T7a3aj+T5LHYzoCdvbQjD+VdF3x0Dx9dlywOeIPnIYfq3YT/7 v7auTlEPLZFMlHmHJnBdWx5v1c2ieSN6/VZLXlB1dWp+8Ers4nLd8YdEpqf+pR4UQia7 YAu6o/gGJCm4i2pgYPLDm/ev7N4+RTgHUJPvM1SMQZrPtllWaHx1yzcr1LVXBBpux4Mg epmGPYu/GVDx+XceVco5uho5Ba1ejmzmFEkWX6DzzXbjdmp8agoU2KUC46uc5ym7HrQu YBCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=sN2OnWo1blaAHUPbQ3DGs+S1l5xEBgA9JyrPdsZmu3Y=; fh=A7QWxareB19hl5EgTLakscawVJufUTl1yK9gb2fbOTw=; b=JJ9+cqz7SIATArJka/V6MDQrlnil0bUDRpDoTNxSxnU9A+2k74YYF2b1nNajSuLC4t wz4Jrac+d+R24RTCmN2r0tEVitRb6K3H+A8K5G/+7CX6Mr6WVofSbY2Pa4ipgFDkyR7u 7WbW+41a5+1gXu/+RtlumXjhJVP1/HnKJD73aJuck05GYjBVIPWwYgVM3UIgeEefayVW cbQc56hXIOwsabdUWGSJc2VQnIyfYOdBbv16dq7rYR1FUSYTFfZPffHKK2v8kU9XwF13 vRlhgEauASSYhe5rRW4DfZ7ApTsjXKpIquL/Gv7sp5uYT/lsiTAaH30uN+W7x7tAb+0y iOGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ORbPADi+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-crypto+bounces-3238-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g12-20020a63e60c000000b005f059e70fa9si9452783pgh.747.2024.04.01.13.46.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 13:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3238-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ORbPADi+; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-crypto+bounces-3238-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C22DB282113 for ; Mon, 1 Apr 2024 20:46:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2148753E16; Mon, 1 Apr 2024 20:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ORbPADi+" X-Original-To: linux-crypto@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02E3C50271; Mon, 1 Apr 2024 20:46:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712004386; cv=none; b=g+/RhOIap6e9L8gFyUwElUYGn0+1V+4FzbFmpDkAzsdbk6Mfv3I0wwABhcpw4BPzks7b2g6TojYS8xFrecDnyi3GtKeWqbeJigmXhHnlrwOLvai1X0xbJ7XwHiLHYuFW1C47WsZ2R9FuQCs9z+ZPns5YHzXCp9KmE4HtudojqKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712004386; c=relaxed/simple; bh=sN2OnWo1blaAHUPbQ3DGs+S1l5xEBgA9JyrPdsZmu3Y=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=piCzWQI/2slOmhEIuNaV72NkP+ZbXN29eJd6EdPebK8UcuAlX6cglS3LstyJWga/e5ffRR9n3+FMlYc0vZKWVUei1kCG7JlFMp/aCNCjNruOiaBc0/xqUA5M9EW3yydW55uVv/nwMgq1HbvdT4K9rSUZuEyUhha/1lYRVaZ7vbA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ORbPADi+; arc=none smtp.client-ip=192.198.163.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712004385; x=1743540385; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=sN2OnWo1blaAHUPbQ3DGs+S1l5xEBgA9JyrPdsZmu3Y=; b=ORbPADi+EKO2mby/HJpGPMUS8e3ylb68y9ILgjbuMTwWdb6+MRPC8WQQ DrP78fpZxfEqC8N6IHz/UYIkaCAIuHVYsFWpeTQusmcEt0TwUYhF9YFLv oBFhPeFXGy4/cRHhOkyGQ6DPDoc5uyKDHhWEiS0PiU3BKyh2ePgGq5xTK h9qTDugU9sfwpzah0l7FAI/rPh4GjhzDjAzJwP8KBn4+1CgtjB9B/7mxJ k2ewpVuBLxMPi5ain5gOrD69VjSEx0HL9p13Ka302Q5xJjhbYksBn2KeD StJg4wjpe3s3CuIYzxSlD248C9EmAYxnetoHXWpEFr57YdIa3o5L8gfC4 A==; X-CSE-ConnectionGUID: v//Yf4TRT9ips8F5xDPyhQ== X-CSE-MsgGUID: jKAyL9vxRIKzBsqFFthhXA== X-IronPort-AV: E=McAfee;i="6600,9927,11031"; a="7012898" X-IronPort-AV: E=Sophos;i="6.07,173,1708416000"; d="scan'208";a="7012898" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2024 13:46:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,173,1708416000"; d="scan'208";a="17784626" Received: from a4bf0157aa04.jf.intel.com ([10.54.34.37]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2024 13:46:24 -0700 Message-ID: Subject: Re: [PATCH 0/4] crypto: Add new compression modes for zlib and IAA From: Andre Glover To: Eric Biggers Cc: tom.zanussi@linux.intel.com, herbert@gondor.apana.org.au, davem@davemloft.net, dave.jiang@intel.com, fenghua.yu@intel.com, wajdi.k.feghali@intel.com, james.guilford@intel.com, vinodh.gopal@intel.com, tony.luck@intel.com, linux-crypto@vger.kernel.org, dmaengine@vger.kernel.org Date: Mon, 01 Apr 2024 13:46:23 -0700 In-Reply-To: <20240329024647.GA20263@sol.localdomain> References: <20240329024647.GA20263@sol.localdomain> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi Eric, Thank you for reviewing the patch. Please see responses to your questions inline below. On Thu, 2024-03-28 at 19:46 -0700, Eric Biggers wrote: > On Thu, Mar 28, 2024 at 10:44:41AM -0700, Andre Glover wrote: > > The 'canned' compression mode implements a compression scheme that > > uses a statically defined set of Huffman tables, but where the > > Deflate > > Block Header is implied rather than stored with the compressed > > data.=20 >=20 > This already exists in standard DEFLATE; it's called fixed mode.=C2=A0 Se= e > section > 3.2.6 of RFC1951 > (https://datatracker.ietf.org/doc/html/rfc1951#page-12). >=20 > I think that what's going on is that you've implemented a custom > variant of > DEFLATE where you set the fixed Huffman codes to something different > from the > ones defined in the standard. >=20 > Is that correct, or are there other differences? >=20 We view it as a variant of dynamic block Deflate as opposed to a variant of fixed. In particular, it is compressing the input with static Huffman tables (i.e. ones that do not vary with the input), and where the Deflate block header (which is a constant) is not stored with the compressed data. If the missing block header were to be prepended to the compressed data, the result would be a valid dynamic compressed block. One might think of this as vaguely similar to dictionary compression. In that case, the dictionary is not stored with the compressed data but is agreed to by the compressor and decompression. In the case of canned compression, the header is not stored with the compressed data but is agreed to by both entities. > Actually, looking at your zlib_tr_flush_block(), it looks instead of > using the > reserved block type value (3) or redefining the meaning of the fixed > block type > value (1), you actually deleted the BTYPE and BFINAL fields from the > data stream > entirely.=C2=A0 So the stream no longer stores the type of block or the > flag that > indicates whether the block is the final one or not. >=20 > That has the property that there cannot be any standard blocks, even > uncompressed blocks, included in the data stream anymore.=C2=A0 Is that > intentional? >=20 Conceptually, there is a valid dynamic block header associated with the compressed data, it is just not stored with the data in order to save space (since it is effectively an unchanging constant). In this usage, it is envisioned that the output would consist of a single Deflate block (i.e. the implied header is marked as BFINAL). In theory, one could have the implied block header not marked as BFINAL, and so the compressed data would need to contain at least two blocks (i.e. the body of the initial block, an EOB, and a normal block with header), but this would be counterproductive to the intended usage. > Maybe this is why you're using the name "canned", instead of going > with > something more consistent with the existing "fixed" name, like > "custom-fixed"? >=20 Again, we view this as a variant of dynamic compression rather than as a variant of fixed compression. We use the term "static" to describe compression with a dynamic block where the tables are unchanging (i.e. not dependent on the input data) . This can allow the compression to be done in one pass rather than two. The "canned" compression uses a static table, but is different in that the header is implied rather than stored. > I wonder what the plan is for when the next hardware vendor tries to > do this and > chooses their own Huffman codes, different from yours.=C2=A0 Or what if > Intel decides > the Huffman codes they chose aren't the best ones anymore and > releases new > hardware that uses different codes.=C2=A0 Will we perhaps be getting a > tinned mode > too? >=20 The Huffman tables are not built into the hardware. The Huffman tables/block header is in this case built into the software. The same tables are embedded in the zlib portion of the patch for software compression/decompression and in the hardware driver portion of the patch for IAA compression/decompression. The hardware itself can work with any desired set of tables. Thanks, Andre