diff options
author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-01-27 03:17:49 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-27 03:15:02 -0500 |
commit | b58b667687b71e1f07190ba5faa66e80013eaac6 (patch) | |
tree | 942f6246951b450195861964c2b7bdfe4a71db8d | |
parent | b3bbe36a26d056cc0b64bb2ee72c9e34c4e8683a (diff) |
cxgb4: Added support in debugfs to dump different timer and clock values of the adapter
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 63 | ||||
-rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 23 |
2 files changed, 86 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index df90c78fb6cc..47c0869f34ca 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
@@ -380,6 +380,68 @@ static const struct file_operations pm_stats_debugfs_fops = { | |||
380 | .write = pm_stats_clear | 380 | .write = pm_stats_clear |
381 | }; | 381 | }; |
382 | 382 | ||
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 | |||
383 | /* Firmware Device Log dump. */ | 445 | /* Firmware Device Log dump. */ |
384 | static const char * const devlog_level_strings[] = { | 446 | static const char * const devlog_level_strings[] = { |
385 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", | 447 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", |
@@ -1478,6 +1540,7 @@ int t4_setup_debugfs(struct adapter *adap) | |||
1478 | static struct t4_debugfs_entry t4_debugfs_files[] = { | 1540 | static struct t4_debugfs_entry t4_debugfs_files[] = { |
1479 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, | 1541 | { "cim_la", &cim_la_fops, S_IRUSR, 0 }, |
1480 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, | 1542 | { "cim_qcfg", &cim_qcfg_fops, S_IRUSR, 0 }, |
1543 | { "clk", &clk_debugfs_fops, S_IRUSR, 0 }, | ||
1481 | { "devlog", &devlog_fops, S_IRUSR, 0 }, | 1544 | { "devlog", &devlog_fops, S_IRUSR, 0 }, |
1482 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, | 1545 | { "l2t", &t4_l2t_fops, S_IRUSR, 0}, |
1483 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, | 1546 | { "mps_tcam", &mps_tcam_debugfs_fops, S_IRUSR, 0 }, |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h index 7aa0db137df6..940b56cd5caa 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | |||
@@ -1203,12 +1203,35 @@ | |||
1203 | #define TIMERRESOLUTION_M 0xffU | 1203 | #define TIMERRESOLUTION_M 0xffU |
1204 | #define TIMERRESOLUTION_G(x) (((x) >> TIMERRESOLUTION_S) & TIMERRESOLUTION_M) | 1204 | #define TIMERRESOLUTION_G(x) (((x) >> TIMERRESOLUTION_S) & TIMERRESOLUTION_M) |
1205 | 1205 | ||
1206 | #define TIMESTAMPRESOLUTION_S 8 | ||
1207 | #define TIMESTAMPRESOLUTION_M 0xffU | ||
1208 | #define TIMESTAMPRESOLUTION_G(x) \ | ||
1209 | (((x) >> TIMESTAMPRESOLUTION_S) & TIMESTAMPRESOLUTION_M) | ||
1210 | |||
1206 | #define DELAYEDACKRESOLUTION_S 0 | 1211 | #define DELAYEDACKRESOLUTION_S 0 |
1207 | #define DELAYEDACKRESOLUTION_M 0xffU | 1212 | #define DELAYEDACKRESOLUTION_M 0xffU |
1208 | #define DELAYEDACKRESOLUTION_G(x) \ | 1213 | #define DELAYEDACKRESOLUTION_G(x) \ |
1209 | (((x) >> DELAYEDACKRESOLUTION_S) & DELAYEDACKRESOLUTION_M) | 1214 | (((x) >> DELAYEDACKRESOLUTION_S) & DELAYEDACKRESOLUTION_M) |
1210 | 1215 | ||
1211 | #define TP_SHIFT_CNT_A 0x7dc0 | 1216 | #define TP_SHIFT_CNT_A 0x7dc0 |
1217 | #define TP_RXT_MIN_A 0x7d98 | ||
1218 | #define TP_RXT_MAX_A 0x7d9c | ||
1219 | #define TP_PERS_MIN_A 0x7da0 | ||
1220 | #define TP_PERS_MAX_A 0x7da4 | ||
1221 | #define TP_KEEP_IDLE_A 0x7da8 | ||
1222 | #define TP_KEEP_INTVL_A 0x7dac | ||
1223 | #define TP_INIT_SRTT_A 0x7db0 | ||
1224 | #define TP_DACK_TIMER_A 0x7db4 | ||
1225 | #define TP_FINWAIT2_TIMER_A 0x7db8 | ||
1226 | |||
1227 | #define INITSRTT_S 0 | ||
1228 | #define INITSRTT_M 0xffffU | ||
1229 | #define INITSRTT_G(x) (((x) >> INITSRTT_S) & INITSRTT_M) | ||
1230 | |||
1231 | #define PERSMAX_S 0 | ||
1232 | #define PERSMAX_M 0x3fffffffU | ||
1233 | #define PERSMAX_V(x) ((x) << PERSMAX_S) | ||
1234 | #define PERSMAX_G(x) (((x) >> PERSMAX_S) & PERSMAX_M) | ||
1212 | 1235 | ||
1213 | #define SYNSHIFTMAX_S 24 | 1236 | #define SYNSHIFTMAX_S 24 |
1214 | #define SYNSHIFTMAX_M 0xffU | 1237 | #define SYNSHIFTMAX_M 0xffU |