diff options
| author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-01-27 03:17:48 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-01-27 03:15:02 -0500 |
| commit | b3bbe36a26d056cc0b64bb2ee72c9e34c4e8683a (patch) | |
| tree | 345490f4557ddf5aecfc38cbc753b0e8ade93c4c | |
| parent | c778af7d18646247310b7bceaf3eacc6eeee1614 (diff) | |
cxgb4: Added support in debugfs to dump PM module stats
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.h | 2 | ||||
| -rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | 66 | ||||
| -rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 54 | ||||
| -rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_hw.h | 1 | ||||
| -rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 12 |
5 files changed, 135 insertions, 0 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index da94b9a2f347..d98a44637896 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | |||
| @@ -1054,6 +1054,8 @@ int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, | |||
| 1054 | u64 *parity); | 1054 | u64 *parity); |
| 1055 | int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, | 1055 | int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, |
| 1056 | u64 *parity); | 1056 | u64 *parity); |
| 1057 | void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]); | ||
| 1058 | void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]); | ||
| 1057 | int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data, | 1059 | int t4_read_cim_ibq(struct adapter *adap, unsigned int qid, u32 *data, |
| 1058 | size_t n); | 1060 | size_t n); |
| 1059 | int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data, | 1061 | int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data, |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 4619bb3ff990..df90c78fb6cc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
| @@ -315,6 +315,71 @@ static const struct file_operations cim_obq_fops = { | |||
| 315 | .release = seq_release_private | 315 | .release = seq_release_private |
| 316 | }; | 316 | }; |
| 317 | 317 | ||
| 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 | |||
| 318 | /* Firmware Device Log dump. */ | 383 | /* Firmware Device Log dump. */ |
| 319 | static const char * const devlog_level_strings[] = { | 384 | static const char * const devlog_level_strings[] = { |
| 320 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", | 385 | [FW_DEVLOG_LEVEL_EMERG] = "EMERG", |
| @@ -1434,6 +1499,7 @@ int t4_setup_debugfs(struct adapter *adap) | |||
| 1434 | { "obq_ulp3", &cim_obq_fops, S_IRUSR, 3 }, | 1499 | { "obq_ulp3", &cim_obq_fops, S_IRUSR, 3 }, |
| 1435 | { "obq_sge", &cim_obq_fops, S_IRUSR, 4 }, | 1500 | { "obq_sge", &cim_obq_fops, S_IRUSR, 4 }, |
| 1436 | { "obq_ncsi", &cim_obq_fops, S_IRUSR, 5 }, | 1501 | { "obq_ncsi", &cim_obq_fops, S_IRUSR, 5 }, |
| 1502 | { "pm_stats", &pm_stats_debugfs_fops, S_IRUSR, 0 }, | ||
| 1437 | #if IS_ENABLED(CONFIG_IPV6) | 1503 | #if IS_ENABLED(CONFIG_IPV6) |
| 1438 | { "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 }, | 1504 | { "clip_tbl", &clip_tbl_debugfs_fops, S_IRUSR, 0 }, |
| 1439 | #endif | 1505 | #endif |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index a3d2f31439c4..ea16c623e8b2 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | |||
| @@ -2512,6 +2512,60 @@ void t4_load_mtus(struct adapter *adap, const unsigned short *mtus, | |||
| 2512 | } | 2512 | } |
| 2513 | 2513 | ||
| 2514 | /** | 2514 | /** |
| 2515 | * t4_pmtx_get_stats - returns the HW stats from PMTX | ||
| 2516 | * @adap: the adapter | ||
| 2517 | * @cnt: where to store the count statistics | ||
| 2518 | * @cycles: where to store the cycle statistics | ||
| 2519 | * | ||
| 2520 | * Returns performance statistics from PMTX. | ||
| 2521 | */ | ||
| 2522 | void t4_pmtx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]) | ||
| 2523 | { | ||
| 2524 | int i; | ||
| 2525 | u32 data[2]; | ||
| 2526 | |||
| 2527 | for (i = 0; i < PM_NSTATS; i++) { | ||
| 2528 | t4_write_reg(adap, PM_TX_STAT_CONFIG_A, i + 1); | ||
| 2529 | cnt[i] = t4_read_reg(adap, PM_TX_STAT_COUNT_A); | ||
| 2530 | if (is_t4(adap->params.chip)) { | ||
| 2531 | cycles[i] = t4_read_reg64(adap, PM_TX_STAT_LSB_A); | ||
| 2532 | } else { | ||
| 2533 | t4_read_indirect(adap, PM_TX_DBG_CTRL_A, | ||
| 2534 | PM_TX_DBG_DATA_A, data, 2, | ||
| 2535 | PM_TX_DBG_STAT_MSB_A); | ||
| 2536 | cycles[i] = (((u64)data[0] << 32) | data[1]); | ||
| 2537 | } | ||
| 2538 | } | ||
| 2539 | } | ||
| 2540 | |||
| 2541 | /** | ||
| 2542 | * t4_pmrx_get_stats - returns the HW stats from PMRX | ||
| 2543 | * @adap: the adapter | ||
| 2544 | * @cnt: where to store the count statistics | ||
| 2545 | * @cycles: where to store the cycle statistics | ||
| 2546 | * | ||
| 2547 | * Returns performance statistics from PMRX. | ||
| 2548 | */ | ||
| 2549 | void t4_pmrx_get_stats(struct adapter *adap, u32 cnt[], u64 cycles[]) | ||
| 2550 | { | ||
| 2551 | int i; | ||
| 2552 | u32 data[2]; | ||
| 2553 | |||
| 2554 | for (i = 0; i < PM_NSTATS; i++) { | ||
| 2555 | t4_write_reg(adap, PM_RX_STAT_CONFIG_A, i + 1); | ||
| 2556 | cnt[i] = t4_read_reg(adap, PM_RX_STAT_COUNT_A); | ||
| 2557 | if (is_t4(adap->params.chip)) { | ||
| 2558 | cycles[i] = t4_read_reg64(adap, PM_RX_STAT_LSB_A); | ||
| 2559 | } else { | ||
| 2560 | t4_read_indirect(adap, PM_RX_DBG_CTRL_A, | ||
| 2561 | PM_RX_DBG_DATA_A, data, 2, | ||
| 2562 | PM_RX_DBG_STAT_MSB_A); | ||
| 2563 | cycles[i] = (((u64)data[0] << 32) | data[1]); | ||
| 2564 | } | ||
| 2565 | } | ||
| 2566 | } | ||
| 2567 | |||
| 2568 | /** | ||
| 2515 | * get_mps_bg_map - return the buffer groups associated with a port | 2569 | * get_mps_bg_map - return the buffer groups associated with a port |
| 2516 | * @adap: the adapter | 2570 | * @adap: the adapter |
| 2517 | * @idx: the port index | 2571 | * @idx: the port index |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h index f9fb81e4826e..664375f290ee 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h | |||
| @@ -48,6 +48,7 @@ enum { | |||
| 48 | NMTUS = 16, /* size of MTU table */ | 48 | NMTUS = 16, /* size of MTU table */ |
| 49 | NCCTRL_WIN = 32, /* # of congestion control windows */ | 49 | NCCTRL_WIN = 32, /* # of congestion control windows */ |
| 50 | L2T_SIZE = 4096, /* # of L2T entries */ | 50 | L2T_SIZE = 4096, /* # of L2T entries */ |
| 51 | PM_NSTATS = 5, /* # of PM stats */ | ||
| 51 | MBOX_LEN = 64, /* mailbox size in bytes */ | 52 | MBOX_LEN = 64, /* mailbox size in bytes */ |
| 52 | TRACE_LEN = 112, /* length of trace data and mask */ | 53 | TRACE_LEN = 112, /* length of trace data and mask */ |
| 53 | FILTER_OPT_LEN = 36, /* filter tuple width for optional components */ | 54 | FILTER_OPT_LEN = 36, /* filter tuple width for optional components */ |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h index 1b1560acde2e..7aa0db137df6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | |||
| @@ -1380,6 +1380,12 @@ | |||
| 1380 | #define PBL_BOUND_ERR_CH0_F PBL_BOUND_ERR_CH0_V(1U) | 1380 | #define PBL_BOUND_ERR_CH0_F PBL_BOUND_ERR_CH0_V(1U) |
| 1381 | 1381 | ||
| 1382 | #define PM_RX_INT_CAUSE_A 0x8fdc | 1382 | #define PM_RX_INT_CAUSE_A 0x8fdc |
| 1383 | #define PM_RX_STAT_CONFIG_A 0x8fc8 | ||
| 1384 | #define PM_RX_STAT_COUNT_A 0x8fcc | ||
| 1385 | #define PM_RX_STAT_LSB_A 0x8fd0 | ||
| 1386 | #define PM_RX_DBG_CTRL_A 0x8fd0 | ||
| 1387 | #define PM_RX_DBG_DATA_A 0x8fd4 | ||
| 1388 | #define PM_RX_DBG_STAT_MSB_A 0x10013 | ||
| 1383 | 1389 | ||
| 1384 | #define PMRX_FRAMING_ERROR_F 0x003ffff0U | 1390 | #define PMRX_FRAMING_ERROR_F 0x003ffff0U |
| 1385 | 1391 | ||
| @@ -1404,6 +1410,12 @@ | |||
| 1404 | #define PMRX_E_PCMD_PAR_ERROR_F PMRX_E_PCMD_PAR_ERROR_V(1U) | 1410 | #define PMRX_E_PCMD_PAR_ERROR_F PMRX_E_PCMD_PAR_ERROR_V(1U) |
| 1405 | 1411 | ||
| 1406 | #define PM_TX_INT_CAUSE_A 0x8ffc | 1412 | #define PM_TX_INT_CAUSE_A 0x8ffc |
| 1413 | #define PM_TX_STAT_CONFIG_A 0x8fe8 | ||
| 1414 | #define PM_TX_STAT_COUNT_A 0x8fec | ||
| 1415 | #define PM_TX_STAT_LSB_A 0x8ff0 | ||
| 1416 | #define PM_TX_DBG_CTRL_A 0x8ff0 | ||
| 1417 | #define PM_TX_DBG_DATA_A 0x8ff4 | ||
| 1418 | #define PM_TX_DBG_STAT_MSB_A 0x1001a | ||
| 1407 | 1419 | ||
| 1408 | #define PCMD_LEN_OVFL0_S 31 | 1420 | #define PCMD_LEN_OVFL0_S 31 |
| 1409 | #define PCMD_LEN_OVFL0_V(x) ((x) << PCMD_LEN_OVFL0_S) | 1421 | #define PCMD_LEN_OVFL0_V(x) ((x) << PCMD_LEN_OVFL0_S) |
