From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0083.outbound.protection.outlook.com [104.47.1.83]) by dpdk.org (Postfix) with ESMTP id 817091B745 for ; Wed, 31 Jan 2018 09:59:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TD8OUduDy53RZ5BqrQoZ7ow6ZOitmf5ScX8hqrAxi0c=; b=AaYq/bJ498Hz5yxZCFiq/fWgxvFUvTZdiA2YjZ4rh5JsoE/uvvjRTvguWoM8lJt5YmTdWftVuSnlLixWY/XMpuNG3ILSTEja2d4HBX/tczc3Ih7+At4VhHgyVWkEVFYCGGNLIiHpc7vFTxo2UELVlSt8rMPhYRkFzXKNv0S2JjM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shreyansh.jain@nxp.com; Received: from Tophie.ap.freescale.net (192.88.169.1) by VI1PR0401MB2462.eurprd04.prod.outlook.com (2603:10a6:800:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Wed, 31 Jan 2018 08:58:59 +0000 From: Shreyansh Jain To: thomas@monjalon.net Cc: dev@dpdk.org, hemant.agrawal@nxp.com, fiona.trahe@intel.com, rosen.xu@intel.com, Shreyansh Jain Date: Wed, 31 Jan 2018 14:43:12 +0530 Message-Id: <20180131091318.7894-5-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180131091318.7894-1-shreyansh.jain@nxp.com> References: <20180130145710.24757-1-shreyansh.jain@nxp.com> <20180131091318.7894-1-shreyansh.jain@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.169.1] X-ClientProxiedBy: HK2PR02CA0168.apcprd02.prod.outlook.com (2603:1096:201:1f::28) To VI1PR0401MB2462.eurprd04.prod.outlook.com (2603:10a6:800:55::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e9bf84fa-f59d-4662-93bc-08d56888e0cc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0401MB2462; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2462; 3:XaIHKckrP+RjoDjc28Z7zJTuwo0/fqaRvjXQlyimP7IGIYRPbNmI6s0m4Ec6yi9VvURrKCQ+e0FhqZzOx4IRZGg19KyLpVWgK5uwTT10dXQWos25aELP/sAr1g154ZP2Iimdcdf2cze9E+JWTP2jk7kYEZNzRtbNzeEvReFVQZ3c6+u8eFLfTEqHXwymAYZUO1LAlTBqIB2bb69OkwbrmmiXj4v6v/Ar5FepQSa+NmCesCn/enwb2JIg4Rzv6tvF; 25:yqhKW9Vx1v2g3Eokr+PrUZxhmpZmEY0tq3/Y/a/abCTL+sdjkumWjcpl/NrH5wHab2jvMpeqmjwoZvLO2GGb8Hffw62EfGDct4htXX3oKuP7M3Yxvdtybj4ieKnmRhoEgOt0zaZx124jl1lH3cW/US4JPhBHgbSCxeEj2UKGuQtP6SoNqm327CHU9v1hAqFjSDt28mK92I1lclr9kBr7DuUnwszxLO3XW3JTOAFABwSMcsqEKLORXA/xtjAW/v4V99tUoUr5SRMcjsH08IqTuBa85/qNzrnRJPFnCzQ6//K7uxxsWMJqcmS94rAcKJ0gH1XqgQbZUwTFfQ8L+zzqUA==; 31:EflBN+bx6yTtxhYJmyKzV2mnDUf5+DHCmnXjHnWWiH5jj6NAhbqfNI8QIIxTBdRTD8+sWjU+XgYiP0d9fz5bChZ6W2VDU9ObY9uS3ZCR5zHy6AfN5Fi4aVxzydDB+Fp5TBWCnHeukVgX7MTMyZth6LhlFS8WERH37AHsKGeM2o6Dkmggntp34UUzkX5E8WAc9fYJ4ng7xliY1zfzY0uHQC9IzBvw/fgCiAUNySQjLic= X-MS-TrafficTypeDiagnostic: VI1PR0401MB2462: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2462; 20:jLFRml3TqNGna9qfPWzKFOq+BBXtlPxNnbsHLsPFhN54I/1IWxMiVVViIO3JoJPaPxGn+N5JyJ0wNecUIniRhSt6k+8tJb+H4GRHx6hrPJtM0zu2W9eD6U03sGlZERKAM4V7z1ylx4FQjRmUv63F8GsDkTNRSlEDuIVqsEQVXYN+M45SM1Fj7GwfV4nfq68x+E1wmaCDy2Q4pN6TvFrBdKY5OuFyWjqY3+YpM9UVporc4pWET2qgB7MHY5tuEVmvmeMQo+kXgeyjufCs8QD1VNPU2MJq3gOD7V27iIGR0JvcKXgpShUalZ8rH1TFYyhnh8yLNPV2nalTfO/3J4mTLuiVvJ4+89wMFemR8XvIoBDSnfavKbbaoaMyrPCThLD+kuhpHJBFZGrbbEhD4lrtgztn94nL6AH7kXGH4H4CWEXzBrF/l7KTcOjxQ5RpJ6Azsz5RabANt/cn5XPmbyg6dNkap92Yq0R80BFfbtmkrzuWWqXjG07VJpvnmPQCkwPT; 4:PjO0WX7QhyAj7cBLASzBM+fLxLkOfDQ5U0p4bqfk51H3l7JXZIlfLkj6UW6J1Pg+0QPAAvERUULftkRuS0WZrMlg5RUhDbKNlDsBk0IXMp816TNxtvz+8O2veMzywOttrsYJBBKJYaU4T1QgGb/xVy697ZPc9hEJs6tEW/FF6SGgL/zgHGoccjYjpaRdu0AUeMy9MDm7NFIGWRXJMiFa0kHqGhnNkKpdD4M6fU8ZyjWeMAzz9JUGT5SKmbwagoDXOuqFRXwdKYWx50YgS9T2UJCbCFUbyrP2aBgr/+WGl/esp3Kgn+BBgVFH139Lp9xe X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(10201501046)(6055026)(6041288)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:VI1PR0401MB2462; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2462; X-Forefront-PRVS: 056929CBB8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(376002)(366004)(346002)(39860400002)(199004)(189003)(6486002)(6512007)(50226002)(8676002)(48376002)(4326008)(81156014)(316002)(8936002)(66066001)(6666003)(2950100002)(81166006)(6916009)(53936002)(16526019)(5660300001)(47776003)(186003)(26005)(106356001)(2361001)(97736004)(16586007)(305945005)(478600001)(51416003)(386003)(575784001)(36756003)(86362001)(105586002)(68736007)(2351001)(76176011)(1076002)(52116002)(2906002)(6506007)(25786009)(3846002)(6116002)(50466002)(59450400001)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2462; H:Tophie.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB2462; 23:PYyyUAbjWsBYbZ7jYIR/H3UqFUyFD7mcPl97/CM?= =?us-ascii?Q?b5kg6wHpa0QejygZi/N9VVW/YhOlL8ioXthtzbWoUFUPWJzUo34Eqm4piN7K?= =?us-ascii?Q?q2ScEWpDxlv/dLvu9LuXNrlf4LyJhFSUniucvNn3pgiH97r3tVBN2e46s3xG?= =?us-ascii?Q?QOxjMxjZ1QF6gMM+Azr8r4J9KxpoeUG7Eo7JEUz/8buuktF6DrriBZ+0Fcu7?= =?us-ascii?Q?aRA1qwlFcB9sBvdFzizH4Mk4lGfgkKFCZReB4AMJy+QtlqpaAE3gs4IrRCiX?= =?us-ascii?Q?QumxKX2Xvl4kRSowk+QV/lkx8OKjYlin9BXmT5e1LSNfV8mfJFEEFpd3N7US?= =?us-ascii?Q?Hnky4Z5zrDPsJRR/bK9KRwX6UA5gpdyeTwkMQz027FC5T6m5/67L/vveFx7J?= =?us-ascii?Q?DD6unOgl5qZk+UswHPAV3zkUgV1bSJOcrDIuL4dekqKSJb9h6b3LgcJqIkcO?= =?us-ascii?Q?mPBir/aZW4k/RE10jdN6aMEVrXTEmzTqwOCL9TC8OoRJFyrwUqqCkQATVu8c?= =?us-ascii?Q?z4GzC5EP+NQBLvIyZ01/KfHrAr7kaKWyVox53VYHCGIcuVIC70WGhK4Uv1ws?= =?us-ascii?Q?970xSLFrNY5fb/yzZB+o2XeVI4uCBKUSMMac9QVoz9MXWWzPvELeby+l4xpI?= =?us-ascii?Q?zd2Ep8ywPMNCpyi9r+SNxxUS/NYITZ9exIwxJky9ZhDpjA1gvzyCPhdFXCqw?= =?us-ascii?Q?+gsha+hfaqqnTfjgTWXMohdeUlhwLwpCkyIDsZkWrgvJkqdipSUl3Vx8llnR?= =?us-ascii?Q?i7/thyihNcnYGidE5yAIVLMIzhH9cJukPdUh7O5GRFMAmuaNAAYQ41/4Yu/4?= =?us-ascii?Q?1obts2xKaAFuFERGsPst+oVke19ducTfz3FZJRJ/Rs1bBVTp1ya8MSHyCVDk?= =?us-ascii?Q?LFDqzNoufI/RKFil3F4ZbjstL3zzzZn0uTAFHl1g62WqII00P5SSOcXtYEec?= =?us-ascii?Q?ZaBGtrXyiAZjLIH05SzbGvXPuU30Wixosss05q7iVMidfN79cY8YdG/rTo6o?= =?us-ascii?Q?gPLE8amlQZat8P41hHS8TdqypphlHbSTucKC2YJDWAWGs8hL3Hm59Vn8hvLY?= =?us-ascii?Q?uua7/EeWBYP0tz3+yKXjJWbgXLPacpcDTD9EP2sEsst83lxnylYcwV63BD+V?= =?us-ascii?Q?0kunlGEMFCpRKYAtY2LA5ckkXKq1/0OGGrfHwAr6RCnAiHiWIbi0ZKpJKs1m?= =?us-ascii?Q?k8eYo2KDC+yfdDZkFSfdeMVf2p1QtslowaxEe?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2462; 6:7lKfkqYS4UK1j2DonkgZQJhqLO3YELu9T3dE52RqNDEOmSrWix+F9WXEORKftin7kYJH0SVHxKwKCxTnnb3Ct1FmYST2vGuGPNRtW/iYsfs1s+rSivkgcktaf2oUi8kOpBBx/asmyU1cuJj6HFp7lYP8kg7FFw4Dp3qD1NjEIrqS5QHFC7BiriU16UgJDjcWsXq4JUh+9ubXLItlndaeOcpK6uewjkT9H5OS8e781sg1cm04w9b62CR4l8gnDzzH0OxUz3/f8B32eItvUNSS9xSm04ZUqMI8S6/4uzaYbx6Aufpn3XPTGMHNqfdfQnNjXle7RLrchSJxRuoMf0XpcCbEM/+NwQxv9Q8xf9JcBvs=; 5:EPqv/2MpuP3BfHq/vBdSqjgtuBlJYNO2KZM76oBVVBkfbPtEUHoGNLtlRA4tOUcMK8YnECX/Ysxp/6jVCUkeWRSumWt9Rc9F68wYBlvI/ik2k4ym7eI5482ULcy4e0XUui2EtV7T9f0f685RWgvrxwRLIPqaxJIEnY2uw2phcA8=; 24:vHcMGew8zG+98bjSttjZk9UrcjTKL2cqorC15N505/5zRuoxu/B4056IWWa9UmaWII4JgkNqOr/uaNqJQ02+IGOu9+QCZ/1LjBzId0ut5GM=; 7:s0D3KvF0PwBUqmLenX8RXPWwl4A9Vw49ZtnD5iPLhn9H4EuQSraL2FkaFDd53aYE0fnXL+agTxQ6DLfENqrIfi+tKkldNBzRzO0UGN/f6LnKHvKwbfasbkbKxkovKatJmeujy59TOuIGe7mypgZSupUFJO04wd/QS6ytCS+hj4Swg6+0fkSkz1Pne8GslpovTu1FLSJU3skK+POBOebnQ+zQmOsq16gPEnnLACWOEVKrFeDag+R7LrF8GcGVIfVl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2018 08:58:59.8043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e9bf84fa-f59d-4662-93bc-08d56888e0cc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2462 Subject: [dpdk-dev] [PATCH v4 04/10] rawdev: support for extended stats 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: , X-List-Received-Date: Wed, 31 Jan 2018 08:59:07 -0000 Generic rawdev library cannot define a pre-defined set of stats for devices which are yet to be defined. This patch introduces the xstats support for rawdev so that any implementation can create its own statistics. Signed-off-by: Shreyansh Jain --- lib/librte_rawdev/rte_rawdev.c | 75 ++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev.h | 105 +++++++++++++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_pmd.h | 72 +++++++++++++++++++++ lib/librte_rawdev/rte_rawdev_version.map | 4 ++ 4 files changed, 256 insertions(+) diff --git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c index a6d937c34..d6c284554 100644 --- a/lib/librte_rawdev/rte_rawdev.c +++ b/lib/librte_rawdev/rte_rawdev.c @@ -245,6 +245,81 @@ rte_rawdev_dump(uint16_t dev_id, FILE *f) return (*dev->dev_ops->dump)(dev, f); } +static int +xstats_get_count(uint16_t dev_id) +{ + struct rte_rawdev *dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get_names, -ENOTSUP); + return (*dev->dev_ops->xstats_get_names)(dev, NULL, 0); +} + +int __rte_experimental +rte_rawdev_xstats_names_get(uint16_t dev_id, + struct rte_rawdev_xstats_name *xstats_names, + unsigned int size) +{ + const struct rte_rawdev *dev; + int cnt_expected_entries; + + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV); + + cnt_expected_entries = xstats_get_count(dev_id); + + if (xstats_names == NULL || cnt_expected_entries < 0 || + (int)size < cnt_expected_entries || size <= 0) + return cnt_expected_entries; + + dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get_names, -ENOTSUP); + return (*dev->dev_ops->xstats_get_names)(dev, xstats_names, size); +} + +/* retrieve rawdev extended statistics */ +int __rte_experimental +rte_rawdev_xstats_get(uint16_t dev_id, + const unsigned int ids[], + uint64_t values[], + unsigned int n) +{ + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV); + const struct rte_rawdev *dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get, -ENOTSUP); + return (*dev->dev_ops->xstats_get)(dev, ids, values, n); +} + +uint64_t __rte_experimental +rte_rawdev_xstats_by_name_get(uint16_t dev_id, + const char *name, + unsigned int *id) +{ + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, 0); + const struct rte_rawdev *dev = &rte_rawdevs[dev_id]; + unsigned int temp = -1; + + if (id != NULL) + *id = (unsigned int)-1; + else + id = &temp; /* driver never gets a NULL value */ + + /* implemented by driver */ + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_get_by_name, -ENOTSUP); + return (*dev->dev_ops->xstats_get_by_name)(dev, name, id); +} + +int __rte_experimental +rte_rawdev_xstats_reset(uint16_t dev_id, + const uint32_t ids[], uint32_t nb_ids) +{ + RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); + struct rte_rawdev *dev = &rte_rawdevs[dev_id]; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->xstats_reset, -ENOTSUP); + return (*dev->dev_ops->xstats_reset)(dev, ids, nb_ids); +} + int __rte_experimental rte_rawdev_start(uint16_t dev_id) { diff --git a/lib/librte_rawdev/rte_rawdev.h b/lib/librte_rawdev/rte_rawdev.h index 3820ff08d..28bf9e0ff 100644 --- a/lib/librte_rawdev/rte_rawdev.h +++ b/lib/librte_rawdev/rte_rawdev.h @@ -420,6 +420,111 @@ rte_rawdev_dequeue_buffers(uint16_t dev_id, unsigned int count, rte_rawdev_obj_t context); +/** Maximum name length for extended statistics counters */ +#define RTE_RAW_DEV_XSTATS_NAME_SIZE 64 + +/** + * A name-key lookup element for extended statistics. + * + * This structure is used to map between names and ID numbers + * for extended ethdev statistics. + */ +struct rte_rawdev_xstats_name { + char name[RTE_RAW_DEV_XSTATS_NAME_SIZE]; +}; + +/** + * Retrieve names of extended statistics of a raw device. + * + * @param dev_id + * The identifier of the raw device. + * @param[out] xstats_names + * Block of memory to insert names into. Must be at least size in capacity. + * If set to NULL, function returns required capacity. + * @param size + * Capacity of xstats_names (number of names). + * @return + * - positive value lower or equal to size: success. The return value + * is the number of entries filled in the stats table. + * - positive value higher than size: error, the given statistics table + * is too small. The return value corresponds to the size that should + * be given to succeed. The entries in the table are not valid and + * shall not be used by the caller. + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int __rte_experimental +rte_rawdev_xstats_names_get(uint16_t dev_id, + struct rte_rawdev_xstats_name *xstats_names, + unsigned int size); + +/** + * Retrieve extended statistics of a raw device. + * + * @param dev_id + * The identifier of the device. + * @param ids + * The id numbers of the stats to get. The ids can be got from the stat + * position in the stat list from rte_rawdev_get_xstats_names(), or + * by using rte_rawdev_get_xstats_by_name() + * @param[out] values + * The values for each stats request by ID. + * @param n + * The number of stats requested + * @return + * - positive value: number of stat entries filled into the values array + * - negative value on error: + * -ENODEV for invalid *dev_id* + * -ENOTSUP if the device doesn't support this function. + */ +int __rte_experimental +rte_rawdev_xstats_get(uint16_t dev_id, + const unsigned int ids[], + uint64_t values[], + unsigned int n); + +/** + * Retrieve the value of a single stat by requesting it by name. + * + * @param dev_id + * The identifier of the device + * @param name + * The stat name to retrieve + * @param[out] id + * If non-NULL, the numerical id of the stat will be returned, so that further + * requests for the stat can be got using rte_rawdev_xstats_get, which will + * be faster as it doesn't need to scan a list of names for the stat. + * If the stat cannot be found, the id returned will be (unsigned)-1. + * @return + * - positive value or zero: the stat value + * - negative value: -EINVAL if stat not found, -ENOTSUP if not supported. + */ +uint64_t __rte_experimental +rte_rawdev_xstats_by_name_get(uint16_t dev_id, + const char *name, + unsigned int *id); + +/** + * Reset the values of the xstats of the selected component in the device. + * + * @param dev_id + * The identifier of the device + * @param ids + * Selects specific statistics to be reset. When NULL, all statistics + * will be reset. If non-NULL, must point to array of at least + * *nb_ids* size. + * @param nb_ids + * The number of ids available from the *ids* array. Ignored when ids is NULL. + * @return + * - zero: successfully reset the statistics to zero + * - negative value: -EINVAL invalid parameters, -ENOTSUP if not supported. + */ +int __rte_experimental +rte_rawdev_xstats_reset(uint16_t dev_id, + const uint32_t ids[], + uint32_t nb_ids); + #ifdef __cplusplus } #endif diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h b/lib/librte_rawdev/rte_rawdev_pmd.h index fe9cc6722..abc7c15c5 100644 --- a/lib/librte_rawdev/rte_rawdev_pmd.h +++ b/lib/librte_rawdev/rte_rawdev_pmd.h @@ -353,6 +353,69 @@ typedef int (*rawdev_set_attr_t)(struct rte_rawdev *dev, const char *attr_name, const uint64_t attr_value); +/** + * Retrieve a set of statistics from device. + * Note: Being a raw device, the stats are specific to the device being + * implemented thus represented as xstats. + * + * @param dev + * Raw device pointer + * @param ids + * The stat ids to retrieve + * @param values + * The returned stat values + * @param n + * The number of id values and entries in the values array + * @return + * The number of stat values successfully filled into the values array + */ +typedef int (*rawdev_xstats_get_t)(const struct rte_rawdev *dev, + const unsigned int ids[], uint64_t values[], unsigned int n); + +/** + * Resets the statistic values in xstats for the device. + */ +typedef int (*rawdev_xstats_reset_t)(struct rte_rawdev *dev, + const uint32_t ids[], + uint32_t nb_ids); + +/** + * Get names of extended stats of an raw device + * + * @param dev + * Raw device pointer + * @param xstats_names + * Array of name values to be filled in + * @param size + * Number of values in the xstats_names array + * @return + * When size >= the number of stats, return the number of stat values filled + * into the array. + * When size < the number of available stats, return the number of stats + * values, and do not fill in any data into xstats_names. + */ +typedef int (*rawdev_xstats_get_names_t)(const struct rte_rawdev *dev, + struct rte_rawdev_xstats_name *xstats_names, + unsigned int size); + +/** + * Get value of one stats and optionally return its id + * + * @param dev + * Raw device pointer + * @param name + * The name of the stat to retrieve + * @param id + * Pointer to an unsigned int where we store the stat-id. + * This pointer may be null if the id is not required. + * @return + * The value of the stat, or (uint64_t)-1 if the stat is not found. + * If the stat is not found, the id value will be returned as (unsigned)-1, + * if id pointer is non-NULL + */ +typedef uint64_t (*rawdev_xstats_get_by_name_t)(const struct rte_rawdev *dev, + const char *name, + unsigned int *id); /** Rawdevice operations function pointer table */ struct rte_rawdev_ops { /**< Get device info. */ @@ -388,6 +451,15 @@ struct rte_rawdev_ops { rawdev_get_attr_t attr_get; /**< Set an attribute managed by the implementation */ rawdev_set_attr_t attr_set; + + /**< Get extended device statistics. */ + rawdev_xstats_get_t xstats_get; + /**< Get names of extended stats. */ + rawdev_xstats_get_names_t xstats_get_names; + /**< Get one value by name. */ + rawdev_xstats_get_by_name_t xstats_get_by_name; + /**< Reset the statistics values in xstats. */ + rawdev_xstats_reset_t xstats_reset; }; /** diff --git a/lib/librte_rawdev/rte_rawdev_version.map b/lib/librte_rawdev/rte_rawdev_version.map index bafe2c5de..469b78d81 100644 --- a/lib/librte_rawdev/rte_rawdev_version.map +++ b/lib/librte_rawdev/rte_rawdev_version.map @@ -19,6 +19,10 @@ EXPERIMENTAL { rte_rawdev_socket_id; rte_rawdev_start; rte_rawdev_stop; + rte_rawdev_xstats_by_name_get; + rte_rawdev_xstats_get; + rte_rawdev_xstats_names_get; + rte_rawdev_xstats_reset; rte_rawdevs; local: *; -- 2.14.1