Skip to contentSkip to conversation

thunderbolt: Introducing Thunderbolt(TM) networking

PATCH Superseded Amir Levy 6 participants 23 messages May 23, 2016 – Nov 9, 2016

Subsystems (3)

v1 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Amir Levy

author
#0 lore raw

cover thunderbolt: Introducing Thunderbolt(TM) networking

Thunderbolt(TM) generation 3 provides USB, charging, Display Port and Thunderbolt connectivity over a single physical port.

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet adapter. It provides the same networking benefits with the advantage of the fast Thunderbolt medium capabilities.
Thunderbolt(TM) networking is capable of operating in the last position in the Thunderbolt(TM) device daisy chain.

It is also compatible with Thunderbolt(TM) Networking in OS X and Windows implementations, and supports both Thunderbolt(TM) generation 2 and 3.

The kernel code operates in coordination with the Thunderbolt(TM) user-space daemon. Together, they implement full Thunderbolt(TM) networking functionality.
This implementation runs on ICM (firmware) based Thunderbolt(TM) controllers.

Note that the Thunderbolt(TM) Hardware specs have not been published yet and were partially used for register definitions.

Information
===========
Mailing list:
[email protected]
Register at: https://lists.01.org/mailman/listinfo/thunderbolt-software
Archives at: https://lists.01.org/pipermail/thunderbolt-software/

For additional information about Thunderbolt technology visit:

	https://01.org/thunderbolt-sw
	https://thunderbolttechnology.net/

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

Amir Levy, Michael Jamet (6):
thunderbolt: Updating the register definitions
thunderbolt: Communication with the ICM (firmware)
thunderbolt: Networking state machine
thunderbolt: Networking transmit and receive
thunderbolt: Kconfig for Thunderbolt(TM) networking
thunderbolt: Networking doc

 Documentation/00-INDEX         |    2 +
 Documentation/thunderbolt.txt  |  135 +++
 drivers/thunderbolt/Kconfig    |    9 +-
 drivers/thunderbolt/Makefile   |    3 +-
 drivers/thunderbolt/icm_nhi.c  | 1540 +++++++++++++++++++++++++++
 drivers/thunderbolt/icm_nhi.h  |   53 +
 drivers/thunderbolt/net.c      | 2273 ++++++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/net.h      |  276 +++++
 drivers/thunderbolt/nhi.c      |  195 ++--
 drivers/thunderbolt/nhi_regs.h |  164 ++-
 drivers/thunderbolt/tb.h       |   14 +-
 include/linux/pci_ids.h        |    2 +
 12 files changed, 4580 insertions(+), 86 deletions(-)
 create mode 100644 Documentation/thunderbolt.txt
 create mode 100644 drivers/thunderbolt/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm_nhi.h
 create mode 100644 drivers/thunderbolt/net.c
 create mode 100644 drivers/thunderbolt/net.h
Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
author
#1 lore raw

PATCH 1/6 thunderbolt: Updating the register definitions

This first patch adds more Thunderbolt(TM) register definitions and some helper macros.
It also adds Win Ridge device ID.

---
 drivers/thunderbolt/nhi_regs.h | 164 ++++++++++++++++++++++++++++++++++++++++-
 include/linux/pci_ids.h        |   2 +
 2 files changed, 163 insertions(+), 3 deletions(-)
drivers/thunderbolt/nhi_regs.h +161 -3
index 86b996c..52592e3 100644
@@ -1,14 +1,26 @@
 /*
- * 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>
 
+#define DRV_VERSION "16.1.47.1"
+#define DRV_NAME "thunderbolt"
+
+#define NHI_MMIO_BAR 0
+
+#define TBT_RING_MIN_NUM_BUFFERS	2
+#define TBT_ICM_RING_MAX_FRAME_SIZE	256
+#define TBT_ICM_RING_NUM		0
+#define TBT_RING_MAX_FRAME_SIZE		(4 * 1024)
+#define TBT_RING_MAX_FRM_DATA_SZ	(TBT_RING_MAX_FRAME_SIZE - \
+					 sizeof(struct tbt_frame_header))
+
 enum ring_flags {
 	RING_FLAG_ISOCH_ENABLE = 1 << 27, /* TX only? */
 	RING_FLAG_E2E_FLOW_CONTROL = 1 << 28,
@@ -24,6 +36,13 @@ enum ring_desc_flags {
 	RING_DESC_INTERRUPT = 0x8, /* request an interrupt on completion */
 };
 
+enum icm_operation_mode {
+	SAFE_MODE,
+	AUTHENTICATION_MODE_FUNCTIONALITY,
+	ENDPOINT_OPERATION_MODE,
+	FULL_FUNCTIONALITY,
+};
+
 /**
  * struct ring_desc - TX/RX ring entry
  *
@@ -39,6 +58,44 @@ 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)
+
+#define TBT_ICM_RING_NUM_TX_BUFS TBT_RING_MIN_NUM_BUFFERS
+#define TBT_ICM_RING_NUM_RX_BUFS ((PAGE_SIZE - (TBT_ICM_RING_NUM_TX_BUFS * \
+	(sizeof(struct tbt_buf_desc) + TBT_ICM_RING_MAX_FRAME_SIZE))) / \
+	(sizeof(struct tbt_buf_desc) + TBT_ICM_RING_MAX_FRAME_SIZE))
+/* struct tbt_icm_ring_shared_memory - memory area for DMA */
+struct tbt_icm_ring_shared_memory {
+	u8 tx_buf[TBT_ICM_RING_NUM_TX_BUFS][TBT_ICM_RING_MAX_FRAME_SIZE];
+	u8 rx_buf[TBT_ICM_RING_NUM_RX_BUFS][TBT_ICM_RING_MAX_FRAME_SIZE];
+	struct tbt_buf_desc tx_buf_desc[TBT_ICM_RING_NUM_TX_BUFS];
+	struct tbt_buf_desc rx_buf_desc[TBT_ICM_RING_NUM_RX_BUFS];
+} __aligned(TBT_ICM_RING_MAX_FRAME_SIZE);
+
 /* NHI registers in bar 0 */
 
 /*
@@ -60,6 +117,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 +158,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 +180,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 +189,71 @@ 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 USEC_TO_256_NSECS(usec) DIV_ROUND_UP((usec) * NSEC_PER_USEC, 256)
+
+#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)
+
+/* mailbox data from SW */
+#define REG_INMAIL_DATA		0x39900
+
+/* mailbox command from SW */
+#define REG_INMAIL_CMD		0x39904
+#define REG_INMAIL_CMD_CMD_SHIFT	0
+#define REG_INMAIL_CMD_CMD_MASK		GENMASK(7, REG_INMAIL_CMD_CMD_SHIFT)
+#define REG_INMAIL_CMD_ERROR		BIT(30)
+#define REG_INMAIL_CMD_REQUEST		BIT(31)
+
+/* mailbox command from FW */
+#define REG_OUTMAIL_CMD		0x3990C
+#define REG_OUTMAIL_CMD_STS_SHIFT	0
+#define REG_OUTMAIL_CMD_STS_MASK	GENMASK(7, REG_OUTMAIL_CMD_STS_SHIFT)
+#define REG_OUTMAIL_CMD_OP_MODE_SHIFT	8
+#define REG_OUTMAIL_CMD_OP_MODE_MASK	\
+				GENMASK(11, REG_OUTMAIL_CMD_OP_MODE_SHIFT)
+#define REG_OUTMAIL_CMD_REQUEST		BIT(31)
+
+#define REG_FW_STS		0x39944
+#define REG_FW_STS_ICM_EN		GENMASK(1, 0)
+#define REG_FW_STS_NVM_AUTH_DONE	BIT(31)
 
 #endif
