Skip to contentSkip to conversation

PCI NTB: prepare for more hardware support

RFC PATCH In review Gerhard Sittig 2 participants 9 messages Aug 6, 2014 – Aug 18, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover PCI NTB: prepare for more hardware support

The current implementation of the PCI non-transparent bridge support exclusively supports Intel hardware. This series prepares for the introduction of other vendor's hardware support, by separating the generic 'data transport' driver from the specific 'hardware support' driver.

The current implementation has a circular dependency, where the data transport uses hardware specific routines for its communication, while the hardware driver calls into the data transport layer to have the data link established upon probe. In addition, existing documentation suggests that out-of-tree drivers may use the hardware driver's routines, working in parallel to the in-tree data transport and the network interface on top if it.

This series "puts the data transport first", to provide routines to register hardware drivers with the transport and to have the transport become available as hardware is found. While several hardware drivers may implement the common "hw" API, and one of those drivers gets probed at runtime and then is used for the data transport. The relation of exactly one hardware driver to one transport instance is kept, as is the NTB driver's API within the kernel. No new hardware support gets introduced by this series. It's "mere refactoring".

Unfortunately I don't have Intel hardware to exercise runtime tests for the series. It has only been compile-tested for bisectability and with several combinations of the tristate options, and the series is checkpatch clean including --strict. Testers who have access to hardware are cordially invited. :)

BTW was I surprised to find the NTB driver under drivers/ntb/, and not underneath the PCI subsystem. I hope I got the list of recipients correct for the series.

Gerhard Sittig (4):
ntb: split Intel specifics out of the "NTB hardware" interface
ntb: header file nits (multiple inclusion, explicit entries)
ntb: prepare to build the 'data transport' as a separate module
ntb: de-couple data transport from hardware support

 drivers/ntb/Kconfig                          |   45 ++++--
 drivers/ntb/Makefile                         |    5 +-
 drivers/ntb/ntb_hw.h                         |  101 +++++++------
 drivers/ntb/{ntb_hw.c => ntb_hw_intel.c}     |   83 +++++++----
 drivers/ntb/ntb_hw_intel.h                   |   73 ++++++++++
 drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} |    0
 drivers/ntb/ntb_transport.c                  |  196 ++++++++++++++++++++++++++
 include/linux/ntb.h                          |    7 +
 8 files changed, 426 insertions(+), 84 deletions(-)
 rename drivers/ntb/{ntb_hw.c => ntb_hw_intel.c} (94%)
 create mode 100644 drivers/ntb/ntb_hw_intel.h
 rename drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} (100%)
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH 1/4 ntb: split Intel specifics out of the "NTB hardware" interface

Rename the ntb_hw.c compile unit and adjust the Makefile, to reflect that this code drives Intel hardware. Move Intel specific declarations from ntb_hw.h to a separate ntb_hw_intel.h header file and rename the Intel specific register set header file.

This leaves the ntb_hw.h header file with the declaration of the interface between the 'data transport' and the 'hardware' aspects.

---
 drivers/ntb/Makefile                         |    2 +-
 drivers/ntb/ntb_hw.h                         |   21 --------
 drivers/ntb/{ntb_hw.c => ntb_hw_intel.c}     |   11 ++--
 drivers/ntb/ntb_hw_intel.h                   |   73 ++++++++++++++++++++++++++
 drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} |    0
 5 files changed, 80 insertions(+), 27 deletions(-)
 rename drivers/ntb/{ntb_hw.c => ntb_hw_intel.c} (99%)
 create mode 100644 drivers/ntb/ntb_hw_intel.h
 rename drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} (100%)
drivers/ntb/Makefile +1 -1
index 15cb59fd354e..468ca8ea395e 100644
@@ -1,3 +1,3 @@
 obj-$(CONFIG_NTB) += ntb.o
 
-ntb-objs := ntb_hw.o ntb_transport.o
+ntb-objs := ntb_hw_intel.o ntb_transport.o
drivers/ntb/ntb_hw.h +0 -21
index 465517b7393e..9cb288c045db 100644
@@ -47,19 +47,6 @@
  */
 #include <linux/ntb.h>
 
