Skip to contentSkip to conversation

Driver for Beckhoff CX5020 EtherCAT master module.

PATCH Superseded Darek Marcinkiewicz 2 participants 8 messages May 2, 2014 – May 4, 2014

Subsystems (3)

v5 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

Darek Marcinkiewicz

author maintainer
#0 lore raw

PATCH v5 1/1 Driver for Beckhoff CX5020 EtherCAT master module.

This driver adds support for EtherCAT master module located on CCAT FPGA found on Beckhoff CX series industrial PCs. The driver exposes EtherCAT master as an ethernet interface.

EtherCAT is a filedbus protocol defined on top of ethernet and Beckhoff CX5020 PCs come with built-in EtherCAT master module located on a FPGA, which in turn is connected to a PCI bus.

---
Changes from v4:
* incorporates Francois Romieu comments
* fixes typo spotted by Jesper Brouer

Changes from v3:
* some clarificatoins around buffer allocations

Changes from v2:
* removed all checkpatch warnings
* driver makes use of device rx fifo

Changes from v1:
* added endianess annotation to descriptors' structures
* killed checkpath warnings about string literals being split into multiple lines

 drivers/net/ethernet/Kconfig  |   11 +
 drivers/net/ethernet/Makefile |    1 +
 drivers/net/ethernet/ec_bhf.c |  740 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 752 insertions(+)
 create mode 100644 drivers/net/ethernet/ec_bhf.c
drivers/net/ethernet/Kconfig +11 -0
index 39b26fe..a93ea15 100644
@@ -35,6 +35,17 @@ source "drivers/net/ethernet/calxeda/Kconfig"
 source "drivers/net/ethernet/chelsio/Kconfig"
 source "drivers/net/ethernet/cirrus/Kconfig"
 source "drivers/net/ethernet/cisco/Kconfig"
+
+config CX_ECAT
+	tristate "Beckhoff CX5020 EtherCAT master support"
+	---help---
+	  Driver for EtherCAT master module located on CCAT FPGA
+	  that can be found on Beckhoff CX5020, and possibly other of CX
+	  Beckhoff CX series industrial PCs.
+
+	  To compile this driver as a module, choose M here. The module
+	  will be called ec_bhf.
+
 source "drivers/net/ethernet/davicom/Kconfig"
 
 config DNET
drivers/net/ethernet/Makefile +1 -0
index 545d0b3..35190e3 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_NET_CALXEDA_XGMAC) += calxeda/
 obj-$(CONFIG_NET_VENDOR_CHELSIO) += chelsio/
 obj-$(CONFIG_NET_VENDOR_CIRRUS) += cirrus/
 obj-$(CONFIG_NET_VENDOR_CISCO) += cisco/
+obj-$(CONFIG_CX_ECAT) += ec_bhf.o
 obj-$(CONFIG_DM9000) += davicom/
 obj-$(CONFIG_DNET) += dnet.o
 obj-$(CONFIG_NET_VENDOR_DEC) += dec/
drivers/net/ethernet/ec_bhf.c new file +740 -0

740 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

Darek Marcinkiewicz <[email protected]> :
[...]

Quoted 5 lines

This driver adds support for EtherCAT master module located on CCAT FPGA found on Beckhoff CX series industrial PCs. The driver exposes EtherCAT master as an ethernet interface.

EtherCAT is a filedbus protocol defined on top of ethernet and Beckhoff

s/filedbus/fieldbus/ :o)

Quoted 4 lines

CX5020 PCs come with built-in EtherCAT master module located on a FPGA, which in turn is connected to a PCI bus.

I have attached four patches. Patch #3 / 4 contains a bugfix. Remaining patches are small nits.

The points below are not showstoppers. Your answer will be welcome though.

If the tx_desc_free list can turn empty, I don't see much point for not using an array as descriptor ring. It's quite common for linux ethernet drivers.

Be it a list or an array, sizing it as the max count of descriptors that could fit in the memory window through which packet descriptors _and_ ethernet data are copied seems overkill. It may be an upper bound though. If you are not sure about a sane default value, ethtool API allows to change the descriptor ring size.