include/linux/pci_ids.h +2 -0
index c58752f..01edf07 100644
@@ -2618,6 +2618,8 @@
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE  0x156b
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI     0x156c
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE  0x156d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI        0x157d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE     0x157e
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_NHI     0x1575 /* Thunderbolt 3 */
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE  0x1576
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_NHI     0x1577
Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

Re: [PATCH 1/6] thunderbolt: Updating the register definitions

T24gTW9uLCAyMDE2LTA1LTIzIGF0IDExOjQ4ICswMzAwLCBBbWlyIExldnkgd3JvdGU6DQo+IFRo aXMgZmlyc3QgcGF0Y2ggYWRkcyBtb3JlIFRodW5kZXJib2x0KFRNKSByZWdpc3RlciBkZWZpbml0 aW9ucw0KPiBhbmQgc29tZSBoZWxwZXIgbWFjcm9zLg0KPiBJdCBhbHNvIGFkZHMgV2luIFJpZGdl IGRldmljZSBJRC4NCj4gDQo+IFNpZ25lZC1vZmYtYnk6IEFtaXIgTGV2eSA8YW1pci5qZXIubGV2 eUBpbnRlbC5jb20+DQo+IFNpZ25lZC1vZmYtYnk6IE1pY2hhZWwgSmFtZXQgPG1pY2hhZWwuamFt ZXRAaW50ZWwuY29tPg0KDQpGcm9tIEFtaXIsIFNvQi1ieSBBbWlyLCB3aG8gaXMgTWljaGFlbCB3 cnQgdGhpcyBwYXRjaD8NCg0KPiAtLS0gYS9kcml2ZXJzL3RodW5kZXJib2x0L25oaV9yZWdzLmgN Cj4gKysrIGIvZHJpdmVycy90aHVuZGVyYm9sdC9uaGlfcmVncy5oDQo+IEBAIC0xLDE0ICsxLDI2 IEBADQo+IMKgLyoNCj4gLSAqIFRodW5kZXJib2x0IENhY3R1cyBSaWRnZSBkcml2ZXIgLSBOSEkg cmVnaXN0ZXJzDQo+ICsgKiBUaHVuZGVyYm9sdCBkcml2ZXIgLSBOSEkgcmVnaXN0ZXJzDQo+IMKg ICoNCj4gwqAgKiBDb3B5cmlnaHQgKGMpIDIwMTQgQW5kcmVhcyBOb2V2ZXIgPGFuZHJl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cHJvaGliaXRlZC4gSWYgeW91IGFyZSBub3QgdGhlIGludGVuZGVkCnJlY2lwaWVudCwgcGxlYXNl IGNvbnRhY3QgdGhlIHNlbmRlciBhbmQgZGVsZXRlIGFsbCBjb3BpZXMuCg==

#3 lore raw

Re: [PATCH 1/6] thunderbolt: Updating the register definitions

Hi Andriy, Hi Amir,

Quoted 8 lines · Andriy
Quoted 6 lines · Amir Levy
include/linux/pci_ids.h +0 -0
@@ -2618,6 +2618,8 @@
  #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE  0x156b
  #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI     0x156c
  #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE  0x156d
Quoted 4 lines

include/linux/pci_ids.h line 2622

Quoted 2 lines
include/linux/pci_ids.h +2 -0
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI        0x157d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE     0x157e

Are those IDs going to be used somewhere else than one driver?

We have a number of Thunderbolt quirks in drivers/pci/quirks.c. Although they do not pertain to Win Ridge right now, it's good to have the list complete.

However the list should be sorted numerically, so these should go below Alpine Ridge. I assume Win Ridge is DSL5110, so a comment would be good to signify that it's not Thunderbolt 2 or 3, e.g.:

#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI        0x157d /* Tbt 1 Low Pwr */ #define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE     0x157e

Thanks,

Lukas

#4 lore raw

Re: [PATCH 1/6] thunderbolt: Updating the register definitions

In reply to Amir Levy

include/linux/pci_ids.h line 2625

Quoted 11 lines · Amir Levy
include/linux/pci_ids.h +2 -0
@@ -2618,6 +2618,8 @@
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE  0x156b
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI     0x156c
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE  0x156d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI        0x157d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE     0x157e
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_NHI     0x1575 /* Thunderbolt 3 */
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE  0x1576
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_NHI     0x1577

Please read the top of this file for why you shouldn't be adding new ids to it.

#5 lore raw

RE: [PATCH 1/6] thunderbolt: Updating the register definitions

Quoted 23 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, May 23, 2016 17:40
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 1/6] thunderbolt: Updating the register definitions

include/linux/pci_ids.h line 2623

Quoted 9 lines · Amir Levy
include/linux/pci_ids.h +2 -0
@@ -2618,6 +2618,8 @@
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_BRIDGE  0x156b
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI     0x156c
 #define PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_BRIDGE  0x156d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_NHI        0x157d