-#define PCI_DEVICE_ID_INTEL_NTB_B2B_JSF		0x3725
-#define PCI_DEVICE_ID_INTEL_NTB_PS_JSF		0x3726
-#define PCI_DEVICE_ID_INTEL_NTB_SS_JSF		0x3727
-#define PCI_DEVICE_ID_INTEL_NTB_B2B_SNB		0x3C0D
-#define PCI_DEVICE_ID_INTEL_NTB_PS_SNB		0x3C0E
-#define PCI_DEVICE_ID_INTEL_NTB_SS_SNB		0x3C0F
-#define PCI_DEVICE_ID_INTEL_NTB_B2B_IVT		0x0E0D
-#define PCI_DEVICE_ID_INTEL_NTB_PS_IVT		0x0E0E
-#define PCI_DEVICE_ID_INTEL_NTB_SS_IVT		0x0E0F
-#define PCI_DEVICE_ID_INTEL_NTB_B2B_HSX		0x2F0D
-#define PCI_DEVICE_ID_INTEL_NTB_PS_HSX		0x2F0E
-#define PCI_DEVICE_ID_INTEL_NTB_SS_HSX		0x2F0F
-#define PCI_DEVICE_ID_INTEL_NTB_B2B_BWD		0x0C4E
 
 #ifndef readq
 static inline u64 readq(void __iomem *addr)
@@ -76,14 +63,6 @@ static inline void writeq(u64 val, void __iomem *addr)
 }
 #endif
 
