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 D74E6A0547; Wed, 29 Sep 2021 08:45:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5BFD940E3C; Wed, 29 Sep 2021 08:45:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1B5E14068F for ; Wed, 29 Sep 2021 08:45:31 +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 18T2SrYe017877; Tue, 28 Sep 2021 23:45:30 -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=v92qMsFYs664dlWLkWRmsUBi0pt7ucIMEjQJwnF/qvc=; b=WHmkDaocLfMeUxXXfY9CFjEUsNepDVQFHYMeJEUhJ5nHX4s7wvA59VSvJbKyL5wmlcMO AiDpBzpr+ipt/DmprT/aiqDFQtmOVt/iEPaoN+DFRFGrtBOuEFvB1dSr4nhFrlqnlHe7 +m7N5tK8oc7xD1j35mJG7Mb+yalOcxwzRfVs9ra6knICm9BLKLAHduXwcVXbGIWP5V7U qGe8yN88o5ClJUulpvBt5l8HhyaEUfvHpVBpfxcpYBeSSBRn2yUIWtlx6SRpyEG1bAXV A7LfoDKdIYu508TFAJKT5inaMhubDJHdJQRR+9GqqlCUUytb7b1hWYwMpNmW/9APx5to wA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3bcfd48swr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 28 Sep 2021 23:45:30 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 28 Sep 2021 23:45:28 -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.18 via Frontend Transport; Tue, 28 Sep 2021 23:45:28 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id C7F1A3F7068; Tue, 28 Sep 2021 23:45:26 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Akhil Goyal , Declan Doherty , , Gowrishankar Muthukrishnan Date: Wed, 29 Sep 2021 12:15:23 +0530 Message-ID: <7587cf36f51ff62f1467bfa44af5364130c8163c.1632896481.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210921113235.1920173-1-gmuthukrishn@marvell.com> References: <20210921113235.1920173-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: AmZElWQOoC5qcTp8Af6FFiro7Eje6VQf X-Proofpoint-ORIG-GUID: AmZElWQOoC5qcTp8Af6FFiro7Eje6VQf 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-29_02,2021-09-28_01,2020-04-07_01 Subject: [dpdk-dev] [v1] cryptodev: add telemetry endpoint for cryptodev info 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 info. Signed-off-by: Gowrishankar Muthukrishnan --- Depends-on: patch-18355 ("cryptodev: add telemetry callbacks") Depends-on: patch-19247 ("telemetry: fix json output buffer size") --- lib/cryptodev/rte_cryptodev.c | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c index 0823137465..365cf3ccc1 100644 --- a/lib/cryptodev/rte_cryptodev.c +++ b/lib/cryptodev/rte_cryptodev.c @@ -2481,6 +2481,72 @@ cryptodev_handle_dev_stats(const char *cmd __rte_unused, return 0; } +#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, + const struct rte_cryptodev_capabilities *capabilities) +{ + const struct rte_cryptodev_capabilities *dev_caps; + union caps_u { + struct rte_cryptodev_capabilities dev_caps; + uint64_t val[CRYPTO_CAPS_SZ]; + } caps; + unsigned int i = 0, j, n = 0; + + rte_tel_data_start_array(d, RTE_TEL_U64_VAL); + + while ((dev_caps = &capabilities[i++])->op != + RTE_CRYPTO_OP_TYPE_UNDEFINED) { + memset(&caps, 0, sizeof(caps)); + rte_memcpy(&caps.dev_caps, dev_caps, sizeof(capabilities[0])); + for (j = 0; j < CRYPTO_CAPS_SZ; j++) + rte_tel_data_add_array_u64(d, caps.val[j]); + ++n; + } + + return n; +} + +static int +cryptodev_handle_info(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + struct rte_cryptodev_info dev_info; + struct rte_tel_data *crypto_caps; + struct rte_cryptodev *dev; + int crypto_caps_n; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + rte_strlcpy(name, params, RTE_CRYPTODEV_NAME_LEN); + dev = rte_cryptodev_pmd_get_named_dev(name); + if (!dev) + return -EINVAL; + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_int(d, "dev_id", dev->data->dev_id); + rte_tel_data_add_dict_int(d, "socket_id", dev->data->socket_id); + rte_tel_data_add_dict_int(d, "dev_started", dev->data->dev_started); + + /* Crypto capabilities */ + crypto_caps = rte_tel_data_alloc(); + if (!crypto_caps) + return -ENOMEM; + + rte_cryptodev_info_get(dev->data->dev_id, &dev_info); + crypto_caps_n = crypto_caps_array(crypto_caps, dev_info.capabilities); + 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); + + return 0; +} + RTE_INIT(cryptodev_init_telemetry) { rte_telemetry_register_cmd("/cryptodev/list", cryptodev_handle_dev_list, @@ -2488,4 +2554,6 @@ RTE_INIT(cryptodev_init_telemetry) rte_telemetry_register_cmd("/cryptodev/stats", cryptodev_handle_dev_stats, "Returns the stats for a cryptodev. Parameters: int dev_id"); + rte_telemetry_register_cmd("/cryptodev/info", cryptodev_handle_info, + "Returns cryptodev info. Parameters: pci id"); } -- 2.25.1