Skip to contentSkip to conversation

thunderbolt: Introducing Thunderbolt(TM) Networking

PATCH Superseded Amir Levy 7 participants 20 messages Sep 28, 2016 – Dec 20, 2016

Subsystems (5)

v8 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Amir Levy

author
#0 lore raw

v8 cover thunderbolt: Introducing Thunderbolt(TM) Networking

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Thunderbolt Networking provides peer-to-peer connections to transfer files between computers, perform PC migrations, and/or set up small workgroups with shared storage.

This is a virtual connection that emulates an Ethernet adapter that enables Ethernet networking with the benefit of Thunderbolt superfast medium capability.

Thunderbolt Networking enables two hosts and several devices that have a Thunderbolt controller to be connected together in a linear (Daisy chain) series from a single port.

Thunderbolt Networking for Linux is compatible with Thunderbolt Networking on systems running macOS or Windows and also supports Thunderbolt generation 2 and 3 controllers.

Note that all pre-existing Thunderbolt generation 3 features, such as USB, Display and other Thunderbolt device connectivity will continue to function exactly as they did prior to enabling Thunderbolt Networking.

Code and Software Specifications:
This kernel code creates a virtual ethernet device for computer to computer communication over a Thunderbolt cable.
The new driver is a separate driver to the existing Thunderbolt driver. It is designed to work on systems running Linux that interface with Intel Connection Manager (ICM) firmware based Thunderbolt controllers that support Thunderbolt Networking. The kernel code operates in coordination with the Thunderbolt user- space daemon to implement full Thunderbolt networking functionality.

Hardware Specifications:
Thunderbolt Hardware specs have not yet been published but are used where necessary for register definitions.

Changes since v7:
- Removed debug prints
- Edited error prints
- Edited copyright notice
- Changed the Kconfig patch to be after the code changes

These patches were pushed to GitHub where they can be reviewed more comfortably with green/red highlighting:
https://github.com/01org/thunderbolt-software-kernel-tree

Daemon code:
https://github.com/01org/thunderbolt-software-daemon

For reference, here's a link to version 6:
[v7]: https://lkml.org/lkml/2016/9/27/244

Amir Levy (8):
thunderbolt: Macro rename
thunderbolt: Updating the register definitions
thunderbolt: Communication with the ICM (firmware)
thunderbolt: Networking state machine
thunderbolt: Networking transmit and receive
thunderbolt: Kconfig for Thunderbolt Networking
thunderbolt: Networking doc
thunderbolt: Adding maintainer entry

 Documentation/00-INDEX                   |    2 +
 Documentation/thunderbolt/networking.txt |  132 ++
 MAINTAINERS                              |    8 +-
 drivers/thunderbolt/Kconfig              |   27 +-
 drivers/thunderbolt/Makefile             |    3 +-
 drivers/thunderbolt/icm/Makefile         |    2 +
 drivers/thunderbolt/icm/icm_nhi.c        | 1514 ++++++++++++++++++++
 drivers/thunderbolt/icm/icm_nhi.h        |   82 ++
 drivers/thunderbolt/icm/net.c            | 2254 ++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm/net.h            |  287 ++++
 drivers/thunderbolt/nhi_regs.h           |  115 +-
 11 files changed, 4417 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/thunderbolt/networking.txt
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.c
 create mode 100644 drivers/thunderbolt/icm/net.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v8 1/8 thunderbolt: Macro rename

This first patch updates the NHI Thunderbolt controller registers file to reflect that it is not only for Cactus Ridge.
No functional change intended.

---
 drivers/thunderbolt/nhi_regs.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/thunderbolt/nhi_regs.h +3 -3
index 86b996c..75cf069 100644
@@ -1,11 +1,11 @@
 /*
- * Thunderbolt Cactus Ridge driver - NHI registers
+ * Thunderbolt driver - NHI registers
  *
  * Copyright (c) 2014 Andreas Noever <[email protected]>
  */
 
-#ifndef DSL3510_REGS_H_
-#define DSL3510_REGS_H_
+#ifndef NHI_REGS_H_
+#define NHI_REGS_H_
 
 #include <linux/types.h>
 
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH v8 2/8 thunderbolt: Updating the register definitions

In reply to Amir Levy

Adding more Thunderbolt(TM) register definitions
and some helper macros.

---
 drivers/thunderbolt/nhi_regs.h | 109 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/thunderbolt/nhi_regs.h +109 -0
index 75cf069..b8e961f 100644
@@ -9,6 +9,11 @@
 
 #include <linux/types.h>
 
+#define NHI_MMIO_BAR 0
+
+#define TBT_RING_MIN_NUM_BUFFERS	2
+#define TBT_RING_MAX_FRAME_SIZE		(4 * 1024)
+
 enum ring_flags {
 	RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
 	RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
@@ -39,6 +44,33 @@ struct ring_desc {
 	u32 time; /* write zero */
 } __packed;
 
+/**
+ * struct tbt_buf_desc - TX/RX ring buffer descriptor.
+ * This is same as struct ring_desc, but without the use of bitfields and
+ * with explicit endianity.
+ */
+struct tbt_buf_desc {
+	__le64 phys;
+	__le32 attributes;
+	__le32 time;
+};
+
+#define DESC_ATTR_LEN_SHIFT		0
+#define DESC_ATTR_LEN_MASK		GENMASK(11, DESC_ATTR_LEN_SHIFT)
+#define DESC_ATTR_EOF_SHIFT		12
+#define DESC_ATTR_EOF_MASK		GENMASK(15, DESC_ATTR_EOF_SHIFT)
+#define DESC_ATTR_SOF_SHIFT		16
+#define DESC_ATTR_SOF_MASK		GENMASK(19, DESC_ATTR_SOF_SHIFT)
+#define DESC_ATTR_TX_ISOCH_DMA_EN	BIT(20)	/* TX */
+#define DESC_ATTR_RX_CRC_ERR		BIT(20)	/* RX after use */
+#define DESC_ATTR_DESC_DONE		BIT(21)
+#define DESC_ATTR_REQ_STS		BIT(22)	/* TX and RX before use */
+#define DESC_ATTR_RX_BUF_OVRN_ERR	BIT(22)	/* RX after use */
+#define DESC_ATTR_INT_EN		BIT(23)
+#define DESC_ATTR_OFFSET_SHIFT		24
+#define DESC_ATTR_OFFSET_MASK		GENMASK(31, DESC_ATTR_OFFSET_SHIFT)
+
+
 /* NHI registers in bar 0 */
 
 /*
@@ -60,6 +92,30 @@ struct ring_desc {
  */
 #define REG_RX_RING_BASE	0x08000
 
+#define REG_RING_STEP			16
+#define REG_RING_PHYS_LO_OFFSET		0
+#define REG_RING_PHYS_HI_OFFSET		4
+#define REG_RING_CONS_PROD_OFFSET	8	/* cons - RO, prod - RW */
+#define REG_RING_CONS_SHIFT		0
+#define REG_RING_CONS_MASK		GENMASK(15, REG_RING_CONS_SHIFT)
+#define REG_RING_PROD_SHIFT		16
+#define REG_RING_PROD_MASK		GENMASK(31, REG_RING_PROD_SHIFT)
+#define REG_RING_SIZE_OFFSET		12
+#define REG_RING_SIZE_SHIFT		0
+#define REG_RING_SIZE_MASK		GENMASK(15, REG_RING_SIZE_SHIFT)
+#define REG_RING_BUF_SIZE_SHIFT		16
+#define REG_RING_BUF_SIZE_MASK		GENMASK(27, REG_RING_BUF_SIZE_SHIFT)
+
+#define TBT_RING_CONS_PROD_REG(iobase, ringbase, ringnumber) \
+			      ((iobase) + (ringbase) + \
+			      ((ringnumber) * REG_RING_STEP) + \
+			      REG_RING_CONS_PROD_OFFSET)
+
+#define TBT_REG_RING_PROD_EXTRACT(val) (((val) & REG_RING_PROD_MASK) >> \
+				       REG_RING_PROD_SHIFT)
+
+#define TBT_REG_RING_CONS_EXTRACT(val) (((val) & REG_RING_CONS_MASK) >> \
+				       REG_RING_CONS_SHIFT)
 /*
  * 32 bytes per entry, one entry for every hop (REG_HOP_COUNT)
  * 00: enum_ring_flags
@@ -77,6 +133,19 @@ struct ring_desc {
  * ..: unknown
  */
 #define REG_RX_OPTIONS_BASE	0x29800
