blob: 714cc70b97ccf47834089e15a9f22ca60904481c [file] [log] [blame]
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301/*
2 * This file is part of the Chelsio T4 Ethernet driver for Linux.
3 *
4 * Copyright (c) 2003-2014 Chelsio Communications, Inc. All rights reserved.
5 *
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:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
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.
24 *
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
32 * SOFTWARE.
33 */
34
35#include <linux/seq_file.h>
36#include <linux/debugfs.h>
37#include <linux/string_helpers.h>
38#include <linux/sort.h>
Hariprasad Shenai688ea5f2015-01-20 12:02:21 +053039#include <linux/ctype.h>
Hariprasad Shenaifd88b312014-11-07 09:35:23 +053040
41#include "cxgb4.h"
42#include "t4_regs.h"
43#include "t4fw_api.h"
44#include "cxgb4_debugfs.h"
Anish Bhattb5a02f52015-01-14 15:17:34 -080045#include "clip_tbl.h"
Hariprasad Shenaifd88b312014-11-07 09:35:23 +053046#include "l2t.h"
47
Hariprasad Shenaif1ff24a2015-01-07 08:48:01 +053048/* generic seq_file support for showing a table of size rows x width. */
49static void *seq_tab_get_idx(struct seq_tab *tb, loff_t pos)
50{
51 pos -= tb->skip_first;
52 return pos >= tb->rows ? NULL : &tb->data[pos * tb->width];
53}
54
55static void *seq_tab_start(struct seq_file *seq, loff_t *pos)
56{
57 struct seq_tab *tb = seq->private;
58
59 if (tb->skip_first && *pos == 0)
60 return SEQ_START_TOKEN;
61
62 return seq_tab_get_idx(tb, *pos);
63}
64
65static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos)
66{
67 v = seq_tab_get_idx(seq->private, *pos + 1);
68 if (v)
69 ++*pos;
70 return v;
71}
72
73static void seq_tab_stop(struct seq_file *seq, void *v)
74{
75}
76
77static int seq_tab_show(struct seq_file *seq, void *v)
78{
79 const struct seq_tab *tb = seq->private;
80
81 return tb->show(seq, v, ((char *)v - tb->data) / tb->width);
82}
83
84static const struct seq_operations seq_tab_ops = {
85 .start = seq_tab_start,
86 .next = seq_tab_next,
87 .stop = seq_tab_stop,
88 .show = seq_tab_show
89};
90
91struct 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))
94{
95 struct seq_tab *p;
96
97 p = __seq_open_private(f, &seq_tab_ops, sizeof(*p) + rows * width);
98 if (p) {
99 p->show = show;
100 p->rows = rows;
101 p->width = width;
102 p->skip_first = have_header != 0;
103 }
104 return p;
105}
106
107static int cim_la_show(struct seq_file *seq, void *v, int idx)
108{
109 if (v == SEQ_START_TOKEN)
110 seq_puts(seq, "Status Data PC LS0Stat LS0Addr "
111 " LS0Data\n");
112 else {
113 const u32 *p = v;
114
115 seq_printf(seq,
116 " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n",
117 (p[0] >> 4) & 0xff, p[0] & 0xf, p[1] >> 4,
118 p[1] & 0xf, p[2] >> 4, p[2] & 0xf, p[3], p[4], p[5],
119 p[6], p[7]);
120 }
121 return 0;
122}
123
124static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx)
125{
126 if (v == SEQ_START_TOKEN) {
127 seq_puts(seq, "Status Data PC\n");
128 } else {
129 const u32 *p = v;
130
131 seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6],
132 p[7]);
133 seq_printf(seq, " %02x %02x%06x %02x%06x\n",
134 (p[3] >> 8) & 0xff, p[3] & 0xff, p[4] >> 8,
135 p[4] & 0xff, p[5] >> 8);
136 seq_printf(seq, " %02x %x%07x %x%07x\n", (p[0] >> 4) & 0xff,
137 p[0] & 0xf, p[1] >> 4, p[1] & 0xf, p[2] >> 4);
138 }
139 return 0;
140}
141
142static int cim_la_open(struct inode *inode, struct file *file)
143{
144 int ret;
145 unsigned int cfg;
146 struct seq_tab *p;
147 struct adapter *adap = inode->i_private;
148
149 ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg);
150 if (ret)
151 return ret;
152
153 p = seq_open_tab(file, adap->params.cim_la_size / 8, 8 * sizeof(u32), 1,
154 cfg & UPDBGLACAPTPCONLY_F ?
155 cim_la_show_3in1 : cim_la_show);
156 if (!p)
157 return -ENOMEM;
158
159 ret = t4_cim_read_la(adap, (u32 *)p->data, NULL);
160 if (ret)
161 seq_release_private(inode, file);
162 return ret;
163}
164
165static const struct file_operations cim_la_fops = {
166 .owner = THIS_MODULE,
167 .open = cim_la_open,
168 .read = seq_read,
169 .llseek = seq_lseek,
170 .release = seq_release_private
171};
172
Hariprasad Shenai74b30922015-01-07 08:48:02 +0530173static int cim_qcfg_show(struct seq_file *seq, void *v)
174{
175 static const char * const qname[] = {
176 "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI",
177 "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI",
178 "SGE0-RX", "SGE1-RX"
179 };
180
181 int i;
182 struct adapter *adap = seq->private;
183 u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
184 u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5];
185 u32 stat[(4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5))];
186 u16 thres[CIM_NUM_IBQ];
187 u32 obq_wr_t4[2 * CIM_NUM_OBQ], *wr;
188 u32 obq_wr_t5[2 * CIM_NUM_OBQ_T5];
189 u32 *p = stat;
190 int cim_num_obq = is_t4(adap->params.chip) ?
191 CIM_NUM_OBQ : CIM_NUM_OBQ_T5;
192
193 i = t4_cim_read(adap, is_t4(adap->params.chip) ? UP_IBQ_0_RDADDR_A :
194 UP_IBQ_0_SHADOW_RDADDR_A,
195 ARRAY_SIZE(stat), stat);
196 if (!i) {
197 if (is_t4(adap->params.chip)) {
198 i = t4_cim_read(adap, UP_OBQ_0_REALADDR_A,
199 ARRAY_SIZE(obq_wr_t4), obq_wr_t4);
200 wr = obq_wr_t4;
201 } else {
202 i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A,
203 ARRAY_SIZE(obq_wr_t5), obq_wr_t5);
204 wr = obq_wr_t5;
205 }
206 }
207 if (i)
208 return i;
209
210 t4_read_cimq_cfg(adap, base, size, thres);
211
212 seq_printf(seq,
213 " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n");
214 for (i = 0; i < CIM_NUM_IBQ; i++, p += 4)
215 seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n",
216 qname[i], base[i], size[i], thres[i],
217 IBQRDADDR_G(p[0]), IBQWRADDR_G(p[1]),
218 QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
219 QUEREMFLITS_G(p[2]) * 16);
220 for ( ; i < CIM_NUM_IBQ + cim_num_obq; i++, p += 4, wr += 2)
221 seq_printf(seq, "%7s %5x %5u %12x %4x %4u %4u %5u\n",
222 qname[i], base[i], size[i],
223 QUERDADDR_G(p[0]) & 0x3fff, wr[0] - base[i],
224 QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]),
225 QUEREMFLITS_G(p[2]) * 16);
226 return 0;
227}
228
229static int cim_qcfg_open(struct inode *inode, struct file *file)
230{
231 return single_open(file, cim_qcfg_show, inode->i_private);
232}
233
234static const struct file_operations cim_qcfg_fops = {
235 .owner = THIS_MODULE,
236 .open = cim_qcfg_open,
237 .read = seq_read,
238 .llseek = seq_lseek,
239 .release = single_release,
240};
241
Hariprasad Shenaif1ff24a2015-01-07 08:48:01 +0530242/* Firmware Device Log dump. */
Hariprasad Shenai49aa2842015-01-07 08:48:00 +0530243static const char * const devlog_level_strings[] = {
244 [FW_DEVLOG_LEVEL_EMERG] = "EMERG",
245 [FW_DEVLOG_LEVEL_CRIT] = "CRIT",
246 [FW_DEVLOG_LEVEL_ERR] = "ERR",
247 [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE",
248 [FW_DEVLOG_LEVEL_INFO] = "INFO",
249 [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG"
250};
251
252static const char * const devlog_facility_strings[] = {
253 [FW_DEVLOG_FACILITY_CORE] = "CORE",
254 [FW_DEVLOG_FACILITY_SCHED] = "SCHED",
255 [FW_DEVLOG_FACILITY_TIMER] = "TIMER",
256 [FW_DEVLOG_FACILITY_RES] = "RES",
257 [FW_DEVLOG_FACILITY_HW] = "HW",
258 [FW_DEVLOG_FACILITY_FLR] = "FLR",
259 [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ",
260 [FW_DEVLOG_FACILITY_PHY] = "PHY",
261 [FW_DEVLOG_FACILITY_MAC] = "MAC",
262 [FW_DEVLOG_FACILITY_PORT] = "PORT",
263 [FW_DEVLOG_FACILITY_VI] = "VI",
264 [FW_DEVLOG_FACILITY_FILTER] = "FILTER",
265 [FW_DEVLOG_FACILITY_ACL] = "ACL",
266 [FW_DEVLOG_FACILITY_TM] = "TM",
267 [FW_DEVLOG_FACILITY_QFC] = "QFC",
268 [FW_DEVLOG_FACILITY_DCB] = "DCB",
269 [FW_DEVLOG_FACILITY_ETH] = "ETH",
270 [FW_DEVLOG_FACILITY_OFLD] = "OFLD",
271 [FW_DEVLOG_FACILITY_RI] = "RI",
272 [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI",
273 [FW_DEVLOG_FACILITY_FCOE] = "FCOE",
274 [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI",
275 [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE"
276};
277
278/* Information gathered by Device Log Open routine for the display routine.
279 */
280struct devlog_info {
281 unsigned int nentries; /* number of entries in log[] */
282 unsigned int first; /* first [temporal] entry in log[] */
283 struct fw_devlog_e log[0]; /* Firmware Device Log */
284};
285
286/* Dump a Firmaware Device Log entry.
287 */
288static int devlog_show(struct seq_file *seq, void *v)
289{
290 if (v == SEQ_START_TOKEN)
291 seq_printf(seq, "%10s %15s %8s %8s %s\n",
292 "Seq#", "Tstamp", "Level", "Facility", "Message");
293 else {
294 struct devlog_info *dinfo = seq->private;
295 int fidx = (uintptr_t)v - 2;
296 unsigned long index;
297 struct fw_devlog_e *e;
298
299 /* Get a pointer to the log entry to display. Skip unused log
300 * entries.
301 */
302 index = dinfo->first + fidx;
303 if (index >= dinfo->nentries)
304 index -= dinfo->nentries;
305 e = &dinfo->log[index];
306 if (e->timestamp == 0)
307 return 0;
308
309 /* Print the message. This depends on the firmware using
310 * exactly the same formating strings as the kernel so we may
311 * eventually have to put a format interpreter in here ...
312 */
313 seq_printf(seq, "%10d %15llu %8s %8s ",
314 e->seqno, e->timestamp,
315 (e->level < ARRAY_SIZE(devlog_level_strings)
316 ? devlog_level_strings[e->level]
317 : "UNKNOWN"),
318 (e->facility < ARRAY_SIZE(devlog_facility_strings)
319 ? devlog_facility_strings[e->facility]
320 : "UNKNOWN"));
321 seq_printf(seq, e->fmt, e->params[0], e->params[1],
322 e->params[2], e->params[3], e->params[4],
323 e->params[5], e->params[6], e->params[7]);
324 }
325 return 0;
326}
327
328/* Sequential File Operations for Device Log.
329 */
330static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos)
331{
332 if (pos > dinfo->nentries)
333 return NULL;
334
335 return (void *)(uintptr_t)(pos + 1);
336}
337
338static void *devlog_start(struct seq_file *seq, loff_t *pos)
339{
340 struct devlog_info *dinfo = seq->private;
341
342 return (*pos
343 ? devlog_get_idx(dinfo, *pos)
344 : SEQ_START_TOKEN);
345}
346
347static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos)
348{
349 struct devlog_info *dinfo = seq->private;
350
351 (*pos)++;
352 return devlog_get_idx(dinfo, *pos);
353}
354
355static void devlog_stop(struct seq_file *seq, void *v)
356{
357}
358
359static const struct seq_operations devlog_seq_ops = {
360 .start = devlog_start,
361 .next = devlog_next,
362 .stop = devlog_stop,
363 .show = devlog_show
364};
365
366/* Set up for reading the firmware's device log. We read the entire log here
367 * and then display it incrementally in devlog_show().
368 */
369static int devlog_open(struct inode *inode, struct file *file)
370{
371 struct adapter *adap = inode->i_private;
372 struct devlog_params *dparams = &adap->params.devlog;
373 struct devlog_info *dinfo;
374 unsigned int index;
375 u32 fseqno;
376 int ret;
377
378 /* If we don't know where the log is we can't do anything.
379 */
380 if (dparams->start == 0)
381 return -ENXIO;
382
383 /* Allocate the space to read in the firmware's device log and set up
384 * for the iterated call to our display function.
385 */
386 dinfo = __seq_open_private(file, &devlog_seq_ops,
387 sizeof(*dinfo) + dparams->size);
388 if (!dinfo)
389 return -ENOMEM;
390
391 /* Record the basic log buffer information and read in the raw log.
392 */
393 dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e));
394 dinfo->first = 0;
395 spin_lock(&adap->win0_lock);
396 ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype,
397 dparams->start, dparams->size, (__be32 *)dinfo->log,
398 T4_MEMORY_READ);
399 spin_unlock(&adap->win0_lock);
400 if (ret) {
401 seq_release_private(inode, file);
402 return ret;
403 }
404
405 /* Translate log multi-byte integral elements into host native format
406 * and determine where the first entry in the log is.
407 */
408 for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) {
409 struct fw_devlog_e *e = &dinfo->log[index];
410 int i;
411 __u32 seqno;
412
413 if (e->timestamp == 0)
414 continue;
415
416 e->timestamp = (__force __be64)be64_to_cpu(e->timestamp);
417 seqno = be32_to_cpu(e->seqno);
418 for (i = 0; i < 8; i++)
419 e->params[i] =
420 (__force __be32)be32_to_cpu(e->params[i]);
421
422 if (seqno < fseqno) {
423 fseqno = seqno;
424 dinfo->first = index;
425 }
426 }
427 return 0;
428}
429
430static const struct file_operations devlog_fops = {
431 .owner = THIS_MODULE,
432 .open = devlog_open,
433 .read = seq_read,
434 .llseek = seq_lseek,
435 .release = seq_release_private
436};
437
Hariprasad Shenai49216c12015-01-20 12:02:20 +0530438static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
439 loff_t *ppos)
440{
441 loff_t pos = *ppos;
442 loff_t avail = FILE_DATA(file)->i_size;
443 struct adapter *adap = file->private_data;
444
445 if (pos < 0)
446 return -EINVAL;
447 if (pos >= avail)
448 return 0;
449 if (count > avail - pos)
450 count = avail - pos;
451
452 while (count) {
453 size_t len;
454 int ret, ofst;
455 u8 data[256];
456
457 ofst = pos & 3;
458 len = min(count + ofst, sizeof(data));
459 ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4,
460 (u32 *)data, 1);
461 if (ret)
462 return ret;
463
464 len -= ofst;
465 if (copy_to_user(buf, data + ofst, len))
466 return -EFAULT;
467
468 buf += len;
469 pos += len;
470 count -= len;
471 }
472 count = pos - *ppos;
473 *ppos = pos;
474 return count;
475}
476
477static const struct file_operations flash_debugfs_fops = {
478 .owner = THIS_MODULE,
479 .open = mem_open,
480 .read = flash_read,
481};
482
Hariprasad Shenaief82f662015-01-07 08:48:03 +0530483static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
484{
485 *mask = x | y;
486 y = (__force u64)cpu_to_be64(y);
487 memcpy(addr, (char *)&y + 2, ETH_ALEN);
488}
489
490static int mps_tcam_show(struct seq_file *seq, void *v)
491{
492 if (v == SEQ_START_TOKEN)
493 seq_puts(seq, "Idx Ethernet address Mask Vld Ports PF"
494 " VF Replication "
495 "P0 P1 P2 P3 ML\n");
496 else {
497 u64 mask;
498 u8 addr[ETH_ALEN];
499 struct adapter *adap = seq->private;
500 unsigned int idx = (uintptr_t)v - 2;
501 u64 tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx));
502 u64 tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx));
503 u32 cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx));
504 u32 cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx));
505 u32 rplc[4] = {0, 0, 0, 0};
506
507 if (tcamx & tcamy) {
508 seq_printf(seq, "%3u -\n", idx);
509 goto out;
510 }
511
512 if (cls_lo & REPLICATE_F) {
513 struct fw_ldst_cmd ldst_cmd;
514 int ret;
515
516 memset(&ldst_cmd, 0, sizeof(ldst_cmd));
517 ldst_cmd.op_to_addrspace =
518 htonl(FW_CMD_OP_V(FW_LDST_CMD) |
519 FW_CMD_REQUEST_F |
520 FW_CMD_READ_F |
521 FW_LDST_CMD_ADDRSPACE_V(
522 FW_LDST_ADDRSPC_MPS));
523 ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd));
524 ldst_cmd.u.mps.fid_ctl =
525 htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) |
526 FW_LDST_CMD_CTL_V(idx));
527 ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd,
528 sizeof(ldst_cmd), &ldst_cmd);
529 if (ret)
530 dev_warn(adap->pdev_dev, "Can't read MPS "
531 "replication map for idx %d: %d\n",
532 idx, -ret);
533 else {
534 rplc[0] = ntohl(ldst_cmd.u.mps.rplc31_0);
535 rplc[1] = ntohl(ldst_cmd.u.mps.rplc63_32);
536 rplc[2] = ntohl(ldst_cmd.u.mps.rplc95_64);
537 rplc[3] = ntohl(ldst_cmd.u.mps.rplc127_96);
538 }
539 }
540
541 tcamxy2valmask(tcamx, tcamy, addr, &mask);
542 seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx"
543 "%3c %#x%4u%4d",
544 idx, addr[0], addr[1], addr[2], addr[3], addr[4],
545 addr[5], (unsigned long long)mask,
546 (cls_lo & SRAM_VLD_F) ? 'Y' : 'N', PORTMAP_G(cls_hi),
547 PF_G(cls_lo),
548 (cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1);
549 if (cls_lo & REPLICATE_F)
550 seq_printf(seq, " %08x %08x %08x %08x",
551 rplc[3], rplc[2], rplc[1], rplc[0]);
552 else
553 seq_printf(seq, "%36c", ' ');
554 seq_printf(seq, "%4u%3u%3u%3u %#x\n",
555 SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo),
556 SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo),
557 (cls_lo >> MULTILISTEN0_S) & 0xf);
558 }
559out: return 0;
560}
561
562static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos)
563{
564 struct adapter *adap = seq->private;
565 int max_mac_addr = is_t4(adap->params.chip) ?
566 NUM_MPS_CLS_SRAM_L_INSTANCES :
567 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
568 return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL);
569}
570
571static void *mps_tcam_start(struct seq_file *seq, loff_t *pos)
572{
573 return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN;
574}
575
576static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos)
577{
578 ++*pos;
579 return mps_tcam_get_idx(seq, *pos);
580}
581
582static void mps_tcam_stop(struct seq_file *seq, void *v)
583{
584}
585
586static const struct seq_operations mps_tcam_seq_ops = {
587 .start = mps_tcam_start,
588 .next = mps_tcam_next,
589 .stop = mps_tcam_stop,
590 .show = mps_tcam_show
591};
592
593static int mps_tcam_open(struct inode *inode, struct file *file)
594{
595 int res = seq_open(file, &mps_tcam_seq_ops);
596
597 if (!res) {
598 struct seq_file *seq = file->private_data;
599
600 seq->private = inode->i_private;
601 }
602 return res;
603}
604
605static const struct file_operations mps_tcam_debugfs_fops = {
606 .owner = THIS_MODULE,
607 .open = mps_tcam_open,
608 .read = seq_read,
609 .llseek = seq_lseek,
610 .release = seq_release,
611};
612
Anish Bhattb5a02f52015-01-14 15:17:34 -0800613#if IS_ENABLED(CONFIG_IPV6)
614static int clip_tbl_open(struct inode *inode, struct file *file)
615{
616 return single_open(file, clip_tbl_show, PDE_DATA(inode));
617}
618
619static const struct file_operations clip_tbl_debugfs_fops = {
620 .owner = THIS_MODULE,
621 .open = clip_tbl_open,
622 .read = seq_read,
623 .llseek = seq_lseek,
624 .release = single_release
625};
626#endif
627
Hariprasad Shenai688ea5f2015-01-20 12:02:21 +0530628/*RSS Table.
629 */
630
631static int rss_show(struct seq_file *seq, void *v, int idx)
632{
633 u16 *entry = v;
634
635 seq_printf(seq, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n",
636 idx * 8, entry[0], entry[1], entry[2], entry[3], entry[4],
637 entry[5], entry[6], entry[7]);
638 return 0;
639}
640
641static int rss_open(struct inode *inode, struct file *file)
642{
643 int ret;
644 struct seq_tab *p;
645 struct adapter *adap = inode->i_private;
646
647 p = seq_open_tab(file, RSS_NENTRIES / 8, 8 * sizeof(u16), 0, rss_show);
648 if (!p)
649 return -ENOMEM;
650
651 ret = t4_read_rss(adap, (u16 *)p->data);
652 if (ret)
653 seq_release_private(inode, file);
654
655 return ret;
656}
657
658static const struct file_operations rss_debugfs_fops = {
659 .owner = THIS_MODULE,
660 .open = rss_open,
661 .read = seq_read,
662 .llseek = seq_lseek,
663 .release = seq_release_private
664};
665
666/* RSS Configuration.
667 */
668
669/* Small utility function to return the strings "yes" or "no" if the supplied
670 * argument is non-zero.
671 */
672static const char *yesno(int x)
673{
674 static const char *yes = "yes";
675 static const char *no = "no";
676
677 return x ? yes : no;
678}
679
680static int rss_config_show(struct seq_file *seq, void *v)
681{
682 struct adapter *adapter = seq->private;
683 static const char * const keymode[] = {
684 "global",
685 "global and per-VF scramble",
686 "per-PF and per-VF scramble",
687 "per-VF and per-VF scramble",
688 };
689 u32 rssconf;
690
691 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_A);
692 seq_printf(seq, "TP_RSS_CONFIG: %#x\n", rssconf);
693 seq_printf(seq, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf &
694 TNL4TUPENIPV6_F));
695 seq_printf(seq, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf &
696 TNL2TUPENIPV6_F));
697 seq_printf(seq, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf &
698 TNL4TUPENIPV4_F));
699 seq_printf(seq, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf &
700 TNL2TUPENIPV4_F));
701 seq_printf(seq, " TnlTcpSel: %3s\n", yesno(rssconf & TNLTCPSEL_F));
702 seq_printf(seq, " TnlIp6Sel: %3s\n", yesno(rssconf & TNLIP6SEL_F));
703 seq_printf(seq, " TnlVrtSel: %3s\n", yesno(rssconf & TNLVRTSEL_F));
704 seq_printf(seq, " TnlMapEn: %3s\n", yesno(rssconf & TNLMAPEN_F));
705 seq_printf(seq, " OfdHashSave: %3s\n", yesno(rssconf &
706 OFDHASHSAVE_F));
707 seq_printf(seq, " OfdVrtSel: %3s\n", yesno(rssconf & OFDVRTSEL_F));
708 seq_printf(seq, " OfdMapEn: %3s\n", yesno(rssconf & OFDMAPEN_F));
709 seq_printf(seq, " OfdLkpEn: %3s\n", yesno(rssconf & OFDLKPEN_F));
710 seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
711 SYN4TUPENIPV6_F));
712 seq_printf(seq, " Syn2TupEnIpv6: %3s\n", yesno(rssconf &
713 SYN2TUPENIPV6_F));
714 seq_printf(seq, " Syn4TupEnIpv4: %3s\n", yesno(rssconf &
715 SYN4TUPENIPV4_F));
716 seq_printf(seq, " Syn2TupEnIpv4: %3s\n", yesno(rssconf &
717 SYN2TUPENIPV4_F));
718 seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf &
719 SYN4TUPENIPV6_F));
720 seq_printf(seq, " SynIp6Sel: %3s\n", yesno(rssconf & SYNIP6SEL_F));
721 seq_printf(seq, " SynVrt6Sel: %3s\n", yesno(rssconf & SYNVRTSEL_F));
722 seq_printf(seq, " SynMapEn: %3s\n", yesno(rssconf & SYNMAPEN_F));
723 seq_printf(seq, " SynLkpEn: %3s\n", yesno(rssconf & SYNLKPEN_F));
724 seq_printf(seq, " ChnEn: %3s\n", yesno(rssconf &
725 CHANNELENABLE_F));
726 seq_printf(seq, " PrtEn: %3s\n", yesno(rssconf &
727 PORTENABLE_F));
728 seq_printf(seq, " TnlAllLkp: %3s\n", yesno(rssconf &
729 TNLALLLOOKUP_F));
730 seq_printf(seq, " VrtEn: %3s\n", yesno(rssconf &
731 VIRTENABLE_F));
732 seq_printf(seq, " CngEn: %3s\n", yesno(rssconf &
733 CONGESTIONENABLE_F));
734 seq_printf(seq, " HashToeplitz: %3s\n", yesno(rssconf &
735 HASHTOEPLITZ_F));
736 seq_printf(seq, " Udp4En: %3s\n", yesno(rssconf & UDPENABLE_F));
737 seq_printf(seq, " Disable: %3s\n", yesno(rssconf & DISABLE_F));
738
739 seq_puts(seq, "\n");
740
741 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_TNL_A);
742 seq_printf(seq, "TP_RSS_CONFIG_TNL: %#x\n", rssconf);
743 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
744 seq_printf(seq, " MaskFilter: %3d\n", MASKFILTER_G(rssconf));
745 if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
746 seq_printf(seq, " HashAll: %3s\n",
747 yesno(rssconf & HASHALL_F));
748 seq_printf(seq, " HashEth: %3s\n",
749 yesno(rssconf & HASHETH_F));
750 }
751 seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
752
753 seq_puts(seq, "\n");
754
755 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_OFD_A);
756 seq_printf(seq, "TP_RSS_CONFIG_OFD: %#x\n", rssconf);
757 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
758 seq_printf(seq, " RRCplMapEn: %3s\n", yesno(rssconf &
759 RRCPLMAPEN_F));
760 seq_printf(seq, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf));
761
762 seq_puts(seq, "\n");
763
764 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_SYN_A);
765 seq_printf(seq, "TP_RSS_CONFIG_SYN: %#x\n", rssconf);
766 seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf));
767 seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F));
768
769 seq_puts(seq, "\n");
770
771 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_VRT_A);
772 seq_printf(seq, "TP_RSS_CONFIG_VRT: %#x\n", rssconf);
773 if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) {
774 seq_printf(seq, " KeyWrAddrX: %3d\n",
775 KEYWRADDRX_G(rssconf));
776 seq_printf(seq, " KeyExtend: %3s\n",
777 yesno(rssconf & KEYEXTEND_F));
778 }
779 seq_printf(seq, " VfRdRg: %3s\n", yesno(rssconf & VFRDRG_F));
780 seq_printf(seq, " VfRdEn: %3s\n", yesno(rssconf & VFRDEN_F));
781 seq_printf(seq, " VfPerrEn: %3s\n", yesno(rssconf & VFPERREN_F));
782 seq_printf(seq, " KeyPerrEn: %3s\n", yesno(rssconf & KEYPERREN_F));
783 seq_printf(seq, " DisVfVlan: %3s\n", yesno(rssconf &
784 DISABLEVLAN_F));
785 seq_printf(seq, " EnUpSwt: %3s\n", yesno(rssconf & ENABLEUP0_F));
786 seq_printf(seq, " HashDelay: %3d\n", HASHDELAY_G(rssconf));
787 if (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5)
788 seq_printf(seq, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf));
789 seq_printf(seq, " KeyMode: %s\n", keymode[KEYMODE_G(rssconf)]);
790 seq_printf(seq, " VfWrEn: %3s\n", yesno(rssconf & VFWREN_F));
791 seq_printf(seq, " KeyWrEn: %3s\n", yesno(rssconf & KEYWREN_F));
792 seq_printf(seq, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf));
793
794 seq_puts(seq, "\n");
795
796 rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_CNG_A);
797 seq_printf(seq, "TP_RSS_CONFIG_CNG: %#x\n", rssconf);
798 seq_printf(seq, " ChnCount3: %3s\n", yesno(rssconf & CHNCOUNT3_F));
799 seq_printf(seq, " ChnCount2: %3s\n", yesno(rssconf & CHNCOUNT2_F));
800 seq_printf(seq, " ChnCount1: %3s\n", yesno(rssconf & CHNCOUNT1_F));
801 seq_printf(seq, " ChnCount0: %3s\n", yesno(rssconf & CHNCOUNT0_F));
802 seq_printf(seq, " ChnUndFlow3: %3s\n", yesno(rssconf &
803 CHNUNDFLOW3_F));
804 seq_printf(seq, " ChnUndFlow2: %3s\n", yesno(rssconf &
805 CHNUNDFLOW2_F));
806 seq_printf(seq, " ChnUndFlow1: %3s\n", yesno(rssconf &
807 CHNUNDFLOW1_F));
808 seq_printf(seq, " ChnUndFlow0: %3s\n", yesno(rssconf &
809 CHNUNDFLOW0_F));
810 seq_printf(seq, " RstChn3: %3s\n", yesno(rssconf & RSTCHN3_F));
811 seq_printf(seq, " RstChn2: %3s\n", yesno(rssconf & RSTCHN2_F));
812 seq_printf(seq, " RstChn1: %3s\n", yesno(rssconf & RSTCHN1_F));
813 seq_printf(seq, " RstChn0: %3s\n", yesno(rssconf & RSTCHN0_F));
814 seq_printf(seq, " UpdVld: %3s\n", yesno(rssconf & UPDVLD_F));
815 seq_printf(seq, " Xoff: %3s\n", yesno(rssconf & XOFF_F));
816 seq_printf(seq, " UpdChn3: %3s\n", yesno(rssconf & UPDCHN3_F));
817 seq_printf(seq, " UpdChn2: %3s\n", yesno(rssconf & UPDCHN2_F));
818 seq_printf(seq, " UpdChn1: %3s\n", yesno(rssconf & UPDCHN1_F));
819 seq_printf(seq, " UpdChn0: %3s\n", yesno(rssconf & UPDCHN0_F));
820 seq_printf(seq, " Queue: %3d\n", QUEUE_G(rssconf));
821
822 return 0;
823}
824
825DEFINE_SIMPLE_DEBUGFS_FILE(rss_config);
826
827/* RSS Secret Key.
828 */
829
830static int rss_key_show(struct seq_file *seq, void *v)
831{
832 u32 key[10];
833
834 t4_read_rss_key(seq->private, key);
835 seq_printf(seq, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n",
836 key[9], key[8], key[7], key[6], key[5], key[4], key[3],
837 key[2], key[1], key[0]);
838 return 0;
839}
840
841static int rss_key_open(struct inode *inode, struct file *file)
842{
843 return single_open(file, rss_key_show, inode->i_private);
844}
845
846static ssize_t rss_key_write(struct file *file, const char __user *buf,
847 size_t count, loff_t *pos)
848{
849 int i, j;
850 u32 key[10];
851 char s[100], *p;
852 struct adapter *adap = FILE_DATA(file)->i_private;
853
854 if (count > sizeof(s) - 1)
855 return -EINVAL;
856 if (copy_from_user(s, buf, count))
857 return -EFAULT;
858 for (i = count; i > 0 && isspace(s[i - 1]); i--)
859 ;
860 s[i] = '\0';
861
862 for (p = s, i = 9; i >= 0; i--) {
863 key[i] = 0;
864 for (j = 0; j < 8; j++, p++) {
865 if (!isxdigit(*p))
866 return -EINVAL;
867 key[i] = (key[i] << 4) | hex2val(*p);
868 }
869 }
870
871 t4_write_rss_key(adap, key, -1);
872 return count;
873}
874
875static const struct file_operations rss_key_debugfs_fops = {
876 .owner = THIS_MODULE,
877 .open = rss_key_open,
878 .read = seq_read,
879 .llseek = seq_lseek,
880 .release = single_release,
881 .write = rss_key_write
882};
883
884/* PF RSS Configuration.
885 */
886
887struct rss_pf_conf {
888 u32 rss_pf_map;
889 u32 rss_pf_mask;
890 u32 rss_pf_config;
891};
892
893static int rss_pf_config_show(struct seq_file *seq, void *v, int idx)
894{
895 struct rss_pf_conf *pfconf;
896
897 if (v == SEQ_START_TOKEN) {
898 /* use the 0th entry to dump the PF Map Index Size */
899 pfconf = seq->private + offsetof(struct seq_tab, data);
900 seq_printf(seq, "PF Map Index Size = %d\n\n",
901 LKPIDXSIZE_G(pfconf->rss_pf_map));
902
903 seq_puts(seq, " RSS PF VF Hash Tuple Enable Default\n");
904 seq_puts(seq, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n");
905 seq_puts(seq, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n");
906 } else {
907 #define G_PFnLKPIDX(map, n) \
908 (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M)
909 #define G_PFnMSKSIZE(mask, n) \
910 (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M)
911
912 pfconf = v;
913 seq_printf(seq, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n",
914 idx,
915 yesno(pfconf->rss_pf_config & MAPENABLE_F),
916 yesno(pfconf->rss_pf_config & CHNENABLE_F),
917 yesno(pfconf->rss_pf_config & PRTENABLE_F),
918 G_PFnLKPIDX(pfconf->rss_pf_map, idx),
919 G_PFnMSKSIZE(pfconf->rss_pf_mask, idx),
920 IVFWIDTH_G(pfconf->rss_pf_config),
921 yesno(pfconf->rss_pf_config & IP6FOURTUPEN_F),
922 yesno(pfconf->rss_pf_config & IP6TWOTUPEN_F),
923 yesno(pfconf->rss_pf_config & IP4FOURTUPEN_F),
924 yesno(pfconf->rss_pf_config & IP4TWOTUPEN_F),
925 yesno(pfconf->rss_pf_config & UDPFOURTUPEN_F),
926 CH1DEFAULTQUEUE_G(pfconf->rss_pf_config),
927 CH0DEFAULTQUEUE_G(pfconf->rss_pf_config));
928
929 #undef G_PFnLKPIDX
930 #undef G_PFnMSKSIZE
931 }
932 return 0;
933}
934
935static int rss_pf_config_open(struct inode *inode, struct file *file)
936{
937 struct adapter *adapter = inode->i_private;
938 struct seq_tab *p;
939 u32 rss_pf_map, rss_pf_mask;
940 struct rss_pf_conf *pfconf;
941 int pf;
942
943 p = seq_open_tab(file, 8, sizeof(*pfconf), 1, rss_pf_config_show);
944 if (!p)
945 return -ENOMEM;
946
947 pfconf = (struct rss_pf_conf *)p->data;
948 rss_pf_map = t4_read_rss_pf_map(adapter);
949 rss_pf_mask = t4_read_rss_pf_mask(adapter);
950 for (pf = 0; pf < 8; pf++) {
951 pfconf[pf].rss_pf_map = rss_pf_map;
952 pfconf[pf].rss_pf_mask = rss_pf_mask;
953 t4_read_rss_pf_config(adapter, pf, &pfconf[pf].rss_pf_config);
954 }
955 return 0;
956}
957
958static const struct file_operations rss_pf_config_debugfs_fops = {
959 .owner = THIS_MODULE,
960 .open = rss_pf_config_open,
961 .read = seq_read,
962 .llseek = seq_lseek,
963 .release = seq_release_private
964};
965
966/* VF RSS Configuration.
967 */
968
969struct rss_vf_conf {
970 u32 rss_vf_vfl;
971 u32 rss_vf_vfh;
972};
973
974static int rss_vf_config_show(struct seq_file *seq, void *v, int idx)
975{
976 if (v == SEQ_START_TOKEN) {
977 seq_puts(seq, " RSS Hash Tuple Enable\n");
978 seq_puts(seq, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n");
979 seq_puts(seq, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n");
980 } else {
981 struct rss_vf_conf *vfconf = v;
982
983 seq_printf(seq, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n",
984 idx,
985 yesno(vfconf->rss_vf_vfh & VFCHNEN_F),
986 yesno(vfconf->rss_vf_vfh & VFPRTEN_F),
987 VFLKPIDX_G(vfconf->rss_vf_vfh),
988 yesno(vfconf->rss_vf_vfh & VFVLNEX_F),
989 yesno(vfconf->rss_vf_vfh & VFUPEN_F),
990 yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
991 yesno(vfconf->rss_vf_vfh & VFIP6TWOTUPEN_F),
992 yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F),
993 yesno(vfconf->rss_vf_vfh & VFIP4TWOTUPEN_F),
994 yesno(vfconf->rss_vf_vfh & ENABLEUDPHASH_F),
995 DEFAULTQUEUE_G(vfconf->rss_vf_vfh),
996 KEYINDEX_G(vfconf->rss_vf_vfh),
997 vfconf->rss_vf_vfl);
998 }
999 return 0;
1000}
1001
1002static int rss_vf_config_open(struct inode *inode, struct file *file)
1003{
1004 struct adapter *adapter = inode->i_private;
1005 struct seq_tab *p;
1006 struct rss_vf_conf *vfconf;
1007 int vf;
1008
1009 p = seq_open_tab(file, 128, sizeof(*vfconf), 1, rss_vf_config_show);
1010 if (!p)
1011 return -ENOMEM;
1012
1013 vfconf = (struct rss_vf_conf *)p->data;
1014 for (vf = 0; vf < 128; vf++) {
1015 t4_read_rss_vf_config(adapter, vf, &vfconf[vf].rss_vf_vfl,
1016 &vfconf[vf].rss_vf_vfh);
1017 }
1018 return 0;
1019}
1020
1021static const struct file_operations rss_vf_config_debugfs_fops = {
1022 .owner = THIS_MODULE,
1023 .open = rss_vf_config_open,
1024 .read = seq_read,
1025 .llseek = seq_lseek,
1026 .release = seq_release_private
1027};
1028
Hariprasad Shenai49216c12015-01-20 12:02:20 +05301029int mem_open(struct inode *inode, struct file *file)
1030{
1031 unsigned int mem;
1032 struct adapter *adap;
1033
1034 file->private_data = inode->i_private;
1035
1036 mem = (uintptr_t)file->private_data & 0x3;
1037 adap = file->private_data - mem;
1038
1039 (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH);
1040
1041 return 0;
1042}
1043
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301044static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
1045 loff_t *ppos)
1046{
1047 loff_t pos = *ppos;
1048 loff_t avail = file_inode(file)->i_size;
1049 unsigned int mem = (uintptr_t)file->private_data & 3;
1050 struct adapter *adap = file->private_data - mem;
1051 __be32 *data;
1052 int ret;
1053
1054 if (pos < 0)
1055 return -EINVAL;
1056 if (pos >= avail)
1057 return 0;
1058 if (count > avail - pos)
1059 count = avail - pos;
1060
1061 data = t4_alloc_mem(count);
1062 if (!data)
1063 return -ENOMEM;
1064
1065 spin_lock(&adap->win0_lock);
1066 ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ);
1067 spin_unlock(&adap->win0_lock);
1068 if (ret) {
1069 t4_free_mem(data);
1070 return ret;
1071 }
1072 ret = copy_to_user(buf, data, count);
1073
1074 t4_free_mem(data);
1075 if (ret)
1076 return -EFAULT;
1077
1078 *ppos = pos + count;
1079 return count;
1080}
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301081static const struct file_operations mem_debugfs_fops = {
1082 .owner = THIS_MODULE,
1083 .open = simple_open,
1084 .read = mem_read,
1085 .llseek = default_llseek,
1086};
1087
Hariprasad Shenai49216c12015-01-20 12:02:20 +05301088static void set_debugfs_file_size(struct dentry *de, loff_t size)
1089{
1090 if (!IS_ERR(de) && de->d_inode)
1091 de->d_inode->i_size = size;
1092}
1093
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301094static void add_debugfs_mem(struct adapter *adap, const char *name,
1095 unsigned int idx, unsigned int size_mb)
1096{
1097 struct dentry *de;
1098
1099 de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root,
1100 (void *)adap + idx, &mem_debugfs_fops);
1101 if (de && de->d_inode)
1102 de->d_inode->i_size = size_mb << 20;
1103}
1104
1105/* Add an array of Debug FS files.
1106 */
1107void add_debugfs_files(struct adapter *adap,
1108 struct t4_debugfs_entry *files,
1109 unsigned int nfiles)
1110{
1111 int i;
1112
1113 /* debugfs support is best effort */
1114 for (i = 0; i < nfiles; i++)
1115 debugfs_create_file(files[i].name, files[i].mode,
1116 adap->debugfs_root,
1117 (void *)adap + files[i].data,
1118 files[i].ops);
1119}
1120
1121int t4_setup_debugfs(struct adapter *adap)
1122{
1123 int i;
1124 u32 size;
Hariprasad Shenai49216c12015-01-20 12:02:20 +05301125 struct dentry *de;
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301126
1127 static struct t4_debugfs_entry t4_debugfs_files[] = {
Hariprasad Shenaif1ff24a2015-01-07 08:48:01 +05301128 { "cim_la", &cim_la_fops, S_IRUSR, 0 },
Hariprasad Shenai74b30922015-01-07 08:48:02 +05301129 { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 },
Hariprasad Shenai49aa2842015-01-07 08:48:00 +05301130 { "devlog", &devlog_fops, S_IRUSR, 0 },
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301131 { "l2t", &t4_l2t_fops, S_IRUSR, 0},
Hariprasad Shenaief82f662015-01-07 08:48:03 +05301132 { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 },
Hariprasad Shenai688ea5f2015-01-20 12:02:21 +05301133 { "rss", &rss_debugfs_fops, S_IRUSR, 0 },
1134 { "rss_config", &rss_config_debugfs_fops, S_IRUSR, 0 },
1135 { "rss_key", &rss_key_debugfs_fops, S_IRUSR, 0 },
1136 { "rss_pf_config", &rss_pf_config_debugfs_fops, S_IRUSR, 0 },
1137 { "rss_vf_config", &rss_vf_config_debugfs_fops, S_IRUSR, 0 },
Anish Bhattb5a02f52015-01-14 15:17:34 -08001138#if IS_ENABLED(CONFIG_IPV6)
1139 { "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 },
1140#endif
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301141 };
1142
1143 add_debugfs_files(adap,
1144 t4_debugfs_files,
1145 ARRAY_SIZE(t4_debugfs_files));
1146
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301147 i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A);
1148 if (i & EDRAM0_ENABLE_F) {
1149 size = t4_read_reg(adap, MA_EDRAM0_BAR_A);
1150 add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size));
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301151 }
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301152 if (i & EDRAM1_ENABLE_F) {
1153 size = t4_read_reg(adap, MA_EDRAM1_BAR_A);
1154 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size));
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301155 }
1156 if (is_t4(adap->params.chip)) {
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301157 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A);
1158 if (i & EXT_MEM_ENABLE_F)
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301159 add_debugfs_mem(adap, "mc", MEM_MC,
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301160 EXT_MEM_SIZE_G(size));
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301161 } else {
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301162 if (i & EXT_MEM0_ENABLE_F) {
1163 size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A);
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301164 add_debugfs_mem(adap, "mc0", MEM_MC0,
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301165 EXT_MEM0_SIZE_G(size));
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301166 }
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301167 if (i & EXT_MEM1_ENABLE_F) {
1168 size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A);
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301169 add_debugfs_mem(adap, "mc1", MEM_MC1,
Hariprasad Shenai6559a7e2014-11-07 09:35:24 +05301170 EXT_MEM1_SIZE_G(size));
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301171 }
1172 }
Hariprasad Shenai49216c12015-01-20 12:02:20 +05301173
1174 de = debugfs_create_file("flash", S_IRUSR, adap->debugfs_root, adap,
1175 &flash_debugfs_fops);
1176 set_debugfs_file_size(de, adap->params.sf_size);
1177
Hariprasad Shenaifd88b312014-11-07 09:35:23 +05301178 return 0;
1179}