Skip to content

Commit e26a584

Browse files
Allen Hubbejonmason
Allen Hubbe
authored andcommitted
NTB: Split ntb_hw_intel and ntb_transport drivers
Change ntb_hw_intel to use the new NTB hardware abstraction layer. Split ntb_transport into its own driver. Change it to use the new NTB hardware abstraction layer. Signed-off-by: Allen Hubbe <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent a1bd3ba commit e26a584

File tree

13 files changed

+2589
-2195
lines changed

13 files changed

+2589
-2195
lines changed

Documentation/ntb.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,33 @@ as ntb hardware, or hardware drivers, are inserted and removed. The
2626
registration uses the Linux Device framework, so it should feel familiar to
2727
anyone who has written a pci driver.
2828

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+
2940
## NTB Hardware Drivers
3041

3142
NTB hardware drivers should register devices with the NTB core driver. After
3243
registering, clients probe and remove functions will be called.
44+
45+
### NTB Intel Hardware Driver (ntb\_hw\_intel)
46+
47+
The Intel hardware driver supports NTB on Xeon and Atom CPUs.
48+
49+
Module Parameters:
50+
51+
* b2b\_mw\_idx - If the peer ntb is to be accessed via a memory window, then use
52+
this memory window to access the peer ntb. A value of zero or positive
53+
starts from the first mw idx, and a negative value starts from the last
54+
mw idx. Both sides MUST set the same value here! The default value is
55+
`-1`.
56+
* b2b\_mw\_share - If the peer ntb is to be accessed via a memory window, and if
57+
the memory window is large enough, still allow the client to use the
58+
second half of the memory window for address translation to the peer.

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7007,6 +7007,14 @@ F: drivers/net/ntb_netdev.c
70077007
F: include/linux/ntb.h
70087008
F: include/linux/ntb_transport.h
70097009

7010+
NTB INTEL DRIVER
7011+
M: Jon Mason <[email protected]>
7012+
M: Dave Jiang <[email protected]>
7013+
S: Supported
7014+
W: https://github.com/jonmason/ntb/wiki
7015+
T: git git://github.com/jonmason/ntb.git
7016+
F: drivers/ntb/hw/intel/
7017+
70107018
NTFS FILESYSTEM
70117019
M: Anton Altaparmakov <[email protected]>
70127020

drivers/net/ntb_netdev.c

Lines changed: 30 additions & 24 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]>
@@ -49,6 +51,7 @@
4951
#include <linux/ethtool.h>
5052
#include <linux/module.h>
5153
#include <linux/pci.h>
54+
#include <linux/ntb.h>
5255
#include <linux/ntb_transport.h>
5356

5457
#define NTB_NETDEV_VER "0.7"
@@ -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,7 +413,7 @@ 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;
413419
return ntb_transport_register_client(&ntb_netdev_client);
@@ -417,6 +423,6 @@ module_init(ntb_netdev_init_module);
417423
static void __exit ntb_netdev_exit_module(void)
418424
{
419425
ntb_transport_unregister_client(&ntb_netdev_client);
420-
ntb_unregister_client_dev(KBUILD_MODNAME);
426+
ntb_transport_unregister_client_dev(KBUILD_MODNAME);
421427
}
422428
module_exit(ntb_netdev_exit_module);

drivers/ntb/Kconfig

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
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+
config NTB_TRANSPORT
18+
tristate "NTB Transport Client"
19+
help
20+
This is a transport driver that enables connected systems to exchange
21+
messages over the ntb hardware. The transport exposes a queue pair api
22+
to client drivers.
23+
24+
If unsure, say N.
25+
26+
endif # NTB

drivers/ntb/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
obj-$(CONFIG_NTB) += ntb.o
2-
obj-$(CONFIG_NTB) += ntb_hw_intel.o
3-
4-
ntb_hw_intel-objs := hw/intel/ntb_hw_intel.o ntb_transport.o
1+
obj-$(CONFIG_NTB) += ntb.o hw/
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)