+#define REG_RX_OPTS_TX_E2E_HOP_ID_SHIFT	12
+#define REG_RX_OPTS_TX_E2E_HOP_ID_MASK	\
+				GENMASK(22, REG_RX_OPTS_TX_E2E_HOP_ID_SHIFT)
+#define REG_RX_OPTS_MASK_OFFSET		4
+#define REG_RX_OPTS_MASK_EOF_SHIFT	0
+#define REG_RX_OPTS_MASK_EOF_MASK	GENMASK(15, REG_RX_OPTS_MASK_EOF_SHIFT)
+#define REG_RX_OPTS_MASK_SOF_SHIFT	16
+#define REG_RX_OPTS_MASK_SOF_MASK	GENMASK(31, REG_RX_OPTS_MASK_SOF_SHIFT)
+
+#define REG_OPTS_STEP			32
+#define REG_OPTS_E2E_EN			BIT(28)
+#define REG_OPTS_RAW			BIT(30)
+#define REG_OPTS_VALID			BIT(31)
 
 /*
  * three bitfields: tx, rx, rx overflow
@@ -86,6 +155,7 @@ struct ring_desc {
  */
 #define REG_RING_NOTIFY_BASE	0x37800
 #define RING_NOTIFY_REG_COUNT(nhi) ((31 + 3 * nhi->hop_count) / 32)
+#define REG_RING_NOTIFY_STEP	4
 
 /*
  * two bitfields: rx, tx
@@ -94,8 +164,47 @@ struct ring_desc {
  */
 #define REG_RING_INTERRUPT_BASE	0x38200
 #define RING_INTERRUPT_REG_COUNT(nhi) ((31 + 2 * nhi->hop_count) / 32)
+#define REG_RING_INT_TX_PROCESSED(ring_num)		BIT(ring_num)
+#define REG_RING_INT_RX_PROCESSED(ring_num, num_paths)	BIT((ring_num) + \
+							    (num_paths))
+#define RING_INT_DISABLE(base, val) iowrite32( \
+			ioread32((base) + REG_RING_INTERRUPT_BASE) & ~(val), \
+			(base) + REG_RING_INTERRUPT_BASE)
+#define RING_INT_ENABLE(base, val) iowrite32( \
+			ioread32((base) + REG_RING_INTERRUPT_BASE) | (val), \
+			(base) + REG_RING_INTERRUPT_BASE)
+#define RING_INT_DISABLE_TX(base, ring_num) \
+	RING_INT_DISABLE(base, REG_RING_INT_TX_PROCESSED(ring_num))
+#define RING_INT_DISABLE_RX(base, ring_num, num_paths) \
+	RING_INT_DISABLE(base, REG_RING_INT_RX_PROCESSED(ring_num, num_paths))
+#define RING_INT_ENABLE_TX(base, ring_num) \
+	RING_INT_ENABLE(base, REG_RING_INT_TX_PROCESSED(ring_num))
+#define RING_INT_ENABLE_RX(base, ring_num, num_paths) \
+	RING_INT_ENABLE(base, REG_RING_INT_RX_PROCESSED(ring_num, num_paths))
+#define RING_INT_DISABLE_TX_RX(base, ring_num, num_paths) \
+	RING_INT_DISABLE(base, REG_RING_INT_TX_PROCESSED(ring_num) | \
+			       REG_RING_INT_RX_PROCESSED(ring_num, num_paths))
+
+#define REG_RING_INTERRUPT_STEP	4
+
+#define REG_INT_THROTTLING_RATE	0x38c00
+#define REG_INT_THROTTLING_RATE_STEP	4
+#define NUM_INT_VECTORS			16
+
+#define REG_INT_VEC_ALLOC_BASE	0x38c40
+#define REG_INT_VEC_ALLOC_STEP		4
+#define REG_INT_VEC_ALLOC_FIELD_BITS	4
+#define REG_INT_VEC_ALLOC_FIELD_MASK	(BIT(REG_INT_VEC_ALLOC_FIELD_BITS) - 1)
+#define REG_INT_VEC_ALLOC_PER_REG	((BITS_PER_BYTE * sizeof(u32)) / \
+					 REG_INT_VEC_ALLOC_FIELD_BITS)
 
 /* The last 11 bits contain the number of hops supported by the NHI port. */
 #define REG_HOP_COUNT		0x39640
+#define REG_HOP_COUNT_TOTAL_PATHS_MASK	GENMASK(10, 0)
+
+#define REG_HOST_INTERFACE_RST	0x39858
+
+#define REG_DMA_MISC		0x39864
+#define REG_DMA_MISC_INT_AUTO_CLEAR	BIT(2)
 
 #endif
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v8 3/8 thunderbolt: Communication with the ICM (firmware)

