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> | |
688ea5fe | 39 | #include <linux/ctype.h> |
fd88b31a HS |
40 | |
41 | #include "cxgb4.h" | |
42 | #include "t4_regs.h" | |
43 | #include "t4fw_api.h" | |
44 | #include "cxgb4_debugfs.h" | |
b5a02f50 | 45 | #include "clip_tbl.h" |
fd88b31a HS |
46 | #include "l2t.h" |
47 | ||
f1ff24aa HS |
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) | |
50 | { | |
51 | pos -= tb->skip_first; | |
52 | return pos >= tb->rows ? NULL : &tb->data[pos * tb->width]; | |
53 | } | |
54 | ||
55 | static 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 | ||
65 | static 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 | ||
73 | static void seq_tab_stop(struct seq_file *seq, void *v) | |
74 | { | |
75 | } | |
76 | ||
77 | static 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 | ||
84 | static 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 | ||
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)) | |
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 | ||
c778af7d HS |
107 | /* Trim the size of a seq_tab to the supplied number of rows. The operation is |
108 | * irreversible. | |
109 | */ | |
110 | static int seq_tab_trim(struct seq_tab *p, unsigned int new_rows) | |
111 | { | |
112 | if (new_rows > p->rows) | |
113 | return -EINVAL; | |
114 | p->rows = new_rows; | |
115 | return 0; | |
116 | } | |
117 | ||
f1ff24aa HS |
118 | static int cim_la_show(struct seq_file *seq, void *v, int idx) |
119 | { | |
120 | if (v == SEQ_START_TOKEN) | |
121 | seq_puts(seq, "Status Data PC LS0Stat LS0Addr " | |
122 | " LS0Data\n"); | |
123 | else { | |
124 | const u32 *p = v; | |
125 | ||
126 | seq_printf(seq, | |
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], | |
130 | p[6], p[7]); | |
131 | } | |
132 | return 0; | |
133 | } | |
134 | ||
135 | static int cim_la_show_3in1(struct seq_file *seq, void *v, int idx) | |
136 | { | |
137 | if (v == SEQ_START_TOKEN) { | |
138 | seq_puts(seq, "Status Data PC\n"); | |
139 | } else { | |
140 | const u32 *p = v; | |
141 | ||
142 | seq_printf(seq, " %02x %08x %08x\n", p[5] & 0xff, p[6], | |
143 | p[7]); | |
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); | |
149 | } | |
150 | return 0; | |
151 | } | |
152 | ||
153 | static int cim_la_open(struct inode *inode, struct file *file) | |
154 | { | |
155 | int ret; | |
156 | unsigned int cfg; | |
157 | struct seq_tab *p; | |
158 | struct adapter *adap = inode->i_private; | |
159 | ||
160 | ret = t4_cim_read(adap, UP_UP_DBG_LA_CFG_A, 1, &cfg); | |
161 | if (ret) | |
162 | return ret; | |
163 | ||
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); | |
167 | if (!p) | |
168 | return -ENOMEM; | |
169 | ||
170 | ret = t4_cim_read_la(adap, (u32 *)p->data, NULL); | |
171 | if (ret) | |
172 | seq_release_private(inode, file); | |
173 | return ret; | |
174 | } | |
175 | ||
176 | static const struct file_operations cim_la_fops = { | |
177 | .owner = THIS_MODULE, | |
178 | .open = cim_la_open, | |
179 | .read = seq_read, | |
180 | .llseek = seq_lseek, | |
181 | .release = seq_release_private | |
182 | }; | |
183 | ||
74b3092c HS |
184 | static int cim_qcfg_show(struct seq_file *seq, void *v) |
185 | { | |
186 | static const char * const qname[] = { | |
187 | "TP0", "TP1", "ULP", "SGE0", "SGE1", "NC-SI", | |
188 | "ULP0", "ULP1", "ULP2", "ULP3", "SGE", "NC-SI", | |
189 | "SGE0-RX", "SGE1-RX" | |
190 | }; | |
191 | ||
192 | int i; | |
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]; | |
200 | u32 *p = stat; | |
201 | int cim_num_obq = is_t4(adap->params.chip) ? | |
202 | CIM_NUM_OBQ : CIM_NUM_OBQ_T5; | |
203 | ||
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); | |
207 | if (!i) { | |
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); | |
211 | wr = obq_wr_t4; | |
212 | } else { | |
213 | i = t4_cim_read(adap, UP_OBQ_0_SHADOW_REALADDR_A, | |
214 | ARRAY_SIZE(obq_wr_t5), obq_wr_t5); | |
215 | wr = obq_wr_t5; | |
216 | } | |
217 | } | |
218 | if (i) | |
219 | return i; | |
220 | ||
221 | t4_read_cimq_cfg(adap, base, size, thres); | |
222 | ||
223 | seq_printf(seq, | |
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); | |
237 | return 0; | |
238 | } | |
239 | ||
240 | static int cim_qcfg_open(struct inode *inode, struct file *file) | |
241 | { | |
242 | return single_open(file, cim_qcfg_show, inode->i_private); | |
243 | } | |
244 | ||
245 | static const struct file_operations cim_qcfg_fops = { | |
246 | .owner = THIS_MODULE, | |
247 | .open = cim_qcfg_open, | |
248 | .read = seq_read, | |
249 | .llseek = seq_lseek, | |
250 | .release = single_release, | |
251 | }; | |
252 | ||
e5f0e43b HS |
253 | static int cimq_show(struct seq_file *seq, void *v, int idx) |
254 | { | |
255 | const u32 *p = v; | |
256 | ||
257 | seq_printf(seq, "%#06x: %08x %08x %08x %08x\n", idx * 16, p[0], p[1], | |
258 | p[2], p[3]); | |
259 | return 0; | |
260 | } | |
261 | ||
262 | static int cim_ibq_open(struct inode *inode, struct file *file) | |
263 | { | |
264 | int ret; | |
265 | struct seq_tab *p; | |
266 | unsigned int qid = (uintptr_t)inode->i_private & 7; | |
267 | struct adapter *adap = inode->i_private - qid; | |
268 | ||
269 | p = seq_open_tab(file, CIM_IBQ_SIZE, 4 * sizeof(u32), 0, cimq_show); | |
270 | if (!p) | |
271 | return -ENOMEM; | |
272 | ||
273 | ret = t4_read_cim_ibq(adap, qid, (u32 *)p->data, CIM_IBQ_SIZE * 4); | |
274 | if (ret < 0) | |
275 | seq_release_private(inode, file); | |
276 | else | |
277 | ret = 0; | |
278 | return ret; | |
279 | } | |
280 | ||
281 | static const struct file_operations cim_ibq_fops = { | |
282 | .owner = THIS_MODULE, | |
283 | .open = cim_ibq_open, | |
284 | .read = seq_read, | |
285 | .llseek = seq_lseek, | |
286 | .release = seq_release_private | |
287 | }; | |
288 | ||
c778af7d HS |
289 | static int cim_obq_open(struct inode *inode, struct file *file) |
290 | { | |
291 | int ret; | |
292 | struct seq_tab *p; | |
293 | unsigned int qid = (uintptr_t)inode->i_private & 7; | |
294 | struct adapter *adap = inode->i_private - qid; | |
295 | ||
296 | p = seq_open_tab(file, 6 * CIM_OBQ_SIZE, 4 * sizeof(u32), 0, cimq_show); | |
297 | if (!p) | |
298 | return -ENOMEM; | |
299 | ||
300 | ret = t4_read_cim_obq(adap, qid, (u32 *)p->data, 6 * CIM_OBQ_SIZE * 4); | |
301 | if (ret < 0) { | |
302 | seq_release_private(inode, file); | |
303 | } else { | |
304 | seq_tab_trim(p, ret / 4); | |
305 | ret = 0; | |
306 | } | |
307 | return ret; | |
308 | } | |
309 | ||
310 | static const struct file_operations cim_obq_fops = { | |
311 | .owner = THIS_MODULE, | |
312 | .open = cim_obq_open, | |
313 | .read = seq_read, | |
314 | .llseek = seq_lseek, | |
315 | .release = seq_release_private | |
316 | }; | |
317 | ||
b3bbe36a HS |
318 | /* Show the PM memory stats. These stats include: |
319 | * | |
320 | * TX: | |
321 | * Read: memory read operation | |
322 | * Write Bypass: cut-through | |
323 | * Bypass + mem: cut-through and save copy | |
324 | * | |
325 | * RX: | |
326 | * Read: memory read | |
327 | * Write Bypass: cut-through | |
328 | * Flush: payload trim or drop | |
329 | */ | |
330 | static int pm_stats_show(struct seq_file *seq, void *v) | |
331 | { | |
332 | static const char * const tx_pm_stats[] = { | |
333 | "Read:", "Write bypass:", "Write mem:", "Bypass + mem:" | |
334 | }; | |
335 | static const char * const rx_pm_stats[] = { | |
336 | "Read:", "Write bypass:", "Write mem:", "Flush:" | |
337 | }; | |
338 | ||
339 | int i; | |
340 | u32 tx_cnt[PM_NSTATS], rx_cnt[PM_NSTATS]; | |
341 | u64 tx_cyc[PM_NSTATS], rx_cyc[PM_NSTATS]; | |
342 | struct adapter *adap = seq->private; | |
343 | ||
344 | t4_pmtx_get_stats(adap, tx_cnt, tx_cyc); | |
345 | t4_pmrx_get_stats(adap, rx_cnt, rx_cyc); | |
346 | ||
347 | seq_printf(seq, "%13s %10s %20s\n", " ", "Tx pcmds", "Tx bytes"); | |
348 | for (i = 0; i < PM_NSTATS - 1; i++) | |
349 | seq_printf(seq, "%-13s %10u %20llu\n", | |
350 | tx_pm_stats[i], tx_cnt[i], tx_cyc[i]); | |
351 | ||
352 | seq_printf(seq, "%13s %10s %20s\n", " ", "Rx pcmds", "Rx bytes"); | |
353 | for (i = 0; i < PM_NSTATS - 1; i++) | |
354 | seq_printf(seq, "%-13s %10u %20llu\n", | |
355 | rx_pm_stats[i], rx_cnt[i], rx_cyc[i]); | |
356 | return 0; | |
357 | } | |
358 | ||
359 | static int pm_stats_open(struct inode *inode, struct file *file) | |
360 | { | |
361 | return single_open(file, pm_stats_show, inode->i_private); | |
362 | } | |
363 | ||
364 | static ssize_t pm_stats_clear(struct file *file, const char __user *buf, | |
365 | size_t count, loff_t *pos) | |
366 | { | |
367 | struct adapter *adap = FILE_DATA(file)->i_private; | |
368 | ||
369 | t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0); | |
370 | t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0); | |
371 | return count; | |
372 | } | |
373 | ||
374 | static const struct file_operations pm_stats_debugfs_fops = { | |
375 | .owner = THIS_MODULE, | |
376 | .open = pm_stats_open, | |
377 | .read = seq_read, | |
378 | .llseek = seq_lseek, | |
379 | .release = single_release, | |
380 | .write = pm_stats_clear | |
381 | }; | |
382 | ||
b58b6676 HS |
383 | /* Format a value in a unit that differs from the value's native unit by the |
384 | * given factor. | |
385 | */ | |
386 | static char *unit_conv(char *buf, size_t len, unsigned int val, | |
387 | unsigned int factor) | |
388 | { | |
389 | unsigned int rem = val % factor; | |
390 | ||
391 | if (rem == 0) { | |
392 | snprintf(buf, len, "%u", val / factor); | |
393 | } else { | |
394 | while (rem % 10 == 0) | |
395 | rem /= 10; | |
396 | snprintf(buf, len, "%u.%u", val / factor, rem); | |
397 | } | |
398 | return buf; | |
399 | } | |
400 | ||
401 | static int clk_show(struct seq_file *seq, void *v) | |
402 | { | |
403 | char buf[32]; | |
404 | struct adapter *adap = seq->private; | |
405 | unsigned int cclk_ps = 1000000000 / adap->params.vpd.cclk; /* in ps */ | |
406 | u32 res = t4_read_reg(adap, TP_TIMER_RESOLUTION_A); | |
407 | unsigned int tre = TIMERRESOLUTION_G(res); | |
408 | unsigned int dack_re = DELAYEDACKRESOLUTION_G(res); | |
409 | unsigned long long tp_tick_us = (cclk_ps << tre) / 1000000; /* in us */ | |
410 | ||
411 | seq_printf(seq, "Core clock period: %s ns\n", | |
412 | unit_conv(buf, sizeof(buf), cclk_ps, 1000)); | |
413 | seq_printf(seq, "TP timer tick: %s us\n", | |
414 | unit_conv(buf, sizeof(buf), (cclk_ps << tre), 1000000)); | |
415 | seq_printf(seq, "TCP timestamp tick: %s us\n", | |
416 | unit_conv(buf, sizeof(buf), | |
417 | (cclk_ps << TIMESTAMPRESOLUTION_G(res)), 1000000)); | |
418 | seq_printf(seq, "DACK tick: %s us\n", | |
419 | unit_conv(buf, sizeof(buf), (cclk_ps << dack_re), 1000000)); | |
420 | seq_printf(seq, "DACK timer: %u us\n", | |
421 | ((cclk_ps << dack_re) / 1000000) * | |
422 | t4_read_reg(adap, TP_DACK_TIMER_A)); | |
423 | seq_printf(seq, "Retransmit min: %llu us\n", | |
424 | tp_tick_us * t4_read_reg(adap, TP_RXT_MIN_A)); | |
425 | seq_printf(seq, "Retransmit max: %llu us\n", | |
426 | tp_tick_us * t4_read_reg(adap, TP_RXT_MAX_A)); | |
427 | seq_printf(seq, "Persist timer min: %llu us\n", | |
428 | tp_tick_us * t4_read_reg(adap, TP_PERS_MIN_A)); | |
429 | seq_printf(seq, "Persist timer max: %llu us\n", | |
430 | tp_tick_us * t4_read_reg(adap, TP_PERS_MAX_A)); | |
431 | seq_printf(seq, "Keepalive idle timer: %llu us\n", | |
432 | tp_tick_us * t4_read_reg(adap, TP_KEEP_IDLE_A)); | |
433 | seq_printf(seq, "Keepalive interval: %llu us\n", | |
434 | tp_tick_us * t4_read_reg(adap, TP_KEEP_INTVL_A)); | |
435 | seq_printf(seq, "Initial SRTT: %llu us\n", | |
436 | tp_tick_us * INITSRTT_G(t4_read_reg(adap, TP_INIT_SRTT_A))); | |
437 | seq_printf(seq, "FINWAIT2 timer: %llu us\n", | |
438 | tp_tick_us * t4_read_reg(adap, TP_FINWAIT2_TIMER_A)); | |
439 | ||
440 | return 0; | |
441 | } | |
442 | ||
443 | DEFINE_SIMPLE_DEBUGFS_FILE(clk); | |
444 | ||
f1ff24aa | 445 | /* Firmware Device Log dump. */ |
49aa284f HS |
446 | static const char * const devlog_level_strings[] = { |
447 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", | |
448 | [FW_DEVLOG_LEVEL_CRIT] = "CRIT", | |
449 | [FW_DEVLOG_LEVEL_ERR] = "ERR", | |
450 | [FW_DEVLOG_LEVEL_NOTICE] = "NOTICE", | |
451 | [FW_DEVLOG_LEVEL_INFO] = "INFO", | |
452 | [FW_DEVLOG_LEVEL_DEBUG] = "DEBUG" | |
453 | }; | |
454 | ||
455 | static const char * const devlog_facility_strings[] = { | |
456 | [FW_DEVLOG_FACILITY_CORE] = "CORE", | |
457 | [FW_DEVLOG_FACILITY_SCHED] = "SCHED", | |
458 | [FW_DEVLOG_FACILITY_TIMER] = "TIMER", | |
459 | [FW_DEVLOG_FACILITY_RES] = "RES", | |
460 | [FW_DEVLOG_FACILITY_HW] = "HW", | |
461 | [FW_DEVLOG_FACILITY_FLR] = "FLR", | |
462 | [FW_DEVLOG_FACILITY_DMAQ] = "DMAQ", | |
463 | [FW_DEVLOG_FACILITY_PHY] = "PHY", | |
464 | [FW_DEVLOG_FACILITY_MAC] = "MAC", | |
465 | [FW_DEVLOG_FACILITY_PORT] = "PORT", | |
466 | [FW_DEVLOG_FACILITY_VI] = "VI", | |
467 | [FW_DEVLOG_FACILITY_FILTER] = "FILTER", | |
468 | [FW_DEVLOG_FACILITY_ACL] = "ACL", | |
469 | [FW_DEVLOG_FACILITY_TM] = "TM", | |
470 | [FW_DEVLOG_FACILITY_QFC] = "QFC", | |
471 | [FW_DEVLOG_FACILITY_DCB] = "DCB", | |
472 | [FW_DEVLOG_FACILITY_ETH] = "ETH", | |
473 | [FW_DEVLOG_FACILITY_OFLD] = "OFLD", | |
474 | [FW_DEVLOG_FACILITY_RI] = "RI", | |
475 | [FW_DEVLOG_FACILITY_ISCSI] = "ISCSI", | |
476 | [FW_DEVLOG_FACILITY_FCOE] = "FCOE", | |
477 | [FW_DEVLOG_FACILITY_FOISCSI] = "FOISCSI", | |
478 | [FW_DEVLOG_FACILITY_FOFCOE] = "FOFCOE" | |
479 | }; | |
480 | ||
481 | /* Information gathered by Device Log Open routine for the display routine. | |
482 | */ | |
483 | struct devlog_info { | |
484 | unsigned int nentries; /* number of entries in log[] */ | |
485 | unsigned int first; /* first [temporal] entry in log[] */ | |
486 | struct fw_devlog_e log[0]; /* Firmware Device Log */ | |
487 | }; | |
488 | ||
489 | /* Dump a Firmaware Device Log entry. | |
490 | */ | |
491 | static int devlog_show(struct seq_file *seq, void *v) | |
492 | { | |
493 | if (v == SEQ_START_TOKEN) | |
494 | seq_printf(seq, "%10s %15s %8s %8s %s\n", | |
495 | "Seq#", "Tstamp", "Level", "Facility", "Message"); | |
496 | else { | |
497 | struct devlog_info *dinfo = seq->private; | |
498 | int fidx = (uintptr_t)v - 2; | |
499 | unsigned long index; | |
500 | struct fw_devlog_e *e; | |
501 | ||
502 | /* Get a pointer to the log entry to display. Skip unused log | |
503 | * entries. | |
504 | */ | |
505 | index = dinfo->first + fidx; | |
506 | if (index >= dinfo->nentries) | |
507 | index -= dinfo->nentries; | |
508 | e = &dinfo->log[index]; | |
509 | if (e->timestamp == 0) | |
510 | return 0; | |
511 | ||
512 | /* Print the message. This depends on the firmware using | |
513 | * exactly the same formating strings as the kernel so we may | |
514 | * eventually have to put a format interpreter in here ... | |
515 | */ | |
516 | seq_printf(seq, "%10d %15llu %8s %8s ", | |
517 | e->seqno, e->timestamp, | |
518 | (e->level < ARRAY_SIZE(devlog_level_strings) | |
519 | ? devlog_level_strings[e->level] | |
520 | : "UNKNOWN"), | |
521 | (e->facility < ARRAY_SIZE(devlog_facility_strings) | |
522 | ? devlog_facility_strings[e->facility] | |
523 | : "UNKNOWN")); | |
524 | seq_printf(seq, e->fmt, e->params[0], e->params[1], | |
525 | e->params[2], e->params[3], e->params[4], | |
526 | e->params[5], e->params[6], e->params[7]); | |
527 | } | |
528 | return 0; | |
529 | } | |
530 | ||
531 | /* Sequential File Operations for Device Log. | |
532 | */ | |
533 | static inline void *devlog_get_idx(struct devlog_info *dinfo, loff_t pos) | |
534 | { | |
535 | if (pos > dinfo->nentries) | |
536 | return NULL; | |
537 | ||
538 | return (void *)(uintptr_t)(pos + 1); | |
539 | } | |
540 | ||
541 | static void *devlog_start(struct seq_file *seq, loff_t *pos) | |
542 | { | |
543 | struct devlog_info *dinfo = seq->private; | |
544 | ||
545 | return (*pos | |
546 | ? devlog_get_idx(dinfo, *pos) | |
547 | : SEQ_START_TOKEN); | |
548 | } | |
549 | ||
550 | static void *devlog_next(struct seq_file *seq, void *v, loff_t *pos) | |
551 | { | |
552 | struct devlog_info *dinfo = seq->private; | |
553 | ||
554 | (*pos)++; | |
555 | return devlog_get_idx(dinfo, *pos); | |
556 | } | |
557 | ||
558 | static void devlog_stop(struct seq_file *seq, void *v) | |
559 | { | |
560 | } | |
561 | ||
562 | static const struct seq_operations devlog_seq_ops = { | |
563 | .start = devlog_start, | |
564 | .next = devlog_next, | |
565 | .stop = devlog_stop, | |
566 | .show = devlog_show | |
567 | }; | |
568 | ||
569 | /* Set up for reading the firmware's device log. We read the entire log here | |
570 | * and then display it incrementally in devlog_show(). | |
571 | */ | |
572 | static int devlog_open(struct inode *inode, struct file *file) | |
573 | { | |
574 | struct adapter *adap = inode->i_private; | |
575 | struct devlog_params *dparams = &adap->params.devlog; | |
576 | struct devlog_info *dinfo; | |
577 | unsigned int index; | |
578 | u32 fseqno; | |
579 | int ret; | |
580 | ||
581 | /* If we don't know where the log is we can't do anything. | |
582 | */ | |
583 | if (dparams->start == 0) | |
584 | return -ENXIO; | |
585 | ||
586 | /* Allocate the space to read in the firmware's device log and set up | |
587 | * for the iterated call to our display function. | |
588 | */ | |
589 | dinfo = __seq_open_private(file, &devlog_seq_ops, | |
590 | sizeof(*dinfo) + dparams->size); | |
591 | if (!dinfo) | |
592 | return -ENOMEM; | |
593 | ||
594 | /* Record the basic log buffer information and read in the raw log. | |
595 | */ | |
596 | dinfo->nentries = (dparams->size / sizeof(struct fw_devlog_e)); | |
597 | dinfo->first = 0; | |
598 | spin_lock(&adap->win0_lock); | |
599 | ret = t4_memory_rw(adap, adap->params.drv_memwin, dparams->memtype, | |
600 | dparams->start, dparams->size, (__be32 *)dinfo->log, | |
601 | T4_MEMORY_READ); | |
602 | spin_unlock(&adap->win0_lock); | |
603 | if (ret) { | |
604 | seq_release_private(inode, file); | |
605 | return ret; | |
606 | } | |
607 | ||
608 | /* Translate log multi-byte integral elements into host native format | |
609 | * and determine where the first entry in the log is. | |
610 | */ | |
611 | for (fseqno = ~((u32)0), index = 0; index < dinfo->nentries; index++) { | |
612 | struct fw_devlog_e *e = &dinfo->log[index]; | |
613 | int i; | |
614 | __u32 seqno; | |
615 | ||
616 | if (e->timestamp == 0) | |
617 | continue; | |
618 | ||
619 | e->timestamp = (__force __be64)be64_to_cpu(e->timestamp); | |
620 | seqno = be32_to_cpu(e->seqno); | |
621 | for (i = 0; i < 8; i++) | |
622 | e->params[i] = | |
623 | (__force __be32)be32_to_cpu(e->params[i]); | |
624 | ||
625 | if (seqno < fseqno) { | |
626 | fseqno = seqno; | |
627 | dinfo->first = index; | |
628 | } | |
629 | } | |
630 | return 0; | |
631 | } | |
632 | ||
633 | static const struct file_operations devlog_fops = { | |
634 | .owner = THIS_MODULE, | |
635 | .open = devlog_open, | |
636 | .read = seq_read, | |
637 | .llseek = seq_lseek, | |
638 | .release = seq_release_private | |
639 | }; | |
640 | ||
49216c1c HS |
641 | static ssize_t flash_read(struct file *file, char __user *buf, size_t count, |
642 | loff_t *ppos) | |
643 | { | |
644 | loff_t pos = *ppos; | |
645 | loff_t avail = FILE_DATA(file)->i_size; | |
646 | struct adapter *adap = file->private_data; | |
647 | ||
648 | if (pos < 0) | |
649 | return -EINVAL; | |
650 | if (pos >= avail) | |
651 | return 0; | |
652 | if (count > avail - pos) | |
653 | count = avail - pos; | |
654 | ||
655 | while (count) { | |
656 | size_t len; | |
657 | int ret, ofst; | |
658 | u8 data[256]; | |
659 | ||
660 | ofst = pos & 3; | |
661 | len = min(count + ofst, sizeof(data)); | |
662 | ret = t4_read_flash(adap, pos - ofst, (len + 3) / 4, | |
663 | (u32 *)data, 1); | |
664 | if (ret) | |
665 | return ret; | |
666 | ||
667 | len -= ofst; | |
668 | if (copy_to_user(buf, data + ofst, len)) | |
669 | return -EFAULT; | |
670 | ||
671 | buf += len; | |
672 | pos += len; | |
673 | count -= len; | |
674 | } | |
675 | count = pos - *ppos; | |
676 | *ppos = pos; | |
677 | return count; | |
678 | } | |
679 | ||
680 | static const struct file_operations flash_debugfs_fops = { | |
681 | .owner = THIS_MODULE, | |
682 | .open = mem_open, | |
683 | .read = flash_read, | |
684 | }; | |
685 | ||
ef82f662 HS |
686 | static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask) |
687 | { | |
688 | *mask = x | y; | |
689 | y = (__force u64)cpu_to_be64(y); | |
690 | memcpy(addr, (char *)&y + 2, ETH_ALEN); | |
691 | } | |
692 | ||
693 | static int mps_tcam_show(struct seq_file *seq, void *v) | |
694 | { | |
695 | if (v == SEQ_START_TOKEN) | |
696 | seq_puts(seq, "Idx Ethernet address Mask Vld Ports PF" | |
697 | " VF Replication " | |
698 | "P0 P1 P2 P3 ML\n"); | |
699 | else { | |
700 | u64 mask; | |
701 | u8 addr[ETH_ALEN]; | |
702 | struct adapter *adap = seq->private; | |
703 | unsigned int idx = (uintptr_t)v - 2; | |
704 | u64 tcamy = t4_read_reg64(adap, MPS_CLS_TCAM_Y_L(idx)); | |
705 | u64 tcamx = t4_read_reg64(adap, MPS_CLS_TCAM_X_L(idx)); | |
706 | u32 cls_lo = t4_read_reg(adap, MPS_CLS_SRAM_L(idx)); | |
707 | u32 cls_hi = t4_read_reg(adap, MPS_CLS_SRAM_H(idx)); | |
708 | u32 rplc[4] = {0, 0, 0, 0}; | |
709 | ||
710 | if (tcamx & tcamy) { | |
711 | seq_printf(seq, "%3u -\n", idx); | |
712 | goto out; | |
713 | } | |
714 | ||
715 | if (cls_lo & REPLICATE_F) { | |
716 | struct fw_ldst_cmd ldst_cmd; | |
717 | int ret; | |
718 | ||
719 | memset(&ldst_cmd, 0, sizeof(ldst_cmd)); | |
720 | ldst_cmd.op_to_addrspace = | |
721 | htonl(FW_CMD_OP_V(FW_LDST_CMD) | | |
722 | FW_CMD_REQUEST_F | | |
723 | FW_CMD_READ_F | | |
724 | FW_LDST_CMD_ADDRSPACE_V( | |
725 | FW_LDST_ADDRSPC_MPS)); | |
726 | ldst_cmd.cycles_to_len16 = htonl(FW_LEN16(ldst_cmd)); | |
727 | ldst_cmd.u.mps.fid_ctl = | |
728 | htons(FW_LDST_CMD_FID_V(FW_LDST_MPS_RPLC) | | |
729 | FW_LDST_CMD_CTL_V(idx)); | |
730 | ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd, | |
731 | sizeof(ldst_cmd), &ldst_cmd); | |
732 | if (ret) | |
733 | dev_warn(adap->pdev_dev, "Can't read MPS " | |
734 | "replication map for idx %d: %d\n", | |
735 | idx, -ret); | |
736 | else { | |
737 | rplc[0] = ntohl(ldst_cmd.u.mps.rplc31_0); | |
738 | rplc[1] = ntohl(ldst_cmd.u.mps.rplc63_32); | |
739 | rplc[2] = ntohl(ldst_cmd.u.mps.rplc95_64); | |
740 | rplc[3] = ntohl(ldst_cmd.u.mps.rplc127_96); | |
741 | } | |
742 | } | |
743 | ||
744 | tcamxy2valmask(tcamx, tcamy, addr, &mask); | |
745 | seq_printf(seq, "%3u %02x:%02x:%02x:%02x:%02x:%02x %012llx" | |
746 | "%3c %#x%4u%4d", | |
747 | idx, addr[0], addr[1], addr[2], addr[3], addr[4], | |
748 | addr[5], (unsigned long long)mask, | |
749 | (cls_lo & SRAM_VLD_F) ? 'Y' : 'N', PORTMAP_G(cls_hi), | |
750 | PF_G(cls_lo), | |
751 | (cls_lo & VF_VALID_F) ? VF_G(cls_lo) : -1); | |
752 | if (cls_lo & REPLICATE_F) | |
753 | seq_printf(seq, " %08x %08x %08x %08x", | |
754 | rplc[3], rplc[2], rplc[1], rplc[0]); | |
755 | else | |
756 | seq_printf(seq, "%36c", ' '); | |
757 | seq_printf(seq, "%4u%3u%3u%3u %#x\n", | |
758 | SRAM_PRIO0_G(cls_lo), SRAM_PRIO1_G(cls_lo), | |
759 | SRAM_PRIO2_G(cls_lo), SRAM_PRIO3_G(cls_lo), | |
760 | (cls_lo >> MULTILISTEN0_S) & 0xf); | |
761 | } | |
762 | out: return 0; | |
763 | } | |
764 | ||
765 | static inline void *mps_tcam_get_idx(struct seq_file *seq, loff_t pos) | |
766 | { | |
767 | struct adapter *adap = seq->private; | |
768 | int max_mac_addr = is_t4(adap->params.chip) ? | |
769 | NUM_MPS_CLS_SRAM_L_INSTANCES : | |
770 | NUM_MPS_T5_CLS_SRAM_L_INSTANCES; | |
771 | return ((pos <= max_mac_addr) ? (void *)(uintptr_t)(pos + 1) : NULL); | |
772 | } | |
773 | ||
774 | static void *mps_tcam_start(struct seq_file *seq, loff_t *pos) | |
775 | { | |
776 | return *pos ? mps_tcam_get_idx(seq, *pos) : SEQ_START_TOKEN; | |
777 | } | |
778 | ||
779 | static void *mps_tcam_next(struct seq_file *seq, void *v, loff_t *pos) | |
780 | { | |
781 | ++*pos; | |
782 | return mps_tcam_get_idx(seq, *pos); | |
783 | } | |
784 | ||
785 | static void mps_tcam_stop(struct seq_file *seq, void *v) | |
786 | { | |
787 | } | |
788 | ||
789 | static const struct seq_operations mps_tcam_seq_ops = { | |
790 | .start = mps_tcam_start, | |
791 | .next = mps_tcam_next, | |
792 | .stop = mps_tcam_stop, | |
793 | .show = mps_tcam_show | |
794 | }; | |
795 | ||
796 | static int mps_tcam_open(struct inode *inode, struct file *file) | |
797 | { | |
798 | int res = seq_open(file, &mps_tcam_seq_ops); | |
799 | ||
800 | if (!res) { | |
801 | struct seq_file *seq = file->private_data; | |
802 | ||
803 | seq->private = inode->i_private; | |
804 | } | |
805 | return res; | |
806 | } | |
807 | ||
808 | static const struct file_operations mps_tcam_debugfs_fops = { | |
809 | .owner = THIS_MODULE, | |
810 | .open = mps_tcam_open, | |
811 | .read = seq_read, | |
812 | .llseek = seq_lseek, | |
813 | .release = seq_release, | |
814 | }; | |
815 | ||
b5a02f50 AB |
816 | #if IS_ENABLED(CONFIG_IPV6) |
817 | static int clip_tbl_open(struct inode *inode, struct file *file) | |
818 | { | |
819 | return single_open(file, clip_tbl_show, PDE_DATA(inode)); | |
820 | } | |
821 | ||
822 | static const struct file_operations clip_tbl_debugfs_fops = { | |
823 | .owner = THIS_MODULE, | |
824 | .open = clip_tbl_open, | |
825 | .read = seq_read, | |
826 | .llseek = seq_lseek, | |
827 | .release = single_release | |
828 | }; | |
829 | #endif | |
830 | ||
688ea5fe HS |
831 | /*RSS Table. |
832 | */ | |
833 | ||
834 | static int rss_show(struct seq_file *seq, void *v, int idx) | |
835 | { | |
836 | u16 *entry = v; | |
837 | ||
838 | seq_printf(seq, "%4d: %4u %4u %4u %4u %4u %4u %4u %4u\n", | |
839 | idx * 8, entry[0], entry[1], entry[2], entry[3], entry[4], | |
840 | entry[5], entry[6], entry[7]); | |
841 | return 0; | |
842 | } | |
843 | ||
844 | static int rss_open(struct inode *inode, struct file *file) | |
845 | { | |
846 | int ret; | |
847 | struct seq_tab *p; | |
848 | struct adapter *adap = inode->i_private; | |
849 | ||
850 | p = seq_open_tab(file, RSS_NENTRIES / 8, 8 * sizeof(u16), 0, rss_show); | |
851 | if (!p) | |
852 | return -ENOMEM; | |
853 | ||
854 | ret = t4_read_rss(adap, (u16 *)p->data); | |
855 | if (ret) | |
856 | seq_release_private(inode, file); | |
857 | ||
858 | return ret; | |
859 | } | |
860 | ||
861 | static const struct file_operations rss_debugfs_fops = { | |
862 | .owner = THIS_MODULE, | |
863 | .open = rss_open, | |
864 | .read = seq_read, | |
865 | .llseek = seq_lseek, | |
866 | .release = seq_release_private | |
867 | }; | |
868 | ||
869 | /* RSS Configuration. | |
870 | */ | |
871 | ||
872 | /* Small utility function to return the strings "yes" or "no" if the supplied | |
873 | * argument is non-zero. | |
874 | */ | |
875 | static const char *yesno(int x) | |
876 | { | |
877 | static const char *yes = "yes"; | |
878 | static const char *no = "no"; | |
879 | ||
880 | return x ? yes : no; | |
881 | } | |
882 | ||
883 | static int rss_config_show(struct seq_file *seq, void *v) | |
884 | { | |
885 | struct adapter *adapter = seq->private; | |
886 | static const char * const keymode[] = { | |
887 | "global", | |
888 | "global and per-VF scramble", | |
889 | "per-PF and per-VF scramble", | |
890 | "per-VF and per-VF scramble", | |
891 | }; | |
892 | u32 rssconf; | |
893 | ||
894 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_A); | |
895 | seq_printf(seq, "TP_RSS_CONFIG: %#x\n", rssconf); | |
896 | seq_printf(seq, " Tnl4TupEnIpv6: %3s\n", yesno(rssconf & | |
897 | TNL4TUPENIPV6_F)); | |
898 | seq_printf(seq, " Tnl2TupEnIpv6: %3s\n", yesno(rssconf & | |
899 | TNL2TUPENIPV6_F)); | |
900 | seq_printf(seq, " Tnl4TupEnIpv4: %3s\n", yesno(rssconf & | |
901 | TNL4TUPENIPV4_F)); | |
902 | seq_printf(seq, " Tnl2TupEnIpv4: %3s\n", yesno(rssconf & | |
903 | TNL2TUPENIPV4_F)); | |
904 | seq_printf(seq, " TnlTcpSel: %3s\n", yesno(rssconf & TNLTCPSEL_F)); | |
905 | seq_printf(seq, " TnlIp6Sel: %3s\n", yesno(rssconf & TNLIP6SEL_F)); | |
906 | seq_printf(seq, " TnlVrtSel: %3s\n", yesno(rssconf & TNLVRTSEL_F)); | |
907 | seq_printf(seq, " TnlMapEn: %3s\n", yesno(rssconf & TNLMAPEN_F)); | |
908 | seq_printf(seq, " OfdHashSave: %3s\n", yesno(rssconf & | |
909 | OFDHASHSAVE_F)); | |
910 | seq_printf(seq, " OfdVrtSel: %3s\n", yesno(rssconf & OFDVRTSEL_F)); | |
911 | seq_printf(seq, " OfdMapEn: %3s\n", yesno(rssconf & OFDMAPEN_F)); | |
912 | seq_printf(seq, " OfdLkpEn: %3s\n", yesno(rssconf & OFDLKPEN_F)); | |
913 | seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf & | |
914 | SYN4TUPENIPV6_F)); | |
915 | seq_printf(seq, " Syn2TupEnIpv6: %3s\n", yesno(rssconf & | |
916 | SYN2TUPENIPV6_F)); | |
917 | seq_printf(seq, " Syn4TupEnIpv4: %3s\n", yesno(rssconf & | |
918 | SYN4TUPENIPV4_F)); | |
919 | seq_printf(seq, " Syn2TupEnIpv4: %3s\n", yesno(rssconf & | |
920 | SYN2TUPENIPV4_F)); | |
921 | seq_printf(seq, " Syn4TupEnIpv6: %3s\n", yesno(rssconf & | |
922 | SYN4TUPENIPV6_F)); | |
923 | seq_printf(seq, " SynIp6Sel: %3s\n", yesno(rssconf & SYNIP6SEL_F)); | |
924 | seq_printf(seq, " SynVrt6Sel: %3s\n", yesno(rssconf & SYNVRTSEL_F)); | |
925 | seq_printf(seq, " SynMapEn: %3s\n", yesno(rssconf & SYNMAPEN_F)); | |
926 | seq_printf(seq, " SynLkpEn: %3s\n", yesno(rssconf & SYNLKPEN_F)); | |
927 | seq_printf(seq, " ChnEn: %3s\n", yesno(rssconf & | |
928 | CHANNELENABLE_F)); | |
929 | seq_printf(seq, " PrtEn: %3s\n", yesno(rssconf & | |
930 | PORTENABLE_F)); | |
931 | seq_printf(seq, " TnlAllLkp: %3s\n", yesno(rssconf & | |
932 | TNLALLLOOKUP_F)); | |
933 | seq_printf(seq, " VrtEn: %3s\n", yesno(rssconf & | |
934 | VIRTENABLE_F)); | |
935 | seq_printf(seq, " CngEn: %3s\n", yesno(rssconf & | |
936 | CONGESTIONENABLE_F)); | |
937 | seq_printf(seq, " HashToeplitz: %3s\n", yesno(rssconf & | |
938 | HASHTOEPLITZ_F)); | |
939 | seq_printf(seq, " Udp4En: %3s\n", yesno(rssconf & UDPENABLE_F)); | |
940 | seq_printf(seq, " Disable: %3s\n", yesno(rssconf & DISABLE_F)); | |
941 | ||
942 | seq_puts(seq, "\n"); | |
943 | ||
944 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_TNL_A); | |
945 | seq_printf(seq, "TP_RSS_CONFIG_TNL: %#x\n", rssconf); | |
946 | seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf)); | |
947 | seq_printf(seq, " MaskFilter: %3d\n", MASKFILTER_G(rssconf)); | |
948 | if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) { | |
949 | seq_printf(seq, " HashAll: %3s\n", | |
950 | yesno(rssconf & HASHALL_F)); | |
951 | seq_printf(seq, " HashEth: %3s\n", | |
952 | yesno(rssconf & HASHETH_F)); | |
953 | } | |
954 | seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F)); | |
955 | ||
956 | seq_puts(seq, "\n"); | |
957 | ||
958 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_OFD_A); | |
959 | seq_printf(seq, "TP_RSS_CONFIG_OFD: %#x\n", rssconf); | |
960 | seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf)); | |
961 | seq_printf(seq, " RRCplMapEn: %3s\n", yesno(rssconf & | |
962 | RRCPLMAPEN_F)); | |
963 | seq_printf(seq, " RRCplQueWidth: %3d\n", RRCPLQUEWIDTH_G(rssconf)); | |
964 | ||
965 | seq_puts(seq, "\n"); | |
966 | ||
967 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_SYN_A); | |
968 | seq_printf(seq, "TP_RSS_CONFIG_SYN: %#x\n", rssconf); | |
969 | seq_printf(seq, " MaskSize: %3d\n", MASKSIZE_G(rssconf)); | |
970 | seq_printf(seq, " UseWireCh: %3s\n", yesno(rssconf & USEWIRECH_F)); | |
971 | ||
972 | seq_puts(seq, "\n"); | |
973 | ||
974 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_VRT_A); | |
975 | seq_printf(seq, "TP_RSS_CONFIG_VRT: %#x\n", rssconf); | |
976 | if (CHELSIO_CHIP_VERSION(adapter->params.chip) > CHELSIO_T5) { | |
977 | seq_printf(seq, " KeyWrAddrX: %3d\n", | |
978 | KEYWRADDRX_G(rssconf)); | |
979 | seq_printf(seq, " KeyExtend: %3s\n", | |
980 | yesno(rssconf & KEYEXTEND_F)); | |
981 | } | |
982 | seq_printf(seq, " VfRdRg: %3s\n", yesno(rssconf & VFRDRG_F)); | |
983 | seq_printf(seq, " VfRdEn: %3s\n", yesno(rssconf & VFRDEN_F)); | |
984 | seq_printf(seq, " VfPerrEn: %3s\n", yesno(rssconf & VFPERREN_F)); | |
985 | seq_printf(seq, " KeyPerrEn: %3s\n", yesno(rssconf & KEYPERREN_F)); | |
986 | seq_printf(seq, " DisVfVlan: %3s\n", yesno(rssconf & | |
987 | DISABLEVLAN_F)); | |
988 | seq_printf(seq, " EnUpSwt: %3s\n", yesno(rssconf & ENABLEUP0_F)); | |
989 | seq_printf(seq, " HashDelay: %3d\n", HASHDELAY_G(rssconf)); | |
990 | if (CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5) | |
991 | seq_printf(seq, " VfWrAddr: %3d\n", VFWRADDR_G(rssconf)); | |
992 | seq_printf(seq, " KeyMode: %s\n", keymode[KEYMODE_G(rssconf)]); | |
993 | seq_printf(seq, " VfWrEn: %3s\n", yesno(rssconf & VFWREN_F)); | |
994 | seq_printf(seq, " KeyWrEn: %3s\n", yesno(rssconf & KEYWREN_F)); | |
995 | seq_printf(seq, " KeyWrAddr: %3d\n", KEYWRADDR_G(rssconf)); | |
996 | ||
997 | seq_puts(seq, "\n"); | |
998 | ||
999 | rssconf = t4_read_reg(adapter, TP_RSS_CONFIG_CNG_A); | |
1000 | seq_printf(seq, "TP_RSS_CONFIG_CNG: %#x\n", rssconf); | |
1001 | seq_printf(seq, " ChnCount3: %3s\n", yesno(rssconf & CHNCOUNT3_F)); | |
1002 | seq_printf(seq, " ChnCount2: %3s\n", yesno(rssconf & CHNCOUNT2_F)); | |
1003 | seq_printf(seq, " ChnCount1: %3s\n", yesno(rssconf & CHNCOUNT1_F)); | |
1004 | seq_printf(seq, " ChnCount0: %3s\n", yesno(rssconf & CHNCOUNT0_F)); | |
1005 | seq_printf(seq, " ChnUndFlow3: %3s\n", yesno(rssconf & | |
1006 | CHNUNDFLOW3_F)); | |
1007 | seq_printf(seq, " ChnUndFlow2: %3s\n", yesno(rssconf & | |
1008 | CHNUNDFLOW2_F)); | |
1009 | seq_printf(seq, " ChnUndFlow1: %3s\n", yesno(rssconf & | |
1010 | CHNUNDFLOW1_F)); | |
1011 | seq_printf(seq, " ChnUndFlow0: %3s\n", yesno(rssconf & | |
1012 | CHNUNDFLOW0_F)); | |
1013 | seq_printf(seq, " RstChn3: %3s\n", yesno(rssconf & RSTCHN3_F)); | |
1014 | seq_printf(seq, " RstChn2: %3s\n", yesno(rssconf & RSTCHN2_F)); | |
1015 | seq_printf(seq, " RstChn1: %3s\n", yesno(rssconf & RSTCHN1_F)); | |
1016 | seq_printf(seq, " RstChn0: %3s\n", yesno(rssconf & RSTCHN0_F)); | |
1017 | seq_printf(seq, " UpdVld: %3s\n", yesno(rssconf & UPDVLD_F)); | |
1018 | seq_printf(seq, " Xoff: %3s\n", yesno(rssconf & XOFF_F)); | |
1019 | seq_printf(seq, " UpdChn3: %3s\n", yesno(rssconf & UPDCHN3_F)); | |
1020 | seq_printf(seq, " UpdChn2: %3s\n", yesno(rssconf & UPDCHN2_F)); | |
1021 | seq_printf(seq, " UpdChn1: %3s\n", yesno(rssconf & UPDCHN1_F)); | |
1022 | seq_printf(seq, " UpdChn0: %3s\n", yesno(rssconf & UPDCHN0_F)); | |
1023 | seq_printf(seq, " Queue: %3d\n", QUEUE_G(rssconf)); | |
1024 | ||
1025 | return 0; | |
1026 | } | |
1027 | ||
1028 | DEFINE_SIMPLE_DEBUGFS_FILE(rss_config); | |
1029 | ||
1030 | /* RSS Secret Key. | |
1031 | */ | |
1032 | ||
1033 | static int rss_key_show(struct seq_file *seq, void *v) | |
1034 | { | |
1035 | u32 key[10]; | |
1036 | ||
1037 | t4_read_rss_key(seq->private, key); | |
1038 | seq_printf(seq, "%08x%08x%08x%08x%08x%08x%08x%08x%08x%08x\n", | |
1039 | key[9], key[8], key[7], key[6], key[5], key[4], key[3], | |
1040 | key[2], key[1], key[0]); | |
1041 | return 0; | |
1042 | } | |
1043 | ||
1044 | static int rss_key_open(struct inode *inode, struct file *file) | |
1045 | { | |
1046 | return single_open(file, rss_key_show, inode->i_private); | |
1047 | } | |
1048 | ||
1049 | static ssize_t rss_key_write(struct file *file, const char __user *buf, | |
1050 | size_t count, loff_t *pos) | |
1051 | { | |
1052 | int i, j; | |
1053 | u32 key[10]; | |
1054 | char s[100], *p; | |
1055 | struct adapter *adap = FILE_DATA(file)->i_private; | |
1056 | ||
1057 | if (count > sizeof(s) - 1) | |
1058 | return -EINVAL; | |
1059 | if (copy_from_user(s, buf, count)) | |
1060 | return -EFAULT; | |
1061 | for (i = count; i > 0 && isspace(s[i - 1]); i--) | |
1062 | ; | |
1063 | s[i] = '\0'; | |
1064 | ||
1065 | for (p = s, i = 9; i >= 0; i--) { | |
1066 | key[i] = 0; | |
1067 | for (j = 0; j < 8; j++, p++) { | |
1068 | if (!isxdigit(*p)) | |
1069 | return -EINVAL; | |
1070 | key[i] = (key[i] << 4) | hex2val(*p); | |
1071 | } | |
1072 | } | |
1073 | ||
1074 | t4_write_rss_key(adap, key, -1); | |
1075 | return count; | |
1076 | } | |
1077 | ||
1078 | static const struct file_operations rss_key_debugfs_fops = { | |
1079 | .owner = THIS_MODULE, | |
1080 | .open = rss_key_open, | |
1081 | .read = seq_read, | |
1082 | .llseek = seq_lseek, | |
1083 | .release = single_release, | |
1084 | .write = rss_key_write | |
1085 | }; | |
1086 | ||
1087 | /* PF RSS Configuration. | |
1088 | */ | |
1089 | ||
1090 | struct rss_pf_conf { | |
1091 | u32 rss_pf_map; | |
1092 | u32 rss_pf_mask; | |
1093 | u32 rss_pf_config; | |
1094 | }; | |
1095 | ||
1096 | static int rss_pf_config_show(struct seq_file *seq, void *v, int idx) | |
1097 | { | |
1098 | struct rss_pf_conf *pfconf; | |
1099 | ||
1100 | if (v == SEQ_START_TOKEN) { | |
1101 | /* use the 0th entry to dump the PF Map Index Size */ | |
1102 | pfconf = seq->private + offsetof(struct seq_tab, data); | |
1103 | seq_printf(seq, "PF Map Index Size = %d\n\n", | |
1104 | LKPIDXSIZE_G(pfconf->rss_pf_map)); | |
1105 | ||
1106 | seq_puts(seq, " RSS PF VF Hash Tuple Enable Default\n"); | |
1107 | seq_puts(seq, " Enable IPF Mask Mask IPv6 IPv4 UDP Queue\n"); | |
1108 | seq_puts(seq, " PF Map Chn Prt Map Size Size Four Two Four Two Four Ch1 Ch0\n"); | |
1109 | } else { | |
1110 | #define G_PFnLKPIDX(map, n) \ | |
1111 | (((map) >> PF1LKPIDX_S*(n)) & PF0LKPIDX_M) | |
1112 | #define G_PFnMSKSIZE(mask, n) \ | |
1113 | (((mask) >> PF1MSKSIZE_S*(n)) & PF1MSKSIZE_M) | |
1114 | ||
1115 | pfconf = v; | |
1116 | seq_printf(seq, "%3d %3s %3s %3s %3d %3d %3d %3s %3s %3s %3s %3s %3d %3d\n", | |
1117 | idx, | |
1118 | yesno(pfconf->rss_pf_config & MAPENABLE_F), | |
1119 | yesno(pfconf->rss_pf_config & CHNENABLE_F), | |
1120 | yesno(pfconf->rss_pf_config & PRTENABLE_F), | |
1121 | G_PFnLKPIDX(pfconf->rss_pf_map, idx), | |
1122 | G_PFnMSKSIZE(pfconf->rss_pf_mask, idx), | |
1123 | IVFWIDTH_G(pfconf->rss_pf_config), | |
1124 | yesno(pfconf->rss_pf_config & IP6FOURTUPEN_F), | |
1125 | yesno(pfconf->rss_pf_config & IP6TWOTUPEN_F), | |
1126 | yesno(pfconf->rss_pf_config & IP4FOURTUPEN_F), | |
1127 | yesno(pfconf->rss_pf_config & IP4TWOTUPEN_F), | |
1128 | yesno(pfconf->rss_pf_config & UDPFOURTUPEN_F), | |
1129 | CH1DEFAULTQUEUE_G(pfconf->rss_pf_config), | |
1130 | CH0DEFAULTQUEUE_G(pfconf->rss_pf_config)); | |
1131 | ||
1132 | #undef G_PFnLKPIDX | |
1133 | #undef G_PFnMSKSIZE | |
1134 | } | |
1135 | return 0; | |
1136 | } | |
1137 | ||
1138 | static int rss_pf_config_open(struct inode *inode, struct file *file) | |
1139 | { | |
1140 | struct adapter *adapter = inode->i_private; | |
1141 | struct seq_tab *p; | |
1142 | u32 rss_pf_map, rss_pf_mask; | |
1143 | struct rss_pf_conf *pfconf; | |
1144 | int pf; | |
1145 | ||
1146 | p = seq_open_tab(file, 8, sizeof(*pfconf), 1, rss_pf_config_show); | |
1147 | if (!p) | |
1148 | return -ENOMEM; | |
1149 | ||
1150 | pfconf = (struct rss_pf_conf *)p->data; | |
1151 | rss_pf_map = t4_read_rss_pf_map(adapter); | |
1152 | rss_pf_mask = t4_read_rss_pf_mask(adapter); | |
1153 | for (pf = 0; pf < 8; pf++) { | |
1154 | pfconf[pf].rss_pf_map = rss_pf_map; | |
1155 | pfconf[pf].rss_pf_mask = rss_pf_mask; | |
1156 | t4_read_rss_pf_config(adapter, pf, &pfconf[pf].rss_pf_config); | |
1157 | } | |
1158 | return 0; | |
1159 | } | |
1160 | ||
1161 | static const struct file_operations rss_pf_config_debugfs_fops = { | |
1162 | .owner = THIS_MODULE, | |
1163 | .open = rss_pf_config_open, | |
1164 | .read = seq_read, | |
1165 | .llseek = seq_lseek, | |
1166 | .release = seq_release_private | |
1167 | }; | |
1168 | ||
1169 | /* VF RSS Configuration. | |
1170 | */ | |
1171 | ||
1172 | struct rss_vf_conf { | |
1173 | u32 rss_vf_vfl; | |
1174 | u32 rss_vf_vfh; | |
1175 | }; | |
1176 | ||
1177 | static int rss_vf_config_show(struct seq_file *seq, void *v, int idx) | |
1178 | { | |
1179 | if (v == SEQ_START_TOKEN) { | |
1180 | seq_puts(seq, " RSS Hash Tuple Enable\n"); | |
1181 | seq_puts(seq, " Enable IVF Dis Enb IPv6 IPv4 UDP Def Secret Key\n"); | |
1182 | seq_puts(seq, " VF Chn Prt Map VLAN uP Four Two Four Two Four Que Idx Hash\n"); | |
1183 | } else { | |
1184 | struct rss_vf_conf *vfconf = v; | |
1185 | ||
1186 | seq_printf(seq, "%3d %3s %3s %3d %3s %3s %3s %3s %3s %3s %3s %4d %3d %#10x\n", | |
1187 | idx, | |
1188 | yesno(vfconf->rss_vf_vfh & VFCHNEN_F), | |
1189 | yesno(vfconf->rss_vf_vfh & VFPRTEN_F), | |
1190 | VFLKPIDX_G(vfconf->rss_vf_vfh), | |
1191 | yesno(vfconf->rss_vf_vfh & VFVLNEX_F), | |
1192 | yesno(vfconf->rss_vf_vfh & VFUPEN_F), | |
1193 | yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F), | |
1194 | yesno(vfconf->rss_vf_vfh & VFIP6TWOTUPEN_F), | |
1195 | yesno(vfconf->rss_vf_vfh & VFIP4FOURTUPEN_F), | |
1196 | yesno(vfconf->rss_vf_vfh & VFIP4TWOTUPEN_F), | |
1197 | yesno(vfconf->rss_vf_vfh & ENABLEUDPHASH_F), | |
1198 | DEFAULTQUEUE_G(vfconf->rss_vf_vfh), | |
1199 | KEYINDEX_G(vfconf->rss_vf_vfh), | |
1200 | vfconf->rss_vf_vfl); | |
1201 | } | |
1202 | return 0; | |
1203 | } | |
1204 | ||
1205 | static int rss_vf_config_open(struct inode *inode, struct file *file) | |
1206 | { | |
1207 | struct adapter *adapter = inode->i_private; | |
1208 | struct seq_tab *p; | |
1209 | struct rss_vf_conf *vfconf; | |
1210 | int vf; | |
1211 | ||
1212 | p = seq_open_tab(file, 128, sizeof(*vfconf), 1, rss_vf_config_show); | |
1213 | if (!p) | |
1214 | return -ENOMEM; | |
1215 | ||
1216 | vfconf = (struct rss_vf_conf *)p->data; | |
1217 | for (vf = 0; vf < 128; vf++) { | |
1218 | t4_read_rss_vf_config(adapter, vf, &vfconf[vf].rss_vf_vfl, | |
1219 | &vfconf[vf].rss_vf_vfh); | |
1220 | } | |
1221 | return 0; | |
1222 | } | |
1223 | ||
1224 | static const struct file_operations rss_vf_config_debugfs_fops = { | |
1225 | .owner = THIS_MODULE, | |
1226 | .open = rss_vf_config_open, | |
1227 | .read = seq_read, | |
1228 | .llseek = seq_lseek, | |
1229 | .release = seq_release_private | |
1230 | }; | |
1231 | ||
dc9daab2 HS |
1232 | static int sge_qinfo_show(struct seq_file *seq, void *v) |
1233 | { | |
1234 | struct adapter *adap = seq->private; | |
1235 | int eth_entries = DIV_ROUND_UP(adap->sge.ethqsets, 4); | |
1236 | int toe_entries = DIV_ROUND_UP(adap->sge.ofldqsets, 4); | |
1237 | int rdma_entries = DIV_ROUND_UP(adap->sge.rdmaqs, 4); | |
1238 | int ciq_entries = DIV_ROUND_UP(adap->sge.rdmaciqs, 4); | |
1239 | int ctrl_entries = DIV_ROUND_UP(MAX_CTRL_QUEUES, 4); | |
1240 | int i, r = (uintptr_t)v - 1; | |
1241 | int toe_idx = r - eth_entries; | |
1242 | int rdma_idx = toe_idx - toe_entries; | |
1243 | int ciq_idx = rdma_idx - rdma_entries; | |
1244 | int ctrl_idx = ciq_idx - ciq_entries; | |
1245 | int fq_idx = ctrl_idx - ctrl_entries; | |
1246 | ||
1247 | if (r) | |
1248 | seq_putc(seq, '\n'); | |
1249 | ||
1250 | #define S3(fmt_spec, s, v) \ | |
1251 | do { \ | |
1252 | seq_printf(seq, "%-12s", s); \ | |
1253 | for (i = 0; i < n; ++i) \ | |
1254 | seq_printf(seq, " %16" fmt_spec, v); \ | |
1255 | seq_putc(seq, '\n'); \ | |
1256 | } while (0) | |
1257 | #define S(s, v) S3("s", s, v) | |
1258 | #define T(s, v) S3("u", s, tx[i].v) | |
1259 | #define R(s, v) S3("u", s, rx[i].v) | |
1260 | ||
1261 | if (r < eth_entries) { | |
1262 | int base_qset = r * 4; | |
1263 | const struct sge_eth_rxq *rx = &adap->sge.ethrxq[base_qset]; | |
1264 | const struct sge_eth_txq *tx = &adap->sge.ethtxq[base_qset]; | |
1265 | int n = min(4, adap->sge.ethqsets - 4 * r); | |
1266 | ||
1267 | S("QType:", "Ethernet"); | |
1268 | S("Interface:", | |
1269 | rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A"); | |
1270 | T("TxQ ID:", q.cntxt_id); | |
1271 | T("TxQ size:", q.size); | |
1272 | T("TxQ inuse:", q.in_use); | |
1273 | T("TxQ CIDX:", q.cidx); | |
1274 | T("TxQ PIDX:", q.pidx); | |
1275 | #ifdef CONFIG_CXGB4_DCB | |
1276 | T("DCB Prio:", dcb_prio); | |
1277 | S3("u", "DCB PGID:", | |
1278 | (ethqset2pinfo(adap, base_qset + i)->dcb.pgid >> | |
1279 | 4*(7-tx[i].dcb_prio)) & 0xf); | |
1280 | S3("u", "DCB PFC:", | |
1281 | (ethqset2pinfo(adap, base_qset + i)->dcb.pfcen >> | |
1282 | 1*(7-tx[i].dcb_prio)) & 0x1); | |
1283 | #endif | |
1284 | R("RspQ ID:", rspq.abs_id); | |
1285 | R("RspQ size:", rspq.size); | |
1286 | R("RspQE size:", rspq.iqe_len); | |
1287 | R("RspQ CIDX:", rspq.cidx); | |
1288 | R("RspQ Gen:", rspq.gen); | |
1289 | S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq)); | |
1290 | S3("u", "Intr pktcnt:", | |
1291 | adap->sge.counter_val[rx[i].rspq.pktcnt_idx]); | |
1292 | R("FL ID:", fl.cntxt_id); | |
1293 | R("FL size:", fl.size - 8); | |
1294 | R("FL pend:", fl.pend_cred); | |
1295 | R("FL avail:", fl.avail); | |
1296 | R("FL PIDX:", fl.pidx); | |
1297 | R("FL CIDX:", fl.cidx); | |
1298 | } else if (toe_idx < toe_entries) { | |
1299 | const struct sge_ofld_rxq *rx = &adap->sge.ofldrxq[toe_idx * 4]; | |
1300 | const struct sge_ofld_txq *tx = &adap->sge.ofldtxq[toe_idx * 4]; | |
1301 | int n = min(4, adap->sge.ofldqsets - 4 * toe_idx); | |
1302 | ||
1303 | S("QType:", "TOE"); | |
1304 | T("TxQ ID:", q.cntxt_id); | |
1305 | T("TxQ size:", q.size); | |
1306 | T("TxQ inuse:", q.in_use); | |
1307 | T("TxQ CIDX:", q.cidx); | |
1308 | T("TxQ PIDX:", q.pidx); | |
1309 | R("RspQ ID:", rspq.abs_id); | |
1310 | R("RspQ size:", rspq.size); | |
1311 | R("RspQE size:", rspq.iqe_len); | |
1312 | R("RspQ CIDX:", rspq.cidx); | |
1313 | R("RspQ Gen:", rspq.gen); | |
1314 | S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq)); | |
1315 | S3("u", "Intr pktcnt:", | |
1316 | adap->sge.counter_val[rx[i].rspq.pktcnt_idx]); | |
1317 | R("FL ID:", fl.cntxt_id); | |
1318 | R("FL size:", fl.size - 8); | |
1319 | R("FL pend:", fl.pend_cred); | |
1320 | R("FL avail:", fl.avail); | |
1321 | R("FL PIDX:", fl.pidx); | |
1322 | R("FL CIDX:", fl.cidx); | |
1323 | } else if (rdma_idx < rdma_entries) { | |
1324 | const struct sge_ofld_rxq *rx = | |
1325 | &adap->sge.rdmarxq[rdma_idx * 4]; | |
1326 | int n = min(4, adap->sge.rdmaqs - 4 * rdma_idx); | |
1327 | ||
1328 | S("QType:", "RDMA-CPL"); | |
1329 | R("RspQ ID:", rspq.abs_id); | |
1330 | R("RspQ size:", rspq.size); | |
1331 | R("RspQE size:", rspq.iqe_len); | |
1332 | R("RspQ CIDX:", rspq.cidx); | |
1333 | R("RspQ Gen:", rspq.gen); | |
1334 | S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq)); | |
1335 | S3("u", "Intr pktcnt:", | |
1336 | adap->sge.counter_val[rx[i].rspq.pktcnt_idx]); | |
1337 | R("FL ID:", fl.cntxt_id); | |
1338 | R("FL size:", fl.size - 8); | |
1339 | R("FL pend:", fl.pend_cred); | |
1340 | R("FL avail:", fl.avail); | |
1341 | R("FL PIDX:", fl.pidx); | |
1342 | R("FL CIDX:", fl.cidx); | |
1343 | } else if (ciq_idx < ciq_entries) { | |
1344 | const struct sge_ofld_rxq *rx = &adap->sge.rdmaciq[ciq_idx * 4]; | |
1345 | int n = min(4, adap->sge.rdmaciqs - 4 * ciq_idx); | |
1346 | ||
1347 | S("QType:", "RDMA-CIQ"); | |
1348 | R("RspQ ID:", rspq.abs_id); | |
1349 | R("RspQ size:", rspq.size); | |
1350 | R("RspQE size:", rspq.iqe_len); | |
1351 | R("RspQ CIDX:", rspq.cidx); | |
1352 | R("RspQ Gen:", rspq.gen); | |
1353 | S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq)); | |
1354 | S3("u", "Intr pktcnt:", | |
1355 | adap->sge.counter_val[rx[i].rspq.pktcnt_idx]); | |
1356 | } else if (ctrl_idx < ctrl_entries) { | |
1357 | const struct sge_ctrl_txq *tx = &adap->sge.ctrlq[ctrl_idx * 4]; | |
1358 | int n = min(4, adap->params.nports - 4 * ctrl_idx); | |
1359 | ||
1360 | S("QType:", "Control"); | |
1361 | T("TxQ ID:", q.cntxt_id); | |
1362 | T("TxQ size:", q.size); | |
1363 | T("TxQ inuse:", q.in_use); | |
1364 | T("TxQ CIDX:", q.cidx); | |
1365 | T("TxQ PIDX:", q.pidx); | |
1366 | } else if (fq_idx == 0) { | |
1367 | const struct sge_rspq *evtq = &adap->sge.fw_evtq; | |
1368 | ||
1369 | seq_printf(seq, "%-12s %16s\n", "QType:", "FW event queue"); | |
1370 | seq_printf(seq, "%-12s %16u\n", "RspQ ID:", evtq->abs_id); | |
1371 | seq_printf(seq, "%-12s %16u\n", "RspQ size:", evtq->size); | |
1372 | seq_printf(seq, "%-12s %16u\n", "RspQE size:", evtq->iqe_len); | |
1373 | seq_printf(seq, "%-12s %16u\n", "RspQ CIDX:", evtq->cidx); | |
1374 | seq_printf(seq, "%-12s %16u\n", "RspQ Gen:", evtq->gen); | |
1375 | seq_printf(seq, "%-12s %16u\n", "Intr delay:", | |
1376 | qtimer_val(adap, evtq)); | |
1377 | seq_printf(seq, "%-12s %16u\n", "Intr pktcnt:", | |
1378 | adap->sge.counter_val[evtq->pktcnt_idx]); | |
1379 | } | |
1380 | #undef R | |
1381 | #undef T | |
1382 | #undef S | |
1383 | #undef S3 | |
1384 | return 0; | |
1385 | } | |
1386 | ||
1387 | static int sge_queue_entries(const struct adapter *adap) | |
1388 | { | |
1389 | return DIV_ROUND_UP(adap->sge.ethqsets, 4) + | |
1390 | DIV_ROUND_UP(adap->sge.ofldqsets, 4) + | |
1391 | DIV_ROUND_UP(adap->sge.rdmaqs, 4) + | |
1392 | DIV_ROUND_UP(adap->sge.rdmaciqs, 4) + | |
1393 | DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1; | |
1394 | } | |
1395 | ||
1396 | static void *sge_queue_start(struct seq_file *seq, loff_t *pos) | |
1397 | { | |
1398 | int entries = sge_queue_entries(seq->private); | |
1399 | ||
1400 | return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL; | |
1401 | } | |
1402 | ||
1403 | static void sge_queue_stop(struct seq_file *seq, void *v) | |
1404 | { | |
1405 | } | |
1406 | ||
1407 | static void *sge_queue_next(struct seq_file *seq, void *v, loff_t *pos) | |
1408 | { | |
1409 | int entries = sge_queue_entries(seq->private); | |
1410 | ||
1411 | ++*pos; | |
1412 | return *pos < entries ? (void *)((uintptr_t)*pos + 1) : NULL; | |
1413 | } | |
1414 | ||
1415 | static const struct seq_operations sge_qinfo_seq_ops = { | |
1416 | .start = sge_queue_start, | |
1417 | .next = sge_queue_next, | |
1418 | .stop = sge_queue_stop, | |
1419 | .show = sge_qinfo_show | |
1420 | }; | |
1421 | ||
1422 | static int sge_qinfo_open(struct inode *inode, struct file *file) | |
1423 | { | |
1424 | int res = seq_open(file, &sge_qinfo_seq_ops); | |
1425 | ||
1426 | if (!res) { | |
1427 | struct seq_file *seq = file->private_data; | |
1428 | ||
1429 | seq->private = inode->i_private; | |
1430 | } | |
1431 | return res; | |
1432 | } | |
1433 | ||
1434 | static const struct file_operations sge_qinfo_debugfs_fops = { | |
1435 | .owner = THIS_MODULE, | |
1436 | .open = sge_qinfo_open, | |
1437 | .read = seq_read, | |
1438 | .llseek = seq_lseek, | |
1439 | .release = seq_release, | |
1440 | }; | |
1441 | ||
49216c1c HS |
1442 | int mem_open(struct inode *inode, struct file *file) |
1443 | { | |
1444 | unsigned int mem; | |
1445 | struct adapter *adap; | |
1446 | ||
1447 | file->private_data = inode->i_private; | |
1448 | ||
1449 | mem = (uintptr_t)file->private_data & 0x3; | |
1450 | adap = file->private_data - mem; | |
1451 | ||
1452 | (void)t4_fwcache(adap, FW_PARAM_DEV_FWCACHE_FLUSH); | |
1453 | ||
1454 | return 0; | |
1455 | } | |
1456 | ||
fd88b31a HS |
1457 | static ssize_t mem_read(struct file *file, char __user *buf, size_t count, |
1458 | loff_t *ppos) | |
1459 | { | |
1460 | loff_t pos = *ppos; | |
1461 | loff_t avail = file_inode(file)->i_size; | |
1462 | unsigned int mem = (uintptr_t)file->private_data & 3; | |
1463 | struct adapter *adap = file->private_data - mem; | |
1464 | __be32 *data; | |
1465 | int ret; | |
1466 | ||
1467 | if (pos < 0) | |
1468 | return -EINVAL; | |
1469 | if (pos >= avail) | |
1470 | return 0; | |
1471 | if (count > avail - pos) | |
1472 | count = avail - pos; | |
1473 | ||
1474 | data = t4_alloc_mem(count); | |
1475 | if (!data) | |
1476 | return -ENOMEM; | |
1477 | ||
1478 | spin_lock(&adap->win0_lock); | |
1479 | ret = t4_memory_rw(adap, 0, mem, pos, count, data, T4_MEMORY_READ); | |
1480 | spin_unlock(&adap->win0_lock); | |
1481 | if (ret) { | |
1482 | t4_free_mem(data); | |
1483 | return ret; | |
1484 | } | |
1485 | ret = copy_to_user(buf, data, count); | |
1486 | ||
1487 | t4_free_mem(data); | |
1488 | if (ret) | |
1489 | return -EFAULT; | |
1490 | ||
1491 | *ppos = pos + count; | |
1492 | return count; | |
1493 | } | |
fd88b31a HS |
1494 | static const struct file_operations mem_debugfs_fops = { |
1495 | .owner = THIS_MODULE, | |
1496 | .open = simple_open, | |
1497 | .read = mem_read, | |
1498 | .llseek = default_llseek, | |
1499 | }; | |
1500 | ||
49216c1c HS |
1501 | static void set_debugfs_file_size(struct dentry *de, loff_t size) |
1502 | { | |
1503 | if (!IS_ERR(de) && de->d_inode) | |
1504 | de->d_inode->i_size = size; | |
1505 | } | |
1506 | ||
fd88b31a HS |
1507 | static void add_debugfs_mem(struct adapter *adap, const char *name, |
1508 | unsigned int idx, unsigned int size_mb) | |
1509 | { | |
1510 | struct dentry *de; | |
1511 | ||
1512 | de = debugfs_create_file(name, S_IRUSR, adap->debugfs_root, | |
1513 | (void *)adap + idx, &mem_debugfs_fops); | |
1514 | if (de && de->d_inode) | |
1515 | de->d_inode->i_size = size_mb << 20; | |
1516 | } | |
1517 | ||
1518 | /* Add an array of Debug FS files. | |
1519 | */ | |
1520 | void add_debugfs_files(struct adapter *adap, | |
1521 | struct t4_debugfs_entry *files, | |
1522 | unsigned int nfiles) | |
1523 | { | |
1524 | int i; | |
1525 | ||
1526 | /* debugfs support is best effort */ | |
1527 | for (i = 0; i < nfiles; i++) | |
1528 | debugfs_create_file(files[i].name, files[i].mode, | |
1529 | adap->debugfs_root, | |
1530 | (void *)adap + files[i].data, | |
1531 | files[i].ops); | |
1532 | } | |
1533 | ||
1534 | int t4_setup_debugfs(struct adapter *adap) | |
1535 | { | |
1536 | int i; | |
1537 | u32 size; | |
49216c1c | 1538 | struct dentry *de; |
fd88b31a HS |
1539 | |
1540 | static struct t4_debugfs_entry t4_debugfs_files[] = { | |
f1ff24aa | 1541 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, |
74b3092c | 1542 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, |
b58b6676 | 1543 | { "clk", &clk_debugfs_fops, S_IRUSR, 0 }, |
49aa284f | 1544 | { "devlog", &devlog_fops, S_IRUSR, 0 }, |
fd88b31a | 1545 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, |
ef82f662 | 1546 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, |
688ea5fe HS |
1547 | { "rss", &rss_debugfs_fops, S_IRUSR, 0 }, |
1548 | { "rss_config", &rss_config_debugfs_fops, S_IRUSR, 0 }, | |
1549 | { "rss_key", &rss_key_debugfs_fops, S_IRUSR, 0 }, | |
1550 | { "rss_pf_config", &rss_pf_config_debugfs_fops, S_IRUSR, 0 }, | |
1551 | { "rss_vf_config", &rss_vf_config_debugfs_fops, S_IRUSR, 0 }, | |
dc9daab2 | 1552 | { "sge_qinfo", &sge_qinfo_debugfs_fops, S_IRUSR, 0 }, |
e5f0e43b HS |
1553 | { "ibq_tp0", &cim_ibq_fops, S_IRUSR, 0 }, |
1554 | { "ibq_tp1", &cim_ibq_fops, S_IRUSR, 1 }, | |
1555 | { "ibq_ulp", &cim_ibq_fops, S_IRUSR, 2 }, | |
1556 | { "ibq_sge0", &cim_ibq_fops, S_IRUSR, 3 }, | |
1557 | { "ibq_sge1", &cim_ibq_fops, S_IRUSR, 4 }, | |
1558 | { "ibq_ncsi", &cim_ibq_fops, S_IRUSR, 5 }, | |
c778af7d HS |
1559 | { "obq_ulp0", &cim_obq_fops, S_IRUSR, 0 }, |
1560 | { "obq_ulp1", &cim_obq_fops, S_IRUSR, 1 }, | |
1561 | { "obq_ulp2", &cim_obq_fops, S_IRUSR, 2 }, | |
1562 | { "obq_ulp3", &cim_obq_fops, S_IRUSR, 3 }, | |
1563 | { "obq_sge", &cim_obq_fops, S_IRUSR, 4 }, | |
1564 | { "obq_ncsi", &cim_obq_fops, S_IRUSR, 5 }, | |
b3bbe36a | 1565 | { "pm_stats", &pm_stats_debugfs_fops, S_IRUSR, 0 }, |
b5a02f50 AB |
1566 | #if IS_ENABLED(CONFIG_IPV6) |
1567 | { "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 }, | |
1568 | #endif | |
fd88b31a HS |
1569 | }; |
1570 | ||
c778af7d HS |
1571 | /* Debug FS nodes common to all T5 and later adapters. |
1572 | */ | |
1573 | static struct t4_debugfs_entry t5_debugfs_files[] = { | |
1574 | { "obq_sge_rx_q0", &cim_obq_fops, S_IRUSR, 6 }, | |
1575 | { "obq_sge_rx_q1", &cim_obq_fops, S_IRUSR, 7 }, | |
1576 | }; | |
1577 | ||
fd88b31a HS |
1578 | add_debugfs_files(adap, |
1579 | t4_debugfs_files, | |
1580 | ARRAY_SIZE(t4_debugfs_files)); | |
c778af7d HS |
1581 | if (!is_t4(adap->params.chip)) |
1582 | add_debugfs_files(adap, | |
1583 | t5_debugfs_files, | |
1584 | ARRAY_SIZE(t5_debugfs_files)); | |
fd88b31a | 1585 | |
6559a7e8 HS |
1586 | i = t4_read_reg(adap, MA_TARGET_MEM_ENABLE_A); |
1587 | if (i & EDRAM0_ENABLE_F) { | |
1588 | size = t4_read_reg(adap, MA_EDRAM0_BAR_A); | |
1589 | add_debugfs_mem(adap, "edc0", MEM_EDC0, EDRAM0_SIZE_G(size)); | |
fd88b31a | 1590 | } |
6559a7e8 HS |
1591 | if (i & EDRAM1_ENABLE_F) { |
1592 | size = t4_read_reg(adap, MA_EDRAM1_BAR_A); | |
1593 | add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM1_SIZE_G(size)); | |
fd88b31a HS |
1594 | } |
1595 | if (is_t4(adap->params.chip)) { | |
6559a7e8 HS |
1596 | size = t4_read_reg(adap, MA_EXT_MEMORY_BAR_A); |
1597 | if (i & EXT_MEM_ENABLE_F) | |
fd88b31a | 1598 | add_debugfs_mem(adap, "mc", MEM_MC, |
6559a7e8 | 1599 | EXT_MEM_SIZE_G(size)); |
fd88b31a | 1600 | } else { |
6559a7e8 HS |
1601 | if (i & EXT_MEM0_ENABLE_F) { |
1602 | size = t4_read_reg(adap, MA_EXT_MEMORY0_BAR_A); | |
fd88b31a | 1603 | add_debugfs_mem(adap, "mc0", MEM_MC0, |
6559a7e8 | 1604 | EXT_MEM0_SIZE_G(size)); |
fd88b31a | 1605 | } |
6559a7e8 HS |
1606 | if (i & EXT_MEM1_ENABLE_F) { |
1607 | size = t4_read_reg(adap, MA_EXT_MEMORY1_BAR_A); | |
fd88b31a | 1608 | add_debugfs_mem(adap, "mc1", MEM_MC1, |
6559a7e8 | 1609 | EXT_MEM1_SIZE_G(size)); |
fd88b31a HS |
1610 | } |
1611 | } | |
49216c1c HS |
1612 | |
1613 | de = debugfs_create_file("flash", S_IRUSR, adap->debugfs_root, adap, | |
1614 | &flash_debugfs_fops); | |
1615 | set_debugfs_file_size(de, adap->params.sf_size); | |
1616 | ||
fd88b31a HS |
1617 | return 0; |
1618 | } |