From owner-freebsd-hackers@freebsd.org Tue Oct 27 16:24:54 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 96E944534E7 for ; Tue, 27 Oct 2020 16:24:54 +0000 (UTC) (envelope-from kaduk@mit.edu) Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CLH9K4J3nz3Z38; Tue, 27 Oct 2020 16:24:53 +0000 (UTC) (envelope-from kaduk@mit.edu) Received: from kduck.mit.edu ([24.16.140.251]) (authenticated bits=56) (User authenticated as kaduk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 09RGOkwG009696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2020 12:24:50 -0400 Date: Tue, 27 Oct 2020 09:24:45 -0700 From: Benjamin Kaduk To: Mark Johnston Cc: Neel Chauhan , freebsd-hackers@freebsd.org Subject: Re: QAT driver Message-ID: <20201027162445.GN39170@kduck.mit.edu> References: <20201026200059.GA66299@raichu> <723fbd7326df42ce30cd5e361db9c736@neelc.org> <20201027032720.GB31663@raichu> <20201027045735.GJ39170@kduck.mit.edu> <20201027130754.GE31663@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027130754.GE31663@raichu> X-Rspamd-Queue-Id: 4CLH9K4J3nz3Z38 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of kaduk@mit.edu designates 18.9.28.11 as permitted sender) smtp.mailfrom=kaduk@mit.edu X-Spamd-Result: default: False [-2.92 / 15.00]; ARC_NA(0.00)[]; RWL_MAILSPIKE_VERYGOOD(0.00)[18.9.28.11:from]; RECEIVED_SPAMHAUS_PBL(0.00)[24.16.140.251:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:18.9.28.0/24]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[mit.edu]; NEURAL_HAM_LONG(-1.00)[-0.999]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.61)[-0.611]; NEURAL_HAM_MEDIUM(-1.01)[-1.011]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:3, ipnet:18.9.0.0/16, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[freebsd-hackers]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 16:24:54 -0000 On Tue, Oct 27, 2020 at 09:07:54AM -0400, Mark Johnston wrote: > On Mon, Oct 26, 2020 at 09:57:35PM -0700, Benjamin Kaduk wrote: > > On Mon, Oct 26, 2020 at 11:27:20PM -0400, Mark Johnston wrote: > > > On Mon, Oct 26, 2020 at 08:00:08PM -0700, Neel Chauhan wrote: > > > > Hi, > > > > > > > > This is great news for me with my home HPE ML110 G10/Xeon 4108 server. > > > > > > > > However, I will not be able to test this patch unless it can get > > > > backported to 12.1 or 12.2 once it's out, and I don't expect backporting > > > > to happen. > > > > > > Indeed, it wouldn't appear before 12.3. > > > > > > > I have one question about this: will I be able to use this to accelerate > > > > OpenSSL? Is additional code needed? > > > > > > In principle OpenSSL can make use of cryptodev(4) using the cryptodev > > > engine, which would allow requests to be handled by qat(4) (or any other > > > hardware crypto driver loaded in the kernel). I don't know that the > > > cryptodev engine is really maintained these days though. More > > > > The openssl cryptodev engine was rewritten in > > https://github.com/openssl/openssl/pull/3744 , but engines are going to be > > deprecated in openssl 3.0. > > Is this the devcrypto engine? It appears to be broken on FreeBSD: it Yes, the devcrypto engine. > tries to invoke CIOCGSESSION on a /dev/crypto descriptor, but one is > supposed to first use CRIOGET to get a separate descriptor with which > sessions are associated. As the linked page says, "implemented based on cryptodev-linux and then adjusted to work on FreeBSD 8.4". I don't know of anyone testing it on a recent FreeBSD prior to your report. > truss(1)ing "openssl speed -evp aes-128-cbc -engine devcrypto" yields: > > 82677: openat(AT_FDCWD,"/dev/crypto",O_RDWR,00) = 3 (0x3) > 82677: ioctl(3,CIOCGSESSION,0x7fffffffde70) ERR#22 'Invalid argument' > 82677: ioctl(3,CIOCGSESSION,0x7fffffffde70) ERR#22 'Invalid argument' > 82677: ioctl(3,CIOCGSESSION,0x7fffffffde70) ERR#22 'Invalid argument' > 82677: ioctl(3,CIOCGSESSION,0x7fffffffde70) ERR#22 'Invalid argument' > 82677: ioctl(3,CIOCGSESSION,0x7fffffffde70) ERR#22 'Invalid argument' > ... > > > In theory someone (Intel?) could write an > > openssl "provider" that utilizes the QAT hardware, but (unsurprisingly, > > given that the interface isn't even finalized yet!) no one has done that > > yet. > > What's the difference between providers and engines? There is a QAT > engine for OpenSSL. OpenSSL is getting a big rearchitecture for the 3.0.0 release, and providers are the new way to provide external implementations for crypto algorithms and such; the openssl/provider interface is arguably cleaner and definitely more extensible than the openssl/engine interface. There's a bit more information at, e.g., https://wiki.openssl.org/index.php/OpenSSL_3.0#Providers and https://www.openssl.org/blog/blog/2019/11/07/3.0-update/ (which links to https://www.openssl.org/docs/OpenSSL300Design.html). -Ben