From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52231A0548; Sun, 31 Oct 2021 06:24:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC4304068E; Sun, 31 Oct 2021 06:24:35 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2B54440689 for ; Sun, 31 Oct 2021 06:24:34 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 19V2jLPL008684; Sat, 30 Oct 2021 22:24:33 -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=vmYfrf94/SPVh2xGPNmw7m/IwYzoC1sDLupjzHE9b7M=; b=NwcAkND/ha4URMTOCqwIaR82Ssxd2n+3I4jvfirZDD6GN0gtx+xrlaVSUVrV3f/5so0A 2EItvX3l/VIkX/jODc3QR19UmwLZmeaYvLlDNnKdv806cBrs4/gG97XG0ba/DyDWxr39 5HjwgDel6rd0oSaE2hlJU5kO87PGw3WlzZVnD3U+WqZ+U9+bT5OVOoRawpsb1gdFsjJB mFyEAteMCx4d5RUzId2llKoglXol3GmMPnSQMefblWu6aL6PqXyafKG/l1fXI0tTt6O0 ntycZfxE1eFuPVqOJTFu8Ed1oTNp6HdPDp5nMjXAkdDghTAFZ+Q2IwBXdVnjgHkXeM0C Gw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3c15jk9x8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 30 Oct 2021 22:24:33 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 30 Oct 2021 22:24:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 30 Oct 2021 22:24:30 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id CFCE73F708F; Sat, 30 Oct 2021 22:24:28 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , , Gowrishankar Muthukrishnan Date: Sun, 31 Oct 2021 10:54:26 +0530 Message-ID: <7067f42a1f22103665c15429913f56f8c114f401.1635657772.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <835cb4c93debb80afd3decc7e4540ed0f07d33fa.1635614976.git.gmuthukrishn@marvell.com> References: <835cb4c93debb80afd3decc7e4540ed0f07d33fa.1635614976.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 3ufaA0-vkDgWia9Ogni6MFmlZUWpXQq0 X-Proofpoint-ORIG-GUID: 3ufaA0-vkDgWia9Ogni6MFmlZUWpXQq0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-31_01,2021-10-29_03,2020-04-07_01 Subject: [dpdk-dev] [v2] security: add telemetry endpoint for cryptodev security capabilities X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Add telemetry endpoint for cryptodev security capabilities. Signed-off-by: Gowrishankar Muthukrishnan --- v2: - updated doc and release notes --- doc/guides/prog_guide/rte_security.rst | 22 ++++++ doc/guides/rel_notes/release_21_11.rst | 5 ++ lib/security/rte_security.c | 98 ++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) diff --git a/doc/guides/prog_guide/rte_security.rst b/doc/guides/prog_guide/rte_security.rst index 46c9b51d1b..dbc6ef0783 100644 --- a/doc/guides/prog_guide/rte_security.rst +++ b/doc/guides/prog_guide/rte_security.rst @@ -728,3 +728,25 @@ it is only valid to have a single flow to map to that security session. +-------+ +--------+ +-----+ | Eth | -> ... -> | ESP | -> | END | +-------+ +--------+ +-----+ + + +Telemetry support +----------------- + +The Security library has support for displaying Crypto device information +with respect to its Security capabilities. Telemetry commands that can be used +are shown below. + +#. Get the list of available Crypto devices by ID, that supports Security features:: + + --> /security/list + {"/security/list": [0, 1, 2, 3]} + +#. Get the security capabilities of a Crypto device:: + + --> /security/caps,0 + {"/security/caps": {"sec_caps": [], "sec_caps_n": }} + +For more information on how to use the Telemetry interface, see +the :doc:`../howto/telemetry`. diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 47cd67131e..88834d91d8 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -197,6 +197,11 @@ New Features * Added port representors support on SN1000 SmartNICs * Added flow API transfer proxy support +* **Added Telemetry callback to Security library.** + + Added Telemetry callback function to query security capabilities of + Crypto device. + * **Updated Marvell cnxk crypto PMD.** * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K. diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index fe81ed3e4c..068d855d9b 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -4,8 +4,10 @@ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved */ +#include #include #include +#include #include "rte_compat.h" #include "rte_security.h" #include "rte_security_driver.h" @@ -203,3 +205,99 @@ rte_security_capability_get(struct rte_security_ctx *instance, return NULL; } + +static int +cryptodev_handle_dev_list(const char *cmd __rte_unused, + const char *params __rte_unused, + struct rte_tel_data *d) +{ + int dev_id; + + if (rte_cryptodev_count() < 1) + return -1; + + rte_tel_data_start_array(d, RTE_TEL_INT_VAL); + for (dev_id = 0; dev_id < RTE_CRYPTO_MAX_DEVS; dev_id++) + if (rte_cryptodev_is_valid_dev(dev_id) && + rte_cryptodev_get_sec_ctx(dev_id)) + rte_tel_data_add_array_int(d, dev_id); + + return 0; +} + +#define SEC_CAPS_SZ \ + (RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \ + sizeof(uint64_t)) / sizeof(uint64_t)) + +static int +sec_caps_array(struct rte_tel_data *d, + const struct rte_security_capability *capabilities) +{ + const struct rte_security_capability *dev_caps; + uint64_t caps_val[SEC_CAPS_SZ]; + unsigned int i = 0, j; + + rte_tel_data_start_array(d, RTE_TEL_U64_VAL); + + while ((dev_caps = &capabilities[i++])->action != + RTE_SECURITY_ACTION_TYPE_NONE) { + memset(&caps_val, 0, SEC_CAPS_SZ * sizeof(caps_val[0])); + rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0])); + for (j = 0; j < SEC_CAPS_SZ; j++) + rte_tel_data_add_array_u64(d, caps_val[j]); + } + + return i; +} + +static int +security_handle_dev_caps(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + const struct rte_security_capability *capabilities; + struct rte_security_ctx *sec_ctx; + struct rte_tel_data *sec_caps; + int sec_caps_n; + char *end_param; + int dev_id; + + if (!params || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + dev_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + CDEV_LOG_ERR("Extra parameters passed to command, ignoring"); + + if (!rte_cryptodev_is_valid_dev(dev_id)) + return -EINVAL; + + rte_tel_data_start_dict(d); + sec_caps = rte_tel_data_alloc(); + if (!sec_caps) + return -ENOMEM; + + sec_ctx = (struct rte_security_ctx *)rte_cryptodev_get_sec_ctx(dev_id); + if (!sec_ctx) + return -EINVAL; + + capabilities = rte_security_capabilities_get(sec_ctx); + if (!capabilities) + return -EINVAL; + + sec_caps_n = sec_caps_array(sec_caps, capabilities); + rte_tel_data_add_dict_container(d, "sec_caps", sec_caps, 0); + rte_tel_data_add_dict_int(d, "sec_caps_n", sec_caps_n); + + return 0; +} + +RTE_INIT(security_init_telemetry) +{ + rte_telemetry_register_cmd("/security/list", + cryptodev_handle_dev_list, + "Returns list of available crypto devices by IDs. No parameters."); + + rte_telemetry_register_cmd("/security/caps", + security_handle_dev_caps, + "Returns security capabilities for a cryptodev. Parameters: int dev_id"); +} -- 2.25.1