Skip to contentSkip to conversation

PCI-Express Non-Transparent Bridge Support

RFC Superseded Jon Mason 7 participants 26 messages Jul 30, 2012 – Aug 2, 2012

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
author
#1 lore raw

RFC v2 1/2 PCI-Express Non-Transparent Bridge Support

A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus connecting 2 systems, providing electrical isolation between the two subsystems. A non-transparent bridge is functionally similar to a transparent bridge except that both sides of the bridge have their own independent address domains. The host on one side of the bridge will not have the visibility of the complete memory or I/O space on the other side of the bridge. To communicate across the non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to the local system. Writes to these apertures are mirrored to memory on the remote system. Communications can also occur through the use of doorbell registers that initiate interrupts to the alternate domain, and scratch-pad registers accessible from both sides.

The NTB device driver is needed to configure these memory windows, doorbell, and scratch-pad registers as well as use them in such a way as they can be turned into a viable communication channel to the remote system. ntb_hw.[ch] determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away the underlying hardware to provide access and a common interface to the doorbell registers, scratch pads, and memory windows. These hardware interfaces are exported so that other, non-mainlined kernel drivers can access these. ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a communication channel(s) and provide a reliable way of transferring data from one side to the other, which it then exports so that "client" drivers can access them. These client drivers are used to provide a standard kernel interface (i.e., Ethernet device) to NTB, such that Linux can transfer data from one system to the other in a standard way.

---
 MAINTAINERS                 |    6 +
 drivers/Kconfig             |    2 +
 drivers/Makefile            |    1 +
 drivers/ntb/Kconfig         |   13 +
 drivers/ntb/Makefile        |    3 +
 drivers/ntb/ntb_hw.c        | 1178 ++++++++++++++++++++++++++++++++++++
 drivers/ntb/ntb_hw.h        |  206 +++++++
 drivers/ntb/ntb_regs.h      |  150 +++++
 drivers/ntb/ntb_transport.c | 1387 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ntb.h         |   92 +++
 10 files changed, 3038 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ntb/Kconfig
 create mode 100644 drivers/ntb/Makefile
 create mode 100644 drivers/ntb/ntb_hw.c
 create mode 100644 drivers/ntb/ntb_hw.h
 create mode 100644 drivers/ntb/ntb_regs.h
 create mode 100644 drivers/ntb/ntb_transport.c
 create mode 100644 include/linux/ntb.h
MAINTAINERS +6 -0
index bd45164..9d57552 100644
@@ -4844,6 +4844,12 @@ S:	Maintained
 F:	Documentation/scsi/NinjaSCSI.txt
 F:	drivers/scsi/nsp32*
 
+NTB DRIVER
+M:	Jon Mason <[email protected]>
+S:	Supported
+F:	drivers/ntb/
+F:	include/linux/ntb.h
+
 NTFS FILESYSTEM
 M:	Anton Altaparmakov <[email protected]>
 L:	[email protected]
drivers/Kconfig +2 -0
index bfc9186..ebc16d3 100644
@@ -148,4 +148,6 @@ source "drivers/iio/Kconfig"
 
 source "drivers/vme/Kconfig"
 
+source "drivers/ntb/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index 2ba29ff..39bba94 100644
@@ -137,3 +137,4 @@ obj-$(CONFIG_EXTCON)		+= extcon/
 obj-$(CONFIG_MEMORY)		+= memory/
 obj-$(CONFIG_IIO)		+= iio/
 obj-$(CONFIG_VME_BUS)		+= vme/
+obj-$(CONFIG_NTB)		+= ntb/
drivers/ntb/Kconfig new file +13 -0
new file mode 100644
index 0000000..f69df793
@@ -0,0 +1,13 @@
+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.
+
drivers/ntb/Makefile new file +3 -0
new file mode 100644
index 0000000..15cb59f
@@ -0,0 +1,3 @@
+obj-$(CONFIG_NTB) += ntb.o
+
+ntb-objs := ntb_hw.o ntb_transport.o
drivers/ntb/ntb_hw.c new file +1178 -0

1,178 lines not on this page · raw message

drivers/ntb/ntb_hw.h new file +206 -0

206 lines not on this page · raw message

drivers/ntb/ntb_regs.h new file +150 -0

150 lines not on this page · raw message