+#define PCI_DEVICE_ID_INTEL_WIN_RIDGE_2C_BRIDGE     0x157e
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_NHI     0x1575 /*

Thunderbolt 3 */

Quoted 4 lines

include/linux/pci_ids.h line 2625

Quoted 2 lines
include/linux/pci_ids.h +0 -0
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_BRIDGE  0x1576
 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_NHI     0x1577

Please read the top of this file for why you shouldn't be adding new ids to it.

I missed the comment in top of this file, just wanted that the thunderbolt device list will be complete. I'll revert the 2 new entries.
Note that the instruction in this file wasn't kept even before this patch.

Thanks,
Amir
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

author
#6 lore raw

PATCH 2/6 thunderbolt: Communication with the ICM (firmware)

In reply to Amir Levy

Firmware-based (a.k.a ICM - Intel Connection Manager) controller is used for establishing and maintaining the Thunderbolt Networking connection. We need to be able to communicate with it.

---
 drivers/thunderbolt/Makefile  |    3 +-
 drivers/thunderbolt/icm_nhi.c | 1241 +++++++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/icm_nhi.h |   53 ++
 drivers/thunderbolt/net.h     |  198 +++++++
 drivers/thunderbolt/nhi.c     |  195 ++++---
 drivers/thunderbolt/tb.h      |   14 +-
 6 files changed, 1626 insertions(+), 78 deletions(-)
 create mode 100644 drivers/thunderbolt/icm_nhi.c
 create mode 100644 drivers/thunderbolt/icm_nhi.h
 create mode 100644 drivers/thunderbolt/net.h
drivers/thunderbolt/Makefile +1 -2
index 5d1053c..e2b6141 100644
@@ -1,3 +1,2 @@
 obj-${CONFIG_THUNDERBOLT} := thunderbolt.o
-thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o
-
+thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o icm_nhi.o
\ No newline at end of file
drivers/thunderbolt/icm_nhi.c new file +1241 -0

1,241 lines not on this page · raw message

drivers/thunderbolt/icm_nhi.h new file +53 -0

53 lines not on this page · raw message

drivers/thunderbolt/net.h new file +198 -0

198 lines not on this page · raw message

drivers/thunderbolt/nhi.c +126 -69

281 lines not on this page · raw message