In reply to Amir Levy

This patch provides the communication protocol between the Intel Connection Manager(ICM) firmware that is operational in the Thunderbolt controller in non-Apple hardware.
The ICM firmware-based controller is used for establishing and maintaining the Thunderbolt Networking connection - we need to be able to communicate with it.

---
 drivers/thunderbolt/icm/Makefile  |    2 +
 drivers/thunderbolt/icm/icm_nhi.c | 1251 +++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm/icm_nhi.h |   82 +++
 drivers/thunderbolt/icm/net.h     |  217 +++++++
 4 files changed, 1552 insertions(+)
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.h
drivers/thunderbolt/icm/Makefile new file +2 -0
new file mode 100644
index 0000000..f0d0fbb
@@ -0,0 +1,2 @@
+obj-${CONFIG_THUNDERBOLT_ICM} += thunderbolt-icm.o
+thunderbolt-icm-objs := icm_nhi.o
drivers/thunderbolt/icm/icm_nhi.c new file +1251 -0

1,251 lines not on this page · raw message

drivers/thunderbolt/icm/icm_nhi.h new file +82 -0

82 lines not on this page · raw message

drivers/thunderbolt/icm/net.h new file +217 -0

217 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH v8 3/8] thunderbolt: Communication with the ICM (firmware)

Quoted 6 lines · Amir Levy

This patch provides the communication protocol between the Intel Connection Manager(ICM) firmware that is operational in the Thunderbolt controller in non-Apple hardware.
The ICM firmware-based controller is used for establishing and maintaining the Thunderbolt Networking connection - we need to be able to communicate with it.

I'm a bit late to the party, but here goes. I have two big questions:

1. Why is this using netlink at all? A system has zero or more Thunderbolt controllers, they're probed just like any other PCI devices (by nhi_probe() if I'm understanding correctly), they'll have nodes in sysfs, etc. Shouldn't there be a simple char device per Thunderbolt controller that a daemon can connect to? This will clean up lots of things:

a) You can actually enforce one-daemon-at-a-time in a very natural way. Your current code seems to try, but it's rather buggy. Your subscription count is a guess, your unsubscribe is entirely unchecked, and you are entirely unable to detect if a daemon crashes AFAICT.

b) You won't need all of the complexity that's currently there to figure out *which* Thunderbolt device a daemon is talking to.

c) You can use regular ioctl passing *structs* instead of netlink attrs.
There's nothing wrong with netlink attrs, except that your driver
seems to have a whole lot of boilerplate that just converts back and forth to regular structures.

d) The userspace code that does stuff like "send message, wait 150ms, receive reply, complain if no reply" goes away because ioctl is synchronous. (Or you can use read and write, but it's still simpler.)

e) You could have one daemon per Thunderbolt device if you were so inclined.

f) You get privilege separation in userspace. Creating a netlink socket and dropping privilege is busted^Winteresting. Opening a device node and dropping privilege works quite nicely.

2. Why do you need a daemon anyway. Functionally, what exactly does it do? (Okay, I get that it seems to talk to a giant pile of code running in SMM, and I get that Intel, for some bizarre reason, wants everyone except Apple to use this code in SMM, and that Apple (for entirely understandable reasons) turned it off, but that's beside the point. What does the user code do that's useful and that the kernel can't do all by itself? The only really interesting bit I can see is the part that approves PCI devices.

I'm not going to review this in detail, but here's a tiny bit:

drivers/thunderbolt/icm/icm_nhi.c line 294

Quoted 8 lines
drivers/thunderbolt/icm/icm_nhi.c new file +8 -0
+static int nhi_genl_unsubscribe(__always_unused struct sk_buff *u_skb,
+				__always_unused struct genl_info *info)
+{
+	atomic_dec_if_positive(&subscribers);
+
+	return 0;
+}
+

This, for example, is really quite buggy.

This entire function here:

Quoted 69 lines
drivers/thunderbolt/icm/icm_nhi.c new file +69 -0
+static int nhi_genl_query_information(__always_unused struct sk_buff *u_skb,
+				      struct genl_info *info)
+{
+	struct tbt_nhi_ctxt *nhi_ctxt;
+	struct sk_buff *skb;
+	bool msg_too_long;
+	int res = -ENODEV;
+	u32 *msg_head;
+
+	if (!info || !info->userhdr)
+		return -EINVAL;
+
+	skb = genlmsg_new(NLMSG_ALIGN(nhi_genl_family.hdrsize) +
+			  nla_total_size(sizeof(DRV_VERSION)) +
+			  nla_total_size(sizeof(nhi_ctxt->nvm_ver_offset)) +
+			  nla_total_size(sizeof(nhi_ctxt->num_ports)) +
+			  nla_total_size(sizeof(nhi_ctxt->dma_port)) +
+			  nla_total_size(0),	/* nhi_ctxt->support_full_e2e */
+			  GFP_KERNEL);
+	if (!skb)
+		return -ENOMEM;
+
+	msg_head = genlmsg_put_reply(skb, info, &nhi_genl_family, 0,
+				     NHI_CMD_QUERY_INFORMATION);
+	if (!msg_head) {
+		res = -ENOMEM;
+		goto genl_put_reply_failure;
+	}
+
+	if (mutex_lock_interruptible(&controllers_list_mutex)) {
+		res = -ERESTART;
+		goto genl_put_reply_failure;
+	}
+
+	nhi_ctxt = nhi_search_ctxt(*(u32 *)info->userhdr);
+	if (nhi_ctxt && !nhi_ctxt->d0_exit) {
+		*msg_head = nhi_ctxt->id;
+
+		msg_too_long = !!nla_put_string(skb, NHI_ATTR_DRV_VERSION,
+						DRV_VERSION);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u16(skb, NHI_ATTR_NVM_VER_OFFSET,
+					   nhi_ctxt->nvm_ver_offset);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u8(skb, NHI_ATTR_NUM_PORTS,
+					  nhi_ctxt->num_ports);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u8(skb, NHI_ATTR_DMA_PORT,
+					  nhi_ctxt->dma_port);
+
+		if (msg_too_long) {
+			res = -EMSGSIZE;
+			goto release_ctl_list_lock;
+		}
+
+		if (nhi_ctxt->support_full_e2e &&
+		    nla_put_flag(skb, NHI_ATTR_SUPPORT_FULL_E2E)) {
+			res = -EMSGSIZE;
+			goto release_ctl_list_lock;
+		}
+		mutex_unlock(&controllers_list_mutex);
+
+		genlmsg_end(skb, msg_head);
+
+		return genlmsg_reply(skb, info);
+	}

drivers/thunderbolt/icm/icm_nhi.c line 373

Quoted 10 lines
drivers/thunderbolt/icm/icm_nhi.c new file +10 -0
+
+release_ctl_list_lock:
+	mutex_unlock(&controllers_list_mutex);
+	genlmsg_cancel(skb, msg_head);
+
+genl_put_reply_failure:
+	nlmsg_free(skb);
+
+	return res;
+}

would be about three lines of code if you used copy_to_user and a struct.

--Andy

#5 lore raw

Re: [PATCH v8 3/8] thunderbolt: Communication with the ICM (firmware)

Quoted 33 lines · Andy Lutomirski
Quoted 6 lines · Amir Levy

This patch provides the communication protocol between the Intel Connection Manager(ICM) firmware that is operational in the Thunderbolt controller in non-Apple hardware.
The ICM firmware-based controller is used for establishing and maintaining the Thunderbolt Networking connection - we need to be able to communicate with it.

I'm a bit late to the party, but here goes. I have two big questions:

1. Why is this using netlink at all? A system has zero or more Thunderbolt controllers, they're probed just like any other PCI devices (by nhi_probe() if I'm understanding correctly), they'll have nodes in sysfs, etc. Shouldn't there be a simple char device per Thunderbolt controller that a daemon can connect to? This will clean up lots of things:

