1fd88b31aSHariprasad Shenai /*
2fd88b31aSHariprasad Shenai * This file is part of the Chelsio T4 Ethernet driver for Linux.
3fd88b31aSHariprasad Shenai *
4fd88b31aSHariprasad Shenai * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
5fd88b31aSHariprasad Shenai *
6fd88b31aSHariprasad Shenai * This software is available to you under a choice of one of two
7fd88b31aSHariprasad Shenai * licenses. You may choose to be licensed under the terms of the GNU
8fd88b31aSHariprasad Shenai * General Public License (GPL) Version 2, available from the file
9fd88b31aSHariprasad Shenai * COPYING in the main directory of this source tree, or the
10fd88b31aSHariprasad Shenai * OpenIB.org BSD license below:
11fd88b31aSHariprasad Shenai *
12fd88b31aSHariprasad Shenai * Redistribution and use in source and binary forms, with or
13fd88b31aSHariprasad Shenai * without modification, are permitted provided that the following
14fd88b31aSHariprasad Shenai * conditions are met:
15fd88b31aSHariprasad Shenai *
16fd88b31aSHariprasad Shenai * - Redistributions of source code must retain the above
17fd88b31aSHariprasad Shenai * copyright notice, this list of conditions and the following
18fd88b31aSHariprasad Shenai * disclaimer.
19fd88b31aSHariprasad Shenai *
20fd88b31aSHariprasad Shenai * - Redistributions in binary form must reproduce the above
21fd88b31aSHariprasad Shenai * copyright notice, this list of conditions and the following
22fd88b31aSHariprasad Shenai * disclaimer in the documentation and/or other materials
23fd88b31aSHariprasad Shenai * provided with the distribution.
24fd88b31aSHariprasad Shenai *
25fd88b31aSHariprasad Shenai * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26fd88b31aSHariprasad Shenai * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27fd88b31aSHariprasad Shenai * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28fd88b31aSHariprasad Shenai * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29fd88b31aSHariprasad Shenai * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30fd88b31aSHariprasad Shenai * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31fd88b31aSHariprasad Shenai * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32fd88b31aSHariprasad Shenai * SOFTWARE.
33fd88b31aSHariprasad Shenai */
34fd88b31aSHariprasad Shenai
35fd88b31aSHariprasad Shenai #ifndef __CXGB4_DEBUGFS_H
36fd88b31aSHariprasad Shenai #define __CXGB4_DEBUGFS_H
37fd88b31aSHariprasad Shenai
38fd88b31aSHariprasad Shenai #include <linux/export.h>
39fd88b31aSHariprasad Shenai
40fd88b31aSHariprasad Shenai struct t4_debugfs_entry {
41fd88b31aSHariprasad Shenai const char *name;
42fd88b31aSHariprasad Shenai const struct file_operations *ops;
4392fc41c3SAl Viro umode_t mode;
44fd88b31aSHariprasad Shenai unsigned char data;
45fd88b31aSHariprasad Shenai };
46fd88b31aSHariprasad Shenai
47f1ff24aaSHariprasad Shenai struct seq_tab {
48f1ff24aaSHariprasad Shenai int (*show)(struct seq_file *seq, void *v, int idx);
49f1ff24aaSHariprasad Shenai unsigned int rows; /* # of entries */
50f1ff24aaSHariprasad Shenai unsigned char width; /* size in bytes of each entry */
51f1ff24aaSHariprasad Shenai unsigned char skip_first; /* whether the first line is a header */
52*65dc2f1aSGustavo A. R. Silva char data[]; /* the table data */
53f1ff24aaSHariprasad Shenai };
54f1ff24aaSHariprasad Shenai
hex2val(char c)55688ea5feSHariprasad Shenai static inline unsigned int hex2val(char c)
56688ea5feSHariprasad Shenai {
57688ea5feSHariprasad Shenai return isdigit(c) ? c - '0' : tolower(c) - 'a' + 10;
58688ea5feSHariprasad Shenai }
59688ea5feSHariprasad Shenai
60f1ff24aaSHariprasad Shenai struct seq_tab *seq_open_tab(struct file *f, unsigned int rows,
61f1ff24aaSHariprasad Shenai unsigned int width, unsigned int have_header,
62f1ff24aaSHariprasad Shenai int (*show)(struct seq_file *seq, void *v, int i));
63f1ff24aaSHariprasad Shenai
64fd88b31aSHariprasad Shenai int t4_setup_debugfs(struct adapter *adap);
65fd88b31aSHariprasad Shenai void add_debugfs_files(struct adapter *adap,
66fd88b31aSHariprasad Shenai struct t4_debugfs_entry *files,
67fd88b31aSHariprasad Shenai unsigned int nfiles);
6849216c1cSHariprasad Shenai int mem_open(struct inode *inode, struct file *file);
69fd88b31aSHariprasad Shenai
70fd88b31aSHariprasad Shenai #endif
71