drivers/thunderbolt/tb.h +7 -7
index 61d57ba..3e9a8ab 100644
@@ -97,6 +97,13 @@ struct tb_path {
  * struct tb - main thunderbolt bus structure
  */
 struct tb {
+	bool icm_enabled;	/* icm_enabled must be the first field */
+	bool hotplug_active; /*
+			      * tb_handle_hotplug will stop progressing plug
+			      * events and exit if this is not set (it needs to
+			      * acquire the lock one more time). Used to drain
+			      * wq after cfg has been paused.
+			      */
 	struct mutex lock;	/*
 				 * Big lock. Must be held when accessing cfg or
 				 * any struct tb_switch / struct tb_port.
@@ -106,13 +113,6 @@ struct tb {
 	struct workqueue_struct *wq; /* ordered workqueue for plug events */
 	struct tb_switch *root_switch;
 	struct list_head tunnel_list; /* list of active PCIe tunnels */
-	bool hotplug_active; /*
-			      * tb_handle_hotplug will stop progressing plug
-			      * events and exit if this is not set (it needs to
-			      * acquire the lock one more time). Used to drain
-			      * wq after cfg has been paused.
-			      */
-
 };
 
 /* helper functions & macros */
Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#7 lore raw

Re: [PATCH 2/6] thunderbolt: Communication with the ICM (firmware)

Quoted 14 lines · Amir Levy

Firmware-based (a.k.a ICM - Intel Connection Manager) controller is used for establishing and maintaining the Thunderbolt Networking connection. We need to be able to communicate with it.

drivers/thunderbolt/Makefile +0 -0
@@ -1,3 +1,2 @@

 obj-${CONFIG_THUNDERBOLT} := thunderbolt.o -thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o

drivers/thunderbolt/Makefile +1 -1
-
+thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o

tunnel_pci.o eeprom.o icm_nhi.o

Quoted 1 line

\ No newline at end of file

Something wrong with an editor?

Quoted 36 lines
drivers/thunderbolt/icm_nhi.c new file +1 -0
new file mode 100644
index 0000000..5b7e448
@@ -0,0 +1,1241 @@
+/********************************************************************

***********
+ *
+ * Intel Thunderbolt(TM) driver
+ * Copyright(c) 2014 - 2016 Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * The full GNU General Public License is included in this distribution in
+ * the file called "COPYING".
+ *

Quoted 2 lines

+ * Contact Information:
+ * Intel Thunderbolt Mailing List <[email protected]>

We have MAINTAINERS for that, have we?

Quoted 2 lines

+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497

I doubt it makes sense here.

Quoted 4 lines

+ *
+
**********************************************************************
********/

Not every maintainer likes long star lines.

drivers/thunderbolt/icm_nhi.c line 30

Quoted 5 lines
drivers/thunderbolt/icm_nhi.c new file +5 -0
+
+#include <linux/printk.h>
+#include <linux/crc32.h>
+#include <linux/delay.h>
+#include <linux/pci.h>

+ empty line

drivers/thunderbolt/icm_nhi.c line 78

Quoted 7 lines
drivers/thunderbolt/icm_nhi.c new file +5 -0
+#include "nhi_regs.h"
+#include "icm_nhi.h"
+#include "net.h"
+
 
 
+#define NHI_CMD_MAX (__NHI_CMD_MAX - 1)

MAX should be MAX¸ not MAX-1, otherwise the name is chosen poorly.

Quoted 35 lines
drivers/thunderbolt/icm_nhi.c new file +4 -0
+
+/* NHI genetlink policy */
+static const struct nla_policy nhi_genl_policy[NHI_ATTR_MAX + 1] = {
+	[NHI_ATTR_DRV_VERSION]		= { .type =

NLA_NUL_STRING, },

drivers/thunderbolt/icm_nhi.c new file +8 -0
+	[NHI_ATTR_NVM_VER_OFFSET]	= { .type = NLA_U16, },
+	[NHI_ATTR_NUM_PORTS]		= { .type = NLA_U8, },
+	[NHI_ATTR_DMA_PORT]		= { .type = NLA_U8, },
+	[NHI_ATTR_SUPPORT_FULL_E2E]	= { .type = NLA_FLAG, },
+	[NHI_ATTR_MAILBOX_CMD]		= { .type = NLA_U32, },
+	[NHI_ATTR_PDF]			= { .type = NLA_U32, },
+	[NHI_ATTR_MSG_TO_ICM]		= { .type = NLA_BINARY,
+					.len =

TBT_ICM_RING_MAX_FRAME_SIZE },

drivers/thunderbolt/icm_nhi.c new file +1 -0
+	[NHI_ATTR_MSG_FROM_ICM]		= { .type =

NLA_BINARY,

drivers/thunderbolt/icm_nhi.c new file +1 -0
+					.len =

TBT_ICM_RING_MAX_FRAME_SIZE },

drivers/thunderbolt/icm_nhi.c new file +17 -0
+};
+
+/* NHI genetlink family */
+static struct genl_family nhi_genl_family = {
+	.id		= GENL_ID_GENERATE,
+	.hdrsize	= FIELD_SIZEOF(struct tbt_nhi_ctxt, id),
+	.name		= NHI_GENL_NAME,
+	.version	= NHI_GENL_VERSION,
+	.maxattr	= NHI_ATTR_MAX,
+};
+
+static LIST_HEAD(controllers_list);
+static DECLARE_RWSEM(controllers_list_rwsem);
+static atomic_t subscribers = ATOMIC_INIT(0);
+static u32 portid;
+
+static bool nhi_nvm_authenticated(struct tbt_nhi_ctxt *nhi_ctxt)

drivers/thunderbolt/icm_nhi.c line 119

Quoted 10 lines
drivers/thunderbolt/icm_nhi.c new file +10 -0
+{
+	enum icm_operation_mode op_mode;
+	u32 *msg_head, port_id, reg;
+	struct sk_buff *skb;
+	int i;
+
+	if (!nhi_ctxt->nvm_auth_on_boot)
+		return true;
+
+	for (i = 0; i < 5; i++) {

5 is a magic number.

drivers/thunderbolt/icm_nhi.c line 122

Quoted 3 lines
drivers/thunderbolt/icm_nhi.c new file +3 -0
+		u32 status;
+
+		status = ioread32(nhi_ctxt->iobase + REG_FW_STS);

So, can be registers represented as IO ports? Otherwise use plain writel() / readl() and friends.

drivers/thunderbolt/icm_nhi.c line 126

Quoted 5 lines
drivers/thunderbolt/icm_nhi.c new file +4 -0
+
+		if (status & REG_FW_STS_NVM_AUTH_DONE)
+			break;
 
+		msleep(30);

Definitely needs comment why this is here.

Quoted 17 lines
drivers/thunderbolt/icm_nhi.c new file +5 -0
+	}
+	/*
+	 * The check for authentication is done after checking if iCM
+	 * is present so it shouldn't reach the max tries (=5).
+	 * Anyway, the check for full functionality below covers the

error case.

drivers/thunderbolt/icm_nhi.c new file +8 -0
+	 */
+	reg = ioread32(nhi_ctxt->iobase + REG_OUTMAIL_CMD);
+	op_mode = (reg & REG_OUTMAIL_CMD_OP_MODE_MASK) >>
+		  REG_OUTMAIL_CMD_OP_MODE_SHIFT;
+	if (op_mode == FULL_FUNCTIONALITY)
+		return true;
+
+	dev_warn(&nhi_ctxt->pdev->dev, "controller id %#x is in

operation mode %#x status %#lx\n",

drivers/thunderbolt/icm_nhi.c new file +2 -0
+		 nhi_ctxt->id, op_mode,
+		 (reg &
Quoted 1 line

REG_OUTMAIL_CMD_STS_MASK)>>REG_OUTMAIL_CMD_STS_SHIFT);

Spaces are missed around >>.

Quoted 6 lines
drivers/thunderbolt/icm_nhi.c new file +2 -0
+
+	skb = genlmsg_new(NLMSG_ALIGN(nhi_genl_family.hdrsize),

GFP_KERNEL);

drivers/thunderbolt/icm_nhi.c new file +2 -0
+	if (!skb) {
+		dev_err(&nhi_ctxt->pdev->dev, "genlmsg_new failed:

not enough memory to send controller operational mode\n");

Message can be located on the next line.

drivers/thunderbolt/icm_nhi.c line 149

Quoted 4 lines
drivers/thunderbolt/icm_nhi.c new file +4 -0
+		return false;
+	}
+
+	/* keeping port_id into a local variable for next use */

keeping -> Keeping

Quoted 7 lines
drivers/thunderbolt/icm_nhi.c new file +6 -0
+	port_id = portid;
+	msg_head = genlmsg_put(skb, port_id, 0, &nhi_genl_family, 0,
+			       NHI_CMD_ICM_IN_SAFE_MODE);
+	if (!msg_head) {
+		nlmsg_free(skb);
+		dev_err(&nhi_ctxt->pdev->dev, "genlmsg_put failed:

not enough memory to send controller operational mode\n");

Message can be located on the next line.

Quoted 16 lines
drivers/thunderbolt/icm_nhi.c new file +3 -0
+		return false;
+	}
+

 static int __init nhi_init(void)
 {

drivers/thunderbolt/icm_nhi.c new file +7 -3
-	if (!dmi_match(DMI_BOARD_VENDOR, "Apple Inc."))
-		return -ENOSYS;
-	return pci_register_driver(&nhi_driver);
+	int rc = nhi_genl_register();
+
+	if (rc)
+		goto failure;
+
+	rc = pci_register_driver(&nhi_driver);
+	if (rc)

drivers/thunderbolt/icm_nhi.c

Quoted 10 lines
drivers/thunderbolt/icm_nhi.c new file +9 -0
+		goto failure_genl;
+
+	return 0;
+
+failure_genl:
+	nhi_genl_unregister();
+
+failure:
 
+	pr_debug("nhi: error %d occurred in %s\n", rc, __func__);

Doesn't make much sense. We have a mechanism to get this code and function printed.

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
author
#8 lore raw

PATCH 3/6 thunderbolt: Networking state machine

In reply to Amir Levy

Negotiation states that a peer goes through in order to establish the communication with the second peer.
This includes communication with upper layer and additional infrastructure support to communicate with the second peer through ICM.

---
 drivers/thunderbolt/Makefile  |   2 +-
 drivers/thunderbolt/icm_nhi.c | 304 +++++++++++++++-
 drivers/thunderbolt/net.c     | 802 ++++++++++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/net.h     |  78 ++++
 4 files changed, 1175 insertions(+), 11 deletions(-)
 create mode 100644 drivers/thunderbolt/net.c
drivers/thunderbolt/Makefile +1 -1
index e2b6141..171f31c 100644
@@ -1,2 +1,2 @@
 obj-${CONFIG_THUNDERBOLT} := thunderbolt.o
-thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o icm_nhi.o
\ No newline at end of file
+thunderbolt-objs := nhi.o ctl.o tb.o switch.o cap.o path.o tunnel_pci.o eeprom.o icm_nhi.o net.o
drivers/thunderbolt/icm_nhi.c +294 -10

368 lines not on this page · raw message

drivers/thunderbolt/net.c new file +802 -0

802 lines not on this page · raw message

drivers/thunderbolt/net.h +78 -0

112 lines not on this page · raw message

Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
author
#9 lore raw

PATCH 4/6 thunderbolt: Networking transmit and receive

In reply to Amir Levy

Handling the transmission to second peer and receiving from it. This includes communication with upper layer, the network stack and configuration of Thunderbolt(TM) HW.

---
 drivers/thunderbolt/icm_nhi.c |   15 +
 drivers/thunderbolt/net.c     | 1471 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1486 insertions(+)
drivers/thunderbolt/icm_nhi.c +15 -0
index 96194d5..bbf624b 100644
@@ -1034,6 +1034,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);
@@ -1056,6 +1057,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/net.c +1471 -0

1,563 lines not on this page · raw message

Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
author
#10 lore raw

PATCH 5/6 thunderbolt: Kconfig for Thunderbolt(TM) networking

In reply to Amir Levy

Updating the Kconfig Thunderbolt(TM) description.

---
 drivers/thunderbolt/Kconfig | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/thunderbolt/Kconfig +4 -5
index c121acc..8ac4149 100644
@@ -1,13 +1,12 @@
 menuconfig THUNDERBOLT
-	tristate "Thunderbolt support for Apple devices"
+	tristate "Thunderbolt(TM) support"
 	depends on PCI
 	select CRC32
 	help
-	  Cactus Ridge Thunderbolt Controller driver
-	  This driver is required if you want to hotplug Thunderbolt devices on
-	  Apple hardware.
+	  Thunderbolt(TM) Controller driver
+	  This driver is required if you want to hotplug Thunderbolt(TM) devices.
 
-	  Device chaining is currently not supported.
+	  Device chaining is currently not supported on Apple hardware.
 
 	  To compile this driver a module, choose M here. The module will be
 	  called thunderbolt.
Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
author
#11 lore raw

PATCH 6/6 thunderbolt: Networking doc

In reply to Amir Levy

Adding Thunderbolt(TM) networking documentation.

---
 Documentation/00-INDEX        |   2 +
 Documentation/thunderbolt.txt | 135 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 137 insertions(+)
 create mode 100644 Documentation/thunderbolt.txt
Documentation/00-INDEX +2 -0
index cd077ca..d9b0e30 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.txt 
+	- Thunderbolt(TM) Networking driver description.
 trace/
 	- directory with info on tracing technologies within linux
 unaligned-memory-access.txt
Documentation/thunderbolt.txt new file +135 -0

135 lines not on this page · raw message

Signature · 9 lines
1.9.1

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#12 lore raw

Re: [PATCH 6/6] thunderbolt: Networking doc

Quoted 7 lines · Amir Levy

Adding Thunderbolt(TM) networking documentation.

---
 Documentation/00-INDEX        |   2 +
 Documentation/thunderbolt.txt | 135 ++++++++++++++++++++++++++++++++++++++++++

This is networking with thunderbolt, you might want to name the documentation file to reflect that otherwise people are going to think this is describing all thunderbolt support in the kernel.

thanks,

greg k-h

#13 lore raw

RE: [PATCH 6/6] thunderbolt: Networking doc

Quoted 22 lines

-----Original Message-----
From: Greg KH [mailto:[email protected]]
Sent: Monday, May 23, 2016 18:34
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 6/6] thunderbolt: Networking doc

Quoted 8 lines · Amir Levy

Adding Thunderbolt(TM) networking documentation.

---
 Documentation/00-INDEX        |   2 +
 Documentation/thunderbolt.txt | 135

++++++++++++++++++++++++++++++++++++++++++

Quoted 7 lines

This is networking with thunderbolt, you might want to name the documentation file to reflect that otherwise people are going to think this is describing all thunderbolt support in the kernel.

thanks,

greg k-h

OK, I'll rename it.
Our plan after this patch series is to provide more thunderbolt features that aren't related to networking.

Thanks,
Amir
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#14 lore raw

Re: [PATCH 6/6] thunderbolt: Networking doc

Quoted 6 lines · Amir (Jer)

Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

I can't respond to any email with this as the footer, sorry.

#15 lore raw
In reply to Amir Levy

Hi Amir,

Quoted 2 lines · Amir Levy

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet adapter.

Thank you for this contribution. I think it may take some time to review everything, for now just some general observations:

- Since this is networking-related, it would be good if you could cc [email protected] and possibly other relevant lists in future submissions of this series so that all stakeholders get the chance to comment.

- You're including multiple networking related header files but you're not adding any dependencies to Kconfig. I think you'll either have to add dependencies to Kconfig or compile portions of your code conditionally (using ifdefs in the code or conditions in the Makefile). Intel's kbuild test robot can help you find missing dependencies.

- Your github kernel directory only contains the raw patches. If you could clone torvalds/linux and apply the patches, it would allow people to browse the patches more comfortably with green/red highlighting. Also, I think kbuild test robot will automatically test forks of torvalds/linux.

- Your patches contain spelling fixes, it would be good to have those in a separate commit marked "No functional change intended" in the commit message. Also, since the driver was originally developed for Cactus Ridge but is now used for other controllers, you've changed comments which made it appear that the driver is Cactus Ridge only. These should go into a separate commit as well. Same for macro renames like DSL3510_REGS_H_ => NHI_REGS_H_.

- Up until now this driver was Mac-only. IIUC the functionality you're adding will also be used on non-Macs. That's an important change that should probably be made more explicit in the commit messages. Did you test your patches on a Mac to see that nothing regresses? Andreas Noever took on the Herculean task of writing this driver although no public documentation was available from Intel, he's the maintainer and needs to ack everything that goes into the driver. So in a sense it's like you're being a guest in someone else's house even though it's your own proprietary technology. E.g. adding an Intel-specific version number to the driver seems a bit odd at first glance.

Thanks,

Lukas

#16 lore raw
Quoted 20 lines

-----Original Message-----
From: Lukas Wunner [mailto:[email protected]]
Sent: Tuesday, May 24, 2016 13:55
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Hi Amir,

Quoted 2 lines · Amir Levy

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet adapter.

Quoted 7 lines

Thank you for this contribution. I think it may take some time to review everything, for now just some general observations:

- Up until now this driver was Mac-only. IIUC the functionality you're adding will also be used on non-Macs. That's an important change that should probably be made more explicit in the commit messages. Did you test your patches on a Mac to see that nothing regresses?

Yes, we did some tests on MacBook Pro with Falcon Ridge.
Note that (as written in the cover letter), the functionality that we are adding is based on ICM (Intel Connection Manager, firmware). These patches will keep the current functionality on Mac and will add the networking functionality on non-Macs.

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

maintainer
#17 lore raw
Quoted 23 lines · Amir (Jer)
Quoted 23 lines

-----Original Message-----
From: Lukas Wunner [mailto:[email protected]]
Sent: Tuesday, May 24, 2016 13:55
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Hi Amir,

Quoted 2 lines · Amir Levy

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet adapter.

Thank you for this contribution. I think it may take some time to review everything, for now just some general observations:

Quoted 8 lines
Quoted 4 lines

- Up until now this driver was Mac-only. IIUC the functionality you're adding will also be used on non-Macs. That's an important change that should probably be made more explicit in the commit messages. Did you test your patches on a Mac to see that nothing regresses?

Yes, we did some tests on MacBook Pro with Falcon Ridge.
Note that (as written in the cover letter), the functionality that we are adding is based on ICM (Intel Connection Manager, firmware). These patches will keep the current functionality on Mac and will add the networking functionality on non-Macs.

Hi Amir,

First of all thanks for contributing this. It is certainly good to see Intel help out with the driver.

I only did a cursory read, but already have a few questions concerning the ICM and its relation to the rest of the driver:
- Is the ICM only responsible for networking or does it also handle pci tunnels, DP, ...?
- Your code only supports TB2,3. Afaik Apple supports IP over TB also on TB 1. What are the obstacles to support first generation chips?
- Related to the above: if some of the registers are available only for some chips then please document this in nhi_regs.h (and other places).
- Is it possible to use the ICM on Apple hardware?

Your patch essentially splits the driver into two. You add an if statement to nhi_probe which either runs your code or the old one. This is just silly (you might as well add a separate driver). At least parts of the functionality are already implemented. For example patch 2 has large overlap with what is currently handled by nhi.c/ctl.c (reading/writing the ring buffer and handling communication with the PDF). I understand that the interface provided by ring_rx/ring_tx is not a good match for high speed networking introduced in the later patches. But then you should refactor it to provide what you need instead of reimplementing all the functionality.

Lastly, why do you need a user mode component? What does it do?

Andreas

#18 lore raw

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBBbmRyZWFzIE5vZXZlciBbbWFp bHRvOmFuZHJlYXMubm9ldmVyQGdtYWlsLmNvbV0NCj4gU2VudDogV2VkbmVzZGF5LCBNYXkgMjUs IDIwMTYgMDI6MjUNCj4gVG86IExldnksIEFtaXIgKEplcikgPGFtaXIuamVyLmxldnlAaW50ZWwu Y29tPg0KPiBDYzogTHVrYXMgV3VubmVyIDxsdWthc0B3dW5uZXIuZGU+OyBncmVna2hAbGludXhm b3VuZGF0aW9uLm9yZzsNCj4gYmhlbGdhYXNAZ29vZ2xlLmNvbTsgbGludXgtcGNpQHZnZXIua2Vy bmVsLm9yZzsgSmFtZXQsIE1pY2hhZWwNCj4gPG1pY2hhZWwuamFtZXRAaW50ZWwuY29tPjsgQWxs b3VuLCBEYW4gPGRhbi5hbGxvdW5AaW50ZWwuY29tPjsNCj4gV2VzdGVyYmVyZywgTW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mVy ZW5jZSBob3cgdGhlIHNlcGFyYXRpb24gc2hvdWxkIGJlPw0KSSB0aG91Z2h0IGFib3V0IGRlZmlu aW5nIGljbV9uaGkuYyBhcyBhIG1vZHVsZV9pbml0IGFuZCBpbiBjb250cmFzdCB0byB0aGUgb3Jp Z2luYWwgZHJpdmVyLCBpZiBkbWlfbWF0Y2goQXBwbGUpIHJldHVybiBlcnJvci4NCg0KPiANCj4g TGFzdGx5LCB3aHkgZG8geW91IG5lZWQgYSB1c2VyIG1vZGUgY29tcG9uZW50PyBXaGF0IGRvZXMg aXQgZG8/DQoNClRoZSBnZW5lcmFsIGNvbmNlcHQgd2FzIHRvIGtlZXAgYXMgbWluaW11bSBhcyBw b3NzaWJsZSBpbiBrZXJuZWwgYW5kIG1vdmUgc29tZSBvZiB0aGUgbG9naWMgdG8gdXNlciBzcGFj ZS4NClRoaXMgd2lsbCBnaXZlIHVzIHRoZSBvcHRpb24gdG8gaGF2ZSBtaW5pbWFsIGNoYW5nZXMg aW4ga2VybmVsIG1vZHVsZSBpbiB0aGUgZnV0dXJlLCBhbmQgdG8gcmVsZWFzZSBmZWF0dXJlcyBp biBhIHRpbWVseSBtYW5uZXIuDQpBbHNvIGl0IGlzIGEgcHJlcGFyYXRpb24gdG8gc29tZSBvZiB0 aGUgZmVhdHVyZXMgdGhhdCB3aWxsIHJlcXVpcmUgdXNlciBpbnRlcmFjdGlvbi4NCg0KPiANCj4g QW5kcmVhcw0K

maintainer
#19 lore raw
Quoted 90 lines · Amir (Jer)
Quoted 47 lines

-----Original Message-----
From: Andreas Noever [mailto:[email protected]]
Sent: Wednesday, May 25, 2016 02:25
To: Levy, Amir (Jer) <[email protected]>
Cc: Lukas Wunner <[email protected]>; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Quoted 14 lines · Amir (Jer)
Quoted 14 lines

-----Original Message-----
From: Lukas Wunner [mailto:[email protected]]
Sent: Tuesday, May 24, 2016 13:55
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Quoted 5 lines
Quoted 5 lines

Hi Amir,

Quoted 2 lines · Amir Levy

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet

adapter.

Quoted 11 lines
Quoted 8 lines

Thank you for this contribution. I think it may take some time to review everything, for now just some general observations:

- Up until now this driver was Mac-only. IIUC the functionality you're adding will also be used on non-Macs. That's an important change that should probably be made more explicit in the commit messages. Did you test your patches on a Mac to see that nothing regresses?

Yes, we did some tests on MacBook Pro with Falcon Ridge.
Note that (as written in the cover letter), the functionality that we are

Quoted 8 lines

adding is based on ICM (Intel Connection Manager, firmware).

Quoted 1 line

These patches will keep the current functionality on Mac and will add the

networking functionality on non-Macs.

Hi Amir,

First of all thanks for contributing this. It is certainly good to see Intel help out with the driver.

Hi Andreas,
Thank you for the comments.

Quoted 5 lines

I only did a cursory read, but already have a few questions concerning the ICM and its relation to the rest of the driver:
- Is the ICM only responsible for networking or does it also handle pci tunnels, DP, ...?

ICM is responsible for PCI tunnels and DP as well.

Quoted 2 lines

- Your code only supports TB2,3. Afaik Apple supports IP over TB also on TB 1. What are the obstacles to support first generation chips?

Intel decided to support Thunderbolt Networking from generation 2.

Quoted 3 lines

- Related to the above: if some of the registers are available only for some chips then please document this in nhi_regs.h (and other places).
- Is it possible to use the ICM on Apple hardware?

We don't know if Apple supports it or plans to support it.

Quoted 11 lines

Your patch essentially splits the driver into two. You add an if statement to nhi_probe which either runs your code or the old one.
This is just silly (you might as well add a separate driver). At least parts of the functionality are already implemented. For example patch
2 has large overlap with what is currently handled by nhi.c/ctl.c (reading/writing the ring buffer and handling communication with the PDF). I understand that the interface provided by ring_rx/ring_tx is not a good match for high speed networking introduced in the later patches. But then you should refactor it to provide what you need instead of reimplementing all the functionality.

Quoted 4 lines

We had a lot of discussions around the driver separation topic and we also consulted some Linux contributors in Intel and got to the conclusion that one driver will be better. If you recommend to do it in separate driver, I'll send new patches.
Do you have preference how the separation should be?
I thought about defining icm_nhi.c as a module_init and in contrast to the original driver, if dmi_match(Apple) return error.

Well I would prefer it to be in a single driver, but without duplicated functionality.

There are two parts to your driver:
1) The part that talks to the ICM to setup thunderbolt paths between
two controllers.
2) The network driver.

I have no experience with networking and we have analoge to 2) in the current driver. So this is fine from my perspective. As far as I can tell the network driver just needs to be given a thunderbolt path (which rx/tx ring to use on the nhi) and is otherwise self contained. This is interesting to me since I would like to try to implement networking on Apple hardware.

