2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
4 * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 #include <linux/seq_file.h>
36 #include <linux/debugfs.h>
37 #include <linux/string_helpers.h>
38 #include <linux/sort.h>
39 #include <linux/ctype.h>
44 #include "cxgb4_debugfs.h"
48 /* generic seq_file support for showing a table of size rows x width. */
49 static void *seq_tab_get_idx(struct seq_tab
*tb
, loff_t pos
)
51 pos
-= tb
->skip_first
;
52 return pos
>= tb
->rows
? NULL
: &tb
->data
[pos
* tb
->width
];
55 static void *seq_tab_start(struct seq_file
*seq
, loff_t
*pos
)
57 struct seq_tab
*tb
= seq
->private;
59 if (tb
->skip_first
&& *pos
== 0)
60 return SEQ_START_TOKEN
;
62 return seq_tab_get_idx(tb
, *pos
);
65 static void *seq_tab_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
67 v
= seq_tab_get_idx(seq
->private, *pos
+ 1);
73 static void seq_tab_stop(struct seq_file
*seq
, void *v
)
77 static int seq_tab_show(struct seq_file
*seq
, void *v
)
79 const struct seq_tab
*tb
= seq
->private;
81 return tb
->show(seq
, v
, ((char *)v
- tb
->data
) / tb
->width
);
84 static const struct seq_operations seq_tab_ops
= {
85 .start
= seq_tab_start
,
91 struct seq_tab
*seq_open_tab(struct file
*f
, unsigned int rows
,
92 unsigned int width
, unsigned int have_header
,
93 int (*show
)(struct seq_file
*seq
, void *v
, int i
))
97 p
= __seq_open_private(f
, &seq_tab_ops
, sizeof(*p
) + rows
* width
);
102 p
->skip_first
= have_header
!= 0;
107 /* Trim the size of a seq_tab to the supplied number of rows. The operation is
110 static int seq_tab_trim(struct seq_tab
*p
, unsigned int new_rows
)
112 if (new_rows
> p
->rows
)
118 static int cim_la_show(struct seq_file
*seq
, void *v
, int idx
)
120 if (v
== SEQ_START_TOKEN
)
121 seq_puts(seq
, "Status Data PC LS0Stat LS0Addr "
127 " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
128 (p
[0] >> 4) & 0xff, p
[0] & 0xf, p
[1] >> 4,
129 p
[1] & 0xf, p
[2] >> 4, p
[2] & 0xf, p
[3], p
[4], p
[5],
135 static int cim_la_show_3in1(struct seq_file
*seq
, void *v
, int idx
)
137 if (v
== SEQ_START_TOKEN
) {
138 seq_puts(seq
, "Status Data PC\n");
142 seq_printf(seq
, " %02x %08x %08x\n", p
[5] & 0xff, p
[6],
144 seq_printf(seq
, " %02x %02x%06x %02x%06x\n",
145 (p
[3] >> 8) & 0xff, p
[3] & 0xff, p
[4] >> 8,
146 p
[4] & 0xff, p
[5] >> 8);
147 seq_printf(seq
, " %02x %x%07x %x%07x\n", (p
[0] >> 4) & 0xff,
148 p
[0] & 0xf, p
[1] >> 4, p
[1] & 0xf, p
[2] >> 4);
153 static int cim_la_open(struct inode
*inode
, struct file
*file
)
158 struct adapter
*adap
= inode
->i_private
;
160 ret
= t4_cim_read(adap
, UP_UP_DBG_LA_CFG_A
, 1, &cfg
);
164 p
= seq_open_tab(file
, adap
->params
.cim_la_size
/ 8, 8 * sizeof(u32
), 1,
165 cfg
& UPDBGLACAPTPCONLY_F
?
166 cim_la_show_3in1
: cim_la_show
);
170 ret
= t4_cim_read_la(adap
, (u32
*)p
->data
, NULL
);
172 seq_release_private(inode
, file
);
176 static const struct file_operations cim_la_fops
= {
177 .owner
= THIS_MODULE
,
181 .release
= seq_release_private
184 static int cim_qcfg_show(struct seq_file
*seq
, void *v
)
186 static const char * const qname
[] = {
187 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
188 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
193 struct adapter
*adap
= seq
->private;
194 u16 base
[CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
];
195 u16 size
[CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
];
196 u32 stat
[(4 * (CIM_NUM_IBQ
+ CIM_NUM_OBQ_T5
))];
197 u16 thres
[CIM_NUM_IBQ
];
198 u32 obq_wr_t4
[2 * CIM_NUM_OBQ
], *wr
;
199 u32 obq_wr_t5
[2 * CIM_NUM_OBQ_T5
];
201 int cim_num_obq
= is_t4(adap
->params
.chip
) ?
202 CIM_NUM_OBQ
: CIM_NUM_OBQ_T5
;
204 i
= t4_cim_read(adap
, is_t4(adap
->params
.chip
) ? UP_IBQ_0_RDADDR_A
:
205 UP_IBQ_0_SHADOW_RDADDR_A
,
206 ARRAY_SIZE(stat
), stat
);
208 if (is_t4(adap
->params
.chip
)) {
209 i
= t4_cim_read(adap
, UP_OBQ_0_REALADDR_A
,
210 ARRAY_SIZE(obq_wr_t4
), obq_wr_t4
);
213 i
= t4_cim_read(adap
, UP_OBQ_0_SHADOW_REALADDR_A
,
214 ARRAY_SIZE(obq_wr_t5
), obq_wr_t5
);
221 t4_read_cimq_cfg(adap
, base
, size
, thres
);
224 " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
225 for (i
= 0; i
< CIM_NUM_IBQ
; i
++, p
+= 4)
226 seq_printf(seq
, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
227 qname
[i
], base
[i
], size
[i
], thres
[i
],
228 IBQRDADDR_G(p
[0]), IBQWRADDR_G(p
[1]),
229 QUESOPCNT_G(p
[3]), QUEEOPCNT_G(p
[3]),
230 QUEREMFLITS_G(p
[2]) * 16);
231 for ( ; i
< CIM_NUM_IBQ
+ cim_num_obq
; i
++, p
+= 4, wr
+= 2)
232 seq_printf(seq
, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
233 qname
[i
], base
[i
], size
[i
],
234 QUERDADDR_G(p
[0]) & 0x3fff, wr
[0] - base
[i
],
235 QUESOPCNT_G(p
[3]), QUEEOPCNT_G(p
[3]),
236 QUEREMFLITS_G(p
[2]) * 16);
240 static int cim_qcfg_open(struct inode
*inode
, struct file
*file
)
242 return single_open(file
, cim_qcfg_show
, inode
->i_private
);
245 static const struct file_operations cim_qcfg_fops
= {
246 .owner
= THIS_MODULE
,
247 .open
= cim_qcfg_open
,
250 .release
= single_release
,
253 static int cimq_show(struct seq_file
*seq
, void *v
, int idx
)
257 seq_printf(seq
, "%#06x: %08x %08x %08x %08x\n", idx
* 16, p
[0], p
[1],
262 static int cim_ibq_open(struct inode
*inode
, struct file
*file
)
266 unsigned int qid
= (uintptr_t)inode
->i_private
& 7;
267 struct adapter
*adap
= inode
->i_private
- qid
;
269 p
= seq_open_tab(file
, CIM_IBQ_SIZE
, 4 * sizeof(u32
), 0, cimq_show
);
273 ret
= t4_read_cim_ibq(adap
, qid
, (u32
*)p
->data
, CIM_IBQ_SIZE
* 4);
275 seq_release_private(inode
, file
);
281 static const struct file_operations cim_ibq_fops
= {
282 .owner
= THIS_MODULE
,
283 .open
= cim_ibq_open
,
286 .release
= seq_release_private
289 static int cim_obq_open(struct inode
*inode
, struct file
*file
)
293 unsigned int qid
= (uintptr_t)inode
->i_private
& 7;
294 struct adapter
*adap
= inode
->i_private
- qid
;
296 p
= seq_open_tab(file
, 6 * CIM_OBQ_SIZE
, 4 * sizeof(u32
), 0, cimq_show
);
300 ret
= t4_read_cim_obq(adap
, qid
, (u32
*)p
->data
, 6 * CIM_OBQ_SIZE
* 4);
302 seq_release_private(inode
, file
);
304 seq_tab_trim(p
, ret
/ 4);
310 static const struct file_operations cim_obq_fops
= {
311 .owner
= THIS_MODULE
,
312 .open
= cim_obq_open
,
315 .release
= seq_release_private
318 /* Firmware Device Log dump. */
319 static const char * const devlog_level_strings
[] = {
320 [FW_DEVLOG_LEVEL_EMERG
] = "EMERG",
321 [FW_DEVLOG_LEVEL_CRIT
] = "CRIT",
322 [FW_DEVLOG_LEVEL_ERR
] = "ERR",
323 [FW_DEVLOG_LEVEL_NOTICE
] = "NOTICE",
324 [FW_DEVLOG_LEVEL_INFO
] = "INFO",
325 [FW_DEVLOG_LEVEL_DEBUG
] = "DEBUG"
328 static const char * const devlog_facility_strings
[] = {
329 [FW_DEVLOG_FACILITY_CORE
] = "CORE",
330 [FW_DEVLOG_FACILITY_SCHED
] = "SCHED",
331 [FW_DEVLOG_FACILITY_TIMER
] = "TIMER",
332 [FW_DEVLOG_FACILITY_RES
] = "RES",
333 [FW_DEVLOG_FACILITY_HW
] = "HW",
334 [FW_DEVLOG_FACILITY_FLR
] = "FLR",
335 [FW_DEVLOG_FACILITY_DMAQ
] = "DMAQ",
336 [FW_DEVLOG_FACILITY_PHY
] = "PHY",
337 [FW_DEVLOG_FACILITY_MAC
] = "MAC",
338 [FW_DEVLOG_FACILITY_PORT
] = "PORT",
339 [FW_DEVLOG_FACILITY_VI
] = "VI",
340 [FW_DEVLOG_FACILITY_FILTER
] = "FILTER",
341 [FW_DEVLOG_FACILITY_ACL
] = "ACL",
342 [FW_DEVLOG_FACILITY_TM
] = "TM",
343 [FW_DEVLOG_FACILITY_QFC
] = "QFC",
344 [FW_DEVLOG_FACILITY_DCB
] = "DCB",
345 [FW_DEVLOG_FACILITY_ETH
] = "ETH",
346 [FW_DEVLOG_FACILITY_OFLD
] = "OFLD",
347 [FW_DEVLOG_FACILITY_RI
] = "RI",
348 [FW_DEVLOG_FACILITY_ISCSI
] = "ISCSI",
349 [FW_DEVLOG_FACILITY_FCOE
] = "FCOE",
350 [FW_DEVLOG_FACILITY_FOISCSI
] = "FOISCSI",
351 [FW_DEVLOG_FACILITY_FOFCOE
] = "FOFCOE"
354 /* Information gathered by Device Log Open routine for the display routine.
357 unsigned int nentries
; /* number of entries in log[] */
358 unsigned int first
; /* first [temporal] entry in log[] */
359 struct fw_devlog_e log
[0]; /* Firmware Device Log */
362 /* Dump a Firmaware Device Log entry.
364 static int devlog_show(struct seq_file
*seq
, void *v
)
366 if (v
== SEQ_START_TOKEN
)
367 seq_printf(seq
, "%10s %15s %8s %8s %s\n",
368 "Seq#", "Tstamp", "Level", "Facility", "Message");
370 struct devlog_info
*dinfo
= seq
->private;
371 int fidx
= (uintptr_t)v
- 2;
373 struct fw_devlog_e
*e
;
375 /* Get a pointer to the log entry to display. Skip unused log
378 index
= dinfo
->first
+ fidx
;
379 if (index
>= dinfo
->nentries
)
380 index
-= dinfo
->nentries
;
381 e
= &dinfo
->log
[index
];
382 if (e
->timestamp
== 0)
385 /* Print the message. This depends on the firmware using
386 * exactly the same formating strings as the kernel so we may
387 * eventually have to put a format interpreter in here ...
389 seq_printf(seq
, "%10d %15llu %8s %8s ",
390 e
->seqno
, e
->timestamp
,
391 (e
->level
< ARRAY_SIZE(devlog_level_strings
)
392 ? devlog_level_strings
[e
->level
]
394 (e
->facility
< ARRAY_SIZE(devlog_facility_strings
)
395 ? devlog_facility_strings
[e
->facility
]
397 seq_printf(seq
, e
->fmt
, e
->params
[0], e
->params
[1],
398 e
->params
[2], e
->params
[3], e
->params
[4],
399 e
->params
[5], e
->params
[6], e
->params
[7]);
404 /* Sequential File Operations for Device Log.
406 static inline void *devlog_get_idx(struct devlog_info
*dinfo
, loff_t pos
)
408 if (pos
> dinfo
->nentries
)
411 return (void *)(uintptr_t)(pos
+ 1);
414 static void *devlog_start(struct seq_file
*seq
, loff_t
*pos
)
416 struct devlog_info
*dinfo
= seq
->private;
419 ? devlog_get_idx(dinfo
, *pos
)
423 static void *devlog_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
425 struct devlog_info
*dinfo
= seq
->private;
428 return devlog_get_idx(dinfo
, *pos
);
431 static void devlog_stop(struct seq_file
*seq
, void *v
)
435 static const struct seq_operations devlog_seq_ops
= {
436 .start
= devlog_start
,
442 /* Set up for reading the firmware's device log. We read the entire log here
443 * and then display it incrementally in devlog_show().
445 static int devlog_open(struct inode
*inode
, struct file
*file
)
447 struct adapter
*adap
= inode
->i_private
;
448 struct devlog_params
*dparams
= &adap
->params
.devlog
;
449 struct devlog_info
*dinfo
;
454 /* If we don't know where the log is we can't do anything.
456 if (dparams
->start
== 0)
459 /* Allocate the space to read in the firmware's device log and set up
460 * for the iterated call to our display function.
462 dinfo
= __seq_open_private(file
, &devlog_seq_ops
,
463 sizeof(*dinfo
) + dparams
->size
);
467 /* Record the basic log buffer information and read in the raw log.
469 dinfo
->nentries
= (dparams
->size
/ sizeof(struct fw_devlog_e
));
471 spin_lock(&adap
->win0_lock
);
472 ret
= t4_memory_rw(adap
, adap
->params
.drv_memwin
, dparams
->memtype
,
473 dparams
->start
, dparams
->size
, (__be32
*)dinfo
->log
,
475 spin_unlock(&adap
->win0_lock
);
477 seq_release_private(inode
, file
);
481 /* Translate log multi-byte integral elements into host native format
482 * and determine where the first entry in the log is.
484 for (fseqno
= ~((u32
)0), index
= 0; index
< dinfo
->nentries
; index
++) {
485 struct fw_devlog_e
*e
= &dinfo
->log
[index
];
489 if (e
->timestamp
== 0)
492 e
->timestamp
= (__force __be64
)be64_to_cpu(e
->timestamp
);
493 seqno
= be32_to_cpu(e
->seqno
);
494 for (i
= 0; i
< 8; i
++)
496 (__force __be32
)be32_to_cpu(e
->params
[i
]);
498 if (seqno
< fseqno
) {
500 dinfo
->first
= index
;
506 static const struct file_operations devlog_fops
= {
507 .owner
= THIS_MODULE
,
511 .release
= seq_release_private
514 static ssize_t
flash_read(struct file
*file
, char __user
*buf
, size_t count
,
518 loff_t avail
= FILE_DATA(file
)->i_size
;
519 struct adapter
*adap
= file
->private_data
;
525 if (count
> avail
- pos
)
534 len
= min(count
+ ofst
, sizeof(data
));
535 ret
= t4_read_flash(adap
, pos
- ofst
, (len
+ 3) / 4,
541 if (copy_to_user(buf
, data
+ ofst
, len
))
553 static const struct file_operations flash_debugfs_fops
= {
554 .owner
= THIS_MODULE
,
559 static inline void tcamxy2valmask(u64 x
, u64 y
, u8
*addr
, u64
*mask
)
562 y
= (__force u64
)cpu_to_be64(y
);
563 memcpy(addr
, (char *)&y
+ 2, ETH_ALEN
);
566 static int mps_tcam_show(struct seq_file
*seq
, void *v
)
568 if (v
== SEQ_START_TOKEN
)
569 seq_puts(seq
, "Idx Ethernet address Mask Vld Ports PF"
575 struct adapter
*adap
= seq
->private;
576 unsigned int idx
= (uintptr_t)v
- 2;
577 u64 tcamy
= t4_read_reg64(adap
, MPS_CLS_TCAM_Y_L(idx
));
578 u64 tcamx
= t4_read_reg64(adap
, MPS_CLS_TCAM_X_L(idx
));
579 u32 cls_lo
= t4_read_reg(adap
, MPS_CLS_SRAM_L(idx
));
580 u32 cls_hi
= t4_read_reg(adap
, MPS_CLS_SRAM_H(idx
));
581 u32 rplc
[4] = {0, 0, 0, 0};
584 seq_printf(seq
, "%3u -\n", idx
);
588 if (cls_lo
& REPLICATE_F
) {
589 struct fw_ldst_cmd ldst_cmd
;
592 memset(&ldst_cmd
, 0, sizeof(ldst_cmd
));
593 ldst_cmd
.op_to_addrspace
=
594 htonl(FW_CMD_OP_V(FW_LDST_CMD
) |
597 FW_LDST_CMD_ADDRSPACE_V(
598 FW_LDST_ADDRSPC_MPS
));
599 ldst_cmd
.cycles_to_len16
= htonl(FW_LEN16(ldst_cmd
));
600 ldst_cmd
.u
.mps
.fid_ctl
=
601 htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC
) |
602 FW_LDST_CMD_CTL_V(idx
));
603 ret
= t4_wr_mbox(adap
, adap
->mbox
, &ldst_cmd
,
604 sizeof(ldst_cmd
), &ldst_cmd
);
606 dev_warn(adap
->pdev_dev
, "Can't read MPS "
607 "replication map for idx %d: %d\n",
610 rplc
[0] = ntohl(ldst_cmd
.u
.mps
.rplc31_0
);
611 rplc
[1] = ntohl(ldst_cmd
.u
.mps
.rplc63_32
);
612 rplc
[2] = ntohl(ldst_cmd
.u
.mps
.rplc95_64
);
613 rplc
[3] = ntohl(ldst_cmd
.u
.mps
.rplc127_96
);
617 tcamxy2valmask(tcamx
, tcamy
, addr
, &mask
);
618 seq_printf(seq
, "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx"
620 idx
, addr
[0], addr
[1], addr
[2], addr
[3], addr
[4],
621 addr
[5], (unsigned long long)mask
,
622 (cls_lo
& SRAM_VLD_F
) ? 'Y' : 'N', PORTMAP_G(cls_hi
),
624 (cls_lo
& VF_VALID_F
) ? VF_G(cls_lo
) : -1);
625 if (cls_lo
& REPLICATE_F
)
626 seq_printf(seq
, " %08x %08x %08x %08x",
627 rplc
[3], rplc
[2], rplc
[1], rplc
[0]);
629 seq_printf(seq
, "%36c", ' ');
630 seq_printf(seq
, "%4u%3u%3u%3u %#x\n",
631 SRAM_PRIO0_G(cls_lo
), SRAM_PRIO1_G(cls_lo
),
632 SRAM_PRIO2_G(cls_lo
), SRAM_PRIO3_G(cls_lo
),
633 (cls_lo
>> MULTILISTEN0_S
) & 0xf);
638 static inline void *mps_tcam_get_idx(struct seq_file
*seq
, loff_t pos
)
640 struct adapter
*adap
= seq
->private;
641 int max_mac_addr
= is_t4(adap
->params
.chip
) ?
642 NUM_MPS_CLS_SRAM_L_INSTANCES
:
643 NUM_MPS_T5_CLS_SRAM_L_INSTANCES
;
644 return ((pos
<= max_mac_addr
) ? (void *)(uintptr_t)(pos
+ 1) : NULL
);
647 static void *mps_tcam_start(struct seq_file
*seq
, loff_t
*pos
)
649 return *pos
? mps_tcam_get_idx(seq
, *pos
) : SEQ_START_TOKEN
;
652 static void *mps_tcam_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
655 return mps_tcam_get_idx(seq
, *pos
);
658 static void mps_tcam_stop(struct seq_file
*seq
, void *v
)
662 static const struct seq_operations mps_tcam_seq_ops
= {
663 .start
= mps_tcam_start
,
664 .next
= mps_tcam_next
,
665 .stop
= mps_tcam_stop
,
666 .show
= mps_tcam_show
669 static int mps_tcam_open(struct inode
*inode
, struct file
*file
)
671 int res
= seq_open(file
, &mps_tcam_seq_ops
);
674 struct seq_file
*seq
= file
->private_data
;
676 seq
->private = inode
->i_private
;
681 static const struct file_operations mps_tcam_debugfs_fops
= {
682 .owner
= THIS_MODULE
,
683 .open
= mps_tcam_open
,
686 .release
= seq_release
,
689 #if IS_ENABLED(CONFIG_IPV6)
690 static int clip_tbl_open(struct inode
*inode
, struct file
*file
)
692 return single_open(file
, clip_tbl_show
, PDE_DATA(inode
));
695 static const struct file_operations clip_tbl_debugfs_fops
= {
696 .owner
= THIS_MODULE
,
697 .open
= clip_tbl_open
,
700 .release
= single_release
707 static int rss_show(struct seq_file
*seq
, void *v
, int idx
)
711 seq_printf(seq
, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
712 idx
* 8, entry
[0], entry
[1], entry
[2], entry
[3], entry
[4],
713 entry
[5], entry
[6], entry
[7]);
717 static int rss_open(struct inode
*inode
, struct file
*file
)
721 struct adapter
*adap
= inode
->i_private
;
723 p
= seq_open_tab(file
, RSS_NENTRIES
/ 8, 8 * sizeof(u16
), 0, rss_show
);
727 ret
= t4_read_rss(adap
, (u16
*)p
->data
);
729 seq_release_private(inode
, file
);
734 static const struct file_operations rss_debugfs_fops
= {
735 .owner
= THIS_MODULE
,
739 .release
= seq_release_private
742 /* RSS Configuration.
745 /* Small utility function to return the strings "yes" or "no" if the supplied
746 * argument is non-zero.
748 static const char *yesno(int x
)
750 static const char *yes
= "yes";
751 static const char *no
= "no";
756 static int rss_config_show(struct seq_file
*seq
, void *v
)
758 struct adapter
*adapter
= seq
->private;
759 static const char * const keymode
[] = {
761 "global and per-VF scramble",
762 "per-PF and per-VF scramble",
763 "per-VF and per-VF scramble",
767 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_A
);
768 seq_printf(seq
, "TP_RSS_CONFIG: %#x\n", rssconf
);
769 seq_printf(seq
, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf
&
771 seq_printf(seq
, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf
&
773 seq_printf(seq
, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf
&
775 seq_printf(seq
, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf
&
777 seq_printf(seq
, " TnlTcpSel: %3s\n", yesno(rssconf
& TNLTCPSEL_F
));
778 seq_printf(seq
, " TnlIp6Sel: %3s\n", yesno(rssconf
& TNLIP6SEL_F
));
779 seq_printf(seq
, " TnlVrtSel: %3s\n", yesno(rssconf
& TNLVRTSEL_F
));
780 seq_printf(seq
, " TnlMapEn: %3s\n", yesno(rssconf
& TNLMAPEN_F
));
781 seq_printf(seq
, " OfdHashSave: %3s\n", yesno(rssconf
&
783 seq_printf(seq
, " OfdVrtSel: %3s\n", yesno(rssconf
& OFDVRTSEL_F
));
784 seq_printf(seq
, " OfdMapEn: %3s\n", yesno(rssconf
& OFDMAPEN_F
));
785 seq_printf(seq
, " OfdLkpEn: %3s\n", yesno(rssconf
& OFDLKPEN_F
));
786 seq_printf(seq
, " Syn4TupEnIpv6: %3s\n", yesno(rssconf
&
788 seq_printf(seq
, " Syn2TupEnIpv6: %3s\n", yesno(rssconf
&
790 seq_printf(seq
, " Syn4TupEnIpv4: %3s\n", yesno(rssconf
&
792 seq_printf(seq
, " Syn2TupEnIpv4: %3s\n", yesno(rssconf
&
794 seq_printf(seq
, " Syn4TupEnIpv6: %3s\n", yesno(rssconf
&
796 seq_printf(seq
, " SynIp6Sel: %3s\n", yesno(rssconf
& SYNIP6SEL_F
));
797 seq_printf(seq
, " SynVrt6Sel: %3s\n", yesno(rssconf
& SYNVRTSEL_F
));
798 seq_printf(seq
, " SynMapEn: %3s\n", yesno(rssconf
& SYNMAPEN_F
));
799 seq_printf(seq
, " SynLkpEn: %3s\n", yesno(rssconf
& SYNLKPEN_F
));
800 seq_printf(seq
, " ChnEn: %3s\n", yesno(rssconf
&
802 seq_printf(seq
, " PrtEn: %3s\n", yesno(rssconf
&
804 seq_printf(seq
, " TnlAllLkp: %3s\n", yesno(rssconf
&
806 seq_printf(seq
, " VrtEn: %3s\n", yesno(rssconf
&
808 seq_printf(seq
, " CngEn: %3s\n", yesno(rssconf
&
809 CONGESTIONENABLE_F
));
810 seq_printf(seq
, " HashToeplitz: %3s\n", yesno(rssconf
&
812 seq_printf(seq
, " Udp4En: %3s\n", yesno(rssconf
& UDPENABLE_F
));
813 seq_printf(seq
, " Disable: %3s\n", yesno(rssconf
& DISABLE_F
));
817 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_TNL_A
);
818 seq_printf(seq
, "TP_RSS_CONFIG_TNL: %#x\n", rssconf
);
819 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
820 seq_printf(seq
, " MaskFilter: %3d\n", MASKFILTER_G(rssconf
));
821 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) > CHELSIO_T5
) {
822 seq_printf(seq
, " HashAll: %3s\n",
823 yesno(rssconf
& HASHALL_F
));
824 seq_printf(seq
, " HashEth: %3s\n",
825 yesno(rssconf
& HASHETH_F
));
827 seq_printf(seq
, " UseWireCh: %3s\n", yesno(rssconf
& USEWIRECH_F
));
831 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_OFD_A
);
832 seq_printf(seq
, "TP_RSS_CONFIG_OFD: %#x\n", rssconf
);
833 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
834 seq_printf(seq
, " RRCplMapEn: %3s\n", yesno(rssconf
&
836 seq_printf(seq
, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf
));
840 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_SYN_A
);
841 seq_printf(seq
, "TP_RSS_CONFIG_SYN: %#x\n", rssconf
);
842 seq_printf(seq
, " MaskSize: %3d\n", MASKSIZE_G(rssconf
));
843 seq_printf(seq
, " UseWireCh: %3s\n", yesno(rssconf
& USEWIRECH_F
));
847 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_VRT_A
);
848 seq_printf(seq
, "TP_RSS_CONFIG_VRT: %#x\n", rssconf
);
849 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) > CHELSIO_T5
) {
850 seq_printf(seq
, " KeyWrAddrX: %3d\n",
851 KEYWRADDRX_G(rssconf
));
852 seq_printf(seq
, " KeyExtend: %3s\n",
853 yesno(rssconf
& KEYEXTEND_F
));
855 seq_printf(seq
, " VfRdRg: %3s\n", yesno(rssconf
& VFRDRG_F
));
856 seq_printf(seq
, " VfRdEn: %3s\n", yesno(rssconf
& VFRDEN_F
));
857 seq_printf(seq
, " VfPerrEn: %3s\n", yesno(rssconf
& VFPERREN_F
));
858 seq_printf(seq
, " KeyPerrEn: %3s\n", yesno(rssconf
& KEYPERREN_F
));
859 seq_printf(seq
, " DisVfVlan: %3s\n", yesno(rssconf
&
861 seq_printf(seq
, " EnUpSwt: %3s\n", yesno(rssconf
& ENABLEUP0_F
));
862 seq_printf(seq
, " HashDelay: %3d\n", HASHDELAY_G(rssconf
));
863 if (CHELSIO_CHIP_VERSION(adapter
->params
.chip
) <= CHELSIO_T5
)
864 seq_printf(seq
, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf
));
865 seq_printf(seq
, " KeyMode: %s\n", keymode
[KEYMODE_G(rssconf
)]);
866 seq_printf(seq
, " VfWrEn: %3s\n", yesno(rssconf
& VFWREN_F
));
867 seq_printf(seq
, " KeyWrEn: %3s\n", yesno(rssconf
& KEYWREN_F
));
868 seq_printf(seq
, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf
));
872 rssconf
= t4_read_reg(adapter
, TP_RSS_CONFIG_CNG_A
);
873 seq_printf(seq
, "TP_RSS_CONFIG_CNG: %#x\n", rssconf
);
874 seq_printf(seq
, " ChnCount3: %3s\n", yesno(rssconf
& CHNCOUNT3_F
));
875 seq_printf(seq
, " ChnCount2: %3s\n", yesno(rssconf
& CHNCOUNT2_F
));
876 seq_printf(seq
, " ChnCount1: %3s\n", yesno(rssconf
& CHNCOUNT1_F
));
877 seq_printf(seq
, " ChnCount0: %3s\n", yesno(rssconf
& CHNCOUNT0_F
));
878 seq_printf(seq
, " ChnUndFlow3: %3s\n", yesno(rssconf
&
880 seq_printf(seq
, " ChnUndFlow2: %3s\n", yesno(rssconf
&
882 seq_printf(seq
, " ChnUndFlow1: %3s\n", yesno(rssconf
&
884 seq_printf(seq
, " ChnUndFlow0: %3s\n", yesno(rssconf
&
886 seq_printf(seq
, " RstChn3: %3s\n", yesno(rssconf
& RSTCHN3_F
));
887 seq_printf(seq
, " RstChn2: %3s\n", yesno(rssconf
& RSTCHN2_F
));
888 seq_printf(seq
, " RstChn1: %3s\n", yesno(rssconf
& RSTCHN1_F
));
889 seq_printf(seq
, " RstChn0: %3s\n", yesno(rssconf
& RSTCHN0_F
));
890 seq_printf(seq
, " UpdVld: %3s\n", yesno(rssconf
& UPDVLD_F
));
891 seq_printf(seq
, " Xoff: %3s\n", yesno(rssconf
& XOFF_F
));
892 seq_printf(seq
, " UpdChn3: %3s\n", yesno(rssconf
& UPDCHN3_F
));
893 seq_printf(seq
, " UpdChn2: %3s\n", yesno(rssconf
& UPDCHN2_F
));
894 seq_printf(seq
, " UpdChn1: %3s\n", yesno(rssconf
& UPDCHN1_F
));
895 seq_printf(seq
, " UpdChn0: %3s\n", yesno(rssconf
& UPDCHN0_F
));
896 seq_printf(seq
, " Queue: %3d\n", QUEUE_G(rssconf
));
901 DEFINE_SIMPLE_DEBUGFS_FILE(rss_config
);
906 static int rss_key_show(struct seq_file
*seq
, void *v
)
910 t4_read_rss_key(seq
->private, key
);
911 seq_printf(seq
, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
912 key
[9], key
[8], key
[7], key
[6], key
[5], key
[4], key
[3],
913 key
[2], key
[1], key
[0]);
917 static int rss_key_open(struct inode
*inode
, struct file
*file
)
919 return single_open(file
, rss_key_show
, inode
->i_private
);
922 static ssize_t
rss_key_write(struct file
*file
, const char __user
*buf
,
923 size_t count
, loff_t
*pos
)
928 struct adapter
*adap
= FILE_DATA(file
)->i_private
;
930 if (count
> sizeof(s
) - 1)
932 if (copy_from_user(s
, buf
, count
))
934 for (i
= count
; i
> 0 && isspace(s
[i
- 1]); i
--)
938 for (p
= s
, i
= 9; i
>= 0; i
--) {
940 for (j
= 0; j
< 8; j
++, p
++) {
943 key
[i
] = (key
[i
] << 4) | hex2val(*p
);
947 t4_write_rss_key(adap
, key
, -1);
951 static const struct file_operations rss_key_debugfs_fops
= {
952 .owner
= THIS_MODULE
,
953 .open
= rss_key_open
,
956 .release
= single_release
,
957 .write
= rss_key_write
960 /* PF RSS Configuration.
969 static int rss_pf_config_show(struct seq_file
*seq
, void *v
, int idx
)
971 struct rss_pf_conf
*pfconf
;
973 if (v
== SEQ_START_TOKEN
) {
974 /* use the 0th entry to dump the PF Map Index Size */
975 pfconf
= seq
->private + offsetof(struct seq_tab
, data
);
976 seq_printf(seq
, "PF Map Index Size = %d\n\n",
977 LKPIDXSIZE_G(pfconf
->rss_pf_map
));
979 seq_puts(seq
, " RSS PF VF Hash Tuple Enable Default\n");
980 seq_puts(seq
, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
981 seq_puts(seq
, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
983 #define G_PFnLKPIDX(map, n) \
984 (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
985 #define G_PFnMSKSIZE(mask, n) \
986 (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
989 seq_printf(seq
, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
991 yesno(pfconf
->rss_pf_config
& MAPENABLE_F
),
992 yesno(pfconf
->rss_pf_config
& CHNENABLE_F
),
993 yesno(pfconf
->rss_pf_config
& PRTENABLE_F
),
994 G_PFnLKPIDX(pfconf
->rss_pf_map
, idx
),
995 G_PFnMSKSIZE(pfconf
->rss_pf_mask
, idx
),
996 IVFWIDTH_G(pfconf
->rss_pf_config
),
997 yesno(pfconf
->rss_pf_config
& IP6FOURTUPEN_F
),
998 yesno(pfconf
->rss_pf_config
& IP6TWOTUPEN_F
),
999 yesno(pfconf
->rss_pf_config
& IP4FOURTUPEN_F
),
1000 yesno(pfconf
->rss_pf_config
& IP4TWOTUPEN_F
),
1001 yesno(pfconf
->rss_pf_config
& UDPFOURTUPEN_F
),
1002 CH1DEFAULTQUEUE_G(pfconf
->rss_pf_config
),
1003 CH0DEFAULTQUEUE_G(pfconf
->rss_pf_config
));
1011 static int rss_pf_config_open(struct inode
*inode
, struct file
*file
)
1013 struct adapter
*adapter
= inode
->i_private
;
1015 u32 rss_pf_map
, rss_pf_mask
;
1016 struct rss_pf_conf
*pfconf
;
1019 p
= seq_open_tab(file
, 8, sizeof(*pfconf
), 1, rss_pf_config_show
);
1023 pfconf
= (struct rss_pf_conf
*)p
->data
;
1024 rss_pf_map
= t4_read_rss_pf_map(adapter
);
1025 rss_pf_mask
= t4_read_rss_pf_mask(adapter
);
1026 for (pf
= 0; pf
< 8; pf
++) {
1027 pfconf
[pf
].rss_pf_map
= rss_pf_map
;
1028 pfconf
[pf
].rss_pf_mask
= rss_pf_mask
;
1029 t4_read_rss_pf_config(adapter
, pf
, &pfconf
[pf
].rss_pf_config
);
1034 static const struct file_operations rss_pf_config_debugfs_fops
= {
1035 .owner
= THIS_MODULE
,
1036 .open
= rss_pf_config_open
,
1038 .llseek
= seq_lseek
,
1039 .release
= seq_release_private
1042 /* VF RSS Configuration.
1045 struct rss_vf_conf
{
1050 static int rss_vf_config_show(struct seq_file
*seq
, void *v
, int idx
)
1052 if (v
== SEQ_START_TOKEN
) {
1053 seq_puts(seq
, " RSS Hash Tuple Enable\n");
1054 seq_puts(seq
, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
1055 seq_puts(seq
, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
1057 struct rss_vf_conf
*vfconf
= v
;
1059 seq_printf(seq
, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
1061 yesno(vfconf
->rss_vf_vfh
& VFCHNEN_F
),
1062 yesno(vfconf
->rss_vf_vfh
& VFPRTEN_F
),
1063 VFLKPIDX_G(vfconf
->rss_vf_vfh
),
1064 yesno(vfconf
->rss_vf_vfh
& VFVLNEX_F
),
1065 yesno(vfconf
->rss_vf_vfh
& VFUPEN_F
),
1066 yesno(vfconf
->rss_vf_vfh
& VFIP4FOURTUPEN_F
),
1067 yesno(vfconf
->rss_vf_vfh
& VFIP6TWOTUPEN_F
),
1068 yesno(vfconf
->rss_vf_vfh
& VFIP4FOURTUPEN_F
),
1069 yesno(vfconf
->rss_vf_vfh
& VFIP4TWOTUPEN_F
),
1070 yesno(vfconf
->rss_vf_vfh
& ENABLEUDPHASH_F
),
1071 DEFAULTQUEUE_G(vfconf
->rss_vf_vfh
),
1072 KEYINDEX_G(vfconf
->rss_vf_vfh
),
1073 vfconf
->rss_vf_vfl
);
1078 static int rss_vf_config_open(struct inode
*inode
, struct file
*file
)
1080 struct adapter
*adapter
= inode
->i_private
;
1082 struct rss_vf_conf
*vfconf
;
1085 p
= seq_open_tab(file
, 128, sizeof(*vfconf
), 1, rss_vf_config_show
);
1089 vfconf
= (struct rss_vf_conf
*)p
->data
;
1090 for (vf
= 0; vf
< 128; vf
++) {
1091 t4_read_rss_vf_config(adapter
, vf
, &vfconf
[vf
].rss_vf_vfl
,
1092 &vfconf
[vf
].rss_vf_vfh
);
1097 static const struct file_operations rss_vf_config_debugfs_fops
= {
1098 .owner
= THIS_MODULE
,
1099 .open
= rss_vf_config_open
,
1101 .llseek
= seq_lseek
,
1102 .release
= seq_release_private
1105 static int sge_qinfo_show(struct seq_file
*seq
, void *v
)
1107 struct adapter
*adap
= seq
->private;
1108 int eth_entries
= DIV_ROUND_UP(adap
->sge
.ethqsets
, 4);
1109 int toe_entries
= DIV_ROUND_UP(adap
->sge
.ofldqsets
, 4);
1110 int rdma_entries
= DIV_ROUND_UP(adap
->sge
.rdmaqs
, 4);
1111 int ciq_entries
= DIV_ROUND_UP(adap
->sge
.rdmaciqs
, 4);
1112 int ctrl_entries
= DIV_ROUND_UP(MAX_CTRL_QUEUES
, 4);
1113 int i
, r
= (uintptr_t)v
- 1;
1114 int toe_idx
= r
- eth_entries
;
1115 int rdma_idx
= toe_idx
- toe_entries
;
1116 int ciq_idx
= rdma_idx
- rdma_entries
;
1117 int ctrl_idx
= ciq_idx
- ciq_entries
;
1118 int fq_idx
= ctrl_idx
- ctrl_entries
;
1121 seq_putc(seq
, '\n');
1123 #define S3(fmt_spec, s, v) \
1125 seq_printf(seq, "%-12s", s); \
1126 for (i = 0; i < n; ++i) \
1127 seq_printf(seq, " %16" fmt_spec, v); \
1128 seq_putc(seq, '\n'); \
1130 #define S(s, v) S3("s", s, v)
1131 #define T(s, v) S3("u", s, tx[i].v)
1132 #define R(s, v) S3("u", s, rx[i].v)
1134 if (r
< eth_entries
) {
1135 int base_qset
= r
* 4;
1136 const struct sge_eth_rxq
*rx
= &adap
->sge
.ethrxq
[base_qset
];
1137 const struct sge_eth_txq
*tx
= &adap
->sge
.ethtxq
[base_qset
];
1138 int n
= min(4, adap
->sge
.ethqsets
- 4 * r
);
1140 S("QType:", "Ethernet");
1142 rx
[i
].rspq
.netdev
? rx
[i
].rspq
.netdev
->name
: "N/A");
1143 T("TxQ ID:", q
.cntxt_id
);
1144 T("TxQ size:", q
.size
);
1145 T("TxQ inuse:", q
.in_use
);
1146 T("TxQ CIDX:", q
.cidx
);
1147 T("TxQ PIDX:", q
.pidx
);
1148 #ifdef CONFIG_CXGB4_DCB
1149 T("DCB Prio:", dcb_prio
);
1150 S3("u", "DCB PGID:",
1151 (ethqset2pinfo(adap
, base_qset
+ i
)->dcb
.pgid
>>
1152 4*(7-tx
[i
].dcb_prio
)) & 0xf);
1154 (ethqset2pinfo(adap
, base_qset
+ i
)->dcb
.pfcen
>>
1155 1*(7-tx
[i
].dcb_prio
)) & 0x1);
1157 R("RspQ ID:", rspq
.abs_id
);
1158 R("RspQ size:", rspq
.size
);
1159 R("RspQE size:", rspq
.iqe_len
);
1160 R("RspQ CIDX:", rspq
.cidx
);
1161 R("RspQ Gen:", rspq
.gen
);
1162 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1163 S3("u", "Intr pktcnt:",
1164 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1165 R("FL ID:", fl
.cntxt_id
);
1166 R("FL size:", fl
.size
- 8);
1167 R("FL pend:", fl
.pend_cred
);
1168 R("FL avail:", fl
.avail
);
1169 R("FL PIDX:", fl
.pidx
);
1170 R("FL CIDX:", fl
.cidx
);
1171 } else if (toe_idx
< toe_entries
) {
1172 const struct sge_ofld_rxq
*rx
= &adap
->sge
.ofldrxq
[toe_idx
* 4];
1173 const struct sge_ofld_txq
*tx
= &adap
->sge
.ofldtxq
[toe_idx
* 4];
1174 int n
= min(4, adap
->sge
.ofldqsets
- 4 * toe_idx
);
1177 T("TxQ ID:", q
.cntxt_id
);
1178 T("TxQ size:", q
.size
);
1179 T("TxQ inuse:", q
.in_use
);
1180 T("TxQ CIDX:", q
.cidx
);
1181 T("TxQ PIDX:", q
.pidx
);
1182 R("RspQ ID:", rspq
.abs_id
);
1183 R("RspQ size:", rspq
.size
);
1184 R("RspQE size:", rspq
.iqe_len
);
1185 R("RspQ CIDX:", rspq
.cidx
);
1186 R("RspQ Gen:", rspq
.gen
);
1187 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1188 S3("u", "Intr pktcnt:",
1189 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1190 R("FL ID:", fl
.cntxt_id
);
1191 R("FL size:", fl
.size
- 8);
1192 R("FL pend:", fl
.pend_cred
);
1193 R("FL avail:", fl
.avail
);
1194 R("FL PIDX:", fl
.pidx
);
1195 R("FL CIDX:", fl
.cidx
);
1196 } else if (rdma_idx
< rdma_entries
) {
1197 const struct sge_ofld_rxq
*rx
=
1198 &adap
->sge
.rdmarxq
[rdma_idx
* 4];
1199 int n
= min(4, adap
->sge
.rdmaqs
- 4 * rdma_idx
);
1201 S("QType:", "RDMA-CPL");
1202 R("RspQ ID:", rspq
.abs_id
);
1203 R("RspQ size:", rspq
.size
);
1204 R("RspQE size:", rspq
.iqe_len
);
1205 R("RspQ CIDX:", rspq
.cidx
);
1206 R("RspQ Gen:", rspq
.gen
);
1207 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1208 S3("u", "Intr pktcnt:",
1209 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1210 R("FL ID:", fl
.cntxt_id
);
1211 R("FL size:", fl
.size
- 8);
1212 R("FL pend:", fl
.pend_cred
);
1213 R("FL avail:", fl
.avail
);
1214 R("FL PIDX:", fl
.pidx
);
1215 R("FL CIDX:", fl
.cidx
);
1216 } else if (ciq_idx
< ciq_entries
) {
1217 const struct sge_ofld_rxq
*rx
= &adap
->sge
.rdmaciq
[ciq_idx
* 4];
1218 int n
= min(4, adap
->sge
.rdmaciqs
- 4 * ciq_idx
);
1220 S("QType:", "RDMA-CIQ");
1221 R("RspQ ID:", rspq
.abs_id
);
1222 R("RspQ size:", rspq
.size
);
1223 R("RspQE size:", rspq
.iqe_len
);
1224 R("RspQ CIDX:", rspq
.cidx
);
1225 R("RspQ Gen:", rspq
.gen
);
1226 S3("u", "Intr delay:", qtimer_val(adap
, &rx
[i
].rspq
));
1227 S3("u", "Intr pktcnt:",
1228 adap
->sge
.counter_val
[rx
[i
].rspq
.pktcnt_idx
]);
1229 } else if (ctrl_idx
< ctrl_entries
) {
1230 const struct sge_ctrl_txq
*tx
= &adap
->sge
.ctrlq
[ctrl_idx
* 4];
1231 int n
= min(4, adap
->params
.nports
- 4 * ctrl_idx
);
1233 S("QType:", "Control");
1234 T("TxQ ID:", q
.cntxt_id
);
1235 T("TxQ size:", q
.size
);
1236 T("TxQ inuse:", q
.in_use
);
1237 T("TxQ CIDX:", q
.cidx
);
1238 T("TxQ PIDX:", q
.pidx
);
1239 } else if (fq_idx
== 0) {
1240 const struct sge_rspq
*evtq
= &adap
->sge
.fw_evtq
;
1242 seq_printf(seq
, "%-12s %16s\n", "QType:", "FW event queue");
1243 seq_printf(seq
, "%-12s %16u\n", "RspQ ID:", evtq
->abs_id
);
1244 seq_printf(seq
, "%-12s %16u\n", "RspQ size:", evtq
->size
);
1245 seq_printf(seq
, "%-12s %16u\n", "RspQE size:", evtq
->iqe_len
);
1246 seq_printf(seq
, "%-12s %16u\n", "RspQ CIDX:", evtq
->cidx
);
1247 seq_printf(seq
, "%-12s %16u\n", "RspQ Gen:", evtq
->gen
);
1248 seq_printf(seq
, "%-12s %16u\n", "Intr delay:",
1249 qtimer_val(adap
, evtq
));
1250 seq_printf(seq
, "%-12s %16u\n", "Intr pktcnt:",
1251 adap
->sge
.counter_val
[evtq
->pktcnt_idx
]);
1260 static int sge_queue_entries(const struct adapter
*adap
)
1262 return DIV_ROUND_UP(adap
->sge
.ethqsets
, 4) +
1263 DIV_ROUND_UP(adap
->sge
.ofldqsets
, 4) +
1264 DIV_ROUND_UP(adap
->sge
.rdmaqs
, 4) +
1265 DIV_ROUND_UP(adap
->sge
.rdmaciqs
, 4) +
1266 DIV_ROUND_UP(MAX_CTRL_QUEUES
, 4) + 1;
1269 static void *sge_queue_start(struct seq_file
*seq
, loff_t
*pos
)
1271 int entries
= sge_queue_entries(seq
->private);
1273 return *pos
< entries
? (void *)((uintptr_t)*pos
+ 1) : NULL
;
1276 static void sge_queue_stop(struct seq_file
*seq
, void *v
)
1280 static void *sge_queue_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
1282 int entries
= sge_queue_entries(seq
->private);
1285 return *pos
< entries
? (void *)((uintptr_t)*pos
+ 1) : NULL
;
1288 static const struct seq_operations sge_qinfo_seq_ops
= {
1289 .start
= sge_queue_start
,
1290 .next
= sge_queue_next
,
1291 .stop
= sge_queue_stop
,
1292 .show
= sge_qinfo_show
1295 static int sge_qinfo_open(struct inode
*inode
, struct file
*file
)
1297 int res
= seq_open(file
, &sge_qinfo_seq_ops
);
1300 struct seq_file
*seq
= file
->private_data
;
1302 seq
->private = inode
->i_private
;
1307 static const struct file_operations sge_qinfo_debugfs_fops
= {
1308 .owner
= THIS_MODULE
,
1309 .open
= sge_qinfo_open
,
1311 .llseek
= seq_lseek
,
1312 .release
= seq_release
,
1315 int mem_open(struct inode
*inode
, struct file
*file
)
1318 struct adapter
*adap
;
1320 file
->private_data
= inode
->i_private
;
1322 mem
= (uintptr_t)file
->private_data
& 0x3;
1323 adap
= file
->private_data
- mem
;
1325 (void)t4_fwcache(adap
, FW_PARAM_DEV_FWCACHE_FLUSH
);
1330 static ssize_t
mem_read(struct file
*file
, char __user
*buf
, size_t count
,
1334 loff_t avail
= file_inode(file
)->i_size
;
1335 unsigned int mem
= (uintptr_t)file
->private_data
& 3;
1336 struct adapter
*adap
= file
->private_data
- mem
;
1344 if (count
> avail
- pos
)
1345 count
= avail
- pos
;
1347 data
= t4_alloc_mem(count
);
1351 spin_lock(&adap
->win0_lock
);
1352 ret
= t4_memory_rw(adap
, 0, mem
, pos
, count
, data
, T4_MEMORY_READ
);
1353 spin_unlock(&adap
->win0_lock
);
1358 ret
= copy_to_user(buf
, data
, count
);
1364 *ppos
= pos
+ count
;
1367 static const struct file_operations mem_debugfs_fops
= {
1368 .owner
= THIS_MODULE
,
1369 .open
= simple_open
,
1371 .llseek
= default_llseek
,
1374 static void set_debugfs_file_size(struct dentry
*de
, loff_t size
)
1376 if (!IS_ERR(de
) && de
->d_inode
)
1377 de
->d_inode
->i_size
= size
;
1380 static void add_debugfs_mem(struct adapter
*adap
, const char *name
,
1381 unsigned int idx
, unsigned int size_mb
)
1385 de
= debugfs_create_file(name
, S_IRUSR
, adap
->debugfs_root
,
1386 (void *)adap
+ idx
, &mem_debugfs_fops
);
1387 if (de
&& de
->d_inode
)
1388 de
->d_inode
->i_size
= size_mb
<< 20;
1391 /* Add an array of Debug FS files.
1393 void add_debugfs_files(struct adapter
*adap
,
1394 struct t4_debugfs_entry
*files
,
1395 unsigned int nfiles
)
1399 /* debugfs support is best effort */
1400 for (i
= 0; i
< nfiles
; i
++)
1401 debugfs_create_file(files
[i
].name
, files
[i
].mode
,
1403 (void *)adap
+ files
[i
].data
,
1407 int t4_setup_debugfs(struct adapter
*adap
)
1413 static struct t4_debugfs_entry t4_debugfs_files
[] = {
1414 { "cim_la", &cim_la_fops
, S_IRUSR
, 0 },
1415 { "cim_qcfg", &cim_qcfg_fops
, S_IRUSR
, 0 },
1416 { "devlog", &devlog_fops
, S_IRUSR
, 0 },
1417 { "l2t", &t4_l2t_fops
, S_IRUSR
, 0},
1418 { "mps_tcam", &mps_tcam_debugfs_fops
, S_IRUSR
, 0 },
1419 { "rss", &rss_debugfs_fops
, S_IRUSR
, 0 },
1420 { "rss_config", &rss_config_debugfs_fops
, S_IRUSR
, 0 },
1421 { "rss_key", &rss_key_debugfs_fops
, S_IRUSR
, 0 },
1422 { "rss_pf_config", &rss_pf_config_debugfs_fops
, S_IRUSR
, 0 },
1423 { "rss_vf_config", &rss_vf_config_debugfs_fops
, S_IRUSR
, 0 },
1424 { "sge_qinfo", &sge_qinfo_debugfs_fops
, S_IRUSR
, 0 },
1425 { "ibq_tp0", &cim_ibq_fops
, S_IRUSR
, 0 },
1426 { "ibq_tp1", &cim_ibq_fops
, S_IRUSR
, 1 },
1427 { "ibq_ulp", &cim_ibq_fops
, S_IRUSR
, 2 },
1428 { "ibq_sge0", &cim_ibq_fops
, S_IRUSR
, 3 },
1429 { "ibq_sge1", &cim_ibq_fops
, S_IRUSR
, 4 },
1430 { "ibq_ncsi", &cim_ibq_fops
, S_IRUSR
, 5 },
1431 { "obq_ulp0", &cim_obq_fops
, S_IRUSR
, 0 },
1432 { "obq_ulp1", &cim_obq_fops
, S_IRUSR
, 1 },
1433 { "obq_ulp2", &cim_obq_fops
, S_IRUSR
, 2 },
1434 { "obq_ulp3", &cim_obq_fops
, S_IRUSR
, 3 },
1435 { "obq_sge", &cim_obq_fops
, S_IRUSR
, 4 },
1436 { "obq_ncsi", &cim_obq_fops
, S_IRUSR
, 5 },
1437 #if IS_ENABLED(CONFIG_IPV6)
1438 { "clip_tbl", &clip_tbl_debugfs_fops
, S_IRUSR
, 0 },
1442 /* Debug FS nodes common to all T5 and later adapters.
1444 static struct t4_debugfs_entry t5_debugfs_files
[] = {
1445 { "obq_sge_rx_q0", &cim_obq_fops
, S_IRUSR
, 6 },
1446 { "obq_sge_rx_q1", &cim_obq_fops
, S_IRUSR
, 7 },
1449 add_debugfs_files(adap
,
1451 ARRAY_SIZE(t4_debugfs_files
));
1452 if (!is_t4(adap
->params
.chip
))
1453 add_debugfs_files(adap
,
1455 ARRAY_SIZE(t5_debugfs_files
));
1457 i
= t4_read_reg(adap
, MA_TARGET_MEM_ENABLE_A
);
1458 if (i
& EDRAM0_ENABLE_F
) {
1459 size
= t4_read_reg(adap
, MA_EDRAM0_BAR_A
);
1460 add_debugfs_mem(adap
, "edc0", MEM_EDC0
, EDRAM0_SIZE_G(size
));
1462 if (i
& EDRAM1_ENABLE_F
) {
1463 size
= t4_read_reg(adap
, MA_EDRAM1_BAR_A
);
1464 add_debugfs_mem(adap
, "edc1", MEM_EDC1
, EDRAM1_SIZE_G(size
));
1466 if (is_t4(adap
->params
.chip
)) {
1467 size
= t4_read_reg(adap
, MA_EXT_MEMORY_BAR_A
);
1468 if (i
& EXT_MEM_ENABLE_F
)
1469 add_debugfs_mem(adap
, "mc", MEM_MC
,
1470 EXT_MEM_SIZE_G(size
));
1472 if (i
& EXT_MEM0_ENABLE_F
) {
1473 size
= t4_read_reg(adap
, MA_EXT_MEMORY0_BAR_A
);
1474 add_debugfs_mem(adap
, "mc0", MEM_MC0
,
1475 EXT_MEM0_SIZE_G(size
));
1477 if (i
& EXT_MEM1_ENABLE_F
) {
1478 size
= t4_read_reg(adap
, MA_EXT_MEMORY1_BAR_A
);
1479 add_debugfs_mem(adap
, "mc1", MEM_MC1
,
1480 EXT_MEM1_SIZE_G(size
));
1484 de
= debugfs_create_file("flash", S_IRUSR
, adap
->debugfs_root
, adap
,
1485 &flash_debugfs_fops
);
1486 set_debugfs_file_size(de
, adap
->params
.sf_size
);