drivers/ntb/ntb_transport.c new file +1387 -0

1,387 lines not on this page · raw message

include/linux/ntb.h new file +92 -0

41 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.5.4

Part of the diff is not shown here. View the raw message.

maintainer
#2 lore raw
Quoted 27 lines · Jon Mason

A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus connecting 2 systems, providing electrical isolation between the two subsystems. A non-transparent bridge is functionally similar to a transparent bridge except that both sides of the bridge have their own independent address domains. The host on one side of the bridge will not have the visibility of the complete memory or I/O space on the other side of the bridge. To communicate across the non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to the local system. Writes to these apertures are mirrored to memory on the remote system. Communications can also occur through the use of doorbell registers that initiate interrupts to the alternate domain, and scratch-pad registers accessible from both sides.

The NTB device driver is needed to configure these memory windows, doorbell, and scratch-pad registers as well as use them in such a way as they can be turned into a viable communication channel to the remote system. ntb_hw.[ch] determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away the underlying hardware to provide access and a common interface to the doorbell registers, scratch pads, and memory windows. These hardware interfaces are exported so that other, non-mainlined kernel drivers can access these. ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a communication channel(s) and provide a reliable way of transferring data from one side to the other, which it then exports so that "client" drivers can access them. These client drivers are used to provide a standard kernel interface (i.e., Ethernet device) to NTB, such that Linux can transfer data from one system to the other in a standard way.

Quoted 11 lines
---
 MAINTAINERS                 |    6 +
 drivers/Kconfig             |    2 +
 drivers/Makefile            |    1 +
 drivers/ntb/Kconfig         |   13 +
 drivers/ntb/Makefile        |    3 +
 drivers/ntb/ntb_hw.c        | 1178 ++++++++++++++++++++++++++++++++++++
 drivers/ntb/ntb_hw.h        |  206 +++++++
 drivers/ntb/ntb_regs.h      |  150 +++++
 drivers/ntb/ntb_transport.c | 1387 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ntb.h         |   92 +++

Where will drivers for non-Intel NTBs fit in this hierarchy? It seems a bit presumptuous to claim the generic "ntb" names just for Intel devices.

author
#3 lore raw
Quoted 40 lines · Bjorn Helgaas
Quoted 27 lines · Jon Mason

A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus connecting 2 systems, providing electrical isolation between the two subsystems. A non-transparent bridge is functionally similar to a transparent bridge except that both sides of the bridge have their own independent address domains. The host on one side of the bridge will not have the visibility of the complete memory or I/O space on the other side of the bridge. To communicate across the non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to the local system. Writes to these apertures are mirrored to memory on the remote system. Communications can also occur through the use of doorbell registers that initiate interrupts to the alternate domain, and scratch-pad registers accessible from both sides.

The NTB device driver is needed to configure these memory windows, doorbell, and scratch-pad registers as well as use them in such a way as they can be turned into a viable communication channel to the remote system. ntb_hw.[ch] determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away the underlying hardware to provide access and a common interface to the doorbell registers, scratch pads, and memory windows. These hardware interfaces are exported so that other, non-mainlined kernel drivers can access these. ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a communication channel(s) and provide a reliable way of transferring data from one side to the other, which it then exports so that "client" drivers can access them. These client drivers are used to provide a standard kernel interface (i.e., Ethernet device) to NTB, such that Linux can transfer data from one system to the other in a standard way.

Quoted 11 lines
---
 MAINTAINERS                 |    6 +
 drivers/Kconfig             |    2 +
 drivers/Makefile            |    1 +
 drivers/ntb/Kconfig         |   13 +
 drivers/ntb/Makefile        |    3 +
 drivers/ntb/ntb_hw.c        | 1178 ++++++++++++++++++++++++++++++++++++
 drivers/ntb/ntb_hw.h        |  206 +++++++
 drivers/ntb/ntb_regs.h      |  150 +++++
 drivers/ntb/ntb_transport.c | 1387 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ntb.h         |   92 +++
Quoted 3 lines

Where will drivers for non-Intel NTBs fit in this hierarchy? It seems a bit presumptuous to claim the generic "ntb" names just for Intel devices.

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Thanks,
Jon

#4 lore raw
Quoted 8 lines

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