1) communicates with the ICM by writing SW_TO_FW/FW_TO_SW packages to the control channel (or "raw mode", "PDF", ... not sure what the correct terminology is). The code to drive the control channel is already present in ctl.c (we just use raw config_read/write packages). Why can't you reuse all the plumbing code from there (pushing packages onto the ring, handling interrupts etc..). I think it should be possible to add support for the two new package types to ctl.c and then work with them from say thunderbolt_alloc_and_start (instead of scanning the root switch just talk to the icm...).

Btw, what is the sequence of ICM commands needed to establish get a network path setup? Is that supposed to be done from userspace?

Quoted 9 lines
Quoted 2 lines

Lastly, why do you need a user mode component? What does it do?

The general concept was to keep as minimum as possible in kernel and move some of the logic to user space. This will give us the option to have minimal changes in kernel module in the future, and to release features in a timely manner. Also it is a preparation to some of the features that will require user interaction.

Quoted 2 lines

Andreas

#20 lore raw

T24gMjAxNi0wNi0wOCBBbmRyZWFzIE5vZXZlciB3cm90ZToNCj4gT24gV2VkLCBKdW4gMSwgMjAx NiBhdCAyOjIyIFBNLCBMZXZ5LCBBbWlyIChKZXIpIDxhbWlyLmplci5sZXZ5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mUgbWluaW1hbCBjaGFuZ2VzIGluIGtlcm5lbCBtb2R1bGUgaW4gdGhlDQo+IGZ1 dHVyZSwgYW5kIHRvIHJlbGVhc2UgZmVhdHVyZXMgaW4gYSB0aW1lbHkgbWFubmVyLg0KPiA+IEFs c28gaXQgaXMgYSBwcmVwYXJhdGlvbiB0byBzb21lIG9mIHRoZSBmZWF0dXJlcyB0aGF0IHdpbGwg cmVxdWlyZSB1c2VyDQo+IGludGVyYWN0aW9uLg0KPiA+DQo+ID4+DQo+ID4+IEFuZHJlYXMNCg0K

