/******************************************************************************
 *
 *   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright(c) 2007-2026 Intel Corporation
 * 
 *  version: QAT.B.3.15.0-00012
 *   These contents may have been developed with support from one or more
 *   Intel-operated generative artificial intelligence solutions.
 *
 *****************************************************************************/

===============================================================================


March, 2024
===============================================================================

Quick References
================

    - https://intel.com/quickassist (overview)

      https://developer.intel.com/quickassist (developers)

    - Intel® QuickAssist Technology (QAT) Message of the Week (Full Collateral List)
      https://cdrdv2.intel.com/v1/dl/getContent/738128 (requires account)

    - Getting Started Guides:

Intel® QuickAssist Technology Software for Linux* - Getting Started Guide - HW version 1.7
https://cdrdv2.intel.com/v1/dl/getContent/710059 (public)

Intel® QuickAssist Technology Software for Linux* - Getting Started Guide - HW version 2.0
https://cdrdv2.intel.com/v1/dl/getContent/632506 (requires account)

    - Programmer's Guides:

Intel® QuickAssist Technology Software for Linux* - Programmer's Guide - HW version 1.7
https://cdrdv2.intel.com/v1/dl/getContent/710060 (public)


Intel® QuickAssist Technology Software for Linux* - Programmer's Guide - HW version 2.0
https://cdrdv2.intel.com/v1/dl/getContent/743912 (public)

===============================================================================

Overview
=========

Intel® QuickAssist Technology provides cryptographic and compression acceleration
capabilities used to improve performance and efficiency across the data center.

Note: This README applies to QAT1.6, QAT1.7, and QAT2.0 devices. Not all
sections may apply to your device generation.

===============================================================================

Licensing
==========

This product is released under the BSD-3-Clause License.

Files within this project have various inbound licenses, listed below:
        - Dual BSD/GPLv2 License
        - BSD License

Binary files are provided under the binary redistribution license. Please see
the file LICENSE contained in the top level folder.


===============================================================================

Compilation and installation

===============================================================================

1) QAT compilation requires the following dependencies:

    Libraries:
    - openssl    >= 1.1.1
    - zlib       >= 1.2.3

    Tools:
    - clang      >= 10.0.0
    - gcc        >= 4.4.7
    - g++        >= 4.4.7

    Development packages:
    - libtool
    - automake
    - autoconf
    - nasm

    These dependencies can be installed on FreeBSD with:

    # pkg install -y openssl gcc libtool automake autoconf nasm bash

    FreeBSD kernel source requirement:

    Building the QAT kernel module (qat.ko) requires the FreeBSD kernel source
    tree at /usr/src, matching the exact branch of the running kernel. An ABI
    mismatch between /usr/src and the running kernel causes the modules to be
    rejected during installation with a "version mismatch" linker error (which
    may be reported by kldload as "already loaded or in kernel").

    a) Install git and bash:

       # pkg install -y git-lite bash

    b) Check the running kernel version and select the matching branch
       (e.g. releng/15.1 for 15.1-RELEASE, stable/15 for 15.x-STABLE):

       # uname -r

    c) If /usr/src is missing or empty, clone the matching branch:

       # git clone --depth 1 -b <branch> https://git.FreeBSD.org/src.git /usr/src

    d) If /usr/src already exists, align it to the running kernel branch:

       # git -C /usr/src fetch --depth=1 origin <branch>:refs/remotes/origin/<branch>
       # git -C /usr/src checkout refs/remotes/origin/<branch>

===============================================================================

2) Configuration process:

    To setup the default build configuration - call:
    # ./autogen.sh
    # ./configure

    Any other configuration setup can be found under
    "configuration options section" or by calling:

    # ./configure --help

    Note (QAT 4xxx / 420xx devices):

    The default ./configure generates device configuration files with
    Asymmetric Crypto and Data Compression services enabled (asym;dc). To
    configure alternative QAT services, please use the appropriate
    ./configure option. For example, to configure QAT for Symmetric Crypto
    and Data Compression services please use the following:

    # ./configure --enable-icp-dc-sym-only

    Using the ./configure flags is strongly recommended over manually editing
    /etc/420xx_devX.conf to ensure valid hardware acceleration unit
    allocations.

    To configure with nonstandard headers and libraries directories
    following environment variables have to be exported:

    # LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
    #             nonstandard directory <lib dir>

    # CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
    #             you have headers in a nonstandard directory <include dir>

    # export LDFLAGS="-L_path_to_lib__dir"
    # export CPPFLAGS="-I_path_to_include_dir_"
    # ./configure