In ntb_process_tx(), ntb uses hard-coding 'memcpy_toio' to copy data
to remote.
Is it better to provide a function pointer like 'tx()' and call qp->tx(). memcpy_toio is a slow operation. Some hardware can setup a dma
transfer and wait.

IMHO, the best way is to handle tx in async mode. But it requires
lots of modification.

author
#5 lore raw
Quoted 8 lines · Jianbin Kang
Quoted 8 lines

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Quoted 8 lines

In ntb_process_tx(), ntb uses hard-coding 'memcpy_toio' to copy data
to remote.
Is it better to provide a function pointer like 'tx()' and call qp->tx(). memcpy_toio is a slow operation. Some hardware can setup a dma
transfer and wait.

IMHO, the best way is to handle tx in async mode. But it requires
lots of modification.

Actually this is what I'm working on now, using async_tx to replace the memcpy. I believe the changes shouldn't be that significant.

Is the "hardware that can setup dma" you refer to something that does not use this interface?

Thanks,
Jon

#6 lore raw
Quoted 6 lines

Actually this is what I'm working on now, using async_tx to replace the memcpy. I believe the changes shouldn't be that significant.

Is the "hardware that can setup dma" you refer to something that does not use this interface?

Yes, they use this interface, but split 'memcpy_toio' to two operation:
1. setup dma
2. wait/poll for the dma to finish.
So maybe it need to provide a generic function 'tx' for different hardwares.

If async_tx is available, it's much better than this 'sync dma/memcpy'. One problem with async_tx is, it can't detect memcpy error. If the remote ntb goes down when async_memcpy is in operation, async_tx will trigger an oops.

maintainer
#7 lore raw
Quoted 12 lines · Jianbin Kang
Quoted 6 lines

Actually this is what I'm working on now, using async_tx to replace the memcpy. I believe the changes shouldn't be that significant.

Is the "hardware that can setup dma" you refer to something that does not use this interface?

Yes, they use this interface, but split 'memcpy_toio' to two operation:
1. setup dma
2. wait/poll for the dma to finish.
So maybe it need to provide a generic function 'tx' for different hardwares.

It's not worth it to do sync DMA. The performance is terrible.

Quoted 4 lines

If async_tx is available, it's much better than this 'sync dma/memcpy'. One problem with async_tx is, it can't detect memcpy error. If the remote ntb goes down when async_memcpy is in operation, async_tx will trigger an oops.

Yes that is something that needs to be addressed when we get async DMA support working.

maintainer
#8 lore raw
In reply to Jon Mason
Quoted 45 lines · Jon Mason
Quoted 40 lines · Bjorn Helgaas
Quoted 27 lines · Jon Mason

A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus connecting 2 systems, providing electrical isolation between the two subsystems. A non-transparent bridge is functionally similar to a transparent bridge except that both sides of the bridge have their own independent address domains. The host on one side of the bridge will not have the visibility of the complete memory or I/O space on the other side of the bridge. To communicate across the non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to the local system. Writes to these apertures are mirrored to memory on the remote system. Communications can also occur through the use of doorbell registers that initiate interrupts to the alternate domain, and scratch-pad registers accessible from both sides.

The NTB device driver is needed to configure these memory windows, doorbell, and scratch-pad registers as well as use them in such a way as they can be turned into a viable communication channel to the remote system. ntb_hw.[ch] determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away the underlying hardware to provide access and a common interface to the doorbell registers, scratch pads, and memory windows. These hardware interfaces are exported so that other, non-mainlined kernel drivers can access these. ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a communication channel(s) and provide a reliable way of transferring data from one side to the other, which it then exports so that "client" drivers can access them. These client drivers are used to provide a standard kernel interface (i.e., Ethernet device) to NTB, such that Linux can transfer data from one system to the other in a standard way.

Quoted 11 lines
---
 MAINTAINERS                 |    6 +
 drivers/Kconfig             |    2 +
 drivers/Makefile            |    1 +
 drivers/ntb/Kconfig         |   13 +
 drivers/ntb/Makefile        |    3 +
 drivers/ntb/ntb_hw.c        | 1178 ++++++++++++++++++++++++++++++++++++
 drivers/ntb/ntb_hw.h        |  206 +++++++
 drivers/ntb/ntb_regs.h      |  150 +++++
 drivers/ntb/ntb_transport.c | 1387 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ntb.h         |   92 +++
