27 #include <linux/seq_file.h>
28 #include <linux/proc_fs.h>
38 static void *hb_seq_start(
struct seq_file *sfile, loff_t *pos)
48 static void *hb_seq_next(
struct seq_file *s,
void *v, loff_t *pos)
60 static void hb_seq_stop(
struct seq_file *s,
void *v) {}
63 static inline const char *BSTATE2S(
enum BSTATE bstate)
66 case BS_EMPTY:
return "BS_EMPTY";
67 case BS_FILLING:
return "BS_FILLING";
68 case BS_FULL:
return "BS_FULL";
69 case BS_FULL_APP:
return "BS_FULL_APP";
70 default:
return "BS_ERROR";
75 static int hb_seq_show(
struct seq_file *sfile,
void *v)
77 struct file *file = (
struct file *)sfile->private;
78 struct AFHBA_DEV *adev = PDE_DATA(file_inode(file));
84 seq_printf(sfile,
"ix va pa len req_len descr state\n");
87 "[%02d] %p %08x %06x %06x %08x %s\n",
93 static int hbd_seq_show(
struct seq_file *sfile,
void *v)
95 struct file *file = (
struct file *)sfile->private;
96 struct AFHBA_DEV *adev = PDE_DATA(file_inode(file));
101 seq_printf(sfile,
"%08x\n", hb->
descr);
108 static int ab_seq_show(
struct seq_file *sfile,
void *v)
111 struct file *file = (
struct file *)sfile->private;
112 struct AFHBA_DEV *adev = PDE_DATA(file_inode(file));
118 seq_printf(sfile,
"ix va pa len req_len descr state\n");
122 "[%02d] %p %08x %06x %06x %08x %s\n",
130 static int __proc_open(
131 struct inode *inode,
struct file *file,
132 struct seq_operations *_seq_ops)
134 int rc = seq_open(file, _seq_ops);
137 struct seq_file* seq_file =
138 (
struct seq_file*)file->private_data;
139 seq_file->private = file;
145 static int hb_proc_open(
struct inode *inode,
struct file *file)
147 static struct seq_operations _seq_ops = {
148 .start = hb_seq_start,
153 return __proc_open(inode, file, &_seq_ops);
155 static int hbd_proc_open(
struct inode *inode,
struct file *file)
157 static struct seq_operations _seq_ops = {
158 .start = hb_seq_start,
163 return __proc_open(inode, file, &_seq_ops);
166 static int addHostBufferProcFiles(
struct AFHBA_DEV *adev)
168 static struct file_operations hb_proc_fops = {
169 .owner = THIS_MODULE,
170 .open = hb_proc_open,
173 .release = seq_release
175 static struct file_operations hbd_proc_fops = {
176 .owner = THIS_MODULE,
177 .open = hbd_proc_open,
180 .release = seq_release
183 struct proc_dir_entry *hb_entry =
184 proc_create_data(
"HostBuffers", S_IRUGO,
188 hb_entry = proc_create_data(
"HostDescriptors", S_IRUGO,
195 dev_err(
pdev(adev),
"Failed to create entry");
199 static int ab_proc_open(
struct inode *inode,
struct file *file)
201 static struct seq_operations _seq_ops = {
202 .start = hb_seq_start,
207 return __proc_open(inode, file, &_seq_ops);
210 static int addAppBufferProcFiles(
struct AFHBA_DEV *adev)
212 static struct file_operations ab_proc_fops = {
213 .owner = THIS_MODULE,
214 .open = ab_proc_open,
217 .release = seq_release
220 struct proc_dir_entry *ab_entry =
221 proc_create_data(
"AppBuffers", S_IRUGO,
227 dev_err(
pdev(adev),
"Failed to create entry");
231 static int job_proc_show(
struct seq_file *m,
void *v)
233 struct file *file = (
struct file *)m->private;
234 struct AFHBA_DEV *adev = PDE_DATA(file_inode(file));
236 struct JOB *job = &sdev->
job;
241 if (data_rate > 0x100000){
242 data_rate /= 0x100000;
248 dev_warn(
pdev(adev),
"bstate[%d] %d out of range", ii, bs);
255 "dev=%s idx=%d demand=%d queued=%d "
256 "rx=%d rx_rate=%d int_rate=%d "
258 "BS_EMPTY=%-2d BS_FILLING=%-2d BS_FULL=%-2d BS_FULL_APP=%-2d "
259 "STATUS=%s ERRORS=%d\n",
263 job->buffers_received,
264 job->rx_rate, job->int_rate,
266 bstates[0], bstates[1], bstates[2], bstates[3],
274 static int job_proc_open(
struct inode *inode,
struct file *file)
276 return single_open(file, job_proc_show, file);
278 static int addJobProcFile(
struct AFHBA_DEV *adev)
281 static struct file_operations job_proc_fops = {
282 .owner = THIS_MODULE,
283 .open = job_proc_open,
286 .release = single_release
288 if (proc_create_data(
"Job", S_IRUGO,
292 dev_err(
pdev(adev),
"Failed to create entry");
308 if ((rc = addHostBufferProcFiles(adev)) == 0 &&
309 (rc = addAppBufferProcFiles(adev)) == 0 &&
310 (rc = addJobProcFile(adev) == 0) == 0){