From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8B65942BB3;
	Sat, 27 May 2023 11:52:22 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7BB7C4282D;
	Sat, 27 May 2023 11:52:22 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id 32A7A4021D
 for <dev@dpdk.org>; Sat, 27 May 2023 11:52:21 +0200 (CEST)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 34R9PkEo018670; Sat, 27 May 2023 02:52:19 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0220;
 bh=BSJ2KiwMAu8U7fJrQBBnZ7ERts+xzYeZK/HONSzeGv4=;
 b=AtPMEKfS7sSkltz192JtuwSgHUvBiqc7Xr1mKnaoeIudLrWNNO+dbiH/YPO681vX5GCD
 Roiy3lFNK47UCoNYEc+7WhU5sSg475fF2o+gr9N6aqaRtu1K81OGyGN4Z2LoRLcWsI51
 yzM5t5QQ9w1ZyUX7TKvocMBfINIE41jxoJSd+AJDJt5UkJ6PK/G25cMfUPLvKLl12sMF
 ERx3zybfCK41S9Su6otaNFqOdM9PkpnhLTDAquqdudQieKEVCIxoOjYOTS+Ax6FpWt27
 JjwswMX2XrcUVWQTEtImLeFIdXmRmjAhUBQ7txS0sxLU2QmUyeyd5UyDcJ3WXW9wJfLR +g== 