maintainer
#21 lore raw
Quoted 133 lines · Amir (Jer)
Quoted 122 lines · On 2016-06-08 Andreas Noever wrote:
Quoted 37 lines · Amir (Jer)
Quoted 37 lines

-----Original Message-----
From: Andreas Noever [mailto:[email protected]]
Sent: Wednesday, May 25, 2016 02:25
To: Levy, Amir (Jer) <[email protected]>
Cc: Lukas Wunner <[email protected]>; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Quoted 20 lines · Amir (Jer)
Quoted 20 lines

-----Original Message-----
From: Lukas Wunner [mailto:[email protected]]
Sent: Tuesday, May 24, 2016 13:55
To: Levy, Amir (Jer) <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Jamet, Michael <[email protected]>; Alloun, Dan <[email protected]>; Westerberg, Mika <[email protected]>; Svahn, Kai <[email protected]>; Shevchenko, Andriy <[email protected]>; Winkler, Tomas <[email protected]>
Subject: Re: [PATCH 0/6] thunderbolt: Introducing Thunderbolt(TM) networking

Hi Amir,

Quoted 3 lines · Amir Levy

Thunderbolt(TM) networking, introduced in these patches, provides the capability of connecting hosts together by emulating an Ethernet

Quoted 8 lines
Quoted 8 lines

