Skip to content

Commit 6d7c8e1

Browse files
committed
Merge tag 'ntb-4.2' of git://github.com/jonmason/ntb
Pull NTB updates from Jon Mason: "This includes a pretty significant reworking of the NTB core code, but has already produced some significant performance improvements. An abstraction layer was added to allow the hardware and clients to be easily added. This required rewriting the NTB transport layer for this abstraction layer. This modification will allow future "high performance" NTB clients. In addition to this change, a number of performance modifications were added. These changes include NUMA enablement, using CPU memcpy instead of asyncdma, and modification of NTB layer MTU size" * tag 'ntb-4.2' of git://github.com/jonmason/ntb: (22 commits) NTB: Add split BAR output for debugfs stats NTB: Change WARN_ON_ONCE to pr_warn_once on unsafe NTB: Print driver name and version in module init NTB: Increase transport MTU to 64k from 16k NTB: Rename Intel code names to platform names NTB: Default to CPU memcpy for performance NTB: Improve performance with write combining NTB: Use NUMA memory in Intel driver NTB: Use NUMA memory and DMA chan in transport NTB: Rate limit ntb_qp_link_work NTB: Add tool test client NTB: Add ping pong test client NTB: Add parameters for Intel SNB B2B addresses NTB: Reset transport QP link stats on down NTB: Do not advance transport RX on link down NTB: Differentiate transport link down messages NTB: Check the device ID to set errata flags NTB: Enable link for Intel root port mode in probe NTB: Read peer info from local SPAD in transport NTB: Split ntb_hw_intel and ntb_transport drivers ...
2 parents 1b3618b + bf44fe4 commit 6d7c8e1

File tree

23 files changed

+5545
-2816
lines changed

23 files changed

+5545
-2816
lines changed

