From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 023CCA04AA;
	Tue,  8 Sep 2020 10:43:01 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 020742BAB;
	Tue,  8 Sep 2020 10:43:01 +0200 (CEST)
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id 87F2F2BA8
 for <dev@dpdk.org>; Tue,  8 Sep 2020 10:42:58 +0200 (CEST)
IronPort-SDR: iqKgHYk/pAJ6dE9rNndTQRUpfo/0oaU/ONX3BAWrg23n+LFkVR023qMmNbl1YNfNyCT78gKBnv
 xr+PQMDb3H1g==
X-IronPort-AV: E=McAfee;i="6000,8403,9737"; a="159068001"
X-IronPort-AV: E=Sophos;i="5.76,405,1592895600"; d="scan'208";a="159068001"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga003.fm.intel.com ([10.253.24.29])
 by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 08 Sep 2020 01:42:57 -0700
IronPort-SDR: 7OQtAyO/xbDVREufELs1BwYz4wjmAETQ88o3FObcnOMUAqzQ8B0jqlqB7/iSmTI/0rpIfomi8S
 HBQh4o2wyWVw==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.76,405,1592895600"; d="scan'208";a="341105544"
Received: from silpixa00398673.ir.intel.com (HELO
 silpixa00398673.ger.corp.intel.com) ([10.237.223.136])
 by FMSMGA003.fm.intel.com with ESMTP; 08 Sep 2020 01:42:55 -0700
From: Fan Zhang <roy.fan.zhang@intel.com>
To: dev@dpdk.org
Cc: akhil.goyal@nxp.com, fiona.trahe@intel.com, arkadiuszx.kusztal@intel.com,
 adamx.dybkowski@intel.com, Fan Zhang <roy.fan.zhang@intel.com>
Date: Tue,  8 Sep 2020 09:42:49 +0100
Message-Id: <20200908084253.81022-1-roy.fan.zhang@intel.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20200904152539.20608-1-roy.fan.zhang@intel.com>
References: <20200904152539.20608-1-roy.fan.zhang@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [dpdk-dev v9 0/4] cryptodev: add data-path service APIs
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Direct crypto data-path service are a set of APIs that especially provided for
the external libraries/applications who want to take advantage of the rich
features provided by cryptodev, but not necessarily depend on cryptodev
operations, mempools, or mbufs in the their data-path implementations.

The direct crypto data-path service has the following advantages:
- Supports raw data pointer and physical addresses as input.
- Do not require specific data structure allocated from heap, such as
  cryptodev operation.
- Enqueue in a burst or single operation. The service allow enqueuing in
  a burst similar to ``rte_cryptodev_enqueue_burst`` operation, or only
  enqueue one job at a time but maintaining necessary context data locally for
  next single job enqueue operation. The latter method is especially helpful
  when the user application's crypto operations are clustered into a burst.
  Allowing enqueue one operation at a time helps reducing one additional loop
  and also reduced the cache misses during the double "looping" situation.
- Customerizable dequeue count. Instead of dequeue maximum possible operations
  as same as ``rte_cryptodev_dequeue_burst`` operation, the service allows the
  user to provide a callback function to decide how many operations to be
  dequeued. This is especially helpful when the expected dequeue count is
  hidden inside the opaque data stored during enqueue. The user can provide
  the callback function to parse the opaque data structure.
- Abandon enqueue and dequeue anytime. One of the drawbacks of
  ``rte_cryptodev_enqueue_burst`` and ``rte_cryptodev_dequeue_burst``
  operations are: once an operation is enqueued/dequeued there is no way to
  undo the operation. The service make the operation abandon possible by
  creating a local copy of the queue operation data in the service context
  data. The data will be written back to driver maintained operation data
  when enqueue or dequeue done function is called.

The cryptodev data-path service uses

Cryptodev PMDs who supports this feature will have
``RTE_CRYPTODEV_FF_SYM_HW_DIRECT_API`` feature flag presented. To use this
feature the function ``rte_cryptodev_get_dp_service_ctx_data_size`` should
be called to get the data path service context data size. The user should
creates a local buffer at least this size long and initialize it using
``rte_cryptodev_dp_configure_service`` function call.