adapter.

Quoted 7 lines
Quoted 7 lines

Thank you for this contribution. I think it may take some time to review everything, for now just some general observations:

- Up until now this driver was Mac-only. IIUC the functionality you're adding will also be used on non-Macs. That's an important change that should probably be made more explicit in the commit messages. Did

you

Quoted 19 lines
Quoted 6 lines
Quoted 5 lines
Quoted 1 line

test your patches on a Mac to see that nothing regresses?

Yes, we did some tests on MacBook Pro with Falcon Ridge. Note that (as written in the cover letter), the functionality that we are

adding is based on ICM (Intel Connection Manager, firmware).

Quoted 8 lines
Quoted 2 lines

These patches will keep the current functionality on Mac and will add the

networking functionality on non-Macs.

Hi Amir,

First of all thanks for contributing this. It is certainly good to see Intel help out with the driver.

Hi Andreas,
Thank you for the comments.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

I only did a cursory read, but already have a few questions concerning the ICM and its relation to the rest of the driver:
- Is the ICM only responsible for networking or does it also handle pci tunnels, DP, ...?

ICM is responsible for PCI tunnels and DP as well.

Quoted 1 line

- Your code only supports TB2,3. Afaik Apple supports IP over TB also on

TB 1.

Quoted 6 lines
Quoted 1 line

