diff options
author | Jon Mason <jon.mason@intel.com> | 2014-04-07 13:55:47 -0400 |
---|---|---|
committer | Jon Mason <jdmason@kudzu.us> | 2014-10-17 07:08:50 -0400 |
commit | 6465d02ee15f7a45339b7e7859d0a0f22100ca87 (patch) | |
tree | b0554823791bb6b366734c16d241783d6ecf3149 | |
parent | bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9 (diff) |
NTB: debugfs device entry
Create a debugfs entry for the NTB device to log the basic device info,
as well as display the error count on a number of registers.
Signed-off-by: Jon Mason <jon.mason@intel.com>
-rw-r--r-- | drivers/ntb/ntb_hw.c | 101 | ||||
-rw-r--r-- | drivers/ntb/ntb_hw.h | 1 | ||||
-rw-r--r-- | drivers/ntb/ntb_regs.h | 7 |
3 files changed, 107 insertions, 2 deletions
diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c index 372e08c4ffef..a3990363a171 100644 --- a/drivers/ntb/ntb_hw.c +++ b/drivers/ntb/ntb_hw.c | |||
@@ -1344,6 +1344,101 @@ static void ntb_free_callbacks(struct ntb_device *ndev) | |||
1344 | kfree(ndev->db_cb); | 1344 | kfree(ndev->db_cb); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | static ssize_t ntb_debugfs_read(struct file *filp, char __user *ubuf, | ||
1348 | size_t count, loff_t *offp) | ||
1349 | { | ||
1350 | struct ntb_device *ndev; | ||
1351 | char *buf; | ||
1352 | ssize_t ret, offset, out_count; | ||
1353 | |||
1354 | out_count = 500; | ||
1355 | |||
1356 | buf = kmalloc(out_count, GFP_KERNEL); | ||
1357 | if (!buf) | ||
1358 | return -ENOMEM; | ||
1359 | |||
1360 | ndev = filp->private_data; | ||
1361 | offset = 0; | ||
1362 | offset += snprintf(buf + offset, out_count - offset, | ||
1363 | "NTB Device Information:\n"); | ||
1364 | offset += snprintf(buf + offset, out_count - offset, | ||
1365 | "Connection Type - \t\t%s\n", | ||
1366 | ndev->conn_type == NTB_CONN_TRANSPARENT ? | ||
1367 | "Transparent" : (ndev->conn_type == NTB_CONN_B2B) ? | ||
1368 | "Back to back" : "Root Port"); | ||
1369 | offset += snprintf(buf + offset, out_count - offset, | ||
1370 | "Device Type - \t\t\t%s\n", | ||
1371 | ndev->dev_type == NTB_DEV_USD ? | ||
1372 | "DSD/USP" : "USD/DSP"); | ||
1373 | offset += snprintf(buf + offset, out_count - offset, | ||
1374 | "Max Number of Callbacks - \t%u\n", | ||
1375 | ntb_max_cbs(ndev)); | ||
1376 | offset += snprintf(buf + offset, out_count - offset, | ||
1377 | "Link Status - \t\t\t%s\n", | ||
1378 | ntb_hw_link_status(ndev) ? "Up" : "Down"); | ||
1379 | if (ntb_hw_link_status(ndev)) { | ||
1380 | offset += snprintf(buf + offset, out_count - offset, | ||
1381 | "Link Speed - \t\t\tPCI-E Gen %u\n", | ||
1382 | ndev->link_speed); | ||
1383 | offset += snprintf(buf + offset, out_count - offset, | ||
1384 | "Link Width - \t\t\tx%u\n", | ||
1385 | ndev->link_width); | ||
1386 | } | ||
1387 | |||
1388 | if (ndev->hw_type != BWD_HW) { | ||
1389 | u32 status32; | ||
1390 | u16 status16; | ||
1391 | int rc; | ||
1392 | |||
1393 | offset += snprintf(buf + offset, out_count - offset, | ||
1394 | "\nNTB Device Statistics:\n"); | ||
1395 | offset += snprintf(buf + offset, out_count - offset, | ||
1396 | "Upstream Memory Miss - \t%u\n", | ||
1397 | readw(ndev->reg_base + | ||
1398 | SNB_USMEMMISS_OFFSET)); | ||
1399 | |||
1400 | offset += snprintf(buf + offset, out_count - offset, | ||
1401 | "\nNTB Hardware Errors:\n"); | ||
1402 | |||
1403 | rc = pci_read_config_word(ndev->pdev, SNB_DEVSTS_OFFSET, | ||
1404 | &status16); | ||
1405 | if (!rc) | ||
1406 | offset += snprintf(buf + offset, out_count - offset, | ||
1407 | "DEVSTS - \t%#06x\n", status16); | ||
1408 | |||
1409 | rc = pci_read_config_word(ndev->pdev, SNB_LINK_STATUS_OFFSET, | ||
1410 | &status16); | ||
1411 | if (!rc) | ||
1412 | offset += snprintf(buf + offset, out_count - offset, | ||
1413 | "LNKSTS - \t%#06x\n", status16); | ||
1414 | |||
1415 | rc = pci_read_config_dword(ndev->pdev, SNB_UNCERRSTS_OFFSET, | ||
1416 | &status32); | ||
1417 | if (!rc) | ||
1418 | offset += snprintf(buf + offset, out_count - offset, | ||
1419 | "UNCERRSTS - \t%#010x\n", status32); | ||
1420 | |||
1421 | rc = pci_read_config_dword(ndev->pdev, SNB_CORERRSTS_OFFSET, | ||
1422 | &status32); | ||
1423 | if (!rc) | ||
1424 | offset += snprintf(buf + offset, out_count - offset, | ||
1425 | "CORERRSTS - \t%#010x\n", status32); | ||
1426 | } | ||
1427 | |||
1428 | if (offset > out_count) | ||
1429 | offset = out_count; | ||
1430 | |||
1431 | ret = simple_read_from_buffer(ubuf, count, offp, buf, offset); | ||
1432 | kfree(buf); | ||
1433 | return ret; | ||
1434 | } | ||
1435 | |||
1436 | static const struct file_operations ntb_debugfs_info = { | ||
1437 | .owner = THIS_MODULE, | ||
1438 | .open = simple_open, | ||
1439 | .read = ntb_debugfs_read, | ||
1440 | }; | ||
1441 | |||
1347 | static void ntb_setup_debugfs(struct ntb_device *ndev) | 1442 | static void ntb_setup_debugfs(struct ntb_device *ndev) |
1348 | { | 1443 | { |
1349 | if (!debugfs_initialized()) | 1444 | if (!debugfs_initialized()) |
@@ -1354,6 +1449,11 @@ static void ntb_setup_debugfs(struct ntb_device *ndev) | |||
1354 | 1449 | ||
1355 | ndev->debugfs_dir = debugfs_create_dir(pci_name(ndev->pdev), | 1450 | ndev->debugfs_dir = debugfs_create_dir(pci_name(ndev->pdev), |
1356 | debugfs_dir); | 1451 | debugfs_dir); |
1452 | if (ndev->debugfs_dir) | ||
1453 | ndev->debugfs_info = debugfs_create_file("info", S_IRUSR, | ||
1454 | ndev->debugfs_dir, | ||
1455 | ndev, | ||
1456 | &ntb_debugfs_info); | ||
1357 | } | 1457 | } |
1358 | 1458 | ||
1359 | static void ntb_free_debugfs(struct ntb_device *ndev) | 1459 | static void ntb_free_debugfs(struct ntb_device *ndev) |
@@ -1542,4 +1642,5 @@ static struct pci_driver ntb_pci_driver = { | |||
1542 | .probe = ntb_pci_probe, | 1642 | .probe = ntb_pci_probe, |
1543 | .remove = ntb_pci_remove, | 1643 | .remove = ntb_pci_remove, |
1544 | }; | 1644 | }; |
1645 | |||
1545 | module_pci_driver(ntb_pci_driver); | 1646 | module_pci_driver(ntb_pci_driver); |
diff --git a/drivers/ntb/ntb_hw.h b/drivers/ntb/ntb_hw.h index 465517b7393e..ddbcbfda0f49 100644 --- a/drivers/ntb/ntb_hw.h +++ b/drivers/ntb/ntb_hw.h | |||
@@ -152,6 +152,7 @@ struct ntb_device { | |||
152 | struct delayed_work lr_timer; | 152 | struct delayed_work lr_timer; |
153 | 153 | ||
154 | struct dentry *debugfs_dir; | 154 | struct dentry *debugfs_dir; |
155 | struct dentry *debugfs_info; | ||
155 | }; | 156 | }; |
156 | 157 | ||
157 | /** | 158 | /** |
diff --git a/drivers/ntb/ntb_regs.h b/drivers/ntb/ntb_regs.h index 9774506419d7..07872057c76e 100644 --- a/drivers/ntb/ntb_regs.h +++ b/drivers/ntb/ntb_regs.h | |||
@@ -62,10 +62,13 @@ | |||
62 | 62 | ||
63 | #define SNB_DB_HW_LINK 0x8000 | 63 | #define SNB_DB_HW_LINK 0x8000 |
64 | 64 | ||
65 | #define SNB_UNCERRSTS_OFFSET 0x014C | ||
66 | #define SNB_CORERRSTS_OFFSET 0x0158 | ||
67 | #define SNB_LINK_STATUS_OFFSET 0x01A2 | ||
65 | #define SNB_PCICMD_OFFSET 0x0504 | 68 | #define SNB_PCICMD_OFFSET 0x0504 |
66 | #define SNB_DEVCTRL_OFFSET 0x0598 | 69 | #define SNB_DEVCTRL_OFFSET 0x0598 |
70 | #define SNB_DEVSTS_OFFSET 0x059A | ||
67 | #define SNB_SLINK_STATUS_OFFSET 0x05A2 | 71 | #define SNB_SLINK_STATUS_OFFSET 0x05A2 |
68 | #define SNB_LINK_STATUS_OFFSET 0x01A2 | ||
69 | 72 | ||
70 | #define SNB_PBAR2LMT_OFFSET 0x0000 | 73 | #define SNB_PBAR2LMT_OFFSET 0x0000 |
71 | #define SNB_PBAR4LMT_OFFSET 0x0008 | 74 | #define SNB_PBAR4LMT_OFFSET 0x0008 |
@@ -84,7 +87,7 @@ | |||
84 | #define SNB_PDBMSK_OFFSET 0x0062 | 87 | #define SNB_PDBMSK_OFFSET 0x0062 |
85 | #define SNB_SDOORBELL_OFFSET 0x0064 | 88 | #define SNB_SDOORBELL_OFFSET 0x0064 |
86 | #define SNB_SDBMSK_OFFSET 0x0066 | 89 | #define SNB_SDBMSK_OFFSET 0x0066 |
87 | #define SNB_USMEMMISS 0x0070 | 90 | #define SNB_USMEMMISS_OFFSET 0x0070 |
88 | #define SNB_SPAD_OFFSET 0x0080 | 91 | #define SNB_SPAD_OFFSET 0x0080 |
89 | #define SNB_SPADSEMA4_OFFSET 0x00c0 | 92 | #define SNB_SPADSEMA4_OFFSET 0x00c0 |
90 | #define SNB_WCCNTRL_OFFSET 0x00e0 | 93 | #define SNB_WCCNTRL_OFFSET 0x00e0 |