The ``rte_cryptodev_dp_configure_service`` function call initialize or
updates the ``struct rte_crypto_dp_service_ctx`` buffer, in which contains the
driver specific queue pair data pointer and service context buffer, and a
set of function pointers to enqueue and dequeue different algorithms'
operations. The ``rte_cryptodev_dp_configure_service`` should be called when:

- Before enqueuing or dequeuing starts (set ``is_update`` parameter to 0).
- When different cryptodev session, security session, or session-less xform
  is used (set ``is_update`` parameter to 1).

Two different enqueue functions are provided.

- ``rte_cryptodev_dp_sym_submit_vec``: submit a burst of operations stored in
  the ``rte_crypto_sym_vec`` structure.
- ``rte_cryptodev_dp_submit_single_job``: submit single operation.

Either enqueue functions will not command the crypto device to start processing
until ``rte_cryptodev_dp_submit_done`` function is called. Before then the user
shall expect the driver only stores the necessory context data in the
``rte_crypto_dp_service_ctx`` buffer for the next enqueue operation. If the user
wants to abandon the submitted operations, simply call
``rte_cryptodev_dp_configure_service`` function instead with the parameter
``is_update`` set to 0. The driver will recover the service context data to
the previous state.

To dequeue the operations the user also have two operations:

- ``rte_cryptodev_dp_sym_dequeue``: fully customizable deuqueue operation. The
  user needs to provide the callback function for the driver to get the
  dequeue count and perform post processing such as write the status field.
- ``rte_cryptodev_dp_sym_dequeue_single_job``: dequeue single job.

Same as enqueue, the function ``rte_cryptodev_dp_dequeue_done`` is used to
merge user's local service context data with the driver's queue operation
data. Also to abandon the dequeue operation (still keep the operations in the
queue), the user shall avoid ``rte_cryptodev_dp_dequeue_done`` function call
but calling ``rte_cryptodev_dp_configure_service`` function with the parameter
``is_update`` set to 0.

There are a few limitations to the data path service:

* Only support in-place operations.
* APIs are NOT thread-safe.
* CANNOT mix the direct API's enqueue with rte_cryptodev_enqueue_burst, or
  vice versa.

v9:
- Changed return types of submit_done() and dequeue_done() APIs.
- Added release note update. 

v8:
- Updated following by comments.
- Fixed a few bugs.
- Fixed ARM build error.
- Updated the unit test covering all tests.

v7:
- Fixed a few typos.
- Fixed length calculation bugs.

v6:
- Rebased on top of DPDK 20.08.
- Changed to service ctx and added single job submit/dequeue.

v5:
- Changed to use rte_crypto_sym_vec as input.
- Changed to use public APIs instead of use function pointer.

v4:
- Added missed patch.

v3:
- Instead of QAT only API, moved the API to cryptodev.
- Added cryptodev feature flags.

v2:
- Used a structure to simplify parameters.
- Added unit tests.
- Added documentation.

Fan Zhang (4):
  cryptodev: add crypto data-path service APIs
  crypto/qat: add crypto data-path service API support
  test/crypto: add unit-test for cryptodev direct APIs
  doc: add cryptodev service APIs guide

 app/test/test_cryptodev.c                     | 461 ++++++++-
 app/test/test_cryptodev.h                     |   7 +
 app/test/test_cryptodev_blockcipher.c         |  51 +-
 doc/guides/prog_guide/cryptodev_lib.rst       |  90 ++
 doc/guides/rel_notes/release_20_11.rst        |   7 +
 drivers/common/qat/Makefile                   |   1 +
 drivers/crypto/qat/meson.build                |   1 +
 drivers/crypto/qat/qat_sym.h                  |  13 +
 drivers/crypto/qat/qat_sym_hw_dp.c            | 947 ++++++++++++++++++
 drivers/crypto/qat/qat_sym_pmd.c              |   9 +-
 lib/librte_cryptodev/rte_crypto.h             |   9 +
 lib/librte_cryptodev/rte_crypto_sym.h         |  49 +-
 lib/librte_cryptodev/rte_cryptodev.c          |  98 ++
 lib/librte_cryptodev/rte_cryptodev.h          | 335 ++++++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h      |  48 +-
 .../rte_cryptodev_version.map                 |  10 +
 16 files changed, 2062 insertions(+), 74 deletions(-)
 create mode 100644 drivers/crypto/qat/qat_sym_hw_dp.c

-- 
2.20.1