Given the amount of debug messages, ethtool registers dump support could be of some value.

I guess that the ASIC and the host CPU need some external polling to communicate (no IRQ, really ?), whence the hrtimer. It should naturally fit with NAPI. hrtimer could thus be disabled as soon as some ASIC event is detected. It should save some hrtimer work when load increases and the usual Tx lock avoidance patterns would kick in (current locking is gross).

Did Beckhoff document their FPGA PCI interface ?

Signature · 1 line
Ueimor
Quoted 1 line

From d2a5bfdc7854e9b3cffcab9249299354fa5037d0 Mon Sep 17 00:00:00 2001

Message-Id: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:15:26 +0200
Subject: [PATCH 1/4] ec_bhf: inverted xmas tree.
X-Organisation: Land of Sunshine Inc.

---
 drivers/net/ethernet/ec_bhf.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/ec_bhf.c +4 -4
index 8e78b8d..9e1636b 100644
@@ -205,8 +205,8 @@ static void ec_bhf_reset(struct ec_bhf_priv *priv)
 
 static void ec_bhf_send_packet(struct ec_bhf_priv *priv, struct tx_desc *desc)
 {
-	u32 addr = (u8 *)desc - priv->tx_buf.buf;
 	u32 len = le16_to_cpu(desc->header.len) + sizeof(desc->header);
+	u32 addr = (u8 *)desc - priv->tx_buf.buf;
 
 	iowrite32((ALIGN(len, 8) << 24) | addr, priv->fifo_io + FIFO_TX_REG);
 
@@ -598,11 +598,11 @@ static const struct net_device_ops ec_bhf_netdev_ops = {
 
 static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	int err = 0;
-	void * __iomem io;
-	void * __iomem dma_io;
 	struct net_device *net_dev;
 	struct ec_bhf_priv *priv;
+	void * __iomem dma_io;
+	void * __iomem io;
+	int err = 0;
 
 	err = pci_enable_device(dev);
 	if (err)
Signature · 1 line
1.9.0
Quoted 1 line

From b64a35b7f4190a8126bc7b393370c711285f8c30 Mon Sep 17 00:00:00 2001

Message-Id: <b64a35b7f4190a8126bc7b393370c711285f8c30.1399110121.git.romieu@fr.zoreil.com>
In-Reply-To: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
References: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:31:55 +0200
Subject: [PATCH 2/4] ec_bhf: line breaks and indent.
X-Organisation: Land of Sunshine Inc.

---
 drivers/net/ethernet/ec_bhf.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)
drivers/net/ethernet/ec_bhf.c +16 -20
index 9e1636b..d33b691 100644
@@ -168,23 +168,23 @@ static void ec_bhf_print_status(struct ec_bhf_priv *priv)
 	struct device *dev = PRIV_TO_DEV(priv);
 
 	dev_dbg(dev, "Frame error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_FRAME_ERR_CNT));
+		ioread8(priv->mac_io + MAC_FRAME_ERR_CNT));
 	dev_dbg(dev, "RX error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_RX_ERR_CNT));
+		ioread8(priv->mac_io + MAC_RX_ERR_CNT));
 	dev_dbg(dev, "CRC error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_CRC_ERR_CNT));
+		ioread8(priv->mac_io + MAC_CRC_ERR_CNT));
 	dev_dbg(dev, "TX frame counter: %d\n",
-		 ioread32(priv->mac_io + MAC_TX_FRAME_CNT));
+		ioread32(priv->mac_io + MAC_TX_FRAME_CNT));
 	dev_dbg(dev, "RX frame counter: %d\n",
-		 ioread32(priv->mac_io + MAC_RX_FRAME_CNT));
+		ioread32(priv->mac_io + MAC_RX_FRAME_CNT));
 	dev_dbg(dev, "TX fifo level: %d\n",
-		 ioread8(priv->mac_io + MAC_TX_FIFO_LVL));
+		ioread8(priv->mac_io + MAC_TX_FIFO_LVL));
 	dev_dbg(dev, "Dropped frames: %d\n",
-		 ioread8(priv->mac_io + MAC_DROPPED_FRMS));
+		ioread8(priv->mac_io + MAC_DROPPED_FRMS));
 	dev_dbg(dev, "Connected with CCAT slot: %d\n",
-		 ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG));
+		ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG));
 	dev_dbg(dev, "Link status: %d\n",
-		 ioread8(priv->mii_io + MII_LINK_STATUS));
+		ioread8(priv->mii_io + MII_LINK_STATUS));
 }
 
 static void ec_bhf_reset(struct ec_bhf_priv *priv)
