From patchwork Fri Dec 15 08:43:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 32297 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 760C01B00C; Fri, 15 Dec 2017 09:44:08 +0100 (CET) Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0053.outbound.protection.outlook.com [104.47.41.53]) by dpdk.org (Postfix) with ESMTP id D87C7E5D for ; Fri, 15 Dec 2017 09:44:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Cg/LeE8uf9dHwlJSsKteGnl3jH/T/kcWxYBnde/JcK4=; b=ilnov1dEerIZNYSc4NcA6MKZealemW13+8JpE7hPu411XCtzbbX1Ak57pMcGAiJ5RplIqKD0yU8F2USri6zqaMzWlT5ASTMcZgI6xyDm3QqaDBBvK4vZnvMjFTFhPwkMPjPwJp+ymNakFcH3I9nTk1U/cs/M+he9BGCcLLPkjdA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com (115.113.156.2) by CY4PR0701MB3635.namprd07.prod.outlook.com (2603:10b6:910:93::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Fri, 15 Dec 2017 08:44:02 +0000 From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Radu Nicolau , Sergio Gonzalez Monroy Cc: Anoob Joseph , Jerin Jacob , Narayana Prasad , dev@dpdk.org Date: Fri, 15 Dec 2017 08:43:15 +0000 Message-Id: <1513327396-22178-2-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513327396-22178-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1513326606-21970-1-git-send-email-anoob.joseph@caviumnetworks.com> <1513327396-22178-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: CY4PR2201CA0011.namprd22.prod.outlook.com (2603:10b6:910:5f::21) To CY4PR0701MB3635.namprd07.prod.outlook.com (2603:10b6:910:93::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a2cd6f4e-c0d4-4b96-5425-08d54397ffcc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(2017052603307); SRVR:CY4PR0701MB3635; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3635; 3:8C7l54fOG2BKhL3cEFSVyl9Mcms/k7hmdyPSlrvpaqXJ90M7v7hjV7LqvCEgzDJYJqygXvJkRX8numR4wO5wJAOaFf9kVC+8K855Kh9Squjwcy7TYNptYExmO2hE+IB2+YM6B9aXn9dDKXGyrMTRgWM1bXrMe52HcOFuuUXJ7rR6EdenQfM+nanfQMo2wdkk8n0Gizz3tbr0vHu/kk9JyVO2aDAN8LQpwgwutvqABXQnqhsKlqr7N8Xd+qqMbuX7; 25:cKEESFotfr9LKNADnAlSlpIczVErinUnpSmjAvKceMqdfFROHi2hISkD89rAhlv7yXR7VwTuNcuUe7DOXZiaoZVFqg3XBbliaXSa2Xa1yg379aXplgGGIBtHub/Ot8QR1IOePByf12F1HOPB4U/QlPL6cm3Hhk6i2X76/6dxX6A+6dojSg6K6wPpyrqmyH+h2PDIEorFfgWpY3CvY83sxfUCkVt4QmwpyNBgQhQvJhEsdZJgkpkQtxmyyIGcUObp9+h/n1JlLOmtSBobTuYdcedxVdlHVV10lqZEO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yTum1D4eReBHD559K1HNQxgYUgx/ZEpaU5jkPXaopZl+yB6l01QblzbWL/4cnjv2ucC3XarmUDljlmUslpROrl5HuVtMiYSckRslbQbmbViSd5n2eBgDDk7TIfXiLh6OAmZ7NQMY6qQDf6iFdvRA9qjwDOzRlyTxQFFpqbGEEUycshczs/eCkWMUoZVRAaUMj986ii+SURt9lonk08cAOOfHROe0DIsaPIHs/8Z X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231023)(93006095)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123555025)(20161123558100)(6072148)(201708071742011); SRVR:CY4PR0701MB3635; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR0701MB3635; X-Forefront-PRVS: 05220145DE X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(346002)(366004)(376002)(189003)(199004)(68736007)(8936002)(50226002)(72206003)(8656006)(478600001)(16526018)(15650500001)(316002)(386003)(53416004)(5890100001)(55236004)(66066001)(16586007)(2906002)(54906003)(69596002)(110136005)(6506007)(47776003)(59450400001)(25786009)(53936002)(81166006)(81156014)(51416003)(8676002)(4326008)(7736002)(6486002)(52116002)(305945005)(36756003)(106356001)(2950100002)(48376002)(105586002)(6666003)(42882006)(50466002)(3846002)(6116002)(6512007)(5660300001)(97736004)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3635; H:ajoseph83.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3635; 23:jMsEAh/GEvfUgkTNQZz+nVUFrywztyMvFfhAMuj?= MpVF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Pqr0IMa2rD15gabhA1co5MNWtSIrz5WFQ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2017 08:44:02.9121 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2cd6f4e-c0d4-4b96-5425-08d54397ffcc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3635 Subject: [dpdk-dev] [PATCH v5 1/2] lib/security: add support for get userdata X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In case of inline protocol processed ingress traffic, the packet may not have enough information to determine the security parameters with which the packet was processed. In such cases, application could get metadata from the packet which could be used to identify the security parameters with which the packet was processed. Application could register "userdata" with the security session, and this could be retrieved from the metadata of inline processed packets. The metadata returned by "rte_security_get_pkt_metadata()" will be device specific. Also the driver is expected to return the application registered "userdata" as is, without any modifications. Signed-off-by: Anoob Joseph --- v5: * No change v4: * Documented the usage of rte_mbuf.udata64 field by security library * Removed (rte_security_get_pkt_metadata() API as the udata64 field itself will have device-specific metadata, and could be directly used v3: * Replaced 64 bit metadata in conf with (void *)userdata * The API(rte_security_get_pkt_metadata) would return void * instead of uint64_t v2: * Replaced get_session and get_cookie APIs with get_pkt_metadata API doc/guides/prog_guide/rte_security.rst | 22 +++++++++++++++++++++- lib/librte_security/rte_security.c | 12 ++++++++++++ lib/librte_security/rte_security.h | 20 ++++++++++++++++++++ lib/librte_security/rte_security_driver.h | 18 ++++++++++++++++++ lib/librte_security/rte_security_version.map | 1 + 5 files changed, 72 insertions(+), 1 deletion(-) diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst index 71be036..6768ebe 100644 --- a/doc/guides/prog_guide/rte_security.rst +++ b/doc/guides/prog_guide/rte_security.rst @@ -148,7 +148,9 @@ packet. e.g. in the case of IPSec, the IPSec tunnel headers (if any), ESP/AH headers will be removed from the packet and the received packet will contains the decrypted packet only. The driver Rx path checks the descriptors and based on the crypto status sets additional flags in -``rte_mbuf.ol_flags`` field. +``rte_mbuf.ol_flags`` field. The driver would also set device-specific +metadata in ``rte_mbuf.udata64`` field. This will allow the application +to identify the security processing done on the packet. .. note:: @@ -421,6 +423,22 @@ For Inline Crypto and Inline protocol offload, device specific defined metadata updated in the mbuf using ``rte_security_set_pkt_metadata()`` if ``DEV_TX_OFFLOAD_SEC_NEED_MDATA`` is set. +For inline protocol offloaded ingress traffic, the application can register a +pointer, ``userdata`` , in the security session. When the packet is received, +``rte_security_get_userdata()`` would return the userdata registered for the +security session which processed the packet. + +.. note:: + + In case of inline processed packets, ``rte_mbuf.udata64`` field would be + used by the driver to relay information on the security processing + associated with the packet. In ingress, the driver would set this in Rx + path while in egress, ``rte_security_set_pkt_metadata()`` would perform a + similar operation. The application is expected not to modify the field + when it has relevant info. For ingress, this device-specific 64 bit value + is required to derive other information (like userdata), required for + identifying the security processing done on the packet. + Security session configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -440,6 +458,8 @@ Security Session configuration structure is defined as ``rte_security_session_co /**< Configuration parameters for security session */ struct rte_crypto_sym_xform *crypto_xform; /**< Security Session Crypto Transformations */ + void *userdata; + /**< Application specific userdata to be saved with session */ }; The configuration structure reuses the ``rte_crypto_sym_xform`` struct for crypto related diff --git a/lib/librte_security/rte_security.c b/lib/librte_security/rte_security.c index 1227fca..5805051 100644 --- a/lib/librte_security/rte_security.c +++ b/lib/librte_security/rte_security.c @@ -108,6 +108,18 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, sess, m, params); } +void * +rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md) +{ + void *userdata = NULL; + + RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->get_userdata, NULL); + if (instance->ops->get_userdata(instance->device, md, &userdata)) + return NULL; + + return userdata; +} + const struct rte_security_capability * rte_security_capabilities_get(struct rte_security_ctx *instance) { diff --git a/lib/librte_security/rte_security.h b/lib/librte_security/rte_security.h index 653929b..a34cbba 100644 --- a/lib/librte_security/rte_security.h +++ b/lib/librte_security/rte_security.h @@ -274,6 +274,8 @@ struct rte_security_session_conf { /**< Configuration parameters for security session */ struct rte_crypto_sym_xform *crypto_xform; /**< Security Session Crypto Transformations */ + void *userdata; + /**< Application specific userdata to be saved with session */ }; struct rte_security_session { @@ -346,6 +348,24 @@ rte_security_set_pkt_metadata(struct rte_security_ctx *instance, struct rte_mbuf *mb, void *params); /** + * Get userdata associated with the security session which processed the + * packet. This userdata would be registered while creating the session, and + * application can use this to identify the SA etc. Device-specific metadata + * in the mbuf would be used for this. + * + * This is valid only for inline processed ingress packets. + * + * @param instance security instance + * @param md device-specific metadata set in mbuf + * + * @return + * - On success, userdata + * - On failure, NULL + */ +void * +rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md); + +/** * Attach a session to a symmetric crypto operation * * @param sym_op crypto operation diff --git a/lib/librte_security/rte_security_driver.h b/lib/librte_security/rte_security_driver.h index 997fbe7..4e93362 100644 --- a/lib/librte_security/rte_security_driver.h +++ b/lib/librte_security/rte_security_driver.h @@ -122,6 +122,22 @@ typedef int (*security_set_pkt_metadata_t)(void *device, void *params); /** + * Get application specific userdata associated with the security session which + * processed the packet. This would be retrieved using the metadata obtained + * from packet. + * + * @param device Crypto/eth device pointer + * @param md Metadata + * @param userdata Pointer to receive userdata + * + * @return + * - Returns 0 if userdata is retrieved successfully. + * - Returns -ve value for errors. + */ +typedef int (*security_get_userdata_t)(void *device, + uint64_t md, void **userdata); + +/** * Get security capabilities of the device. * * @param device crypto/eth device pointer @@ -145,6 +161,8 @@ struct rte_security_ops { /**< Clear a security sessions private data. */ security_set_pkt_metadata_t set_pkt_metadata; /**< Update mbuf metadata. */ + security_get_userdata_t get_userdata; + /**< Get userdata associated with session which processed the packet. */ security_capabilities_get_t capabilities_get; /**< Get security capabilities. */ }; diff --git a/lib/librte_security/rte_security_version.map b/lib/librte_security/rte_security_version.map index e12c04b..87f35d7 100644 --- a/lib/librte_security/rte_security_version.map +++ b/lib/librte_security/rte_security_version.map @@ -9,6 +9,7 @@ EXPERIMENTAL { rte_security_session_stats_get; rte_security_session_update; rte_security_set_pkt_metadata; + rte_security_get_userdata; local: *; };