1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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>
40
41#include "cxgb4.h"
42#include "t4_regs.h"
43#include "t4_values.h"
44#include "t4fw_api.h"
45#include "cxgb4_debugfs.h"
46#include "clip_tbl.h"
47#include "l2t.h"
48#include "cudbg_if.h"
49#include "cudbg_lib_common.h"
50#include "cudbg_entity.h"
51#include "cudbg_lib.h"
52#include "cxgb4_tc_mqprio.h"
53
54
55static void *seq_tab_get_idx(struct seq_tab *tb, loff_t pos)
56{
57 pos -= tb->skip_first;
58 return pos >= tb->rows ? NULL : &tb->data[pos * tb->width];
59}
60
61static void *seq_tab_start(struct seq_file *seq, loff_t *pos)
62{
63 struct seq_tab *tb = seq->private;
64
65 if (tb->skip_first && *pos == 0)
66 return SEQ_START_TOKEN;
67
68 return seq_tab_get_idx(tb, *pos);
69}
70
71static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos)
72{
73 v = seq_tab_get_idx(seq->private, *pos + 1);
74 ++(*pos);
75 return v;
76}
77
78static void seq_tab_stop(struct seq_file *seq, void *v)
79{
80}
81
82static int seq_tab_show(struct seq_file *seq, void *v)
83{
84 const struct seq_tab *tb = seq->private;
85
86 return tb->show(seq, v, ((char *)v - tb->data) / tb->width);
87}
88
89static const struct seq_operations seq_tab_ops = {
90 .start = seq_tab_start,
91 .next = seq_tab_next,
92 .stop = seq_tab_stop,
93 .show = seq_tab_show
94};
95
96struct seq_tab *seq_open_tab(struct file *f, unsigned int rows,
97 unsigned int width, unsigned int have_header,
98 int (*show)(struct seq_file *seq, void *v, int i))
99{
100 struct seq_tab *p;
101
102 p = __seq_open_private(f, &seq_tab_ops, sizeof(*p) + rows * width);
103 if (p) {
104 p->show = show;
105 p->rows = rows;
106 p->width = width;
107 p->skip_first = have_header != 0;
108 }
109 return p;
110}
111
112
113
114
115static int seq_tab_trim(struct seq_tab *p, unsigned int new_rows)
116{
117 if (new_rows > p->rows)
118 return -EINVAL;
119 p->rows = new_rows;
120 return 0;
121}
122
123static int cim_la_show(struct seq_file *seq, void *v, int idx)
124{
125 if (v == SEQ_START_TOKEN)
126 seq_puts(seq, "Status Data PC LS0Stat LS0Addr "
127 " LS0Data\n");
128 else {
129 const u32 *p = v;
130
131 seq_printf(seq,
132 " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
133 (p[0] >> 4) & 0xff, p[0] & 0xf, p[1] >> 4,
134 p[1] & 0xf, p[2] >> 4, p[2] & 0xf, p[3], p[4], p[5],
135 p[6], p[7]);
136 }
137 return 0;
138}
139
140static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx)
141{
142 if (v == SEQ_START_TOKEN) {
143 seq_puts(seq, "Status Data PC\n");
144 } else {
145 const u32 *p = v;
146
147 seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6],
148 p[7]);
149 seq_printf(seq, " %02x %02x%06x %02x%06x\n",
150 (p[3] >> 8) & 0xff, p[3] & 0xff, p[4] >> 8,
151 p[4] & 0xff, p[5] >> 8);
152 seq_printf(seq, " %02x %x%07x %x%07x\n", (p[0] >> 4) & 0xff,
153 p[0] & 0xf, p[1] >> 4, p[1] & 0xf, p[2] >> 4);
154 }
155 return 0;
156}
157
158static int cim_la_show_t6(struct seq_file *seq, void *v, int idx)
159{
160 if (v == SEQ_START_TOKEN) {
161 seq_puts(seq, "Status Inst Data PC LS0Stat "
162 "LS0Addr LS0Data LS1Stat LS1Addr LS1Data\n");
163 } else {
164 const u32 *p = v;
165
166 seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x %08x %08x %08x %08x %08x %08x\n",
167 (p[9] >> 16) & 0xff,
168 p[9] & 0xffff, p[8] >> 16,
169 p[8] & 0xffff, p[7] >> 16,
170 p[7] & 0xffff, p[6] >> 16,
171 p[2], p[1], p[0],
172 p[5], p[4], p[3]);
173 }
174 return 0;
175}
176
177static int cim_la_show_pc_t6(struct seq_file *seq, void *v, int idx)
178{
179 if (v == SEQ_START_TOKEN) {
180 seq_puts(seq, "Status Inst Data PC\n");
181 } else {
182 const u32 *p = v;
183
184 seq_printf(seq, " %02x %08x %08x %08x\n",
185 p[3] & 0xff, p[2], p[1], p[0]);
186 seq_printf(seq, " %02x %02x%06x %02x%06x %02x%06x\n",
187 (p[6] >> 8) & 0xff, p[6] & 0xff, p[5] >> 8,
188 p[5] & 0xff, p[4] >> 8, p[4] & 0xff, p[3] >> 8);
189 seq_printf(seq, " %02x %04x%04x %04x%04x %04x%04x\n",
190 (p[9] >> 16) & 0xff, p[9] & 0xffff, p[8] >> 16,
191 p[8] & 0xffff, p[7] >> 16, p[7] & 0xffff,
192 p[6] >> 16);
193 }
194 return 0;
195}
196
197static int cim_la_open(struct inode *inode, struct file *file)
198{
199 int ret;
200 unsigned int cfg;
201 struct seq_tab *p;
202 struct adapter *adap = inode->i_private;
203
204 ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg);
205 if (ret)
206 return ret;
207
208 if (is_t6(adap->params.chip)) {
209
210 p = seq_open_tab(file, (adap->params.cim_la_size / 10) + 1,
211 10 * sizeof(u32), 1,
212 cfg & UPDBGLACAPTPCONLY_F ?
213 cim_la_show_pc_t6 : cim_la_show_t6);
214 } else {
215 p = seq_open_tab(file, adap->params.cim_la_size / 8,
216 8 * sizeof(u32), 1,
217 cfg & UPDBGLACAPTPCONLY_F ? cim_la_show_3in1 :
218 cim_la_show);
219 }
220 if (!p)
221 return -ENOMEM;
222
223 ret = t4_cim_read_la(adap, (u32 *)p->data, NULL);
224 if (ret)
225 seq_release_private(inode, file);
226 return ret;
227}
228
229static const struct file_operations cim_la_fops = {
230 .owner = THIS_MODULE,
231 .open = cim_la_open,
232 .read = seq_read,
233 .llseek = seq_lseek,
234 .release = seq_release_private
235};
236
237static int cim_pif_la_show(struct seq_file *seq, void *v, int idx)
238{
239 const u32 *p = v;
240
241 if (v == SEQ_START_TOKEN) {
242 seq_puts(seq, "Cntl ID DataBE Addr Data\n");
243 } else if (idx < CIM_PIFLA_SIZE) {
244 seq_printf(seq, " %02x %02x %04x %08x %08x%08x%08x%08x\n",
245 (p[5] >> 22) & 0xff, (p[5] >> 16) & 0x3f,
246 p[5] & 0xffff, p[4], p[3], p[2], p[1], p[0]);
247 } else {
248 if (idx == CIM_PIFLA_SIZE)
249 seq_puts(seq, "\nCntl ID Data\n");
250 seq_printf(seq, " %02x %02x %08x%08x%08x%08x\n",
251 (p[4] >> 6) & 0xff, p[4] & 0x3f,
252 p[3], p[2], p[1], p[0]);
253 }
254 return 0;
255}
256
257static int cim_pif_la_open(struct inode *inode, struct file *file)
258{
259 struct seq_tab *p;
260 struct adapter *adap = inode->i_private;
261
262 p = seq_open_tab(file, 2 * CIM_PIFLA_SIZE, 6 * sizeof(u32), 1,
263 cim_pif_la_show);
264 if (!p)
265 return -ENOMEM;
266
267 t4_cim_read_pif_la(adap, (u32 *)p->data,
268 (u32 *)p->data + 6 * CIM_PIFLA_SIZE, NULL, NULL);
269 return 0;
270}
271
272static const struct file_operations cim_pif_la_fops = {
273 .owner = THIS_MODULE,
274 .open = cim_pif_la_open,
275 .read = seq_read,
276 .llseek = seq_lseek,
277 .release = seq_release_private
278};
279
280static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)
281{
282 const u32 *p = v;
283
284 if (v == SEQ_START_TOKEN) {
285 seq_puts(seq, "\n");
286 } else if (idx < CIM_MALA_SIZE) {
287 seq_printf(seq, "%02x%08x%08x%08x%08x\n",
288 p[4], p[3], p[2], p[1], p[0]);
289 } else {
290 if (idx == CIM_MALA_SIZE)
291 seq_puts(seq,
292 "\nCnt ID Tag UE Data RDY VLD\n");
293 seq_printf(seq, "%3u %2u %x %u %08x%08x %u %u\n",
294 (p[2] >> 10) & 0xff, (p[2] >> 7) & 7,
295 (p[2] >> 3) & 0xf, (p[2] >> 2) & 1,
296 (p[1] >> 2) | ((p[2] & 3) << 30),
297 (p[0] >> 2) | ((p[1] & 3) << 30), (p[0] >> 1) & 1,
298 p[0] & 1);
299 }
300 return 0;
301}
302
303static int cim_ma_la_open(struct inode *inode, struct file *file)
304{
305 struct seq_tab *p;
306 struct adapter *adap = inode->i_private;
307
308 p = seq_open_tab(file, 2 * CIM_MALA_SIZE, 5 * sizeof(u32), 1,
309 cim_ma_la_show);
310 if (!p)
311 return -ENOMEM;
312
313 t4_cim_read_ma_la(adap, (u32 *)p->data,
314 (u32 *)p->data + 5 * CIM_MALA_SIZE);
315 return 0;
316}
317
318static const struct file_operations cim_ma_la_fops = {
319 .owner = THIS_MODULE,
320 .open = cim_ma_la_open,
321 .read = seq_read,
322 .llseek = seq_lseek,
323 .release = seq_release_private
324};
325
326static int cim_qcfg_show(struct seq_file *seq, void *v)
327{
328 static const char * const qname[] = {
329 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
330 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
331 "SGE0-RX", "SGE1-RX"
332 };
333
334 int i;
335 struct adapter *adap = seq->private;
336 u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
337 u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
338 u32 stat[(4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5))];
339 u16 thres[CIM_NUM_IBQ];
340 u32 obq_wr_t4[2 * CIM_NUM_OBQ], *wr;
341 u32 obq_wr_t5[2 * CIM_NUM_OBQ_T5];
342 u32 *p = stat;
343 int cim_num_obq = is_t4(adap->params.chip) ?
344 CIM_NUM_OBQ : CIM_NUM_OBQ_T5;
345
346 i = t4_cim_read(adap, is_t4(adap->params.chip) ? UP_IBQ_0_RDADDR_A :
347 UP_IBQ_0_SHADOW_RDADDR_A,
348 ARRAY_SIZE(stat), stat);
349 if (!i) {
350 if (is_t4(adap->params.chip)) {
351 i = t4_cim_read(adap, UP_OBQ_0_REALADDR_A,
352 ARRAY_SIZE(obq_wr_t4), obq_wr_t4);
353 wr = obq_wr_t4;
354 } else {
355 i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A,
356 ARRAY_SIZE(obq_wr_t5), obq_wr_t5);
357 wr = obq_wr_t5;
358 }
359 }
360 if (i)
361 return i;
362
363 t4_read_cimq_cfg(adap, base, size, thres);
364
365 seq_printf(seq,
366 " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
367 for (i = 0; i < CIM_NUM_IBQ; i++, p += 4)
368 seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
369 qname[i], base[i], size[i], thres[i],
370 IBQRDADDR_G(p[0]), IBQWRADDR_G(p[1]),
371 QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
372 QUEREMFLITS_G(p[2]) * 16);
373 for ( ; i < CIM_NUM_IBQ + cim_num_obq; i++, p += 4, wr += 2)
374 seq_printf(seq, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
375 qname[i], base[i], size[i],
376 QUERDADDR_G(p[0]) & 0x3fff, wr[0] - base[i],
377 QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
378 QUEREMFLITS_G(p[2]) * 16);
379 return 0;
380}
381DEFINE_SHOW_ATTRIBUTE(cim_qcfg);
382
383static int cimq_show(struct seq_file *seq, void *v, int idx)
384{
385 const u32 *p = v;
386
387 seq_printf(seq, "%#06x: %08x %08x %08x %08x\n", idx * 16, p[0], p[1],
388 p[2], p[3]);
389 return 0;
390}
391
392static int cim_ibq_open(struct inode *inode, struct file *file)
393{
394 int ret;
395 struct seq_tab *p;
396 unsigned int qid = (uintptr_t)inode->i_private & 7;
397 struct adapter *adap = inode->i_private - qid;
398
399 p = seq_open_tab(file, CIM_IBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
400 if (!p)
401 return -ENOMEM;
402
403 ret = t4_read_cim_ibq(adap, qid, (u32 *)p->data, CIM_IBQ_SIZE * 4);
404 if (ret < 0)
405 seq_release_private(inode, file);
406 else
407 ret = 0;
408 return ret;
409}
410
411static const struct file_operations cim_ibq_fops = {
412 .owner = THIS_MODULE,
413 .open = cim_ibq_open,
414 .read = seq_read,
415 .llseek = seq_lseek,
416 .release = seq_release_private
417};
418
419static int cim_obq_open(struct inode *inode, struct file *file)
420{
421 int ret;
422 struct seq_tab *p;
423 unsigned int qid = (uintptr_t)inode->i_private & 7;
424 struct adapter *adap = inode->i_private - qid;
425
426 p = seq_open_tab(file, 6 * CIM_OBQ_SIZE, 4 * sizeof(u32), 0, cimq_show);
427 if (!p)
428 return -ENOMEM;
429
430 ret = t4_read_cim_obq(adap, qid, (u32 *)p->data, 6 * CIM_OBQ_SIZE * 4);
431 if (ret < 0) {
432 seq_release_private(inode, file);
433 } else {
434 seq_tab_trim(p, ret / 4);
435 ret = 0;
436 }
437 return ret;
438}
439
440static const struct file_operations cim_obq_fops = {
441 .owner = THIS_MODULE,
442 .open = cim_obq_open,
443 .read = seq_read,
444 .llseek = seq_lseek,
445 .release = seq_release_private
446};
447
448struct field_desc {
449 const char *name;
450 unsigned int start;
451 unsigned int width;
452};
453
454static void field_desc_show(struct seq_file *seq, u64 v,
455 const struct field_desc *p)
456{
457 char buf[32];
458 int line_size = 0;
459
460 while (p->name) {
461 u64 mask = (1ULL << p->width) - 1;
462 int len = scnprintf(buf, sizeof(buf), "%s: %llu", p->name,
463 ((unsigned long long)v >> p->start) & mask);
464
465 if (line_size + len >= 79) {
466 line_size = 8;
467 seq_puts(seq, "\n ");
468 }
469 seq_printf(seq, "%s ", buf);
470 line_size += len + 1;
471 p++;
472 }
473 seq_putc(seq, '\n');
474}
475
476static struct field_desc tp_la0[] = {
477 { "RcfOpCodeOut", 60, 4 },
478 { "State", 56, 4 },
479 { "WcfState", 52, 4 },
480 { "RcfOpcSrcOut", 50, 2 },
481 { "CRxError", 49, 1 },
482 { "ERxError", 48, 1 },
483 { "SanityFailed", 47, 1 },
484 { "SpuriousMsg", 46, 1 },
485 { "FlushInputMsg", 45, 1 },
486 { "FlushInputCpl", 44, 1 },
487 { "RssUpBit", 43, 1 },
488 { "RssFilterHit", 42, 1 },
489 { "Tid", 32, 10 },
490 { "InitTcb", 31, 1 },
491 { "LineNumber", 24, 7 },
492 { "Emsg", 23, 1 },
493 { "EdataOut", 22, 1 },
494 { "Cmsg", 21, 1 },
495 { "CdataOut", 20, 1 },
496 { "EreadPdu", 19, 1 },
497 { "CreadPdu", 18, 1 },
498 { "TunnelPkt", 17, 1 },
499 { "RcfPeerFin", 16, 1 },
500 { "RcfReasonOut", 12, 4 },
501 { "TxCchannel", 10, 2 },
502 { "RcfTxChannel", 8, 2 },
503 { "RxEchannel", 6, 2 },
504 { "RcfRxChannel", 5, 1 },
505 { "RcfDataOutSrdy", 4, 1 },
506 { "RxDvld", 3, 1 },
507 { "RxOoDvld", 2, 1 },
508 { "RxCongestion", 1, 1 },
509 { "TxCongestion", 0, 1 },
510 { NULL }
511};
512
513static int tp_la_show(struct seq_file *seq, void *v, int idx)
514{
515 const u64 *p = v;
516
517 field_desc_show(seq, *p, tp_la0);
518 return 0;
519}
520
521static int tp_la_show2(struct seq_file *seq, void *v, int idx)
522{
523 const u64 *p = v;
524
525 if (idx)
526 seq_putc(seq, '\n');
527 field_desc_show(seq, p[0], tp_la0);
528 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
529 field_desc_show(seq, p[1], tp_la0);
530 return 0;
531}
532
533static int tp_la_show3(struct seq_file *seq, void *v, int idx)
534{
535 static struct field_desc tp_la1[] = {
536 { "CplCmdIn", 56, 8 },
537 { "CplCmdOut", 48, 8 },
538 { "ESynOut", 47, 1 },
539 { "EAckOut", 46, 1 },
540 { "EFinOut", 45, 1 },
541 { "ERstOut", 44, 1 },
542 { "SynIn", 43, 1 },
543 { "AckIn", 42, 1 },
544 { "FinIn", 41, 1 },
545 { "RstIn", 40, 1 },
546 { "DataIn", 39, 1 },
547 { "DataInVld", 38, 1 },
548 { "PadIn", 37, 1 },
549 { "RxBufEmpty", 36, 1 },
550 { "RxDdp", 35, 1 },
551 { "RxFbCongestion", 34, 1 },
552 { "TxFbCongestion", 33, 1 },
553 { "TxPktSumSrdy", 32, 1 },
554 { "RcfUlpType", 28, 4 },
555 { "Eread", 27, 1 },
556 { "Ebypass", 26, 1 },
557 { "Esave", 25, 1 },
558 { "Static0", 24, 1 },
559 { "Cread", 23, 1 },
560 { "Cbypass", 22, 1 },
561 { "Csave", 21, 1 },
562 { "CPktOut", 20, 1 },
563 { "RxPagePoolFull", 18, 2 },
564 { "RxLpbkPkt", 17, 1 },
565 { "TxLpbkPkt", 16, 1 },
566 { "RxVfValid", 15, 1 },
567 { "SynLearned", 14, 1 },
568 { "SetDelEntry", 13, 1 },
569 { "SetInvEntry", 12, 1 },
570 { "CpcmdDvld", 11, 1 },
571 { "CpcmdSave", 10, 1 },
572 { "RxPstructsFull", 8, 2 },
573 { "EpcmdDvld", 7, 1 },
574 { "EpcmdFlush", 6, 1 },
575 { "EpcmdTrimPrefix", 5, 1 },
576 { "EpcmdTrimPostfix", 4, 1 },
577 { "ERssIp4Pkt", 3, 1 },
578 { "ERssIp6Pkt", 2, 1 },
579 { "ERssTcpUdpPkt", 1, 1 },
580 { "ERssFceFipPkt", 0, 1 },
581 { NULL }
582 };
583 static struct field_desc tp_la2[] = {
584 { "CplCmdIn", 56, 8 },
585 { "MpsVfVld", 55, 1 },
586 { "MpsPf", 52, 3 },
587 { "MpsVf", 44, 8 },
588 { "SynIn", 43, 1 },
589 { "AckIn", 42, 1 },
590 { "FinIn", 41, 1 },
591 { "RstIn", 40, 1 },
592 { "DataIn", 39, 1 },
593 { "DataInVld", 38, 1 },
594 { "PadIn", 37, 1 },
595 { "RxBufEmpty", 36, 1 },
596 { "RxDdp", 35, 1 },
597 { "RxFbCongestion", 34, 1 },
598 { "TxFbCongestion", 33, 1 },
599 { "TxPktSumSrdy", 32, 1 },
600 { "RcfUlpType", 28, 4 },
601 { "Eread", 27, 1 },
602 { "Ebypass", 26, 1 },
603 { "Esave", 25, 1 },
604 { "Static0", 24, 1 },
605 { "Cread", 23, 1 },
606 { "Cbypass", 22, 1 },
607 { "Csave", 21, 1 },
608 { "CPktOut", 20, 1 },
609 { "RxPagePoolFull", 18, 2 },
610 { "RxLpbkPkt", 17, 1 },
611 { "TxLpbkPkt", 16, 1 },
612 { "RxVfValid", 15, 1 },
613 { "SynLearned", 14, 1 },
614 { "SetDelEntry", 13, 1 },
615 { "SetInvEntry", 12, 1 },
616 { "CpcmdDvld", 11, 1 },
617 { "CpcmdSave", 10, 1 },
618 { "RxPstructsFull", 8, 2 },
619 { "EpcmdDvld", 7, 1 },
620 { "EpcmdFlush", 6, 1 },
621 { "EpcmdTrimPrefix", 5, 1 },
622 { "EpcmdTrimPostfix", 4, 1 },
623 { "ERssIp4Pkt", 3, 1 },
624 { "ERssIp6Pkt", 2, 1 },
625 { "ERssTcpUdpPkt", 1, 1 },
626 { "ERssFceFipPkt", 0, 1 },
627 { NULL }
628 };
629 const u64 *p = v;
630
631 if (idx)
632 seq_putc(seq, '\n');
633 field_desc_show(seq, p[0], tp_la0);
634 if (idx < (TPLA_SIZE / 2 - 1) || p[1] != ~0ULL)
635 field_desc_show(seq, p[1], (p[0] & BIT(17)) ? tp_la2 : tp_la1);
636 return 0;
637}
638
639static int tp_la_open(struct inode *inode, struct file *file)
640{
641 struct seq_tab *p;
642 struct adapter *adap = inode->i_private;
643
644 switch (DBGLAMODE_G(t4_read_reg(adap, TP_DBG_LA_CONFIG_A))) {
645 case 2:
646 p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
647 tp_la_show2);
648 break;
649 case 3:
650 p = seq_open_tab(file, TPLA_SIZE / 2, 2 * sizeof(u64), 0,
651 tp_la_show3);
652 break;
653 default:
654 p = seq_open_tab(file, TPLA_SIZE, sizeof(u64), 0, tp_la_show);
655 }
656 if (!p)
657 return -ENOMEM;
658
659 t4_tp_read_la(adap, (u64 *)p->data, NULL);
660 return 0;
661}
662
663static ssize_t tp_la_write(struct file *file, const char __user *buf,
664 size_t count, loff_t *pos)
665{
666 int err;
667 char s[32];
668 unsigned long val;
669 size_t size = min(sizeof(s) - 1, count);
670 struct adapter *adap = file_inode(file)->i_private;
671
672 if (copy_from_user(s, buf, size))
673 return -EFAULT;
674 s[size] = '\0';
675 err = kstrtoul(s, 0, &val);
676 if (err)
677 return err;
678 if (val > 0xffff)
679 return -EINVAL;
680 adap->params.tp.la_mask = val << 16;
681 t4_set_reg_field(adap, TP_DBG_LA_CONFIG_A, 0xffff0000U,
682 adap->params.tp.la_mask);
683 return count;
684}
685
686static const struct file_operations tp_la_fops = {
687 .owner = THIS_MODULE,
688 .open = tp_la_open,
689 .read = seq_read,
690 .llseek = seq_lseek,
691 .release = seq_release_private,
692 .write = tp_la_write
693};
694
695static int ulprx_la_show(struct seq_file *seq, void *v, int idx)
696{
697 const u32 *p = v;
698
699 if (v == SEQ_START_TOKEN)
700 seq_puts(seq, " Pcmd Type Message"
701 " Data\n");
702 else
703 seq_printf(seq, "%08x%08x %4x %08x %08x%08x%08x%08x\n",
704 p[1], p[0], p[2], p[3], p[7], p[6], p[5], p[4]);
705 return 0;
706}
707
708static int ulprx_la_open(struct inode *inode, struct file *file)
709{
710 struct seq_tab *p;
711 struct adapter *adap = inode->i_private;
712
713 p = seq_open_tab(file, ULPRX_LA_SIZE, 8 * sizeof(u32), 1,
714 ulprx_la_show);
715 if (!p)
716 return -ENOMEM;
717
718 t4_ulprx_read_la(adap, (u32 *)p->data);
719 return 0;
720}
721
722static const struct file_operations ulprx_la_fops = {
723 .owner = THIS_MODULE,
724 .open = ulprx_la_open,
725 .read = seq_read,
726 .llseek = seq_lseek,
727 .release = seq_release_private
728};
729
730
731
732
733
734
735
736
737
738
739
740
741
742static int pm_stats_show(struct seq_file *seq, void *v)
743{
744 static const char * const tx_pm_stats[] = {
745 "Read:", "Write bypass:", "Write mem:", "Bypass + mem:"
746 };
747 static const char * const rx_pm_stats[] = {
748 "Read:", "Write bypass:", "Write mem:", "Flush:"
749 };
750
751 int i;
752 u32 tx_cnt[T6_PM_NSTATS], rx_cnt[T6_PM_NSTATS];
753 u64 tx_cyc[T6_PM_NSTATS], rx_cyc[T6_PM_NSTATS];
754 struct adapter *adap = seq->private;
755
756 t4_pmtx_get_stats(adap, tx_cnt, tx_cyc);
757 t4_pmrx_get_stats(adap, rx_cnt, rx_cyc);
758
759 seq_printf(seq, "%13s %10s %20s\n", " ", "Tx pcmds", "Tx bytes");
760 for (i = 0; i < PM_NSTATS - 1; i++)
761 seq_printf(seq, "%-13s %10u %20llu\n",
762 tx_pm_stats[i], tx_cnt[i], tx_cyc[i]);
763
764 seq_printf(seq, "%13s %10s %20s\n", " ", "Rx pcmds", "Rx bytes");
765 for (i = 0; i < PM_NSTATS - 1; i++)
766 seq_printf(seq, "%-13s %10u %20llu\n",
767 rx_pm_stats[i], rx_cnt[i], rx_cyc[i]);
768
769 if (CHELSIO_CHIP_VERSION(adap->params.chip) > CHELSIO_T5) {
770
771
772
773
774 seq_printf(seq, "%13s %10s %20s\n",
775 " ", "Total wait", "Total Occupancy");
776 seq_printf(seq, "Tx FIFO wait %10u %20llu\n",
777 tx_cnt[i], tx_cyc[i]);
778 seq_printf(seq, "Rx FIFO wait %10u %20llu\n",
779 rx_cnt[i], rx_cyc[i]);
780
781
782 i += 2;
783
784
785
786
787 seq_printf(seq, "%13s %10s %20s\n",
788 " ", "Reads", "Total wait");
789 seq_printf(seq, "Tx latency %10u %20llu\n",
790 tx_cnt[i], tx_cyc[i]);
791 seq_printf(seq, "Rx latency %10u %20llu\n",
792 rx_cnt[i], rx_cyc[i]);
793 }
794 return 0;
795}
796
797static int pm_stats_open(struct inode *inode, struct file *file)
798{
799 return single_open(file, pm_stats_show, inode->i_private);
800}
801
802static ssize_t pm_stats_clear(struct file *file, const char __user *buf,
803 size_t count, loff_t *pos)
804{
805 struct adapter *adap = file_inode(file)->i_private;
806
807 t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0);
808 t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0);
809 return count;
810}
811
812static const struct file_operations pm_stats_debugfs_fops = {
813 .owner = THIS_MODULE,
814 .open = pm_stats_open,
815 .read = seq_read,
816 .llseek = seq_lseek,
817 .release = single_release,
818 .write = pm_stats_clear
819};
820
821static int tx_rate_show(struct seq_file *seq, void *v)
822{
823 u64 nrate[NCHAN], orate[NCHAN];
824 struct adapter *adap = seq->private;
825
826 t4_get_chan_txrate(adap, nrate, orate);
827 if (adap->params.arch.nchan == NCHAN) {
828 seq_puts(seq, " channel 0 channel 1 "
829 "channel 2 channel 3\n");
830 seq_printf(seq, "NIC B/s: %10llu %10llu %10llu %10llu\n",
831 (unsigned long long)nrate[0],
832 (unsigned long long)nrate[1],
833 (unsigned long long)nrate[2],
834 (unsigned long long)nrate[3]);
835 seq_printf(seq, "Offload B/s: %10llu %10llu %10llu %10llu\n",
836 (unsigned long long)orate[0],
837 (unsigned long long)orate[1],
838 (unsigned long long)orate[2],
839 (unsigned long long)orate[3]);
840 } else {
841 seq_puts(seq, " channel 0 channel 1\n");
842 seq_printf(seq, "NIC B/s: %10llu %10llu\n",
843 (unsigned long long)nrate[0],
844 (unsigned long long)nrate[1]);
845 seq_printf(seq, "Offload B/s: %10llu %10llu\n",
846 (unsigned long long)orate[0],
847 (unsigned long long)orate[1]);
848 }
849 return 0;
850}
851DEFINE_SHOW_ATTRIBUTE(tx_rate);
852
853static int cctrl_tbl_show(struct seq_file *seq, void *v)
854{
855 static const char * const dec_fac[] = {
856 "0.5", "0.5625", "0.625", "0.6875", "0.75", "0.8125", "0.875",
857 "0.9375" };
858
859 int i;
860 u16 (*incr)[NCCTRL_WIN];
861 struct adapter *adap = seq->private;
862
863 incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL);
864 if (!incr)
865 return -ENOMEM;
866
867 t4_read_cong_tbl(adap, incr);
868
869 for (i = 0; i < NCCTRL_WIN; ++i) {
870 seq_printf(seq, "%2d: %4u %4u %4u %4u %4u %4u %4u %4u\n", i,
871 incr[0][i], incr[1][i], incr[2][i], incr[3][i],
872 incr[4][i], incr[5][i], incr[6][i], incr[7][i]);
873 seq_printf(seq, "%8u %4u %4u %4u %4u %4u %4u %4u %5u %s\n",
874 incr[8][i], incr[9][i], incr[10][i], incr[11][i],
875 incr[12][i], incr[13][i], incr[14][i], incr[15][i],
876 adap->params.a_wnd[i],
877 dec_fac[adap->params.b_wnd[i]]);
878 }
879
880 kfree(incr);
881 return 0;
882}
883DEFINE_SHOW_ATTRIBUTE(cctrl_tbl);
884
885
886
887
888static char *unit_conv(char *buf, size_t len, unsigned int val,
889 unsigned int factor)
890{
891 unsigned int rem = val % factor;
892
893 if (rem == 0) {
894 snprintf(buf, len, "%u", val / factor);
895 } else {
896 while (rem % 10 == 0)
897 rem /= 10;
898 snprintf(buf, len, "%u.%u", val / factor, rem);
899 }
900 return buf;
901}
902
903static int clk_show(struct seq_file *seq, void *v)
904{
905 char buf[32];
906 struct adapter *adap = seq->private;
907 unsigned int cclk_ps = 1000000000 / adap->params.vpd.cclk;
908 u32 res = t4_read_reg(adap, TP_TIMER_RESOLUTION_A);
909 unsigned int tre = TIMERRESOLUTION_G(res);
910 unsigned int dack_re = DELAYEDACKRESOLUTION_G(res);
911 unsigned long long tp_tick_us = (cclk_ps << tre) / 1000000;
912
913 seq_printf(seq, "Core clock period: %s ns\n",
914 unit_conv(buf, sizeof(buf), cclk_ps, 1000));
915 seq_printf(seq, "TP timer tick: %s us\n",
916 unit_conv(buf, sizeof(buf), (cclk_ps << tre), 1000000));
917 seq_printf(seq, "TCP timestamp tick: %s us\n",
918 unit_conv(buf, sizeof(buf),
919 (cclk_ps << TIMESTAMPRESOLUTION_G(res)), 1000000));
920 seq_printf(seq, "DACK tick: %s us\n",
921 unit_conv(buf, sizeof(buf), (cclk_ps << dack_re), 1000000));
922 seq_printf(seq, "DACK timer: %u us\n",
923 ((cclk_ps << dack_re) / 1000000) *
924 t4_read_reg(adap, TP_DACK_TIMER_A));
925 seq_printf(seq, "Retransmit min: %llu us\n",
926 tp_tick_us * t4_read_reg(adap, TP_RXT_MIN_A));
927 seq_printf(seq, "Retransmit max: %llu us\n",
928 tp_tick_us * t4_read_reg(adap, TP_RXT_MAX_A));
929 seq_printf(seq, "Persist timer min: %llu us\n",
930 tp_tick_us * t4_read_reg(adap, TP_PERS_MIN_A));
931 seq_printf(seq, "Persist timer max: %llu us\n",
932 tp_tick_us * t4_read_reg(adap, TP_PERS_MAX_A));
933 seq_printf(seq, "Keepalive idle timer: %llu us\n",
934 tp_tick_us * t4_read_reg(adap, TP_KEEP_IDLE_A));
935 seq_printf(seq, "Keepalive interval: %llu us\n",
936 tp_tick_us * t4_read_reg(adap, TP_KEEP_INTVL_A));
937 seq_printf(seq, "Initial SRTT: %llu us\n",
938 tp_tick_us * INITSRTT_G(t4_read_reg(adap, TP_INIT_SRTT_A)));
939 seq_printf(seq, "FINWAIT2 timer: %llu us\n",
940 tp_tick_us * t4_read_reg(adap, TP_FINWAIT2_TIMER_A));
941
942 return 0;
943}
944DEFINE_SHOW_ATTRIBUTE(clk);
945
946
947static const char * const devlog_level_strings[] = {
948 [FW_DEVLOG_LEVEL_EMERG] = "EMERG",
949 [FW_DEVLOG_LEVEL_CRIT] = "CRIT",
950 [FW_DEVLOG_LEVEL_ERR] = "ERR",
951 [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE",
952 [FW_DEVLOG_LEVEL_INFO] = "INFO",
953 [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG"
954};
955
956static const char * const devlog_facility_strings[] = {
957 [FW_DEVLOG_FACILITY_CORE] = "CORE",
958 [FW_DEVLOG_FACILITY_CF] = "CF",
959 [FW_DEVLOG_FACILITY_SCHED] = "SCHED",
960 [FW_DEVLOG_FACILITY_TIMER] = "TIMER",
961 [FW_DEVLOG_FACILITY_RES] = "RES",
962 [FW_DEVLOG_FACILITY_HW] = "HW",
963 [FW_DEVLOG_FACILITY_FLR] = "FLR",
964 [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ",
965 [FW_DEVLOG_FACILITY_PHY] = "PHY",
966 [FW_DEVLOG_FACILITY_MAC] = "MAC",
967 [FW_DEVLOG_FACILITY_PORT] = "PORT",
968 [FW_DEVLOG_FACILITY_VI] = "VI",
969 [FW_DEVLOG_FACILITY_FILTER] = "FILTER",
970 [FW_DEVLOG_FACILITY_ACL] = "ACL",
971 [FW_DEVLOG_FACILITY_TM] = "TM",
972 [FW_DEVLOG_FACILITY_QFC] = "QFC",
973 [FW_DEVLOG_FACILITY_DCB] = "DCB",
974 [FW_DEVLOG_FACILITY_ETH] = "ETH",
975 [FW_DEVLOG_FACILITY_OFLD] = "OFLD",
976 [FW_DEVLOG_FACILITY_RI] = "RI",
977 [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI",
978 [FW_DEVLOG_FACILITY_FCOE] = "FCOE",
979 [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI",
980 [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE"
981};
982
983
984
985struct devlog_info {
986 unsigned int nentries;
987 unsigned int first;
988 struct fw_devlog_e log[0];
989};
990
991
992
993static int devlog_show(struct seq_file *seq, void *v)
994{
995 if (v == SEQ_START_TOKEN)
996 seq_printf(seq, "%10s %15s %8s %8s %s\n",
997 "Seq#", "Tstamp", "Level", "Facility", "Message");
998 else {
999 struct devlog_info *dinfo = seq->private;
1000 int fidx = (uintptr_t)v - 2;
1001 unsigned long index;
1002 struct fw_devlog_e *e;
1003
1004
1005
1006
1007 index = dinfo->first + fidx;
1008 if (index >= dinfo->nentries)
1009 index -= dinfo->nentries;
1010 e = &dinfo->log[index];
1011 if (e->timestamp == 0)
1012 return 0;
1013
1014
1015
1016
1017
1018 seq_printf(seq, "%10d %15llu %8s %8s ",
1019 be32_to_cpu(e->seqno),
1020 be64_to_cpu(e->timestamp),
1021 (e->level < ARRAY_SIZE(devlog_level_strings)
1022 ? devlog_level_strings[e->level]
1023 : "UNKNOWN"),
1024 (e->facility < ARRAY_SIZE(devlog_facility_strings)
1025 ? devlog_facility_strings[e->facility]
1026 : "UNKNOWN"));
1027 seq_printf(seq, e->fmt,
1028 be32_to_cpu(e->params[0]),
1029 be32_to_cpu(e->params[1]),
1030 be32_to_cpu(e->params[2]),
1031 be32_to_cpu(e->params[3]),
1032 be32_to_cpu(e->params[4]),
1033 be32_to_cpu(e->params[5]),
1034 be32_to_cpu(e->params[6]),
1035 be32_to_cpu(e->params[7]));
1036 }
1037 return 0;
1038}
1039
1040
1041
1042static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos)
1043{
1044 if (pos > dinfo->nentries)
1045 return NULL;
1046
1047 return (void *)(uintptr_t)(pos + 1);
1048}
1049
1050static void *devlog_start(struct seq_file *seq, loff_t *pos)
1051{
1052 struct devlog_info *dinfo = seq->private;
1053
1054 return (*pos
1055 ? devlog_get_idx(dinfo, *pos)
1056 : SEQ_START_TOKEN);
1057}
1058
1059static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos)
1060{
1061 struct devlog_info *dinfo = seq->private;
1062
1063 (*pos)++;
1064 return devlog_get_idx(dinfo, *pos);
1065}
1066
1067static void devlog_stop(struct seq_file *seq, void *v)
1068{
1069}
1070
1071static const struct seq_operations devlog_seq_ops = {
1072 .start = devlog_start,
1073 .next = devlog_next,
1074 .stop = devlog_stop,
1075 .show = devlog_show
1076};
1077
1078
1079
1080
1081static int devlog_open(struct inode *inode, struct file *file)
1082{
1083 struct adapter *adap = inode->i_private;
1084 struct devlog_params *dparams = &adap->params.devlog;
1085 struct devlog_info *dinfo;
1086 unsigned int index;
1087 u32 fseqno;
1088 int ret;
1089
1090
1091
1092 if (dparams->start == 0)
1093 return -ENXIO;
1094
1095
1096
1097
1098 dinfo = __seq_open_private(file, &devlog_seq_ops,
1099 sizeof(*dinfo) + dparams->size);
1100 if (!dinfo)
1101 return -ENOMEM;
1102
1103
1104
1105 dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e));
1106 dinfo->first = 0;
1107 spin_lock(&adap->win0_lock);
1108 ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype,
1109 dparams->start, dparams->size, (__be32 *)dinfo->log,
1110 T4_MEMORY_READ);
1111 spin_unlock(&adap->win0_lock);
1112 if (ret) {
1113 seq_release_private(inode, file);
1114 return ret;
1115 }
1116
1117
1118
1119
1120 for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) {
1121 struct fw_devlog_e *e = &dinfo->log[index];
1122 __u32 seqno;
1123
1124 if (e->timestamp == 0)
1125 continue;
1126
1127 seqno = be32_to_cpu(e->seqno);
1128 if (seqno < fseqno) {
1129 fseqno = seqno;
1130 dinfo->first = index;
1131 }
1132 }
1133 return 0;
1134}
1135
1136static const struct file_operations devlog_fops = {
1137 .owner = THIS_MODULE,
1138 .open = devlog_open,
1139 .read = seq_read,
1140 .llseek = seq_lseek,
1141 .release = seq_release_private
1142};
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154static int mboxlog_show(struct seq_file *seq, void *v)
1155{
1156 struct adapter *adapter = seq->private;
1157 struct mbox_cmd_log *log = adapter->mbox_log;
1158 struct mbox_cmd *entry;
1159 int entry_idx, i;
1160
1161 if (v == SEQ_START_TOKEN) {
1162 seq_printf(seq,
1163 "%10s %15s %5s %5s %s\n",
1164 "Seq#", "Tstamp", "Atime", "Etime",
1165 "Command/Reply");
1166 return 0;
1167 }
1168
1169 entry_idx = log->cursor + ((uintptr_t)v - 2);
1170 if (entry_idx >= log->size)
1171 entry_idx -= log->size;
1172 entry = mbox_cmd_log_entry(log, entry_idx);
1173
1174
1175 if (entry->timestamp == 0)
1176 return 0;
1177
1178 seq_printf(seq, "%10u %15llu %5d %5d",
1179 entry->seqno, entry->timestamp,
1180 entry->access, entry->execute);
1181 for (i = 0; i < MBOX_LEN / 8; i++) {
1182 u64 flit = entry->cmd[i];
1183 u32 hi = (u32)(flit >> 32);
1184 u32 lo = (u32)flit;
1185
1186 seq_printf(seq, " %08x %08x", hi, lo);
1187 }
1188 seq_puts(seq, "\n");
1189 return 0;
1190}
1191
1192static inline void *mboxlog_get_idx(struct seq_file *seq, loff_t pos)
1193{
1194 struct adapter *adapter = seq->private;
1195 struct mbox_cmd_log *log = adapter->mbox_log;
1196
1197 return ((pos <= log->size) ? (void *)(uintptr_t)(pos + 1) : NULL);
1198}
1199
1200static void *mboxlog_start(struct seq_file *seq, loff_t *pos)
1201{
1202 return *pos ? mboxlog_get_idx(seq, *pos) : SEQ_START_TOKEN;
1203}
1204
1205static void *mboxlog_next(struct seq_file *seq, void *v, loff_t *pos)
1206{
1207 ++*pos;
1208 return mboxlog_get_idx(seq, *pos);
1209}
1210
1211static void mboxlog_stop(struct seq_file *seq, void *v)
1212{
1213}
1214
1215static const struct seq_operations mboxlog_seq_ops = {
1216 .start = mboxlog_start,
1217 .next = mboxlog_next,
1218 .stop = mboxlog_stop,
1219 .show = mboxlog_show
1220};
1221
1222static int mboxlog_open(struct inode *inode, struct file *file)
1223{
1224 int res = seq_open(file, &mboxlog_seq_ops);
1225
1226 if (!res) {
1227 struct seq_file *seq = file->private_data;
1228
1229 seq->private = inode->i_private;
1230 }
1231 return res;
1232}
1233
1234static const struct file_operations mboxlog_fops = {
1235 .owner = THIS_MODULE,
1236 .open = mboxlog_open,
1237 .read = seq_read,
1238 .llseek = seq_lseek,
1239 .release = seq_release,
1240};
1241
1242static int mbox_show(struct seq_file *seq, void *v)
1243{
1244 static const char * const owner[] = { "none", "FW", "driver",
1245 "unknown", "<unread>" };
1246
1247 int i;
1248 unsigned int mbox = (uintptr_t)seq->private & 7;
1249 struct adapter *adap = seq->private - mbox;
1250 void __iomem *addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
1251
1252
1253
1254
1255
1256 if (is_t4(adap->params.chip)) {
1257 i = 4;
1258 } else {
1259 unsigned int ctrl_reg = CIM_PF_MAILBOX_CTRL_SHADOW_COPY_A;
1260 void __iomem *ctrl = adap->regs + PF_REG(mbox, ctrl_reg);
1261
1262 i = MBOWNER_G(readl(ctrl));
1263 }
1264
1265 seq_printf(seq, "mailbox owned by %s\n\n", owner[i]);
1266
1267 for (i = 0; i < MBOX_LEN; i += 8)
1268 seq_printf(seq, "%016llx\n",
1269 (unsigned long long)readq(addr + i));
1270 return 0;
1271}
1272
1273static int mbox_open(struct inode *inode, struct file *file)
1274{
1275 return single_open(file, mbox_show, inode->i_private);
1276}
1277
1278static ssize_t mbox_write(struct file *file, const char __user *buf,
1279 size_t count, loff_t *pos)
1280{
1281 int i;
1282 char c = '\n', s[256];
1283 unsigned long long data[8];
1284 const struct inode *ino;
1285 unsigned int mbox;
1286 struct adapter *adap;
1287 void __iomem *addr;
1288 void __iomem *ctrl;
1289
1290 if (count > sizeof(s) - 1 || !count)
1291 return -EINVAL;
1292 if (copy_from_user(s, buf, count))
1293 return -EFAULT;
1294 s[count] = '\0';
1295
1296 if (sscanf(s, "%llx %llx %llx %llx %llx %llx %llx %llx%c", &data[0],
1297 &data[1], &data[2], &data[3], &data[4], &data[5], &data[6],
1298 &data[7], &c) < 8 || c != '\n')
1299 return -EINVAL;
1300
1301 ino = file_inode(file);
1302 mbox = (uintptr_t)ino->i_private & 7;
1303 adap = ino->i_private - mbox;
1304 addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
1305 ctrl = addr + MBOX_LEN;
1306
1307 if (MBOWNER_G(readl(ctrl)) != X_MBOWNER_PL)
1308 return -EBUSY;
1309
1310 for (i = 0; i < 8; i++)
1311 writeq(data[i], addr + 8 * i);
1312
1313 writel(MBMSGVALID_F | MBOWNER_V(X_MBOWNER_FW), ctrl);
1314 return count;
1315}
1316
1317static const struct file_operations mbox_debugfs_fops = {
1318 .owner = THIS_MODULE,
1319 .open = mbox_open,
1320 .read = seq_read,
1321 .llseek = seq_lseek,
1322 .release = single_release,
1323 .write = mbox_write
1324};
1325
1326static int mps_trc_show(struct seq_file *seq, void *v)
1327{
1328 int enabled, i;
1329 struct trace_params tp;
1330 unsigned int trcidx = (uintptr_t)seq->private & 3;
1331 struct adapter *adap = seq->private - trcidx;
1332
1333 t4_get_trace_filter(adap, &tp, trcidx, &enabled);
1334 if (!enabled) {
1335 seq_puts(seq, "tracer is disabled\n");
1336 return 0;
1337 }
1338
1339 if (tp.skip_ofst * 8 >= TRACE_LEN) {
1340 dev_err(adap->pdev_dev, "illegal trace pattern skip offset\n");
1341 return -EINVAL;
1342 }
1343 if (tp.port < 8) {
1344 i = adap->chan_map[tp.port & 3];
1345 if (i >= MAX_NPORTS) {
1346 dev_err(adap->pdev_dev, "tracer %u is assigned "
1347 "to non-existing port\n", trcidx);
1348 return -EINVAL;
1349 }
1350 seq_printf(seq, "tracer is capturing %s %s, ",
1351 adap->port[i]->name, tp.port < 4 ? "Rx" : "Tx");
1352 } else
1353 seq_printf(seq, "tracer is capturing loopback %d, ",
1354 tp.port - 8);
1355 seq_printf(seq, "snap length: %u, min length: %u\n", tp.snap_len,
1356 tp.min_len);
1357 seq_printf(seq, "packets captured %smatch filter\n",
1358 tp.invert ? "do not " : "");
1359
1360 if (tp.skip_ofst) {
1361 seq_puts(seq, "filter pattern: ");
1362 for (i = 0; i < tp.skip_ofst * 2; i += 2)
1363 seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
1364 seq_putc(seq, '/');
1365 for (i = 0; i < tp.skip_ofst * 2; i += 2)
1366 seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
1367 seq_puts(seq, "@0\n");
1368 }
1369
1370 seq_puts(seq, "filter pattern: ");
1371 for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
1372 seq_printf(seq, "%08x%08x", tp.data[i], tp.data[i + 1]);
1373 seq_putc(seq, '/');
1374 for (i = tp.skip_ofst * 2; i < TRACE_LEN / 4; i += 2)
1375 seq_printf(seq, "%08x%08x", tp.mask[i], tp.mask[i + 1]);
1376 seq_printf(seq, "@%u\n", (tp.skip_ofst + tp.skip_len) * 8);
1377 return 0;
1378}
1379
1380static int mps_trc_open(struct inode *inode, struct file *file)
1381{
1382 return single_open(file, mps_trc_show, inode->i_private);
1383}
1384
1385static unsigned int xdigit2int(unsigned char c)
1386{
1387 return isdigit(c) ? c - '0' : tolower(c) - 'a' + 10;
1388}
1389
1390#define TRC_PORT_NONE 0xff
1391#define TRC_RSS_ENABLE 0x33
1392#define TRC_RSS_DISABLE 0x13
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411static ssize_t mps_trc_write(struct file *file, const char __user *buf,
1412 size_t count, loff_t *pos)
1413{
1414 int i, enable, ret;
1415 u32 *data, *mask;
1416 struct trace_params tp;
1417 const struct inode *ino;
1418 unsigned int trcidx;
1419 char *s, *p, *word, *end;
1420 struct adapter *adap;
1421 u32 j;
1422
1423 ino = file_inode(file);
1424 trcidx = (uintptr_t)ino->i_private & 3;
1425 adap = ino->i_private - trcidx;
1426
1427
1428
1429
1430 if (count > 1024)
1431 return -EFBIG;
1432 p = s = kzalloc(count + 1, GFP_USER);
1433 if (!s)
1434 return -ENOMEM;
1435 if (copy_from_user(s, buf, count)) {
1436 count = -EFAULT;
1437 goto out;
1438 }
1439
1440 if (s[count - 1] == '\n')
1441 s[count - 1] = '\0';
1442
1443 enable = strcmp("disable", s) != 0;
1444 if (!enable)
1445 goto apply;
1446
1447
1448 if (adap->trace_rss)
1449 t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_ENABLE);
1450 else
1451 t4_write_reg(adap, MPS_TRC_CFG_A, TRC_RSS_DISABLE);
1452
1453 memset(&tp, 0, sizeof(tp));
1454 tp.port = TRC_PORT_NONE;
1455 i = 0;
1456
1457 while (p) {
1458 while (isspace(*p))
1459 p++;
1460 word = strsep(&p, " ");
1461 if (!*word)
1462 break;
1463
1464 if (!strncmp(word, "qid=", 4)) {
1465 end = (char *)word + 4;
1466 ret = kstrtouint(end, 10, &j);
1467 if (ret)
1468 goto out;
1469 if (!adap->trace_rss) {
1470 t4_write_reg(adap, MPS_T5_TRC_RSS_CONTROL_A, j);
1471 continue;
1472 }
1473
1474 switch (trcidx) {
1475 case 0:
1476 t4_write_reg(adap, MPS_TRC_RSS_CONTROL_A, j);
1477 break;
1478 case 1:
1479 t4_write_reg(adap,
1480 MPS_TRC_FILTER1_RSS_CONTROL_A, j);
1481 break;
1482 case 2:
1483 t4_write_reg(adap,
1484 MPS_TRC_FILTER2_RSS_CONTROL_A, j);
1485 break;
1486 case 3:
1487 t4_write_reg(adap,
1488 MPS_TRC_FILTER3_RSS_CONTROL_A, j);
1489 break;
1490 }
1491 continue;
1492 }
1493 if (!strncmp(word, "snaplen=", 8)) {
1494 end = (char *)word + 8;
1495 ret = kstrtouint(end, 10, &j);
1496 if (ret || j > 9600) {
1497inval: count = -EINVAL;
1498 goto out;
1499 }
1500 tp.snap_len = j;
1501 continue;
1502 }
1503 if (!strncmp(word, "minlen=", 7)) {
1504 end = (char *)word + 7;
1505 ret = kstrtouint(end, 10, &j);
1506 if (ret || j > TFMINPKTSIZE_M)
1507 goto inval;
1508 tp.min_len = j;
1509 continue;
1510 }
1511 if (!strcmp(word, "not")) {
1512 tp.invert = !tp.invert;
1513 continue;
1514 }
1515 if (!strncmp(word, "loopback", 8) && tp.port == TRC_PORT_NONE) {
1516 if (word[8] < '0' || word[8] > '3' || word[9])
1517 goto inval;
1518 tp.port = word[8] - '0' + 8;
1519 continue;
1520 }
1521 if (!strncmp(word, "tx", 2) && tp.port == TRC_PORT_NONE) {
1522 if (word[2] < '0' || word[2] > '3' || word[3])
1523 goto inval;
1524 tp.port = word[2] - '0' + 4;
1525 if (adap->chan_map[tp.port & 3] >= MAX_NPORTS)
1526 goto inval;
1527 continue;
1528 }
1529 if (!strncmp(word, "rx", 2) && tp.port == TRC_PORT_NONE) {
1530 if (word[2] < '0' || word[2] > '3' || word[3])
1531 goto inval;
1532 tp.port = word[2] - '0';
1533 if (adap->chan_map[tp.port] >= MAX_NPORTS)
1534 goto inval;
1535 continue;
1536 }
1537 if (!isxdigit(*word))
1538 goto inval;
1539
1540
1541 if (i) {
1542 if (tp.skip_len)
1543 goto inval;
1544 tp.skip_ofst = i / 16;
1545 }
1546
1547 data = &tp.data[i / 8];
1548 mask = &tp.mask[i / 8];
1549 j = i;
1550
1551 while (isxdigit(*word)) {
1552 if (i >= TRACE_LEN * 2) {
1553 count = -EFBIG;
1554 goto out;
1555 }
1556 *data = (*data << 4) + xdigit2int(*word++);
1557 if (++i % 8 == 0)
1558 data++;
1559 }
1560 if (*word == '/') {
1561 word++;
1562 while (isxdigit(*word)) {
1563 if (j >= i)
1564 goto inval;
1565 *mask = (*mask << 4) + xdigit2int(*word++);
1566 if (++j % 8 == 0)
1567 mask++;
1568 }
1569 if (i != j)
1570 goto inval;
1571 } else {
1572 for ( ; i - j >= 8; j += 8)
1573 *mask++ = 0xffffffff;
1574 if (i % 8)
1575 *mask = (1 << (i % 8) * 4) - 1;
1576 }
1577 if (*word == '@') {
1578 end = (char *)word + 1;
1579 ret = kstrtouint(end, 10, &j);
1580 if (*end && *end != '\n')
1581 goto inval;
1582 if (j & 7)
1583 goto inval;
1584 j /= 8;
1585 if (j < tp.skip_ofst)
1586 goto inval;
1587 if (j - tp.skip_ofst > 31)
1588 goto inval;
1589 tp.skip_len = j - tp.skip_ofst;
1590 }
1591 if (i % 8) {
1592 *data <<= (8 - i % 8) * 4;
1593 *mask <<= (8 - i % 8) * 4;
1594 i = (i + 15) & ~15;
1595 }
1596 }
1597
1598 if (tp.port == TRC_PORT_NONE)
1599 goto inval;
1600
1601apply:
1602 i = t4_set_trace_filter(adap, &tp, trcidx, enable);
1603 if (i)
1604 count = i;
1605out:
1606 kfree(s);
1607 return count;
1608}
1609
1610static const struct file_operations mps_trc_debugfs_fops = {
1611 .owner = THIS_MODULE,
1612 .open = mps_trc_open,
1613 .read = seq_read,
1614 .llseek = seq_lseek,
1615 .release = single_release,
1616 .write = mps_trc_write
1617};
1618
1619static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
1620 loff_t *ppos)
1621{
1622 loff_t pos = *ppos;
1623 loff_t avail = file_inode(file)->i_size;
1624 struct adapter *adap = file->private_data;
1625
1626 if (pos < 0)
1627 return -EINVAL;
1628 if (pos >= avail)
1629 return 0;
1630 if (count > avail - pos)
1631 count = avail - pos;
1632
1633 while (count) {
1634 size_t len;
1635 int ret, ofst;
1636 u8 data[256];
1637
1638 ofst = pos & 3;
1639 len = min(count + ofst, sizeof(data));
1640 ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4,
1641 (u32 *)data, 1);
1642 if (ret)
1643 return ret;
1644
1645 len -= ofst;
1646 if (copy_to_user(buf, data + ofst, len))
1647 return -EFAULT;
1648
1649 buf += len;
1650 pos += len;
1651 count -= len;
1652 }
1653 count = pos - *ppos;
1654 *ppos = pos;
1655 return count;
1656}
1657
1658static const struct file_operations flash_debugfs_fops = {
1659 .owner = THIS_MODULE,
1660 .open = mem_open,
1661 .read = flash_read,
1662 .llseek = default_llseek,
1663};
1664
1665static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
1666{
1667 *mask = x | y;
1668 y = (__force u64)cpu_to_be64(y);
1669 memcpy(addr, (char *)&y + 2, ETH_ALEN);
1670}
1671
1672static int mps_tcam_show(struct seq_file *seq, void *v)
1673{
1674 struct adapter *adap = seq->private;
1675 unsigned int chip_ver = CHELSIO_CHIP_VERSION(adap->params.chip);
1676 if (v == SEQ_START_TOKEN) {
1677 if (chip_ver > CHELSIO_T5) {
1678 seq_puts(seq, "Idx Ethernet address Mask "
1679 " VNI Mask IVLAN Vld "
1680 "DIP_Hit Lookup Port "
1681 "Vld Ports PF VF "
1682 "Replication "
1683 " P0 P1 P2 P3 ML\n");
1684 } else {
1685 if (adap->params.arch.mps_rplc_size > 128)
1686 seq_puts(seq, "Idx Ethernet address Mask "
1687 "Vld Ports PF VF "
1688 "Replication "
1689 " P0 P1 P2 P3 ML\n");
1690 else
1691 seq_puts(seq, "Idx Ethernet address Mask "
1692 "Vld Ports PF VF Replication"
1693 " P0 P1 P2 P3 ML\n");
1694 }
1695 } else {
1696 u64 mask;
1697 u8 addr[ETH_ALEN];
1698 bool replicate, dip_hit = false, vlan_vld = false;
1699 unsigned int idx = (uintptr_t)v - 2;
1700 u64 tcamy, tcamx, val;
1701 u32 cls_lo, cls_hi, ctl, data2, vnix = 0, vniy = 0;
1702 u32 rplc[8] = {0};
1703 u8 lookup_type = 0, port_num = 0;
1704 u16 ivlan = 0;
1705
1706 if (chip_ver > CHELSIO_T5) {
1707
1708
1709
1710
1711
1712
1713 ctl = CTLCMDTYPE_V(0) | CTLXYBITSEL_V(0);
1714 if (idx < 256)
1715 ctl |= CTLTCAMINDEX_V(idx) | CTLTCAMSEL_V(0);
1716 else
1717 ctl |= CTLTCAMINDEX_V(idx - 256) |
1718 CTLTCAMSEL_V(1);
1719 t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
1720 val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
1721 tcamy = DMACH_G(val) << 32;
1722 tcamy |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
1723 data2 = t4_read_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A);
1724 lookup_type = DATALKPTYPE_G(data2);
1725
1726
1727
1728
1729 if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
1730
1731 vniy = (data2 & DATAVIDH2_F) |
1732 (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
1733 dip_hit = data2 & DATADIPHIT_F;
1734 } else {
1735 vlan_vld = data2 & DATAVIDH2_F;
1736 ivlan = VIDL_G(val);
1737 }
1738 port_num = DATAPORTNUM_G(data2);
1739
1740
1741 vnix = 0;
1742 ctl |= CTLXYBITSEL_V(1);
1743 t4_write_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A, ctl);
1744 val = t4_read_reg(adap, MPS_CLS_TCAM_DATA1_A);
1745 tcamx = DMACH_G(val) << 32;
1746 tcamx |= t4_read_reg(adap, MPS_CLS_TCAM_DATA0_A);
1747 data2 = t4_read_reg(adap, MPS_CLS_TCAM_DATA2_CTL_A);
1748 if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
1749
1750 vnix = (data2 & DATAVIDH2_F) |
1751 (DATAVIDH1_G(data2) << 16) | VIDL_G(val);
1752 }
1753 } else {
1754 tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx));
1755 tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx));
1756 }
1757
1758 cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx));
1759 cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx));
1760
1761 if (tcamx & tcamy) {
1762 seq_printf(seq, "%3u -\n", idx);
1763 goto out;
1764 }
1765
1766 rplc[0] = rplc[1] = rplc[2] = rplc[3] = 0;
1767 if (chip_ver > CHELSIO_T5)
1768 replicate = (cls_lo & T6_REPLICATE_F);
1769 else
1770 replicate = (cls_lo & REPLICATE_F);
1771
1772 if (replicate) {
1773 struct fw_ldst_cmd ldst_cmd;
1774 int ret;
1775 struct fw_ldst_mps_rplc mps_rplc;
1776 u32 ldst_addrspc;
1777
1778 memset(&ldst_cmd, 0, sizeof(ldst_cmd));
1779 ldst_addrspc =
1780 FW_LDST_CMD_ADDRSPACE_V(FW_LDST_ADDRSPC_MPS);
1781 ldst_cmd.op_to_addrspace =
1782 htonl(FW_CMD_OP_V(FW_LDST_CMD) |
1783 FW_CMD_REQUEST_F |
1784 FW_CMD_READ_F |
1785 ldst_addrspc);
1786 ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
1787 ldst_cmd.u.mps.rplc.fid_idx =
1788 htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) |
1789 FW_LDST_CMD_IDX_V(idx));
1790 ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd,
1791 sizeof(ldst_cmd), &ldst_cmd);
1792 if (ret)
1793 dev_warn(adap->pdev_dev, "Can't read MPS "
1794 "replication map for idx %d: %d\n",
1795 idx, -ret);
1796 else {
1797 mps_rplc = ldst_cmd.u.mps.rplc;
1798 rplc[0] = ntohl(mps_rplc.rplc31_0);
1799 rplc[1] = ntohl(mps_rplc.rplc63_32);
1800 rplc[2] = ntohl(mps_rplc.rplc95_64);
1801 rplc[3] = ntohl(mps_rplc.rplc127_96);
1802 if (adap->params.arch.mps_rplc_size > 128) {
1803 rplc[4] = ntohl(mps_rplc.rplc159_128);
1804 rplc[5] = ntohl(mps_rplc.rplc191_160);
1805 rplc[6] = ntohl(mps_rplc.rplc223_192);
1806 rplc[7] = ntohl(mps_rplc.rplc255_224);
1807 }
1808 }
1809 }
1810
1811 tcamxy2valmask(tcamx, tcamy, addr, &mask);
1812 if (chip_ver > CHELSIO_T5) {
1813
1814 if (lookup_type && (lookup_type != DATALKPTYPE_M)) {
1815 seq_printf(seq,
1816 "%3u %02x:%02x:%02x:%02x:%02x:%02x "
1817 "%012llx %06x %06x - - %3c"
1818 " 'I' %4x "
1819 "%3c %#x%4u%4d", idx, addr[0],
1820 addr[1], addr[2], addr[3],
1821 addr[4], addr[5],
1822 (unsigned long long)mask,
1823 vniy, (vnix | vniy),
1824 dip_hit ? 'Y' : 'N',
1825 port_num,
1826 (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
1827 PORTMAP_G(cls_hi),
1828 T6_PF_G(cls_lo),
1829 (cls_lo & T6_VF_VALID_F) ?
1830 T6_VF_G(cls_lo) : -1);
1831 } else {
1832 seq_printf(seq,
1833 "%3u %02x:%02x:%02x:%02x:%02x:%02x "
1834 "%012llx - - ",
1835 idx, addr[0], addr[1], addr[2],
1836 addr[3], addr[4], addr[5],
1837 (unsigned long long)mask);
1838
1839 if (vlan_vld)
1840 seq_printf(seq, "%4u Y ", ivlan);
1841 else
1842 seq_puts(seq, " - N ");
1843
1844 seq_printf(seq,
1845 "- %3c %4x %3c %#x%4u%4d",
1846 lookup_type ? 'I' : 'O', port_num,
1847 (cls_lo & T6_SRAM_VLD_F) ? 'Y' : 'N',
1848 PORTMAP_G(cls_hi),
1849 T6_PF_G(cls_lo),
1850 (cls_lo & T6_VF_VALID_F) ?
1851 T6_VF_G(cls_lo) : -1);
1852 }
1853 } else
1854 seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x "
1855 "%012llx%3c %#x%4u%4d",
1856 idx, addr[0], addr[1], addr[2], addr[3],
1857 addr[4], addr[5], (unsigned long long)mask,
1858 (cls_lo & SRAM_VLD_F) ? 'Y' : 'N',
1859 PORTMAP_G(cls_hi),
1860 PF_G(cls_lo),
1861 (cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1);
1862
1863 if (replicate) {
1864 if (adap->params.arch.mps_rplc_size > 128)
1865 seq_printf(seq, " %08x %08x %08x %08x "
1866 "%08x %08x %08x %08x",
1867 rplc[7], rplc[6], rplc[5], rplc[4],
1868 rplc[3], rplc[2], rplc[1], rplc[0]);
1869 else
1870 seq_printf(seq, " %08x %08x %08x %08x",
1871 rplc[3], rplc[2], rplc[1], rplc[0]);
1872 } else {
1873 if (adap->params.arch.mps_rplc_size > 128)
1874 seq_printf(seq, "%72c", ' ');
1875 else
1876 seq_printf(seq, "%36c", ' ');
1877 }
1878
1879 if (chip_ver > CHELSIO_T5)
1880 seq_printf(seq, "%4u%3u%3u%3u %#x\n",
1881 T6_SRAM_PRIO0_G(cls_lo),
1882 T6_SRAM_PRIO1_G(cls_lo),
1883 T6_SRAM_PRIO2_G(cls_lo),
1884 T6_SRAM_PRIO3_G(cls_lo),
1885 (cls_lo >> T6_MULTILISTEN0_S) & 0xf);
1886 else
1887 seq_printf(seq, "%4u%3u%3u%3u %#x\n",
1888 SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo),
1889 SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo),
1890 (cls_lo >> MULTILISTEN0_S) & 0xf);
1891 }
1892out: return 0;
1893}
1894
1895static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos)
1896{
1897 struct adapter *adap = seq->private;
1898 int max_mac_addr = is_t4(adap->params.chip) ?
1899 NUM_MPS_CLS_SRAM_L_INSTANCES :
1900 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
1901 return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL);
1902}
1903
1904static void *mps_tcam_start(struct seq_file *seq, loff_t *pos)
1905{
1906 return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN;
1907}
1908
1909static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos)
1910{
1911 ++*pos;
1912 return mps_tcam_get_idx(seq, *pos);
1913}
1914
1915static void mps_tcam_stop(struct seq_file *seq, void *v)
1916{
1917}
1918
1919static const struct seq_operations mps_tcam_seq_ops = {
1920 .start = mps_tcam_start,
1921 .next = mps_tcam_next,
1922 .stop = mps_tcam_stop,
1923 .show = mps_tcam_show
1924};
1925
1926static int mps_tcam_open(struct inode *inode, struct file *file)
1927{
1928 int res = seq_open(file, &mps_tcam_seq_ops);
1929
1930 if (!res) {
1931 struct seq_file *seq = file->private_data;
1932
1933 seq->private = inode->i_private;
1934 }
1935 return res;
1936}
1937
1938static const struct file_operations mps_tcam_debugfs_fops = {
1939 .owner = THIS_MODULE,
1940 .open = mps_tcam_open,
1941 .read = seq_read,
1942 .llseek = seq_lseek,
1943 .release = seq_release,
1944};
1945
1946
1947
1948static int sensors_show(struct seq_file *seq, void *v)
1949{
1950 struct adapter *adap = seq->private;
1951 u32 param[7], val[7];
1952 int ret;
1953
1954
1955
1956
1957 param[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
1958 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
1959 FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_TMP));
1960 param[1] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
1961 FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_DIAG) |
1962 FW_PARAMS_PARAM_Y_V(FW_PARAM_DEV_DIAG_VDD));
1963 ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 2,
1964 param, val);
1965
1966 if (ret < 0 || val[0] == 0)
1967 seq_puts(seq, "Temperature: <unknown>\n");
1968 else
1969 seq_printf(seq, "Temperature: %dC\n", val[0]);
1970
1971 if (ret < 0 || val[1] == 0)
1972 seq_puts(seq, "Core VDD: <unknown>\n");
1973 else
1974 seq_printf(seq, "Core VDD: %dmV\n", val[1]);
1975
1976 return 0;
1977}
1978DEFINE_SHOW_ATTRIBUTE(sensors);
1979
1980#if IS_ENABLED(CONFIG_IPV6)
1981DEFINE_SHOW_ATTRIBUTE(clip_tbl);
1982#endif
1983
1984
1985
1986
1987static int rss_show(struct seq_file *seq, void *v, int idx)
1988{
1989 u16 *entry = v;
1990
1991 seq_printf(seq, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
1992 idx * 8, entry[0], entry[1], entry[2], entry[3], entry[4],
1993 entry[5], entry[6], entry[7]);
1994 return 0;
1995}
1996
1997static int rss_open(struct inode *inode, struct file *file)
1998{
1999 struct adapter *adap = inode->i_private;
2000 int ret, nentries;
2001 struct seq_tab *p;
2002
2003 nentries = t4_chip_rss_size(adap);
2004 p = seq_open_tab(file, nentries / 8, 8 * sizeof(u16), 0, rss_show);
2005 if (!p)
2006 return -ENOMEM;
2007
2008 ret = t4_read_rss(adap, (u16 *)p->data);
2009 if (ret)
2010 seq_release_private(inode, file);
2011
2012 return ret;
2013}
2014
2015static const struct file_operations rss_debugfs_fops = {
2016 .owner = THIS_MODULE,
2017 .open = rss_open,
2018 .read = seq_read,
2019 .llseek = seq_lseek,
2020 .release = seq_release_private
2021};
2022
2023
2024
2025
2026
2027
2028
2029static const char *yesno(int x)
2030{
2031 static const char *yes = "yes";
2032 static const char *no = "no";
2033
2034 return x ? yes : no;
2035}
2036
2037static int rss_config_show(struct seq_file *seq, void *v)
2038{
2039 struct adapter *adapter = seq->private;
2040 static const char * const keymode[] = {
2041 "global",
2042 "global and per-VF scramble",
2043 "per-PF and per-VF scramble",
2044 "per-VF and per-VF scramble",
2045 };
2046 u32 rssconf;
2047
2048 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_A);
2049 seq_printf(seq, "TP_RSS_CONFIG: %#x\n", rssconf);
2050 seq_printf(seq, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf &
2051 TNL4TUPENIPV6_F));
2052 seq_printf(seq, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf &
2053 TNL2TUPENIPV6_F));
2054 seq_printf(seq, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf &
2055 TNL4TUPENIPV4_F));
2056 seq_printf(seq, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf &
2057 TNL2TUPENIPV4_F));
2058 seq_printf(seq, " TnlTcpSel: %3s\n", yesno(rssconf & TNLTCPSEL_F));
2059 seq_printf(seq, " TnlIp6Sel: %3s\n", yesno(rssconf & TNLIP6SEL_F));
2060 seq_printf(seq, " TnlVrtSel: %3s\n", yesno(rssconf & TNLVRTSEL_F));
2061 seq_printf(seq, " TnlMapEn: %3s\n", yesno(rssconf & TNLMAPEN_F));
2062 seq_printf(seq, " OfdHashSave: %3s\n", yesno(rssconf &
2063 OFDHASHSAVE_F));
2064 seq_printf(seq, " OfdVrtSel: %3s\n", yesno(rssconf & OFDVRTSEL_F));
2065 seq_printf(seq, " OfdMapEn: %3s\n", yesno(rssconf & OFDMAPEN_F));
2066 seq_printf(seq, " OfdLkpEn: %3s\n", yesno(rssconf & OFDLKPEN_F));
2067 seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
2068 SYN4TUPENIPV6_F));
2069 seq_printf(seq, " Syn2TupEnIpv6: %3s\n", yesno(rssconf &
2070 SYN2TUPENIPV6_F));
2071 seq_printf(seq, " Syn4TupEnIpv4: %3s\n", yesno(rssconf &
2072 SYN4TUPENIPV4_F));
2073 seq_printf(seq, " Syn2TupEnIpv4: %3s\n", yesno(rssconf &
2074 SYN2TUPENIPV4_F));
2075 seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
2076 SYN4TUPENIPV6_F));
2077 seq_printf(seq, " SynIp6Sel: %3s\n", yesno(rssconf & SYNIP6SEL_F));
2078 seq_printf(seq, " SynVrt6Sel: %3s\n", yesno(rssconf & SYNVRTSEL_F));
2079 seq_printf(seq, " SynMapEn: %3s\n", yesno(rssconf & SYNMAPEN_F));
2080 seq_printf(seq, " SynLkpEn: %3s\n", yesno(rssconf & SYNLKPEN_F));
2081 seq_printf(seq, " ChnEn: %3s\n", yesno(rssconf &
2082 CHANNELENABLE_F));
2083 seq_printf(seq, " PrtEn: %3s\n", yesno(rssconf &
2084 PORTENABLE_F));
2085 seq_printf(seq, " TnlAllLkp: %3s\n", yesno(rssconf &
2086 TNLALLLOOKUP_F));
2087 seq_printf(seq, " VrtEn: %3s\n", yesno(rssconf &
2088 VIRTENABLE_F));
2089 seq_printf(seq, " CngEn: %3s\n", yesno(rssconf &
2090 CONGESTIONENABLE_F));
2091 seq_printf(seq, " HashToeplitz: %3s\n", yesno(rssconf &
2092 HASHTOEPLITZ_F));
2093 seq_printf(seq, " Udp4En: %3s\n", yesno(rssconf & UDPENABLE_F));
2094 seq_printf(seq, " Disable: %3s\n", yesno(rssconf & DISABLE_F));
2095
2096 seq_puts(seq, "\n");
2097
2098 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_TNL_A);
2099 seq_printf(seq, "TP_RSS_CONFIG_TNL: %#x\n", rssconf);
2100 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
2101 seq_printf(seq, " MaskFilter: %3d\n", MASKFILTER_G(rssconf));
2102 if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
2103 seq_printf(seq, " HashAll: %3s\n",
2104 yesno(rssconf & HASHALL_F));
2105 seq_printf(seq, " HashEth: %3s\n",
2106 yesno(rssconf & HASHETH_F));
2107 }
2108 seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
2109
2110 seq_puts(seq, "\n");
2111
2112 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_OFD_A);
2113 seq_printf(seq, "TP_RSS_CONFIG_OFD: %#x\n", rssconf);
2114 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
2115 seq_printf(seq, " RRCplMapEn: %3s\n", yesno(rssconf &
2116 RRCPLMAPEN_F));
2117 seq_printf(seq, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf));
2118
2119 seq_puts(seq, "\n");
2120
2121 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_SYN_A);
2122 seq_printf(seq, "TP_RSS_CONFIG_SYN: %#x\n", rssconf);
2123 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
2124 seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
2125
2126 seq_puts(seq, "\n");
2127
2128 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_VRT_A);
2129 seq_printf(seq, "TP_RSS_CONFIG_VRT: %#x\n", rssconf);
2130 if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
2131 seq_printf(seq, " KeyWrAddrX: %3d\n",
2132 KEYWRADDRX_G(rssconf));
2133 seq_printf(seq, " KeyExtend: %3s\n",
2134 yesno(rssconf & KEYEXTEND_F));
2135 }
2136 seq_printf(seq, " VfRdRg: %3s\n", yesno(rssconf & VFRDRG_F));
2137 seq_printf(seq, " VfRdEn: %3s\n", yesno(rssconf & VFRDEN_F));
2138 seq_printf(seq, " VfPerrEn: %3s\n", yesno(rssconf & VFPERREN_F));
2139 seq_printf(seq, " KeyPerrEn: %3s\n", yesno(rssconf & KEYPERREN_F));
2140 seq_printf(seq, " DisVfVlan: %3s\n", yesno(rssconf &
2141 DISABLEVLAN_F));
2142 seq_printf(seq, " EnUpSwt: %3s\n", yesno(rssconf & ENABLEUP0_F));
2143 seq_printf(seq, " HashDelay: %3d\n", HASHDELAY_G(rssconf));
2144 if (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5)
2145 seq_printf(seq, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf));
2146 else
2147 seq_printf(seq, " VfWrAddr: %3d\n",
2148 T6_VFWRADDR_G(rssconf));
2149 seq_printf(seq, " KeyMode: %s\n", keymode[KEYMODE_G(rssconf)]);
2150 seq_printf(seq, " VfWrEn: %3s\n", yesno(rssconf & VFWREN_F));
2151 seq_printf(seq, " KeyWrEn: %3s\n", yesno(rssconf & KEYWREN_F));
2152 seq_printf(seq, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf));
2153
2154 seq_puts(seq, "\n");
2155
2156 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_CNG_A);
2157 seq_printf(seq, "TP_RSS_CONFIG_CNG: %#x\n", rssconf);
2158 seq_printf(seq, " ChnCount3: %3s\n", yesno(rssconf & CHNCOUNT3_F));
2159 seq_printf(seq, " ChnCount2: %3s\n", yesno(rssconf & CHNCOUNT2_F));
2160 seq_printf(seq, " ChnCount1: %3s\n", yesno(rssconf & CHNCOUNT1_F));
2161 seq_printf(seq, " ChnCount0: %3s\n", yesno(rssconf & CHNCOUNT0_F));
2162 seq_printf(seq, " ChnUndFlow3: %3s\n", yesno(rssconf &
2163 CHNUNDFLOW3_F));
2164 seq_printf(seq, " ChnUndFlow2: %3s\n", yesno(rssconf &
2165 CHNUNDFLOW2_F));
2166 seq_printf(seq, " ChnUndFlow1: %3s\n", yesno(rssconf &
2167 CHNUNDFLOW1_F));
2168 seq_printf(seq, " ChnUndFlow0: %3s\n", yesno(rssconf &
2169 CHNUNDFLOW0_F));
2170 seq_printf(seq, " RstChn3: %3s\n", yesno(rssconf & RSTCHN3_F));
2171 seq_printf(seq, " RstChn2: %3s\n", yesno(rssconf & RSTCHN2_F));
2172 seq_printf(seq, " RstChn1: %3s\n", yesno(rssconf & RSTCHN1_F));
2173 seq_printf(seq, " RstChn0: %3s\n", yesno(rssconf & RSTCHN0_F));
2174 seq_printf(seq, " UpdVld: %3s\n", yesno(rssconf & UPDVLD_F));
2175 seq_printf(seq, " Xoff: %3s\n", yesno(rssconf & XOFF_F));
2176 seq_printf(seq, " UpdChn3: %3s\n", yesno(rssconf & UPDCHN3_F));
2177 seq_printf(seq, " UpdChn2: %3s\n", yesno(rssconf & UPDCHN2_F));
2178 seq_printf(seq, " UpdChn1: %3s\n", yesno(rssconf & UPDCHN1_F));
2179 seq_printf(seq, " UpdChn0: %3s\n", yesno(rssconf & UPDCHN0_F));
2180 seq_printf(seq, " Queue: %3d\n", QUEUE_G(rssconf));
2181
2182 return 0;
2183}
2184DEFINE_SHOW_ATTRIBUTE(rss_config);
2185
2186
2187
2188
2189static int rss_key_show(struct seq_file *seq, void *v)
2190{
2191 u32 key[10];
2192
2193 t4_read_rss_key(seq->private, key, true);
2194 seq_printf(seq, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
2195 key[9], key[8], key[7], key[6], key[5], key[4], key[3],
2196 key[2], key[1], key[0]);
2197 return 0;
2198}
2199
2200static int rss_key_open(struct inode *inode, struct file *file)
2201{
2202 return single_open(file, rss_key_show, inode->i_private);
2203}
2204
2205static ssize_t rss_key_write(struct file *file, const char __user *buf,
2206 size_t count, loff_t *pos)
2207{
2208 int i, j;
2209 u32 key[10];
2210 char s[100], *p;
2211 struct adapter *adap = file_inode(file)->i_private;
2212
2213 if (count > sizeof(s) - 1)
2214 return -EINVAL;
2215 if (copy_from_user(s, buf, count))
2216 return -EFAULT;
2217 for (i = count; i > 0 && isspace(s[i - 1]); i--)
2218 ;
2219 s[i] = '\0';
2220
2221 for (p = s, i = 9; i >= 0; i--) {
2222 key[i] = 0;
2223 for (j = 0; j < 8; j++, p++) {
2224 if (!isxdigit(*p))
2225 return -EINVAL;
2226 key[i] = (key[i] << 4) | hex2val(*p);
2227 }
2228 }
2229
2230 t4_write_rss_key(adap, key, -1, true);
2231 return count;
2232}
2233
2234static const struct file_operations rss_key_debugfs_fops = {
2235 .owner = THIS_MODULE,
2236 .open = rss_key_open,
2237 .read = seq_read,
2238 .llseek = seq_lseek,
2239 .release = single_release,
2240 .write = rss_key_write
2241};
2242
2243
2244
2245
2246struct rss_pf_conf {
2247 u32 rss_pf_map;
2248 u32 rss_pf_mask;
2249 u32 rss_pf_config;
2250};
2251
2252static int rss_pf_config_show(struct seq_file *seq, void *v, int idx)
2253{
2254 struct rss_pf_conf *pfconf;
2255
2256 if (v == SEQ_START_TOKEN) {
2257
2258 pfconf = seq->private + offsetof(struct seq_tab, data);
2259 seq_printf(seq, "PF Map Index Size = %d\n\n",
2260 LKPIDXSIZE_G(pfconf->rss_pf_map));
2261
2262 seq_puts(seq, " RSS PF VF Hash Tuple Enable Default\n");
2263 seq_puts(seq, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
2264 seq_puts(seq, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
2265 } else {
2266 #define G_PFnLKPIDX(map, n) \
2267 (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
2268 #define G_PFnMSKSIZE(mask, n) \
2269 (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
2270
2271 pfconf = v;
2272 seq_printf(seq, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
2273 idx,
2274 yesno(pfconf->rss_pf_config & MAPENABLE_F),
2275 yesno(pfconf->rss_pf_config & CHNENABLE_F),
2276 yesno(pfconf->rss_pf_config & PRTENABLE_F),
2277 G_PFnLKPIDX(pfconf->rss_pf_map, idx),
2278 G_PFnMSKSIZE(pfconf->rss_pf_mask, idx),
2279 IVFWIDTH_G(pfconf->rss_pf_config),
2280 yesno(pfconf->rss_pf_config & IP6FOURTUPEN_F),
2281 yesno(pfconf->rss_pf_config & IP6TWOTUPEN_F),
2282 yesno(pfconf->rss_pf_config & IP4FOURTUPEN_F),
2283 yesno(pfconf->rss_pf_config & IP4TWOTUPEN_F),
2284 yesno(pfconf->rss_pf_config & UDPFOURTUPEN_F),
2285 CH1DEFAULTQUEUE_G(pfconf->rss_pf_config),
2286 CH0DEFAULTQUEUE_G(pfconf->rss_pf_config));
2287
2288 #undef G_PFnLKPIDX
2289 #undef G_PFnMSKSIZE
2290 }
2291 return 0;
2292}
2293
2294static int rss_pf_config_open(struct inode *inode, struct file *file)
2295{
2296 struct adapter *adapter = inode->i_private;
2297 struct seq_tab *p;
2298 u32 rss_pf_map, rss_pf_mask;
2299 struct rss_pf_conf *pfconf;
2300 int pf;
2301
2302 p = seq_open_tab(file, 8, sizeof(*pfconf), 1, rss_pf_config_show);
2303 if (!p)
2304 return -ENOMEM;
2305
2306 pfconf = (struct rss_pf_conf *)p->data;
2307 rss_pf_map = t4_read_rss_pf_map(adapter, true);
2308 rss_pf_mask = t4_read_rss_pf_mask(adapter, true);
2309 for (pf = 0; pf < 8; pf++) {
2310 pfconf[pf].rss_pf_map = rss_pf_map;
2311 pfconf[pf].rss_pf_mask = rss_pf_mask;
2312 t4_read_rss_pf_config(adapter, pf, &pfconf[pf].rss_pf_config,
2313 true);
2314 }
2315 return 0;
2316}
2317
2318static const struct file_operations rss_pf_config_debugfs_fops = {
2319 .owner = THIS_MODULE,
2320 .open = rss_pf_config_open,
2321 .read = seq_read,
2322 .llseek = seq_lseek,
2323 .release = seq_release_private
2324};
2325
2326
2327
2328
2329struct rss_vf_conf {
2330 u32 rss_vf_vfl;
2331 u32 rss_vf_vfh;
2332};
2333
2334static int rss_vf_config_show(struct seq_file *seq, void *v, int idx)
2335{
2336 if (v == SEQ_START_TOKEN) {
2337 seq_puts(seq, " RSS Hash Tuple Enable\n");
2338 seq_puts(seq, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
2339 seq_puts(seq, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
2340 } else {
2341 struct rss_vf_conf *vfconf = v;
2342
2343 seq_printf(seq, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
2344 idx,
2345 yesno(vfconf->rss_vf_vfh & VFCHNEN_F),
2346 yesno(vfconf->rss_vf_vfh & VFPRTEN_F),
2347 VFLKPIDX_G(vfconf->rss_vf_vfh),
2348 yesno(vfconf->rss_vf_vfh & VFVLNEX_F),
2349 yesno(vfconf->rss_vf_vfh & VFUPEN_F),
2350 yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
2351 yesno(vfconf->rss_vf_vfh & VFIP6TWOTUPEN_F),
2352 yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
2353 yesno(vfconf->rss_vf_vfh & VFIP4TWOTUPEN_F),
2354 yesno(vfconf->rss_vf_vfh & ENABLEUDPHASH_F),
2355 DEFAULTQUEUE_G(vfconf->rss_vf_vfh),
2356 KEYINDEX_G(vfconf->rss_vf_vfh),
2357 vfconf->rss_vf_vfl);
2358 }
2359 return 0;
2360}
2361
2362static int rss_vf_config_open(struct inode *inode, struct file *file)
2363{
2364 struct adapter *adapter = inode->i_private;
2365 struct seq_tab *p;
2366 struct rss_vf_conf *vfconf;
2367 int vf, vfcount = adapter->params.arch.vfcount;
2368
2369 p = seq_open_tab(file, vfcount, sizeof(*vfconf), 1, rss_vf_config_show);
2370 if (!p)
2371 return -ENOMEM;
2372
2373 vfconf = (struct rss_vf_conf *)p->data;
2374 for (vf = 0; vf < vfcount; vf++) {
2375 t4_read_rss_vf_config(adapter, vf, &vfconf[vf].rss_vf_vfl,
2376 &vfconf[vf].rss_vf_vfh, true);
2377 }
2378 return 0;
2379}
2380
2381static const struct file_operations rss_vf_config_debugfs_fops = {
2382 .owner = THIS_MODULE,
2383 .open = rss_vf_config_open,
2384 .read = seq_read,
2385 .llseek = seq_lseek,
2386 .release = seq_release_private
2387};
2388
2389#ifdef CONFIG_CHELSIO_T4_DCB
2390extern char *dcb_ver_array[];
2391
2392
2393
2394static int dcb_info_show(struct seq_file *seq, void *v)
2395{
2396 struct adapter *adap = seq->private;
2397
2398 if (v == SEQ_START_TOKEN) {
2399 seq_puts(seq, "Data Center Bridging Information\n");
2400 } else {
2401 int port = (uintptr_t)v - 2;
2402 struct net_device *dev = adap->port[port];
2403 struct port_info *pi = netdev2pinfo(dev);
2404 struct port_dcb_info *dcb = &pi->dcb;
2405
2406 seq_puts(seq, "\n");
2407 seq_printf(seq, "Port: %d (DCB negotiated: %s)\n",
2408 port,
2409 cxgb4_dcb_enabled(dev) ? "yes" : "no");
2410
2411 if (cxgb4_dcb_enabled(dev))
2412 seq_printf(seq, "[ DCBx Version %s ]\n",
2413 dcb_ver_array[dcb->dcb_version]);
2414
2415 if (dcb->msgs) {
2416 int i;
2417
2418 seq_puts(seq, "\n Index\t\t\t :\t");
2419 for (i = 0; i < 8; i++)
2420 seq_printf(seq, " %3d", i);
2421 seq_puts(seq, "\n\n");
2422 }
2423
2424 if (dcb->msgs & CXGB4_DCB_FW_PGID) {
2425 int prio, pgid;
2426
2427 seq_puts(seq, " Priority Group IDs\t :\t");
2428 for (prio = 0; prio < 8; prio++) {
2429 pgid = (dcb->pgid >> 4 * (7 - prio)) & 0xf;
2430 seq_printf(seq, " %3d", pgid);
2431 }
2432 seq_puts(seq, "\n");
2433 }
2434
2435 if (dcb->msgs & CXGB4_DCB_FW_PGRATE) {
2436 int pg;
2437
2438 seq_puts(seq, " Priority Group BW(%)\t :\t");
2439 for (pg = 0; pg < 8; pg++)
2440 seq_printf(seq, " %3d", dcb->pgrate[pg]);
2441 seq_puts(seq, "\n");
2442
2443 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
2444 seq_puts(seq, " TSA Algorithm\t\t :\t");
2445 for (pg = 0; pg < 8; pg++)
2446 seq_printf(seq, " %3d", dcb->tsa[pg]);
2447 seq_puts(seq, "\n");
2448 }
2449
2450 seq_printf(seq, " Max PG Traffic Classes [%3d ]\n",
2451 dcb->pg_num_tcs_supported);
2452
2453 seq_puts(seq, "\n");
2454 }
2455
2456 if (dcb->msgs & CXGB4_DCB_FW_PRIORATE) {
2457 int prio;
2458
2459 seq_puts(seq, " Priority Rate\t:\t");
2460 for (prio = 0; prio < 8; prio++)
2461 seq_printf(seq, " %3d", dcb->priorate[prio]);
2462 seq_puts(seq, "\n");
2463 }
2464
2465 if (dcb->msgs & CXGB4_DCB_FW_PFC) {
2466 int prio;
2467
2468 seq_puts(seq, " Priority Flow Control :\t");
2469 for (prio = 0; prio < 8; prio++) {
2470 int pfcen = (dcb->pfcen >> 1 * (7 - prio))
2471 & 0x1;
2472 seq_printf(seq, " %3d", pfcen);
2473 }
2474 seq_puts(seq, "\n");
2475
2476 seq_printf(seq, " Max PFC Traffic Classes [%3d ]\n",
2477 dcb->pfc_num_tcs_supported);
2478
2479 seq_puts(seq, "\n");
2480 }
2481
2482 if (dcb->msgs & CXGB4_DCB_FW_APP_ID) {
2483 int app, napps;
2484
2485 seq_puts(seq, " Application Information:\n");
2486 seq_puts(seq, " App Priority Selection Protocol\n");
2487 seq_puts(seq, " Index Map Field ID\n");
2488 for (app = 0, napps = 0;
2489 app < CXGB4_MAX_DCBX_APP_SUPPORTED; app++) {
2490 struct app_priority *ap;
2491 static const char * const sel_names[] = {
2492 "Ethertype",
2493 "Socket TCP",
2494 "Socket UDP",
2495 "Socket All",
2496 };
2497 const char *sel_name;
2498
2499 ap = &dcb->app_priority[app];
2500
2501 if (ap->protocolid == 0)
2502 continue;
2503 napps++;
2504
2505 if (ap->sel_field < ARRAY_SIZE(sel_names))
2506 sel_name = sel_names[ap->sel_field];
2507 else
2508 sel_name = "UNKNOWN";
2509
2510 seq_printf(seq, " %3d %#04x %-10s (%d) %#06x (%d)\n",
2511 app,
2512 ap->user_prio_map,
2513 sel_name, ap->sel_field,
2514 ap->protocolid, ap->protocolid);
2515 }
2516 if (napps == 0)
2517 seq_puts(seq, " --- None ---\n");
2518 }
2519 }
2520 return 0;
2521}
2522
2523static inline void *dcb_info_get_idx(struct adapter *adap, loff_t pos)
2524{
2525 return (pos <= adap->params.nports
2526 ? (void *)((uintptr_t)pos + 1)
2527 : NULL);
2528}
2529
2530static void *dcb_info_start(struct seq_file *seq, loff_t *pos)
2531{
2532 struct adapter *adap = seq->private;
2533
2534 return (*pos
2535 ? dcb_info_get_idx(adap, *pos)
2536 : SEQ_START_TOKEN);
2537}
2538
2539static void dcb_info_stop(struct seq_file *seq, void *v)
2540{
2541}
2542
2543static void *dcb_info_next(struct seq_file *seq, void *v, loff_t *pos)
2544{
2545 struct adapter *adap = seq->private;
2546
2547 (*pos)++;
2548 return dcb_info_get_idx(adap, *pos);
2549}
2550
2551static const struct seq_operations dcb_info_seq_ops = {
2552 .start = dcb_info_start,
2553 .next = dcb_info_next,
2554 .stop = dcb_info_stop,
2555 .show = dcb_info_show
2556};
2557
2558static int dcb_info_open(struct inode *inode, struct file *file)
2559{
2560 int res = seq_open(file, &dcb_info_seq_ops);
2561
2562 if (!res) {
2563 struct seq_file *seq = file->private_data;
2564
2565 seq->private = inode->i_private;
2566 }
2567 return res;
2568}
2569
2570static const struct file_operations dcb_info_debugfs_fops = {
2571 .owner = THIS_MODULE,
2572 .open = dcb_info_open,
2573 .read = seq_read,
2574 .llseek = seq_lseek,
2575 .release = seq_release,
2576};
2577#endif
2578
2579static int resources_show(struct seq_file *seq, void *v)
2580{
2581 struct adapter *adapter = seq->private;
2582 struct pf_resources *pfres = &adapter->params.pfres;
2583
2584 #define S(desc, fmt, var) \
2585 seq_printf(seq, "%-60s " fmt "\n", \
2586 desc " (" #var "):", pfres->var)
2587
2588 S("Virtual Interfaces", "%d", nvi);
2589 S("Egress Queues", "%d", neq);
2590 S("Ethernet Control", "%d", nethctrl);
2591 S("Ingress Queues/w Free Lists/Interrupts", "%d", niqflint);
2592 S("Ingress Queues", "%d", niq);
2593 S("Traffic Class", "%d", tc);
2594 S("Port Access Rights Mask", "%#x", pmask);
2595 S("MAC Address Filters", "%d", nexactf);
2596 S("Firmware Command Read Capabilities", "%#x", r_caps);
2597 S("Firmware Command Write/Execute Capabilities", "%#x", wx_caps);
2598
2599 #undef S
2600
2601 return 0;
2602}
2603DEFINE_SHOW_ATTRIBUTE(resources);
2604
2605
2606
2607
2608
2609
2610static inline struct port_info *ethqset2pinfo(struct adapter *adap, int qset)
2611{
2612 int pidx;
2613
2614 for_each_port(adap, pidx) {
2615 struct port_info *pi = adap2pinfo(adap, pidx);
2616
2617 if (qset >= pi->first_qset &&
2618 qset < pi->first_qset + pi->nqsets)
2619 return pi;
2620 }
2621
2622
2623 BUG();
2624 return NULL;
2625}
2626
2627static int sge_qinfo_uld_txq_entries(const struct adapter *adap, int uld)
2628{
2629 const struct sge_uld_txq_info *utxq_info = adap->sge.uld_txq_info[uld];
2630
2631 if (!utxq_info)
2632 return 0;
2633
2634 return DIV_ROUND_UP(utxq_info->ntxq, 4);
2635}
2636
2637static int sge_qinfo_uld_rspq_entries(const struct adapter *adap, int uld,
2638 bool ciq)
2639{
2640 const struct sge_uld_rxq_info *urxq_info = adap->sge.uld_rxq_info[uld];
2641
2642 if (!urxq_info)
2643 return 0;
2644
2645 return ciq ? DIV_ROUND_UP(urxq_info->nciq, 4) :
2646 DIV_ROUND_UP(urxq_info->nrxq, 4);
2647}
2648
2649static int sge_qinfo_uld_rxq_entries(const struct adapter *adap, int uld)
2650{
2651 return sge_qinfo_uld_rspq_entries(adap, uld, false);
2652}
2653
2654static int sge_qinfo_uld_ciq_entries(const struct adapter *adap, int uld)
2655{
2656 return sge_qinfo_uld_rspq_entries(adap, uld, true);
2657}
2658
2659static int sge_qinfo_show(struct seq_file *seq, void *v)
2660{
2661 int eth_entries, ctrl_entries, eohw_entries = 0, eosw_entries = 0;
2662 int uld_rxq_entries[CXGB4_ULD_MAX] = { 0 };
2663 int uld_ciq_entries[CXGB4_ULD_MAX] = { 0 };
2664 int uld_txq_entries[CXGB4_TX_MAX] = { 0 };
2665 const struct sge_uld_txq_info *utxq_info;
2666 const struct sge_uld_rxq_info *urxq_info;
2667 struct cxgb4_tc_port_mqprio *port_mqprio;
2668 struct adapter *adap = seq->private;
2669 int i, j, n, r = (uintptr_t)v - 1;
2670 struct sge *s = &adap->sge;
2671
2672 eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4);
2673 ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4);
2674
2675 if (r)
2676 seq_putc(seq, '\n');
2677
2678#define S3(fmt_spec, s, v) \
2679do { \
2680 seq_printf(seq, "%-12s", s); \
2681 for (i = 0; i < n; ++i) \
2682 seq_printf(seq, " %16" fmt_spec, v); \
2683 seq_putc(seq, '\n'); \
2684} while (0)
2685#define S(s, v) S3("s", s, v)
2686#define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
2687#define T(s, v) S3("u", s, tx[i].v)
2688#define TL(s, v) T3("lu", s, v)
2689#define R3(fmt_spec, s, v) S3(fmt_spec, s, rx[i].v)
2690#define R(s, v) S3("u", s, rx[i].v)
2691#define RL(s, v) R3("lu", s, v)
2692
2693 if (r < eth_entries) {
2694 int base_qset = r * 4;
2695 const struct sge_eth_rxq *rx = &s->ethrxq[base_qset];
2696 const struct sge_eth_txq *tx = &s->ethtxq[base_qset];
2697
2698 n = min(4, s->ethqsets - 4 * r);
2699
2700 S("QType:", "Ethernet");
2701 S("Interface:",
2702 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2703 T("TxQ ID:", q.cntxt_id);
2704 T("TxQ size:", q.size);
2705 T("TxQ inuse:", q.in_use);
2706 T("TxQ CIDX:", q.cidx);
2707 T("TxQ PIDX:", q.pidx);
2708#ifdef CONFIG_CHELSIO_T4_DCB
2709 T("DCB Prio:", dcb_prio);
2710 S3("u", "DCB PGID:",
2711 (ethqset2pinfo(adap, base_qset + i)->dcb.pgid >>
2712 4*(7-tx[i].dcb_prio)) & 0xf);
2713 S3("u", "DCB PFC:",
2714 (ethqset2pinfo(adap, base_qset + i)->dcb.pfcen >>
2715 1*(7-tx[i].dcb_prio)) & 0x1);
2716#endif
2717 R("RspQ ID:", rspq.abs_id);
2718 R("RspQ size:", rspq.size);
2719 R("RspQE size:", rspq.iqe_len);
2720 R("RspQ CIDX:", rspq.cidx);
2721 R("RspQ Gen:", rspq.gen);
2722 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2723 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2724 R("FL ID:", fl.cntxt_id);
2725 R("FL size:", fl.size - 8);
2726 R("FL pend:", fl.pend_cred);
2727 R("FL avail:", fl.avail);
2728 R("FL PIDX:", fl.pidx);
2729 R("FL CIDX:", fl.cidx);
2730 RL("RxPackets:", stats.pkts);
2731 RL("RxCSO:", stats.rx_cso);
2732 RL("VLANxtract:", stats.vlan_ex);
2733 RL("LROmerged:", stats.lro_merged);
2734 RL("LROpackets:", stats.lro_pkts);
2735 RL("RxDrops:", stats.rx_drops);
2736 RL("RxBadPkts:", stats.bad_rx_pkts);
2737 TL("TSO:", tso);
2738 TL("USO:", uso);
2739 TL("TxCSO:", tx_cso);
2740 TL("VLANins:", vlan_ins);
2741 TL("TxQFull:", q.stops);
2742 TL("TxQRestarts:", q.restarts);
2743 TL("TxMapErr:", mapping_err);
2744 RL("FLAllocErr:", fl.alloc_failed);
2745 RL("FLLrgAlcErr:", fl.large_alloc_failed);
2746 RL("FLMapErr:", fl.mapping_err);
2747 RL("FLLow:", fl.low);
2748 RL("FLStarving:", fl.starving);
2749
2750 goto out;
2751 }
2752
2753 r -= eth_entries;
2754 if (!adap->tc_mqprio)
2755 goto skip_mqprio;
2756
2757 mutex_lock(&adap->tc_mqprio->mqprio_mutex);
2758 if (!refcount_read(&adap->tc_mqprio->refcnt)) {
2759 mutex_unlock(&adap->tc_mqprio->mqprio_mutex);
2760 goto skip_mqprio;
2761 }
2762
2763 eohw_entries = DIV_ROUND_UP(adap->sge.eoqsets, 4);
2764 if (r < eohw_entries) {
2765 int base_qset = r * 4;
2766 const struct sge_ofld_rxq *rx = &s->eohw_rxq[base_qset];
2767 const struct sge_eohw_txq *tx = &s->eohw_txq[base_qset];
2768
2769 n = min(4, s->eoqsets - 4 * r);
2770
2771 S("QType:", "ETHOFLD");
2772 S("Interface:",
2773 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2774 T("TxQ ID:", q.cntxt_id);
2775 T("TxQ size:", q.size);
2776 T("TxQ inuse:", q.in_use);
2777 T("TxQ CIDX:", q.cidx);
2778 T("TxQ PIDX:", q.pidx);
2779 R("RspQ ID:", rspq.abs_id);
2780 R("RspQ size:", rspq.size);
2781 R("RspQE size:", rspq.iqe_len);
2782 R("RspQ CIDX:", rspq.cidx);
2783 R("RspQ Gen:", rspq.gen);
2784 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2785 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2786 R("FL ID:", fl.cntxt_id);
2787 S3("u", "FL size:", rx->fl.size ? rx->fl.size - 8 : 0);
2788 R("FL pend:", fl.pend_cred);
2789 R("FL avail:", fl.avail);
2790 R("FL PIDX:", fl.pidx);
2791 R("FL CIDX:", fl.cidx);
2792 RL("RxPackets:", stats.pkts);
2793 RL("RxImm:", stats.imm);
2794 RL("RxAN", stats.an);
2795 RL("RxNoMem", stats.nomem);
2796 TL("TSO:", tso);
2797 TL("USO:", uso);
2798 TL("TxCSO:", tx_cso);
2799 TL("VLANins:", vlan_ins);
2800 TL("TxQFull:", q.stops);
2801 TL("TxQRestarts:", q.restarts);
2802 TL("TxMapErr:", mapping_err);
2803 RL("FLAllocErr:", fl.alloc_failed);
2804 RL("FLLrgAlcErr:", fl.large_alloc_failed);
2805 RL("FLMapErr:", fl.mapping_err);
2806 RL("FLLow:", fl.low);
2807 RL("FLStarving:", fl.starving);
2808
2809 mutex_unlock(&adap->tc_mqprio->mqprio_mutex);
2810 goto out;
2811 }
2812
2813 r -= eohw_entries;
2814 for (j = 0; j < adap->params.nports; j++) {
2815 int entries;
2816 u8 tc;
2817
2818 port_mqprio = &adap->tc_mqprio->port_mqprio[j];
2819 entries = 0;
2820 for (tc = 0; tc < port_mqprio->mqprio.qopt.num_tc; tc++)
2821 entries += port_mqprio->mqprio.qopt.count[tc];
2822
2823 if (!entries)
2824 continue;
2825
2826 eosw_entries = DIV_ROUND_UP(entries, 4);
2827 if (r < eosw_entries) {
2828 const struct sge_eosw_txq *tx;
2829
2830 n = min(4, entries - 4 * r);
2831 tx = &port_mqprio->eosw_txq[4 * r];
2832
2833 S("QType:", "EOSW-TXQ");
2834 S("Interface:",
2835 adap->port[j] ? adap->port[j]->name : "N/A");
2836 T("EOTID:", hwtid);
2837 T("HWQID:", hwqid);
2838 T("State:", state);
2839 T("Size:", ndesc);
2840 T("In-Use:", inuse);
2841 T("Credits:", cred);
2842 T("Compl:", ncompl);
2843 T("Last-Compl:", last_compl);
2844 T("PIDX:", pidx);
2845 T("Last-PIDX:", last_pidx);
2846 T("CIDX:", cidx);
2847 T("Last-CIDX:", last_cidx);
2848 T("FLOWC-IDX:", flowc_idx);
2849
2850 mutex_unlock(&adap->tc_mqprio->mqprio_mutex);
2851 goto out;
2852 }
2853
2854 r -= eosw_entries;
2855 }
2856 mutex_unlock(&adap->tc_mqprio->mqprio_mutex);
2857
2858skip_mqprio:
2859 if (!is_uld(adap))
2860 goto skip_uld;
2861
2862 mutex_lock(&uld_mutex);
2863 if (s->uld_txq_info)
2864 for (i = 0; i < ARRAY_SIZE(uld_txq_entries); i++)
2865 uld_txq_entries[i] = sge_qinfo_uld_txq_entries(adap, i);
2866
2867 if (s->uld_rxq_info) {
2868 for (i = 0; i < ARRAY_SIZE(uld_rxq_entries); i++) {
2869 uld_rxq_entries[i] = sge_qinfo_uld_rxq_entries(adap, i);
2870 uld_ciq_entries[i] = sge_qinfo_uld_ciq_entries(adap, i);
2871 }
2872 }
2873
2874 if (r < uld_txq_entries[CXGB4_TX_OFLD]) {
2875 const struct sge_uld_txq *tx;
2876
2877 utxq_info = s->uld_txq_info[CXGB4_TX_OFLD];
2878 tx = &utxq_info->uldtxq[r * 4];
2879 n = min(4, utxq_info->ntxq - 4 * r);
2880
2881 S("QType:", "OFLD-TXQ");
2882 T("TxQ ID:", q.cntxt_id);
2883 T("TxQ size:", q.size);
2884 T("TxQ inuse:", q.in_use);
2885 T("TxQ CIDX:", q.cidx);
2886 T("TxQ PIDX:", q.pidx);
2887
2888 goto unlock;
2889 }
2890
2891 r -= uld_txq_entries[CXGB4_TX_OFLD];
2892 if (r < uld_rxq_entries[CXGB4_ULD_RDMA]) {
2893 const struct sge_ofld_rxq *rx;
2894
2895 urxq_info = s->uld_rxq_info[CXGB4_ULD_RDMA];
2896 rx = &urxq_info->uldrxq[r * 4];
2897 n = min(4, urxq_info->nrxq - 4 * r);
2898
2899 S("QType:", "RDMA-CPL");
2900 S("Interface:",
2901 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2902 R("RspQ ID:", rspq.abs_id);
2903 R("RspQ size:", rspq.size);
2904 R("RspQE size:", rspq.iqe_len);
2905 R("RspQ CIDX:", rspq.cidx);
2906 R("RspQ Gen:", rspq.gen);
2907 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2908 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2909 R("FL ID:", fl.cntxt_id);
2910 R("FL size:", fl.size - 8);
2911 R("FL pend:", fl.pend_cred);
2912 R("FL avail:", fl.avail);
2913 R("FL PIDX:", fl.pidx);
2914 R("FL CIDX:", fl.cidx);
2915
2916 goto unlock;
2917 }
2918
2919 r -= uld_rxq_entries[CXGB4_ULD_RDMA];
2920 if (r < uld_ciq_entries[CXGB4_ULD_RDMA]) {
2921 const struct sge_ofld_rxq *rx;
2922 int ciq_idx = 0;
2923
2924 urxq_info = s->uld_rxq_info[CXGB4_ULD_RDMA];
2925 ciq_idx = urxq_info->nrxq + (r * 4);
2926 rx = &urxq_info->uldrxq[ciq_idx];
2927 n = min(4, urxq_info->nciq - 4 * r);
2928
2929 S("QType:", "RDMA-CIQ");
2930 S("Interface:",
2931 rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A");
2932 R("RspQ ID:", rspq.abs_id);
2933 R("RspQ size:", rspq.size);
2934 R("RspQE size:", rspq.iqe_len);
2935 R("RspQ CIDX:", rspq.cidx);
2936 R("RspQ Gen:", rspq.gen);
2937 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2938 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2939
2940 goto unlock;
2941 }
2942
2943 r -= uld_ciq_entries[CXGB4_ULD_RDMA];
2944 if (r < uld_rxq_entries[CXGB4_ULD_ISCSI]) {
2945 const struct sge_ofld_rxq *rx;
2946
2947 urxq_info = s->uld_rxq_info[CXGB4_ULD_ISCSI];
2948 rx = &urxq_info->uldrxq[r * 4];
2949 n = min(4, urxq_info->nrxq - 4 * r);
2950
2951 S("QType:", "iSCSI");
2952 R("RspQ ID:", rspq.abs_id);
2953 R("RspQ size:", rspq.size);
2954 R("RspQE size:", rspq.iqe_len);
2955 R("RspQ CIDX:", rspq.cidx);
2956 R("RspQ Gen:", rspq.gen);
2957 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2958 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2959 R("FL ID:", fl.cntxt_id);
2960 R("FL size:", fl.size - 8);
2961 R("FL pend:", fl.pend_cred);
2962 R("FL avail:", fl.avail);
2963 R("FL PIDX:", fl.pidx);
2964 R("FL CIDX:", fl.cidx);
2965
2966 goto unlock;
2967 }
2968
2969 r -= uld_rxq_entries[CXGB4_ULD_ISCSI];
2970 if (r < uld_rxq_entries[CXGB4_ULD_ISCSIT]) {
2971 const struct sge_ofld_rxq *rx;
2972
2973 urxq_info = s->uld_rxq_info[CXGB4_ULD_ISCSIT];
2974 rx = &urxq_info->uldrxq[r * 4];
2975 n = min(4, urxq_info->nrxq - 4 * r);
2976
2977 S("QType:", "iSCSIT");
2978 R("RspQ ID:", rspq.abs_id);
2979 R("RspQ size:", rspq.size);
2980 R("RspQE size:", rspq.iqe_len);
2981 R("RspQ CIDX:", rspq.cidx);
2982 R("RspQ Gen:", rspq.gen);
2983 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
2984 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
2985 R("FL ID:", fl.cntxt_id);
2986 R("FL size:", fl.size - 8);
2987 R("FL pend:", fl.pend_cred);
2988 R("FL avail:", fl.avail);
2989 R("FL PIDX:", fl.pidx);
2990 R("FL CIDX:", fl.cidx);
2991
2992 goto unlock;
2993 }
2994
2995 r -= uld_rxq_entries[CXGB4_ULD_ISCSIT];
2996 if (r < uld_rxq_entries[CXGB4_ULD_TLS]) {
2997 const struct sge_ofld_rxq *rx;
2998
2999 urxq_info = s->uld_rxq_info[CXGB4_ULD_TLS];
3000 rx = &urxq_info->uldrxq[r * 4];
3001 n = min(4, urxq_info->nrxq - 4 * r);
3002
3003 S("QType:", "TLS");
3004 R("RspQ ID:", rspq.abs_id);
3005 R("RspQ size:", rspq.size);
3006 R("RspQE size:", rspq.iqe_len);
3007 R("RspQ CIDX:", rspq.cidx);
3008 R("RspQ Gen:", rspq.gen);
3009 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
3010 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
3011 R("FL ID:", fl.cntxt_id);
3012 R("FL size:", fl.size - 8);
3013 R("FL pend:", fl.pend_cred);
3014 R("FL avail:", fl.avail);
3015 R("FL PIDX:", fl.pidx);
3016 R("FL CIDX:", fl.cidx);
3017
3018 goto unlock;
3019 }
3020
3021 r -= uld_rxq_entries[CXGB4_ULD_TLS];
3022 if (r < uld_txq_entries[CXGB4_TX_CRYPTO]) {
3023 const struct sge_ofld_rxq *rx;
3024 const struct sge_uld_txq *tx;
3025
3026 utxq_info = s->uld_txq_info[CXGB4_TX_CRYPTO];
3027 urxq_info = s->uld_rxq_info[CXGB4_ULD_CRYPTO];
3028 tx = &utxq_info->uldtxq[r * 4];
3029 rx = &urxq_info->uldrxq[r * 4];
3030 n = min(4, utxq_info->ntxq - 4 * r);
3031
3032 S("QType:", "Crypto");
3033 T("TxQ ID:", q.cntxt_id);
3034 T("TxQ size:", q.size);
3035 T("TxQ inuse:", q.in_use);
3036 T("TxQ CIDX:", q.cidx);
3037 T("TxQ PIDX:", q.pidx);
3038 R("RspQ ID:", rspq.abs_id);
3039 R("RspQ size:", rspq.size);
3040 R("RspQE size:", rspq.iqe_len);
3041 R("RspQ CIDX:", rspq.cidx);
3042 R("RspQ Gen:", rspq.gen);
3043 S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq));
3044 S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]);
3045 R("FL ID:", fl.cntxt_id);
3046 R("FL size:", fl.size - 8);
3047 R("FL pend:", fl.pend_cred);
3048 R("FL avail:", fl.avail);
3049 R("FL PIDX:", fl.pidx);
3050 R("FL CIDX:", fl.cidx);
3051
3052 goto unlock;
3053 }
3054
3055 r -= uld_txq_entries[CXGB4_TX_CRYPTO];
3056 mutex_unlock(&uld_mutex);
3057
3058skip_uld:
3059 if (r < ctrl_entries) {
3060 const struct sge_ctrl_txq *tx = &s->ctrlq[r * 4];
3061
3062 n = min(4, adap->params.nports - 4 * r);
3063
3064 S("QType:", "Control");
3065 T("TxQ ID:", q.cntxt_id);
3066 T("TxQ size:", q.size);
3067 T("TxQ inuse:", q.in_use);
3068 T("TxQ CIDX:", q.cidx);
3069 T("TxQ PIDX:", q.pidx);
3070 TL("TxQFull:", q.stops);
3071 TL("TxQRestarts:", q.restarts);
3072
3073 goto out;
3074 }
3075
3076 r -= ctrl_entries;
3077 if (r < 1) {
3078 const struct sge_rspq *evtq = &s->fw_evtq;
3079
3080 seq_printf(seq, "%-12s %16s\n", "QType:", "FW event queue");
3081 seq_printf(seq, "%-12s %16u\n", "RspQ ID:", evtq->abs_id);
3082 seq_printf(seq, "%-12s %16u\n", "RspQ size:", evtq->size);
3083 seq_printf(seq, "%-12s %16u\n", "RspQE size:", evtq->iqe_len);
3084 seq_printf(seq, "%-12s %16u\n", "RspQ CIDX:", evtq->cidx);
3085 seq_printf(seq, "%-12s %16u\n", "RspQ Gen:", evtq->gen);
3086 seq_printf(seq, "%-12s %16u\n", "Intr delay:",
3087 qtimer_val(adap, evtq));
3088 seq_printf(seq, "%-12s %16u\n", "Intr pktcnt:",
3089 s->counter_val[evtq->pktcnt_idx]);
3090
3091 goto out;
3092 }
3093
3094#undef R
3095#undef RL
3096#undef T
3097#undef TL
3098#undef S
3099#undef R3
3100#undef T3
3101#undef S3
3102out:
3103 return 0;
3104
3105unlock:
3106 mutex_unlock(&uld_mutex);
3107 return 0;
3108}
3109
3110static int sge_queue_entries(const struct adapter *adap)
3111{
3112 int i, tot_uld_entries = 0, eohw_entries = 0, eosw_entries = 0;
3113
3114 if (adap->tc_mqprio) {
3115 struct cxgb4_tc_port_mqprio *port_mqprio;
3116 u8 tc;
3117
3118 mutex_lock(&adap->tc_mqprio->mqprio_mutex);
3119 if (adap->sge.eohw_txq)
3120 eohw_entries = DIV_ROUND_UP(adap->sge.eoqsets, 4);
3121
3122 for (i = 0; i < adap->params.nports; i++) {
3123 u32 entries = 0;
3124
3125 port_mqprio = &adap->tc_mqprio->port_mqprio[i];
3126 for (tc = 0; tc < port_mqprio->mqprio.qopt.num_tc; tc++)
3127 entries += port_mqprio->mqprio.qopt.count[tc];
3128
3129 if (entries)
3130 eosw_entries += DIV_ROUND_UP(entries, 4);
3131 }
3132 mutex_unlock(&adap->tc_mqprio->mqprio_mutex);
3133 }
3134
3135 if (!is_uld(adap))
3136 goto lld_only;
3137
3138 mutex_lock(&uld_mutex);
3139 for (i = 0; i < CXGB4_TX_MAX; i++)
3140 tot_uld_entries += sge_qinfo_uld_txq_entries(adap, i);
3141
3142 for (i = 0; i < CXGB4_ULD_MAX; i++) {
3143 tot_uld_entries += sge_qinfo_uld_rxq_entries(adap, i);
3144 tot_uld_entries += sge_qinfo_uld_ciq_entries(adap, i);
3145 }
3146 mutex_unlock(&uld_mutex);
3147
3148lld_only:
3149 return DIV_ROUND_UP(adap->sge.ethqsets, 4) +
3150 eohw_entries + eosw_entries + tot_uld_entries +
3151 DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1;
3152}
3153
3154static void *sge_queue_start(struct seq_file *seq, loff_t *pos)
3155{
3156 int entries = sge_queue_entries(seq->private);
3157
3158 return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
3159}
3160
3161static void sge_queue_stop(struct seq_file *seq, void *v)
3162{
3163}
3164
3165static void *sge_queue_next(struct seq_file *seq, void *v, loff_t *pos)
3166{
3167 int entries = sge_queue_entries(seq->private);
3168
3169 ++*pos;
3170 return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL;
3171}
3172
3173static const struct seq_operations sge_qinfo_seq_ops = {
3174 .start = sge_queue_start,
3175 .next = sge_queue_next,
3176 .stop = sge_queue_stop,
3177 .show = sge_qinfo_show
3178};
3179
3180static int sge_qinfo_open(struct inode *inode, struct file *file)
3181{
3182 int res = seq_open(file, &sge_qinfo_seq_ops);
3183
3184 if (!res) {
3185 struct seq_file *seq = file->private_data;
3186
3187 seq->private = inode->i_private;
3188 }
3189 return res;
3190}
3191
3192static const struct file_operations sge_qinfo_debugfs_fops = {
3193 .owner = THIS_MODULE,
3194 .open = sge_qinfo_open,
3195 .read = seq_read,
3196 .llseek = seq_lseek,
3197 .release = seq_release,
3198};
3199
3200int mem_open(struct inode *inode, struct file *file)
3201{
3202 unsigned int mem;
3203 struct adapter *adap;
3204
3205 file->private_data = inode->i_private;
3206
3207 mem = (uintptr_t)file->private_data & 0x7;
3208 adap = file->private_data - mem;
3209
3210 (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH);
3211
3212 return 0;
3213}
3214
3215static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
3216 loff_t *ppos)
3217{
3218 loff_t pos = *ppos;
3219 loff_t avail = file_inode(file)->i_size;
3220 unsigned int mem = (uintptr_t)file->private_data & 0x7;
3221 struct adapter *adap = file->private_data - mem;
3222 __be32 *data;
3223 int ret;
3224
3225 if (pos < 0)
3226 return -EINVAL;
3227 if (pos >= avail)
3228 return 0;
3229 if (count > avail - pos)
3230 count = avail - pos;
3231
3232 data = kvzalloc(count, GFP_KERNEL);
3233 if (!data)
3234 return -ENOMEM;
3235
3236 spin_lock(&adap->win0_lock);
3237 ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
3238 spin_unlock(&adap->win0_lock);
3239 if (ret) {
3240 kvfree(data);
3241 return ret;
3242 }
3243 ret = copy_to_user(buf, data, count);
3244
3245 kvfree(data);
3246 if (ret)
3247 return -EFAULT;
3248
3249 *ppos = pos + count;
3250 return count;
3251}
3252static const struct file_operations mem_debugfs_fops = {
3253 .owner = THIS_MODULE,
3254 .open = simple_open,
3255 .read = mem_read,
3256 .llseek = default_llseek,
3257};
3258
3259static int tid_info_show(struct seq_file *seq, void *v)
3260{
3261 struct adapter *adap = seq->private;
3262 const struct tid_info *t;
3263 enum chip_type chip;
3264
3265 t = &adap->tids;
3266 chip = CHELSIO_CHIP_VERSION(adap->params.chip);
3267 if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
3268 unsigned int sb;
3269 seq_printf(seq, "Connections in use: %u\n",
3270 atomic_read(&t->conns_in_use));
3271
3272 if (chip <= CHELSIO_T5)
3273 sb = t4_read_reg(adap, LE_DB_SERVER_INDEX_A) / 4;
3274 else
3275 sb = t4_read_reg(adap, LE_DB_SRVR_START_INDEX_A);
3276
3277 if (sb) {
3278 seq_printf(seq, "TID range: %u..%u/%u..%u", t->tid_base,
3279 sb - 1, adap->tids.hash_base,
3280 t->tid_base + t->ntids - 1);
3281 seq_printf(seq, ", in use: %u/%u\n",
3282 atomic_read(&t->tids_in_use),
3283 atomic_read(&t->hash_tids_in_use));
3284 } else if (adap->flags & CXGB4_FW_OFLD_CONN) {
3285 seq_printf(seq, "TID range: %u..%u/%u..%u",
3286 t->aftid_base,
3287 t->aftid_end,
3288 adap->tids.hash_base,
3289 t->tid_base + t->ntids - 1);
3290 seq_printf(seq, ", in use: %u/%u\n",
3291 atomic_read(&t->tids_in_use),
3292 atomic_read(&t->hash_tids_in_use));
3293 } else {
3294 seq_printf(seq, "TID range: %u..%u",
3295 adap->tids.hash_base,
3296 t->tid_base + t->ntids - 1);
3297 seq_printf(seq, ", in use: %u\n",
3298 atomic_read(&t->hash_tids_in_use));
3299 }
3300 } else if (t->ntids) {
3301 seq_printf(seq, "Connections in use: %u\n",
3302 atomic_read(&t->conns_in_use));
3303
3304 seq_printf(seq, "TID range: %u..%u", t->tid_base,
3305 t->tid_base + t->ntids - 1);
3306 seq_printf(seq, ", in use: %u\n",
3307 atomic_read(&t->tids_in_use));
3308 }
3309
3310 if (t->nstids)
3311 seq_printf(seq, "STID range: %u..%u, in use-IPv4/IPv6: %u/%u\n",
3312 (!t->stid_base &&
3313 (chip <= CHELSIO_T5)) ?
3314 t->stid_base + 1 : t->stid_base,
3315 t->stid_base + t->nstids - 1,
3316 t->stids_in_use - t->v6_stids_in_use,
3317 t->v6_stids_in_use);
3318
3319 if (t->natids)
3320 seq_printf(seq, "ATID range: 0..%u, in use: %u\n",
3321 t->natids - 1, t->atids_in_use);
3322 seq_printf(seq, "FTID range: %u..%u\n", t->ftid_base,
3323 t->ftid_base + t->nftids - 1);
3324 if (t->nsftids)
3325 seq_printf(seq, "SFTID range: %u..%u in use: %u\n",
3326 t->sftid_base, t->sftid_base + t->nsftids - 2,
3327 t->sftids_in_use);
3328 if (t->nhpftids)
3329 seq_printf(seq, "HPFTID range: %u..%u\n", t->hpftid_base,
3330 t->hpftid_base + t->nhpftids - 1);
3331 if (t->neotids)
3332 seq_printf(seq, "EOTID range: %u..%u, in use: %u\n",
3333 t->eotid_base, t->eotid_base + t->neotids - 1,
3334 atomic_read(&t->eotids_in_use));
3335 if (t->ntids)
3336 seq_printf(seq, "HW TID usage: %u IP users, %u IPv6 users\n",
3337 t4_read_reg(adap, LE_DB_ACT_CNT_IPV4_A),
3338 t4_read_reg(adap, LE_DB_ACT_CNT_IPV6_A));
3339 return 0;
3340}
3341DEFINE_SHOW_ATTRIBUTE(tid_info);
3342
3343static void add_debugfs_mem(struct adapter *adap, const char *name,
3344 unsigned int idx, unsigned int size_mb)
3345{
3346 debugfs_create_file_size(name, 0400, adap->debugfs_root,
3347 (void *)adap + idx, &mem_debugfs_fops,
3348 size_mb << 20);
3349}
3350
3351static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
3352 size_t count, loff_t *ppos)
3353{
3354 int len;
3355 const struct adapter *adap = filp->private_data;
3356 char *buf;
3357 ssize_t size = (adap->sge.egr_sz + 3) / 4 +
3358 adap->sge.egr_sz / 32 + 2;
3359
3360 buf = kzalloc(size, GFP_KERNEL);
3361 if (!buf)
3362 return -ENOMEM;
3363
3364 len = snprintf(buf, size - 1, "%*pb\n",
3365 adap->sge.egr_sz, adap->sge.blocked_fl);
3366 len += sprintf(buf + len, "\n");
3367 size = simple_read_from_buffer(ubuf, count, ppos, buf, len);
3368 kvfree(buf);
3369 return size;
3370}
3371
3372static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
3373 size_t count, loff_t *ppos)
3374{
3375 int err;
3376 unsigned long *t;
3377 struct adapter *adap = filp->private_data;
3378
3379 t = kcalloc(BITS_TO_LONGS(adap->sge.egr_sz), sizeof(long), GFP_KERNEL);
3380 if (!t)
3381 return -ENOMEM;
3382
3383 err = bitmap_parse_user(ubuf, count, t, adap->sge.egr_sz);
3384 if (err) {
3385 kvfree(t);
3386 return err;
3387 }
3388
3389 bitmap_copy(adap->sge.blocked_fl, t, adap->sge.egr_sz);
3390 kvfree(t);
3391 return count;
3392}
3393
3394static const struct file_operations blocked_fl_fops = {
3395 .owner = THIS_MODULE,
3396 .open = simple_open,
3397 .read = blocked_fl_read,
3398 .write = blocked_fl_write,
3399 .llseek = generic_file_llseek,
3400};
3401
3402static void mem_region_show(struct seq_file *seq, const char *name,
3403 unsigned int from, unsigned int to)
3404{
3405 char buf[40];
3406
3407 string_get_size((u64)to - from + 1, 1, STRING_UNITS_2, buf,
3408 sizeof(buf));
3409 seq_printf(seq, "%-15s %#x-%#x [%s]\n", name, from, to, buf);
3410}
3411
3412static int meminfo_show(struct seq_file *seq, void *v)
3413{
3414 static const char * const memory[] = { "EDC0:", "EDC1:", "MC:",
3415 "MC0:", "MC1:", "HMA:"};
3416 struct adapter *adap = seq->private;
3417 struct cudbg_meminfo meminfo;
3418 int i, rc;
3419
3420 memset(&meminfo, 0, sizeof(struct cudbg_meminfo));
3421 rc = cudbg_fill_meminfo(adap, &meminfo);
3422 if (rc)
3423 return -ENXIO;
3424
3425 for (i = 0; i < meminfo.avail_c; i++)
3426 mem_region_show(seq, memory[meminfo.avail[i].idx],
3427 meminfo.avail[i].base,
3428 meminfo.avail[i].limit - 1);
3429
3430 seq_putc(seq, '\n');
3431 for (i = 0; i < meminfo.mem_c; i++) {
3432 if (meminfo.mem[i].idx >= ARRAY_SIZE(cudbg_region))
3433 continue;
3434 if (!meminfo.mem[i].limit)
3435 meminfo.mem[i].limit =
3436 i < meminfo.mem_c - 1 ?
3437 meminfo.mem[i + 1].base - 1 : ~0;
3438 mem_region_show(seq, cudbg_region[meminfo.mem[i].idx],
3439 meminfo.mem[i].base, meminfo.mem[i].limit);
3440 }
3441
3442 seq_putc(seq, '\n');
3443 mem_region_show(seq, "uP RAM:", meminfo.up_ram_lo, meminfo.up_ram_hi);
3444 mem_region_show(seq, "uP Extmem2:", meminfo.up_extmem2_lo,
3445 meminfo.up_extmem2_hi);
3446
3447 seq_printf(seq, "\n%u Rx pages (%u free) of size %uKiB for %u channels\n",
3448 meminfo.rx_pages_data[0], meminfo.free_rx_cnt,
3449 meminfo.rx_pages_data[1], meminfo.rx_pages_data[2]);
3450
3451 seq_printf(seq, "%u Tx pages (%u free) of size %u%ciB for %u channels\n",
3452 meminfo.tx_pages_data[0], meminfo.free_tx_cnt,
3453 meminfo.tx_pages_data[1], meminfo.tx_pages_data[2],
3454 meminfo.tx_pages_data[3]);
3455
3456 seq_printf(seq, "%u p-structs (%u free)\n\n",
3457 meminfo.p_structs, meminfo.p_structs_free_cnt);
3458
3459 for (i = 0; i < 4; i++)
3460
3461 seq_printf(seq, "Port %d using %u pages out of %u allocated\n",
3462 i, meminfo.port_used[i], meminfo.port_alloc[i]);
3463
3464 for (i = 0; i < adap->params.arch.nchan; i++)
3465
3466 seq_printf(seq,
3467 "Loopback %d using %u pages out of %u allocated\n",
3468 i, meminfo.loopback_used[i],
3469 meminfo.loopback_alloc[i]);
3470
3471 return 0;
3472}
3473DEFINE_SHOW_ATTRIBUTE(meminfo);
3474
3475static int chcr_stats_show(struct seq_file *seq, void *v)
3476{
3477 struct adapter *adap = seq->private;
3478
3479 seq_puts(seq, "Chelsio Crypto Accelerator Stats \n");
3480 seq_printf(seq, "Cipher Ops: %10u \n",
3481 atomic_read(&adap->chcr_stats.cipher_rqst));
3482 seq_printf(seq, "Digest Ops: %10u \n",
3483 atomic_read(&adap->chcr_stats.digest_rqst));
3484 seq_printf(seq, "Aead Ops: %10u \n",
3485 atomic_read(&adap->chcr_stats.aead_rqst));
3486 seq_printf(seq, "Completion: %10u \n",
3487 atomic_read(&adap->chcr_stats.complete));
3488 seq_printf(seq, "Error: %10u \n",
3489 atomic_read(&adap->chcr_stats.error));
3490 seq_printf(seq, "Fallback: %10u \n",
3491 atomic_read(&adap->chcr_stats.fallback));
3492 seq_printf(seq, "IPSec PDU: %10u\n",
3493 atomic_read(&adap->chcr_stats.ipsec_cnt));
3494 seq_printf(seq, "TLS PDU Tx: %10u\n",
3495 atomic_read(&adap->chcr_stats.tls_pdu_tx));
3496 seq_printf(seq, "TLS PDU Rx: %10u\n",
3497 atomic_read(&adap->chcr_stats.tls_pdu_rx));
3498 seq_printf(seq, "TLS Keys (DDR) Count: %10u\n",
3499 atomic_read(&adap->chcr_stats.tls_key));
3500#ifdef CONFIG_CHELSIO_TLS_DEVICE
3501 seq_puts(seq, "\nChelsio KTLS Crypto Accelerator Stats\n");
3502 seq_printf(seq, "Tx TLS offload refcount: %20u\n",
3503 refcount_read(&adap->chcr_ktls.ktls_refcount));
3504 seq_printf(seq, "Tx HW offload contexts added: %20llu\n",
3505 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_ctx));
3506 seq_printf(seq, "Tx connection created: %20llu\n",
3507 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_connection_open));
3508 seq_printf(seq, "Tx connection failed: %20llu\n",
3509 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_connection_fail));
3510 seq_printf(seq, "Tx connection closed: %20llu\n",
3511 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_connection_close));
3512 seq_printf(seq, "Packets passed for encryption : %20llu\n",
3513 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_encrypted_packets));
3514 seq_printf(seq, "Bytes passed for encryption : %20llu\n",
3515 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_encrypted_bytes));
3516 seq_printf(seq, "Tx records send: %20llu\n",
3517 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_send_records));
3518 seq_printf(seq, "Tx partial start of records: %20llu\n",
3519 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_start_pkts));
3520 seq_printf(seq, "Tx partial middle of records: %20llu\n",
3521 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_middle_pkts));
3522 seq_printf(seq, "Tx partial end of record: %20llu\n",
3523 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_end_pkts));
3524 seq_printf(seq, "Tx complete records: %20llu\n",
3525 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_complete_pkts));
3526 seq_printf(seq, "TX trim pkts : %20llu\n",
3527 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_trimmed_pkts));
3528 seq_printf(seq, "Tx out of order packets: %20llu\n",
3529 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_ooo));
3530 seq_printf(seq, "Tx drop pkts before HW offload: %20llu\n",
3531 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_skip_no_sync_data));
3532 seq_printf(seq, "Tx drop not synced packets: %20llu\n",
3533 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_drop_no_sync_data));
3534 seq_printf(seq, "Tx drop bypass req: %20llu\n",
3535 (u64)atomic64_read(&adap->chcr_stats.ktls_tx_drop_bypass_req));
3536#endif
3537
3538 return 0;
3539}
3540DEFINE_SHOW_ATTRIBUTE(chcr_stats);
3541
3542#define PRINT_ADAP_STATS(string, value) \
3543 seq_printf(seq, "%-25s %-20llu\n", (string), \
3544 (unsigned long long)(value))
3545
3546#define PRINT_CH_STATS(string, value) \
3547do { \
3548 seq_printf(seq, "%-25s ", (string)); \
3549 for (i = 0; i < adap->params.arch.nchan; i++) \
3550 seq_printf(seq, "%-20llu ", \
3551 (unsigned long long)stats.value[i]); \
3552 seq_printf(seq, "\n"); \
3553} while (0)
3554
3555#define PRINT_CH_STATS2(string, value) \
3556do { \
3557 seq_printf(seq, "%-25s ", (string)); \
3558 for (i = 0; i < adap->params.arch.nchan; i++) \
3559 seq_printf(seq, "%-20llu ", \
3560 (unsigned long long)stats[i].value); \
3561 seq_printf(seq, "\n"); \
3562} while (0)
3563
3564static void show_tcp_stats(struct seq_file *seq)
3565{
3566 struct adapter *adap = seq->private;
3567 struct tp_tcp_stats v4, v6;
3568
3569 spin_lock(&adap->stats_lock);
3570 t4_tp_get_tcp_stats(adap, &v4, &v6, false);
3571 spin_unlock(&adap->stats_lock);
3572
3573 PRINT_ADAP_STATS("tcp_ipv4_out_rsts:", v4.tcp_out_rsts);
3574 PRINT_ADAP_STATS("tcp_ipv4_in_segs:", v4.tcp_in_segs);
3575 PRINT_ADAP_STATS("tcp_ipv4_out_segs:", v4.tcp_out_segs);
3576 PRINT_ADAP_STATS("tcp_ipv4_retrans_segs:", v4.tcp_retrans_segs);
3577 PRINT_ADAP_STATS("tcp_ipv6_out_rsts:", v6.tcp_out_rsts);
3578 PRINT_ADAP_STATS("tcp_ipv6_in_segs:", v6.tcp_in_segs);
3579 PRINT_ADAP_STATS("tcp_ipv6_out_segs:", v6.tcp_out_segs);
3580 PRINT_ADAP_STATS("tcp_ipv6_retrans_segs:", v6.tcp_retrans_segs);
3581}
3582
3583static void show_ddp_stats(struct seq_file *seq)
3584{
3585 struct adapter *adap = seq->private;
3586 struct tp_usm_stats stats;
3587
3588 spin_lock(&adap->stats_lock);
3589 t4_get_usm_stats(adap, &stats, false);
3590 spin_unlock(&adap->stats_lock);
3591
3592 PRINT_ADAP_STATS("usm_ddp_frames:", stats.frames);
3593 PRINT_ADAP_STATS("usm_ddp_octets:", stats.octets);
3594 PRINT_ADAP_STATS("usm_ddp_drops:", stats.drops);
3595}
3596
3597static void show_rdma_stats(struct seq_file *seq)
3598{
3599 struct adapter *adap = seq->private;
3600 struct tp_rdma_stats stats;
3601
3602 spin_lock(&adap->stats_lock);
3603 t4_tp_get_rdma_stats(adap, &stats, false);
3604 spin_unlock(&adap->stats_lock);
3605
3606 PRINT_ADAP_STATS("rdma_no_rqe_mod_defer:", stats.rqe_dfr_mod);
3607 PRINT_ADAP_STATS("rdma_no_rqe_pkt_defer:", stats.rqe_dfr_pkt);
3608}
3609
3610static void show_tp_err_adapter_stats(struct seq_file *seq)
3611{
3612 struct adapter *adap = seq->private;
3613 struct tp_err_stats stats;
3614
3615 spin_lock(&adap->stats_lock);
3616 t4_tp_get_err_stats(adap, &stats, false);
3617 spin_unlock(&adap->stats_lock);
3618
3619 PRINT_ADAP_STATS("tp_err_ofld_no_neigh:", stats.ofld_no_neigh);
3620 PRINT_ADAP_STATS("tp_err_ofld_cong_defer:", stats.ofld_cong_defer);
3621}
3622
3623static void show_cpl_stats(struct seq_file *seq)
3624{
3625 struct adapter *adap = seq->private;
3626 struct tp_cpl_stats stats;
3627 u8 i;
3628
3629 spin_lock(&adap->stats_lock);
3630 t4_tp_get_cpl_stats(adap, &stats, false);
3631 spin_unlock(&adap->stats_lock);
3632
3633 PRINT_CH_STATS("tp_cpl_requests:", req);
3634 PRINT_CH_STATS("tp_cpl_responses:", rsp);
3635}
3636
3637static void show_tp_err_channel_stats(struct seq_file *seq)
3638{
3639 struct adapter *adap = seq->private;
3640 struct tp_err_stats stats;
3641 u8 i;
3642
3643 spin_lock(&adap->stats_lock);
3644 t4_tp_get_err_stats(adap, &stats, false);
3645 spin_unlock(&adap->stats_lock);
3646
3647 PRINT_CH_STATS("tp_mac_in_errs:", mac_in_errs);
3648 PRINT_CH_STATS("tp_hdr_in_errs:", hdr_in_errs);
3649 PRINT_CH_STATS("tp_tcp_in_errs:", tcp_in_errs);
3650 PRINT_CH_STATS("tp_tcp6_in_errs:", tcp6_in_errs);
3651 PRINT_CH_STATS("tp_tnl_cong_drops:", tnl_cong_drops);
3652 PRINT_CH_STATS("tp_tnl_tx_drops:", tnl_tx_drops);
3653 PRINT_CH_STATS("tp_ofld_vlan_drops:", ofld_vlan_drops);
3654 PRINT_CH_STATS("tp_ofld_chan_drops:", ofld_chan_drops);
3655}
3656
3657static void show_fcoe_stats(struct seq_file *seq)
3658{
3659 struct adapter *adap = seq->private;
3660 struct tp_fcoe_stats stats[NCHAN];
3661 u8 i;
3662
3663 spin_lock(&adap->stats_lock);
3664 for (i = 0; i < adap->params.arch.nchan; i++)
3665 t4_get_fcoe_stats(adap, i, &stats[i], false);
3666 spin_unlock(&adap->stats_lock);
3667
3668 PRINT_CH_STATS2("fcoe_octets_ddp", octets_ddp);
3669 PRINT_CH_STATS2("fcoe_frames_ddp", frames_ddp);
3670 PRINT_CH_STATS2("fcoe_frames_drop", frames_drop);
3671}
3672
3673#undef PRINT_CH_STATS2
3674#undef PRINT_CH_STATS
3675#undef PRINT_ADAP_STATS
3676
3677static int tp_stats_show(struct seq_file *seq, void *v)
3678{
3679 struct adapter *adap = seq->private;
3680
3681 seq_puts(seq, "\n--------Adapter Stats--------\n");
3682 show_tcp_stats(seq);
3683 show_ddp_stats(seq);
3684 show_rdma_stats(seq);
3685 show_tp_err_adapter_stats(seq);
3686
3687 seq_puts(seq, "\n-------- Channel Stats --------\n");
3688 if (adap->params.arch.nchan == NCHAN)
3689 seq_printf(seq, "%-25s %-20s %-20s %-20s %-20s\n",
3690 " ", "channel 0", "channel 1",
3691 "channel 2", "channel 3");
3692 else
3693 seq_printf(seq, "%-25s %-20s %-20s\n",
3694 " ", "channel 0", "channel 1");
3695 show_cpl_stats(seq);
3696 show_tp_err_channel_stats(seq);
3697 show_fcoe_stats(seq);
3698
3699 return 0;
3700}
3701DEFINE_SHOW_ATTRIBUTE(tp_stats);
3702
3703
3704
3705void add_debugfs_files(struct adapter *adap,
3706 struct t4_debugfs_entry *files,
3707 unsigned int nfiles)
3708{
3709 int i;
3710
3711
3712 for (i = 0; i < nfiles; i++)
3713 debugfs_create_file(files[i].name, files[i].mode,
3714 adap->debugfs_root,
3715 (void *)adap + files[i].data,
3716 files[i].ops);
3717}
3718
3719int t4_setup_debugfs(struct adapter *adap)
3720{
3721 int i;
3722 u32 size = 0;
3723
3724 static struct t4_debugfs_entry t4_debugfs_files[] = {
3725 { "cim_la", &cim_la_fops, 0400, 0 },
3726 { "cim_pif_la", &cim_pif_la_fops, 0400, 0 },
3727 { "cim_ma_la", &cim_ma_la_fops, 0400, 0 },
3728 { "cim_qcfg", &cim_qcfg_fops, 0400, 0 },
3729 { "clk", &clk_fops, 0400, 0 },
3730 { "devlog", &devlog_fops, 0400, 0 },
3731 { "mboxlog", &mboxlog_fops, 0400, 0 },
3732 { "mbox0", &mbox_debugfs_fops, 0600, 0 },
3733 { "mbox1", &mbox_debugfs_fops, 0600, 1 },
3734 { "mbox2", &mbox_debugfs_fops, 0600, 2 },
3735 { "mbox3", &mbox_debugfs_fops, 0600, 3 },
3736 { "mbox4", &mbox_debugfs_fops, 0600, 4 },
3737 { "mbox5", &mbox_debugfs_fops, 0600, 5 },
3738 { "mbox6", &mbox_debugfs_fops, 0600, 6 },
3739 { "mbox7", &mbox_debugfs_fops, 0600, 7 },
3740 { "trace0", &mps_trc_debugfs_fops, 0600, 0 },
3741 { "trace1", &mps_trc_debugfs_fops, 0600, 1 },
3742 { "trace2", &mps_trc_debugfs_fops, 0600, 2 },
3743 { "trace3", &mps_trc_debugfs_fops, 0600, 3 },
3744 { "l2t", &t4_l2t_fops, 0400, 0},
3745 { "mps_tcam", &mps_tcam_debugfs_fops, 0400, 0 },
3746 { "rss", &rss_debugfs_fops, 0400, 0 },
3747 { "rss_config", &rss_config_fops, 0400, 0 },
3748 { "rss_key", &rss_key_debugfs_fops, 0400, 0 },
3749 { "rss_pf_config", &rss_pf_config_debugfs_fops, 0400, 0 },
3750 { "rss_vf_config", &rss_vf_config_debugfs_fops, 0400, 0 },
3751 { "resources", &resources_fops, 0400, 0 },
3752#ifdef CONFIG_CHELSIO_T4_DCB
3753 { "dcb_info", &dcb_info_debugfs_fops, 0400, 0 },
3754#endif
3755 { "sge_qinfo", &sge_qinfo_debugfs_fops, 0400, 0 },
3756 { "ibq_tp0", &cim_ibq_fops, 0400, 0 },
3757 { "ibq_tp1", &cim_ibq_fops, 0400, 1 },
3758 { "ibq_ulp", &cim_ibq_fops, 0400, 2 },
3759 { "ibq_sge0", &cim_ibq_fops, 0400, 3 },
3760 { "ibq_sge1", &cim_ibq_fops, 0400, 4 },
3761 { "ibq_ncsi", &cim_ibq_fops, 0400, 5 },
3762 { "obq_ulp0", &cim_obq_fops, 0400, 0 },
3763 { "obq_ulp1", &cim_obq_fops, 0400, 1 },
3764 { "obq_ulp2", &cim_obq_fops, 0400, 2 },
3765 { "obq_ulp3", &cim_obq_fops, 0400, 3 },
3766 { "obq_sge", &cim_obq_fops, 0400, 4 },
3767 { "obq_ncsi", &cim_obq_fops, 0400, 5 },
3768 { "tp_la", &tp_la_fops, 0400, 0 },
3769 { "ulprx_la", &ulprx_la_fops, 0400, 0 },
3770 { "sensors", &sensors_fops, 0400, 0 },
3771 { "pm_stats", &pm_stats_debugfs_fops, 0400, 0 },
3772 { "tx_rate", &tx_rate_fops, 0400, 0 },
3773 { "cctrl", &cctrl_tbl_fops, 0400, 0 },
3774#if IS_ENABLED(CONFIG_IPV6)
3775 { "clip_tbl", &clip_tbl_fops, 0400, 0 },
3776#endif
3777 { "tids", &tid_info_fops, 0400, 0},
3778 { "blocked_fl", &blocked_fl_fops, 0600, 0 },
3779 { "meminfo", &meminfo_fops, 0400, 0 },
3780 { "crypto", &chcr_stats_fops, 0400, 0 },
3781 { "tp_stats", &tp_stats_fops, 0400, 0 },
3782 };
3783
3784
3785
3786 static struct t4_debugfs_entry t5_debugfs_files[] = {
3787 { "obq_sge_rx_q0", &cim_obq_fops, 0400, 6 },
3788 { "obq_sge_rx_q1", &cim_obq_fops, 0400, 7 },
3789 };
3790
3791 add_debugfs_files(adap,
3792 t4_debugfs_files,
3793 ARRAY_SIZE(t4_debugfs_files));
3794 if (!is_t4(adap->params.chip))
3795 add_debugfs_files(adap,
3796 t5_debugfs_files,
3797 ARRAY_SIZE(t5_debugfs_files));
3798
3799 i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
3800 if (i & EDRAM0_ENABLE_F) {
3801 size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
3802 add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size));
3803 }
3804 if (i & EDRAM1_ENABLE_F) {
3805 size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
3806 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size));
3807 }
3808 if (is_t5(adap->params.chip)) {
3809 if (i & EXT_MEM0_ENABLE_F) {
3810 size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
3811 add_debugfs_mem(adap, "mc0", MEM_MC0,
3812 EXT_MEM0_SIZE_G(size));
3813 }
3814 if (i & EXT_MEM1_ENABLE_F) {
3815 size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
3816 add_debugfs_mem(adap, "mc1", MEM_MC1,
3817 EXT_MEM1_SIZE_G(size));
3818 }
3819 } else {
3820 if (i & EXT_MEM_ENABLE_F) {
3821 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
3822 add_debugfs_mem(adap, "mc", MEM_MC,
3823 EXT_MEM_SIZE_G(size));
3824 }
3825
3826 if (i & HMA_MUX_F) {
3827 size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
3828 add_debugfs_mem(adap, "hma", MEM_HMA,
3829 EXT_MEM1_SIZE_G(size));
3830 }
3831 }
3832
3833 debugfs_create_file_size("flash", 0400, adap->debugfs_root, adap,
3834 &flash_debugfs_fops, adap->params.sf_size);
3835 debugfs_create_bool("use_backdoor", 0600,
3836 adap->debugfs_root, &adap->use_bd);
3837 debugfs_create_bool("trace_rss", 0600,
3838 adap->debugfs_root, &adap->trace_rss);
3839
3840 return 0;
3841}
3842