Skip to content

Commit 32199ec

Browse files
committed
Merge tag 'ntb-4.8' of git://github.com/jonmason/ntb
Pull NTB updates from Jon Mason: "NTB bug fixes for the ntb_tool and ntb_perf, and improvements to the ntb_perf and ntb_pingpong for increased debugability. Also, modification to the ntb_transport layer to increase/decrease the number of transport entries depending on the ring size" * tag 'ntb-4.8' of git://github.com/jonmason/ntb: NTB: ntb_hw_intel: use local variable pdev NTB: ntb_hw_intel: show BAR size in debugfs info ntb_test: Add a selftest script for the NTB subsystem ntb_perf: clear link_is_up flag when the link goes down. ntb_pingpong: Add a debugfs file to get the ping count ntb_tool: Add link status and files to debugfs ntb_tool: Postpone memory window initialization for the user ntb_perf: Wait for link before running test ntb_perf: Return results by reading the run file ntb_perf: Improve thread handling to increase robustness ntb_perf: Schedule based on time not on performance ntb_transport: Check the number of spads the hardware supports ntb_tool: Add memory window debug support ntb_perf: Allow limiting the size of the memory windows NTB: allocate number transport entries depending on size of ring size ntb_tool: BUG: Ensure the buffer size is large enough to return all spads ntb_tool: Fix infinite loop bug when writing spad/peer_spad file
2 parents a02040d + 95f1464 commit 32199ec

File tree

7 files changed

+1172
-99
lines changed

7 files changed

+1172
-99
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8341,6 +8341,7 @@ F: drivers/ntb/
83418341
F: drivers/net/ntb_netdev.c
83428342
F: include/linux/ntb.h
83438343
F: include/linux/ntb_transport.h
8344+
F: tools/testing/selftests/ntb/
83448345

83458346
NTB INTEL DRIVER
83468347
M: Jon Mason <jdmason@kudzu.us>

drivers/ntb/hw/intel/ntb_hw_intel.c

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,15 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
551551
size_t count, loff_t *offp)
552552
{
553553
struct intel_ntb_dev *ndev;
554+
struct pci_dev *pdev;
554555
void __iomem *mmio;
555556
char *buf;
556557
size_t buf_size;
557558
ssize_t ret, off;
558-
union { u64 v64; u32 v32; u16 v16; } u;
559+
union { u64 v64; u32 v32; u16 v16; u8 v8; } u;
559560

560561
ndev = filp->private_data;
562+
pdev = ndev_pdev(ndev);
561563
mmio = ndev->self_mmio;
562564

563565
buf_size = min(count, 0x800ul);
@@ -631,6 +633,41 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
631633
off += scnprintf(buf + off, buf_size - off,
632634
"Doorbell Bell -\t\t%#llx\n", u.v64);
633635

636+
off += scnprintf(buf + off, buf_size - off,
637+
"\nNTB Window Size:\n");
638+
639+
pci_read_config_byte(pdev, XEON_PBAR23SZ_OFFSET, &u.v8);
640+
off += scnprintf(buf + off, buf_size - off,
641+
"PBAR23SZ %hhu\n", u.v8);
642+
if (!ndev->bar4_split) {
643+
pci_read_config_byte(pdev, XEON_PBAR45SZ_OFFSET, &u.v8);
644+
off += scnprintf(buf + off, buf_size - off,
645+
"PBAR45SZ %hhu\n", u.v8);
646+
} else {
647+
pci_read_config_byte(pdev, XEON_PBAR4SZ_OFFSET, &u.v8);
648+
off += scnprintf(buf + off, buf_size - off,
649+
"PBAR4SZ %hhu\n", u.v8);
650+
pci_read_config_byte(pdev, XEON_PBAR5SZ_OFFSET, &u.v8);
651+
off += scnprintf(buf + off, buf_size - off,
652+
"PBAR5SZ %hhu\n", u.v8);
653+
}
654+
655+
pci_read_config_byte(pdev, XEON_SBAR23SZ_OFFSET, &u.v8);
656+
off += scnprintf(buf + off, buf_size - off,
657+
"SBAR23SZ %hhu\n", u.v8);
658+
if (!ndev->bar4_split) {
659+
pci_read_config_byte(pdev, XEON_SBAR45SZ_OFFSET, &u.v8);
660+
off += scnprintf(buf + off, buf_size - off,
661+
"SBAR45SZ %hhu\n", u.v8);
662+
} else {
663+
pci_read_config_byte(pdev, XEON_SBAR4SZ_OFFSET, &u.v8);
664+
off += scnprintf(buf + off, buf_size - off,
665+
"SBAR4SZ %hhu\n", u.v8);
666+
pci_read_config_byte(pdev, XEON_SBAR5SZ_OFFSET, &u.v8);
667+
off += scnprintf(buf + off, buf_size - off,
668+
"SBAR5SZ %hhu\n", u.v8);
669+
}
670+
634671
off += scnprintf(buf + off, buf_size - off,
635672
"\nNTB Incoming XLAT:\n");
636673

@@ -669,7 +706,7 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
669706
"LMT45 -\t\t\t%#018llx\n", u.v64);
670707
}
671708