Received: from dc5-exch01.marvell.com ([199.233.59.181])
 by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3quf7p81nr-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);
 Sat, 27 May 2023 02:52:19 -0700
Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;
 Sat, 27 May 2023 02:52:17 -0700
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com
 (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend
 Transport; Sat, 27 May 2023 02:52:17 -0700
Received: from BG-LT92004.corp.innovium.com (unknown [10.193.65.175])
 by maili.marvell.com (Postfix) with ESMTP id ADC6A5E7268;
 Sat, 27 May 2023 01:59:15 -0700 (PDT)
From: Anoob Joseph <anoobj@marvell.com>
To: Thomas Monjalon <thomas@monjalon.net>, Akhil Goyal <gakhil@marvell.com>,
 Jerin Jacob <jerinj@marvell.com>, Konstantin Ananyev
 <konstantin.v.ananyev@yandex.ru>
CC: Hemant Agrawal <hemant.agrawal@nxp.com>,
 =?UTF-8?q?Mattias=20R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>, "Kiran
 Kumar K" <kirankumark@marvell.com>,
 Volodymyr Fialko <vfialko@marvell.com>, <dev@dpdk.org>,
 Olivier Matz <olivier.matz@6wind.com>, Stephen Hemminger
 <stephen@networkplumber.org>
Subject: [PATCH v5 00/21] lib: add pdcp protocol
Date: Sat, 27 May 2023 14:28:49 +0530
Message-ID: <20230527085910.972-1-anoobj@marvell.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20230526210214.617-1-anoobj@marvell.com>
References: <20230526210214.617-1-anoobj@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: oONsyQFix2GwXTA0QtgcG1psmp3rUDbS
X-Proofpoint-ORIG-GUID: oONsyQFix2GwXTA0QtgcG1psmp3rUDbS
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26
 definitions=2023-05-27_06,2023-05-25_03,2023-05-22_02
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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

Add Packet Data Convergence Protocol (PDCP) processing library.

The library is similar to lib_ipsec which provides IPsec processing
capabilities in DPDK.

PDCP would involve roughly the following operations,
1. Transfer of user plane data
2. Transfer of control plane data
3. Header compression
4. Uplink data compression
5. Ciphering and integrity protection

PDCP library provides following control path APIs that is used to
configure various PDCP entities,
1. rte_pdcp_entity_establish()
2. rte_pdcp_entity_suspend()
3. rte_pdcp_entity_release()

PDCP process is split into 2 parts. One before crypto processing
(rte_pdcp_pkt_pre_process()) and one after crypto processing
(rte_pdcp_pkt_post_process()). Since cryptodev dequeue can return crypto
operations belonging to multiple entities, rte_pdcp_pkt_crypto_group()
is added to help grouping crypto operations belonging to same entity.

Similar to lib IPsec, lib PDCP would allow application to use same API
sequence while leveraging protocol offload features enabled by rte_security
library. Lib PDCP would internally change the handles registered for
*pre_process* and *post_process* based on features enabled in the entity.

Lib PDCP would create the required sessions on the device provided in entity to
minimize the application requirements. Also, the crypto_op allocation and free
would also be done internally by lib PDCP to allow the library to create
crypto ops as required for the input packets. For example, when control PDUs are
received, no cryptodev enqueue-dequeue is expected for the same and lib PDCP
is expected to handle it differently.

Lib PDCP utilizes reorder library for implementing in-order delivery. It
utilizes bitmap library for implementing status reports and track the COUNT
value of the packets received. To allow application to choose timer
implementation of choice, lib PDCP allows application to configure handles that
can be used for starting & stopping timers. Upon expiry, application can call
corresponding PDCP API(``rte_pdcp_t_reordering_expiry_handle``) for handling the
event. Unit tests are added to verify both rte_timer based timers as well as
rte_eventdev based timers.

PDCP tracks the sequence number of the received packets and during events such
as re-establishment, it is required to generate reports and transmit to the
peer. This series introduces ``rte_pdcp_control_pdu_create`` for handling
control PDU generation.

Changes in v5:
- Deferred patch adding thread safe processing.
- Updated release notes & MAINTAINERS file.

Changes in v4:
- Disabled 'annotate locks' with lib PDCP
- Enable PDCP autotest only when lib is enabled
- Use rwlock instead of spinlock
- Avoid per packet checks for thread safety (Stephen)
- In DL path, save count determined during pre-process in mbuf and
  use the same in post-process. Determining count again may lead To
  errors
- Simplified DL path threads to allow more common code between SN 12
  & 18


Changes in v3:
- Addressed review comments (Akhil)
- Addressed build failure in CI (tests with lib eventdev disabled)
- Addressed checkpatch issues
- Set only positive values to rte_errno (Akhil)

Changes in v2:
- Added control PDU handling
- Added t-Reordering timer
- Added in-order delivery
- Added status PDU generation
- Rebased on top of new features added in reorder library
- Split base patch
- Increased test coverage
- Improved thread safety

Changes from RFC
- Implementation for all APIs covering basic control plane & user plane packets
- Unit test leveraging existing PDCP vectors available in test_cryptodev
- Unit test performing both UL & DL operations to verify various protocol
  features
- Updated documentation

Sample application sequence:

	struct rte_mbuf **out_mb, *pkts[MAX_BURST_SIZE];
	struct rte_crypto_op *cop[MAX_BURST_SIZE];
	struct rte_pdcp_group grp[MAX_BURST_SIZE];
	struct rte_pdcp_entity *pdcp_entity;
	int nb_max_out_mb, ret, nb_grp;

	/* Create PDCP entity */
	pdcp_entity = rte_pdcp_entity_establish(&conf);

	/**
	 * Allocate buffer for holding mbufs returned during PDCP suspend,
	 * release & post-process APIs.
	 */

	/* Max packets that can be cached in entity + burst size */
	nb_max_out_mb = pdcp_entity->max_pkt_cache + 1;
	out_mb = rte_malloc(NULL, nb_max_out_mb * sizeof(uintptr_t), 0);
	if (out_mb == NULL) {
		/* Handle error */
	}

	while (1) {
		/* Receive packet and form mbuf */

		/**
		 * Prepare packets for crypto operation. Following operations
		 * would be done,
		 *
		 * Transmitting entity/UL (only data PDUs):
		 *  - Perform compression
		 *  - Assign sequence number
		 *  - Add PDCP header
		 *  - Create & prepare crypto_op
		 *  - Prepare IV for crypto operation (auth_gen, encrypt)
		 *  - Save original PDCP SDU (during PDCP re-establishment,
		 *    unconfirmed PDCP SDUs need to crypto processed again and
		 *    transmitted/re-transmitted)
		 *
		 *  Receiving entity/DL:
		 *  - Any control PDUs received would be processed and
		 *    appropriate actions taken. If data PDU, continue.
		 *  - Determine sequence number (based on HFN & per packet SN)
		 *  - Prepare crypto_op
		 *  - Prepare IV for crypto operation (decrypt, auth_verify)
		 */
		nb_success = rte_pdcp_pkt_pre_process(pdcp_entity, pkts, cop,
						      nb_rx, &nb_err);
		if (nb_err != 0) {
			/* Handle error packets */
		}

		if ((rte_cryptodev_enqueue_burst(dev_id, qp_id, cop, nb_success)
				!= nb_success) {
			/* Retry for enqueue failure packets */
		}

		...

		ret = rte_cryptodev_dequeue_burst(dev_id, qp_id, cop,
						  MAX_BURST_SIZE);
		if (ret == 0)
			continue;

		/**
		 * Received a burst of completed crypto ops from cryptodev. It
		 * may belong to various entities. Group similar ones together
		 * for entity specific post-processing.
		 */

		/**
		 * Groups similar entities together. Frees crypto op and based
		 * on crypto_op status, set mbuf->ol_flags which would be
		 * checked in rte_pdcp_pkt_post_process().
		 */
		nb_grp = rte_pdcp_pkt_crypto_group(cop, pkts, grp, ret);

		for (i = 0; i != nb_grp; i++) {

			/**
			 * Post process packets after crypto completion.
			 * Following operations would be done,
			 *
			 *  Transmitting entity/UL:
			 *  - Check crypto result
			 *
			 *  Receiving entity/DL:
			 *  - Check crypto operation status
			 *  - Check for duplication (if yes, drop duplicate)
			 *  - Perform decompression
			 *  - Trim PDCP header
			 *  - Hold packet (SDU) for in-order delivery (return
			 *    completed packets as and when sequence is
			 *    completed)
			 *  - If not in sequence, cache the packet and start
			 *    t-Reordering timer. When timer expires, the
			 *    packets need to delivered to upper layers (not
			 *    treated as error packets).
			 */
			nb_success = rte_pdcp_pkt_post_process(grp[i].id.ptr,
							       grp[i].m, out_mb,
							       grp[i].cnt,
							       &nb_err);
			if (nb_err != 0) {
				/* Handle error packets */
			}

			/* Perform additional operations */

			/**
			 * Tranmitting entity/UL
			 * - If duplication is enabled, duplicate PDCP PDUs
			 * - When lower layers confirm reception of a PDCP PDU,
			 *   it should be communicated to PDCP layer so that
			 *   PDCP can drop the corresponding SDU
			 */
		}
	}

Sample output from unit test executed on crypto_cn10k PMD(summary):

~# DPDK_TEST=pdcp_autotest ./dpdk-test --log-level=7
<snip>
 + ------------------------------------------------------- +
 + Test Suite Summary : PDCP Unit Test Suite
 + ------------------------------------------------------- +
 + Known vector cases : 112/160 passed, 0/160 skipped, 0/160 failed, 48/160 unsupported
 + PDCP combined mode : 1/1 passed, 0/1 skipped, 0/1 failed, 0/1 unsupported
 + PDCP HFN/SN : 4/4 passed, 0/4 skipped, 0/4 failed, 0/4 unsupported
 + PDCP reorder : 5/5 passed, 0/5 skipped, 0/5 failed, 0/5 unsupported
 + PDCP status report : 9/9 passed, 0/9 skipped, 0/9 failed, 0/9 unsupported
 + ------------------------------------------------------- +
 + Sub Testsuites Total :      5
 + Sub Testsuites Skipped :    0
 + Sub Testsuites Passed :     5
 + Sub Testsuites Failed :     0
 + ------------------------------------------------------- +
 + Tests Total :       179
 + Tests Skipped :      0
 + Tests Executed :    179
 + Tests Unsupported:  48
 + Tests Passed :      131
 + Tests Failed :       0
 + ------------------------------------------------------- +
Test OK

Anoob Joseph (10):
  lib: add pdcp protocol
  pdcp: add pre and post-process
  pdcp: add packet group
  pdcp: add crypto session create and destroy
  pdcp: add pre and post process for UL
  pdcp: add pre and post process for DL
  pdcp: add IV generation routines
  app/test: add lib pdcp tests
  doc: add PDCP library guide
  pdcp: add control PDU handling for status report

Volodymyr Fialko (11):
  net: add PDCP header
  test/pdcp: pdcp HFN tests in combined mode
  pdcp: implement t-Reordering and packet buffering
  test/pdcp: add in-order delivery cases
  pdcp: add timer callback handlers
  pdcp: add timer expiry handle
  test/pdcp: add timer expiry cases
  test/pdcp: add timer restart case
  pdcp: add support for status report
  pdcp: allocate reorder buffer alongside with entity
  test/pdcp: add PDCP status report cases

 MAINTAINERS                                   |    8 +
 app/test/meson.build                          |    5 +
 app/test/test_pdcp.c                          | 1981 +++++++++++++++++
 doc/api/doxy-api-index.md                     |    4 +-
 doc/api/doxy-api.conf.in                      |    1 +
 .../img/pdcp_functional_overview.svg          |    1 +
 doc/guides/prog_guide/index.rst               |    1 +
 doc/guides/prog_guide/pdcp_lib.rst            |  293 +++
 doc/guides/rel_notes/release_23_07.rst        |   12 +
 lib/meson.build                               |    1 +
 lib/net/meson.build                           |    1 +
 lib/net/rte_pdcp_hdr.h                        |  147 ++
 lib/pdcp/meson.build                          |   21 +
 lib/pdcp/pdcp_cnt.c                           |  164 ++
 lib/pdcp/pdcp_cnt.h                           |   24 +
 lib/pdcp/pdcp_crypto.c                        |  238 ++
 lib/pdcp/pdcp_crypto.h                        |   20 +
 lib/pdcp/pdcp_ctrl_pdu.c                      |   72 +
 lib/pdcp/pdcp_ctrl_pdu.h                      |   16 +
 lib/pdcp/pdcp_entity.h                        |  260 +++
 lib/pdcp/pdcp_process.c                       | 1223 ++++++++++
 lib/pdcp/pdcp_process.h                       |   37 +
 lib/pdcp/pdcp_reorder.c                       |   20 +
 lib/pdcp/pdcp_reorder.h                       |   68 +
 lib/pdcp/rte_pdcp.c                           |  334 +++
 lib/pdcp/rte_pdcp.h                           |  383 ++++
 lib/pdcp/rte_pdcp_group.h                     |  131 ++
 lib/pdcp/version.map                          |   20 +
 28 files changed, 5485 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_pdcp.c
 create mode 100644 doc/guides/prog_guide/img/pdcp_functional_overview.svg
 create mode 100644 doc/guides/prog_guide/pdcp_lib.rst
 create mode 100644 lib/net/rte_pdcp_hdr.h
 create mode 100644 lib/pdcp/meson.build
 create mode 100644 lib/pdcp/pdcp_cnt.c
 create mode 100644 lib/pdcp/pdcp_cnt.h
 create mode 100644 lib/pdcp/pdcp_crypto.c
 create mode 100644 lib/pdcp/pdcp_crypto.h
 create mode 100644 lib/pdcp/pdcp_ctrl_pdu.c
 create mode 100644 lib/pdcp/pdcp_ctrl_pdu.h
 create mode 100644 lib/pdcp/pdcp_entity.h
 create mode 100644 lib/pdcp/pdcp_process.c
 create mode 100644 lib/pdcp/pdcp_process.h
 create mode 100644 lib/pdcp/pdcp_reorder.c
 create mode 100644 lib/pdcp/pdcp_reorder.h
 create mode 100644 lib/pdcp/rte_pdcp.c
 create mode 100644 lib/pdcp/rte_pdcp.h
 create mode 100644 lib/pdcp/rte_pdcp_group.h
 create mode 100644 lib/pdcp/version.map

-- 
2.25.1