blob: 385c71aad671194e4221382f1f17d80e103a11fd [file] [log] [blame]
Yu Huang8c107082017-07-24 14:58:26 -07001/*
2 **************************************************************************
Manish Verma51973ce2020-01-20 23:13:37 +05303 * Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved.
Yu Huang8c107082017-07-24 14:58:26 -07004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/*
18 * nss_stats.h
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -070019 * printing stats header file
Yu Huang8c107082017-07-24 14:58:26 -070020 */
21
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -070022#ifndef __NSS_STATS_PRINT_H
23#define __NSS_STATS_PRINT_H
24#include <linux/ctype.h>
25#include <nss_drv_stats.h>
26#include <nss_def.h>
Wayne Tan5b7b6e92020-01-21 12:26:44 -080027#include <nss_stats_public.h>
Yu Huang8c107082017-07-24 14:58:26 -070028
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -070029/*
30 * Defines to be used by single instance/core packages.
31*/
32#define NSS_STATS_SINGLE_CORE -1
33#define NSS_STATS_SINGLE_INSTANCE -1
34
35/*
36 * Number of Extra outputlines for future reference to add new stats + start tag line + end tag line + three blank lines
37 */
38#define NSS_STATS_EXTRA_OUTPUT_LINES 35
Yu Huang8c107082017-07-24 14:58:26 -070039
Yu Huang8c107082017-07-24 14:58:26 -070040#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \
41static const struct file_operations nss_##name##_stats_ops = { \
42 .open = nss_stats_open, \
43 .read = nss_##name##_stats_read, \
44 .llseek = generic_file_llseek, \
45 .release = nss_stats_release, \
46};
47
48/*
49 * Private data for every file descriptor
50 */
51struct nss_stats_data {
52 uint32_t if_num; /**< Interface number for stats */
53 uint32_t index; /**< Index for GRE_REDIR stats */
54 uint32_t edma_id; /**< EDMA port ID or ring ID */
55 struct nss_ctx_instance *nss_ctx;
56 /**< The core for project stats */
57};
58
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -070059/*
60 * Structure definition carrying stats info.
61 */
62struct nss_stats_info {
63 char stats_name[NSS_STATS_MAX_STR_LENGTH]; /* stat name */
64 enum nss_stats_types stats_type; /* enum that tags stat type */
65};
Yu Huang8c107082017-07-24 14:58:26 -070066
Sakthi Vignesh Radhakrishnan150c5592019-07-02 10:17:44 -070067extern void nss_stats_register_sysctl(void);
68void nss_stats_init(void);
69extern int nss_stats_release(struct inode *inode, struct file *filp);
70extern int nss_stats_open(struct inode *inode, struct file *filp);
71void nss_stats_create_dentry(char *name, const struct file_operations *ops);
Manish Verma51973ce2020-01-20 23:13:37 +053072extern void nss_stats_reset_common_stats(uint32_t if_num);
Sakthi Vignesh Radhakrishnan1ceafde2019-08-23 13:05:00 -070073extern size_t nss_stats_fill_common_stats(uint32_t if_num, int instance, char *lbuf, size_t size_wr, size_t size_al, char *node);
74extern size_t nss_stats_banner(char *lbuf , size_t size_wr, size_t size_al, char *node, int core);
75extern size_t nss_stats_print(char *node, char *stat_details, int instance, struct nss_stats_info *stats_info, uint64_t *stats_val, uint16_t max, char *lbuf, size_t size_wr, size_t size_al);
Yu Huang8c107082017-07-24 14:58:26 -070076#endif /* __NSS_STATS_H */