What are the obstacles to support first generation chips?

Intel decided to support Thunderbolt Networking from generation 2.

Quoted 2 lines

- Related to the above: if some of the registers are available only for some chips then please document this in nhi_regs.h (and other

places).

Quoted 17 lines
Quoted 1 line

- Is it possible to use the ICM on Apple hardware?

We don't know if Apple supports it or plans to support it.

Quoted 12 lines

Your patch essentially splits the driver into two. You add an if statement to nhi_probe which either runs your code or the old one. This is just silly (you might as well add a separate driver). At least parts of the functionality are already implemented. For example patch
2 has large overlap with what is currently handled by nhi.c/ctl.c (reading/writing the ring buffer and handling communication with the PDF). I understand that the interface provided by ring_rx/ring_tx is not a good match for high speed networking introduced in the later patches. But then you should refactor it to provide what you need instead of reimplementing all the functionality.

Quoted 1 line

We had a lot of discussions around the driver separation topic and we also

consulted some Linux contributors in Intel and got to the conclusion that one driver will be better.

Quoted 3 lines

If you recommend to do it in separate driver, I'll send new patches. Do you have preference how the separation should be?
I thought about defining icm_nhi.c as a module_init and in contrast to the

original driver, if dmi_match(Apple) return error.
Well I would prefer it to be in a single driver, but without duplicated functionality.

There are two parts to your driver:
1) The part that talks to the ICM to setup thunderbolt paths between two
controllers.
2) The network driver.

I have no experience with networking and we have analoge to 2) in the current driver. So this is fine from my perspective. As far as I can tell the network driver just needs to be given a thunderbolt path (which rx/tx ring to use on the nhi) and is otherwise self contained.
This is interesting to me since I would like to try to implement networking on Apple hardware.

Quoted 9 lines

1) communicates with the ICM by writing SW_TO_FW/FW_TO_SW packages to the control channel (or "raw mode", "PDF", ... not sure what the correct terminology is). The code to drive the control channel is already present in ctl.c (we just use raw config_read/write packages).
Why can't you reuse all the plumbing code from there (pushing packages onto the ring, handling interrupts etc..). I think it should be possible to add support for the two new package types to ctl.c and then work with them from say thunderbolt_alloc_and_start (instead of scanning the root switch just talk to the icm...).

Quoted 2 lines

Intel handles Thunderbolt developments on non-MAC systems only (with ICM).
Intel doesn’t maintain, develop and publish Thunderbolt SW code running on Apple HW for OS X and Linux.

You submitted a patch to a thunderbolt driver for Apple HW. I think that it is reasonable for you to make some effort to integrate with it and not duplicate functionality in two places.

Quoted 2 lines

This is the reason there is minimal code in the probe function, that branches to 2 separate modules. I can remove this from probe and produce two separate drivers, as I suggested.

If you want to make your own driver then I won't fight you. At least that is a more honest approach than a huge if statement in the probe function...

Quoted 22 lines
Quoted 3 lines

Btw, what is the sequence of ICM commands needed to establish get a network path setup? Is that supposed to be done from userspace?

The network path establishment is divided between user-space (Daemon) and driver. It starts in user-space and ends in driver.
The hand over from Daemon to driver is in nhi_genl_approve_networking.

Quoted 13 lines
Quoted 5 lines
Quoted 3 lines

Lastly, why do you need a user mode component? What does it do?

The general concept was to keep as minimum as possible in kernel and

move some of the logic to user space.

Quoted 1 line

This will give us the option to have minimal changes in kernel module in the

future, and to release features in a timely manner.

Quoted 1 line

Also it is a preparation to some of the features that will require user

interaction.

Quoted 3 lines
Quoted 3 lines

Andreas

#22 lore raw
In reply to Andreas Noever
Quoted 1 line · Andreas Noever

- Is it possible to use the ICM on Apple hardware?

Found this by accident:

On Macs introduced 2015 (MBP11,4, MBP11,5, MBP12,1, iMac17,1, ...) the DSDT contains AML code which appears to enable ICM for \_OSI("Windows 2012"), i.e. Windows 8 but not 7, presumably for BootCamp.

Grab an acpidump of an MBP11,4 here and search for ICM:
https://bugzilla.kernel.org/attachment.cgi?id=207701

There are two ICM-related GPEs, 0x10 and 0x14.

Best regards,

Lukas