Quoted 3 lines

Where will drivers for non-Intel NTBs fit in this hierarchy? It seems a bit presumptuous to claim the generic "ntb" names just for Intel devices.

Quoted 8 lines

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

That makes sense from a technical point of view, but I think it's going to cause maintenance issues. For example, assume PLX NTB support is added. Will PLX be happy about having to convince you to accept changes? Will Intel be happy about having to release a new driver for their hardware just to incorporate a PLX bug fix? Will users of PLX hardware accept a new driver release that only benefits Intel users?

#9 lore raw
Quoted 11 lines · Bjorn Helgaas
Quoted 9 lines · Jon Mason

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Quoted 4 lines

That makes sense from a technical point of view, but I think it's going to cause maintenance issues. For example, assume PLX NTB support is added. Will PLX be happy about having to convince you to accept changes? Will Intel be happy about having to release a new

Do you mean convince Intel? Well, if we think of ntb as the class driver then the onus is on the community to vet the changes and NOT intel.
And since this is the first NTB part for which the support is introduced the class driver design could be a moving target. As someone else mentioned, the async/sync tx-dma is another hook that could change the class driver's design.

Quoted 3 lines

driver for their hardware just to incorporate a PLX bug fix? Will users of PLX hardware accept a new driver release that only benefits Intel users?

May be till the class driver is stable, the client(intel/PLX) drivers might have to be modified. This is a cue for other vendors to chime-in and review this design?
Just thinking if this could sit in staging for some time(so that others get a chance to review/suggest changes as well) and then get promoted out of staging.

Chetan Loke

maintainer
#10 lore raw
Quoted 12 lines · chetan loke
Quoted 11 lines · Bjorn Helgaas
Quoted 9 lines · Jon Mason

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Quoted 8 lines
Quoted 4 lines

That makes sense from a technical point of view, but I think it's going to cause maintenance issues. For example, assume PLX NTB support is added. Will PLX be happy about having to convince you to accept changes? Will Intel be happy about having to release a new

Do you mean convince Intel? Well, if we think of ntb as the class driver then the onus is on the community to vet the changes and NOT intel.

No, I said convince "you," meaning *Jon*. Intel doesn't apply patches. "The community" doesn't apply patches. Jon applies patches.
This has nothing to do with the fact that Jon is employed by Intel.
The point is that when you have multiple organizations involved, they have different goals, markets, customers, and schedules. If one module contains both Intel-specific and PLX-specific things, that's a place where these organizational differences may cause issues, regardless of who is applying the patches.

Obviously it's not a problem now, and maybe it will never be. But I think there's a possibility. Since I have no direct interest in any of these devices, I'm only raising that possibility, not trying to force any particular direction.

author
#11 lore raw
In reply to chetan loke
Quoted 30 lines · chetan loke
Quoted 11 lines · Bjorn Helgaas
Quoted 9 lines · Jon Mason

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Quoted 4 lines

That makes sense from a technical point of view, but I think it's going to cause maintenance issues. For example, assume PLX NTB support is added. Will PLX be happy about having to convince you to accept changes? Will Intel be happy about having to release a new

Do you mean convince Intel? Well, if we think of ntb as the class driver then the onus is on the community to vet the changes and NOT intel.
And since this is the first NTB part for which the support is introduced the class driver design could be a moving target. As someone else mentioned, the async/sync tx-dma is another hook that could change the class driver's design.

Quoted 3 lines

driver for their hardware just to incorporate a PLX bug fix? Will users of PLX hardware accept a new driver release that only benefits Intel users?

Quoted 6 lines

May be till the class driver is stable, the client(intel/PLX) drivers might have to be modified. This is a cue for other vendors to chime-in and review this design?
Just thinking if this could sit in staging for some time(so that others get a chance to review/suggest changes as well) and then get promoted out of staging.

I don't see the benefit of having the driver in staging. Any vendors who would notice the ntb driver in staging would be sitting on these mailing lists and hopefully have planety of comments on the design. Stashing the driver in staging while waiting for these comments (which may never come) doesn't seem the best course of action.

Thanks,
Jon

Quoted 2 lines

Chetan Loke

#12 lore raw
Quoted 7 lines · Jon Mason

