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 04E7BA0C4C; Tue, 21 Sep 2021 13:32:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DDB140DF8; Tue, 21 Sep 2021 13:32:44 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EA9F940683 for ; Tue, 21 Sep 2021 13:32:42 +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 SMTP id 18KMaoxX005379 for ; Tue, 21 Sep 2021 04:32:42 -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=4QQxdJ9+mQKoOjpzdTxugk3QvGZg39V1UjOhGbD71iU=; b=EQXZPbEsqwNzl1wlFg4HxKz/RCIXZZN7Z9Rj59dIeMXp7xDvGGX+ZO+hFDX4UqMGTKT4 u+3HkvhABw0zzjyVT2DtfbLPlfg+hN8bGhG5R3U2HvrQNrt8c4dMDXByhJjmvR/OyLlo prsd+k5eWadiDz+3dHbnqRJEltgpxPYbw3PeqFi9t+zvJWtQKDTnYAa8R1X75hBRV6dT mmZWSb41Vq5YssRFRYWz9I0jwEAPyQXCETiP/q8y29HhcIeILxSO/eqNTPoV7gjkEDI7 94CDoNolgEbXvESHvAEI11y2AQ6rNTF5+I87MvkXG5x6jwrPIa5qmsX63ipXuFlxIWar fQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3b7384hy91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 21 Sep 2021 04:32:42 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 21 Sep 2021 04:32:40 -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; Tue, 21 Sep 2021 04:32:40 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 3023A3F706B; Tue, 21 Sep 2021 04:32:37 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , , Gowrishankar Muthukrishnan Date: Tue, 21 Sep 2021 17:02:35 +0530 Message-ID: <20210921113235.1920173-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <08ba4b465588c72b6fc22b52497e86b14b664319.1631120194.git.gmuthukrishn@marvell.com> References: <08ba4b465588c72b6fc22b52497e86b14b664319.1631120194.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: BPuOZIKaQPDeOqgeGsPiT1vAvnaJ-Uya X-Proofpoint-ORIG-GUID: BPuOZIKaQPDeOqgeGsPiT1vAvnaJ-Uya X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-21_01,2021-09-20_01,2020-04-07_01 Subject: [dpdk-dev] [v2] 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 cryptodev. Signed-off-by: Gowrishankar Muthukrishnan --- Depends-on: series-19052 ("cnxk: enable telemetry endpoints for mempool and ethdev") Depends-on: patch-19054 ("telemetry: fix json output buffer size") v2: - split from series 18768 ("cnxk: enable telemetry endpoints"). --- .../crypto/cnxk/cnxk_cryptodev_telemetry.c | 154 ++++++++++++++++++ drivers/crypto/cnxk/meson.build | 1 + 2 files changed, 155 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..4c754bc6c7 --- /dev/null +++ b/drivers/crypto/cnxk/cnxk_cryptodev_telemetry.c @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell. + */ + +#include +#include +#include + +#include + +#include "cnxk_cryptodev.h" +#include "cnxk_telemetry.h" + +#define CRYPTO_CAPS_SZ \ + (RTE_ALIGN_CEIL(sizeof(struct rte_cryptodev_capabilities), \ + sizeof(uint64_t)) / \ + sizeof(uint64_t)) + +#define SEC_CAPS_SZ \ + (RTE_ALIGN_CEIL(sizeof(struct rte_security_capability), \ + sizeof(uint64_t)) / \ + sizeof(uint64_t)) + +static int +cryptodev_tel_handle_list(const char *cmd __rte_unused, + const char *params __rte_unused, + struct rte_tel_data *d) +{ + struct rte_cryptodev *cryptodev; + unsigned int i; + + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + + for (i = 0; i < RTE_CRYPTO_MAX_DEVS; i++) { + cryptodev = rte_cryptodev_pmd_get_dev(i); + if (cryptodev->attached != RTE_CRYPTODEV_ATTACHED) + continue; + + rte_tel_data_add_array_string(d, cryptodev->data->name); + } + + return 0; +} + +static int +crypto_caps_array(struct rte_tel_data *d, + struct rte_cryptodev_capabilities *dev_caps, + size_t dev_caps_n) +{ + union caps_u { + struct rte_cryptodev_capabilities dev_caps; + uint64_t val[CRYPTO_CAPS_SZ]; + } caps; + unsigned int i, j, n = 0; + + rte_tel_data_start_array(d, RTE_TEL_U64_VAL); + + for (i = 0; i < dev_caps_n; i++) { + if (dev_caps[i].op == RTE_CRYPTO_OP_TYPE_UNDEFINED) + break; + + memset(&caps, 0, sizeof(caps)); + rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0])); + for (j = 0; j < CRYPTO_CAPS_SZ; j++) + rte_tel_data_add_array_u64(d, caps.val[j]); + ++n; + } + + return n; +} + +static int +sec_caps_array(struct rte_tel_data *d, struct rte_security_capability *dev_caps, + size_t dev_caps_n) +{ + union caps_u { + struct rte_security_capability dev_caps; + uint64_t val[SEC_CAPS_SZ]; + } caps; + unsigned int i, j, n = 0; + + rte_tel_data_start_array(d, RTE_TEL_U64_VAL); + + for (i = 0; i < dev_caps_n; i++) { + memset(&caps, 0, sizeof(caps)); + rte_memcpy(&caps.dev_caps, &dev_caps[i], sizeof(dev_caps[0])); + for (j = 0; j < SEC_CAPS_SZ; j++) + rte_tel_data_add_array_u64(d, caps.val[j]); + ++n; + } + + return n; +} + +static int +cryptodev_tel_handle_info(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + struct rte_tel_data *crypto_caps, *sec_crypto_caps, *sec_caps; + int crypto_caps_n, sec_crypto_caps_n, sec_caps_n; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + struct rte_cryptodev *dev; + struct cnxk_cpt_vf *vf; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN); + dev = rte_cryptodev_pmd_get_named_dev(name); + if (!dev) { + plt_err("No cryptodev of name %s available", name); + return -1; + } + + vf = dev->data->dev_private; + + rte_tel_data_start_dict(d); + CNXK_TEL_DICT_INT(d, dev->data, dev_id); + CNXK_TEL_DICT_INT(d, dev->data, socket_id); + CNXK_TEL_DICT_INT(d, dev->data, dev_started); + + /* Crypto capabilities */ + crypto_caps = rte_tel_data_alloc(); + crypto_caps_n = crypto_caps_array(crypto_caps, vf->crypto_caps, + CNXK_CPT_MAX_CAPS); + rte_tel_data_add_dict_container(d, "crypto_caps", crypto_caps, 0); + rte_tel_data_add_dict_int(d, "crypto_caps_n", crypto_caps_n); + + /* Security Crypto capabilities */ + sec_crypto_caps = rte_tel_data_alloc(); + sec_crypto_caps_n = crypto_caps_array( + sec_crypto_caps, vf->sec_crypto_caps, CNXK_SEC_CRYPTO_MAX_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); + + /* Security capabilities */ + sec_caps = rte_tel_data_alloc(); + sec_caps_n = sec_caps_array(sec_caps, vf->sec_caps, CNXK_SEC_MAX_CAPS); + 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(cnxk_cryptodev_init_telemetry) +{ + rte_telemetry_register_cmd( + "/cnxk/cryptodev/list", cryptodev_tel_handle_list, + "Returns list of available cryptodev. Takes no parameters"); + rte_telemetry_register_cmd( + "/cnxk/cryptodev/info", cryptodev_tel_handle_info, + "Returns cryptodev info. Parameters: pci id"); +} diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build index e40d132f80..0ce89f1c12 100644 --- a/drivers/crypto/cnxk/meson.build +++ b/drivers/crypto/cnxk/meson.build @@ -19,6 +19,7 @@ sources = files( 'cnxk_cryptodev_capabilities.c', 'cnxk_cryptodev_ops.c', 'cnxk_cryptodev_sec.c', + 'cnxk_cryptodev_telemetry.c', ) deps += ['bus_pci', 'common_cnxk', 'security', 'eventdev'] -- 2.25.1