a) You can actually enforce one-daemon-at-a-time in a very natural way. Your current code seems to try, but it's rather buggy. Your subscription count is a guess, your unsubscribe is entirely unchecked, and you are entirely unable to detect if a daemon crashes AFAICT.

b) You won't need all of the complexity that's currently there to figure out *which* Thunderbolt device a daemon is talking to.

c) You can use regular ioctl passing *structs* instead of netlink attrs. There's nothing wrong with netlink attrs, except that your driver seems to have a whole lot of boilerplate that just converts back and forth to regular structures.

d) The userspace code that does stuff like "send message, wait 150ms, receive reply, complain if no reply" goes away because ioctl is synchronous. (Or you can use read and write, but it's still simpler.)

Quoted 5 lines

e) You could have one daemon per Thunderbolt device if you were so inclined.

f) You get privilege separation in userspace. Creating a netlink socket and dropping privilege is busted^Winteresting. Opening a device node and dropping privilege works quite nicely.

I agree with your points. Using a char device here instead seems to be the right way to go forward.

There is small problem, though. On non-Apple systems the host controller only appears when something is connected to thunderbolt ports. So the char device would not be there all the time. However, I think we can still notify the userspace by sending an extra uevent when we detect there is a PCIe device or inter-domain connection plugged in.

Quoted 7 lines

2. Why do you need a daemon anyway. Functionally, what exactly does it do? (Okay, I get that it seems to talk to a giant pile of code running in SMM, and I get that Intel, for some bizarre reason, wants everyone except Apple to use this code in SMM, and that Apple (for entirely understandable reasons) turned it off, but that's beside the point. What does the user code do that's useful and that the kernel can't do all by itself? The only really interesting bit I can see is the part that approves PCI devices.

As far as I can tell it is used to notify user (via dbus, I guess) that there is a new PCIe device or inter-domain connection (networking) available and it needs to be approved before it can be used.

I don't think anything prevents the kernel to do all this (Amir, Michael can correct me if I'm mistaken).

In fact we could provide a simple "tbtadm" tool, built on top of the char device that can be used to list and approve devices from shell command line. That could also allow user to turn on "auto-approve" mode or similar where the kernel approves all connected devices automatically (if such functionality is wanted).

The daemon can still be useful for listening uevents generated by the driver and forwarding approval requests to user.

Quoted 12 lines

I'm not going to review this in detail, but here's a tiny bit:

drivers/thunderbolt/icm/icm_nhi.c line 294

Quoted 8 lines
drivers/thunderbolt/icm/icm_nhi.c new file +8 -0
+static int nhi_genl_unsubscribe(__always_unused struct sk_buff *u_skb,
+				__always_unused struct genl_info *info)
+{
+	atomic_dec_if_positive(&subscribers);
+
+	return 0;
+}
+

This, for example, is really quite buggy.

OK.

Quoted 75 lines

This entire function here:

Quoted 73 lines
drivers/thunderbolt/icm/icm_nhi.c new file +73 -0
+static int nhi_genl_query_information(__always_unused struct sk_buff *u_skb,
+				      struct genl_info *info)
+{
+	struct tbt_nhi_ctxt *nhi_ctxt;
+	struct sk_buff *skb;
+	bool msg_too_long;
+	int res = -ENODEV;
+	u32 *msg_head;
+
+	if (!info || !info->userhdr)
+		return -EINVAL;
+
+	skb = genlmsg_new(NLMSG_ALIGN(nhi_genl_family.hdrsize) +
+			  nla_total_size(sizeof(DRV_VERSION)) +
+			  nla_total_size(sizeof(nhi_ctxt->nvm_ver_offset)) +
+			  nla_total_size(sizeof(nhi_ctxt->num_ports)) +
+			  nla_total_size(sizeof(nhi_ctxt->dma_port)) +
+			  nla_total_size(0),	/* nhi_ctxt->support_full_e2e */
+			  GFP_KERNEL);
+	if (!skb)
+		return -ENOMEM;
+
+	msg_head = genlmsg_put_reply(skb, info, &nhi_genl_family, 0,
+				     NHI_CMD_QUERY_INFORMATION);
+	if (!msg_head) {
+		res = -ENOMEM;
+		goto genl_put_reply_failure;
+	}
+
+	if (mutex_lock_interruptible(&controllers_list_mutex)) {
+		res = -ERESTART;
+		goto genl_put_reply_failure;
+	}
+
+	nhi_ctxt = nhi_search_ctxt(*(u32 *)info->userhdr);
+	if (nhi_ctxt && !nhi_ctxt->d0_exit) {
+		*msg_head = nhi_ctxt->id;
+
+		msg_too_long = !!nla_put_string(skb, NHI_ATTR_DRV_VERSION,
+						DRV_VERSION);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u16(skb, NHI_ATTR_NVM_VER_OFFSET,
+					   nhi_ctxt->nvm_ver_offset);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u8(skb, NHI_ATTR_NUM_PORTS,
+					  nhi_ctxt->num_ports);
+
+		msg_too_long = msg_too_long ||
+			       nla_put_u8(skb, NHI_ATTR_DMA_PORT,
+					  nhi_ctxt->dma_port);
+
+		if (msg_too_long) {
+			res = -EMSGSIZE;
+			goto release_ctl_list_lock;
+		}
+
+		if (nhi_ctxt->support_full_e2e &&
+		    nla_put_flag(skb, NHI_ATTR_SUPPORT_FULL_E2E)) {
+			res = -EMSGSIZE;
+			goto release_ctl_list_lock;
+		}
+		mutex_unlock(&controllers_list_mutex);
+
+		genlmsg_end(skb, msg_head);
+
+		return genlmsg_reply(skb, info);
+	}
+
+release_ctl_list_lock:
+	mutex_unlock(&controllers_list_mutex);
+	genlmsg_cancel(skb, msg_head);
Quoted 8 lines

drivers/thunderbolt/icm/icm_nhi.c line 373

Quoted 6 lines
drivers/thunderbolt/icm/icm_nhi.c new file +6 -0
+
+genl_put_reply_failure:
+	nlmsg_free(skb);
+
+	return res;
+}