I don't see the benefit of having the driver in staging. Any vendors who would notice the ntb driver in staging would be sitting on these mailing lists and hopefully have planety of comments on the design. Stashing the driver in staging while waiting for these comments (which may never come) doesn't seem the best course of action.

I thought that since others are talking about it then may be there is some WIP code for foo-NTB. Seems like that's not the case. So no need to stage.

Correct me if I'm wrong but wouldn't apps just open a socket and route data via ntb_vir_eth_dev? So I don't see an ABI breakage issue and hence nothing would prevent us from changing the kernel parts(for accommodating some foo-NTB part) in future.

It may not be a bad idea to prefix intel-specific(if any) ntb_structs/variables/logic with the 'intc'(Intel ticker or pick your string) keyword.

Chetan Loke

author
#13 lore raw
Quoted 9 lines · chetan loke
Quoted 7 lines · Jon Mason

I don't see the benefit of having the driver in staging. Any vendors who would notice the ntb driver in staging would be sitting on these mailing lists and hopefully have planety of comments on the design. Stashing the driver in staging while waiting for these comments (which may never come) doesn't seem the best course of action.

Quoted 8 lines

I thought that since others are talking about it then may be there is some WIP code for foo-NTB. Seems like that's not the case. So no need to stage.

Correct me if I'm wrong but wouldn't apps just open a socket and route data via ntb_vir_eth_dev? So I don't see an ABI breakage issue and hence nothing would prevent us from changing the kernel parts(for accommodating some foo-NTB part) in future.

The virtual ethernet device (patch #2) would allow for a generic way of passing data to the remote side. The only issue would be changing how it is encoded in the shared buffer.

Quoted 3 lines

It may not be a bad idea to prefix intel-specific(if any) ntb_structs/variables/logic with the 'intc'(Intel ticker or pick your string) keyword.

The Intel specific things are current pre-pended with "xeon" or "bwd".

Thanks,
Jon

Quoted 2 lines

Chetan Loke

author
#14 lore raw
In reply to Bjorn Helgaas
Quoted 55 lines · Bjorn Helgaas
Quoted 45 lines · Jon Mason
Quoted 40 lines · Bjorn Helgaas
Quoted 27 lines · Jon Mason

A PCI-Express non-transparent bridge (NTB) is a point-to-point PCIe bus connecting 2 systems, providing electrical isolation between the two subsystems. A non-transparent bridge is functionally similar to a transparent bridge except that both sides of the bridge have their own independent address domains. The host on one side of the bridge will not have the visibility of the complete memory or I/O space on the other side of the bridge. To communicate across the non-transparent bridge, each NTB endpoint has one (or more) apertures exposed to the local system. Writes to these apertures are mirrored to memory on the remote system. Communications can also occur through the use of doorbell registers that initiate interrupts to the alternate domain, and scratch-pad registers accessible from both sides.

The NTB device driver is needed to configure these memory windows, doorbell, and scratch-pad registers as well as use them in such a way as they can be turned into a viable communication channel to the remote system. ntb_hw.[ch] determines the usage model (NTB to NTB or NTB to Root Port) and abstracts away the underlying hardware to provide access and a common interface to the doorbell registers, scratch pads, and memory windows. These hardware interfaces are exported so that other, non-mainlined kernel drivers can access these. ntb_transport.[ch] also uses the exported interfaces in ntb_hw.[ch] to setup a communication channel(s) and provide a reliable way of transferring data from one side to the other, which it then exports so that "client" drivers can access them. These client drivers are used to provide a standard kernel interface (i.e., Ethernet device) to NTB, such that Linux can transfer data from one system to the other in a standard way.

Quoted 11 lines
---
 MAINTAINERS                 |    6 +
 drivers/Kconfig             |    2 +
 drivers/Makefile            |    1 +
 drivers/ntb/Kconfig         |   13 +
 drivers/ntb/Makefile        |    3 +
 drivers/ntb/ntb_hw.c        | 1178 ++++++++++++++++++++++++++++++++++++
 drivers/ntb/ntb_hw.h        |  206 +++++++
 drivers/ntb/ntb_regs.h      |  150 +++++
 drivers/ntb/ntb_transport.c | 1387 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/ntb.h         |   92 +++
Quoted 3 lines

Where will drivers for non-Intel NTBs fit in this hierarchy? It seems a bit presumptuous to claim the generic "ntb" names just for Intel devices.

Quoted 8 lines

I've tried to make it all generic enough that non-Intel NTBs should plug in with minimal changes to ntb_hw.c. If their design is too divergent, then a slight redesign of ntb_hw.c might be necessary. But from what I've seen of other designs on the internet, they appear to be extremely similar. The transport and client drivers were written with the hardware abstracted away as much as possible to prevent the need to modify it for different hardware. If there is anything which is Intel hardware specific, I'd be happy to change it to make it more generic.

Quoted 7 lines

That makes sense from a technical point of view, but I think it's going to cause maintenance issues. For example, assume PLX NTB support is added. Will PLX be happy about having to convince you to accept changes? Will Intel be happy about having to release a new driver for their hardware just to incorporate a PLX bug fix? Will users of PLX hardware accept a new driver release that only benefits Intel users?

Firstly, I don't believe this is an issue. The amount of hardware specific code is small (<150 loc), and the design of the PLX hardware appears to be the same as Intel (from what I've read on the internet).

