2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
4 * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #include <linux/seq_file.h>
36 #include <linux/debugfs.h>
37 #include <linux/string_helpers.h>
38 #include <linux/sort.h>
39 #include <linux/ctype.h>
43 #include "t4_values.h"
45 #include "cxgb4_debugfs.h"
49 /* generic seq_file support for showing a table of size rows x width. */
50 static void *seq_tab_get_idx(struct seq_tab
*tb
, loff_t pos
)
52 pos
-= tb
->skip_first
;
53 return pos
>= tb
->rows
? NULL
: &tb
->data
[pos
* tb
->width
];
56 static void *seq_tab_start(struct seq_file
*seq
, loff_t
*pos
)
58 struct seq_tab
*tb
= seq
->private;
60 if (tb
->skip_first
&& *pos
== 0)
61 return SEQ_START_TOKEN
;
63 return seq_tab_get_idx(tb
, *pos
);
66 static void *seq_tab_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
68 v
= seq_tab_get_idx(seq
->private, *pos
+ 1);
74 static void seq_tab_stop(struct seq_file
*seq
, void *v
)
78 static int seq_tab_show(struct seq_file
*seq
, void *v
)
80 const struct seq_tab
*tb
= seq
->private;
82 return tb
->show(seq
, v
, ((char *)v
- tb
->data
) / tb
->width
);
85 static const struct seq_operations seq_tab_ops
= {
86 .start
= seq_tab_start
,
92 struct seq_tab
*seq_open_tab(struct file
*f
, unsigned int rows
,
93 unsigned int width
, unsigned int have_header
,
94 int (*show
)(struct seq_file
*seq
, void *v
, int i
))
98 p
= __seq_open_private(f
, &seq_tab_ops
, sizeof(*p
) + rows
* width
);
103 p
->skip_first
= have_header
!= 0;
108 /* Trim the size of a seq_tab to the supplied number of rows. The operation is
111 static int seq_tab_trim(struct seq_tab
*p
, unsigned int new_rows
)
113 if (new_rows
> p
->rows
)
119 static int cim_la_show(struct seq_file
*seq
, void *v
, int idx
)
121 if (v
== SEQ_START_TOKEN
)
122 seq_puts(seq
, "Status Data PC LS0Stat LS0Addr "
128 " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
129 (p
[0] >> 4) & 0xff, p
[0] & 0xf, p
[1] >> 4,
130 p
[1] & 0xf, p
[2] >> 4, p
[2] & 0xf, p
[3], p
[4], p
[5],
136 static int cim_la_show_3in1(struct seq_file
*seq
, void *v
, int idx
)
138 if (v
== SEQ_START_TOKEN
) {
139 seq_puts(seq
, "Status Data PC\n");
143 seq_printf(seq
, " %02x %08x %08x\n", p
[5] & 0xff, p
[6],
145 seq_printf(seq
, " %02x %02x%06x %02x%06x\n",
146 (p
[3] >> 8) & 0xff, p
[3] & 0xff, p
[4] >> 8,
147 p
[4] & 0xff, p
[5] >> 8);
148 seq_printf(seq
, " %02x %x%07x %x%07x\n", (p
[0] >> 4) & 0xff,
149 p
[0] & 0xf, p
[1] >> 4, p
[1] & 0xf, p
[2] >> 4);
154 static int cim_la_open(struct inode
*inode
, struct file
*file
)
159 struct adapter
*adap
= inode
->i_private
;
161 ret
= t4_cim_read(adap
, UP_UP_DBG_LA_CFG_A
, 1, &cfg
);
165 p
= seq_open_tab(file
, adap
->params
.cim_la_size
/ 8, 8 * sizeof(u32
), 1,
166 cfg
& UPDBGLACAPTPCONLY_F
?
167 cim_la_show_3in1
: cim_la_show
);
171 ret
= t4_cim_read_la(adap
, (u32
*)p
->data
, NULL
);
173 seq_release_private(inode
, file
);
177 static const struct file_operations cim_la_fops
= {
178 .owner
= THIS_MODULE
,
182 .release
= seq_release_private
185 static int cim_qcfg_show(struct seq_file
*seq
, void *v
)
187 static const char * const qname
[] = {
188 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
189 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
194 struct adapter
*adap
= seq
->private;
195 u16 base
[CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
];
196 u16 size
[CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
];
197 u32 stat
[(4 * (CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
))];
198 u16 thres
[CIM_NUM_IBQ
];
199 u32 obq_wr_t4
[2 * CIM_NUM_OBQ
], *wr
;
200 u32 obq_wr_t5
[2 * CIM_NUM_OBQ_T5
];
202 int cim_num_obq
= is_t4(adap
->params
.chip
) ?
203 CIM_NUM_OBQ
: CIM_NUM_OBQ_T5
;
205 i
= t4_cim_read(adap
, is_t4(adap
->params
.chip
) ? UP_IBQ_0_RDADDR_A
:
206 UP_IBQ_0_SHADOW_RDADDR_A
,
207 ARRAY_SIZE(stat
), stat
);
209 if (is_t4(adap
->params
.chip
)) {
210 i
= t4_cim_read(adap
, UP_OBQ_0_REALADDR_A
,
211 ARRAY_SIZE(obq_wr_t4
), obq_wr_t4
);
214 i
= t4_cim_read(adap
, UP_OBQ_0_SHADOW_REALADDR_A
,
215 ARRAY_SIZE(obq_wr_t5
), obq_wr_t5
);
222 t4_read_cimq_cfg(adap
, base
, size
, thres
);
225 " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
226 for (i
= 0; i
< CIM_NUM_IBQ
; i
++, p
+= 4)
227 seq_printf(seq
, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
228 qname
[i
], base
[i
], size
[i
], thres
[i
],
229 IBQRDADDR_G(p
[0]), IBQWRADDR_G(p
[1]),
230 QUESOPCNT_G(p
[3]), QUEEOPCNT_G(p
[3]),
231 QUEREMFLITS_G(p
[2]) * 16);
232 for ( ; i
< CIM_NUM_IBQ
+ cim_num_obq
; i
++, p
+= 4, wr
+= 2)
233 seq_printf(seq
, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
234 qname
[i
], base
[i
], size
[i
],
235 QUERDADDR_G(p
[0]) & 0x3fff, wr
[0] - base
[i
],
236 QUESOPCNT_G(p
[3]), QUEEOPCNT_G(p
[3]),
237 QUEREMFLITS_G(p
[2]) * 16);
241 static int cim_qcfg_open(struct inode
*inode
, struct file
*file
)
243 return single_open(file
, cim_qcfg_show
, inode
->i_private
);
246 static const struct file_operations cim_qcfg_fops
= {
247 .owner
= THIS_MODULE
,
248 .open
= cim_qcfg_open
,
251 .release
= single_release
,
254 static int cimq_show(struct seq_file
*seq
, void *v
, int idx
)
258 seq_printf(seq
, "%#06x: %08x %08x %08x %08x\n", idx
* 16, p
[0], p
[1],
263 static int cim_ibq_open(struct inode
*inode
, struct file
*file
)
267 unsigned int qid
= (uintptr_t)inode
->i_private
& 7;
268 struct adapter
*adap
= inode
->i_private
- qid
;
270 p
= seq_open_tab(file
, CIM_IBQ_SIZE
, 4 * sizeof(u32
), 0, cimq_show
);
274 ret
= t4_read_cim_ibq(adap
, qid
, (u32
*)p
->data
, CIM_IBQ_SIZE
* 4);
276 seq_release_private(inode
, file
);
282 static const struct file_operations cim_ibq_fops
= {
283 .owner
= THIS_MODULE
,
284 .open
= cim_ibq_open
,
287 .release
= seq_release_private
290 static int cim_obq_open(struct inode
*inode
, struct file
*file
)
294 unsigned int qid
= (uintptr_t)inode
->i_private
& 7;
295 struct adapter
*adap
= inode
->i_private
- qid
;
297 p
= seq_open_tab(file
, 6 * CIM_OBQ_SIZE
, 4 * sizeof(u32
), 0, cimq_show
);
301 ret
= t4_read_cim_obq(adap
, qid
, (u32
*)p
->data
, 6 * CIM_OBQ_SIZE
* 4);
303 seq_release_private(inode
, file
);
305 seq_tab_trim(p
, ret
/ 4);
311 static const struct file_operations cim_obq_fops
= {
312 .owner
= THIS_MODULE
,
313 .open
= cim_obq_open
,
316 .release
= seq_release_private
325 static void field_desc_show(struct seq_file
*seq
, u64 v
,
326 const struct field_desc
*p
)
332 u64 mask
= (1ULL << p
->width
) - 1;
333 int len
= scnprintf(buf
, sizeof(buf
), "%s: %llu", p
->name
,
334 ((unsigned long long)v
>> p
->start
) & mask
);
336 if (line_size
+ len
>= 79) {
338 seq_puts(seq
, "\n ");
340 seq_printf(seq
, "%s ", buf
);
341 line_size
+= len
+ 1;
347 static struct field_desc tp_la0
[] = {
348 { "RcfOpCodeOut", 60, 4 },
350 { "WcfState", 52, 4 },
351 { "RcfOpcSrcOut", 50, 2 },
352 { "CRxError", 49, 1 },
353 { "ERxError", 48, 1 },
354 { "SanityFailed", 47, 1 },
355 { "SpuriousMsg", 46, 1 },
356 { "FlushInputMsg", 45, 1 },
357 { "FlushInputCpl", 44, 1 },
358 { "RssUpBit", 43, 1 },
359 { "RssFilterHit", 42, 1 },
361 { "InitTcb", 31, 1 },
362 { "LineNumber", 24, 7 },
364 { "EdataOut", 22, 1 },
366 { "CdataOut", 20, 1 },
367 { "EreadPdu", 19, 1 },
368 { "CreadPdu", 18, 1 },
369 { "TunnelPkt", 17, 1 },
370 { "RcfPeerFin", 16, 1 },
371 { "RcfReasonOut", 12, 4 },
372 { "TxCchannel", 10, 2 },
373 { "RcfTxChannel", 8, 2 },
374 { "RxEchannel", 6, 2 },
375 { "RcfRxChannel", 5, 1 },
376 { "RcfDataOutSrdy", 4, 1 },
378 { "RxOoDvld", 2, 1 },
379 { "RxCongestion", 1, 1 },
380 { "TxCongestion", 0, 1 },
384 static int tp_la_show(struct seq_file
*seq
, void *v
, int idx
)
388 field_desc_show(seq
, *p
, tp_la0
);
392 static int tp_la_show2(struct seq_file
*seq
, void *v
, int idx
)
398 field_desc_show(seq
, p
[0], tp_la0
);
399 if (idx
< (TPLA_SIZE
/ 2 - 1) || p
[1] != ~0ULL)
400 field_desc_show(seq
, p
[1], tp_la0
);
404 static int tp_la_show3(struct seq_file
*seq
, void *v
, int idx
)
406 static struct field_desc tp_la1
[] = {
407 { "CplCmdIn", 56, 8 },
408 { "CplCmdOut", 48, 8 },
409 { "ESynOut", 47, 1 },
410 { "EAckOut", 46, 1 },
411 { "EFinOut", 45, 1 },
412 { "ERstOut", 44, 1 },
418 { "DataInVld", 38, 1 },
420 { "RxBufEmpty", 36, 1 },
422 { "RxFbCongestion", 34, 1 },
423 { "TxFbCongestion", 33, 1 },
424 { "TxPktSumSrdy", 32, 1 },
425 { "RcfUlpType", 28, 4 },
427 { "Ebypass", 26, 1 },
429 { "Static0", 24, 1 },
431 { "Cbypass", 22, 1 },
433 { "CPktOut", 20, 1 },
434 { "RxPagePoolFull", 18, 2 },
435 { "RxLpbkPkt", 17, 1 },
436 { "TxLpbkPkt", 16, 1 },
437 { "RxVfValid", 15, 1 },
438 { "SynLearned", 14, 1 },
439 { "SetDelEntry", 13, 1 },
440 { "SetInvEntry", 12, 1 },
441 { "CpcmdDvld", 11, 1 },
442 { "CpcmdSave", 10, 1 },
443 { "RxPstructsFull", 8, 2 },
444 { "EpcmdDvld", 7, 1 },
445 { "EpcmdFlush", 6, 1 },
446 { "EpcmdTrimPrefix", 5, 1 },
447 { "EpcmdTrimPostfix", 4, 1 },
448 { "ERssIp4Pkt", 3, 1 },
449 { "ERssIp6Pkt", 2, 1 },
450 { "ERssTcpUdpPkt", 1, 1 },
451 { "ERssFceFipPkt", 0, 1 },
454 static struct field_desc tp_la2
[] = {
455 { "CplCmdIn", 56, 8 },
456 { "MpsVfVld", 55, 1 },
464 { "DataInVld", 38, 1 },
466 { "RxBufEmpty", 36, 1 },
468 { "RxFbCongestion", 34, 1 },
469 { "TxFbCongestion", 33, 1 },
470 { "TxPktSumSrdy", 32, 1 },
471 { "RcfUlpType", 28, 4 },
473 { "Ebypass", 26, 1 },
475 { "Static0", 24, 1 },
477 { "Cbypass", 22, 1 },
479 { "CPktOut", 20, 1 },
480 { "RxPagePoolFull", 18, 2 },
481 { "RxLpbkPkt", 17, 1 },
482 { "TxLpbkPkt", 16, 1 },
483 { "RxVfValid", 15, 1 },
484 { "SynLearned", 14, 1 },
485 { "SetDelEntry", 13, 1 },
486 { "SetInvEntry", 12, 1 },
487 { "CpcmdDvld", 11, 1 },
488 { "CpcmdSave", 10, 1 },
489 { "RxPstructsFull", 8, 2 },
490 { "EpcmdDvld", 7, 1 },
491 { "EpcmdFlush", 6, 1 },
492 { "EpcmdTrimPrefix", 5, 1 },
493 { "EpcmdTrimPostfix", 4, 1 },
494 { "ERssIp4Pkt", 3, 1 },
495 { "ERssIp6Pkt", 2, 1 },
496 { "ERssTcpUdpPkt", 1, 1 },
497 { "ERssFceFipPkt", 0, 1 },
504 field_desc_show(seq
, p
[0], tp_la0
);
505 if (idx
< (TPLA_SIZE
/ 2 - 1) || p
[1] != ~0ULL)
506 field_desc_show(seq
, p
[1], (p
[0] & BIT(17)) ? tp_la2
: tp_la1
);
510 static int tp_la_open(struct inode
*inode
, struct file
*file
)
513 struct adapter
*adap
= inode
->i_private
;
515 switch (DBGLAMODE_G(t4_read_reg(adap
, TP_DBG_LA_CONFIG_A
))) {
517 p
= seq_open_tab(file
, TPLA_SIZE
/ 2, 2 * sizeof(u64
), 0,
521 p
= seq_open_tab(file
, TPLA_SIZE
/ 2, 2 * sizeof(u64
), 0,
525 p
= seq_open_tab(file
, TPLA_SIZE
, sizeof(u64
), 0, tp_la_show
);
530 t4_tp_read_la(adap
, (u64
*)p
->data
, NULL
);
534 static ssize_t
tp_la_write(struct file
*file
, const char __user
*buf
,
535 size_t count
, loff_t
*pos
)
540 size_t size
= min(sizeof(s
) - 1, count
);
541 struct adapter
*adap
= FILE_DATA(file
)->i_private
;
543 if (copy_from_user(s
, buf
, size
))
546 err
= kstrtoul(s
, 0, &val
);
551 adap
->params
.tp
.la_mask
= val
<< 16;
552 t4_set_reg_field(adap
, TP_DBG_LA_CONFIG_A
, 0xffff0000U
,
553 adap
->params
.tp
.la_mask
);
557 static const struct file_operations tp_la_fops
= {
558 .owner
= THIS_MODULE
,
562 .release
= seq_release_private
,
566 static int ulprx_la_show(struct seq_file
*seq
, void *v
, int idx
)
570 if (v
== SEQ_START_TOKEN
)
571 seq_puts(seq
, " Pcmd Type Message"
574 seq_printf(seq
, "%08x%08x %4x %08x %08x%08x%08x%08x\n",
575 p
[1], p
[0], p
[2], p
[3], p
[7], p
[6], p
[5], p
[4]);
579 static int ulprx_la_open(struct inode
*inode
, struct file
*file
)
582 struct adapter
*adap
= inode
->i_private
;
584 p
= seq_open_tab(file
, ULPRX_LA_SIZE
, 8 * sizeof(u32
), 1,
589 t4_ulprx_read_la(adap
, (u32
*)p
->data
);
593 static const struct file_operations ulprx_la_fops
= {
594 .owner
= THIS_MODULE
,
595 .open
= ulprx_la_open
,
598 .release
= seq_release_private
601 /* Show the PM memory stats. These stats include:
604 * Read: memory read operation
605 * Write Bypass: cut-through
606 * Bypass + mem: cut-through and save copy
610 * Write Bypass: cut-through
611 * Flush: payload trim or drop
613 static int pm_stats_show(struct seq_file
*seq
, void *v
)
615 static const char * const tx_pm_stats
[] = {
616 "Read:", "Write bypass:", "Write mem:", "Bypass + mem:"
618 static const char * const rx_pm_stats
[] = {
619 "Read:", "Write bypass:", "Write mem:", "Flush:"
623 u32 tx_cnt
[PM_NSTATS
], rx_cnt
[PM_NSTATS
];
624 u64 tx_cyc
[PM_NSTATS
], rx_cyc
[PM_NSTATS
];
625 struct adapter
*adap
= seq
->private;
627 t4_pmtx_get_stats(adap
, tx_cnt
, tx_cyc
);
628 t4_pmrx_get_stats(adap
, rx_cnt
, rx_cyc
);
630 seq_printf(seq
, "%13s %10s %20s\n", " ", "Tx pcmds", "Tx bytes");
631 for (i
= 0; i
< PM_NSTATS
- 1; i
++)
632 seq_printf(seq
, "%-13s %10u %20llu\n",
633 tx_pm_stats
[i
], tx_cnt
[i
], tx_cyc
[i
]);
635 seq_printf(seq
, "%13s %10s %20s\n", " ", "Rx pcmds", "Rx bytes");
636 for (i
= 0; i
< PM_NSTATS
- 1; i
++)
637 seq_printf(seq
, "%-13s %10u %20llu\n",
638 rx_pm_stats
[i
], rx_cnt
[i
], rx_cyc
[i
]);
642 static int pm_stats_open(struct inode
*inode
, struct file
*file
)
644 return single_open(file
, pm_stats_show
, inode
->i_private
);
647 static ssize_t
pm_stats_clear(struct file
*file
, const char __user
*buf
,
648 size_t count
, loff_t
*pos
)
650 struct adapter
*adap
= FILE_DATA(file
)->i_private
;
652 t4_write_reg(adap
, PM_RX_STAT_CONFIG_A
, 0);
653 t4_write_reg(adap
, PM_TX_STAT_CONFIG_A
, 0);
657 static const struct file_operations pm_stats_debugfs_fops
= {
658 .owner
= THIS_MODULE
,
659 .open
= pm_stats_open
,
662 .release
= single_release
,
663 .write
= pm_stats_clear
666 static int cctrl_tbl_show(struct seq_file
*seq
, void *v
)
668 static const char * const dec_fac
[] = {
669 "0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875",
673 u16 incr
[NMTUS
][NCCTRL_WIN
];
674 struct adapter
*adap
= seq
->private;
676 t4_read_cong_tbl(adap
, incr
);
678 for (i
= 0; i
< NCCTRL_WIN
; ++i
) {
679 seq_printf(seq
, "%2d: %4u %4u %4u %4u %4u %4u %4u %4u\n", i
,
680 incr
[0][i
], incr
[1][i
], incr
[2][i
], incr
[3][i
],
681 incr
[4][i
], incr
[5][i
], incr
[6][i
], incr
[7][i
]);
682 seq_printf(seq
, "%8u %4u %4u %4u %4u %4u %4u %4u %5u %s\n",
683 incr
[8][i
], incr
[9][i
], incr
[10][i
], incr
[11][i
],
684 incr
[12][i
], incr
[13][i
], incr
[14][i
], incr
[15][i
],
685 adap
->params
.a_wnd
[i
],
686 dec_fac
[adap
->params
.b_wnd
[i
]]);
691 DEFINE_SIMPLE_DEBUGFS_FILE(cctrl_tbl
);
693 /* Format a value in a unit that differs from the value's native unit by the
696 static char *unit_conv(char *buf
, size_t len
, unsigned int val
,
699 unsigned int rem
= val
% factor
;
702 snprintf(buf
, len
, "%u", val
/ factor
);
704 while (rem
% 10 == 0)
706 snprintf(buf
, len
, "%u.%u", val
/ factor
, rem
);
711 static int clk_show(struct seq_file
*seq
, void *v
)
714 struct adapter
*adap
= seq
->private;
715 unsigned int cclk_ps
= 1000000000 / adap
->params
.vpd
.cclk
; /* in ps */
716 u32 res
= t4_read_reg(adap
, TP_TIMER_RESOLUTION_A
);
717 unsigned int tre
= TIMERRESOLUTION_G(res
);
718 unsigned int dack_re
= DELAYEDACKRESOLUTION_G(res
);
719 unsigned long long tp_tick_us
= (cclk_ps
<< tre
) / 1000000; /* in us */
721 seq_printf(seq
, "Core clock period: %s ns\n",
722 unit_conv(buf
, sizeof(buf
), cclk_ps
, 1000));
723 seq_printf(seq
, "TP timer tick: %s us\n",
724 unit_conv(buf
, sizeof(buf
), (cclk_ps
<< tre
), 1000000));
725 seq_printf(seq
, "TCP timestamp tick: %s us\n",
726 unit_conv(buf
, sizeof(buf
),
727 (cclk_ps
<< TIMESTAMPRESOLUTION_G(res
)), 1000000));
728 seq_printf(seq
, "DACK tick: %s us\n",
729 unit_conv(buf
, sizeof(buf
), (cclk_ps
<< dack_re
), 1000000));
730 seq_printf(seq
, "DACK timer: %u us\n",
731 ((cclk_ps
<< dack_re
) / 1000000) *
732 t4_read_reg(adap
, TP_DACK_TIMER_A
));
733 seq_printf(seq
, "Retransmit min: %llu us\n",
734 tp_tick_us
* t4_read_reg(adap
, TP_RXT_MIN_A
));
735 seq_printf(seq
, "Retransmit max: %llu us\n",
736 tp_tick_us
* t4_read_reg(adap
, TP_RXT_MAX_A
));
737 seq_printf(seq
, "Persist timer min: %llu us\n",
738 tp_tick_us
* t4_read_reg(adap
, TP_PERS_MIN_A
));
739 seq_printf(seq
, "Persist timer max: %llu us\n",
740 tp_tick_us
* t4_read_reg(adap
, TP_PERS_MAX_A
));
741 seq_printf(seq
, "Keepalive idle timer: %llu us\n",
742 tp_tick_us
* t4_read_reg(adap
, TP_KEEP_IDLE_A
));
743 seq_printf(seq
, "Keepalive interval: %llu us\n",
744 tp_tick_us
* t4_read_reg(adap
, TP_KEEP_INTVL_A
));
745 seq_printf(seq
, "Initial SRTT: %llu us\n",
746 tp_tick_us
* INITSRTT_G(t4_read_reg(adap
, TP_INIT_SRTT_A
)));
747 seq_printf(seq
, "FINWAIT2 timer: %llu us\n",
748 tp_tick_us
* t4_read_reg(adap
, TP_FINWAIT2_TIMER_A
));
753 DEFINE_SIMPLE_DEBUGFS_FILE(clk
);
755 /* Firmware Device Log dump. */
756 static const char * const devlog_level_strings
[] = {
757 [FW_DEVLOG_LEVEL_EMERG
] = "EMERG",
758 [FW_DEVLOG_LEVEL_CRIT
] = "CRIT",
759 [FW_DEVLOG_LEVEL_ERR
] = "ERR",
760 [FW_DEVLOG_LEVEL_NOTICE
] = "NOTICE",
761 [FW_DEVLOG_LEVEL_INFO
] = "INFO",
762 [FW_DEVLOG_LEVEL_DEBUG
] = "DEBUG"
765 static const char * const devlog_facility_strings
[] = {
766 [FW_DEVLOG_FACILITY_CORE
] = "CORE",
767 [FW_DEVLOG_FACILITY_SCHED
] = "SCHED",
768 [FW_DEVLOG_FACILITY_TIMER
] = "TIMER",
769 [FW_DEVLOG_FACILITY_RES
] = "RES",
770 [FW_DEVLOG_FACILITY_HW
] = "HW",
771 [FW_DEVLOG_FACILITY_FLR
] = "FLR",
772 [FW_DEVLOG_FACILITY_DMAQ
] = "DMAQ",
773 [FW_DEVLOG_FACILITY_PHY
] = "PHY",
774 [FW_DEVLOG_FACILITY_MAC
] = "MAC",
775 [FW_DEVLOG_FACILITY_PORT
] = "PORT",
776 [FW_DEVLOG_FACILITY_VI
] = "VI",
777 [FW_DEVLOG_FACILITY_FILTER
] = "FILTER",
778 [FW_DEVLOG_FACILITY_ACL
] = "ACL",
779 [FW_DEVLOG_FACILITY_TM
] = "TM",
780 [FW_DEVLOG_FACILITY_QFC
] = "QFC",
781 [FW_DEVLOG_FACILITY_DCB
] = "DCB",
782 [FW_DEVLOG_FACILITY_ETH
] = "ETH",
783 [FW_DEVLOG_FACILITY_OFLD
] = "OFLD",
784 [FW_DEVLOG_FACILITY_RI
] = "RI",
785 [FW_DEVLOG_FACILITY_ISCSI
] = "ISCSI",
786 [FW_DEVLOG_FACILITY_FCOE
] = "FCOE",
787 [FW_DEVLOG_FACILITY_FOISCSI
] = "FOISCSI",
788 [FW_DEVLOG_FACILITY_FOFCOE
] = "FOFCOE"
791 /* Information gathered by Device Log Open routine for the display routine.
794 unsigned int nentries
; /* number of entries in log[] */
795 unsigned int first
; /* first [temporal] entry in log[] */
796 struct fw_devlog_e log
[0]; /* Firmware Device Log */
799 /* Dump a Firmaware Device Log entry.
801 static int devlog_show(struct seq_file
*seq
, void *v
)
803 if (v
== SEQ_START_TOKEN
)
804 seq_printf(seq
, "%10s %15s %8s %8s %s\n",
805 "Seq#", "Tstamp", "Level", "Facility", "Message");
807 struct devlog_info
*dinfo
= seq
->private;
808 int fidx
= (uintptr_t)v
- 2;
810 struct fw_devlog_e
*e
;
812 /* Get a pointer to the log entry to display. Skip unused log
815 index
= dinfo
->first
+ fidx
;
816 if (index
>= dinfo
->nentries
)
817 index
-= dinfo
->nentries
;
818 e
= &dinfo
->log
[index
];
819 if (e
->timestamp
== 0)
822 /* Print the message. This depends on the firmware using
823 * exactly the same formating strings as the kernel so we may
824 * eventually have to put a format interpreter in here ...
826 seq_printf(seq
, "%10d %15llu %8s %8s ",
827 e
->seqno
, e
->timestamp
,
828 (e
->level
< ARRAY_SIZE(devlog_level_strings
)
829 ? devlog_level_strings
[e
->level
]
831 (e
->facility
< ARRAY_SIZE(devlog_facility_strings
)
832 ? devlog_facility_strings
[e
->facility
]
834 seq_printf(seq
, e
->fmt
, e
->params
[0], e
->params
[1],
835 e
->params
[2], e
->params
[3], e
->params
[4],
836 e
->params
[5], e
->params
[6], e
->params
[7]);
841 /* Sequential File Operations for Device Log.
843 static inline void *devlog_get_idx(struct devlog_info
*dinfo
, loff_t pos
)
845 if (pos
> dinfo
->nentries
)
848 return (void *)(uintptr_t)(pos
+ 1);
851 static void *devlog_start(struct seq_file
*seq
, loff_t
*pos
)
853 struct devlog_info
*dinfo
= seq
->private;
856 ? devlog_get_idx(dinfo
, *pos
)
860 static void *devlog_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
862 struct devlog_info
*dinfo
= seq
->private;
865 return devlog_get_idx(dinfo
, *pos
);
868 static void devlog_stop(struct seq_file
*seq
, void *v
)
872 static const struct seq_operations devlog_seq_ops
= {
873 .start
= devlog_start
,
879 /* Set up for reading the firmware's device log. We read the entire log here
880 * and then display it incrementally in devlog_show().
882 static int devlog_open(struct inode
*inode
, struct file
*file
)
884 struct adapter
*adap
= inode
->i_private
;
885 struct devlog_params
*dparams
= &adap
->params
.devlog
;
886 struct devlog_info
*dinfo
;
891 /* If we don't know where the log is we can't do anything.
893 if (dparams
->start
== 0)
896 /* Allocate the space to read in the firmware's device log and set up
897 * for the iterated call to our display function.
899 dinfo
= __seq_open_private(file
, &devlog_seq_ops
,
900 sizeof(*dinfo
) + dparams
->size
);
904 /* Record the basic log buffer information and read in the raw log.
906 dinfo
->nentries
= (dparams
->size
/ sizeof(struct fw_devlog_e
));
908 spin_lock(&adap
->win0_lock
);
909 ret
= t4_memory_rw(adap
, adap
->params
.drv_memwin
, dparams
->memtype
,
910 dparams
->start
, dparams
->size
, (__be32
*)dinfo
->log
,
912 spin_unlock(&adap
->win0_lock
);
914 seq_release_private(inode
, file
);
918 /* Translate log multi-byte integral elements into host native format
919 * and determine where the first entry in the log is.
921 for (fseqno
= ~((u32
)0), index
= 0; index
< dinfo
->nentries
; index
++) {
922 struct fw_devlog_e
*e
= &dinfo
->log
[index
];
926 if (e
->timestamp
== 0)
929 e
->timestamp
= (__force __be64
)be64_to_cpu(e
->timestamp
);
930 seqno
= be32_to_cpu(e
->seqno
);
931 for (i
= 0; i
< 8; i
++)
933 (__force __be32
)be32_to_cpu(e
->params
[i
]);
935 if (seqno
< fseqno
) {
937 dinfo
->first
= index
;
943 static const struct file_operations devlog_fops
= {
944 .owner
= THIS_MODULE
,
948 .release
= seq_release_private
951 static int mbox_show(struct seq_file
*seq
, void *v
)
953 static const char * const owner
[] = { "none", "FW", "driver",
957 unsigned int mbox
= (uintptr_t)seq
->private & 7;
958 struct adapter
*adap
= seq
->private - mbox
;
959 void __iomem
*addr
= adap
->regs
+ PF_REG(mbox
, CIM_PF_MAILBOX_DATA_A
);
960 unsigned int ctrl_reg
= (is_t4(adap
->params
.chip
)
961 ? CIM_PF_MAILBOX_CTRL_A
962 : CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A
);
963 void __iomem
*ctrl
= adap
->regs
+ PF_REG(mbox
, ctrl_reg
);
965 i
= MBOWNER_G(readl(ctrl
));
966 seq_printf(seq
, "mailbox owned by %s\n\n", owner
[i
]);
968 for (i
= 0; i
< MBOX_LEN
; i
+= 8)
969 seq_printf(seq
, "%016llx\n",
970 (unsigned long long)readq(addr
+ i
));
974 static int mbox_open(struct inode
*inode
, struct file
*file
)
976 return single_open(file
, mbox_show
, inode
->i_private
);
979 static ssize_t
mbox_write(struct file
*file
, const char __user
*buf
,
980 size_t count
, loff_t
*pos
)
983 char c
= '\n', s
[256];
984 unsigned long long data
[8];
985 const struct inode
*ino
;
987 struct adapter
*adap
;
991 if (count
> sizeof(s
) - 1 || !count
)
993 if (copy_from_user(s
, buf
, count
))
997 if (sscanf(s
, "%llx %llx %llx %llx %llx %llx %llx %llx%c", &data
[0],
998 &data
[1], &data
[2], &data
[3], &data
[4], &data
[5], &data
[6],
999 &data
[7], &c
) < 8 || c
!= '\n')
1002 ino
= FILE_DATA(file
);
1003 mbox
= (uintptr_t)ino
->i_private
& 7;
1004 adap
= ino
->i_private
- mbox
;
1005 addr
= adap
->regs
+ PF_REG(mbox
, CIM_PF_MAILBOX_DATA_A
);
1006 ctrl
= addr
+ MBOX_LEN
;
1008 if (MBOWNER_G(readl(ctrl
)) != X_MBOWNER_PL
)
1011 for (i
= 0; i
< 8; i
++)
1012 writeq(data
[i
], addr
+ 8 * i
);
1014 writel(MBMSGVALID_F
| MBOWNER_V(X_MBOWNER_FW
), ctrl
);
1018 static const struct file_operations mbox_debugfs_fops
= {
1019 .owner
= THIS_MODULE
,
1022 .llseek
= seq_lseek
,
1023 .release
= single_release
,
1027 static ssize_t
flash_read(struct file
*file
, char __user
*buf
, size_t count
,
1031 loff_t avail
= FILE_DATA(file
)->i_size
;
1032 struct adapter
*adap
= file
->private_data
;
1038 if (count
> avail
- pos
)
1039 count
= avail
- pos
;
1047 len
= min(count
+ ofst
, sizeof(data
));
1048 ret
= t4_read_flash(adap
, pos
- ofst
, (len
+ 3) / 4,
1054 if (copy_to_user(buf
, data
+ ofst
, len
))
1061 count
= pos
- *ppos
;
1066 static const struct file_operations flash_debugfs_fops
= {
1067 .owner
= THIS_MODULE
,
1072 static inline void tcamxy2valmask(u64 x
, u64 y
, u8
*addr
, u64
*mask
)
1075 y
= (__force u64
)cpu_to_be64(y
);
1076 memcpy(addr
, (char *)&y
+ 2, ETH_ALEN
);
1079 static int mps_tcam_show(struct seq_file
*seq
, void *v
)
1081 if (v
== SEQ_START_TOKEN
)
1082 seq_puts(seq
, "Idx Ethernet address Mask Vld Ports PF"
1084 "P0 P1 P2 P3 ML\n");
1088 struct adapter
*adap
= seq
->private;
1089 unsigned int idx
= (uintptr_t)v
- 2;
1090 u64 tcamy
= t4_read_reg64(adap
, MPS_CLS_TCAM_Y_L(idx
));
1091 u64 tcamx
= t4_read_reg64(adap
, MPS_CLS_TCAM_X_L(idx
));
1092 u32 cls_lo
= t4_read_reg(adap
, MPS_CLS_SRAM_L(idx
));
1093 u32 cls_hi
= t4_read_reg(adap
, MPS_CLS_SRAM_H(idx
));
1094 u32 rplc
[4] = {0, 0, 0, 0};
1096 if (tcamx
& tcamy
) {
1097 seq_printf(seq
, "%3u -\n", idx
);
1101 if (cls_lo
& REPLICATE_F
) {
1102 struct fw_ldst_cmd ldst_cmd
;
1105 memset(&ldst_cmd
, 0, sizeof(ldst_cmd
));
1106 ldst_cmd
.op_to_addrspace
=
1107 htonl(FW_CMD_OP_V(FW_LDST_CMD
) |
1110 FW_LDST_CMD_ADDRSPACE_V(
1111 FW_LDST_ADDRSPC_MPS
));
1112 ldst_cmd
.cycles_to_len16
= htonl(FW_LEN16(ldst_cmd
));
1113 ldst_cmd
.u
.mps
.fid_ctl
=
1114 htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC
) |
1115 FW_LDST_CMD_CTL_V(idx
));
1116 ret
= t4_wr_mbox(adap
, adap
->mbox
, &ldst_cmd
,
1117 sizeof(ldst_cmd
), &ldst_cmd
);
1119 dev_warn(adap
->pdev_dev
, "Can't read MPS "
1120 "replication map for idx %d: %d\n",
1123 rplc
[0] = ntohl(ldst_cmd
.u
.mps
.rplc31_0
);
1124 rplc
[1] = ntohl(ldst_cmd
.u
.mps
.rplc63_32
);
1125 rplc
[2] = ntohl(ldst_cmd
.u
.mps
.rplc95_64
);
1126 rplc
[3] = ntohl(ldst_cmd
.u
.mps
.rplc127_96
);
1130 tcamxy2valmask(tcamx
, tcamy
, addr
, &mask
);
1131 seq_printf(seq
, "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx"
1133 idx
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4],
1134 addr
[5], (unsigned long long)mask
,
1135 (cls_lo
& SRAM_VLD_F
) ? 'Y' : 'N', PORTMAP_G(cls_hi
),
1137 (cls_lo
& VF_VALID_F
) ? VF_G(cls_lo
) : -1);
1138 if (cls_lo
& REPLICATE_F
)
1139 seq_printf(seq
, " %08x %08x %08x %08x",
1140 rplc
[3], rplc
[2], rplc
[1], rplc
[0]);
1142 seq_printf(seq
, "%36c", ' ');
1143 seq_printf(seq
, "%4u%3u%3u%3u %#x\n",
1144 SRAM_PRIO0_G(cls_lo
), SRAM_PRIO1_G(cls_lo
),
1145 SRAM_PRIO2_G(cls_lo
), SRAM_PRIO3_G(cls_lo
),
1146 (cls_lo
>> MULTILISTEN0_S
) & 0xf);
1151 static inline void *mps_tcam_get_idx(struct seq_file
*seq
, loff_t pos
)
1153 struct adapter
*adap
= seq
->private;
1154 int max_mac_addr
= is_t4(adap
->params
.chip
) ?
1155 NUM_MPS_CLS_SRAM_L_INSTANCES
:
1156 NUM_MPS_T5_CLS_SRAM_L_INSTANCES
;
1157 return ((pos
<= max_mac_addr
) ? (void *)(uintptr_t)(pos
+ 1) : NULL
);
1160 static void *mps_tcam_start(struct seq_file
*seq
, loff_t
*pos
)
1162 return *pos
? mps_tcam_get_idx(seq
, *pos
) : SEQ_START_TOKEN
;
1165 static void *mps_tcam_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
1168 return mps_tcam_get_idx(seq
, *pos
);
1171 static void mps_tcam_stop(struct seq_file
*seq
, void *v
)
1175 static const struct seq_operations mps_tcam_seq_ops
= {
1176 .start
= mps_tcam_start
,
1177 .next
= mps_tcam_next
,
1178 .stop
= mps_tcam_stop
,
1179 .show
= mps_tcam_show
1182 static int mps_tcam_open(struct inode
*inode
, struct file
*file
)
1184 int res
= seq_open(file
, &mps_tcam_seq_ops
);
1187 struct seq_file
*seq
= file
->private_data
;
1189 seq
->private = inode
->i_private
;
1194 static const struct file_operations mps_tcam_debugfs_fops
= {
1195 .owner
= THIS_MODULE
,
1196 .open
= mps_tcam_open
,
1198 .llseek
= seq_lseek
,
1199 .release
= seq_release
,
1202 /* Display various sensor information.
1204 static int sensors_show(struct seq_file
*seq
, void *v
)
1206 struct adapter
*adap
= seq
->private;
1207 u32 param
[7], val
[7];
1210 /* Note that if the sensors haven't been initialized and turned on
1211 * we'll get values of 0, so treat those as "<unknown>" ...
1213 param
[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV
) |
1214 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG
) |
1215 FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_TMP
));
1216 param
[1] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV
) |
1217 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG
) |
1218 FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_VDD
));
1219 ret
= t4_query_params(adap
, adap
->mbox
, adap
->fn
, 0, 2,
1222 if (ret
< 0 || val
[0] == 0)
1223 seq_puts(seq
, "Temperature: <unknown>\n");
1225 seq_printf(seq
, "Temperature: %dC\n", val
[0]);
1227 if (ret
< 0 || val
[1] == 0)
1228 seq_puts(seq
, "Core VDD: <unknown>\n");
1230 seq_printf(seq
, "Core VDD: %dmV\n", val
[1]);
1235 DEFINE_SIMPLE_DEBUGFS_FILE(sensors
);
1237 #if IS_ENABLED(CONFIG_IPV6)
1238 static int clip_tbl_open(struct inode
*inode
, struct file
*file
)
1240 return single_open(file
, clip_tbl_show
, inode
->i_private
);
1243 static const struct file_operations clip_tbl_debugfs_fops
= {
1244 .owner
= THIS_MODULE
,
1245 .open
= clip_tbl_open
,
1247 .llseek
= seq_lseek
,
1248 .release
= single_release
1255 static int rss_show(struct seq_file
*seq
, void *v
, int idx
)
1259 seq_printf(seq
, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
1260 idx
* 8, entry
[0], entry
[1], entry
[2], entry
[3], entry
[4],
1261 entry
[5], entry
[6], entry
[7]);
1265 static int rss_open(struct inode
*inode
, struct file
*file
)
1269 struct adapter
*adap
= inode
->i_private
;
1271 p
= seq_open_tab(file
, RSS_NENTRIES
/ 8, 8 * sizeof(u16
), 0, rss_show
);
1275 ret
= t4_read_rss(adap
, (u16
*)p
->data
);
1277 seq_release_private(inode
, file
);
1282 static const struct file_operations rss_debugfs_fops
= {
1283 .owner
= THIS_MODULE
,
1286 .llseek
= seq_lseek
,
1287 .release
= seq_release_private
1290 /* RSS Configuration.
1293 /* Small utility function to return the strings "yes" or "no" if the supplied
1294 * argument is non-zero.
1296 static const char *yesno(int x
)
1298 static const char *yes
= "yes";
1299 static const char *no
= "no";
1301 return x
? yes
: no
;
1304 static int rss_config_show(struct seq_file
*seq
, void *v
)
1306 struct adapter
*adapter
= seq
->private;
1307 static const char * const keymode
[] = {
1309 "global and per-VF scramble",
1310 "per-PF and per-VF scramble",
1311 "per-VF and per-VF scramble",
1315 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_A
);
1316 seq_printf(seq
, "TP_RSS_CONFIG: %#x\n", rssconf
);
1317 seq_printf(seq
, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf
&
1319 seq_printf(seq
, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf
&
1321 seq_printf(seq
, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf
&
1323 seq_printf(seq
, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf
&
1325 seq_printf(seq
, " TnlTcpSel: %3s\n", yesno(rssconf
& TNLTCPSEL_F
));
1326 seq_printf(seq
, " TnlIp6Sel: %3s\n", yesno(rssconf
& TNLIP6SEL_F
));
1327 seq_printf(seq
, " TnlVrtSel: %3s\n", yesno(rssconf
& TNLVRTSEL_F
));
1328 seq_printf(seq
, " TnlMapEn: %3s\n", yesno(rssconf
& TNLMAPEN_F
));
1329 seq_printf(seq
, " OfdHashSave: %3s\n", yesno(rssconf
&
1331 seq_printf(seq
, " OfdVrtSel: %3s\n", yesno(rssconf
& OFDVRTSEL_F
));
1332 seq_printf(seq
, " OfdMapEn: %3s\n", yesno(rssconf
& OFDMAPEN_F
));
1333 seq_printf(seq
, " OfdLkpEn: %3s\n", yesno(rssconf
& OFDLKPEN_F
));
1334 seq_printf(seq
, " Syn4TupEnIpv6: %3s\n", yesno(rssconf
&
1336 seq_printf(seq
, " Syn2TupEnIpv6: %3s\n", yesno(rssconf
&
1338 seq_printf(seq
, " Syn4TupEnIpv4: %3s\n", yesno(rssconf
&
1340 seq_printf(seq
, " Syn2TupEnIpv4: %3s\n", yesno(rssconf
&
1342 seq_printf(seq
, " Syn4TupEnIpv6: %3s\n", yesno(rssconf
&
1344 seq_printf(seq
, " SynIp6Sel: %3s\n", yesno(rssconf
& SYNIP6SEL_F
));
1345 seq_printf(seq
, " SynVrt6Sel: %3s\n", yesno(rssconf
& SYNVRTSEL_F
));
1346 seq_printf(seq
, " SynMapEn: %3s\n", yesno(rssconf
& SYNMAPEN_F
));
1347 seq_printf(seq
, " SynLkpEn: %3s\n", yesno(rssconf
& SYNLKPEN_F
));
1348 seq_printf(seq
, " ChnEn: %3s\n", yesno(rssconf
&
1350 seq_printf(seq
, " PrtEn: %3s\n", yesno(rssconf
&
1352 seq_printf(seq
, " TnlAllLkp: %3s\n", yesno(rssconf
&
1354 seq_printf(seq
, " VrtEn: %3s\n", yesno(rssconf
&
1356 seq_printf(seq
, " CngEn: %3s\n", yesno(rssconf
&
1357 CONGESTIONENABLE_F
));
1358 seq_printf(seq
, " HashToeplitz: %3s\n", yesno(rssconf
&
1360 seq_printf(seq
, " Udp4En: %3s\n", yesno(rssconf
& UDPENABLE_F
));
1361 seq_printf(seq
, " Disable: %3s\n", yesno(rssconf
& DISABLE_F
));
1363 seq_puts(seq
, "\n");
1365 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_TNL_A
);
1366 seq_printf(seq
, "TP_RSS_CONFIG_TNL: %#x\n", rssconf
);
1367 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
1368 seq_printf(seq
, " MaskFilter: %3d\n", MASKFILTER_G(rssconf
));
1369 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) > CHELSIO_T5
) {
1370 seq_printf(seq
, " HashAll: %3s\n",
1371 yesno(rssconf
& HASHALL_F
));
1372 seq_printf(seq
, " HashEth: %3s\n",
1373 yesno(rssconf
& HASHETH_F
));
1375 seq_printf(seq
, " UseWireCh: %3s\n", yesno(rssconf
& USEWIRECH_F
));
1377 seq_puts(seq
, "\n");
1379 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_OFD_A
);
1380 seq_printf(seq
, "TP_RSS_CONFIG_OFD: %#x\n", rssconf
);
1381 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
1382 seq_printf(seq
, " RRCplMapEn: %3s\n", yesno(rssconf
&
1384 seq_printf(seq
, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf
));
1386 seq_puts(seq
, "\n");
1388 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_SYN_A
);
1389 seq_printf(seq
, "TP_RSS_CONFIG_SYN: %#x\n", rssconf
);
1390 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
1391 seq_printf(seq
, " UseWireCh: %3s\n", yesno(rssconf
& USEWIRECH_F
));
1393 seq_puts(seq
, "\n");
1395 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_VRT_A
);
1396 seq_printf(seq
, "TP_RSS_CONFIG_VRT: %#x\n", rssconf
);
1397 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) > CHELSIO_T5
) {
1398 seq_printf(seq
, " KeyWrAddrX: %3d\n",
1399 KEYWRADDRX_G(rssconf
));
1400 seq_printf(seq
, " KeyExtend: %3s\n",
1401 yesno(rssconf
& KEYEXTEND_F
));
1403 seq_printf(seq
, " VfRdRg: %3s\n", yesno(rssconf
& VFRDRG_F
));
1404 seq_printf(seq
, " VfRdEn: %3s\n", yesno(rssconf
& VFRDEN_F
));
1405 seq_printf(seq
, " VfPerrEn: %3s\n", yesno(rssconf
& VFPERREN_F
));
1406 seq_printf(seq
, " KeyPerrEn: %3s\n", yesno(rssconf
& KEYPERREN_F
));
1407 seq_printf(seq
, " DisVfVlan: %3s\n", yesno(rssconf
&
1409 seq_printf(seq
, " EnUpSwt: %3s\n", yesno(rssconf
& ENABLEUP0_F
));
1410 seq_printf(seq
, " HashDelay: %3d\n", HASHDELAY_G(rssconf
));
1411 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) <= CHELSIO_T5
)
1412 seq_printf(seq
, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf
));
1413 seq_printf(seq
, " KeyMode: %s\n", keymode
[KEYMODE_G(rssconf
)]);
1414 seq_printf(seq
, " VfWrEn: %3s\n", yesno(rssconf
& VFWREN_F
));
1415 seq_printf(seq
, " KeyWrEn: %3s\n", yesno(rssconf
& KEYWREN_F
));
1416 seq_printf(seq
, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf
));
1418 seq_puts(seq
, "\n");
1420 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_CNG_A
);
1421 seq_printf(seq
, "TP_RSS_CONFIG_CNG: %#x\n", rssconf
);
1422 seq_printf(seq
, " ChnCount3: %3s\n", yesno(rssconf
& CHNCOUNT3_F
));
1423 seq_printf(seq
, " ChnCount2: %3s\n", yesno(rssconf
& CHNCOUNT2_F
));
1424 seq_printf(seq
, " ChnCount1: %3s\n", yesno(rssconf
& CHNCOUNT1_F
));
1425 seq_printf(seq
, " ChnCount0: %3s\n", yesno(rssconf
& CHNCOUNT0_F
));
1426 seq_printf(seq
, " ChnUndFlow3: %3s\n", yesno(rssconf
&
1428 seq_printf(seq
, " ChnUndFlow2: %3s\n", yesno(rssconf
&
1430 seq_printf(seq
, " ChnUndFlow1: %3s\n", yesno(rssconf
&
1432 seq_printf(seq
, " ChnUndFlow0: %3s\n", yesno(rssconf
&
1434 seq_printf(seq
, " RstChn3: %3s\n", yesno(rssconf
& RSTCHN3_F
));
1435 seq_printf(seq
, " RstChn2: %3s\n", yesno(rssconf
& RSTCHN2_F
));
1436 seq_printf(seq
, " RstChn1: %3s\n", yesno(rssconf
& RSTCHN1_F
));
1437 seq_printf(seq
, " RstChn0: %3s\n", yesno(rssconf
& RSTCHN0_F
));
1438 seq_printf(seq
, " UpdVld: %3s\n", yesno(rssconf
& UPDVLD_F
));
1439 seq_printf(seq
, " Xoff: %3s\n", yesno(rssconf
& XOFF_F
));
1440 seq_printf(seq
, " UpdChn3: %3s\n", yesno(rssconf
& UPDCHN3_F
));
1441 seq_printf(seq
, " UpdChn2: %3s\n", yesno(rssconf
& UPDCHN2_F
));
1442 seq_printf(seq
, " UpdChn1: %3s\n", yesno(rssconf
& UPDCHN1_F
));
1443 seq_printf(seq
, " UpdChn0: %3s\n", yesno(rssconf
& UPDCHN0_F
));
1444 seq_printf(seq
, " Queue: %3d\n", QUEUE_G(rssconf
));
1449 DEFINE_SIMPLE_DEBUGFS_FILE(rss_config
);
1454 static int rss_key_show(struct seq_file
*seq
, void *v
)
1458 t4_read_rss_key(seq
->private, key
);
1459 seq_printf(seq
, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
1460 key
[9], key
[8], key
[7], key
[6], key
[5], key
[4], key
[3],
1461 key
[2], key
[1], key
[0]);
1465 static int rss_key_open(struct inode
*inode
, struct file
*file
)
1467 return single_open(file
, rss_key_show
, inode
->i_private
);
1470 static ssize_t
rss_key_write(struct file
*file
, const char __user
*buf
,
1471 size_t count
, loff_t
*pos
)
1476 struct adapter
*adap
= FILE_DATA(file
)->i_private
;
1478 if (count
> sizeof(s
) - 1)
1480 if (copy_from_user(s
, buf
, count
))
1482 for (i
= count
; i
> 0 && isspace(s
[i
- 1]); i
--)
1486 for (p
= s
, i
= 9; i
>= 0; i
--) {
1488 for (j
= 0; j
< 8; j
++, p
++) {
1491 key
[i
] = (key
[i
] << 4) | hex2val(*p
);
1495 t4_write_rss_key(adap
, key
, -1);
1499 static const struct file_operations rss_key_debugfs_fops
= {
1500 .owner
= THIS_MODULE
,
1501 .open
= rss_key_open
,
1503 .llseek
= seq_lseek
,
1504 .release
= single_release
,
1505 .write
= rss_key_write
1508 /* PF RSS Configuration.
1511 struct rss_pf_conf
{
1517 static int rss_pf_config_show(struct seq_file
*seq
, void *v
, int idx
)
1519 struct rss_pf_conf
*pfconf
;
1521 if (v
== SEQ_START_TOKEN
) {
1522 /* use the 0th entry to dump the PF Map Index Size */
1523 pfconf
= seq
->private + offsetof(struct seq_tab
, data
);
1524 seq_printf(seq
, "PF Map Index Size = %d\n\n",
1525 LKPIDXSIZE_G(pfconf
->rss_pf_map
));
1527 seq_puts(seq
, " RSS PF VF Hash Tuple Enable Default\n");
1528 seq_puts(seq
, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
1529 seq_puts(seq
, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
1531 #define G_PFnLKPIDX(map, n) \
1532 (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
1533 #define G_PFnMSKSIZE(mask, n) \
1534 (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
1537 seq_printf(seq
, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
1539 yesno(pfconf
->rss_pf_config
& MAPENABLE_F
),
1540 yesno(pfconf
->rss_pf_config
& CHNENABLE_F
),
1541 yesno(pfconf
->rss_pf_config
& PRTENABLE_F
),
1542 G_PFnLKPIDX(pfconf
->rss_pf_map
, idx
),
1543 G_PFnMSKSIZE(pfconf
->rss_pf_mask
, idx
),
1544 IVFWIDTH_G(pfconf
->rss_pf_config
),
1545 yesno(pfconf
->rss_pf_config
& IP6FOURTUPEN_F
),
1546 yesno(pfconf
->rss_pf_config
& IP6TWOTUPEN_F
),
1547 yesno(pfconf
->rss_pf_config
& IP4FOURTUPEN_F
),
1548 yesno(pfconf
->rss_pf_config
& IP4TWOTUPEN_F
),
1549 yesno(pfconf
->rss_pf_config
& UDPFOURTUPEN_F
),
1550 CH1DEFAULTQUEUE_G(pfconf
->rss_pf_config
),
1551 CH0DEFAULTQUEUE_G(pfconf
->rss_pf_config
));
1559 static int rss_pf_config_open(struct inode
*inode
, struct file
*file
)
1561 struct adapter
*adapter
= inode
->i_private
;
1563 u32 rss_pf_map
, rss_pf_mask
;
1564 struct rss_pf_conf
*pfconf
;
1567 p
= seq_open_tab(file
, 8, sizeof(*pfconf
), 1, rss_pf_config_show
);
1571 pfconf
= (struct rss_pf_conf
*)p
->data
;
1572 rss_pf_map
= t4_read_rss_pf_map(adapter
);
1573 rss_pf_mask
= t4_read_rss_pf_mask(adapter
);
1574 for (pf
= 0; pf
< 8; pf
++) {
1575 pfconf
[pf
].rss_pf_map
= rss_pf_map
;
1576 pfconf
[pf
].rss_pf_mask
= rss_pf_mask
;
1577 t4_read_rss_pf_config(adapter
, pf
, &pfconf
[pf
].rss_pf_config
);
1582 static const struct file_operations rss_pf_config_debugfs_fops
= {
1583 .owner
= THIS_MODULE
,
1584 .open
= rss_pf_config_open
,
1586 .llseek
= seq_lseek
,
1587 .release
= seq_release_private
1590 /* VF RSS Configuration.
1593 struct rss_vf_conf
{
1598 static int rss_vf_config_show(struct seq_file
*seq
, void *v
, int idx
)
1600 if (v
== SEQ_START_TOKEN
) {
1601 seq_puts(seq
, " RSS Hash Tuple Enable\n");
1602 seq_puts(seq
, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
1603 seq_puts(seq
, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
1605 struct rss_vf_conf
*vfconf
= v
;
1607 seq_printf(seq
, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
1609 yesno(vfconf
->rss_vf_vfh
& VFCHNEN_F
),
1610 yesno(vfconf
->rss_vf_vfh
& VFPRTEN_F
),
1611 VFLKPIDX_G(vfconf
->rss_vf_vfh
),
1612 yesno(vfconf
->rss_vf_vfh
& VFVLNEX_F
),
1613 yesno(vfconf
->rss_vf_vfh
& VFUPEN_F
),
1614 yesno(vfconf
->rss_vf_vfh
& VFIP4FOURTUPEN_F
),
1615 yesno(vfconf
->rss_vf_vfh
& VFIP6TWOTUPEN_F
),
1616 yesno(vfconf
->rss_vf_vfh
& VFIP4FOURTUPEN_F
),
1617 yesno(vfconf
->rss_vf_vfh
& VFIP4TWOTUPEN_F
),
1618 yesno(vfconf
->rss_vf_vfh
& ENABLEUDPHASH_F
),
1619 DEFAULTQUEUE_G(vfconf
->rss_vf_vfh
),
1620 KEYINDEX_G(vfconf
->rss_vf_vfh
),
1621 vfconf
->rss_vf_vfl
);
1626 static int rss_vf_config_open(struct inode
*inode
, struct file
*file
)
1628 struct adapter
*adapter
= inode
->i_private
;
1630 struct rss_vf_conf
*vfconf
;
1633 p
= seq_open_tab(file
, 128, sizeof(*vfconf
), 1, rss_vf_config_show
);
1637 vfconf
= (struct rss_vf_conf
*)p
->data
;
1638 for (vf
= 0; vf
< 128; vf
++) {
1639 t4_read_rss_vf_config(adapter
, vf
, &vfconf
[vf
].rss_vf_vfl
,
1640 &vfconf
[vf
].rss_vf_vfh
);
1645 static const struct file_operations rss_vf_config_debugfs_fops
= {
1646 .owner
= THIS_MODULE
,
1647 .open
= rss_vf_config_open
,
1649 .llseek
= seq_lseek
,
1650 .release
= seq_release_private
1654 * ethqset2pinfo - return port_info of an Ethernet Queue Set
1655 * @adap: the adapter
1656 * @qset: Ethernet Queue Set
1658 static inline struct port_info
*ethqset2pinfo(struct adapter
*adap
, int qset
)
1662 for_each_port(adap
, pidx
) {
1663 struct port_info
*pi
= adap2pinfo(adap
, pidx
);
1665 if (qset
>= pi
->first_qset
&&
1666 qset
< pi
->first_qset
+ pi
->nqsets
)
1670 /* should never happen! */
1675 static int sge_qinfo_show(struct seq_file
*seq
, void *v
)
1677 struct adapter
*adap
= seq
->private;
1678 int eth_entries
= DIV_ROUND_UP(adap
->sge
.ethqsets
, 4);
1679 int toe_entries
= DIV_ROUND_UP(adap
->sge
.ofldqsets
, 4);
1680 int rdma_entries
= DIV_ROUND_UP(adap
->sge
.rdmaqs
, 4);
1681 int ciq_entries
= DIV_ROUND_UP(adap
->sge
.rdmaciqs
, 4);
1682 int ctrl_entries
= DIV_ROUND_UP(MAX_CTRL_QUEUES
, 4);
1683 int i
, r
= (uintptr_t)v
- 1;
1684 int toe_idx
= r
- eth_entries
;
1685 int rdma_idx
= toe_idx
- toe_entries
;
1686 int ciq_idx
= rdma_idx
- rdma_entries
;
1687 int ctrl_idx
= ciq_idx
- ciq_entries
;
1688 int fq_idx
= ctrl_idx
- ctrl_entries
;
1691 seq_putc(seq
, '\n');
1693 #define S3(fmt_spec, s, v) \
1695 seq_printf(seq, "%-12s", s); \
1696 for (i = 0; i < n; ++i) \
1697 seq_printf(seq, " %16" fmt_spec, v); \
1698 seq_putc(seq, '\n'); \
1700 #define S(s, v) S3("s", s, v)
1701 #define T(s, v) S3("u", s, tx[i].v)
1702 #define R(s, v) S3("u", s, rx[i].v)
1704 if (r
< eth_entries
) {
1705 int base_qset
= r
* 4;
1706 const struct sge_eth_rxq
*rx
= &adap
->sge
.ethrxq
[base_qset
];
1707 const struct sge_eth_txq
*tx
= &adap
->sge
.ethtxq
[base_qset
];
1708 int n
= min(4, adap
->sge
.ethqsets
- 4 * r
);
1710 S("QType:", "Ethernet");
1712 rx
[i
].rspq
.netdev
? rx
[i
].rspq
.netdev
->name
: "N/A");
1713 T("TxQ ID:", q
.cntxt_id
);
1714 T("TxQ size:", q
.size
);
1715 T("TxQ inuse:", q
.in_use
);
1716 T("TxQ CIDX:", q
.cidx
);
1717 T("TxQ PIDX:", q
.pidx
);
1718 #ifdef CONFIG_CHELSIO_T4_DCB
1719 T("DCB Prio:", dcb_prio
);
1720 S3("u", "DCB PGID:",
1721 (ethqset2pinfo(adap
, base_qset
+ i
)->dcb
.pgid
>>
1722 4*(7-tx
[i
].dcb_prio
)) & 0xf);
1724 (ethqset2pinfo(adap
, base_qset
+ i
)->dcb
.pfcen
>>
1725 1*(7-tx
[i
].dcb_prio
)) & 0x1);
1727 R("RspQ ID:", rspq
.abs_id
);
1728 R("RspQ size:", rspq
.size
);
1729 R("RspQE size:", rspq
.iqe_len
);
1730 R("RspQ CIDX:", rspq
.cidx
);
1731 R("RspQ Gen:", rspq
.gen
);
1732 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1733 S3("u", "Intr pktcnt:",
1734 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1735 R("FL ID:", fl
.cntxt_id
);
1736 R("FL size:", fl
.size
- 8);
1737 R("FL pend:", fl
.pend_cred
);
1738 R("FL avail:", fl
.avail
);
1739 R("FL PIDX:", fl
.pidx
);
1740 R("FL CIDX:", fl
.cidx
);
1741 } else if (toe_idx
< toe_entries
) {
1742 const struct sge_ofld_rxq
*rx
= &adap
->sge
.ofldrxq
[toe_idx
* 4];
1743 const struct sge_ofld_txq
*tx
= &adap
->sge
.ofldtxq
[toe_idx
* 4];
1744 int n
= min(4, adap
->sge
.ofldqsets
- 4 * toe_idx
);
1747 T("TxQ ID:", q
.cntxt_id
);
1748 T("TxQ size:", q
.size
);
1749 T("TxQ inuse:", q
.in_use
);
1750 T("TxQ CIDX:", q
.cidx
);
1751 T("TxQ PIDX:", q
.pidx
);
1752 R("RspQ ID:", rspq
.abs_id
);
1753 R("RspQ size:", rspq
.size
);
1754 R("RspQE size:", rspq
.iqe_len
);
1755 R("RspQ CIDX:", rspq
.cidx
);
1756 R("RspQ Gen:", rspq
.gen
);
1757 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1758 S3("u", "Intr pktcnt:",
1759 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1760 R("FL ID:", fl
.cntxt_id
);
1761 R("FL size:", fl
.size
- 8);
1762 R("FL pend:", fl
.pend_cred
);
1763 R("FL avail:", fl
.avail
);
1764 R("FL PIDX:", fl
.pidx
);
1765 R("FL CIDX:", fl
.cidx
);
1766 } else if (rdma_idx
< rdma_entries
) {
1767 const struct sge_ofld_rxq
*rx
=
1768 &adap
->sge
.rdmarxq
[rdma_idx
* 4];
1769 int n
= min(4, adap
->sge
.rdmaqs
- 4 * rdma_idx
);
1771 S("QType:", "RDMA-CPL");
1772 R("RspQ ID:", rspq
.abs_id
);
1773 R("RspQ size:", rspq
.size
);
1774 R("RspQE size:", rspq
.iqe_len
);
1775 R("RspQ CIDX:", rspq
.cidx
);
1776 R("RspQ Gen:", rspq
.gen
);
1777 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1778 S3("u", "Intr pktcnt:",
1779 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1780 R("FL ID:", fl
.cntxt_id
);
1781 R("FL size:", fl
.size
- 8);
1782 R("FL pend:", fl
.pend_cred
);
1783 R("FL avail:", fl
.avail
);
1784 R("FL PIDX:", fl
.pidx
);
1785 R("FL CIDX:", fl
.cidx
);
1786 } else if (ciq_idx
< ciq_entries
) {
1787 const struct sge_ofld_rxq
*rx
= &adap
->sge
.rdmaciq
[ciq_idx
* 4];
1788 int n
= min(4, adap
->sge
.rdmaciqs
- 4 * ciq_idx
);
1790 S("QType:", "RDMA-CIQ");
1791 R("RspQ ID:", rspq
.abs_id
);
1792 R("RspQ size:", rspq
.size
);
1793 R("RspQE size:", rspq
.iqe_len
);
1794 R("RspQ CIDX:", rspq
.cidx
);
1795 R("RspQ Gen:", rspq
.gen
);
1796 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1797 S3("u", "Intr pktcnt:",
1798 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1799 } else if (ctrl_idx
< ctrl_entries
) {
1800 const struct sge_ctrl_txq
*tx
= &adap
->sge
.ctrlq
[ctrl_idx
* 4];
1801 int n
= min(4, adap
->params
.nports
- 4 * ctrl_idx
);
1803 S("QType:", "Control");
1804 T("TxQ ID:", q
.cntxt_id
);
1805 T("TxQ size:", q
.size
);
1806 T("TxQ inuse:", q
.in_use
);
1807 T("TxQ CIDX:", q
.cidx
);
1808 T("TxQ PIDX:", q
.pidx
);
1809 } else if (fq_idx
== 0) {
1810 const struct sge_rspq
*evtq
= &adap
->sge
.fw_evtq
;
1812 seq_printf(seq
, "%-12s %16s\n", "QType:", "FW event queue");
1813 seq_printf(seq
, "%-12s %16u\n", "RspQ ID:", evtq
->abs_id
);
1814 seq_printf(seq
, "%-12s %16u\n", "RspQ size:", evtq
->size
);
1815 seq_printf(seq
, "%-12s %16u\n", "RspQE size:", evtq
->iqe_len
);
1816 seq_printf(seq
, "%-12s %16u\n", "RspQ CIDX:", evtq
->cidx
);
1817 seq_printf(seq
, "%-12s %16u\n", "RspQ Gen:", evtq
->gen
);
1818 seq_printf(seq
, "%-12s %16u\n", "Intr delay:",
1819 qtimer_val(adap
, evtq
));
1820 seq_printf(seq
, "%-12s %16u\n", "Intr pktcnt:",
1821 adap
->sge
.counter_val
[evtq
->pktcnt_idx
]);
1830 static int sge_queue_entries(const struct adapter
*adap
)
1832 return DIV_ROUND_UP(adap
->sge
.ethqsets
, 4) +
1833 DIV_ROUND_UP(adap
->sge
.ofldqsets
, 4) +
1834 DIV_ROUND_UP(adap
->sge
.rdmaqs
, 4) +
1835 DIV_ROUND_UP(adap
->sge
.rdmaciqs
, 4) +
1836 DIV_ROUND_UP(MAX_CTRL_QUEUES
, 4) + 1;
1839 static void *sge_queue_start(struct seq_file
*seq
, loff_t
*pos
)
1841 int entries
= sge_queue_entries(seq
->private);
1843 return *pos
< entries
? (void *)((uintptr_t)*pos
+ 1) : NULL
;
1846 static void sge_queue_stop(struct seq_file
*seq
, void *v
)
1850 static void *sge_queue_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
1852 int entries
= sge_queue_entries(seq
->private);
1855 return *pos
< entries
? (void *)((uintptr_t)*pos
+ 1) : NULL
;
1858 static const struct seq_operations sge_qinfo_seq_ops
= {
1859 .start
= sge_queue_start
,
1860 .next
= sge_queue_next
,
1861 .stop
= sge_queue_stop
,
1862 .show
= sge_qinfo_show
1865 static int sge_qinfo_open(struct inode
*inode
, struct file
*file
)
1867 int res
= seq_open(file
, &sge_qinfo_seq_ops
);
1870 struct seq_file
*seq
= file
->private_data
;
1872 seq
->private = inode
->i_private
;
1877 static const struct file_operations sge_qinfo_debugfs_fops
= {
1878 .owner
= THIS_MODULE
,
1879 .open
= sge_qinfo_open
,
1881 .llseek
= seq_lseek
,
1882 .release
= seq_release
,
1885 int mem_open(struct inode
*inode
, struct file
*file
)
1888 struct adapter
*adap
;
1890 file
->private_data
= inode
->i_private
;
1892 mem
= (uintptr_t)file
->private_data
& 0x3;
1893 adap
= file
->private_data
- mem
;
1895 (void)t4_fwcache(adap
, FW_PARAM_DEV_FWCACHE_FLUSH
);
1900 static ssize_t
mem_read(struct file
*file
, char __user
*buf
, size_t count
,
1904 loff_t avail
= file_inode(file
)->i_size
;
1905 unsigned int mem
= (uintptr_t)file
->private_data
& 3;
1906 struct adapter
*adap
= file
->private_data
- mem
;
1914 if (count
> avail
- pos
)
1915 count
= avail
- pos
;
1917 data
= t4_alloc_mem(count
);
1921 spin_lock(&adap
->win0_lock
);
1922 ret
= t4_memory_rw(adap
, 0, mem
, pos
, count
, data
, T4_MEMORY_READ
);
1923 spin_unlock(&adap
->win0_lock
);
1928 ret
= copy_to_user(buf
, data
, count
);
1934 *ppos
= pos
+ count
;
1937 static const struct file_operations mem_debugfs_fops
= {
1938 .owner
= THIS_MODULE
,
1939 .open
= simple_open
,
1941 .llseek
= default_llseek
,
1944 static void set_debugfs_file_size(struct dentry
*de
, loff_t size
)
1946 if (!IS_ERR(de
) && de
->d_inode
)
1947 de
->d_inode
->i_size
= size
;
1950 static void add_debugfs_mem(struct adapter
*adap
, const char *name
,
1951 unsigned int idx
, unsigned int size_mb
)
1953 debugfs_create_file_size(name
, S_IRUSR
, adap
->debugfs_root
,
1954 (void *)adap
+ idx
, &mem_debugfs_fops
,
1958 /* Add an array of Debug FS files.
1960 void add_debugfs_files(struct adapter
*adap
,
1961 struct t4_debugfs_entry
*files
,
1962 unsigned int nfiles
)
1966 /* debugfs support is best effort */
1967 for (i
= 0; i
< nfiles
; i
++)
1968 debugfs_create_file(files
[i
].name
, files
[i
].mode
,
1970 (void *)adap
+ files
[i
].data
,
1974 int t4_setup_debugfs(struct adapter
*adap
)
1980 static struct t4_debugfs_entry t4_debugfs_files
[] = {
1981 { "cim_la", &cim_la_fops
, S_IRUSR
, 0 },
1982 { "cim_qcfg", &cim_qcfg_fops
, S_IRUSR
, 0 },
1983 { "clk", &clk_debugfs_fops
, S_IRUSR
, 0 },
1984 { "devlog", &devlog_fops
, S_IRUSR
, 0 },
1985 { "mbox0", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 0 },
1986 { "mbox1", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 1 },
1987 { "mbox2", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 2 },
1988 { "mbox3", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 3 },
1989 { "mbox4", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 4 },
1990 { "mbox5", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 5 },
1991 { "mbox6", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 6 },
1992 { "mbox7", &mbox_debugfs_fops
, S_IRUSR
| S_IWUSR
, 7 },
1993 { "l2t", &t4_l2t_fops
, S_IRUSR
, 0},
1994 { "mps_tcam", &mps_tcam_debugfs_fops
, S_IRUSR
, 0 },
1995 { "rss", &rss_debugfs_fops
, S_IRUSR
, 0 },
1996 { "rss_config", &rss_config_debugfs_fops
, S_IRUSR
, 0 },
1997 { "rss_key", &rss_key_debugfs_fops
, S_IRUSR
, 0 },
1998 { "rss_pf_config", &rss_pf_config_debugfs_fops
, S_IRUSR
, 0 },
1999 { "rss_vf_config", &rss_vf_config_debugfs_fops
, S_IRUSR
, 0 },
2000 { "sge_qinfo", &sge_qinfo_debugfs_fops
, S_IRUSR
, 0 },
2001 { "ibq_tp0", &cim_ibq_fops
, S_IRUSR
, 0 },
2002 { "ibq_tp1", &cim_ibq_fops
, S_IRUSR
, 1 },
2003 { "ibq_ulp", &cim_ibq_fops
, S_IRUSR
, 2 },
2004 { "ibq_sge0", &cim_ibq_fops
, S_IRUSR
, 3 },
2005 { "ibq_sge1", &cim_ibq_fops
, S_IRUSR
, 4 },
2006 { "ibq_ncsi", &cim_ibq_fops
, S_IRUSR
, 5 },
2007 { "obq_ulp0", &cim_obq_fops
, S_IRUSR
, 0 },
2008 { "obq_ulp1", &cim_obq_fops
, S_IRUSR
, 1 },
2009 { "obq_ulp2", &cim_obq_fops
, S_IRUSR
, 2 },
2010 { "obq_ulp3", &cim_obq_fops
, S_IRUSR
, 3 },
2011 { "obq_sge", &cim_obq_fops
, S_IRUSR
, 4 },
2012 { "obq_ncsi", &cim_obq_fops
, S_IRUSR
, 5 },
2013 { "tp_la", &tp_la_fops
, S_IRUSR
, 0 },
2014 { "ulprx_la", &ulprx_la_fops
, S_IRUSR
, 0 },
2015 { "sensors", &sensors_debugfs_fops
, S_IRUSR
, 0 },
2016 { "pm_stats", &pm_stats_debugfs_fops
, S_IRUSR
, 0 },
2017 { "cctrl", &cctrl_tbl_debugfs_fops
, S_IRUSR
, 0 },
2018 #if IS_ENABLED(CONFIG_IPV6)
2019 { "clip_tbl", &clip_tbl_debugfs_fops
, S_IRUSR
, 0 },
2023 /* Debug FS nodes common to all T5 and later adapters.
2025 static struct t4_debugfs_entry t5_debugfs_files
[] = {
2026 { "obq_sge_rx_q0", &cim_obq_fops
, S_IRUSR
, 6 },
2027 { "obq_sge_rx_q1", &cim_obq_fops
, S_IRUSR
, 7 },
2030 add_debugfs_files(adap
,
2032 ARRAY_SIZE(t4_debugfs_files
));
2033 if (!is_t4(adap
->params
.chip
))
2034 add_debugfs_files(adap
,
2036 ARRAY_SIZE(t5_debugfs_files
));
2038 i
= t4_read_reg(adap
, MA_TARGET_MEM_ENABLE_A
);
2039 if (i
& EDRAM0_ENABLE_F
) {
2040 size
= t4_read_reg(adap
, MA_EDRAM0_BAR_A
);
2041 add_debugfs_mem(adap
, "edc0", MEM_EDC0
, EDRAM0_SIZE_G(size
));
2043 if (i
& EDRAM1_ENABLE_F
) {
2044 size
= t4_read_reg(adap
, MA_EDRAM1_BAR_A
);
2045 add_debugfs_mem(adap
, "edc1", MEM_EDC1
, EDRAM1_SIZE_G(size
));
2047 if (is_t4(adap
->params
.chip
)) {
2048 size
= t4_read_reg(adap
, MA_EXT_MEMORY_BAR_A
);
2049 if (i
& EXT_MEM_ENABLE_F
)
2050 add_debugfs_mem(adap
, "mc", MEM_MC
,
2051 EXT_MEM_SIZE_G(size
));
2053 if (i
& EXT_MEM0_ENABLE_F
) {
2054 size
= t4_read_reg(adap
, MA_EXT_MEMORY0_BAR_A
);
2055 add_debugfs_mem(adap
, "mc0", MEM_MC0
,
2056 EXT_MEM0_SIZE_G(size
));
2058 if (i
& EXT_MEM1_ENABLE_F
) {
2059 size
= t4_read_reg(adap
, MA_EXT_MEMORY1_BAR_A
);
2060 add_debugfs_mem(adap
, "mc1", MEM_MC1
,
2061 EXT_MEM1_SIZE_G(size
));
2065 de
= debugfs_create_file("flash", S_IRUSR
, adap
->debugfs_root
, adap
,
2066 &flash_debugfs_fops
);
2067 set_debugfs_file_size(de
, adap
->params
.sf_size
);