32 static char* getDataFifoStat(
u32 stat,
char buf[],
int maxbuf)
37 cursor += sprintf(buf+cursor,
"%4d ",
41 cursor += sprintf(buf+cursor,
"EMPTY ");
44 cursor += sprintf(buf+cursor,
"FULL ");
47 cursor += sprintf(buf+cursor,
"UNDER ");
50 cursor += sprintf(buf+cursor,
"EMPTY ");
57 #define DATA_FIFO_STAT(DIR, SHL) \
58 static ssize_t show_data_fifo_stat_##DIR( \
59 struct device * dev, \
60 struct device_attribute *attr, \
64 struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
65 u32 stat = (DMA_DATA_FIFSTA_RD(adev) >> SHL)&0xffff; \
66 getDataFifoStat(stat, flags, 80); \
67 return sprintf(buf, "0x%04x %s\n", stat, flags); \
70 static DEVICE_ATTR(data_fifo_stat_##DIR, (S_IRUSR|S_IRGRP), show_data_fifo_stat_##DIR, 0)
75 #define DESC_FIFO_STAT(DIR, SHL) \
76 static ssize_t show_desc_fifo_stat_##DIR( \
77 struct device * dev, \
78 struct device_attribute *attr, \
82 struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
83 u32 stat = (DMA_DESC_FIFSTA_RD(adev) >> SHL)&0xffff; \
84 getDataFifoStat(stat, flags, 80); \
85 return sprintf(buf, "0x%04x %s\n", stat, flags); \
88 static DEVICE_ATTR(desc_fifo_stat_##DIR, (S_IRUSR|S_IRGRP), show_desc_fifo_stat_##DIR, 0)
93 static char* getDmaCtrl(
u32 stat,
char buf[],
int maxbuf)
99 cursor += sprintf(buf+cursor,
"ENABLE ");
102 cursor += sprintf(buf+cursor,
"RESET ");
105 cursor += sprintf(buf+cursor,
"LOWLAT ");
108 cursor += sprintf(buf+cursor,
"RECYCLE ");
115 #define DMA_CTRL(DIR, SHL) \
116 static ssize_t show_dma_ctrl_##DIR( \
117 struct device * dev, \
118 struct device_attribute *attr, \
122 struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
123 u32 stat = (DMA_CTRL_RD(adev) >> SHL)&0xffff; \
124 getDmaCtrl(stat, flags, 80); \
125 return sprintf(buf, "0x%04x %s\n", stat, flags); \
128 static DEVICE_ATTR(dma_ctrl_##DIR, (S_IRUSR|S_IRGRP), show_dma_ctrl_##DIR, 0)
133 static char* getDesc(
u32 descr,
char buf[],
int maxbuf)
140 cursor += sprintf(buf+cursor,
"INTEN ");
143 cursor += sprintf(buf+cursor,
"id=%x\n", descr&
DMA_DESCR_ID);
148 #define DMA_LATEST(DIR, RD) \
149 static ssize_t show_dma_latest_##DIR( \
150 struct device * dev, \
151 struct device_attribute *attr, \
155 struct AFHBA_DEV *adev = afhba_lookupDeviceFromClass(dev); \
156 u32 descr = RD(adev); \
157 getDesc(descr, flags, 80); \
158 return sprintf(buf, "0x%08x %s\n", descr, flags); \
161 static DEVICE_ATTR(dma_latest_##DIR##_desc, (S_IRUSR|S_IRGRP), show_dma_latest_##DIR, 0)
169 static ssize_t store_reset_buffers(
171 struct device_attribute *attr,
172 const char *buf,
size_t count)
176 if (sscanf(buf,
"%u", &mode) > 0){
186 static DEVICE_ATTR(reset_buffers, (S_IWUSR|S_IWGRP), 0, store_reset_buffers);
191 static ssize_t store_buffer_len(
193 struct device_attribute *attr,
194 const char * buf,
size_t count)
199 if (sscanf(buf,
"%d", &ll_length) == 1 && ll_length > 0){
208 static ssize_t show_buffer_len(
210 struct device_attribute *attr,
219 static DEVICE_ATTR(
buffer_len, (S_IRUSR|S_IRGRP)|(S_IWUSR|S_IWGRP), show_buffer_len, store_buffer_len);
226 cursor += sprintf(buf+cursor,
"%c%s ",
230 cursor += sprintf(buf+cursor,
"LOS ");
233 cursor += sprintf(buf+cursor,
"TX_FAULT ");
236 cursor += sprintf(buf+cursor,
"HARD_ERR ");
239 cursor += sprintf(buf+cursor,
"SOFT_ERR ");
242 cursor += sprintf(buf+cursor,
"FRAME_ERR ");
245 cursor += sprintf(buf+cursor,
"+CHANNEL_UP ");
248 cursor += sprintf(buf+cursor,
"+LANE_UP ");
255 static ssize_t store_aurora(
257 struct device_attribute *attr,
258 const char * buf,
size_t count)
262 u32 ctrl = simple_strtoul(buf, 0, 16);
268 static ssize_t show_aurora(
270 struct device_attribute *attr,
285 return sprintf(buf,
"0x%08x %s\n", stat,
getFlags(stat, flags, 80)); \
289 static DEVICE_ATTR(aurora, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_aurora, store_aurora);
291 static ssize_t show_aurora_ext(
293 struct device_attribute *attr,
298 return sprintf(buf,
"0x%08x\n", read_astatus2(adev));
300 static DEVICE_ATTR(aurora_ext, (S_IRUGO), show_aurora_ext, 0);
302 static ssize_t store_comms_init(
304 struct device_attribute *attr,
305 const char * buf,
size_t count)
311 if (sscanf(buf,
"%d", &init) == 1 && init==1){
320 static ssize_t show_comms_init(
322 struct device_attribute *attr,
330 static DEVICE_ATTR(comms_init, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_comms_init, store_comms_init);
333 static ssize_t show_inflight(
335 struct device_attribute *attr,
339 struct JOB *job = &sdev->
job;
341 return sprintf(buf,
"%d\n", job->buffers_queued-job->buffers_received);
344 static DEVICE_ATTR(inflight, (S_IRUGO), show_inflight, 0);
346 static ssize_t show_shot(
348 struct device_attribute *attr,
352 return sprintf(buf,
"%d\n", sdev->
shot);
355 static DEVICE_ATTR(
shot, (S_IRUGO), show_shot, 0);
357 #define _ERRLAT(yymask) ((yymask) == 0x0ffff || (yymask) == 0)
358 #define ERRLAT(yy) (_ERRLAT((yy)&0x0ffff))
360 static ssize_t show_latstat(
362 struct device_attribute *attr,
370 unsigned over5 = ls1 & 0x0ffff;
375 dev_warn(dev,
"show_latstat maxtry exceeded");
379 return sprintf(buf,
"%5d %5d %5d %5d\n",
380 ls1>>16, ls1&0x0ffff, ls2>>16, ls2&0x0ffff);
383 static DEVICE_ATTR(latstat, (S_IRUSR|S_IRGRP), show_latstat, 0);
385 static ssize_t show_fpga_rev(
387 struct device_attribute *attr,
394 static DEVICE_ATTR(fpga_rev, (S_IRUGO), show_fpga_rev, 0);
397 static ssize_t store_dma_test(
399 struct device_attribute *attr,
400 const char * buf,
size_t count)
405 if (sscanf(buf,
"0x%x", &test) == 1 || sscanf(buf,
"%d", &test) == 1){
413 static ssize_t show_dma_test(
415 struct device_attribute *attr,
424 static DEVICE_ATTR(dma_test, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_dma_test, store_dma_test);
427 static ssize_t show_heartbeat(
429 struct device_attribute *attr,
436 static DEVICE_ATTR(heartbeat, (S_IRUGO), show_heartbeat, 0);
439 static ssize_t store_push_dma_timeouts(
441 struct device_attribute *attr,
442 const char * buf,
size_t count)
447 if (sscanf(buf,
"%d", &clear) == 1 && clear == 1){
456 static ssize_t show_push_dma_timeouts(
458 struct device_attribute *attr,
467 static DEVICE_ATTR(
push_dma_timeouts, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_push_dma_timeouts, store_push_dma_timeouts);
469 static ssize_t store_pull_dma_timeouts(
471 struct device_attribute *attr,
472 const char * buf,
size_t count)
477 if (sscanf(buf,
"%d", &clear) == 1 && clear == 1){
486 static ssize_t show_pull_dma_timeouts(
488 struct device_attribute *attr,
497 static DEVICE_ATTR(
pull_dma_timeouts, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_pull_dma_timeouts, store_pull_dma_timeouts);
499 static ssize_t store_host_test(
501 struct device_attribute *attr,
502 const char * buf,
size_t count)
507 if (sscanf(buf,
"%x", &tv) == 1){
515 static ssize_t show_host_test(
517 struct device_attribute *attr,
526 static DEVICE_ATTR(host_test, (S_IRUGO)|(S_IWUSR|S_IWGRP), show_host_test, store_host_test);
528 static ssize_t show_host_temp(
530 struct device_attribute *attr,
537 sprintf(buf,
"%08x T:%d.%02d C %s %s %s\n",
538 reg, TC100/100, TC100%100,
544 static DEVICE_ATTR(host_temp, (S_IRUGO), show_host_temp, 0);
546 static ssize_t show_streamer_pid(
548 struct device_attribute *attr,
554 sprintf(buf,
"%d\n", sdev->
pid);
557 static DEVICE_ATTR(streamer_pid, (S_IRUGO), show_streamer_pid, 0 );
560 static const struct attribute *dev_attrs[] = {
561 &dev_attr_buffer_len.attr,
562 &dev_attr_dma_test.attr,
563 &dev_attr_inflight.attr,
564 &dev_attr_reset_buffers.attr,
565 &dev_attr_aurora.attr,
566 &dev_attr_aurora_ext.attr,
567 &dev_attr_data_fifo_stat_push.attr,
568 &dev_attr_data_fifo_stat_pull.attr,
569 &dev_attr_desc_fifo_stat_push.attr,
570 &dev_attr_desc_fifo_stat_pull.attr,
571 &dev_attr_dma_ctrl_push.attr,
572 &dev_attr_dma_ctrl_pull.attr,
573 &dev_attr_dma_latest_push_desc.attr,
574 &dev_attr_dma_latest_pull_desc.attr,
575 &dev_attr_comms_init.attr,
577 &dev_attr_latstat.attr,
578 &dev_attr_fpga_rev.attr,
579 &dev_attr_heartbeat.attr,
580 &dev_attr_host_test.attr,
581 &dev_attr_host_temp.attr,
582 &dev_attr_streamer_pid.attr,
583 &dev_attr_pull_dma_timeouts.attr,
584 &dev_attr_push_dma_timeouts.attr,
593 rc = sysfs_create_files(&adev->
class_dev->kobj, dev_attrs);
595 dev_err(
pdev(adev),
"failed to create files");
602 sysfs_remove_files(&adev->
class_dev->kobj, dev_attrs);
605 static ssize_t show_dev(
607 struct device_attribute *attr,
612 return sprintf(buf,
"%d:0\n", adev->
major);
617 static DEVICE_ATTR(dev, (S_IRUSR|S_IRGRP), show_dev, 0);
619 static const struct attribute *class_attrs[] = {
627 dev_dbg(
pdev(adev),
"01");
629 rc = sysfs_create_files(&adev->
class_dev->kobj, class_attrs);
631 dev_err(
pdev(adev),
"failed to create files");
634 rc = sysfs_create_link(
637 dev_err(
pdev(adev),
"failed to create symlink %s\n",
"device");
639 dev_dbg(
pdev(adev),
"9");
644 sysfs_remove_files(&adev->
pci_dev->dev.kobj, class_attrs);