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 11259A0547; Sat, 30 Oct 2021 19:41:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C28340DDD; Sat, 30 Oct 2021 19:41:52 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6FD2040DDB for ; Sat, 30 Oct 2021 19:41:51 +0200 (CEST) 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 19UDQE1p019749 for ; Sat, 30 Oct 2021 10:41:50 -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=+/bK/kO4imKkWEkwni0eS4YCFSqhuRvtGkkFrXbHByE=; b=Z8V8m3d33CFwt9+SdfIBzXJ+SfpPCm/iNn4x0flTsseVPOa76lNRpSZk0Yove9f+iPHn 4F3TJFBMzRfpRhBsluo47Fym8denrmg4Ne9vFM4CPU4tJ2PBG319fVBtUi/We6vnj9c7 GE7sDDIqklOq0E1MXf8VdY/qr/30Qx9W8z0tjWwvdScN8jii2/pHHXFi+3Wke667z33m OeSJyaz4EKu5mOzIBFi5zkTBV5HpxHyIwOmMD7qNGAvPInLvmKy6NpMlmQD0UuCpPkPH lDecV3kZWqkZd4H+oxrbkaoXu3wkQ/j3LQ2Qk3pGNLkKK3wWb0d6cuPCLHx7jEvCLXr8 RA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3c15jk8pq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 30 Oct 2021 10:41:50 -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 10:41:48 -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 10:41:48 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id B38C63F70C4; Sat, 30 Oct 2021 10:41:45 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , , , Gowrishankar Muthukrishnan Date: Sat, 30 Oct 2021 23:11:42 +0530 Message-ID: <2a35544b52729b3d645f75aca212abf89c7dc45a.1635615372.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <2729853b1a569f04d39ca8e898c9005bc3b47118.1635255702.git.gmuthukrishn@marvell.com> References: <2729853b1a569f04d39ca8e898c9005bc3b47118.1635255702.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: Lea3WI0gC0GDp0ddo9c-6tK0iJdOfHrU X-Proofpoint-ORIG-GUID: Lea3WI0gC0GDp0ddo9c-6tK0iJdOfHrU 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-30_05,2021-10-29_01,2020-04-07_01 Subject: [dpdk-dev] [v9] crypto/cnxk: add telemetry endpoints to cryptodev 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 endpoints to cnxk secure cryptodev capabilities. Signed-off-by: Gowrishankar Muthukrishnan --- v9: - moved rte_security_capability into rte_security lib telemetry. --- .../crypto/cnxk/cnxk_cryptodev_telemetry.c | 81 +++++++++++++++++++ drivers/crypto/cnxk/meson.build | 1 + 2 files changed, 82 insertions(+) create mode 100644 drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c new file mode 100644 index 0000000000..43cde55bfc --- /dev/null +++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c @@ -0,0 +1,81 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell. + */ + +#include +#include +#include + +#include + +#include "cnxk_cryptodev.h" + +#define CRYPTO_CAPS_SZ \ + (RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \ + sizeof(uint64_t)) / \ + sizeof(uint64_t)) + +static int +crypto_caps_array(struct rte_tel_data *d, + struct rte_cryptodev_capabilities *capabilities) +{ + const struct rte_cryptodev_capabilities *dev_caps; + uint64_t caps_val[CRYPTO_CAPS_SZ]; + unsigned int i = 0, j; + + rte_tel_data_start_array(d, RTE_TEL_U64_VAL); + + while ((dev_caps = &capabilities[i++])->op != + RTE_CRYPTO_OP_TYPE_UNDEFINED) { + memset(&caps_val, 0, CRYPTO_CAPS_SZ * sizeof(caps_val[0])); + rte_memcpy(caps_val, dev_caps, sizeof(capabilities[0])); + for (j = 0; j < CRYPTO_CAPS_SZ; j++) + rte_tel_data_add_array_u64(d, caps_val[j]); + } + + return i; +} + +static int +cryptodev_tel_handle_sec_caps(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + struct rte_tel_data *sec_crypto_caps; + struct rte_cryptodev *dev; + struct cnxk_cpt_vf *vf; + int sec_crypto_caps_n; + int dev_id; + + if (!params || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + dev_id = strtol(params, NULL, 10); + if (!rte_cryptodev_is_valid_dev(dev_id)) + return -EINVAL; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + if (!dev) { + plt_err("No cryptodev for id %d available", dev_id); + return -EINVAL; + } + + vf = dev->data->dev_private; + rte_tel_data_start_dict(d); + + /* Secure Crypto capabilities */ + sec_crypto_caps = rte_tel_data_alloc(); + sec_crypto_caps_n = crypto_caps_array(sec_crypto_caps, + vf->sec_crypto_caps); + rte_tel_data_add_dict_container(d, "sec_crypto_caps", + sec_crypto_caps, 0); + rte_tel_data_add_dict_int(d, "sec_crypto_caps_n", sec_crypto_caps_n); + + return 0; +} + +RTE_INIT(cnxk_cryptodev_init_telemetry) +{ + rte_telemetry_register_cmd("/cnxk/cryptodev/sec_caps", + cryptodev_tel_handle_sec_caps, + "Returns cryptodev capabilities. Parameters: int dev_id"); +} diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build index 024109f7e9..2d78757bba 100644 --- a/drivers/crypto/cnxk/meson.build +++ b/drivers/crypto/cnxk/meson.build @@ -20,6 +20,7 @@ sources = files( 'cnxk_cryptodev_devargs.c', 'cnxk_cryptodev_ops.c', 'cnxk_cryptodev_sec.c', + 'cnxk_cryptodev_telemetry.c', ) deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev'] -- 2.25.1