Yu Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
Manish Verma | 51973ce | 2020-01-20 23:13:37 +0530 | [diff] [blame] | 3 | * Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved. |
Yu Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 4 | * 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 Radhakrishnan | 150c559 | 2019-07-02 10:17:44 -0700 | [diff] [blame] | 19 | * printing stats header file |
Yu Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Sakthi Vignesh Radhakrishnan | 150c559 | 2019-07-02 10:17:44 -0700 | [diff] [blame] | 22 | #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 Tan | 5b7b6e9 | 2020-01-21 12:26:44 -0800 | [diff] [blame] | 27 | #include <nss_stats_public.h> |
Yu Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 28 | |
Sakthi Vignesh Radhakrishnan | 150c559 | 2019-07-02 10:17:44 -0700 | [diff] [blame] | 29 | /* |
| 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 Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 39 | |
Yu Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 40 | #define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \ |
| 41 | static 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 | */ |
| 51 | struct 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 Radhakrishnan | 150c559 | 2019-07-02 10:17:44 -0700 | [diff] [blame] | 59 | /* |
| 60 | * Structure definition carrying stats info. |
| 61 | */ |
| 62 | struct 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 Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 66 | |
Sakthi Vignesh Radhakrishnan | 150c559 | 2019-07-02 10:17:44 -0700 | [diff] [blame] | 67 | extern void nss_stats_register_sysctl(void); |
| 68 | void nss_stats_init(void); |
| 69 | extern int nss_stats_release(struct inode *inode, struct file *filp); |
| 70 | extern int nss_stats_open(struct inode *inode, struct file *filp); |
| 71 | void nss_stats_create_dentry(char *name, const struct file_operations *ops); |
Manish Verma | 51973ce | 2020-01-20 23:13:37 +0530 | [diff] [blame] | 72 | extern void nss_stats_reset_common_stats(uint32_t if_num); |
Sakthi Vignesh Radhakrishnan | 1ceafde | 2019-08-23 13:05:00 -0700 | [diff] [blame] | 73 | extern 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); |
| 74 | extern size_t nss_stats_banner(char *lbuf , size_t size_wr, size_t size_al, char *node, int core); |
| 75 | extern 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 Huang | 8c10708 | 2017-07-24 14:58:26 -0700 | [diff] [blame] | 76 | #endif /* __NSS_STATS_H */ |