Skip to contentSkip to conversation

Introduce fieldbus_dev configuration interface

PATCH In review Sven Van Asbroeck 2 participants 14 messages Sep 18, 2019 – Oct 2, 2019

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

cover Introduce fieldbus_dev configuration interface

Introduce a (userspace) config interface for fieldbus_dev.
Add support for the HMS FL-NET controller, which requires config support, and
is its first in-kernel user.

Sven Van Asbroeck (5):
staging: fieldbus core: remove unused strings
staging: fieldbus: move "offline mode" definition to fieldbus core
staging: fieldbus core: add support for device configuration
staging: fieldbus core: add support for FL-NET devices
staging: fieldbus: add support for HMS FL-NET industrial controller

 .../Documentation/ABI/configfs-fieldbus-dev   |  90 +++
 .../ABI/sysfs-class-fieldbus-dev              |   1 +
 .../fieldbus/Documentation/fieldbus_dev.txt   |  60 +-
 drivers/staging/fieldbus/Kconfig              |  14 +
 drivers/staging/fieldbus/Makefile             |   5 +-
 drivers/staging/fieldbus/anybuss/Kconfig      |  17 +
 drivers/staging/fieldbus/anybuss/Makefile     |   1 +
 .../staging/fieldbus/anybuss/anybuss-client.h |  11 +-
 drivers/staging/fieldbus/anybuss/hms-flnet.c  | 520 ++++++++++++++++++
 .../staging/fieldbus/anybuss/hms-profinet.c   |   2 +-
 drivers/staging/fieldbus/anybuss/host.c       |   6 +-
 drivers/staging/fieldbus/dev_config.c         | 383 +++++++++++++
 drivers/staging/fieldbus/dev_config.h         |  41 ++
 drivers/staging/fieldbus/dev_core.c           |  28 +-
 drivers/staging/fieldbus/fieldbus_dev.h       |  56 ++
 15 files changed, 1211 insertions(+), 24 deletions(-)
 create mode 100644 drivers/staging/fieldbus/Documentation/ABI/configfs-fieldbus-dev
 create mode 100644 drivers/staging/fieldbus/anybuss/hms-flnet.c
 create mode 100644 drivers/staging/fieldbus/dev_config.c
 create mode 100644 drivers/staging/fieldbus/dev_config.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 staging: fieldbus core: remove unused strings

Remove two unused static const strings - a leftover from a previous stage. Interestingly, neither gcc nor sparse warned about their presence.

---
 drivers/staging/fieldbus/dev_core.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/staging/fieldbus/dev_core.c +0 -3
index f6f5b92ba914..1ba0234cc60d 100644
@@ -23,9 +23,6 @@ static dev_t fieldbus_devt;
 static DEFINE_IDA(fieldbus_ida);
 static DEFINE_MUTEX(fieldbus_mtx);
 
