blob: b973babe3bbda44c2b8b7f3545e5d5e71483fd76 [file] [log] [blame]
Yu Huang8c107082017-07-24 14:58:26 -07001/*
2 **************************************************************************
3 * Copyright (c) 2016-2017, 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_stats.h
19 * NSS driver stats header file.
20 */
21
22#ifndef __NSS_STATS_H
23#define __NSS_STATS_H
24
25#include <linux/debugfs.h>
26
27/*
28 * Maximum string length:
29 * This should be equal to maximum string size of any stats
30 * inclusive of stats value
31 */
32#define NSS_STATS_MAX_STR_LENGTH 96
33
34/*
35 * Node statistics
36 */
37enum nss_stats_node {
38 NSS_STATS_NODE_RX_PKTS, /* Accelerated node RX packets */
39 NSS_STATS_NODE_RX_BYTES, /* Accelerated node RX bytes */
40 NSS_STATS_NODE_TX_PKTS, /* Accelerated node TX packets */
41 NSS_STATS_NODE_TX_BYTES, /* Accelerated node TX bytes */
42 NSS_STATS_NODE_RX_QUEUE_0_DROPPED,
43 /* Accelerated node RX Queue 0 dropped */
44 NSS_STATS_NODE_RX_QUEUE_1_DROPPED,
45 /* Accelerated node RX Queue 1 dropped */
46 NSS_STATS_NODE_RX_QUEUE_2_DROPPED,
47 /* Accelerated node RX Queue 2 dropped */
48 NSS_STATS_NODE_RX_QUEUE_3_DROPPED,
49 /* Accelerated node RX Queue 3 dropped */
50
51 NSS_STATS_NODE_MAX,
52};
53
54#define NSS_STATS_DECLARE_FILE_OPERATIONS(name) \
55static const struct file_operations nss_##name##_stats_ops = { \
56 .open = nss_stats_open, \
57 .read = nss_##name##_stats_read, \
58 .llseek = generic_file_llseek, \
59 .release = nss_stats_release, \
60};
61
62/*
63 * Private data for every file descriptor
64 */
65struct nss_stats_data {
66 uint32_t if_num; /**< Interface number for stats */
67 uint32_t index; /**< Index for GRE_REDIR stats */
68 uint32_t edma_id; /**< EDMA port ID or ring ID */
69 struct nss_ctx_instance *nss_ctx;
70 /**< The core for project stats */
71};
72
73int nss_stats_release(struct inode *inode, struct file *filp);
74int nss_stats_open(struct inode *inode, struct file *filp);
75void nss_stats_create_dentry(char *name, const struct file_operations *ops);
76size_t nss_stats_fill_common_stats(uint32_t if_num, char *lbuf, size_t size_wr, size_t size_al);
77
78#endif /* __NSS_STATS_H */