would be about three lines of code if you used copy_to_user and a struct.

Understood.

Thanks Andy for your comments.

We will rework the driver to take your suggestions into account and expose a char device instead of using netlink.

Meanwhile we will continue in the github to add new features and support the new Thunderbolt HW generation.

#6 lore raw

RE: [PATCH v8 3/8] thunderbolt: Communication with the ICM (firmware)

Dell - Internal Use - Confidential =20

Quoted 2 lines

=20
There is small problem, though. On non-Apple systems the host controller =

only

Quoted 1 line

appears when something is connected to thunderbolt ports. So the char dev=

ice

Quoted 2 lines

would not be there all the time. However, I think we can still notify the userspace by sending an extra uevent when we detect there is a PCIe devic=

e or

Quoted 2 lines

inter-domain connection plugged in.
=20

Why couldn't you just create it the first time a device is plugged into a T= hunderbolt
port and leave it until the module is cleaned up? If the host controller g= oes to sleep
an event could be sent to the daemon to let it know it disappeared and not = to expect
data on the char device for now, but leave the node around.=20

#7 lore raw

Re: [PATCH v8 3/8] thunderbolt: Communication with the ICM (firmware)

Quoted 10 lines · On Mon, Dec 19, 2016 at 05:21:39PM +0000, [email protected] wrote:

Dell - Internal Use - Confidential

Quoted 7 lines

There is small problem, though. On non-Apple systems the host controller only appears when something is connected to thunderbolt ports. So the char device would not be there all the time. However, I think we can still notify the userspace by sending an extra uevent when we detect there is a PCIe device or inter-domain connection plugged in.

Quoted 4 lines

Why couldn't you just create it the first time a device is plugged into a Thunderbolt port and leave it until the module is cleaned up? If the host controller goes to sleep an event could be sent to the daemon to let it know it disappeared and not to expect data on the char device for now, but leave the node around.

We don't do that for USB memory sticks (or any other removable media) either - once you disconnect the device the nodes are also removed. I suppose same goes with USB network adapters, which is closest to thunderbolt networking I can think of.

author
#8 lore raw

PATCH v8 4/8 thunderbolt: Networking state machine

In reply to Amir Levy

This patch builds the peer to peer communication path. Communication is established by a negotiation process whereby messages are sent back and forth between the peers until a connection is established. This includes the Thunderbolt Network driver communication with the second peer via Intel Connection Manager(ICM) firmware.

  +--------------------+            +--------------------+
  |Host 1              |            |Host 2              |
  |                    |            |                    |
  |     +-----------+  |            |     +-----------+  |
  |     |Thunderbolt|  |            |     |Thunderbolt|  |
  |     |Networking |  |            |     |Networking |  |
  |     |Driver     |  |            |     |Driver     |  |
  |     +-----------+  |            |     +-----------+  |
  |              ^     |            |              ^     |
  |              |     |            |              |     |
  | +------------+---+ |            | +------------+---+ |
  | |Thunderbolt |   | |            | |Thunderbolt |   | |
  | |Controller  v   | |            | |Controller  v   | |
  | |         +---+  | |            | |         +---+  | |
  | |         |ICM|<-+-+------------+-+-------->|ICM|  | |
  | |         +---+  | |            | |         +---+  | |
  | +----------------+ |            | +----------------+ |
  +--------------------+            +--------------------+

Note that this patch only establishes the link between the two hosts and not Network Packet handling - this is dealt with in the next patch.

---
 drivers/thunderbolt/icm/Makefile  |   2 +-
 drivers/thunderbolt/icm/icm_nhi.c | 262 ++++++++++++-
 drivers/thunderbolt/icm/net.c     | 783 ++++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm/net.h     |  70 ++++
 4 files changed, 1109 insertions(+), 8 deletions(-)
 create mode 100644 drivers/thunderbolt/icm/net.c
drivers/thunderbolt/icm/Makefile +1 -1
index f0d0fbb..94a2797 100644
@@ -1,2 +1,2 @@
 obj-${CONFIG_THUNDERBOLT_ICM} += thunderbolt-icm.o
-thunderbolt-icm-objs := icm_nhi.o
+thunderbolt-icm-objs := icm_nhi.o net.o
drivers/thunderbolt/icm/icm_nhi.c +255 -7

322 lines not on this page · raw message

drivers/thunderbolt/icm/net.c new file +783 -0

783 lines not on this page · raw message

drivers/thunderbolt/icm/net.h +70 -0

105 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#9 lore raw

PATCH v8 5/8 thunderbolt: Networking transmit and receive

In reply to Amir Levy

This patch provides the handling interface for sending and receiving network packets between the hosts over the full communication route (using the communication path established in the previous patch).

The Thunderbolt Network driver interfaces the Linux network stack and the hardware controller configuration to handle packet transmissions:

  +----------------+            +----------------+
  |Host 1          |            |Host 2          |
  |                |            |                |
  |   +-------+    |            |    +-------+   |
  |   |Network|    |            |    |Network|   |
  |   |Stack  |    |            |    |Stack  |   |
  |   +-------+    |            |    +-------+   |
  |       ^        |            |        ^       |
  |       |        |            |        |       |
  |       v        |            |        v       |
  | +-----------+  |            |  +-----------+ |
  | |Thunderbolt|  |            |  |Thunderbolt| |
  | |Networking |  |            |  |Networking | |
  | |Driver     |  |            |  |Driver     | |
  | +-----------+  |            |  +-----------+ |
  |       ^        |            |        ^       |
  |       |        |            |        |       |
  |       v        |            |        v       |
  | +-----------+  |            |  +-----------+ |
  | |Thunderbolt|  |            |  |Thunderbolt| |
  | |Controller |<-+------------+->|Controller | |
  | +-----------+  |            |  +-----------+ |
  +----------------+            +----------------+