Assuming Intel is me, I am always happy to do whatever I can to help PLX or any other NTB vendor. I am willing to make internal releases (which I am assuming is the issue you are referring to) for any change to the driver.

If necessary, refactoring the driver shouldn't be a significant issue. However, I would prefer to do it if/when another NTB driver wants to be added. PLX (and those who are using their NTB hardware) hasn't pushed an NTB driver yet, and may never (as their design docs on the web are from '05). Why complicate the driver for them if they never come?

Thanks,
Jon

#15 lore raw
In reply to Jon Mason

On Sun, Jul 29, 2012 at 8:26 PM, Jon Mason <[email protected]> wrote:

<snip>

Quoted 25 lines
drivers/ntb/ntb_transport.c new file +25 -0
+static void ntb_tx_copy_task(struct ntb_transport_qp *qp,
+                            struct ntb_queue_entry *entry,
+                            void *offset)
+{
+       struct ntb_payload_header *hdr = offset;
+
+       offset += sizeof(struct ntb_payload_header);
+       memcpy_toio(offset, entry->buf, entry->len);
+
+       hdr->len = entry->len;
+       hdr->ver = qp->tx_pkts;
+
+       /* Ensure that the data is fully copied out before setting the flag */
+       wmb();
+       hdr->flags = entry->flags | DESC_DONE_FLAG;
+
+       ntb_ring_sdb(qp->ndev, qp->qp_num);
+
+       /* The entry length can only be zero if the packet is intended to be a
+        * "link down" or similar.  Since no payload is being sent in these
+        * cases, there is nothing to add to the completion queue.
+        */
+       if (entry->len > 0) {
+               qp->tx_bytes += entry->len;
+

drivers/ntb/ntb_transport.c line 819

Quoted 10 lines
drivers/ntb/ntb_transport.c new file +10 -0
+               /* Add fully transmitted data to completion queue */
+               ntb_list_add_tail(&qp->ntb_tx_comp_q_lock, &entry->entry,
+                                 &qp->tx_comp_q);
+
+               if (qp->tx_handler)
+                       qp->tx_handler(qp->cb_data, qp);
+       } else
+               ntb_list_add_tail(&qp->ntb_tx_free_q_lock, &entry->entry,
+                                 &qp->tx_free_q);
+}

I know you talked about a fixed array. But it's not here yet. So at all the call-sites, for [r/t]x_free_q , add the 'entry' to the head - change to ntb_list_add_head here and else where.

Chetan Loke

#16 lore raw
In reply to Jon Mason
Quoted 3 lines · Jon Mason
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

You really are going to track the FSF's office movements for the next 40+ years?

Quoted 2 lines

+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.

No it isn't, this sentance is totally wrong for any in-kernel code, please remove it.

Also do the same for all the other files you added please.

greg k-h

author
#17 lore raw
Quoted 8 lines · Greg KH
Quoted 3 lines · Jon Mason
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

You really are going to track the FSF's office movements for the next 40+ years?

Quoted 7 lines
Quoted 2 lines

+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.

No it isn't, this sentance is totally wrong for any in-kernel code, please remove it.

Also do the same for all the other files you added please.

I echo'ed your original comments on this to Intel Legal and am waiting on a response. I 100% agree, but I need their signoff first.

It is worth noting that this version of the license is already in the kernel in numerous other drivers:
drivers/sfi/*
drivers/scsi/isci/*
drivers/dma/ioat/dma_v3.c
drivers/net/wireless/iwlwifi/* drivers/net/wireless/iwlegacy/*

Thanks,
Jon

Quoted 2 lines

greg k-h

#18 lore raw
Quoted 20 lines · Jon Mason
Quoted 8 lines · Greg KH
Quoted 3 lines · Jon Mason
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

You really are going to track the FSF's office movements for the next 40+ years?

Quoted 7 lines
Quoted 2 lines

+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.

No it isn't, this sentance is totally wrong for any in-kernel code, please remove it.

Also do the same for all the other files you added please.

I echo'ed your original comments on this to Intel Legal and am waiting on a response. I 100% agree, but I need their signoff first.

Quoted 7 lines

It is worth noting that this version of the license is already in the kernel in numerous other drivers:
drivers/sfi/*
drivers/scsi/isci/*
drivers/dma/ioat/dma_v3.c
drivers/net/wireless/iwlwifi/* drivers/net/wireless/iwlegacy/*

Just because others got it wrong, doesn't mean you need to continue to :)

greg k-h

#19 lore raw
In reply to Jon Mason

include/linux/ntb.h line 66

Quoted 7 lines · Jon Mason
include/linux/ntb.h new file +7 -0
+struct ntb_transport_qp;
+
+struct ntb_client {
+	char *name;
+	int (*probe) (struct pci_dev *pdev);
+	void (*remove) (struct pci_dev *pdev);
+};

Why isn't this tied into the driver model? That looks like you really want to use a 'struct device' here, right?

Then you have drivers that bind to them, and your devices show up in sysfs, which is probably a requirement you have, right?

greg k-h

author
#20 lore raw
Quoted 12 lines · Greg KH

include/linux/ntb.h line 66

Quoted 7 lines · Jon Mason
include/linux/ntb.h new file +7 -0
+struct ntb_transport_qp;
+
+struct ntb_client {
+	char *name;
+	int (*probe) (struct pci_dev *pdev);
+	void (*remove) (struct pci_dev *pdev);
+};

Why isn't this tied into the driver model? That looks like you really want to use a 'struct device' here, right?

Quoted 2 lines

Then you have drivers that bind to them, and your devices show up in sysfs, which is probably a requirement you have, right?

I was trying to do something more light-weight than that and avoid the complexity, but this is probably the direction it needs to go.

Thanks,
Jon

Quoted 2 lines

greg k-h

author
#21 lore raw

RFC v2 2/2 net: Add support for NTB virtual ethernet device

In reply to Jon Mason

A virtual ethernet device that uses the NTB transport API to send/receive data.

---
 drivers/net/Kconfig      |    4 +
 drivers/net/Makefile     |    1 +
 drivers/net/ntb_netdev.c |  417 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 422 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ntb_netdev.c
drivers/net/Kconfig +4 -0
index 0c2bd80..9bf8a71 100644
@@ -178,6 +178,10 @@ config NETPOLL_TRAP
 config NET_POLL_CONTROLLER
 	def_bool NETPOLL
 
+config NTB_NETDEV
+	tristate "Virtual Ethernet over NTB"
+	depends on NTB
+
 config RIONET
 	tristate "RapidIO Ethernet over messaging driver support"
 	depends on RAPIDIO
drivers/net/Makefile +1 -0
index 3d375ca..9890148 100644
@@ -69,3 +69,4 @@ obj-$(CONFIG_USB_IPHETH)        += usb/
 obj-$(CONFIG_USB_CDC_PHONET)   += usb/
 
 obj-$(CONFIG_HYPERV_NET) += hyperv/
+obj-$(CONFIG_NTB_NETDEV) += ntb_netdev.o
drivers/net/ntb_netdev.c new file +417 -0

417 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#22 lore raw

Re: [RFC v2 2/2] net: Add support for NTB virtual ethernet device

Quoted 7 lines · Mon, Jul 30, 2012 at 02:26:34AM CEST, [email protected] wrote:
drivers/net/ntb_netdev.c new file +7 -0
+static int __devinit ntb_netdev_probe(struct pci_dev *pdev)
+{
+	struct net_device *ndev;
+	struct ntb_netdev *dev;
+	int rc;
+
+	ndev = alloc_etherdev(sizeof(struct ntb_netdev));

drivers/net/ntb_netdev.c line 345

Quoted 10 lines
drivers/net/ntb_netdev.c new file +10 -0
+	if (!ndev)
+		return -ENOMEM;
+
+	dev = netdev_priv(ndev);
+	dev->ndev = ndev;
+	dev->pdev = pdev;
+	BUG_ON(!dev->pdev);
+	ndev->features = NETIF_F_HIGHDMA;
+
+	//ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;

^^ I guess you forgot to un-comment this.

author
#23 lore raw

Re: [RFC v2 2/2] net: Add support for NTB virtual ethernet device

Quoted 11 lines · Jiri Pirko
Quoted 10 lines · Mon, Jul 30, 2012 at 02:26:34AM CEST, [email protected] wrote:
drivers/net/ntb_netdev.c new file +10 -0
+static int __devinit ntb_netdev_probe(struct pci_dev *pdev)
+{
+	struct net_device *ndev;
+	struct ntb_netdev *dev;
+	int rc;
+
+	ndev = alloc_etherdev(sizeof(struct ntb_netdev));
+	if (!ndev)
+		return -ENOMEM;
+
Quoted 8 lines

drivers/net/ntb_netdev.c line 345

Quoted 7 lines
drivers/net/ntb_netdev.c new file +7 -0
+	dev = netdev_priv(ndev);
+	dev->ndev = ndev;
+	dev->pdev = pdev;
+	BUG_ON(!dev->pdev);
+	ndev->features = NETIF_F_HIGHDMA;
+
+	//ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;

^^ I guess you forgot to un-comment this.

Oops. An easy fix. Anything else?

Thanks,
Jon

#24 lore raw

Re: [RFC v2 2/2] net: Add support for NTB virtual ethernet device

Quoted 21 lines · Mon, Jul 30, 2012 at 08:19:11PM CEST, [email protected] wrote:
Quoted 11 lines · Jiri Pirko
Quoted 10 lines · Mon, Jul 30, 2012 at 02:26:34AM CEST, [email protected] wrote:
drivers/net/ntb_netdev.c new file +10 -0
+static int __devinit ntb_netdev_probe(struct pci_dev *pdev)
+{
+	struct net_device *ndev;
+	struct ntb_netdev *dev;
+	int rc;
+
+	ndev = alloc_etherdev(sizeof(struct ntb_netdev));
+	if (!ndev)
+		return -ENOMEM;
+
Quoted 8 lines

drivers/net/ntb_netdev.c line 345

Quoted 7 lines
drivers/net/ntb_netdev.c new file +7 -0
+	dev = netdev_priv(ndev);
+	dev->ndev = ndev;
+	dev->pdev = pdev;
+	BUG_ON(!dev->pdev);
+	ndev->features = NETIF_F_HIGHDMA;
+
+	//ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;

^^ I guess you forgot to un-comment this.

Quoted 1 line

Oops. An easy fix. Anything else?

The rest looks good to me.

Quoted 3 lines

Thanks,
Jon

#25 lore raw

Re: [RFC v2 2/2] net: Add support for NTB virtual ethernet device

In reply to Jon Mason
Quoted 15 lines · Jon Mason

A virtual ethernet device that uses the NTB transport API to send/receive data.

---
 drivers/net/Kconfig      |    4 +
 drivers/net/Makefile     |    1 +
 drivers/net/ntb_netdev.c |  417 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 422 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/ntb_netdev.c
drivers/net/Kconfig +0 -0
index 0c2bd80..9bf8a71 100644

drivers/net/Kconfig config NETPOLL_TRAP · line 183

Quoted 6 lines
drivers/net/Kconfig +3 -0
@@ -178,6 +178,10 @@ config NETPOLL_TRAP
 config NET_POLL_CONTROLLER
 	def_bool NETPOLL
 
+config NTB_NETDEV
+	tristate "Virtual Ethernet over NTB"
+	depends on NTB

How will this module be auto-loaded by a distro? You need some way to detect this device on the "bus" right? What is that method? And why isn't it hooked up to the "traditional" method the kernel uses to determine this?

Don't expect distros to just always load this module, that's not going to work, sorry.

greg k-h