===============================================================================

3) Compilation process:

    After the package has been configured properly,
    follow the steps below:

    Build:
    # make -j$(sysctl -n hw.ncpu)

    Installation - not stripped libraries (with debugging symbols):
    # make install

    Stripped libraries installation (without debugging symbols):
    # make install-strip

    Build and install sample code:
    # make samples
    # make samples-install

    Uninstall and clean up:
    # make uninstall
    # make clean
    # make distclean


===============================================================================

4) Configuration options

        There is a common example of invoke and can be illustrated as follow:

		./configure ICP_ANY_FLAG=path or
		./configure --enable-something

        If it is required to use more than one flag at once:

                ./configure ICP_ANY_PATH=path ICP_ANY_NAME=name --enable-something

Options are split into the two following sections:

Build flags:
	This set of flags has to be set (initial values are assigned by default)
	in order to process the proper QAT build.

	If a different setup if required - flags can be easily modified.

	Warning.
	Please keep in mind that any incorrect change might cause
	compilation problems - in such case default configuration setup is
	recommended to fix it.

Features flags:
	Enables or disables the additional features supported by QAT package

	--enable-icp-debug
		Enables debugging.

	--disable-param-check
		Disables parameters checking in the top-level APIs
		(Use for performance optimization).

	--disable-stats
		Disables statistic collection (Use for performance optimization).

	--enable-icp-log-syslog
		Enables debugging messages to be outputted to the
		system log instead of standard output.

	--enable-icp-sriov
		Enables Single-root I/O Virtualization in the QAT
		driver (available options: host, guest).

		Due to not common calling convention there is an example of
		invoke possibility:

		./configure --enable-icp-sriov=guest

		Note: --enable-icp-sriov=host is not currently supported in this
		release.

	--enable-icp-trace
		Enables tracing for the Cryptography API.

	--enable-icp-dc-only
		Enables driver supports only compression service
		(Can optimize size of build objects).

	--enable-icp-dc-sym-only
		Enables data compression and symmetric crypto services only.

	--enable-dc-error-simulation
		Enables Data Compression Error Simulation.

	--enable-icp-hb-fail-sim
		Enable Heartbeat Failure Simulation.

	--enable-icp-without-thread
		Removes mutex and spin locks for single thread applications.

	--enable-icp-qat-dbg
		Enable QAT Debuggability.

	--enable-legacy-lib-names
		Enables legacy names for libraries.

	--enable-legacy-algorithms              (QAT 1.7 and above)
		Enable legacy algorithms.

	MAX_MR
		Number of Miller Rabin rounds for prime operations. Setting this
		to a smaller value reduces the memory usage required by the
		driver.

		Type: value
		Default value: 50

===============================================================================

5) Running Applications as Non-Root User.

The installation of Intel® QAT software package configures the driver to allow
applications to run as Non-Root User. The users must be added to the 'qat' group.

When the make install is performed at the directory where the Intel® QAT package
is installed, the following /etc/devd/qat.conf file is created that is responsible
for setting up non-root access using devd.

The updates to the devd rules are performed during the installation of the Intel® QAT driver.

The following steps need to be manually applied:

Change the amount of max locked memory for the user (which is by default 64K).
This can be done by specifying the memorylocked limit for qat class

    Add qat class to login class capabilities database (/etc/login.conf) with
    extended wired memory for the `qat` group:

        qat:\
                :memorylocked=4096K:

    For the correct cpa_sample_code at least 128MB are required:

        qat:\
                :memorylocked=128M:

    Remember to rebuild the database after each change to the /etc/login.conf:

        cap_mkdb /etc/login.conf

    Add user with group `qat` and `qat` class:

        pw useradd bob -G qat -L qat

===============================================================================

6) Known Issues


Legal/Disclaimers
===================

INFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL(R) PRODUCTS.
NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL
PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S
TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY
WHATSOEVER, AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO
SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING
TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY
PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT. Intel® products are
not intended for use in medical, life saving, life sustaining, critical control
or safety systems, or in nuclear facility applications.

Intel® may make changes to specifications and product descriptions at any time,
without notice.

(C) Intel® Corporation 2022

* Other names and brands may be claimed as the property of others.

===============================================================================

