Commit | Line | Data |
---|---|---|
fd88b31a HS |
1 | /* |
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> | |
39 | ||
40 | #include "cxgb4.h" | |
41 | #include "t4_regs.h" | |
42 | #include "t4fw_api.h" | |
43 | #include "cxgb4_debugfs.h" | |
44 | #include "l2t.h" | |
45 | ||
f1ff24aa HS |
46 | /* generic seq_file support for showing a table of size rows x width. */ |
47 | static void *seq_tab_get_idx(struct seq_tab *tb, loff_t pos) | |
48 | { | |
49 | pos -= tb->skip_first; | |
50 | return pos >= tb->rows ? NULL : &tb->data[pos * tb->width]; | |
51 | } | |
52 | ||
53 | static void *seq_tab_start(struct seq_file *seq, loff_t *pos) | |
54 | { | |
55 | struct seq_tab *tb = seq->private; | |
56 | ||
57 | if (tb->skip_first && *pos == 0) | |
58 | return SEQ_START_TOKEN; | |
59 | ||
60 | return seq_tab_get_idx(tb, *pos); | |
61 | } | |
62 | ||
63 | static void *seq_tab_next(struct seq_file *seq, void *v, loff_t *pos) | |
64 | { | |
65 | v = seq_tab_get_idx(seq->private, *pos + 1); | |
66 | if (v) | |
67 | ++*pos; | |
68 | return v; | |
69 | } | |
70 | ||
71 | static void seq_tab_stop(struct seq_file *seq, void *v) | |
72 | { | |
73 | } | |
74 | ||
75 | static int seq_tab_show(struct seq_file *seq, void *v) | |
76 | { | |
77 | const struct seq_tab *tb = seq->private; | |
78 | ||
79 | return tb->show(seq, v, ((char *)v - tb->data) / tb->width); | |
80 | } | |
81 | ||
82 | static const struct seq_operations seq_tab_ops = { | |
83 | .start = seq_tab_start, | |
84 | .next = seq_tab_next, | |
85 | .stop = seq_tab_stop, | |
86 | .show = seq_tab_show | |
87 | }; | |
88 | ||
89 | struct seq_tab *seq_open_tab(struct file *f, unsigned int rows, | |
90 | unsigned int width, unsigned int have_header, | |
91 | int (*show)(struct seq_file *seq, void *v, int i)) | |
92 | { | |
93 | struct seq_tab *p; | |
94 | ||
95 | p = __seq_open_private(f, &seq_tab_ops, sizeof(*p) + rows * width); | |
96 | if (p) { | |
97 | p->show = show; | |
98 | p->rows = rows; | |
99 | p->width = width; | |
100 | p->skip_first = have_header != 0; | |
101 | } | |
102 | return p; | |
103 | } | |
104 | ||
105 | static int cim_la_show(struct seq_file *seq, void *v, int idx) | |
106 | { | |
107 | if (v == SEQ_START_TOKEN) | |
108 | seq_puts(seq, "Status Data PC LS0Stat LS0Addr " | |
109 | " LS0Data\n"); | |
110 | else { | |
111 | const u32 *p = v; | |
112 | ||
113 | seq_printf(seq, | |
114 | " %02x %x%07x %x%07x %08x %08x %08x%08x%08x%08x\n", | |
115 | (p[0] >> 4) & 0xff, p[0] & 0xf, p[1] >> 4, | |
116 | p[1] & 0xf, p[2] >> 4, p[2] & 0xf, p[3], p[4], p[5], | |
117 | p[6], p[7]); | |
118 | } | |
119 | return 0; | |
120 | } | |
121 | ||
122 | static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx) | |
123 | { | |
124 | if (v == SEQ_START_TOKEN) { | |
125 | seq_puts(seq, "Status Data PC\n"); | |
126 | } else { | |
127 | const u32 *p = v; | |
128 | ||
129 | seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6], | |
130 | p[7]); | |
131 | seq_printf(seq, " %02x %02x%06x %02x%06x\n", | |
132 | (p[3] >> 8) & 0xff, p[3] & 0xff, p[4] >> 8, | |
133 | p[4] & 0xff, p[5] >> 8); | |
134 | seq_printf(seq, " %02x %x%07x %x%07x\n", (p[0] >> 4) & 0xff, | |
135 | p[0] & 0xf, p[1] >> 4, p[1] & 0xf, p[2] >> 4); | |
136 | } | |
137 | return 0; | |
138 | } | |
139 | ||
140 | static int cim_la_open(struct inode *inode, struct file *file) | |
141 | { | |
142 | int ret; | |
143 | unsigned int cfg; | |
144 | struct seq_tab *p; | |
145 | struct adapter *adap = inode->i_private; | |
146 | ||
147 | ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg); | |
148 | if (ret) | |
149 | return ret; | |
150 | ||
151 | p = seq_open_tab(file, adap->params.cim_la_size / 8, 8 * sizeof(u32), 1, | |
152 | cfg & UPDBGLACAPTPCONLY_F ? | |
153 | cim_la_show_3in1 : cim_la_show); | |
154 | if (!p) | |
155 | return -ENOMEM; | |
156 | ||
157 | ret = t4_cim_read_la(adap, (u32 *)p->data, NULL); | |
158 | if (ret) | |
159 | seq_release_private(inode, file); | |
160 | return ret; | |
161 | } | |
162 | ||
163 | static const struct file_operations cim_la_fops = { | |
164 | .owner = THIS_MODULE, | |
165 | .open = cim_la_open, | |
166 | .read = seq_read, | |
167 | .llseek = seq_lseek, | |
168 | .release = seq_release_private | |
169 | }; | |
170 | ||
74b3092c HS |
171 | static int cim_qcfg_show(struct seq_file *seq, void *v) |
172 | { | |
173 | static const char * const qname[] = { | |
174 | "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI", | |
175 | "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI", | |
176 | "SGE0-RX", "SGE1-RX" | |
177 | }; | |
178 | ||
179 | int i; | |
180 | struct adapter *adap = seq->private; | |
181 | u16 base[CIM_NUM_IBQ + CIM_NUM_OBQ_T5]; | |
182 | u16 size[CIM_NUM_IBQ + CIM_NUM_OBQ_T5]; | |
183 | u32 stat[(4 * (CIM_NUM_IBQ + CIM_NUM_OBQ_T5))]; | |
184 | u16 thres[CIM_NUM_IBQ]; | |
185 | u32 obq_wr_t4[2 * CIM_NUM_OBQ], *wr; | |
186 | u32 obq_wr_t5[2 * CIM_NUM_OBQ_T5]; | |
187 | u32 *p = stat; | |
188 | int cim_num_obq = is_t4(adap->params.chip) ? | |
189 | CIM_NUM_OBQ : CIM_NUM_OBQ_T5; | |
190 | ||
191 | i = t4_cim_read(adap, is_t4(adap->params.chip) ? UP_IBQ_0_RDADDR_A : | |
192 | UP_IBQ_0_SHADOW_RDADDR_A, | |
193 | ARRAY_SIZE(stat), stat); | |
194 | if (!i) { | |
195 | if (is_t4(adap->params.chip)) { | |
196 | i = t4_cim_read(adap, UP_OBQ_0_REALADDR_A, | |
197 | ARRAY_SIZE(obq_wr_t4), obq_wr_t4); | |
198 | wr = obq_wr_t4; | |
199 | } else { | |
200 | i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A, | |
201 | ARRAY_SIZE(obq_wr_t5), obq_wr_t5); | |
202 | wr = obq_wr_t5; | |
203 | } | |
204 | } | |
205 | if (i) | |
206 | return i; | |
207 | ||
208 | t4_read_cimq_cfg(adap, base, size, thres); | |
209 | ||
210 | seq_printf(seq, | |
211 | " Queue Base Size Thres RdPtr WrPtr SOP EOP Avail\n"); | |
212 | for (i = 0; i < CIM_NUM_IBQ; i++, p += 4) | |
213 | seq_printf(seq, "%7s %5x %5u %5u %6x %4x %4u %4u %5u\n", | |
214 | qname[i], base[i], size[i], thres[i], | |
215 | IBQRDADDR_G(p[0]), IBQWRADDR_G(p[1]), | |
216 | QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]), | |
217 | QUEREMFLITS_G(p[2]) * 16); | |
218 | for ( ; i < CIM_NUM_IBQ + cim_num_obq; i++, p += 4, wr += 2) | |
219 | seq_printf(seq, "%7s %5x %5u %12x %4x %4u %4u %5u\n", | |
220 | qname[i], base[i], size[i], | |
221 | QUERDADDR_G(p[0]) & 0x3fff, wr[0] - base[i], | |
222 | QUESOPCNT_G(p[3]), QUEEOPCNT_G(p[3]), | |
223 | QUEREMFLITS_G(p[2]) * 16); | |
224 | return 0; | |
225 | } | |
226 | ||
227 | static int cim_qcfg_open(struct inode *inode, struct file *file) | |
228 | { | |
229 | return single_open(file, cim_qcfg_show, inode->i_private); | |
230 | } | |
231 | ||
232 | static const struct file_operations cim_qcfg_fops = { | |
233 | .owner = THIS_MODULE, | |
234 | .open = cim_qcfg_open, | |
235 | .read = seq_read, | |
236 | .llseek = seq_lseek, | |
237 | .release = single_release, | |
238 | }; | |
239 | ||
f1ff24aa | 240 | /* Firmware Device Log dump. */ |
49aa284f HS |
241 | static const char * const devlog_level_strings[] = { |
242 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", | |
243 | [FW_DEVLOG_LEVEL_CRIT] = "CRIT", | |
244 | [FW_DEVLOG_LEVEL_ERR] = "ERR", | |
245 | [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE", | |
246 | [FW_DEVLOG_LEVEL_INFO] = "INFO", | |
247 | [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG" | |
248 | }; | |
249 | ||
250 | static const char * const devlog_facility_strings[] = { | |
251 | [FW_DEVLOG_FACILITY_CORE] = "CORE", | |
252 | [FW_DEVLOG_FACILITY_SCHED] = "SCHED", | |
253 | [FW_DEVLOG_FACILITY_TIMER] = "TIMER", | |
254 | [FW_DEVLOG_FACILITY_RES] = "RES", | |
255 | [FW_DEVLOG_FACILITY_HW] = "HW", | |
256 | [FW_DEVLOG_FACILITY_FLR] = "FLR", | |
257 | [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ", | |
258 | [FW_DEVLOG_FACILITY_PHY] = "PHY", | |
259 | [FW_DEVLOG_FACILITY_MAC] = "MAC", | |
260 | [FW_DEVLOG_FACILITY_PORT] = "PORT", | |
261 | [FW_DEVLOG_FACILITY_VI] = "VI", | |
262 | [FW_DEVLOG_FACILITY_FILTER] = "FILTER", | |
263 | [FW_DEVLOG_FACILITY_ACL] = "ACL", | |
264 | [FW_DEVLOG_FACILITY_TM] = "TM", | |
265 | [FW_DEVLOG_FACILITY_QFC] = "QFC", | |
266 | [FW_DEVLOG_FACILITY_DCB] = "DCB", | |
267 | [FW_DEVLOG_FACILITY_ETH] = "ETH", | |
268 | [FW_DEVLOG_FACILITY_OFLD] = "OFLD", | |
269 | [FW_DEVLOG_FACILITY_RI] = "RI", | |
270 | [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI", | |
271 | [FW_DEVLOG_FACILITY_FCOE] = "FCOE", | |
272 | [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI", | |
273 | [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE" | |
274 | }; | |
275 | ||
276 | /* Information gathered by Device Log Open routine for the display routine. | |
277 | */ | |
278 | struct devlog_info { | |
279 | unsigned int nentries; /* number of entries in log[] */ | |
280 | unsigned int first; /* first [temporal] entry in log[] */ | |
281 | struct fw_devlog_e log[0]; /* Firmware Device Log */ | |
282 | }; | |
283 | ||
284 | /* Dump a Firmaware Device Log entry. | |
285 | */ | |
286 | static int devlog_show(struct seq_file *seq, void *v) | |
287 | { | |
288 | if (v == SEQ_START_TOKEN) | |
289 | seq_printf(seq, "%10s %15s %8s %8s %s\n", | |
290 | "Seq#", "Tstamp", "Level", "Facility", "Message"); | |
291 | else { | |
292 | struct devlog_info *dinfo = seq->private; | |
293 | int fidx = (uintptr_t)v - 2; | |
294 | unsigned long index; | |
295 | struct fw_devlog_e *e; | |
296 | ||
297 | /* Get a pointer to the log entry to display. Skip unused log | |
298 | * entries. | |
299 | */ | |
300 | index = dinfo->first + fidx; | |
301 | if (index >= dinfo->nentries) | |
302 | index -= dinfo->nentries; | |
303 | e = &dinfo->log[index]; | |
304 | if (e->timestamp == 0) | |
305 | return 0; | |
306 | ||
307 | /* Print the message. This depends on the firmware using | |
308 | * exactly the same formating strings as the kernel so we may | |
309 | * eventually have to put a format interpreter in here ... | |
310 | */ | |
311 | seq_printf(seq, "%10d %15llu %8s %8s ", | |
312 | e->seqno, e->timestamp, | |
313 | (e->level < ARRAY_SIZE(devlog_level_strings) | |
314 | ? devlog_level_strings[e->level] | |
315 | : "UNKNOWN"), | |
316 | (e->facility < ARRAY_SIZE(devlog_facility_strings) | |
317 | ? devlog_facility_strings[e->facility] | |
318 | : "UNKNOWN")); | |
319 | seq_printf(seq, e->fmt, e->params[0], e->params[1], | |
320 | e->params[2], e->params[3], e->params[4], | |
321 | e->params[5], e->params[6], e->params[7]); | |
322 | } | |
323 | return 0; | |
324 | } | |
325 | ||
326 | /* Sequential File Operations for Device Log. | |
327 | */ | |
328 | static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos) | |
329 | { | |
330 | if (pos > dinfo->nentries) | |
331 | return NULL; | |
332 | ||
333 | return (void *)(uintptr_t)(pos + 1); | |
334 | } | |
335 | ||
336 | static void *devlog_start(struct seq_file *seq, loff_t *pos) | |
337 | { | |
338 | struct devlog_info *dinfo = seq->private; | |
339 | ||
340 | return (*pos | |
341 | ? devlog_get_idx(dinfo, *pos) | |
342 | : SEQ_START_TOKEN); | |
343 | } | |
344 | ||
345 | static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos) | |
346 | { | |
347 | struct devlog_info *dinfo = seq->private; | |
348 | ||
349 | (*pos)++; | |
350 | return devlog_get_idx(dinfo, *pos); | |
351 | } | |
352 | ||
353 | static void devlog_stop(struct seq_file *seq, void *v) | |
354 | { | |
355 | } | |
356 | ||
357 | static const struct seq_operations devlog_seq_ops = { | |
358 | .start = devlog_start, | |
359 | .next = devlog_next, | |
360 | .stop = devlog_stop, | |
361 | .show = devlog_show | |
362 | }; | |
363 | ||
364 | /* Set up for reading the firmware's device log. We read the entire log here | |
365 | * and then display it incrementally in devlog_show(). | |
366 | */ | |
367 | static int devlog_open(struct inode *inode, struct file *file) | |
368 | { | |
369 | struct adapter *adap = inode->i_private; | |
370 | struct devlog_params *dparams = &adap->params.devlog; | |
371 | struct devlog_info *dinfo; | |
372 | unsigned int index; | |
373 | u32 fseqno; | |
374 | int ret; | |
375 | ||
376 | /* If we don't know where the log is we can't do anything. | |
377 | */ | |
378 | if (dparams->start == 0) | |
379 | return -ENXIO; | |
380 | ||
381 | /* Allocate the space to read in the firmware's device log and set up | |
382 | * for the iterated call to our display function. | |
383 | */ | |
384 | dinfo = __seq_open_private(file, &devlog_seq_ops, | |
385 | sizeof(*dinfo) + dparams->size); | |
386 | if (!dinfo) | |
387 | return -ENOMEM; | |
388 | ||
389 | /* Record the basic log buffer information and read in the raw log. | |
390 | */ | |
391 | dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e)); | |
392 | dinfo->first = 0; | |
393 | spin_lock(&adap->win0_lock); | |
394 | ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype, | |
395 | dparams->start, dparams->size, (__be32 *)dinfo->log, | |
396 | T4_MEMORY_READ); | |
397 | spin_unlock(&adap->win0_lock); | |
398 | if (ret) { | |
399 | seq_release_private(inode, file); | |
400 | return ret; | |
401 | } | |
402 | ||
403 | /* Translate log multi-byte integral elements into host native format | |
404 | * and determine where the first entry in the log is. | |
405 | */ | |
406 | for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) { | |
407 | struct fw_devlog_e *e = &dinfo->log[index]; | |
408 | int i; | |
409 | __u32 seqno; | |
410 | ||
411 | if (e->timestamp == 0) | |
412 | continue; | |
413 | ||
414 | e->timestamp = (__force __be64)be64_to_cpu(e->timestamp); | |
415 | seqno = be32_to_cpu(e->seqno); | |
416 | for (i = 0; i < 8; i++) | |
417 | e->params[i] = | |
418 | (__force __be32)be32_to_cpu(e->params[i]); | |
419 | ||
420 | if (seqno < fseqno) { | |
421 | fseqno = seqno; | |
422 | dinfo->first = index; | |
423 | } | |
424 | } | |
425 | return 0; | |
426 | } | |
427 | ||
428 | static const struct file_operations devlog_fops = { | |
429 | .owner = THIS_MODULE, | |
430 | .open = devlog_open, | |
431 | .read = seq_read, | |
432 | .llseek = seq_lseek, | |
433 | .release = seq_release_private | |
434 | }; | |
435 | ||
fd88b31a HS |
436 | static ssize_t mem_read(struct file *file, char __user *buf, size_t count, |
437 | loff_t *ppos) | |
438 | { | |
439 | loff_t pos = *ppos; | |
440 | loff_t avail = file_inode(file)->i_size; | |
441 | unsigned int mem = (uintptr_t)file->private_data & 3; | |
442 | struct adapter *adap = file->private_data - mem; | |
443 | __be32 *data; | |
444 | int ret; | |
445 | ||
446 | if (pos < 0) | |
447 | return -EINVAL; | |
448 | if (pos >= avail) | |
449 | return 0; | |
450 | if (count > avail - pos) | |
451 | count = avail - pos; | |
452 | ||
453 | data = t4_alloc_mem(count); | |
454 | if (!data) | |
455 | return -ENOMEM; | |
456 | ||
457 | spin_lock(&adap->win0_lock); | |
458 | ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ); | |
459 | spin_unlock(&adap->win0_lock); | |
460 | if (ret) { | |
461 | t4_free_mem(data); | |
462 | return ret; | |
463 | } | |
464 | ret = copy_to_user(buf, data, count); | |
465 | ||
466 | t4_free_mem(data); | |
467 | if (ret) | |
468 | return -EFAULT; | |
469 | ||
470 | *ppos = pos + count; | |
471 | return count; | |
472 | } | |
473 | ||
474 | static const struct file_operations mem_debugfs_fops = { | |
475 | .owner = THIS_MODULE, | |
476 | .open = simple_open, | |
477 | .read = mem_read, | |
478 | .llseek = default_llseek, | |
479 | }; | |
480 | ||
481 | static void add_debugfs_mem(struct adapter *adap, const char *name, | |
482 | unsigned int idx, unsigned int size_mb) | |
483 | { | |
484 | struct dentry *de; | |
485 | ||
486 | de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root, | |
487 | (void *)adap + idx, &mem_debugfs_fops); | |
488 | if (de && de->d_inode) | |
489 | de->d_inode->i_size = size_mb << 20; | |
490 | } | |
491 | ||
492 | /* Add an array of Debug FS files. | |
493 | */ | |
494 | void add_debugfs_files(struct adapter *adap, | |
495 | struct t4_debugfs_entry *files, | |
496 | unsigned int nfiles) | |
497 | { | |
498 | int i; | |
499 | ||
500 | /* debugfs support is best effort */ | |
501 | for (i = 0; i < nfiles; i++) | |
502 | debugfs_create_file(files[i].name, files[i].mode, | |
503 | adap->debugfs_root, | |
504 | (void *)adap + files[i].data, | |
505 | files[i].ops); | |
506 | } | |
507 | ||
508 | int t4_setup_debugfs(struct adapter *adap) | |
509 | { | |
510 | int i; | |
511 | u32 size; | |
512 | ||
513 | static struct t4_debugfs_entry t4_debugfs_files[] = { | |
f1ff24aa | 514 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, |
74b3092c | 515 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, |
49aa284f | 516 | { "devlog", &devlog_fops, S_IRUSR, 0 }, |
fd88b31a HS |
517 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, |
518 | }; | |
519 | ||
520 | add_debugfs_files(adap, | |
521 | t4_debugfs_files, | |
522 | ARRAY_SIZE(t4_debugfs_files)); | |
523 | ||
6559a7e8 HS |
524 | i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A); |
525 | if (i & EDRAM0_ENABLE_F) { | |
526 | size = t4_read_reg(adap, MA_EDRAM0_BAR_A); | |
527 | add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size)); | |
fd88b31a | 528 | } |
6559a7e8 HS |
529 | if (i & EDRAM1_ENABLE_F) { |
530 | size = t4_read_reg(adap, MA_EDRAM1_BAR_A); | |
531 | add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size)); | |
fd88b31a HS |
532 | } |
533 | if (is_t4(adap->params.chip)) { | |
6559a7e8 HS |
534 | size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A); |
535 | if (i & EXT_MEM_ENABLE_F) | |
fd88b31a | 536 | add_debugfs_mem(adap, "mc", MEM_MC, |
6559a7e8 | 537 | EXT_MEM_SIZE_G(size)); |
fd88b31a | 538 | } else { |
6559a7e8 HS |
539 | if (i & EXT_MEM0_ENABLE_F) { |
540 | size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A); | |
fd88b31a | 541 | add_debugfs_mem(adap, "mc0", MEM_MC0, |
6559a7e8 | 542 | EXT_MEM0_SIZE_G(size)); |
fd88b31a | 543 | } |
6559a7e8 HS |
544 | if (i & EXT_MEM1_ENABLE_F) { |
545 | size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A); | |
fd88b31a | 546 | add_debugfs_mem(adap, "mc1", MEM_MC1, |
6559a7e8 | 547 | EXT_MEM1_SIZE_G(size)); |
fd88b31a HS |
548 | } |
549 | } | |
550 | return 0; | |
551 | } |