Wayne Tan | b45933c | 2020-01-06 17:19:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************** |
| 3 | * Copyright (c) 2020, The Linux Foundation. All rights reserved. |
| 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_strings.h |
| 19 | * NSS driver strings header file. |
| 20 | */ |
| 21 | |
| 22 | #ifndef __NSS_STRINGS_H |
| 23 | #define __NSS_STRINGS_H |
| 24 | |
| 25 | #include <linux/debugfs.h> |
| 26 | #include "nss_stats.h" |
| 27 | |
| 28 | #define NSS_STRINGS_DECLARE_FILE_OPERATIONS(name) \ |
| 29 | static const struct file_operations nss_##name##_strings_ops = { \ |
| 30 | .open = nss_strings_open, \ |
| 31 | .read = nss_##name##_strings_read, \ |
| 32 | .llseek = generic_file_llseek, \ |
| 33 | .release = nss_strings_release, \ |
| 34 | } |
| 35 | |
| 36 | /* |
| 37 | * Private data for every file descriptor |
| 38 | */ |
| 39 | struct nss_strings_data { |
| 40 | uint32_t if_num; /**< Interface number for stats */ |
| 41 | struct nss_ctx_instance *nss_ctx; /**< The core for project stats */ |
| 42 | }; |
| 43 | |
| 44 | extern struct nss_stats_info nss_strings_stats_node[NSS_STATS_NODE_MAX]; |
| 45 | void nss_strings_init(void); |
| 46 | int nss_strings_release(struct inode *inode, struct file *filp); |
| 47 | int nss_strings_open(struct inode *inode, struct file *filp); |
| 48 | void nss_strings_create_dentry(char *name, const struct file_operations *ops); |
| 49 | size_t nss_strings_fill_common_stats(char __user *ubuf, size_t sz, loff_t *ppos); |
| 50 | size_t nss_strings_print(char __user *ubuf, size_t sz, loff_t *ppos, struct nss_stats_info *stats_info, uint16_t max); |
| 51 | |
| 52 | #endif /* __NSS_STRINGS_H */ |