-#define NTB_BAR_MMIO		0
-#define NTB_BAR_23		2
-#define NTB_BAR_45		4
-#define NTB_BAR_MASK		((1 << NTB_BAR_MMIO) | (1 << NTB_BAR_23) |\
-				 (1 << NTB_BAR_45))
-
-#define NTB_HB_TIMEOUT		msecs_to_jiffies(1000)
-
 #define NTB_MAX_NUM_MW		2
 
 enum ntb_hw_event {
drivers/ntb/ntb_hw_intel.c renamed from drivers/ntb/ntb_hw.c +6 -5
similarity index 99%
rename from drivers/ntb/ntb_hw.c
rename to drivers/ntb/ntb_hw_intel.c
index 372e08c4ffef..699f05132a61 100644
@@ -54,13 +54,14 @@
 #include <linux/random.h>
 #include <linux/slab.h>
 #include "ntb_hw.h"
-#include "ntb_regs.h"
+#include "ntb_hw_intel.h"
+#include "ntb_regs_intel.h"
 
-#define NTB_NAME	"Intel(R) PCI-E Non-Transparent Bridge Driver"
-#define NTB_VER		"1.0"
+#define NTB_HW_INTEL_NAME	"Intel(R) PCI-E Non-Transparent Bridge Driver"
+#define NTB_HW_INTEL_VER	"1.0"
 
-MODULE_DESCRIPTION(NTB_NAME);
-MODULE_VERSION(NTB_VER);
+MODULE_DESCRIPTION(NTB_HW_INTEL_NAME);
+MODULE_VERSION(NTB_HW_INTEL_VER);
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Intel Corporation");
 
drivers/ntb/ntb_hw_intel.h new file +73 -0

73 lines not on this page · raw message

drivers/ntb/ntb_regs_intel.h renamed from drivers/ntb/ntb_regs.h +0 -0
similarity index 100%
rename from drivers/ntb/ntb_regs.h
rename to drivers/ntb/ntb_regs_intel.h
Signature · 1 line
1.7.10.4
#2 lore raw

RFC PATCH 2/4 ntb: header file nits (multiple inclusion, explicit entries)

In reply to Gerhard Sittig

Protect NTB related header files against multiple inclusion, because in addition to function signatures they declare data structures, too.

Add more explicit include items such that header files can be used independently from each other, i.e. calling code does not depend on the order of include specs to have all data types declared correctly.

Minor whitespace adjustment, to separate license texts from system includes from local includes for easier navigation.

---
 drivers/ntb/ntb_hw.h        |    8 +++++++-
 drivers/ntb/ntb_hw_intel.c  |    1 +
 drivers/ntb/ntb_transport.c |    3 +++
 include/linux/ntb.h         |    7 +++++++
 4 files changed, 18 insertions(+), 1 deletion(-)
drivers/ntb/ntb_hw.h +7 -1
index 9cb288c045db..fe4c6306f11c 100644
@@ -45,8 +45,12 @@
  * Contact Information:
  * Jon Mason <[email protected]>
  */
-#include <linux/ntb.h>
+#ifndef NTB_HW_H
+#define NTB_HW_H
 
+#include <linux/interrupt.h>
+#include <linux/ntb.h>
+#include <linux/types.h>
 
 #ifndef readq
 static inline u64 readq(void __iomem *addr)
@@ -224,3 +228,5 @@ void *ntb_find_transport(struct pci_dev *pdev);
 
 int ntb_transport_init(struct pci_dev *pdev);
 void ntb_transport_free(void *transport);
+
+#endif /* NTB_HW_H */
drivers/ntb/ntb_hw_intel.c +1 -0
index 699f05132a61..a81a06c50148 100644
@@ -53,6 +53,7 @@
 #include <linux/pci.h>
 #include <linux/random.h>
 #include <linux/slab.h>
+
 #include "ntb_hw.h"
 #include "ntb_hw_intel.h"
 #include "ntb_regs_intel.h"
drivers/ntb/ntb_transport.c +3 -0
index 9dd63b822025..436326ad87bd 100644
@@ -45,6 +45,7 @@
  * Contact Information:
  * Jon Mason <[email protected]>
  */
+
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/dmaengine.h>
@@ -53,9 +54,11 @@
 #include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/ntb.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/types.h>
+
 #include "ntb_hw.h"
 
 #define NTB_TRANSPORT_VERSION	3
include/linux/ntb.h +7 -0
index 9ac1a62fc6f5..5b69d09db84f 100644
@@ -45,6 +45,11 @@
  * Contact Information:
  * Jon Mason <[email protected]>
  */
+#ifndef LINUX_NTB_H
+#define LINUX_NTB_H
+
+#include <linux/pci.h>
+#include <linux/types.h>
 
 struct ntb_transport_qp;
 
@@ -86,3 +91,5 @@ void *ntb_transport_rx_remove(struct ntb_transport_qp *qp, unsigned int *len);
 void ntb_transport_link_up(struct ntb_transport_qp *qp);
 void ntb_transport_link_down(struct ntb_transport_qp *qp);
 bool ntb_transport_link_query(struct ntb_transport_qp *qp);
+
+#endif /* LINUX_NTB_H */
Signature · 1 line
1.7.10.4
#3 lore raw

RFC PATCH 3/4 ntb: prepare to build the 'data transport' as a separate module

In reply to Gerhard Sittig

Export those routines of the data transport which the PCI NTB hardware drivers will reference, and provide module properties such that the data transport over PCI NTB can build as a separate module.

This change does not alter the Makefile, the data transport still gets statically linked against the driver for Intel hardware support.

---
 drivers/ntb/ntb_transport.c |    9 +++++++++
 1 file changed, 9 insertions(+)
drivers/ntb/ntb_transport.c +9 -0
index 436326ad87bd..70f358c8cc09 100644
@@ -61,7 +61,14 @@
 
 #include "ntb_hw.h"
 
+#define NTB_TRANSPORT_NAME	"Data transport over Non-Transparent Bridge"
 #define NTB_TRANSPORT_VERSION	3
+#define NTB_TRANSPORT_VERSTEXT	"3"
+
+MODULE_DESCRIPTION(NTB_TRANSPORT_NAME);
+MODULE_VERSION(NTB_TRANSPORT_VERSTEXT);
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Intel Corporation");
 
 static unsigned int transport_mtu = 0x401E;
 module_param(transport_mtu, uint, 0644);
@@ -979,6 +986,7 @@ err:
 	kfree(nt);
 	return rc;
 }
+EXPORT_SYMBOL(ntb_transport_init);
 
 void ntb_transport_free(void *transport)
 {
@@ -1009,6 +1017,7 @@ void ntb_transport_free(void *transport)
 	ntb_unregister_transport(ndev);
 	kfree(nt);
 }
