From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 430B6A04F5; Thu, 12 Dec 2019 19:44:49 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 975371BF7D; Thu, 12 Dec 2019 19:44:48 +0100 (CET) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130070.outbound.protection.outlook.com [40.107.13.70]) by dpdk.org (Postfix) with ESMTP id 05FA61BF7C for ; Thu, 12 Dec 2019 19:44:46 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Snv9Ob+GheQPWjUlauFDMT6SBiI5a04ltkt5d9bD76+fLvUF9j0nIMyNtlfi2NBov1HyCfqKWMegpeNodmZXECOaoH2bQT+4UDznWVxU+JNUwzkzI8afsN+IvYHTsPwUkUk34yRO91+vJ87YhPrjVQN5bcK8JcjUMvkmwGORteXIl9LuJs3ytbYqHp1bvU3sgeNm1ttVR486yo9FT53w7TUloaE/JdML4AqiJ+Jyxna9hS1q5byWnqXWLHjkRE9u8D6PBBxI+eUNBt4FnybXzh+SpJqLZ9c3YDbcyuyR0g7xFdFkkdQgQsubk6nEgeEIOX4Q4jenEfX2ll0UXzrbAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B3RI1V4jlC3ndUqNLdalhWNq8diadOncuMsKfvTYueY=; b=ByAgbXD8p4trKuHkz2ukLHKz6seMMi7ZBsxA9weqo8QHE5yeN6u9Dcj8qVqBhzVBb/7SeSTOCkVmKrkynHppmedQPO3vAjXdLzDK7uDjGgUPC3JLHQQ1SZRbkqkV2IGUo79qEpAY7PFDDKBNh4Ky/ISdRlBZGja4dmMDaTEy8VAk8qNghU/e3w0+D7vbHoCHNq5APfHeDTzdmvo2rLdT1/J7rftlcsOjHpVH/0ovfoKJmqVr2DDSJExXiMuQdVJzjebNLqK65Mxea5ywOI+AaM6QbBMICr9Zc/2NAZcK11WYQk7nZUXp5PQqT9QJ2yU6AbZHrmIv3y0kJlgapIKa9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=marvell.com smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=none pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B3RI1V4jlC3ndUqNLdalhWNq8diadOncuMsKfvTYueY=; b=rP5vzPjbJ6ApN4Q4tu5tUMsXKF9DTms72+8xS5XRLHV3W8yMJeWUue0xAfSX6XqEoPKeQdVqLa0rwAF93t+N4wFGZhkWR68RXgsLoa0vfurlEPyBhGEBISemX8Kv7FFh7NNrMiNSZrvI/oiMgYIVlWZtt0FS7EtrDRlIMCSnE7g= Received: from VI1PR07CA0167.eurprd07.prod.outlook.com (2603:10a6:802:3e::15) by HE1PR07MB4441.eurprd07.prod.outlook.com (2603:10a6:7:9f::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.14; Thu, 12 Dec 2019 18:44:45 +0000 Received: from AM5EUR02FT039.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::203) by VI1PR07CA0167.outlook.office365.com (2603:10a6:802:3e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.6 via Frontend Transport; Thu, 12 Dec 2019 18:44:45 +0000 Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; marvell.com; dkim=none (message not signed) header.d=none;marvell.com; dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; Received: from oa.msg.ericsson.com (192.176.1.74) by AM5EUR02FT039.mail.protection.outlook.com (10.152.9.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2538.14 via Frontend Transport; Thu, 12 Dec 2019 18:44:44 +0000 Received: from ESESBMB502.ericsson.se (153.88.183.169) by ESESBMR505.ericsson.se (153.88.183.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 12 Dec 2019 19:44:37 +0100 Received: from ESESSMB505.ericsson.se (153.88.183.166) by ESESBMB502.ericsson.se (153.88.183.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 12 Dec 2019 19:44:36 +0100 Received: from selio1a020.lmera.ericsson.se (153.88.183.153) by smtp.internal.ericsson.com (153.88.183.193) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 12 Dec 2019 19:44:36 +0100 Received: from breslau.lmera.ericsson.se (breslau.lmera.ericsson.se [150.132.109.241]) by selio1a020.lmera.ericsson.se (8.15.1+Sun/8.15.1) with ESMTP id xBCIiaf8029479; Thu, 12 Dec 2019 19:44:36 +0100 (CET) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: , CC: , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Date: Thu, 12 Dec 2019 19:44:13 +0100 Message-ID: <20191212184413.18630-1-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.176.1.74; IPV:NLI; CTRY:SE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(346002)(376002)(39860400002)(396003)(136003)(199004)(189003)(51234002)(5660300002)(478600001)(8936002)(4326008)(246002)(316002)(7636002)(70206006)(70586007)(6666004)(356004)(8676002)(956004)(186003)(2616005)(107886003)(1076003)(86362001)(2906002)(336012)(26005)(110136005)(54906003)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR07MB4441; H:oa.msg.ericsson.com; FPR:; SPF:Pass; LANG:en; PTR:office365.se.ericsson.net; A:1; MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90ccab49-b7cb-4201-3e97-08d77f335b48 X-MS-TrafficTypeDiagnostic: HE1PR07MB4441: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-Forefront-PRVS: 0249EFCB0B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iQkmRkEYVKViPhAtARQ6dRY7YHQt2XbDc6RfmyqrD0jwRy5SLdji/kc+yZ0wIRMwRBK+kFnftb2o+Y1tbq0UTfCXJou7+naj+JO07lJELZZrpNGq5wEJJSa1ICsGAzeJFy++1Wn9KwiMcQtmCTPP+vYWAOK1Tli+TjLdmlneq8ss/pX+lfA4WHRh5axexK4PdpGHT9gbHPoeLyqCaSnwZtnaYKSYyO3Lax36n/TxpkXGHn+4Uh0Bjc2tm8kh8c3s7t5Ju8cWks3kvpkjYdYF95vQ+kT2H6l0IdkXJsILLoDuTxag63WxBhAA4XrVKfk4TRqGEfk/GJSbEDpmxpfThycN2rfmczIhciSxrG5L2JWimqZ2M7u4On+e5WLec8h1r03v0+uBa3vyeauXXR/4Z+E6rj8CjnhJ+bEvKNPa5lKwlqPz0ZvYNHwR5Flx9zOZT50Cc867vwgIZnni3ruz2N7kutknZPSdxXSFEkEqwsM9+2KOVmyJo9aDlYOuwsJv X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2019 18:44:44.7134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90ccab49-b7cb-4201-3e97-08d77f335b48 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB4441 Subject: [dpdk-dev] [PATCH] event/dsw: add by-name xstats retrieval 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" Implement rte_event_dev_stats_by_name(). Suggested-by: Niclas Storm Signed-off-by: Mattias Rönnblom --- drivers/event/dsw/dsw_xstats.c | 144 +++++++++++++++++++++-------- drivers/event/sw/sw_evdev_xstats.c | 2 - 2 files changed, 108 insertions(+), 38 deletions(-) diff --git a/drivers/event/dsw/dsw_xstats.c b/drivers/event/dsw/dsw_xstats.c index bf2eec527..c3f5db89c 100644 --- a/drivers/event/dsw/dsw_xstats.c +++ b/drivers/event/dsw/dsw_xstats.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Ericsson AB + * Copyright(c) 2018-2019 Ericsson AB */ #include "dsw_evdev.h" @@ -150,54 +150,81 @@ static struct dsw_xstats_port dsw_port_xstats[] = { false } }; -static int -dsw_xstats_dev_get_names(struct rte_event_dev_xstats_name *xstats_names, - unsigned int *ids, unsigned int size) +typedef +void (*dsw_xstats_foreach_fn)(const char *xstats_name, + enum rte_event_dev_xstats_mode mode, + uint8_t queue_port_id, unsigned int xstats_id, + void *data); + +static void +dsw_xstats_dev_foreach(dsw_xstats_foreach_fn fn, void *fn_data) { unsigned int i; - for (i = 0; i < RTE_DIM(dsw_dev_xstats) && i < size; i++) { - ids[i] = i; - strcpy(xstats_names[i].name, dsw_dev_xstats[i].name); - } - - return i; + for (i = 0; i < RTE_DIM(dsw_dev_xstats); i++) + fn(dsw_dev_xstats[i].name, RTE_EVENT_DEV_XSTATS_DEVICE, 0, + i, fn_data); } -static int -dsw_xstats_port_get_names(struct dsw_evdev *dsw, uint8_t port_id, - struct rte_event_dev_xstats_name *xstats_names, - unsigned int *ids, unsigned int size) +static void +dsw_xstats_port_foreach(struct dsw_evdev *dsw, uint8_t port_id, + dsw_xstats_foreach_fn fn, void *fn_data) { - uint8_t queue_id = 0; - unsigned int id_idx; + uint8_t queue_id; unsigned int stat_idx; - for (id_idx = 0, stat_idx = 0; - id_idx < size && stat_idx < RTE_DIM(dsw_port_xstats); - id_idx++) { + for (stat_idx = 0, queue_id = 0; + stat_idx < RTE_DIM(dsw_port_xstats);) { struct dsw_xstats_port *xstat = &dsw_port_xstats[stat_idx]; + char xstats_name[RTE_EVENT_DEV_XSTATS_NAME_SIZE]; + unsigned int xstats_id; if (xstat->per_queue) { - ids[id_idx] = DSW_XSTATS_ID_CREATE(stat_idx, queue_id); - snprintf(xstats_names[id_idx].name, - RTE_EVENT_DEV_XSTATS_NAME_SIZE, + xstats_id = DSW_XSTATS_ID_CREATE(stat_idx, queue_id); + snprintf(xstats_name, sizeof(xstats_name), dsw_port_xstats[stat_idx].name_fmt, port_id, queue_id); queue_id++; } else { - ids[id_idx] = stat_idx; - snprintf(xstats_names[id_idx].name, - RTE_EVENT_DEV_XSTATS_NAME_SIZE, + xstats_id = stat_idx; + snprintf(xstats_name, sizeof(xstats_name), dsw_port_xstats[stat_idx].name_fmt, port_id); } + fn(xstats_name, RTE_EVENT_DEV_XSTATS_PORT, port_id, + xstats_id, fn_data); + if (!(xstat->per_queue && queue_id < dsw->num_queues)) { stat_idx++; queue_id = 0; } } - return id_idx; +} + +struct store_ctx { + struct rte_event_dev_xstats_name *names; + unsigned int *ids; + unsigned int count; + unsigned int capacity; +}; + +static void +dsw_xstats_store_stat(const char *xstats_name, + enum rte_event_dev_xstats_mode mode, + uint8_t queue_port_id, unsigned int xstats_id, + void *data) +{ + struct store_ctx *ctx = data; + + RTE_SET_USED(mode); + RTE_SET_USED(queue_port_id); + + if (ctx->count < ctx->capacity) { + strcpy(ctx->names[ctx->count].name, xstats_name); + ctx->ids[ctx->count] = xstats_id; + } + + ctx->count++; } int @@ -205,16 +232,24 @@ dsw_xstats_get_names(const struct rte_eventdev *dev, enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id, struct rte_event_dev_xstats_name *xstats_names, - unsigned int *ids, unsigned int size) + unsigned int *ids, unsigned int capacity) { struct dsw_evdev *dsw = dsw_pmd_priv(dev); + struct store_ctx ctx = { + .names = xstats_names, + .ids = ids, + .capacity = capacity + }; + switch (mode) { case RTE_EVENT_DEV_XSTATS_DEVICE: - return dsw_xstats_dev_get_names(xstats_names, ids, size); + dsw_xstats_dev_foreach(dsw_xstats_store_stat, &ctx); + return ctx.count; case RTE_EVENT_DEV_XSTATS_PORT: - return dsw_xstats_port_get_names(dsw, queue_port_id, - xstats_names, ids, size); + dsw_xstats_port_foreach(dsw, queue_port_id, + dsw_xstats_store_stat, &ctx); + return ctx.count; case RTE_EVENT_DEV_XSTATS_QUEUE: return 0; default: @@ -278,11 +313,48 @@ dsw_xstats_get(const struct rte_eventdev *dev, return 0; } -uint64_t dsw_xstats_get_by_name(const struct rte_eventdev *dev, - const char *name, unsigned int *id) +struct find_ctx { + const struct rte_eventdev *dev; + const char *name; + unsigned int *id; + uint64_t value; +}; + +static void +dsw_xstats_find_stat(const char *xstats_name, + enum rte_event_dev_xstats_mode mode, + uint8_t queue_port_id, unsigned int xstats_id, + void *data) { - RTE_SET_USED(dev); - RTE_SET_USED(name); - RTE_SET_USED(id); - return 0; + struct find_ctx *ctx = data; + + if (strcmp(ctx->name, xstats_name) == 0) { + if (ctx->id != NULL) + *ctx->id = xstats_id; + dsw_xstats_get(ctx->dev, mode, queue_port_id, &xstats_id, + &ctx->value, 1); + } +} + +uint64_t +dsw_xstats_get_by_name(const struct rte_eventdev *dev, const char *name, + unsigned int *id) +{ + struct dsw_evdev *dsw = dsw_pmd_priv(dev); + uint16_t port_id; + + struct find_ctx ctx = { + .dev = dev, + .name = name, + .id = id, + .value = -EINVAL + }; + + dsw_xstats_dev_foreach(dsw_xstats_find_stat, &ctx); + + for (port_id = 0; port_id < dsw->num_ports; port_id++) + dsw_xstats_port_foreach(dsw, port_id, dsw_xstats_find_stat, + &ctx); + + return ctx.value; } diff --git a/drivers/event/sw/sw_evdev_xstats.c b/drivers/event/sw/sw_evdev_xstats.c index 90664903b..02f787418 100644 --- a/drivers/event/sw/sw_evdev_xstats.c +++ b/drivers/event/sw/sw_evdev_xstats.c @@ -391,8 +391,6 @@ sw_xstats_get_names(const struct rte_eventdev *dev, const struct sw_evdev *sw = sw_pmd_priv_const(dev); unsigned int i; unsigned int xidx = 0; - RTE_SET_USED(mode); - RTE_SET_USED(queue_port_id); uint32_t xstats_mode_count = 0; uint32_t start_offset = 0; -- 2.17.1