@@ -224,8 +224,7 @@ static void ec_bhf_process_tx(struct ec_bhf_priv *priv)
 	if (list_empty(&priv->tx_desc_queue))
 		goto out;
 
-	desc = list_first_entry(&priv->tx_desc_queue,
-				struct tx_desc, node);
+	desc = list_first_entry(&priv->tx_desc_queue, struct tx_desc, node);
 	sent = le32_to_cpu(desc->header.sent) & TX_HDR_SENT;
 	if (!sent)
 		goto out;
@@ -297,9 +296,8 @@ static void ec_bhf_process_rx(struct ec_bhf_priv *priv)
 
 static enum hrtimer_restart ec_bhf_timer_fun(struct hrtimer *timer)
 {
-	struct ec_bhf_priv *priv = container_of(timer,
-					struct ec_bhf_priv,
-					hrtimer);
+	struct ec_bhf_priv *priv = container_of(timer, struct ec_bhf_priv,
+						hrtimer);
 	ec_bhf_process_rx(priv);
 	ec_bhf_process_tx(priv);
 
@@ -429,8 +427,8 @@ static int ec_bhf_alloc_dma_mem(struct ec_bhf_priv *priv,
 
 	dev_info(dev, "Allocating %d bytes for channel %d",
 		(int)buf->alloc_len, channel);
-	buf->alloc = dma_alloc_coherent(dev, buf->alloc_len,
-					&buf->alloc_phys, GFP_KERNEL);
+	buf->alloc = dma_alloc_coherent(dev, buf->alloc_len, &buf->alloc_phys,
+					GFP_KERNEL);
 	if (buf->alloc == NULL) {
 		dev_info(dev, "Failed to allocate buffer\n");
 		return -ENOMEM;
@@ -529,8 +527,7 @@ static int ec_bhf_open(struct net_device *net_dev)
 
 	hrtimer_init(&priv->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	priv->hrtimer.function = ec_bhf_timer_fun;
-	hrtimer_start(&priv->hrtimer,
-		      ktime_set(0, polling_frequency),
+	hrtimer_start(&priv->hrtimer, ktime_set(0, polling_frequency),
 		      HRTIMER_MODE_REL);
 
 	dev_info(PRIV_TO_DEV(priv), "Device open\n");
@@ -627,8 +624,7 @@ static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	err = pci_request_regions(dev, "ec_bhf");
 	if (err) {
-		dev_err(&dev->dev,
-			"Failed to request pci memory regions\n");
+		dev_err(&dev->dev, "Failed to request pci memory regions\n");
 		goto err_disable_dev;
 	}
 
Signature · 1 line
1.9.0
Quoted 1 line

From a687c964badc9d01e0d2ae269bc5d6996e508dd1 Mon Sep 17 00:00:00 2001

Message-Id: <a687c964badc9d01e0d2ae269bc5d6996e508dd1.1399110121.git.romieu@fr.zoreil.com>
In-Reply-To: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
References: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:36:12 +0200
Subject: [PATCH 3/4] ec_bhf: rx_desc vs tx_desc confusion.
X-Organisation: Land of Sunshine Inc.

---
 drivers/net/ethernet/ec_bhf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ec_bhf.c +1 -1
index d33b691..c697b48 100644
@@ -453,7 +453,7 @@ static void ec_bhf_setup_tx_descs(struct ec_bhf_priv *priv)
 	INIT_LIST_HEAD(&priv->tx_desc_free);
 	INIT_LIST_HEAD(&priv->tx_desc_queue);
 
-	dcount = priv->tx_buf.len / sizeof(struct rx_desc);
+	dcount = priv->tx_buf.len / sizeof(struct tx_desc);
 	for (i = 0; i < dcount; i++) {
 		struct tx_desc *desc = descs + i;
 		list_add_tail(&desc->node, &priv->tx_desc_free);
Signature · 1 line
1.9.0
Quoted 1 line

From d47e13a4a22a5e5ebc32d88397acd702f1ae95d4 Mon Sep 17 00:00:00 2001

Message-Id: <d47e13a4a22a5e5ebc32d88397acd702f1ae95d4.1399110121.git.romieu@fr.zoreil.com>
In-Reply-To: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
References: <d2a5bfdc7854e9b3cffcab9249299354fa5037d0.1399110121.git.romieu@fr.zoreil.com>
From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:40:37 +0200
Subject: [PATCH 4/4] ec_bhf: use once variable removal.
X-Organisation: Land of Sunshine Inc.

---
 drivers/net/ethernet/ec_bhf.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/ethernet/ec_bhf.c +3 -6
index c697b48..10dbcc4 100644
@@ -448,16 +448,13 @@ static int ec_bhf_alloc_dma_mem(struct ec_bhf_priv *priv,
 static void ec_bhf_setup_tx_descs(struct ec_bhf_priv *priv)
 {
 	struct tx_desc *descs = (struct tx_desc *) priv->tx_buf.buf;
-	int dcount, i;
+	int i;
 
 	INIT_LIST_HEAD(&priv->tx_desc_free);
 	INIT_LIST_HEAD(&priv->tx_desc_queue);
 
-	dcount = priv->tx_buf.len / sizeof(struct tx_desc);
-	for (i = 0; i < dcount; i++) {
-		struct tx_desc *desc = descs + i;
-		list_add_tail(&desc->node, &priv->tx_desc_free);
-	}
+	for (i = 0; i < priv->tx_buf.len / sizeof(struct tx_desc); i++)
+		list_add_tail(&descs[i].node, &priv->tx_desc_free);
 }
 
 static void ec_bhf_setup_rx_descs(struct ec_bhf_priv *priv)
Signature · 1 line
1.9.0
author maintainer
#2 lore raw
Quoted 10 lines · Francois Romieu

Darek Marcinkiewicz <[email protected]> :
[...]

Quoted 5 lines

This driver adds support for EtherCAT master module located on CCAT FPGA found on Beckhoff CX series industrial PCs. The driver exposes EtherCAT master as an ethernet interface.

EtherCAT is a filedbus protocol defined on top of ethernet and Beckhoff

s/filedbus/fieldbus/ :o)

Ops :) Fixed in next revision of the patch.

Quoted 8 lines
Quoted 4 lines

CX5020 PCs come with built-in EtherCAT master module located on a FPGA, which in turn is connected to a PCI bus.

I have attached four patches. Patch #3 / 4 contains a bugfix. Remaining patches are small nits.

Thank you. I am attaching 2 of thse to this repsonse - the other two are no longer relevant due to the changes I made into the driver. One of the attached patches is slightly modfied by simply having one hunk removed (that hunk was applying to the code that was removed in next rev of the driver). Not sure how to proceed with those patches, shall I simply sent out these patches to this list as a separate messages?

Quoted 6 lines

The points below are not showstoppers. Your answer will be welcome though.

If the tx_desc_free list can turn empty, I don't see much point for not using an array as descriptor ring. It's quite common for linux ethernet drivers.

I have switched the code to use array of descriptors. Yep, lists do not make too much sense here.

Quoted 6 lines

Be it a list or an array, sizing it as the max count of descriptors that could fit in the memory window through which packet descriptors _and_ ethernet data are copied seems overkill. It may be an upper bound though. If you are not sure about a sane default value, ethtool API allows to change the descriptor ring size.

I have changed the code to use much modest value - it is set to be of the size of the fifo now. I think that this value is much better, but of course having this configurable would be even better.

Quoted 10 lines

Given the amount of debug messages, ethtool registers dump support could be of some value.

I guess that the ASIC and the host CPU need some external polling to communicate (no IRQ, really ?), whence the hrtimer. It should naturally fit with NAPI. hrtimer could thus be disabled as soon as some ASIC event is detected. It should save some hrtimer work when load increases and the usual Tx lock avoidance patterns would kick in (current locking is gross).

No, there is really no interrupt, hence the timer. Also on this device I wouldn't expect any bursts of data. What happens here, during regular operation of the device, is a periodic exchange of (few) ethernet packets between host cpu and terminals attached to the EtherCAT bus. As for the locking on the tx path, I have removed that completely on receiving path. I simply didn't know that it is such a big no-no here :)

Quoted 2 lines

Did Beckhoff document their FPGA PCI interface ?

Yes. It took a lot of nagging but I got some documentation from them, together with a sample code showing how to use dma interface and generally interact with the device.

Thank you!

Signature · 1 line
DM
Quoted 1 line

From 4254a10cb8407634c94882f0f64c8e4a7f84b852 Mon Sep 17 00:00:00 2001

From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:15:26 +0200
Subject: [PATCH 1/2] ec_bhf: inverted xmas tree.

---
 drivers/net/ethernet/ec_bhf.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/ec_bhf.c +4 -4
index feb40cd..e6e303c 100644
@@ -204,8 +204,8 @@ static void ec_bhf_reset(struct ec_bhf_priv *priv)
 
 static void ec_bhf_send_packet(struct ec_bhf_priv *priv, struct tx_desc *desc)
 {
-	u32 addr = (u8 *)desc - priv->tx_buf.buf;
 	u32 len = le16_to_cpu(desc->header.len) + sizeof(desc->header);
+	u32 addr = (u8 *)desc - priv->tx_buf.buf;
 
 	iowrite32((ALIGN(len, 8) << 24) | addr, priv->fifo_io + FIFO_TX_REG);
 
@@ -561,11 +561,11 @@ static const struct net_device_ops ec_bhf_netdev_ops = {
 
 static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
 {
-	int err = 0;
-	void * __iomem io;
-	void * __iomem dma_io;
 	struct net_device *net_dev;
 	struct ec_bhf_priv *priv;
+	void * __iomem dma_io;
+	void * __iomem io;
+	int err = 0;
 
 	err = pci_enable_device(dev);
 	if (err)
Signature · 1 line
1.7.10.4
Quoted 1 line

From d20cec3758521de9c5c9c7a35c0a96a3671bc2c2 Mon Sep 17 00:00:00 2001

From: Francois Romieu <[email protected]>
Date: Sat, 3 May 2014 11:31:55 +0200
Subject: [PATCH 2/2] ec_bhf: line breaks and indent.

---
 drivers/net/ethernet/ec_bhf.c |   33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)
drivers/net/ethernet/ec_bhf.c +15 -18
index e6e303c..46618b9 100644
@@ -167,23 +167,23 @@ static void ec_bhf_print_status(struct ec_bhf_priv *priv)
 	struct device *dev = PRIV_TO_DEV(priv);
 
 	dev_dbg(dev, "Frame error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_FRAME_ERR_CNT));
+		ioread8(priv->mac_io + MAC_FRAME_ERR_CNT));
 	dev_dbg(dev, "RX error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_RX_ERR_CNT));
+		ioread8(priv->mac_io + MAC_RX_ERR_CNT));
 	dev_dbg(dev, "CRC error counter: %d\n",
-		 ioread8(priv->mac_io + MAC_CRC_ERR_CNT));
+		ioread8(priv->mac_io + MAC_CRC_ERR_CNT));
 	dev_dbg(dev, "TX frame counter: %d\n",
-		 ioread32(priv->mac_io + MAC_TX_FRAME_CNT));
+		ioread32(priv->mac_io + MAC_TX_FRAME_CNT));
 	dev_dbg(dev, "RX frame counter: %d\n",
-		 ioread32(priv->mac_io + MAC_RX_FRAME_CNT));
+		ioread32(priv->mac_io + MAC_RX_FRAME_CNT));
 	dev_dbg(dev, "TX fifo level: %d\n",
-		 ioread8(priv->mac_io + MAC_TX_FIFO_LVL));
+		ioread8(priv->mac_io + MAC_TX_FIFO_LVL));
 	dev_dbg(dev, "Dropped frames: %d\n",
-		 ioread8(priv->mac_io + MAC_DROPPED_FRMS));
+		ioread8(priv->mac_io + MAC_DROPPED_FRMS));
 	dev_dbg(dev, "Connected with CCAT slot: %d\n",
-		 ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG));
+		ioread8(priv->mac_io + MAC_CONNECTED_CCAT_FLAG));
 	dev_dbg(dev, "Link status: %d\n",
-		 ioread8(priv->mii_io + MII_LINK_STATUS));
+		ioread8(priv->mii_io + MII_LINK_STATUS));
 }
 
 static void ec_bhf_reset(struct ec_bhf_priv *priv)