+EXPORT_SYMBOL(ntb_transport_free);
 
 static void ntb_rx_copy_callback(void *data)
 {
Signature · 1 line
1.7.10.4
#4 lore raw

RFC PATCH 4/4 ntb: de-couple data transport from hardware support

In reply to Gerhard Sittig

The previous implementation at compile time statically linked one specific hardware driver (Intel) against the generic data transport over PCI NTB.

Make the hardware driver's public routines static, to register them with the data transport at runtime. And make the data transport wrap those routines, to raise appropriate error codes or provide neutral return values in the absence of hardware support. There still is only support for exactly one hardware driver that is used by the data transport.

Adjust the build support to reflect the fact that the data transport and the hardware support can get built independently from each other. Multiple hardware support drivers can implement PCI NTB intrinsics, and the data transport picks up at runtime whatever matches the found hardware.

---
 drivers/ntb/Kconfig         |   45 ++++++++---
 drivers/ntb/Makefile        |    5 +-
 drivers/ntb/ntb_hw.h        |   72 +++++++++++------
 drivers/ntb/ntb_hw_intel.c  |   71 ++++++++++++-----
 drivers/ntb/ntb_transport.c |  184 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 320 insertions(+), 57 deletions(-)
drivers/ntb/Kconfig +33 -12
index f69df793dbe2..3c5f8f88c55d 100644
@@ -1,13 +1,34 @@
-config NTB
-       tristate "Intel Non-Transparent Bridge support"
-       depends on PCI
-       depends on X86
-       help
-        The PCI-E Non-transparent bridge hardware is a point-to-point PCI-E bus
-        connecting 2 systems.  When configured, writes to the device's PCI
-        mapped memory will be mirrored to a buffer on the remote system.  The
-        ntb Linux driver uses this point-to-point communication as a method to
-        transfer data from one system to the other.
-
-        If unsure, say N.
+menuconfig NTB
+	bool "PCI Non-Transparent Bridge support"
+	depends on PCI
+	help
+	  The PCI non-transparent bridge hardware is a point-to-point PCI bus
+	  connecting two systems.  When configured, reads and writes to the
+	  device's PCI mapped memory will be mirrored to a buffer on the remote
+	  system.  The Linux ntb driver uses this point-to-point communication
+	  as a method to transfer data from one system to the other.
 
+	  If unsure, say N.
+
+if NTB
+
+config NTB_TRANSPORT
+	tristate "Data Transport over PCI Non-Transparent Bridges"
+	depends on NTB
+	help
+	  Enable support for data transports over the PCIe non-transparent
+	  bridge connections.  This requires specific hardware support for
+	  PCI NTBs to become operational.
+
+	  If unsure, say N.
+
+config NTB_HW_INTEL
+	tristate "Intel Hardware Support for PCI NTB"
+	depends on X86
+	depends on NTB_TRANSPORT
+	help
+	  Enable support for PCIe non-transparent bridges on Intel hardware.
+
+	  If unsure, say N.
+
+endif # NTB
drivers/ntb/Makefile +2 -3
index 468ca8ea395e..021a5c66b862 100644
@@ -1,3 +1,2 @@
-obj-$(CONFIG_NTB) += ntb.o
-
-ntb-objs := ntb_hw_intel.o ntb_transport.o
+obj-$(CONFIG_NTB_HW_INTEL) += ntb_hw_intel.o
+obj-$(CONFIG_NTB_TRANSPORT) += ntb_transport.o
drivers/ntb/ntb_hw.h +50 -22

79 lines not on this page · raw message

drivers/ntb/ntb_hw_intel.c +51 -20

192 lines not on this page · raw message

drivers/ntb/ntb_transport.c +184 -0

190 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Gerhard Sittig
Quoted 6 lines · Gerhard Sittig

The current implementation of the PCI non-transparent bridge support exclusively supports Intel hardware. This series prepares for the introduction of other vendor's hardware support, by separating the generic 'data transport' driver from the specific 'hardware support' driver.

For the record: Email to Jon Mason, the original NTB driver author, bounced with SMTP error 550. The MAINTAINERS file's "NTB DRIVER" section might need an update. Is the address listed under "NETERION 10GbE DRIVERS" correct, or is it a coincidence that the name matches?

virtually yours
Gerhard Sittig

Signature · 3 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
#7 lore raw
In reply to Gerhard Sittig

Hello Gerhard,

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:linux-pci- [email protected]] On Behalf Of Gerhard Sittig
Sent: Wednesday, August 06, 2014 7:54 AM
To: [email protected]; Jon Mason
Cc: Bjorn Helgaas; Detlev Zundel; Gerhard Sittig
Subject: [PATCH RFC v1 0/4] PCI NTB: prepare for more hardware support