672-
if (pdev_is_xeon(ndev->ntb.pdev)) {
709+
if (pdev_is_xeon(pdev)) {
673710
if (ntb_topo_is_b2b(ndev->ntb.topo)) {
674711
off += scnprintf(buf + off, buf_size - off,
675712
"\nNTB Outgoing B2B XLAT:\n");
@@ -750,22 +787,22 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
750787
off += scnprintf(buf + off, buf_size - off,
751788
"\nXEON NTB Hardware Errors:\n");
752789

753-
if (!pci_read_config_word(ndev->ntb.pdev,
790+
if (!pci_read_config_word(pdev,
754791
XEON_DEVSTS_OFFSET, &u.v16))
755792
off += scnprintf(buf + off, buf_size - off,
756793
"DEVSTS -\t\t%#06x\n", u.v16);
757794

758-
if (!pci_read_config_word(ndev->ntb.pdev,
795+
if (!pci_read_config_word(pdev,
759796
XEON_LINK_STATUS_OFFSET, &u.v16))
760797
off += scnprintf(buf + off, buf_size - off,
761798
"LNKSTS -\t\t%#06x\n", u.v16);
762799

763-
if (!pci_read_config_dword(ndev->ntb.pdev,
800+
if (!pci_read_config_dword(pdev,
764801
XEON_UNCERRSTS_OFFSET, &u.v32))
765802
off += scnprintf(buf + off, buf_size - off,
766803
"UNCERRSTS -\t\t%#06x\n", u.v32);
767804

768-
if (!pci_read_config_dword(ndev->ntb.pdev,
805+
if (!pci_read_config_dword(pdev,
769806
XEON_CORERRSTS_OFFSET, &u.v32))
770807
off += scnprintf(buf + off, buf_size - off,
771808
"CORERRSTS -\t\t%#06x\n", u.v32);

drivers/ntb/ntb_transport.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct ntb_transport_qp {
153153
unsigned int rx_index;
154154
unsigned int rx_max_entry;
155155
unsigned int rx_max_frame;
156+
unsigned int rx_alloc_entry;
156157
dma_cookie_t last_cookie;
157158
struct tasklet_struct rxc_db_work;
158159

@@ -480,7 +481,9 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
480481
out_offset += snprintf(buf + out_offset, out_count - out_offset,
481482
"rx_index - \t%u\n", qp->rx_index);
482483
out_offset += snprintf(buf + out_offset, out_count - out_offset,
483-
"rx_max_entry - \t%u\n\n", qp->rx_max_entry);
484+
"rx_max_entry - \t%u\n", qp->rx_max_entry);
485+
out_offset += snprintf(buf + out_offset, out_count - out_offset,
486+
"rx_alloc_entry - \t%u\n\n", qp->rx_alloc_entry);
484487

485488
out_offset += snprintf(buf + out_offset, out_count - out_offset,
486489
"tx_bytes - \t%llu\n", qp->tx_bytes);
@@ -597,9 +600,12 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
597600
{
598601
struct ntb_transport_qp *qp = &nt->qp_vec[qp_num];
599602
struct ntb_transport_mw *mw;
603+
struct ntb_dev *ndev = nt->ndev;
604+
struct ntb_queue_entry *entry;
600605
unsigned int rx_size, num_qps_mw;
601606
unsigned int mw_num, mw_count, qp_count;
602607
unsigned int i;
608+
int node;
603609

604610
mw_count = nt->mw_count;
605611
qp_count = nt->qp_count;
@@ -626,6 +632,23 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
626632
qp->rx_max_entry = rx_size / qp->rx_max_frame;
627633
qp->rx_index = 0;
628634

635+
/*
636+
* Checking to see if we have more entries than the default.
637+
* We should add additional entries if that is the case so we
638+
* can be in sync with the transport frames.
639+
*/
640+
node = dev_to_node(&ndev->dev);
641+
for (i = qp->rx_alloc_entry; i < qp->rx_max_entry; i++) {
642+
entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
643+
if (!entry)
644+
return -ENOMEM;
645+
646+
entry->qp = qp;
647+
ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry,
648+
&qp->rx_free_q);
649+
qp->rx_alloc_entry++;
650+
}
651+
629652
qp->remote_rx_info->entry = qp->rx_max_entry - 1;
630653

631654
/* setup the hdr offsets with 0's */
@@ -1037,6 +1060,13 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
10371060
int node;
10381061
int rc, i;
10391062

1063+
mw_count = ntb_mw_count(ndev);
1064+
if (ntb_spad_count(ndev) < (NUM_MWS + 1 + mw_count * 2)) {
1065+
dev_err(&ndev->dev, "Not enough scratch pad registers for %s",
1066+
NTB_TRANSPORT_NAME);
1067+
return -EIO;
1068+
}
1069+
10401070
if (ntb_db_is_unsafe(ndev))
10411071
dev_dbg(&ndev->dev,
10421072
"doorbell is unsafe, proceed anyway...\n");
@@ -1052,8 +1082,6 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
10521082

10531083
nt->ndev = ndev;
10541084

1055-
mw_count = ntb_mw_count(ndev);
1056-
10571085
nt->mw_count = mw_count;
10581086

10591087
nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec),
@@ -1722,8 +1750,9 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
17221750
ntb_list_add(&qp->ntb_rx_q_lock, &entry->entry,
17231751
&qp->rx_free_q);
17241752
}
1753+
qp->rx_alloc_entry = NTB_QP_DEF_NUM_ENTRIES;
17251754

1726-
for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) {
1755+
for (i = 0; i < qp->tx_max_entry; i++) {
17271756
entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
17281757
if (!entry)
17291758
goto err2;
@@ -1744,6 +1773,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
17441773
while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q)))
17451774
kfree(entry);
17461775
err1:
1776+
qp->rx_alloc_entry = 0;
17471777
while ((entry = ntb_list_rm(&qp->ntb_rx_q_lock, &qp->rx_free_q)))
17481778
kfree(entry);
17491779
if (qp->tx_dma_chan)

0 commit comments

Comments
 (0)