@@ -277,9 +277,8 @@ static void ec_bhf_process_rx(struct ec_bhf_priv *priv)
 
 static enum hrtimer_restart ec_bhf_timer_fun(struct hrtimer *timer)
 {
-	struct ec_bhf_priv *priv = container_of(timer,
-					struct ec_bhf_priv,
-					hrtimer);
+	struct ec_bhf_priv *priv = container_of(timer, struct ec_bhf_priv,
+						hrtimer);
 	ec_bhf_process_rx(priv);
 	ec_bhf_process_tx(priv);
 
@@ -401,8 +400,8 @@ static int ec_bhf_alloc_dma_mem(struct ec_bhf_priv *priv,
 
 	dev_info(dev, "Allocating %d bytes for channel %d",
 		(int)buf->alloc_len, channel);
-	buf->alloc = dma_alloc_coherent(dev, buf->alloc_len,
-					&buf->alloc_phys, GFP_KERNEL);
+	buf->alloc = dma_alloc_coherent(dev, buf->alloc_len, &buf->alloc_phys,
+					GFP_KERNEL);
 	if (buf->alloc == NULL) {
 		dev_info(dev, "Failed to allocate buffer\n");
 		return -ENOMEM;
@@ -492,8 +491,7 @@ static int ec_bhf_open(struct net_device *net_dev)
 
 	hrtimer_init(&priv->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	priv->hrtimer.function = ec_bhf_timer_fun;
-	hrtimer_start(&priv->hrtimer,
-		      ktime_set(0, polling_frequency),
+	hrtimer_start(&priv->hrtimer, ktime_set(0, polling_frequency),
 		      HRTIMER_MODE_REL);
 
 	dev_info(PRIV_TO_DEV(priv), "Device open\n");
@@ -590,8 +588,7 @@ static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
 
 	err = pci_request_regions(dev, "ec_bhf");
 	if (err) {
-		dev_err(&dev->dev,
-			"Failed to request pci memory regions\n");
+		dev_err(&dev->dev, "Failed to request pci memory regions\n");
 		goto err_disable_dev;
 	}
 
Signature · 1 line
1.7.10.4
author maintainer
#3 lore raw
Quoted 1 line · Darek Marcinkiewicz
Quoted 1 line

...

Quoted 2 lines

attached to the EtherCAT bus. As for the locking on the tx path, I have removed that completely on receiving path. I simply didn't know

...
Erm. I meant - I have removed it on the tx path. It was gone on rx path already a few patch revs ago :)

Signature · 1 line
DM
#4 lore raw
In reply to Darek Marcinkiewicz

Darek Marcinkiewicz <[email protected]> :

Quoted 1 line · Francois Romieu

[...]

Quoted 6 lines

Thank you. I am attaching 2 of thse to this repsonse - the other two are no longer relevant due to the changes I made into the driver. One of the attached patches is slightly modfied by simply having one hunk removed (that hunk was applying to the code that was removed in next rev of the driver). Not sure how to proceed with those patches, shall I simply sent out these patches to this list as a separate messages?

You should submit a complete series if you want them separated - git format-patch does wonders here - or include these directly in your own patch as I don't really care for the credit.

[...]

Quoted 3 lines

I have changed the code to use much modest value - it is set to be of the size of the fifo now. I think that this value is much better, but of course having this configurable would be even better.

(see ethtool_ops.[gs]et_ringparam)

[...]

Quoted 6 lines

No, there is really no interrupt, hence the timer. Also on this device I wouldn't expect any bursts of data. What happens here, during regular operation of the device, is a periodic exchange of (few) ethernet packets between host cpu and terminals attached to the EtherCAT bus. As for the locking on the tx path, I have removed that completely on receiving path. I simply didn't know that it is such a big no-no here :)

Ok.

Regarding tx_dnext updates, you may add a short notice in ec_bhf_start_xmit and ec_bhf_process_tx explaining that the periodic poller will somehow end working with the right value, whence no (smp_)barrier at all.

Signature · 1 line
Ueimor
author maintainer
#5 lore raw
Quoted 10 lines · Francois Romieu

Darek Marcinkiewicz <[email protected]> :

Quoted 1 line · Francois Romieu

[...]

Quoted 6 lines

Thank you. I am attaching 2 of thse to this repsonse - the other two are no longer relevant due to the changes I made into the driver. One of the attached patches is slightly modfied by simply having one hunk removed (that hunk was applying to the code that was removed in next rev of the driver). Not sure how to proceed with those patches, shall I simply sent out these patches to this list as a separate messages?

Quoted 4 lines

You should submit a complete series if you want them separated - git format-patch does wonders here - or include these directly in your own patch as I don't really care for the credit.

Ok. I've coalesced them into single patch. Thanks.

Quoted 7 lines

[...]

Quoted 3 lines

I have changed the code to use much modest value - it is set to be of the size of the fifo now. I think that this value is much better, but of course having this configurable would be even better.

(see ethtool_ops.[gs]et_ringparam)

After giving it a little though I came to the consclusion that in reality it won't bring much value. So, if it is a showstopper, I would leave it at that.

Quoted 8 lines

[...]

Quoted 6 lines

No, there is really no interrupt, hence the timer. Also on this device I wouldn't expect any bursts of data. What happens here, during regular operation of the device, is a periodic exchange of (few) ethernet packets between host cpu and terminals attached to the EtherCAT bus. As for the locking on the tx path, I have removed that completely on receiving path. I simply didn't know that it is such a big no-no here :)

Quoted 6 lines

Ok.

Regarding tx_dnext updates, you may add a short notice in ec_bhf_start_xmit and ec_bhf_process_tx explaining that the periodic poller will somehow end working with the right value, whence no (smp_)barrier at all.

Hmm, good point. I am not really sure that it is not a race. So, I've added memory barriers for the case when the tx ring becomes full.

About to send out new patch revison.

Signature · 1 line
DM
#6 lore raw

Darek Marcinkiewicz <[email protected]> :

Quoted 1 line · Francois Romieu

[...]

Quoted 6 lines
Quoted 4 lines

Regarding tx_dnext updates, you may add a short notice in ec_bhf_start_xmit and ec_bhf_process_tx explaining that the periodic poller will somehow end working with the right value, whence no (smp_)barrier at all.

Hmm, good point. I am not really sure that it is not a race. So, I've added memory barriers for the case when the tx ring becomes full.

Without memory barrier, the hrtimer poller may be wrong but 1) it will always be pessimistic and 2) it won't last. It would be sloppy though.

Did you have some time to test the latest version ?

Signature · 1 line
Ueimor
author maintainer
#7 lore raw
Quoted 7 lines · Francois Romieu

Darek Marcinkiewicz <[email protected]> :

Quoted 1 line · Francois Romieu

[...]

Quoted 4 lines
Quoted 4 lines

Regarding tx_dnext updates, you may add a short notice in ec_bhf_start_xmit and ec_bhf_process_tx explaining that the periodic poller will somehow end working with the right value, whence no (smp_)barrier at all.

Quoted 8 lines
Quoted 2 lines

Hmm, good point. I am not really sure that it is not a race. So, I've added memory barriers for the case when the tx ring becomes full.

Without memory barrier, the hrtimer poller may be wrong but 1) it will always be pessimistic and 2) it won't last. It would be sloppy though.

Did you have some time to test the latest version ?

Yes, I have this code continuously running and it looks good. This is a regular application that I have running now, so not all interesting edge cases might have been exercised, though.

Signature · 1 line
DM