---
 drivers/thunderbolt/icm/icm_nhi.c |   15 +
 drivers/thunderbolt/icm/net.c     | 1471 +++++++++++++++++++++++++++++++++++++
 2 files changed, 1486 insertions(+)
drivers/thunderbolt/icm/icm_nhi.c +15 -0
index a849698..5148081 100644
@@ -928,6 +928,7 @@ static irqreturn_t nhi_msi(int __always_unused irq, void *data)
 {
 	struct tbt_nhi_ctxt *nhi_ctxt = data;
 	u32 isr0, isr1, imr0, imr1;
+	int i;
 
 	/* clear on read */
 	isr0 = ioread32(nhi_ctxt->iobase + REG_RING_NOTIFY_BASE);
@@ -950,6 +951,20 @@ static irqreturn_t nhi_msi(int __always_unused irq, void *data)
 
 	spin_unlock(&nhi_ctxt->lock);
 
+	for (i = 0; i < nhi_ctxt->num_ports; ++i) {
+		struct net_device *net_dev =
+				nhi_ctxt->net_devices[i].net_dev;
+		if (net_dev) {
+			u8 path = PATH_FROM_PORT(nhi_ctxt->num_paths, i);
+
+			if (isr0 & REG_RING_INT_RX_PROCESSED(
+					path, nhi_ctxt->num_paths))
+				tbt_net_rx_msi(net_dev);
+			if (isr0 & REG_RING_INT_TX_PROCESSED(path))
+				tbt_net_tx_msi(net_dev);
+		}
+	}
+
 	if (isr0 & REG_RING_INT_RX_PROCESSED(TBT_ICM_RING_NUM,
 					     nhi_ctxt->num_paths))
 		schedule_work(&nhi_ctxt->icm_msgs_work);
drivers/thunderbolt/icm/net.c +1471 -0

1,563 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#10 lore raw

PATCH v8 6/8 thunderbolt: Kconfig for Thunderbolt Networking

In reply to Amir Levy

Update to the Kconfig Thunderbolt description to add Thunderbolt networking as an option.
The menu item "Thunderbolt support" now offers:
"Apple Hardware Support" (existing)
and/or
"Thunderbolt Networking" (new)

You can choose the driver for your platform or build both drivers - each driver will detect if it can run on the specific platform. If the Thunderbolt Networking option is chosen, Thunderbolt Networking will be enabled between Linux non-Apple systems, macOS and Windows based systems.
Thunderbolt Networking will not affect any other Thunderbolt feature that was previous available to Linux users on either Apple or non-Apple platforms.

---
 drivers/thunderbolt/Kconfig  | 27 +++++++++++++++++++++++----
 drivers/thunderbolt/Makefile |  3 ++-
 2 files changed, 25 insertions(+), 5 deletions(-)
drivers/thunderbolt/Kconfig +23 -4
index c121acc..376e5bb 100644
@@ -1,13 +1,32 @@
-menuconfig THUNDERBOLT
-	tristate "Thunderbolt support for Apple devices"
+config THUNDERBOLT
+	tristate "Thunderbolt support"
 	depends on PCI
 	select CRC32
 	help
-	  Cactus Ridge Thunderbolt Controller driver
+	  Thunderbolt Controller driver
+
+if THUNDERBOLT
+
+config THUNDERBOLT_APPLE
+	tristate "Apple hardware support"
+	help
 	  This driver is required if you want to hotplug Thunderbolt devices on
 	  Apple hardware.
 
 	  Device chaining is currently not supported.
 
-	  To compile this driver a module, choose M here. The module will be
+	  To compile this driver as a module, choose M here. The module will be
 	  called thunderbolt.
+
+config THUNDERBOLT_ICM
+	tristate "Thunderbolt Networking"
+	help
+	  This driver is required if you want Thunderbolt Networking on
+	  non-Apple hardware.
+	  It creates a virtual Ethernet device that enables computer to
+	  computer communication over a Thunderbolt cable.
+
+	  To compile this driver as a module, choose M here. The module will be
+	  called thunderbolt_icm.
+
+endif
drivers/thunderbolt/Makefile +2 -1
index 5d1053c..b6aa6a3 100644
@@ -1,3 +1,4 @@
-obj-${CONFIG_THUNDERBOLT} := thunderbolt.o
+obj-${CONFIG_THUNDERBOLT_APPLE} := thunderbolt.o
 thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o
 
+obj-${CONFIG_THUNDERBOLT_ICM} += icm/
Signature · 1 line
2.7.4
author
#11 lore raw

PATCH v8 7/8 thunderbolt: Networking doc

In reply to Amir Levy

Adding Thunderbolt(TM) networking documentation.

---
 Documentation/00-INDEX                   |   2 +
 Documentation/thunderbolt/networking.txt | 132 +++++++++++++++++++++++++++++++
 2 files changed, 134 insertions(+)
 create mode 100644 Documentation/thunderbolt/networking.txt
Documentation/00-INDEX +2 -0
index cb9a6c6..a448ba1 100644
@@ -439,6 +439,8 @@ this_cpu_ops.txt
 	- List rationale behind and the way to use this_cpu operations.
 thermal/
 	- directory with information on managing thermal issues (CPU/temp)
+thunderbolt/
+	- directory with info regarding Thunderbolt.
 trace/
 	- directory with info on tracing technologies within linux
 unaligned-memory-access.txt
Documentation/thunderbolt/networking.txt new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#12 lore raw

PATCH v8 8/8 thunderbolt: Adding maintainer entry

In reply to Amir Levy

Add Amir Levy as maintainer for Thunderbolt(TM) ICM driver

---
 MAINTAINERS | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
MAINTAINERS +7 -1
index 01bff8e..a4a4614 100644
@@ -10358,7 +10358,13 @@ F:	include/uapi/linux/stm.h
 THUNDERBOLT DRIVER
 M:	Andreas Noever <[email protected]>
 S:	Maintained
-F:	drivers/thunderbolt/
+F:	drivers/thunderbolt/*
+
+THUNDERBOLT ICM DRIVER
+M:	Amir Levy <[email protected]>
+S:	Maintained
+F:	drivers/thunderbolt/icm/
+F:	Documentation/thunderbolt/networking.txt
 
 TI BQ27XXX POWER SUPPLY DRIVER
 R:	Andrew F. Davis <[email protected]>
Signature · 1 line
2.7.4
maintainer
#13 lore raw
In reply to Amir Levy

From: Amir Levy <[email protected]>
Date: Wed, 28 Sep 2016 17:44:22 +0300

Quoted 2 lines

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Greg, any idea where this should get merged once fully vetted? I can take it through the net-next tree, but I'm fine with another more appropriate tree taking it as well.

Thanks!

#14 lore raw
Quoted 9 lines · David Miller

From: Amir Levy <[email protected]>
Date: Wed, 28 Sep 2016 17:44:22 +0300

Quoted 2 lines

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Greg, any idea where this should get merged once fully vetted? I can take it through the net-next tree, but I'm fine with another more appropriate tree taking it as well.

I am supposed to be taking thunderbolt patches, but if this really is a network driver, it should go under drivers/net/ somewhere. It needs more review though, it's not ready to go through anyone's tree just yet :)

I'll let the thunderbolt maintainer go through it first before asking for a netdev review.

thanks,

greg k-h

maintainer
#15 lore raw

From: Greg KH <[email protected]>
Date: Fri, 30 Sep 2016 08:30:05 +0200

Quoted 11 lines · David Miller
Quoted 9 lines

From: Amir Levy <[email protected]>
Date: Wed, 28 Sep 2016 17:44:22 +0300

Quoted 2 lines

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Greg, any idea where this should get merged once fully vetted? I can take it through the net-next tree, but I'm fine with another more appropriate tree taking it as well.

Quoted 6 lines

I am supposed to be taking thunderbolt patches, but if this really is a network driver, it should go under drivers/net/ somewhere. It needs more review though, it's not ready to go through anyone's tree just yet :)

I'll let the thunderbolt maintainer go through it first before asking for a netdev review.

Ok, thanks Greg.

#16 lore raw
Quoted 19 lines · David Miller

From: Greg KH <[email protected]>
Date: Fri, 30 Sep 2016 08:30:05 +0200

Quoted 16 lines · David Miller
Quoted 9 lines

From: Amir Levy <[email protected]>
Date: Wed, 28 Sep 2016 17:44:22 +0300

Quoted 2 lines

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Greg, any idea where this should get merged once fully vetted? I can take it through the net-next tree, but I'm fine with another more appropriate tree taking it as well.

I am supposed to be taking thunderbolt patches, but if this really is a network driver, it should go under drivers/net/ somewhere. It needs more review though, it's not ready to go through anyone's tree just yet :)

Quoted 4 lines
Quoted 2 lines

I'll let the thunderbolt maintainer go through it first before asking for a netdev review.

Ok, thanks Greg.

Greg, David,
Andreas replied to similar request on patch v6:
"This driver is independent from mine. It uses an interface provided by the firmware which is not present on Apple hardware and with which I am not familiar (also it does networking, not pci with which I am also not familiar). So I cannot comment on the driver itself. I don't mind a second driver, if that is what you are asking."

Note that Thunderbolt Networking is the first feature we would like to submit, but the next features aren't related to network, but more to Thunderbolt functionality. This is the reason I created the directory thunderbolt/icm, since the next features requires ICM to be enabled as well.
I also followed the firewire as example that includes net.c (in drivers/firewire directory) along with other firewire functionality.

Thanks,
Amir

#17 lore raw
Quoted 25 lines · Amir (Jer)
Quoted 19 lines · David Miller

From: Greg KH <[email protected]>
Date: Fri, 30 Sep 2016 08:30:05 +0200

Quoted 16 lines · David Miller
Quoted 9 lines

From: Amir Levy <[email protected]>
Date: Wed, 28 Sep 2016 17:44:22 +0300

Quoted 2 lines

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Greg, any idea where this should get merged once fully vetted? I can take it through the net-next tree, but I'm fine with another more appropriate tree taking it as well.

I am supposed to be taking thunderbolt patches, but if this really is a network driver, it should go under drivers/net/ somewhere. It needs more review though, it's not ready to go through anyone's tree just yet :)

Quoted 4 lines
Quoted 2 lines

I'll let the thunderbolt maintainer go through it first before asking for a netdev review.

Ok, thanks Greg.

Quoted 7 lines

Greg, David,
Andreas replied to similar request on patch v6:
"This driver is independent from mine. It uses an interface provided by the firmware which is not present on Apple hardware and with which I am not familiar (also it does networking, not pci with which I am also not familiar). So I cannot comment on the driver itself. I don't mind a second driver, if that is what you are asking."

Yes, but I still need an ack from the thunderbolt maintainer that you aren't doing anything foolish with that interface before I can take the code.

Quoted 3 lines

Note that Thunderbolt Networking is the first feature we would like to submit, but the next features aren't related to network, but more to Thunderbolt functionality.

If this really is a real network device, it should probably live in drivers/net/ like other network drivers.

Quoted 2 lines

This is the reason I created the directory thunderbolt/icm, since the next features requires ICM to be enabled as well.

As long as you have ICM split out so that other drivers can use it, it should be fine, no matter where in the tree it lives, right?

Quoted 2 lines

I also followed the firewire as example that includes net.c (in drivers/firewire directory) along with other firewire functionality.

That's the old-style of placing files. We have moved the USB network drivers out of drivers/usb/ a while ago. The current thought is to group drivers of specific types, not busses, together wherever possible, as that is usually the majority of the logic in the driver (i.e. a USB network driver has more network-driver specific logic than USB-specific logic.)

Hope this helps explain things. I'll get to your patches next week, they are in my queue at the moment, but have conferences to deal with at the moment. Don't let my delay stop you from working on further "ICM" drivers if needed, you can always send new series of patches that build on this one when you have it ready.

thanks,

greg k-h

Tested-by on the v8 series
#18 lore raw
In reply to Amir Levy
Quoted 96 lines

-----Original Message-----
From: Amir Levy [mailto:[email protected]]
Sent: Wednesday, September 28, 2016 9:44 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Amir Levy <[email protected]>
Subject: [PATCH v8 0/8] thunderbolt: Introducing Thunderbolt(TM) Networking

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Thunderbolt Networking provides peer-to-peer connections to transfer files between computers, perform PC migrations, and/or set up small workgroups with shared storage.

This is a virtual connection that emulates an Ethernet adapter that enables Ethernet networking with the benefit of Thunderbolt superfast medium capability.

Thunderbolt Networking enables two hosts and several devices that have a Thunderbolt controller to be connected together in a linear (Daisy chain) series from a single port.

Thunderbolt Networking for Linux is compatible with Thunderbolt Networking on systems running macOS or Windows and also supports Thunderbolt generation 2 and 3 controllers.

Note that all pre-existing Thunderbolt generation 3 features, such as USB, Display and other Thunderbolt device connectivity will continue to function exactly as they did prior to enabling Thunderbolt Networking.

Code and Software Specifications:
This kernel code creates a virtual ethernet device for computer to computer communication over a Thunderbolt cable.
The new driver is a separate driver to the existing Thunderbolt driver. It is designed to work on systems running Linux that interface with Intel Connection Manager (ICM) firmware based Thunderbolt controllers that support Thunderbolt Networking. The kernel code operates in coordination with the Thunderbolt user- space daemon to implement full Thunderbolt networking functionality.

Hardware Specifications:
Thunderbolt Hardware specs have not yet been published but are used where necessary for register definitions.

Changes since v7:
- Removed debug prints
- Edited error prints
- Edited copyright notice
- Changed the Kconfig patch to be after the code changes

These patches were pushed to GitHub where they can be reviewed more comfortably with green/red highlighting:
https://github.com/01org/thunderbolt-software-kernel-tree

Daemon code:
https://github.com/01org/thunderbolt-software-daemon

For reference, here's a link to version 6:
[v7]: https://lkml.org/lkml/2016/9/27/244

Amir Levy (8):
thunderbolt: Macro rename
thunderbolt: Updating the register definitions
thunderbolt: Communication with the ICM (firmware)
thunderbolt: Networking state machine
thunderbolt: Networking transmit and receive
thunderbolt: Kconfig for Thunderbolt Networking
thunderbolt: Networking doc
thunderbolt: Adding maintainer entry

 Documentation/00-INDEX                   |    2 +
 Documentation/thunderbolt/networking.txt |  132 ++
 MAINTAINERS                              |    8 +-
 drivers/thunderbolt/Kconfig              |   27 +-
 drivers/thunderbolt/Makefile             |    3 +-
 drivers/thunderbolt/icm/Makefile         |    2 +
 drivers/thunderbolt/icm/icm_nhi.c        | 1514 ++++++++++++++++++++
 drivers/thunderbolt/icm/icm_nhi.h        |   82 ++
 drivers/thunderbolt/icm/net.c            | 2254
++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm/net.h            |  287 ++++
 drivers/thunderbolt/nhi_regs.h           |  115 +-
 11 files changed, 4417 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/thunderbolt/networking.txt
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.c
 create mode 100644 drivers/thunderbolt/icm/net.h
Quoted 2 lines

--
2.7.4

Hi Amir,

I've tested your v8 series on Dell hardware with Thunderbolt Controllers again between a Linux and Windows box. Functionally it's working well.

Andreas,

Following the history of this thread, I believe Greg was still looking for an ack from you that Amir is using the interface properly.

Thanks,

maintainer Acked-by
#19 lore raw
Quoted 105 lines · On Fri, Oct 21, 2016 at 4:57 PM, <[email protected]> wrote:
Quoted 96 lines

-----Original Message-----
From: Amir Levy [mailto:[email protected]]
Sent: Wednesday, September 28, 2016 9:44 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Limonciello, Mario <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; Amir Levy <[email protected]>
Subject: [PATCH v8 0/8] thunderbolt: Introducing Thunderbolt(TM) Networking

This driver enables Thunderbolt Networking on non-Apple platforms running Linux.

Thunderbolt Networking provides peer-to-peer connections to transfer files between computers, perform PC migrations, and/or set up small workgroups with shared storage.

This is a virtual connection that emulates an Ethernet adapter that enables Ethernet networking with the benefit of Thunderbolt superfast medium capability.

Thunderbolt Networking enables two hosts and several devices that have a Thunderbolt controller to be connected together in a linear (Daisy chain) series from a single port.

Thunderbolt Networking for Linux is compatible with Thunderbolt Networking on systems running macOS or Windows and also supports Thunderbolt generation 2 and 3 controllers.

Note that all pre-existing Thunderbolt generation 3 features, such as USB, Display and other Thunderbolt device connectivity will continue to function exactly as they did prior to enabling Thunderbolt Networking.

Code and Software Specifications:
This kernel code creates a virtual ethernet device for computer to computer communication over a Thunderbolt cable.
The new driver is a separate driver to the existing Thunderbolt driver. It is designed to work on systems running Linux that interface with Intel Connection Manager (ICM) firmware based Thunderbolt controllers that support Thunderbolt Networking. The kernel code operates in coordination with the Thunderbolt user- space daemon to implement full Thunderbolt networking functionality.

Hardware Specifications:
Thunderbolt Hardware specs have not yet been published but are used where necessary for register definitions.

Changes since v7:
- Removed debug prints
- Edited error prints
- Edited copyright notice
- Changed the Kconfig patch to be after the code changes

These patches were pushed to GitHub where they can be reviewed more comfortably with green/red highlighting:
https://github.com/01org/thunderbolt-software-kernel-tree

Daemon code:
https://github.com/01org/thunderbolt-software-daemon

For reference, here's a link to version 6:
[v7]: https://lkml.org/lkml/2016/9/27/244

Amir Levy (8):
thunderbolt: Macro rename
thunderbolt: Updating the register definitions
thunderbolt: Communication with the ICM (firmware)
thunderbolt: Networking state machine
thunderbolt: Networking transmit and receive
thunderbolt: Kconfig for Thunderbolt Networking
thunderbolt: Networking doc
thunderbolt: Adding maintainer entry

 Documentation/00-INDEX                   |    2 +
 Documentation/thunderbolt/networking.txt |  132 ++
 MAINTAINERS                              |    8 +-
 drivers/thunderbolt/Kconfig              |   27 +-
 drivers/thunderbolt/Makefile             |    3 +-
 drivers/thunderbolt/icm/Makefile         |    2 +
 drivers/thunderbolt/icm/icm_nhi.c        | 1514 ++++++++++++++++++++
 drivers/thunderbolt/icm/icm_nhi.h        |   82 ++
 drivers/thunderbolt/icm/net.c            | 2254
++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm/net.h            |  287 ++++
 drivers/thunderbolt/nhi_regs.h           |  115 +-
 11 files changed, 4417 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/thunderbolt/networking.txt
 create mode 100644 drivers/thunderbolt/icm/Makefile
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm/icm_nhi.h
 create mode 100644 drivers/thunderbolt/icm/net.c
 create mode 100644 drivers/thunderbolt/icm/net.h
Quoted 2 lines

--
2.7.4

Hi Amir,

I've tested your v8 series on Dell hardware with Thunderbolt Controllers again between a Linux and Windows box. Functionally it's working well.

Quoted 8 lines

Andreas,

Following the history of this thread, I believe Greg was still looking for an ack from you that Amir is using the interface properly.

Thanks,

That I don't know, but this driver does the inverse dmi_match of the current apple driver (dmi_match(DMI_BOARD_VENDOR, "Apple Inc.")), and therefore there should be no interaction between the two.

Cheers,
Andreas