Intel RSA加速卡結合Intel其QAT_Engine測試性能的提高,其支持的異步模式對性能的提高很大。linux
注意QAT_Engine只支持openssl1.1.0以上c++
硬件:H61 系統:2.6.32-64bits+gcc4.4.5 openssl:公版openssl1.1.1a 加速卡:Intel AV-ICE06(C62X系列)
git clone https://github.com/01org/QAT_Engine.git
git
apt-get update apt-get install pciutils-dev apt-get install g++ apt-get install pkg-config apt-get install libssl-dev
tar jxvf gmp-4.3.2.tar.bz2 cd gmp-4.3.2 mkdir build && cd build ../configure --prefix=/usr/local/gmp-4.3.2 make make install
tar -jzvf mpfr-3.1.4.tar.bz2 cd mpfr-3.1.4 mkdir build && cd build ../configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-4.3.2 make make install
tar -zxvf mpc-1.0.3.tar.gz mkdir build && cd build ../configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 make make install
tar -zxvf gcc-4.4.7.tar.gz cd gcc-4.4.7 mkdir build && cd build ../configure --prefix=/usr/local/gcc-4.4.7 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3 make make install
mkdir QAT && cd QAT tar -zxvf qat1.7.l.4.4.0-00023.tar.gz ./configure make qat-driver-install
解決方法: 刪除 /home/ssl/QAT/quickassist/qat/compat/qat_compat.h第107開始的pci_pcie_cap函數
解決方法: ../quickassist/qat/drivers/crypto/qat/qat_common/adf_clock.c:152 ../quickassist/qat/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c:165 ../quickassist/qat/drivers/crypto/qat/qat_common/adf_admin.c:166 以上3處替換爲udelay函數
沒有/usr/src/linux-headers-2.6.32-5-amd64-hz1000/include/crypto/md5.h文件 解決方法: 將 /home/ssl/QAT/quickassist/utilities/osal/src/linux/kernel_space/OsalCryptoInterface.c 88行if內的部分註釋掉,改爲跟else同樣。 或者直接將內核版本判斷改爲2.6.33,其他幾個地方也是同樣
驅動位於/lib/modules/2.6.32-5-amd64-hz1000/kernel/drivers/uio
github
cd QAT make adf-ctl-install make qat-service-install
service qat_service start service qat_service stop //中止軟件 service qat_service shutdown //中止軟件並移除驅動 或者 /etc/init.d/qat_service start /etc/init.d/qat_service stop //中止軟件 /etc/init.d/qat_service shutdown //中止軟件並移除驅動
在QAT目錄下, make samples-install
shell
6系列內核kernel_write函數是靜態的,sample驅動中用到會找不到。直接註釋掉便可,內核態測試才須要用到api
cp /home/ssl/QAT/quickassist/lookaside/access_layer/src/sample_code/performance/compression/calgary /lib/firmware cp /home/ssl/QAT/quickassist/lookaside/access_layer/src/sample_code/performance/compression/calgary32 /lib/firmware cp /home/ssl/QAT/quickassist/lookaside/access_layer/src/sample_code/performance/compression/canterbury /lib/firmware cp /home/ssl/QAT/build/cpa_sample_code /usr/local/bin/cpa_sample_code cp /home/ssl/QAT/build/cpa_sample_code.ko /usr/local/bin/cpa_sample_code.ko
在用戶態,啓動cpa_sample_code以前,確保LD_LIBRARY_PATH設置了libqat_s.so所在的路徑 在執行sample代碼前,必須已加載驅動且軟件已經啓動。能夠用一下命令確認 lsmod | grep "qa" service qat_service status 用戶態下,執行sample代碼:./cpa_sample_code 內核態下,執行sample代碼: insmod ./cpa_sample_code.ko
./config --prefix=/usr/local/ssl -Wl,-rpath,\${LIBRPATH} make depend (if recommended by the OpenSSL\* build system) make make install export OPENSSL_ENGINES=/usr/local/ssl/lib/engines-1.1
要帶Upstream QAT driver而且使用USDM組件bash
cd /QAT_Engine ./autogen.sh ./configure \ --with-qat_dir=/home/ssl/QAT \ --with-openssl_dir=/home/ssl/openssl-OpenSSL_1_1_1a \ --with-openssl_install_dir=/usr/local/ssl \ --enable-upstream_driver \ --enable-usdm make make install
解決:autoconf要求2.68以上,修改/QAT_Engine/ .tools/configure.ac第4行
解決:export PERL5LIB=$PERL5LIB:/home/ssl/openssl-OpenSSL_1_1_1a
解決:gcc4.9開始才支持此選項,能夠改爲-fstack-protector-all或者-fstack-protector
根據實際狀況選擇/QAT_Engine/qat/config/c6xx下配置拷貝到/etc
重啓加速驅動異步
./openssl engine -t -c -vvvv qat #會打出qat引擎的相關信息
# Software 純軟 ./openssl speed -elapsed rsa2048 # Synchronous 同步 ./openssl speed -engine qat -elapsed rsa2048 # Asynchronous1 異步 ./openssl speed -engine qat -elapsed -async_jobs 36 rsa2048 # Asynchronous2 異步 ./openssl speed -engine qat -elapsed -async_jobs 72 rsa2048
# Software 純軟 ./openssl speed -elapsed ecdsap256 # Synchronous 同步 ./openssl speed -engine qat -elapsed ecdsap256 # Asynchronous1 異步1 ./openssl speed -engine qat -elapsed -async_jobs 36 ecdsap256 # Asynchronous2 異步2 ./openssl speed -engine qat -elapsed -async_jobs 72 ecdsap256
# Software 純軟 ./openssl speed -elapsed ecdhp256 # Synchronous 同步 ./openssl speed -engine qat -elapsed ecdhp256 # Asynchronous1 異步1 ./openssl speed -engine qat -elapsed -async_jobs 36 ecdpp256 # Asynchronous2 異步2 ./openssl speed -engine qat -elapsed -async_jobs 72 ecdpp256