Quoted 4 lines

The current implementation of the PCI non-transparent bridge support exclusively supports Intel hardware. This series prepares for the introduction of other vendor's hardware support, by separating the generic 'data transport' driver from the specific 'hardware support' driver.

Thanks for this effort. I also have a PLX NT bridge that I was exploring to add support for. This will definitely make it easier.

Just curious, do you have any kind of NT bridge hardware that you want to add support for?

Thanks,

Rajat

Quoted 57 lines

The current implementation has a circular dependency, where the data transport uses hardware specific routines for its communication, while the hardware driver calls into the data transport layer to have the data link established upon probe. In addition, existing documentation suggests that out-of-tree drivers may use the hardware driver's routines, working in parallel to the in-tree data transport and the network interface on top if it.

This series "puts the data transport first", to provide routines to register hardware drivers with the transport and to have the transport become available as hardware is found. While several hardware drivers may implement the common "hw" API, and one of those drivers gets probed at runtime and then is used for the data transport. The relation of exactly one hardware driver to one transport instance is kept, as is the NTB driver's API within the kernel. No new hardware support gets introduced by this series. It's "mere refactoring".

Unfortunately I don't have Intel hardware to exercise runtime tests for the series. It has only been compile-tested for bisectability and with several combinations of the tristate options, and the series is checkpatch clean including --strict.
Testers who have access to hardware are cordially invited. :)

BTW was I surprised to find the NTB driver under drivers/ntb/, and not underneath the PCI subsystem. I hope I got the list of recipients correct for the series.

Gerhard Sittig (4):
ntb: split Intel specifics out of the "NTB hardware" interface
ntb: header file nits (multiple inclusion, explicit entries)
ntb: prepare to build the 'data transport' as a separate module
ntb: de-couple data transport from hardware support

 drivers/ntb/Kconfig                          |   45 ++++--
 drivers/ntb/Makefile                         |    5 +-
 drivers/ntb/ntb_hw.h                         |  101 +++++++------
 drivers/ntb/{ntb_hw.c => ntb_hw_intel.c}     |   83 +++++++----
 drivers/ntb/ntb_hw_intel.h                   |   73 ++++++++++
 drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} |    0
 drivers/ntb/ntb_transport.c                  |  196
++++++++++++++++++++++++++
 include/linux/ntb.h                          |    7 +
 8 files changed, 426 insertions(+), 84 deletions(-)  rename

drivers/ntb/{ntb_hw.c => ntb_hw_intel.c} (94%) create mode 100644 drivers/ntb/ntb_hw_intel.h rename drivers/ntb/{ntb_regs.h => ntb_regs_intel.h} (100%)

--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#8 lore raw
Quoted 7 lines · Rajat Jain

Thanks for this effort. I also have a PLX NT bridge that I was exploring to add support for. This will definitely make it easier.

Just curious, do you have any kind of NT bridge hardware that you want to add support for?

That would be IDT hardware.

virtually yours
Gerhard Sittig

Signature · 3 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]
#6 lore raw
In reply to Gerhard Sittig

[ adjusted Jon Mason's email address ]

Quoted 9 lines · Gerhard Sittig
Quoted 6 lines · Gerhard Sittig

The current implementation of the PCI non-transparent bridge support exclusively supports Intel hardware. This series prepares for the introduction of other vendor's hardware support, by separating the generic 'data transport' driver from the specific 'hardware support' driver.

Quoted 5 lines

For the record: Email to Jon Mason, the original NTB driver author, bounced with SMTP error 550. The MAINTAINERS file's "NTB DRIVER" section might need an update. Is the address listed under "NETERION 10GbE DRIVERS" correct, or is it a coincidence that the name matches?

For the record: In personal conversation Jon acknowledged his new/other email address, that was listed in the MAINTAINERS file as well. The NTB entry should receive an update.

Jon is busy moving and changing jobs. Is there any other feedback, test results, opinions, requests, remarks?

virtually yours
Gerhard Sittig

Signature · 3 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: [email protected]