-static const char ctrl_enabled[] = "enabled";
-static const char ctrl_disabled[] = "disabled";
-
 static ssize_t online_show(struct device *dev, struct device_attribute *attr,
 			   char *buf)
 {
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 staging: fieldbus: move "offline mode" definition to fieldbus core

In reply to Sven Van Asbroeck

anybus-s cards use the "offline mode" property to determine if process memory should be clear, set, or frozen when the card is offline.

Move this property to the fieldbus core, so that it can become part of the future fieldbus config interface.

---
 drivers/staging/fieldbus/anybuss/anybuss-client.h | 11 ++++-------
 drivers/staging/fieldbus/anybuss/hms-profinet.c   |  2 +-
 drivers/staging/fieldbus/anybuss/host.c           |  6 +++---
 drivers/staging/fieldbus/fieldbus_dev.h           |  6 ++++++
 4 files changed, 14 insertions(+), 11 deletions(-)
drivers/staging/fieldbus/anybuss/anybuss-client.h +4 -7
index 0c4b6a1ffe10..8ee1f1baccf1 100644
@@ -12,6 +12,9 @@
 #include <linux/types.h>
 #include <linux/poll.h>
 
+/* move to <linux/fieldbus_dev.h> when taking this out of staging */
+#include "../fieldbus_dev.h"
+
 struct anybuss_host;
 
 struct anybuss_client {
@@ -61,12 +64,6 @@ anybuss_set_drvdata(struct anybuss_client *client, void *data)
 
 int anybuss_set_power(struct anybuss_client *client, bool power_on);
 
-enum anybuss_offl_mode {
-	AB_OFFL_MODE_CLEAR = 0,
-	AB_OFFL_MODE_FREEZE,
-	AB_OFFL_MODE_SET
-};
-
 struct anybuss_memcfg {
 	u16 input_io;
 	u16 input_dpram;
@@ -76,7 +73,7 @@ struct anybuss_memcfg {
 	u16 output_dpram;
 	u16 output_total;
 
-	enum anybuss_offl_mode offl_mode;
+	enum fieldbus_dev_offl_mode offl_mode;
 };
 
 int anybuss_start_init(struct anybuss_client *client,
drivers/staging/fieldbus/anybuss/hms-profinet.c +1 -1
index 5446843e35f4..31c43a0a5776 100644
@@ -96,7 +96,7 @@ static int __profi_enable(struct profi_priv *priv)
 		.output_io = 220,
 		.output_dpram = PROFI_DPRAM_SIZE,
 		.output_total = PROFI_DPRAM_SIZE,
-		.offl_mode = AB_OFFL_MODE_CLEAR,
+		.offl_mode = FIELDBUS_DEV_OFFL_MODE_CLEAR,
 	};
 
 	/*
drivers/staging/fieldbus/anybuss/host.c +3 -3
index f69dc4930457..549cb7d51af8 100644
@@ -1022,13 +1022,13 @@ int anybuss_start_init(struct anybuss_client *client,
 	};
 
 	switch (cfg->offl_mode) {
-	case AB_OFFL_MODE_CLEAR:
+	case FIELDBUS_DEV_OFFL_MODE_CLEAR:
 		op_mode = 0;
 		break;
-	case AB_OFFL_MODE_FREEZE:
+	case FIELDBUS_DEV_OFFL_MODE_FREEZE:
 		op_mode = OP_MODE_FBFC;
 		break;
-	case AB_OFFL_MODE_SET:
+	case FIELDBUS_DEV_OFFL_MODE_SET:
 		op_mode = OP_MODE_FBS;
 		break;
 	default:
drivers/staging/fieldbus/fieldbus_dev.h +6 -0
index a10fc3b446dc..301dca3b8d71 100644
@@ -15,6 +15,12 @@ enum fieldbus_dev_type {
 	FIELDBUS_DEV_TYPE_PROFINET,
 };
 
+enum fieldbus_dev_offl_mode {
+	FIELDBUS_DEV_OFFL_MODE_CLEAR = 0,
+	FIELDBUS_DEV_OFFL_MODE_FREEZE,
+	FIELDBUS_DEV_OFFL_MODE_SET
+};
+
 /**
  * struct fieldbus_dev - Fieldbus device
  * @read_area:		[DRIVER] function to read the process data area of the
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 staging: fieldbus core: add support for device configuration

In reply to Sven Van Asbroeck

Support device configuration by adding

- an in-kernel driver config API, and
- a configfs-based userspace config ABI

In short, drivers pick a subset from a set of standardized config properties. This is exposed by the fieldbus core as configfs files. Userspace may then configure the device by writing to these configfs files, prior to enabling the device.

For more details, refer to the included documentation.

---
 .../Documentation/ABI/configfs-fieldbus-dev   |  90 ++++
 .../fieldbus/Documentation/fieldbus_dev.txt   |  60 ++-
 drivers/staging/fieldbus/Kconfig              |  14 +
 drivers/staging/fieldbus/Makefile             |   5 +-
 drivers/staging/fieldbus/dev_config.c         | 383 ++++++++++++++++++
 drivers/staging/fieldbus/dev_config.h         |  41 ++
 drivers/staging/fieldbus/dev_core.c           |  22 +
 drivers/staging/fieldbus/fieldbus_dev.h       |  49 +++
 8 files changed, 654 insertions(+), 10 deletions(-)
 create mode 100644 drivers/staging/fieldbus/Documentation/ABI/configfs-fieldbus-dev
 create mode 100644 drivers/staging/fieldbus/dev_config.c
 create mode 100644 drivers/staging/fieldbus/dev_config.h
drivers/staging/fieldbus/Documentation/ABI/configfs-fieldbus-dev new file +90 -0
new file mode 100644
index 000000000000..fc60460b62f9
@@ -0,0 +1,90 @@
+What: 		/config/fieldbus_dev/fieldbus_dev<num>
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description: 	Interface used to configure and enable/disable fieldbus devices.
+
+		Attributes are visible only when configfs is mounted. To mount
+		configfs in /config directory use:
+		# mount -t configfs none /config/
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/enable
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Whether the device is enabled (power on) or
+			disabled (power off).
+		Possible values:
+			'1' meaning enabled
+			'0' meaning disabled
+		Writing '1' enables the device (power on) with settings
+			described by the configfs properties in this directory.
+		Writing '0' disables the card (power off).
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/macaddr
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		mac address of the device, eg. E8:B3:1F:0C:6D:19
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/ipaddr
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		IPv4 address of the device, in dotted notation
+			(eg. 192.168.22.50).
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/offline_mode
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Behaviour of the process data memory when the fieldbus goes
+			offline.
+		Possible values:
+			'clear'  meaning 'All data is cleared'.
+			'freeze' meaning 'All data is frozen in its current
+					state'.
+			'set'	 meaning 'All data is set'.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/rev_number
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Revision number of the device.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/rev_date_year
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Year of revision for the device.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/rev_date_month
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Month of revision for the device.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/rev_date_day
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		Day of revision for the device.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/id_type
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		The type id by which the card identifies itself on the network.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/id_vendor
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		The vendor id by which the card identifies itself on the
+		network.
+
+What: 		/config/fieldbus_dev/fieldbus_dev<num>/id_product
+KernelVersion:	5.4 (staging)
+Contact:	Sven Van Asbroeck <[email protected]>
+Description:
+		The product id by which the card identifies itself on the
+		network.
drivers/staging/fieldbus/Documentation/fieldbus_dev.txt +52 -8

69 lines not on this page · raw message

drivers/staging/fieldbus/Kconfig +14 -0
index b0b865acccfb..26df88a32895 100644
@@ -15,5 +15,19 @@ menuconfig FIELDBUS_DEV
 
 	  If unsure, say no.
 
+if FIELDBUS_DEV
+
+config FIELDBUS_DEV_CONFIG
+	tristate "Fieldbus Device configuration support"
+	select CONFIGFS_FS
+	help
+	  Select this option to enable support for Fieldbus Device
+	  configuration. The configurable groups will be visible under
+	  /config/fieldbus_dev, assuming configfs is mounted under /config.
+
+	  If unsure, say no.
+
+endif	# FIELDBUS_DEV
+
 source "drivers/staging/fieldbus/anybuss/Kconfig"
 
drivers/staging/fieldbus/Makefile +3 -2
index bdf645d41344..6dbb9d398390 100644
@@ -3,5 +3,6 @@
 # Makefile for fieldbus_dev drivers.
 #
 
-obj-$(CONFIG_FIELDBUS_DEV)	+= fieldbus_dev.o anybuss/
-fieldbus_dev-y			:= dev_core.o
+obj-$(CONFIG_FIELDBUS_DEV)		+= fieldbus_dev.o anybuss/
+fieldbus_dev-y				:= dev_core.o
+obj-$(CONFIG_FIELDBUS_DEV_CONFIG)	+= dev_config.o
drivers/staging/fieldbus/dev_config.c new file +383 -0

383 lines not on this page · raw message

drivers/staging/fieldbus/dev_config.h new file +41 -0

41 lines not on this page · raw message

drivers/staging/fieldbus/dev_core.c +22 -0
index 1ba0234cc60d..9903c4f3cba9 100644
@@ -15,6 +15,8 @@
 /* move to <linux/fieldbus_dev.h> when taking this out of staging */
 #include "fieldbus_dev.h"
 
+#include "dev_config.h"
+
 /* Maximum number of fieldbus devices */
 #define MAX_FIELDBUSES		32
 
@@ -249,6 +251,7 @@ static void __fieldbus_dev_unregister(struct fieldbus_dev *fb)
 {
 	if (!fb)
 		return;
+	fieldbus_dev_config_unregister(fb->cfg);
 	device_destroy(&fieldbus_class, fb->cdev.dev);
 	cdev_del(&fb->cdev);
 	ida_simple_remove(&fieldbus_ida, fb->id);
@@ -289,8 +292,19 @@ static int __fieldbus_dev_register(struct fieldbus_dev *fb)
 		err = PTR_ERR(fb->dev);
 		goto err_dev_create;
 	}
+	/* configuration interface required? */
+	if (fb->cfgprops || fb->num_cfgprops || fb->get_cfgprop ||
+	    fb->set_cfgprop || fb->enable_set) {
+		fb->cfg = fieldbus_dev_config_register(fb);
+		if (IS_ERR(fb->cfg)) {
+			err = PTR_ERR(fb->cfg);
+			goto err_cfg_create;
+		}
+	}
 	return 0;
 
+err_cfg_create:
+	device_destroy(&fieldbus_class, fb->cdev.dev);
 err_dev_create:
 	cdev_del(&fb->cdev);
 err_cdev:
@@ -325,8 +339,15 @@ static int __init fieldbus_init(void)
 		pr_err("fieldbus_dev: unable to allocate char dev region\n");
 		goto err_alloc;
 	}
+	err = fieldbus_dev_config_init();
+	if (err < 0) {
+		pr_err("fieldbus_dev: unable to init config");
+		goto err_config;
+	}
 	return 0;
 
+err_config:
+	unregister_chrdev_region(fieldbus_devt, MAX_FIELDBUSES);
 err_alloc:
 	class_unregister(&fieldbus_class);
 	return err;
@@ -334,6 +355,7 @@ static int __init fieldbus_init(void)
 
 static void __exit fieldbus_exit(void)
 {
+	fieldbus_dev_config_exit();
 	unregister_chrdev_region(fieldbus_devt, MAX_FIELDBUSES);
 	class_unregister(&fieldbus_class);
 	ida_destroy(&fieldbus_ida);
drivers/staging/fieldbus/fieldbus_dev.h +49 -0

79 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#4 lore raw

Re: [PATCH v1 3/5] staging: fieldbus core: add support for device configuration

Quoted 9 lines · Sven Van Asbroeck

Support device configuration by adding

- an in-kernel driver config API, and
- a configfs-based userspace config ABI

In short, drivers pick a subset from a set of standardized config properties. This is exposed by the fieldbus core as configfs files. Userspace may then configure the device by writing to these configfs files, prior to enabling the device.

Why is a new way of doing configuration needed here? What does this provide that the current code doesn't already do?

And have you looked at the recent configfs fixes to make sure this code still works with them? I can't test this so rebasing this on 5.4-rc1 would be good for you to do first.

thanks,

greg k-h

#5 lore raw

Re: [PATCH v1 3/5] staging: fieldbus core: add support for device configuration

Quoted 3 lines · Greg KH

Why is a new way of doing configuration needed here? What does this provide that the current code doesn't already do?

The fieldbus core doesn't have a configuration mechanism yet. This patch adds one.
I deliberately omitted configuration when the core was added - I wanted to keep complexity to a minimum. I'm sorry I didn't make this clearer.

As a result, the current core can only work with cards that either don't require any config, or get it straight from the network/PLC. Profinet is a good example of this. Most cards do require config however. So does the hms flnet card, which I tried to add in the patchset.

Quoted 4 lines

And have you looked at the recent configfs fixes to make sure this code still works with them? I can't test this so rebasing this on 5.4-rc1 would be good for you to do first.

Thanks for the heads-up! I will test that out.

maintainer
#6 lore raw

Re: [PATCH v1 3/5] staging: fieldbus core: add support for device configuration

Quoted 10 lines · Sven Van Asbroeck
Quoted 3 lines · Greg KH

Why is a new way of doing configuration needed here? What does this provide that the current code doesn't already do?

The fieldbus core doesn't have a configuration mechanism yet. This patch adds one.
I deliberately omitted configuration when the core was added - I wanted to keep complexity to a minimum. I'm sorry I didn't make this clearer.

Quoted 4 lines

As a result, the current core can only work with cards that either don't require any config, or get it straight from the network/PLC. Profinet is a good example of this. Most cards do require config however. So does the hms flnet card, which I tried to add in the patchset.

If the code works with some subset now, then why not work to get this cleaned up properly and out of staging and then add new features like this type of configuration system afterward?

Why is this a requirement to add while the code is in staging?

thanks,

greg k-h

#7 lore raw

Re: [PATCH v1 3/5] staging: fieldbus core: add support for device configuration

Quoted 6 lines · Greg KH

If the code works with some subset now, then why not work to get this cleaned up properly and out of staging and then add new features like this type of configuration system afterward?

Why is this a requirement to add while the code is in staging?

I believe we put this code in staging/ not because there were issues with the codebase itself. But rather because the subsystem needs more industry interest and developer sign-offs. The TODO reflects that.

And that will be very hard to do without some form of a config interface, which this patchset adds.

Perhaps the time isn't ripe for this subsystem yet, although I cannot believe that we are the only ones running Linux on fieldbus 'gadgets'.

#8 lore raw

PATCH 4/5 staging: fieldbus core: add support for FL-NET devices

In reply to Sven Van Asbroeck

Add the FL-NET device type to the fieldbus core.

---
 .../fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev        | 1 +
 drivers/staging/fieldbus/dev_core.c                            | 3 +++
 drivers/staging/fieldbus/fieldbus_dev.h                        | 1 +
 3 files changed, 5 insertions(+)
drivers/staging/fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev +1 -0
index 439f14d33c3b..233c418016aa 100644
@@ -12,6 +12,7 @@ Description:
 		Possible values:
 			'unknown'
 			'profinet'
+			'flnet'
 
 What:		/sys/class/fieldbus_dev/fieldbus_devX/fieldbus_id
 KernelVersion:	5.1 (staging)
drivers/staging/fieldbus/dev_core.c +3 -0
index 9903c4f3cba9..7e9405e52f19 100644
@@ -113,6 +113,9 @@ static ssize_t fieldbus_type_show(struct device *dev,
 	case FIELDBUS_DEV_TYPE_PROFINET:
 		t = "profinet";
 		break;
+	case FIELDBUS_DEV_TYPE_FLNET:
+		t = "flnet";
+		break;
 	default:
 		t = "unknown";
 		break;
drivers/staging/fieldbus/fieldbus_dev.h +1 -0
index 3b00315600e5..f775546b3404 100644
@@ -15,6 +15,7 @@ struct fieldbus_dev_config;
 enum fieldbus_dev_type {
 	FIELDBUS_DEV_TYPE_UNKNOWN = 0,
 	FIELDBUS_DEV_TYPE_PROFINET,
+	FIELDBUS_DEV_TYPE_FLNET
 };
 
 enum fieldbus_dev_offl_mode {
Signature · 1 line
2.17.1
maintainer
#9 lore raw

Re: [PATCH v1 4/5] staging: fieldbus core: add support for FL-NET devices

Quoted 1 line · Sven Van Asbroeck

Add the FL-NET device type to the fieldbus core.

What does this mean?

Quoted 39 lines
---
 .../fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev        | 1 +
 drivers/staging/fieldbus/dev_core.c                            | 3 +++
 drivers/staging/fieldbus/fieldbus_dev.h                        | 1 +
 3 files changed, 5 insertions(+)
drivers/staging/fieldbus/Documentation/ABI/sysfs-class-fieldbus-dev +1 -0
index 439f14d33c3b..233c418016aa 100644
@@ -12,6 +12,7 @@ Description:
 		Possible values:
 			'unknown'
 			'profinet'
+			'flnet'
 
 What:		/sys/class/fieldbus_dev/fieldbus_devX/fieldbus_id
 KernelVersion:	5.1 (staging)
drivers/staging/fieldbus/dev_core.c +3 -0
index 9903c4f3cba9..7e9405e52f19 100644
@@ -113,6 +113,9 @@ static ssize_t fieldbus_type_show(struct device *dev,
 	case FIELDBUS_DEV_TYPE_PROFINET:
 		t = "profinet";
 		break;
+	case FIELDBUS_DEV_TYPE_FLNET:
+		t = "flnet";
+		break;
 	default:
 		t = "unknown";
 		break;
drivers/staging/fieldbus/fieldbus_dev.h +0 -0
index 3b00315600e5..f775546b3404 100644

drivers/staging/fieldbus/fieldbus_dev.h struct fieldbus_dev_config; · line 18

Quoted 4 lines
drivers/staging/fieldbus/fieldbus_dev.h +1 -0
@@ -15,6 +15,7 @@ struct fieldbus_dev_config;
 enum fieldbus_dev_type {
 	FIELDBUS_DEV_TYPE_UNKNOWN = 0,
 	FIELDBUS_DEV_TYPE_PROFINET,
+	FIELDBUS_DEV_TYPE_FLNET

You add an unspecified enumerated type and suddenly new hardware starts working? That feels really wrong to me...

greg k-h

#10 lore raw

Re: [PATCH v1 4/5] staging: fieldbus core: add support for FL-NET devices

Quoted 9 lines · Greg KH
Quoted 1 line · Sven Van Asbroeck

Add the FL-NET device type to the fieldbus core.

What does this mean?

You add an unspecified enumerated type and suddenly new hardware starts working? That feels really wrong to me...

This just empowers fieldbus devices to id themselves as 'flnet' when they register with the core:

priv->fbdev.fieldbus_type = FIELDBUS_DEV_TYPE_FLNET;
...
err = fieldbus_dev_register(&priv->fbdev);

The core exports this as a sysfs property, so that userspace has a standardized way of determining the fieldbus type when looking at the fieldbus dev's sysfs dir.

Yes the commit message is too confusing. I'll write a better one if/when I repost flnet support. Might be a while because you indicated "no new h/w support while still in staging".

#11 lore raw

PATCH 5/5 staging: fieldbus: add support for HMS FL-NET industrial controller

In reply to Sven Van Asbroeck

The Anybus-S FL-NET provides full FL-NET Class 1 functionality via the patented Anybus-S application interface. Any device supporting this standard can take advantage of the features offered by the module, providing seamless network integration regardless of network type.

FL-NET is a control network, primarily used for interconnection of devices such as PLCs, Robot Controllers and Numerical Control Devices. It features both cyclic and acyclic data exchange capabilities, and uses a token-based communication scheme for data transmission. The Anybus module is classified as a 'Class 1'-node, which means that it supports cyclic data exchange in both directions.

Official documentation:
https://www.anybus.com/docs/librariesprovider7/default-document-library
/manuals-design-guides/hms-scm_1200_073.pdf

This implementation is an Anybus-S client driver, designed to be instantiated by the Anybus-S bus driver when it discovers the FL-NET card.

If loaded successfully, the driver registers itself as a fieldbus_dev, and userspace can access it through the fieldbus_dev interface.

---
 drivers/staging/fieldbus/anybuss/Kconfig     |  17 +
 drivers/staging/fieldbus/anybuss/Makefile    |   1 +
 drivers/staging/fieldbus/anybuss/hms-flnet.c | 520 +++++++++++++++++++
 3 files changed, 538 insertions(+)
 create mode 100644 drivers/staging/fieldbus/anybuss/hms-flnet.c
drivers/staging/fieldbus/anybuss/Kconfig +17 -0
index 635a0a7b7dd2..8441c6ac210b 100644
@@ -38,4 +38,21 @@ config HMS_PROFINET
 
 	  If unsure, say N.
 
+config HMS_FLNET
+	tristate "HMS FL-Net Controller (Anybus-S)"
+	depends on FIELDBUS_DEV && HMS_ANYBUSS_BUS
+	select FIELDBUS_DEV_CONFIG
+	help
+	  If you say yes here you get support for the HMS Industrial
+	  Networks FL-Net Controller.
+
+	  It will be registered with the kernel as a fieldbus_dev,
+	  so userspace can interact with it via the fieldbus_dev userspace
+	  interface(s).
+
+	  This driver can also be built as a module. If so, the module
+	  will be called hms-flnet.
+
+	  If unsure, say N.
+
 endif
drivers/staging/fieldbus/anybuss/Makefile +1 -0
index 3ad3dcc6be56..79c4083508f4 100644
@@ -8,3 +8,4 @@ anybuss_core-y			+= host.o
 
 obj-$(CONFIG_ARCX_ANYBUS_CONTROLLER) += arcx-anybus.o
 obj-$(CONFIG_HMS_PROFINET)	+= hms-profinet.o
+obj-$(CONFIG_HMS_FLNET)		+= hms-flnet.o
drivers/staging/fieldbus/anybuss/hms-flnet.c new file +520 -0

520 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#12 lore raw

Re: [PATCH v1 5/5] staging: fieldbus: add support for HMS FL-NET industrial controller

Quoted 4 lines · Sven Van Asbroeck

The Anybus-S FL-NET provides full FL-NET Class 1 functionality via the patented Anybus-S application interface. Any device supporting this standard can take advantage of the features offered by the module, providing seamless network integration regardless of network type.

Discussing "patented" in a changelog text is a big no-no. Please don't do that. Talk to your corporate lawyers for why not...

Quoted 15 lines

FL-NET is a control network, primarily used for interconnection of devices such as PLCs, Robot Controllers and Numerical Control Devices. It features both cyclic and acyclic data exchange capabilities, and uses a token-based communication scheme for data transmission. The Anybus module is classified as a 'Class 1'-node, which means that it supports cyclic data exchange in both directions.

Official documentation:
https://www.anybus.com/docs/librariesprovider7/default-document-library
/manuals-design-guides/hms-scm_1200_073.pdf

This implementation is an Anybus-S client driver, designed to be instantiated by the Anybus-S bus driver when it discovers the FL-NET card.

Quoted 8 lines

If loaded successfully, the driver registers itself as a fieldbus_dev, and userspace can access it through the fieldbus_dev interface.

---
 drivers/staging/fieldbus/anybuss/Kconfig     |  17 +
 drivers/staging/fieldbus/anybuss/Makefile    |   1 +
 drivers/staging/fieldbus/anybuss/hms-flnet.c | 520 +++++++++++++++++++

Why are you adding support for new things here? New hardware support should _only_ be added once the code is out of staging, otherwise there is no pressure to get it out of this directory structure.

Please work on that first, before adding new stuff like this.

thanks,

greg k-h

#13 lore raw

Re: [PATCH v1 5/5] staging: fieldbus: add support for HMS FL-NET industrial controller

Quoted 3 lines · Greg KH

Discussing "patented" in a changelog text is a big no-no. Please don't do that. Talk to your corporate lawyers for why not...

Interesting. I will definitely have to investigate what's covered by those patents.

Quoted 5 lines

Why are you adding support for new things here? New hardware support should _only_ be added once the code is out of staging, otherwise there is no pressure to get it out of this directory structure.

Because I am adding configuration support, and the existing supported h/w does not require this to operate. So I thought it'd make sense to add at least one in-kernel user of the new config interface.

Would it be a better strategy to add an (optional) config interface to the existing supported h/w in staging/, rather than introducing new h/w ?