Documentation/ntb.txt

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# NTB Drivers
2+
3+
NTB (Non-Transparent Bridge) is a type of PCI-Express bridge chip that connects
4+
the separate memory systems of two computers to the same PCI-Express fabric.
5+
Existing NTB hardware supports a common feature set, including scratchpad
6+
registers, doorbell registers, and memory translation windows. Scratchpad
7+
registers are read-and-writable registers that are accessible from either side
8+
of the device, so that peers can exchange a small amount of information at a
9+
fixed address. Doorbell registers provide a way for peers to send interrupt
10+
events. Memory windows allow translated read and write access to the peer
11+
memory.
12+
13+
## NTB Core Driver (ntb)
14+
15+
The NTB core driver defines an api wrapping the common feature set, and allows
16+
clients interested in NTB features to discover NTB the devices supported by
17+
hardware drivers. The term "client" is used here to mean an upper layer
18+
component making use of the NTB api. The term "driver," or "hardware driver,"
19+
is used here to mean a driver for a specific vendor and model of NTB hardware.
20+
21+
## NTB Client Drivers
22+
23+
NTB client drivers should register with the NTB core driver. After
24+
registering, the client probe and remove functions will be called appropriately
25+
as ntb hardware, or hardware drivers, are inserted and removed. The
26+
registration uses the Linux Device framework, so it should feel familiar to
27+
anyone who has written a pci driver.
28+
29+
### NTB Transport Client (ntb\_transport) and NTB Netdev (ntb\_netdev)
30+
31+
The primary client for NTB is the Transport client, used in tandem with NTB
32+
Netdev. These drivers function together to create a logical link to the peer,
33+
across the ntb, to exchange packets of network data. The Transport client
34+
establishes a logical link to the peer, and creates queue pairs to exchange
35+
messages and data. The NTB Netdev then creates an ethernet device using a
36+
Transport queue pair. Network data is copied between socket buffers and the
37+
Transport queue pair buffer. The Transport client may be used for other things
38+
besides Netdev, however no other applications have yet been written.
39+
40+
### NTB Ping Pong Test Client (ntb\_pingpong)
41+
42+
The Ping Pong test client serves as a demonstration to exercise the doorbell
43+
and scratchpad registers of NTB hardware, and as an example simple NTB client.
44+
Ping Pong enables the link when started, waits for the NTB link to come up, and
45+
then proceeds to read and write the doorbell scratchpad registers of the NTB.
46+
The peers interrupt each other using a bit mask of doorbell bits, which is
47+
shifted by one in each round, to test the behavior of multiple doorbell bits
48+
and interrupt vectors. The Ping Pong driver also reads the first local
49+
scratchpad, and writes the value plus one to the first peer scratchpad, each
50+
round before writing the peer doorbell register.
51+
52+
Module Parameters:
53+
54+
* unsafe - Some hardware has known issues with scratchpad and doorbell
55+
registers. By default, Ping Pong will not attempt to exercise such
56+
hardware. You may override this behavior at your own risk by setting
57+
unsafe=1.
58+
* delay\_ms - Specify the delay between receiving a doorbell
59+
interrupt event and setting the peer doorbell register for the next
60+
round.
61+
* init\_db - Specify the doorbell bits to start new series of rounds. A new
62+
series begins once all the doorbell bits have been shifted out of
63+
range.
64+
* dyndbg - It is suggested to specify dyndbg=+p when loading this module, and
65+
then to observe debugging output on the console.
66+
67+
### NTB Tool Test Client (ntb\_tool)
68+
69+
The Tool test client serves for debugging, primarily, ntb hardware and drivers.
70+
The Tool provides access through debugfs for reading, setting, and clearing the
71+
NTB doorbell, and reading and writing scratchpads.
72+
73+
The Tool does not currently have any module parameters.
74+
75+
Debugfs Files:
76+
77+
* *debugfs*/ntb\_tool/*hw*/ - A directory in debugfs will be created for each
78+
NTB device probed by the tool. This directory is shortened to *hw*
79+
below.
80+
* *hw*/db - This file is used to read, set, and clear the local doorbell. Not
81+
all operations may be supported by all hardware. To read the doorbell,
82+
read the file. To set the doorbell, write `s` followed by the bits to
83+
set (eg: `echo 's 0x0101' > db`). To clear the doorbell, write `c`
84+
followed by the bits to clear.
85+
* *hw*/mask - This file is used to read, set, and clear the local doorbell mask.
86+
See *db* for details.
87+
* *hw*/peer\_db - This file is used to read, set, and clear the peer doorbell.
88+
See *db* for details.
89+
* *hw*/peer\_mask - This file is used to read, set, and clear the peer doorbell
90+
mask. See *db* for details.
91+
* *hw*/spad - This file is used to read and write local scratchpads. To read
92+
the values of all scratchpads, read the file. To write values, write a
93+
series of pairs of scratchpad number and value
94+
(eg: `echo '4 0x123 7 0xabc' > spad`
95+
# to set scratchpads `4` and `7` to `0x123` and `0xabc`, respectively).
96+
* *hw*/peer\_spad - This file is used to read and write peer scratchpads. See
97+
*spad* for details.
98+
99+
## NTB Hardware Drivers
100+
101+
NTB hardware drivers should register devices with the NTB core driver. After
102+
registering, clients probe and remove functions will be called.
103+
104+
### NTB Intel Hardware Driver (ntb\_hw\_intel)
105+
106+
The Intel hardware driver supports NTB on Xeon and Atom CPUs.
107+
108+
Module Parameters:
109+
110+
* b2b\_mw\_idx - If the peer ntb is to be accessed via a memory window, then use
111+
this memory window to access the peer ntb. A value of zero or positive
112+
starts from the first mw idx, and a negative value starts from the last
113+
mw idx. Both sides MUST set the same value here! The default value is
114+
`-1`.
115+
* b2b\_mw\_share - If the peer ntb is to be accessed via a memory window, and if
116+
the memory window is large enough, still allow the client to use the
117+
second half of the memory window for address translation to the peer.
118+
* xeon\_b2b\_usd\_bar2\_addr64 - If using B2B topology on Xeon hardware, use
119+
this 64 bit address on the bus between the NTB devices for the window
120+
at BAR2, on the upstream side of the link.
121+
* xeon\_b2b\_usd\_bar4\_addr64 - See *xeon\_b2b\_bar2\_addr64*.
122+
* xeon\_b2b\_usd\_bar4\_addr32 - See *xeon\_b2b\_bar2\_addr64*.
123+
* xeon\_b2b\_usd\_bar5\_addr32 - See *xeon\_b2b\_bar2\_addr64*.
124+
* xeon\_b2b\_dsd\_bar2\_addr64 - See *xeon\_b2b\_bar2\_addr64*.
125+
* xeon\_b2b\_dsd\_bar4\_addr64 - See *xeon\_b2b\_bar2\_addr64*.
126+
* xeon\_b2b\_dsd\_bar4\_addr32 - See *xeon\_b2b\_bar2\_addr64*.
127+
* xeon\_b2b\_dsd\_bar5\_addr32 - See *xeon\_b2b\_bar2\_addr64*.

MAINTAINERS

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7212,15 +7212,25 @@ F: drivers/power/bq27x00_battery.c
72127212
F: drivers/power/isp1704_charger.c
72137213
F: drivers/power/rx51_battery.c
72147214

7215-
NTB DRIVER
7215+
NTB DRIVER CORE
72167216
M: Jon Mason <[email protected]>
72177217
M: Dave Jiang <[email protected]>
7218+
M: Allen Hubbe <[email protected]>
72187219
S: Supported
72197220
W: https://github.com/jonmason/ntb/wiki
72207221
T: git git://github.com/jonmason/ntb.git
72217222
F: drivers/ntb/
72227223
F: drivers/net/ntb_netdev.c
72237224
F: include/linux/ntb.h
7225+
F: include/linux/ntb_transport.h
7226+
7227+
NTB INTEL DRIVER
7228+
M: Jon Mason <[email protected]>
7229+
M: Dave Jiang <[email protected]>
7230+
S: Supported
7231+
W: https://github.com/jonmason/ntb/wiki
7232+
T: git git://github.com/jonmason/ntb.git
7233+
F: drivers/ntb/hw/intel/
72247234

72257235
NTFS FILESYSTEM
72267236
M: Anton Altaparmakov <[email protected]>

drivers/net/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ config NET_POLL_CONTROLLER
217217
def_bool NETPOLL
218218

219219
config NTB_NETDEV
220-
tristate "Virtual Ethernet over NTB"
221-
depends on NTB
220+
tristate "Virtual Ethernet over NTB Transport"
221+
depends on NTB_TRANSPORT
222222

223223
config RIONET
224224
tristate "RapidIO Ethernet over messaging driver support"

drivers/net/ntb_netdev.c

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* GPL LICENSE SUMMARY
66
*
77
* Copyright(c) 2012 Intel Corporation. All rights reserved.
8+
* Copyright (C) 2015 EMC Corporation. All Rights Reserved.
89
*
910
* This program is free software; you can redistribute it and/or modify
1011
* it under the terms of version 2 of the GNU General Public License as
@@ -13,6 +14,7 @@
1314
* BSD LICENSE
1415
*
1516
* Copyright(c) 2012 Intel Corporation. All rights reserved.
17+
* Copyright (C) 2015 EMC Corporation. All Rights Reserved.
1618
*
1719
* Redistribution and use in source and binary forms, with or without
1820
* modification, are permitted provided that the following conditions
@@ -40,7 +42,7 @@
4042
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4143
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4244
*
43-
* Intel PCIe NTB Network Linux driver
45+
* PCIe NTB Network Linux driver
4446
*
4547
* Contact Information:
4648
* Jon Mason <[email protected]>
@@ -50,6 +52,7 @@
5052
#include <linux/module.h>
5153
#include <linux/pci.h>
5254
#include <linux/ntb.h>
55+
#include <linux/ntb_transport.h>
5356

5457
#define NTB_NETDEV_VER "0.7"
5558

@@ -70,26 +73,19 @@ struct ntb_netdev {
7073

7174
static LIST_HEAD(dev_list);
7275

73-
static void ntb_netdev_event_handler(void *data, int status)
76+
static void ntb_netdev_event_handler(void *data, int link_is_up)
7477
{
7578
struct net_device *ndev = data;
7679
struct ntb_netdev *dev = netdev_priv(ndev);
7780

78-
netdev_dbg(ndev, "Event %x, Link %x\n", status,
81+
netdev_dbg(ndev, "Event %x, Link %x\n", link_is_up,
7982
ntb_transport_link_query(dev->qp));
8083

81-
switch (status) {
82-
case NTB_LINK_DOWN:
84+
if (link_is_up) {
85+
if (ntb_transport_link_query(dev->qp))
86+
netif_carrier_on(ndev);
87+
} else {
8388
netif_carrier_off(ndev);
84-
break;
85-
case NTB_LINK_UP:
86-
if (!ntb_transport_link_query(dev->qp))
87-
return;
88-
89-
netif_carrier_on(ndev);
90-
break;
91-
default:
92-
netdev_warn(ndev, "Unsupported event type %d\n", status);
9389
}
9490
}
9591

@@ -160,8 +156,6 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,
160156
struct ntb_netdev *dev = netdev_priv(ndev);
161157
int rc;
162158

163-
netdev_dbg(ndev, "%s: skb len %d\n", __func__, skb->len);
164-
165159
rc = ntb_transport_tx_enqueue(dev->qp, skb, skb->data, skb->len);
166160
if (rc)
167161
goto err;
@@ -322,20 +316,26 @@ static const struct ntb_queue_handlers ntb_netdev_handlers = {
322316
.event_handler = ntb_netdev_event_handler,
323317
};
324318

325-
static int ntb_netdev_probe(struct pci_dev *pdev)
319+
static int ntb_netdev_probe(struct device *client_dev)
326320
{
321+
struct ntb_dev *ntb;
327322
struct net_device *ndev;
323+
struct pci_dev *pdev;
328324
struct ntb_netdev *dev;
329325
int rc;
330326

331-
ndev = alloc_etherdev(sizeof(struct ntb_netdev));
327+
ntb = dev_ntb(client_dev->parent);
328+
pdev = ntb->pdev;
329+
if (!pdev)
330+
return -ENODEV;
331+
332+
ndev = alloc_etherdev(sizeof(*dev));
332333
if (!ndev)
333334
return -ENOMEM;
334335

335336
dev = netdev_priv(ndev);
336337
dev->ndev = ndev;
337338
dev->pdev = pdev;
338-
BUG_ON(!dev->pdev);
339339
ndev->features = NETIF_F_HIGHDMA;
340340

341341
ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
@@ -349,7 +349,8 @@ static int ntb_netdev_probe(struct pci_dev *pdev)
349349
ndev->netdev_ops = &ntb_netdev_ops;
350350
ndev->ethtool_ops = &ntb_ethtool_ops;
351351

352-
dev->qp = ntb_transport_create_queue(ndev, pdev, &ntb_netdev_handlers);
352+
dev->qp = ntb_transport_create_queue(ndev, client_dev,
353+
&ntb_netdev_handlers);
353354
if (!dev->qp) {
354355
rc = -EIO;
355356
goto err;
@@ -372,12 +373,17 @@ static int ntb_netdev_probe(struct pci_dev *pdev)
372373
return rc;
373374
}
374375

375-
static void ntb_netdev_remove(struct pci_dev *pdev)
376+
static void ntb_netdev_remove(struct device *client_dev)
376377
{
378+
struct ntb_dev *ntb;
377379
struct net_device *ndev;
380+
struct pci_dev *pdev;
378381
struct ntb_netdev *dev;
379382
bool found = false;
380383

384+
ntb = dev_ntb(client_dev->parent);
385+
pdev = ntb->pdev;
386+
381387
list_for_each_entry(dev, &dev_list, list) {
382388
if (dev->pdev == pdev) {
383389
found = true;
@@ -396,7 +402,7 @@ static void ntb_netdev_remove(struct pci_dev *pdev)
396402
free_netdev(ndev);
397403
}
398404

399-
static struct ntb_client ntb_netdev_client = {
405+
static struct ntb_transport_client ntb_netdev_client = {
400406
.driver.name = KBUILD_MODNAME,
401407
.driver.owner = THIS_MODULE,
402408
.probe = ntb_netdev_probe,
@@ -407,16 +413,16 @@ static int __init ntb_netdev_init_module(void)
407413
{
408414
int rc;
409415

410-
rc = ntb_register_client_dev(KBUILD_MODNAME);
416+
rc = ntb_transport_register_client_dev(KBUILD_MODNAME);
411417
if (rc)
412418
return rc;
413-
return ntb_register_client(&ntb_netdev_client);
419+
return ntb_transport_register_client(&ntb_netdev_client);
414420
}
415421
module_init(ntb_netdev_init_module);
416422

417423
static void __exit ntb_netdev_exit_module(void)
418424
{
419-
ntb_unregister_client(&ntb_netdev_client);
420-
ntb_unregister_client_dev(KBUILD_MODNAME);
425+
ntb_transport_unregister_client(&ntb_netdev_client);
426+
ntb_transport_unregister_client_dev(KBUILD_MODNAME);
421427
}
422428
module_exit(ntb_netdev_exit_module);

drivers/ntb/Kconfig

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1-
config NTB
2-
tristate "Intel Non-Transparent Bridge support"
3-
depends on PCI
4-
depends on X86
5-
help
6-
The PCI-E Non-transparent bridge hardware is a point-to-point PCI-E bus
7-
connecting 2 systems. When configured, writes to the device's PCI
8-
mapped memory will be mirrored to a buffer on the remote system. The
9-
ntb Linux driver uses this point-to-point communication as a method to
10-
transfer data from one system to the other.
11-
12-
If unsure, say N.
1+
menuconfig NTB
2+
tristate "Non-Transparent Bridge support"
3+
depends on PCI
4+
help
5+
The PCI-E Non-transparent bridge hardware is a point-to-point PCI-E bus
6+
connecting 2 systems. When configured, writes to the device's PCI
7+
mapped memory will be mirrored to a buffer on the remote system. The
8+
ntb Linux driver uses this point-to-point communication as a method to
9+
transfer data from one system to the other.
1310

11+
If unsure, say N.
12+
13+
if NTB
14+
15+
source "drivers/ntb/hw/Kconfig"
16+
17+
source "drivers/ntb/test/Kconfig"
18+
19+
config NTB_TRANSPORT
20+
tristate "NTB Transport Client"
21+
help
22+
This is a transport driver that enables connected systems to exchange
23+
messages over the ntb hardware. The transport exposes a queue pair api
24+
to client drivers.
25+
26+
If unsure, say N.
27+
28+
endif # NTB

drivers/ntb/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
obj-$(CONFIG_NTB) += ntb.o
2-
3-
ntb-objs := ntb_hw.o ntb_transport.o
1+
obj-$(CONFIG_NTB) += ntb.o hw/ test/
2+
obj-$(CONFIG_NTB_TRANSPORT) += ntb_transport.o

drivers/ntb/hw/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source "drivers/ntb/hw/intel/Kconfig"

drivers/ntb/hw/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-$(CONFIG_NTB_INTEL) += intel/

drivers/ntb/hw/intel/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
config NTB_INTEL
2+
tristate "Intel Non-Transparent Bridge support"
3+
depends on X86_64
4+
help
5+
This driver supports Intel NTB on capable Xeon and Atom hardware.
6+
7+
If unsure, say N.

drivers/ntb/hw/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
obj-$(CONFIG_NTB_INTEL) += ntb_hw_intel.o

0 commit comments

Comments
 (0)