Skip to contentSkip to conversation

bus: fsl-mc: enhance Management Complex userspace support

PATCH Superseded Ioana Ciornei 9 participants 40 messages Mar 23, 2018 – Apr 5, 2018

Subsystems (5)
lore
Share & tools
lore

Ioana Ciornei

author maintainer
#0 lore raw

v3 cover bus: fsl-mc: enhance Management Complex userspace support

This patch set adds restool support in fsl-mc bus along with a rescan attribute to the root DPRC container.

Changes in v2:
- changed mc_command in fsl_mc_command structure
- updated fsl_mc_command to use the proper types and moved it in uapi
- added proper sysfs documentation

Changes in v3:
- added the correct license for UAPI files
- removed patches 1 and 3 since they were applied

Ioana Ciornei (4):
bus: fsl-mc: move fsl_mc_command struct in a uapi header
bus: fsl-mc: add restool userspace support
bus: fsl-mc: add root dprc rescan attribute
bus: fsl-mc: add bus rescan attribute

 Documentation/ABI/stable/sysfs-bus-fsl-mc   |  13 ++
 Documentation/ioctl/ioctl-number.txt        |   1 +
 Documentation/networking/dpaa2/overview.rst |   4 +
 MAINTAINERS                                 |   2 +
 drivers/bus/fsl-mc/Kconfig                  |   7 +
 drivers/bus/fsl-mc/Makefile                 |   3 +
 drivers/bus/fsl-mc/dprc-driver.c            |   4 +-
 drivers/bus/fsl-mc/fsl-mc-bus.c             |  95 ++++++++++++
 drivers/bus/fsl-mc/fsl-mc-private.h         |  51 +++++++
 drivers/bus/fsl-mc/fsl-mc-restool.c         | 219 ++++++++++++++++++++++++++++
 include/linux/fsl/mc.h                      |   8 +-
 include/uapi/linux/fsl_mc.h                 |  31 ++++
 12 files changed, 429 insertions(+), 9 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc
 create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.c
 create mode 100644 include/uapi/linux/fsl_mc.h
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v3 1/4 bus: fsl-mc: move fsl_mc_command struct in a uapi header

Define "struct fsl_mc_command" as a structure that can cross the user/kernel boundary. Also change the variable types used with the proper ones.

---
Changes in v2:
- added the patch itself
Changes in v3:
- added the correct license for UAPI files

 MAINTAINERS                 |  1 +
 include/linux/fsl/mc.h      |  8 +-------
 include/uapi/linux/fsl_mc.h | 23 +++++++++++++++++++++++
 3 files changed, 25 insertions(+), 7 deletions(-)
 create mode 100644 include/uapi/linux/fsl_mc.h
MAINTAINERS +1 -0
index 61fd418..861cf1d 100644
@@ -11485,6 +11485,7 @@ S:	Maintained
 F:	drivers/bus/fsl-mc/
 F:	Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt
 F:	Documentation/networking/dpaa2/overview.rst
+F:	include/uapi/linux/fsl_mc.h
 
 QT1010 MEDIA DRIVER
 M:	Antti Palosaari <[email protected]>
include/linux/fsl/mc.h +1 -7
index f27cb14..19a352b 100644
@@ -12,6 +12,7 @@
 #include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/interrupt.h>
+#include <uapi/linux/fsl_mc.h>
 
 #define FSL_MC_VENDOR_FREESCALE	0x1957
 
@@ -198,8 +199,6 @@ struct fsl_mc_device {
 #define to_fsl_mc_device(_dev) \
 	container_of(_dev, struct fsl_mc_device, dev)
 
-#define MC_CMD_NUM_OF_PARAMS	7
-
 struct mc_cmd_header {
 	u8 src_id;
 	u8 flags_hw;
@@ -209,11 +208,6 @@ struct mc_cmd_header {
 	__le16 cmd_id;
 };
 
-struct fsl_mc_command {
-	u64 header;
-	u64 params[MC_CMD_NUM_OF_PARAMS];
-};
-
 enum mc_cmd_status {
 	MC_CMD_STATUS_OK = 0x0, /* Completed successfully */
 	MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */
include/uapi/linux/fsl_mc.h new file +23 -0
new file mode 100644
index 0000000..54590a2
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Management Complex (MC) userspace public interface
+ *
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef _UAPI_FSL_MC_H_
+#define _UAPI_FSL_MC_H_
+
+#define MC_CMD_NUM_OF_PARAMS	7
+
+/**
+ * struct fsl_mc_command - Management Complex (MC) command structure
+ * @header: MC command header
+ * @params: MC command parameters
+ */
+struct fsl_mc_command {
+	__u64 header;
+	__u64 params[MC_CMD_NUM_OF_PARAMS];
+};
+
+#endif /* _UAPI_FSL_MC_H_ */
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v3 1/4] bus: fsl-mc: move fsl_mc_command struct in a uapi header

Thank you for the patch! Perhaps something to improve:

Hi Ioana,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on staging/staging-testing]
[cannot apply to linus/master v4.16-rc6 next-20180323]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Ioana-Ciornei/bus-fsl-mc-enhance-Management-Complex-userspace-support/20180325-034313
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

>> ./usr/include/linux/fsl_mc.h:19: found __[us]{8,16,32,64} type without #include <linux/types.h>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author maintainer
#3 lore raw

PATCH v3 2/4 bus: fsl-mc: add restool userspace support

In reply to Ioana Ciornei

Adding kernel support for restool, a userspace tool for resource management, means exporting an ioctl capable device file representing the root resource container.
This new functionality in the fsl-mc bus driver intends to provide restool an interface to interact with the MC firmware. Commands that are composed in userspace are sent to the MC firmware through the RESTOOL_SEND_MC_COMMAND ioctl.
By default the implicit MC I/O portal is used for this operation, but if the implicit one is busy, a dynamic portal is allocated and then freed upon execution.

---
Changes in v2:
- split the bus/driver changes in a separate patch
- moved the ioctl in the uapi header file
Changes in v3:
- no change

 Documentation/ioctl/ioctl-number.txt        |   1 +
 Documentation/networking/dpaa2/overview.rst |   4 +
 drivers/bus/fsl-mc/Kconfig                  |   7 +
 drivers/bus/fsl-mc/Makefile                 |   3 +
 drivers/bus/fsl-mc/fsl-mc-bus.c             |  19 +++
 drivers/bus/fsl-mc/fsl-mc-private.h         |  48 ++++++
 drivers/bus/fsl-mc/fsl-mc-restool.c         | 219 ++++++++++++++++++++++++++++
 include/uapi/linux/fsl_mc.h                 |   8 +
 8 files changed, 309 insertions(+)
 create mode 100644 drivers/bus/fsl-mc/fsl-mc-restool.c
Documentation/ioctl/ioctl-number.txt +1 -0
index 6501389..1a2d132 100644
@@ -170,6 +170,7 @@ Code  Seq#(hex)	Include File		Comments
 'R'	00-1F	linux/random.h		conflict!
 'R'	01	linux/rfkill.h		conflict!
 'R'	C0-DF	net/bluetooth/rfcomm.h
+'R'	E0	uapi/linux/fsl_mc.h
 'S'	all	linux/cdrom.h		conflict!
 'S'	80-81	scsi/scsi_ioctl.h	conflict!
 'S'	82-FF	scsi/scsi.h		conflict!
Documentation/networking/dpaa2/overview.rst +4 -0
index 79fede4..1056445 100644
@@ -127,6 +127,10 @@ level.
 
 DPRCs can be defined statically and populated with objects
 via a config file passed to the MC when firmware starts it.
+There is also a Linux user space tool called "restool" that can be
+used to create/destroy containers and objects dynamically. The latest
+version of restool can be found at:
+        https://github.com/qoriq-open-source/restool
 
 DPAA2 Objects for an Ethernet Network Interface
 -----------------------------------------------
drivers/bus/fsl-mc/Kconfig +7 -0
index c23c77c..66ec3b9 100644
@@ -14,3 +14,10 @@ config FSL_MC_BUS
 	  architecture.  The fsl-mc bus driver handles discovery of
 	  DPAA2 objects (which are represented as Linux devices) and
 	  binding objects to drivers.
+
+config FSL_MC_RESTOOL
+	bool "Management Complex (MC) restool support"
+	depends on FSL_MC_BUS
+	help
+	  Provides kernel support for the Management Complex resource
+	  manager user-space tool - restool.
drivers/bus/fsl-mc/Makefile +3 -0
index 3c518c7..2017bdb 100644
@@ -16,3 +16,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \
 		      fsl-mc-allocator.o \
 		      fsl-mc-msi.o \
 		      dpmcp.o
+
+# MC restool kernel support
+obj-$(CONFIG_FSL_MC_RESTOOL) += fsl-mc-restool.o
drivers/bus/fsl-mc/fsl-mc-bus.c +19 -0
index 5d8266c..0ade415 100644
@@ -792,6 +792,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 	struct fsl_mc *mc;
 	struct fsl_mc_device *mc_bus_dev = NULL;
 	struct fsl_mc_io *mc_io = NULL;
+	struct fsl_mc_bus *mc_bus = NULL;
 	int container_id;
 	phys_addr_t mc_portal_phys_addr;
 	u32 mc_portal_size;
@@ -863,9 +864,18 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 	if (error < 0)
 		goto error_cleanup_mc_io;
 
+	mc_bus = to_fsl_mc_bus(mc_bus_dev);
+	error = fsl_mc_restool_create_device_file(mc_bus);
+	if (error < 0)
+		goto error_cleanup_device;
+
 	mc->root_mc_bus_dev = mc_bus_dev;
+
 	return 0;
 
+error_cleanup_device:
+	fsl_mc_device_remove(mc_bus_dev);
+
 error_cleanup_mc_io:
 	fsl_destroy_mc_io(mc_io);
 	return error;
@@ -878,10 +888,12 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 static int fsl_mc_bus_remove(struct platform_device *pdev)
 {
 	struct fsl_mc *mc = platform_get_drvdata(pdev);
+	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc->root_mc_bus_dev);
 
 	if (!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev))
 		return -EINVAL;
 
+	fsl_mc_restool_remove_device_file(mc_bus);
 	fsl_mc_device_remove(mc->root_mc_bus_dev);
 
 	fsl_destroy_mc_io(mc->root_mc_bus_dev->mc_io);
@@ -931,8 +943,15 @@ static int __init fsl_mc_bus_driver_init(void)
 	if (error < 0)
 		goto error_cleanup_dprc_driver;
 
+	error = fsl_mc_restool_init();
+	if (error < 0)
+		goto error_cleanup_mc_allocator;
+
 	return 0;
 
+error_cleanup_mc_allocator:
+	fsl_mc_allocator_driver_exit();
+
 error_cleanup_dprc_driver:
 	dprc_driver_exit();
 
drivers/bus/fsl-mc/fsl-mc-private.h +48 -0

76 lines not on this page · raw message

drivers/bus/fsl-mc/fsl-mc-restool.c new file +219 -0

219 lines not on this page · raw message

include/uapi/linux/fsl_mc.h +8 -0
index 54590a2..e4c8dd0 100644
@@ -14,10 +14,18 @@
  * struct fsl_mc_command - Management Complex (MC) command structure
  * @header: MC command header
  * @params: MC command parameters
+ *
+ * Used by RESTOOL_SEND_MC_COMMAND
  */
 struct fsl_mc_command {
 	__u64 header;
 	__u64 params[MC_CMD_NUM_OF_PARAMS];
 };
 
+#define RESTOOL_IOCTL_TYPE	'R'
+#define RESTOOL_IOCTL_SEQ	0xE0
+
+#define RESTOOL_SEND_MC_COMMAND \
+	_IOWR(RESTOOL_IOCTL_TYPE, RESTOOL_IOCTL_SEQ, struct fsl_mc_command)
+
 #endif /* _UAPI_FSL_MC_H_ */
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

drivers/bus/fsl-mc/fsl-mc-restool.c line 16

Quoted 3 lines · Ioana Ciornei
drivers/bus/fsl-mc/fsl-mc-restool.c new file +3 -0
+#include "fsl-mc-private.h"
+
+#define FSL_MC_BUS_MAX_MINORS	1

As you only need/want one character device here, why not just use the misc device api? It's much simpler, and handles all of the housekeeping for you correctly. It also means I don't have to audit all of your chardev code to verify it is correct :)

And it will save you lines-of-code, always a good thing.

thanks,

greg k-h

author maintainer
#5 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 11 lines · Ioana Ciornei

drivers/bus/fsl-mc/fsl-mc-restool.c line 16

Quoted 3 lines
drivers/bus/fsl-mc/fsl-mc-restool.c new file +3 -0
+#include "fsl-mc-private.h"
+
+#define FSL_MC_BUS_MAX_MINORS	1

As you only need/want one character device here, why not just use the misc device api? It's much simpler, and handles all of the housekeeping for you correctly. It also means I don't have to audit all of your chardev code to verify it is correct :)

I have considered the misc device api but the fsl-mc bus, since it is a platform driver, is probing before the misc char driver.

Ioana

Quoted 6 lines

And it will save you lines-of-code, always a good thing.

thanks,

greg k-h

#6 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 12 lines · Ioana Ciornei
Quoted 11 lines · Ioana Ciornei

drivers/bus/fsl-mc/fsl-mc-restool.c line 16

Quoted 3 lines
drivers/bus/fsl-mc/fsl-mc-restool.c new file +3 -0
+#include "fsl-mc-private.h"
+
+#define FSL_MC_BUS_MAX_MINORS	1

As you only need/want one character device here, why not just use the misc device api? It's much simpler, and handles all of the housekeeping for you correctly. It also means I don't have to audit all of your chardev code to verify it is correct :)

Quoted 2 lines

I have considered the misc device api but the fsl-mc bus, since it is a platform driver, is probing before the misc char driver.

How? The misc code is just "core code" there's nothing to "probe" here. Is this an init-call ordering issue somehow? A platform driver probe should be after the misc core is initialized. And if not, you can always defer your probe.

thanks,

greg k-h

author maintainer
#7 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines · Ioana Ciornei

drivers/bus/fsl-mc/fsl-mc-restool.c line 16

Quoted 3 lines
drivers/bus/fsl-mc/fsl-mc-restool.c new file +3 -0
+#include "fsl-mc-private.h"
+
+#define FSL_MC_BUS_MAX_MINORS	1

As you only need/want one character device here, why not just use the misc device api? It's much simpler, and handles all of the housekeeping for you correctly. It also means I don't have to audit all of your chardev code to verify it is correct :)

Quoted 6 lines
Quoted 2 lines

I have considered the misc device api but the fsl-mc bus, since it is a platform driver, is probing before the misc char driver.

How? The misc code is just "core code" there's nothing to "probe" here. Is this an init-call ordering issue somehow? A platform driver probe should be after the misc core is initialized. And if not, you can always defer your probe.

Sorry for the previous improper wording. I have tested again using the misc device api and indeed the devices on the fsl-mc bus are probing before the misc core is initialized but I am able to complete the misc registration deferring the probe the first time.

I will update the patch set and send a new version.

Ioana C

Quoted 4 lines

thanks,

greg k-h

#8 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

In reply to Ioana Ciornei
Quoted 10 lines · Ioana Ciornei

Adding kernel support for restool, a userspace tool for resource management, means exporting an ioctl capable device file representing the root resource container.
This new functionality in the fsl-mc bus driver intends to provide restool an interface to interact with the MC firmware. Commands that are composed in userspace are sent to the MC firmware through the RESTOOL_SEND_MC_COMMAND ioctl.
By default the implicit MC I/O portal is used for this operation, but if the implicit one is busy, a dynamic portal is allocated and then freed upon execution.

Hi Ioana,

So this driver is a direct passthrough to your hardware for passing fixed-length command/response pairs. Have you considered using a higher-level interface instead?

Can you list some of the commands that are passed here as clarification, and explain what the tradeoffs are that have led to adopting a low-level interface instead of a high-level interface?

The main downside of the direct passthrough obviously is that you tie your user space to a particular hardware implementation, while a high-level abstraction could in principle work across a wider range of hardware revisions or even across multiple vendors implementing the same concept by different means.

Quoted 15 lines
drivers/bus/fsl-mc/fsl-mc-restool.c new file +10 -0
+static long fsl_mc_restool_dev_ioctl(struct file *file,
+                                    unsigned int cmd,
+                                    unsigned long arg)
+{
+       int error;
+
+       switch (cmd) {
+       case RESTOOL_SEND_MC_COMMAND:
+               error = fsl_mc_restool_send_command(arg, file->private_data);
+               break;
@@ -14,10 +14,18 @@
  * struct fsl_mc_command - Management Complex (MC) command structure
  * @header: MC command header
  * @params: MC command parameters

drivers/bus/fsl-mc/fsl-mc-restool.c line 26

Quoted 10 lines
drivers/bus/fsl-mc/fsl-mc-restool.c new file +4 -0
+ *
+ * Used by RESTOOL_SEND_MC_COMMAND
  */
 struct fsl_mc_command {
        __u64 header;
        __u64 params[MC_CMD_NUM_OF_PARAMS];
 };
 
+#define RESTOOL_IOCTL_TYPE     'R'
+#define RESTOOL_IOCTL_SEQ      0xE0

I tried to follow the code path into the hardware and am a bit confused about the semantics of the 'header' field and the data. Both are accessed passed to the hardware using

       writeq(le64_to_cpu(cmd->header))

which would indicate a fixed byte layout on the user structure and that it should really be a '__le64' instead of '__u64', or possibly should be represented as '__u8 header[8]' to clarify that the byte ordering is supposed to match the order of the byte addresses of the register.

However, the in-kernel usage of that field suggests that we treat it as a 64-bit cpu-endian number, for which the hardware needs to know the endianess of the currently running kernel and user space.

Can you have a look at where the mistake is and what the byteorder for the fsl_mc_command structure is supposed to be? Obviously, this is one thing that would be simplified by using a high-level interface, but it's possible to do it like this as long as it's completely clear how the structure layout is meant to be used in the uapi header.

Arnd

author maintainer
#9 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hi,

Quoted 11 lines

Hi Ioana,

So this driver is a direct passthrough to your hardware for passing fixed- length command/response pairs. Have you considered using a higher-level interface instead?

Can you list some of the commands that are passed here as clarification, and explain what the tradeoffs are that have led to adopting a low-level interface instead of a high-level interface?

Quoted 5 lines

The main downside of the direct passthrough obviously is that you tie your user space to a particular hardware implementation, while a high-level abstraction could in principle work across a wider range of hardware revisions or even across multiple vendors implementing the same concept by different means.

If by "higher-level" you mean an implementation where commands are created by the kernel at userspace's request, then I believe this approach is not really viable because of the sheer number of possible commands that would bloat the driver.

For example, a DPNI (Data Path Network Interface) can be created using a command that has the following structure:

struct dpni_cmd_create {
	uint32_t options;
	uint8_t num_queues;
	uint8_t num_tcs;
	uint8_t mac_filter_entries;
	uint8_t pad1;
	uint8_t vlan_filter_entries;
	uint8_t pad2;
	uint8_t qos_entries;
	uint8_t pad3;
	uint16_t fs_entries;
};

In the above structure, each field has a meaning that the end-user might want to be able to change according to their particular use-case (not much is left at its default value). The same level of complexity is encountered for all the commands that interact with Data Path objects such as DPBP(buffer pools), DPRC(Resource Container) etc. You can find more examples of commands in restool's repo: https://github.com/qoriq-open-source/restool/tree/integration/mc_v10

In my opinion, an in-kernel implementation that is equivalent in terms of flexibility will turn into a giant ioctl parser, all while also exposing an userspace API that is not as simple/easy to use.

Quoted 19 lines

Review line 14

Quoted 2 lines
(quoted diff) +0 -0
@@ -14,10 +14,18 @@
  * struct fsl_mc_command - Management Complex (MC) command

structure

include/uapi/linux/fsl_mc.h line 26

Quoted 11 lines
include/uapi/linux/fsl_mc.h +4 -0
  * @header: MC command header
  * @params: MC command parameters
+ *
+ * Used by RESTOOL_SEND_MC_COMMAND
  */
 struct fsl_mc_command {
        __u64 header;
        __u64 params[MC_CMD_NUM_OF_PARAMS];  };
 
+#define RESTOOL_IOCTL_TYPE     'R'
+#define RESTOOL_IOCTL_SEQ      0xE0

I tried to follow the code path into the hardware and am a bit confused about the semantics of the 'header' field and the data. Both are accessed passed to the hardware using

Quoted 7 lines
       writeq(le64_to_cpu(cmd->header))

which would indicate a fixed byte layout on the user structure and that it should really be a '__le64' instead of '__u64', or possibly should be represented as '__u8 header[8]' to clarify that the byte ordering is supposed to match the order of the byte addresses of the register.

Indeed, the struct fsl_mc_command should use '__le64' instead of '__u64', so that the UAPI header file clearly states what endianness should the userspace prepare.
The writeq appeared as a consequence of a previous mail thread https://lkml.org/lkml/2017/7/17/415, because the endianness of the command is handled by the user and the bus should leave the binary blob intact.

Quoted 4 lines

However, the in-kernel usage of that field suggests that we treat it as a 64-bit cpu-endian number, for which the hardware needs to know the endianess of the currently running kernel and user space.

I might have not understood what you are trying to say, but the in-kernel code treats the fsl_mc_command as little endian by using cpu_to_leXX and leXX_to_cpu in order to setup the command structure.

Ioana

Quoted 7 lines

Can you have a look at where the mistake is and what the byteorder for the fsl_mc_command structure is supposed to be? Obviously, this is one thing that would be simplified by using a high-level interface, but it's possible to do it like this as long as it's completely clear how the structure layout is meant to be used in the uapi header.

Arnd

#10 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 36 lines · Ioana Ciornei

Hi,

Quoted 11 lines

Hi Ioana,

So this driver is a direct passthrough to your hardware for passing fixed- length command/response pairs. Have you considered using a higher-level interface instead?

Can you list some of the commands that are passed here as clarification, and explain what the tradeoffs are that have led to adopting a low-level interface instead of a high-level interface?

Quoted 5 lines

The main downside of the direct passthrough obviously is that you tie your user space to a particular hardware implementation, while a high-level abstraction could in principle work across a wider range of hardware revisions or even across multiple vendors implementing the same concept by different means.

If by "higher-level" you mean an implementation where commands are created by the kernel at userspace's request, then I believe this approach is not really viable because of the sheer number of possible commands that would bloat the driver.

For example, a DPNI (Data Path Network Interface) can be created using a command that has the following structure:

struct dpni_cmd_create {
        uint32_t options;
        uint8_t num_queues;
        uint8_t num_tcs;
        uint8_t mac_filter_entries;
        uint8_t pad1;
        uint8_t vlan_filter_entries;
        uint8_t pad2;
        uint8_t qos_entries;
        uint8_t pad3;
        uint16_t fs_entries;
};
Quoted 6 lines

In the above structure, each field has a meaning that the end-user might want to be able to change according to their particular use-case (not much is left at its default value). The same level of complexity is encountered for all the commands that interact with Data Path objects such as DPBP(buffer pools), DPRC(Resource Container) etc. You can find more examples of commands in restool's repo: https://github.com/qoriq-open-source/restool/tree/integration/mc_v10

In my opinion, an in-kernel implementation that is equivalent in terms of flexibility will turn into a giant ioctl parser, all while also exposing an userspace API that is not as simple/easy to use.

(adding the netdev list)

The command you list there seems to be networking related, so instead of an ioctl based interface, a high-lever interface would likely use netlink for consistency with other drivers. Are all commands for networking or are there some that are talking to the device to do something unrelated?

Obviously creating a high-level interface would be a lot of work in the kernel, and it only pays off if there are multiple independent users, we wouldn't do that for just one driver.

I'm still not convinced either way (high-level or low-level interface), but I think
this needs to be discussed with the networking maintainers. Given the examples on the github page you linked to, the high-level user space commands based on these ioctls

   ls-addni   # adds a network interface
   ls-addmux  # adds a dpdmux
   ls-addsw   # adds an l2switch

ls-listmac # lists MACs and their connections ls-listni # lists network interfaces and their connections

and I see that you also support the switchdev interface in drivers/staging/fsl-dpaa2, which I think does some of the same things, presumably by implementing the switchdev API using fsl_mc_command low-level interfaces in the kernel.

Is that a correct interpretation? If yes, could we extend switchdev or other networking interfaces to fill in whatever those don't handle yet?

Quoted 21 lines
Quoted 21 lines

Review line 14

Quoted 2 lines
(quoted diff) +0 -0
@@ -14,10 +14,18 @@
  * struct fsl_mc_command - Management Complex (MC) command

structure

include/uapi/linux/fsl_mc.h line 26

Quoted 11 lines
include/uapi/linux/fsl_mc.h +4 -0
  * @header: MC command header
  * @params: MC command parameters
+ *
+ * Used by RESTOOL_SEND_MC_COMMAND
  */
 struct fsl_mc_command {
        __u64 header;
        __u64 params[MC_CMD_NUM_OF_PARAMS];  };
 
+#define RESTOOL_IOCTL_TYPE     'R'
+#define RESTOOL_IOCTL_SEQ      0xE0

I tried to follow the code path into the hardware and am a bit confused about the semantics of the 'header' field and the data. Both are accessed passed to the hardware using

       writeq(le64_to_cpu(cmd->header))
Quoted 8 lines
Quoted 5 lines

which would indicate a fixed byte layout on the user structure and that it should really be a '__le64' instead of '__u64', or possibly should be represented as '__u8 header[8]' to clarify that the byte ordering is supposed to match the order of the byte addresses of the register.

Indeed, the struct fsl_mc_command should use '__le64' instead of '__u64', so that the UAPI header file clearly states what endianness should the userspace prepare.
The writeq appeared as a consequence of a previous mail thread https://lkml.org/lkml/2017/7/17/415, because the endianness of the command is handled by the user and the bus should leave the binary blob intact.

Ok. However, with the dpni_cmd_create structure you list above, it seems that it doesn't actually contain a set of __le64 but rather an array of bytes, so it might be best to

Quoted 6 lines
Quoted 4 lines

However, the in-kernel usage of that field suggests that we treat it as a 64-bit cpu-endian number, for which the hardware needs to know the endianess of the currently running kernel and user space.

I might have not understood what you are trying to say, but the in-kernel code treats the fsl_mc_command as little endian by using cpu_to_leXX and leXX_to_cpu in order to setup the command structure.

One function that seems to have a problem is this one:

static enum mc_cmd_status mc_cmd_hdr_read_status(struct fsl_mc_command *cmd)

{
        struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header;

        return (enum mc_cmd_status)hdr->status;
}

If cmd->header is little-endian here, then the result is not an 'enum mc_cmd_status'. I think it would be good to change the types for fsl_mc_command to __le64 first and run everything through 'sparse' with 'make C=1' to find any remaining endianess problems.

Arnd

#11 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 9 lines

I'm still not convinced either way (high-level or low-level interface), but I think
this needs to be discussed with the networking maintainers. Given the examples on the github page you linked to, the high-level user space commands based on these ioctls

   ls-addni   # adds a network interface
   ls-addmux  # adds a dpdmux
   ls-addsw   # adds an l2switch
Quoted 7 lines

ls-listmac # lists MACs and their connections ls-listni # lists network interfaces and their connections

and I see that you also support the switchdev interface in drivers/staging/fsl-dpaa2, which I think does some of the same things, presumably by implementing the switchdev API using fsl_mc_command low-level interfaces in the kernel.

Hi Arnd

I agree that switchdev and devlink should be the correct way to handle this. The low level plumbing of the hardware should all be hidden. There should not be any user space commands needed other than the usual network configuration tools and devlink.

Andrew

author maintainer
#12 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 18 lines
Quoted 10 lines

I'm still not convinced either way (high-level or low-level interface), but I think this needs to be discussed with the networking maintainers. Given the examples on the github page you linked to, the high-level user space commands based on these ioctls

   ls-addni   # adds a network interface
   ls-addmux  # adds a dpdmux
   ls-addsw   # adds an l2switch
Quoted 7 lines

ls-listmac # lists MACs and their connections ls-listni # lists network interfaces and their connections

and I see that you also support the switchdev interface in drivers/staging/fsl-dpaa2, which I think does some of the same things, presumably by implementing the switchdev API using fsl_mc_command low-level interfaces in the kernel.

Quoted 7 lines

Hi Arnd

I agree that switchdev and devlink should be the correct way to handle this. The low level plumbing of the hardware should all be hidden. There should not be any user space commands needed other than the usual network configuration tools and devlink.

Hi,

The commands listed above are for creating/destroying DPAA2 objects in Management Complex and not for runtime configuration where standard userspace tools are used.
Restool is responsible for creating objects in Management complex and this process can be seen as the equivalent of hotplugging a peripheral rather than configuring it, thus there is no standard userspace tool to handle that.

* The Management Complex is configured to create a specific set of DPAA2 objects dynamically through Restool (by sending create commands) or statically, at boot time, through a configuration file (Data Path Layout file)
* The objects are then probed and configured by the corresponding drivers
* The objects are controlled at runtime by the user via standard tools (e.g. ethtool for network interfaces).

I hope this gives a better understanding on the DPAA2 hardware and software architecture. The fsl-mc bus documentation gives more details on this: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/tree/Documentation/networking/dpaa2/overview.rst?h=staging-next

Ioana

#13 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hi Ioana

Quoted 3 lines

The commands listed above are for creating/destroying DPAA2 objects in Management Complex and not for runtime configuration where standard userspace tools are used.

Please can you explain why this is not just plumbing inside a switchdev driver?

The hardware has a number of physical ports. So on probe, i would expect it to create a DPMAC, DPNI, and DPIO for each port, and a linux netdev. From then on, standard tools are all that are needed. The switchdev driver can create a l2 switch object when the user uses the ip link add name br0 type bridge. It can then connect the switch object to the DPNI when the user adds an interface to the switch, etc.

Andrew

#14 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hello Andrew,

Quoted 22 lines

-----Original Message-----
From: Andrew Lunn [mailto:[email protected]]
Sent: Monday, April 2, 2018 4:45 PM
To: Ioana Ciornei <[email protected]>
Cc: Arnd Bergmann <[email protected]>; gregkh <[email protected]>; Laurentiu Tudor <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; Stuart Yoder <[email protected]>; Ruxandra Ioana Ciocoi Radulescu <[email protected]>; Razvan Stefanescu <[email protected]>; Roy Pledge <[email protected]>; Networking <[email protected]>
Subject: Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hi Ioana

Quoted 3 lines

The commands listed above are for creating/destroying DPAA2 objects in Management Complex and not for runtime configuration where standard userspace tools are used.

Please can you explain why this is not just plumbing inside a switchdev driver?

Quoted 7 lines

The hardware has a number of physical ports. So on probe, i would expect it to create a DPMAC, DPNI, and DPIO for each port, and a linux netdev. From then on, standard tools are all that are needed. The switchdev driver can create a l2 switch object when the user uses the ip link add name br0 type bridge. It can then connect the switch object to the DPNI when the user adds an interface to the switch, etc.

I'll chime in as you mentioned switchdev driver.

DPAA2 offers several object-based abstractions for modeling network related devices (interfaces, L2 Ethernet switch) or accelerators (DPSECI - crypto and DPDCEI - compression), the latter not up-streamed yet. They are modeled using various low-level resources (e.g. queues, classification tables, physical ports) and have multiple configuration and interconnectivity options, managed by the Management Complex. Resources are limited and they are only used when needed by the objects, to accommodate more configurations and usage scenarios.

Some of the objects have a 1-to-1 correspondence to physical resources (e.g. DPMACs to physical ports), while others (like DPNIs and DPSW) can be seen as a collection of the mentioned resources. The types and number of such objects are not predetermined.

When the board boots up, none of them exist yet. Restool allows a user to define the system topology, by providing a way to dynamically create, destroy and interconnect these objects.

After an object is created, it will be presented on the fsl-mc bus. A driver is loaded to implement the required kernel interfaces specific to that object type. Kernel can boot and afterwards the DPAA2 objects are added, as the user requires.

As you mentioned DPMACs: objects of this type can be connected only to a DPNI (a network interface like object) or to a DPSW (L2 ethernet switch) port. Likewise, a DPNI can have only one connection (to a DPMAC, a DPSW port or another DPNI object).

Here's several examples of valid connection types:
* DPMAC <----> DPNI (standard network i/f corresponding to a physical port)
* DPMAC <----> DPSW (physical port in a switch)
* DPNI <----> DPSW (virtual network interface connected to a switch port)
* DPNI <----> DPNI

In the latter case, the two DPNIs will not be connected to any physical port, but can be used as a point-to-point connection between two virtual machines for instance.

So, it is not possible to connect a DPNI to a DPSW after it was connected to a DPMAC. The DPNI-DPMAC pair would have to be disconnected and DPMAC will be reconnected to the switch. DPNI interface that is no longer connected to a DPMAC will be destroyed and any new addition/deletion of a DPNI/DPMAC interface to the switch port will trigger the entire switch re-configuration.

Best regards,
Razvan Stefanescu

#15 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 9 lines · Razvan Stefanescu

DPAA2 offers several object-based abstractions for modeling network related devices (interfaces, L2 Ethernet switch) or accelerators (DPSECI - crypto and DPDCEI - compression), the latter not up-streamed yet. They are modeled using various low-level resources (e.g. queues, classification tables, physical ports) and have multiple configuration and interconnectivity options, managed by the Management Complex. Resources are limited and they are only used when needed by the objects, to accommodate more configurations and usage scenarios.

Quoted 8 lines

Some of the objects have a 1-to-1 correspondence to physical resources (e.g. DPMACs to physical ports), while others (like DPNIs and DPSW) can be seen as a collection of the mentioned resources. The types and number of such objects are not predetermined.

When the board boots up, none of them exist yet. Restool allows a user to define the system topology, by providing a way to dynamically create, destroy and interconnect these objects.

Hi Razvan

The core concept with Linux networking and offload is that the hardware is there to accelerate what Linux can already do. Since Linux can already do it, i don't need any additional tools.

You have new hardware. It might offer features which we currently don't have offload support for. But all the means is you need to extend the core networking code which implements the software version of that feature to offload to the hardware.

The board knows how many physical ports it has. switchdev can then setup the plumbing to create the objects needed to represent the ports. Restool is not needed for that.

Quoted 3 lines

In the latter case, the two DPNIs will not be connected to any physical port, but can be used as a point-to-point connection between two virtual machines for instance.

Can Linux already do this? Isn't that what PCI Virtual Functions are all about? You need to find the current Linux concept for this, and extend it to offload the functionality to hardware. If Linux can do it, it already has the tools to configure it. Restool is not needed for that.

Quoted 6 lines

So, it is not possible to connect a DPNI to a DPSW after it was connected to a DPMAC. The DPNI-DPMAC pair would have to be disconnected and DPMAC will be reconnected to the switch. DPNI interface that is no longer connected to a DPMAC will be destroyed and any new addition/deletion of a DPNI/DPMAC interface to the switch port will trigger the entire switch re-configuration.

Switches and ports connected to switches are dynamic. They come and go. You don't expect it to happen very often, but Linux has no restrictions on this. You need to figure out how best to offload this to your hardware. Maybe when you create the switch object you make a guess as to how many ports you need. Leave some of the ports not connected to anything. You can then add ports to the switch using the free ports. If you run out of ports, you have no choice but to destroy the switch object and create a new one. Hopefully that does not take too long. Restool is not needed for this, it all happens within the switchdev driver.

Andrew

#16 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

In reply to Arnd Bergmann
Quoted 67 lines · Arnd Bergmann
Quoted 36 lines · Ioana Ciornei

Hi,

Quoted 11 lines

Hi Ioana,

So this driver is a direct passthrough to your hardware for passing fixed- length command/response pairs. Have you considered using a higher-level interface instead?

Can you list some of the commands that are passed here as clarification, and explain what the tradeoffs are that have led to adopting a low-level interface instead of a high-level interface?

Quoted 5 lines

The main downside of the direct passthrough obviously is that you tie your user space to a particular hardware implementation, while a high-level abstraction could in principle work across a wider range of hardware revisions or even across multiple vendors implementing the same concept by different means.

If by "higher-level" you mean an implementation where commands are created by the kernel at userspace's request, then I believe this approach is not really viable because of the sheer number of possible commands that would bloat the driver.

For example, a DPNI (Data Path Network Interface) can be created using a command that has the following structure:

struct dpni_cmd_create {
        uint32_t options;
        uint8_t num_queues;
        uint8_t num_tcs;
        uint8_t mac_filter_entries;
        uint8_t pad1;
        uint8_t vlan_filter_entries;
        uint8_t pad2;
        uint8_t qos_entries;
        uint8_t pad3;
        uint16_t fs_entries;
};
Quoted 6 lines

In the above structure, each field has a meaning that the end-user might want to be able to change according to their particular use-case (not much is left at its default value). The same level of complexity is encountered for all the commands that interact with Data Path objects such as DPBP(buffer pools), DPRC(Resource Container) etc. You can find more examples of commands in restool's repo: https://github.com/qoriq-open-source/restool/tree/integration/mc_v10

In my opinion, an in-kernel implementation that is equivalent in terms of flexibility will turn into a giant ioctl parser, all while also exposing an userspace API that is not as simple/easy to use.

(adding the netdev list)

The command you list there seems to be networking related, so instead of an ioctl based interface, a high-lever interface would likely use netlink for consistency with other drivers. Are all commands for networking or are there some that are talking to the device to do something unrelated?

Obviously creating a high-level interface would be a lot of work in the kernel, and it only pays off if there are multiple independent users, we wouldn't do that for just one driver.

I'm still not convinced either way (high-level or low-level interface), but I think
this needs to be discussed with the networking maintainers. Given the examples on the github page you linked to, the high-level user space commands based on these ioctls

   ls-addni   # adds a network interface
   ls-addmux  # adds a dpdmux
   ls-addsw   # adds an l2switch

ls-listmac # lists MACs and their connections ls-listni # lists network interfaces and their connections

Quoted 8 lines

and I see that you also support the switchdev interface in drivers/staging/fsl-dpaa2, which I think does some of the same things, presumably by implementing the switchdev API using fsl_mc_command low-level interfaces in the kernel.

Is that a correct interpretation? If yes, could we extend switchdev or other networking interfaces to fill in whatever those don't handle yet?

The wrapper scripts you referenced are not sufficient to show the scope of what the proposed user space interface is for. The command list is not just about networking related objects, as there are quite a few other types of objects as well:
dprc - container object representing an fsl-mc bus instance...i.e. other
objects are attached to this bus
dpio - used for queuing operations towards any accelerator or network
interface
dpbp - buffer pool object
dpmcp - command portal interface
dpdmai - DMA engine
dpseci - crypto accelerator
dpdcei - compression/decompression accelerator
dpni - network interface
dprtc - real time counter
dpaiop - heterogenous core complex for packet processing offload dpmac - represents an Ethernet MAC
dpsw - network switch
dpcon - network concentrator
dpci - communication interface

The proposed ioctl interface is about:
A) creating and destroying all those object types
B) managing the dprc containers they live in, including moving objects between containers
C) where applicable establishing connections between different objects

No _operational_ aspects of these object/devices is being handled through this interface. The network interface should be managed through ethtool, for example. The proposed ioctl interface is about bringing the devices into existence and getting them "wired" up.

Suppose you want to create and assign a network interface to a KVM virtual machine, you would do something like the following using a user space tool like restool:
-create a new (empty) dprc object
-create a new dpni and assign it to the dprc
-create a new dpio and assign it to the dprc
-create a new dpbp and assign it to the dprc
-create a new dpmcp and assign it to the dprc -create a new dpmac and assign it to the dprc -connect the dpni to the dpmac

Now, at this point you have a functional set of objects that can function as a network interface.

That dprc can now be assigned to a KVM VM using vfio and the guest will see a dprc that it can probe and enumerate using the fsl-mc bus infrastructure that is now upstream.

There is no existing kernel <--> user space mechanism that will work to do all that, so something new was needed.

As far as low-level vs high-level...we did consider a higher level interface that would expose operations on individual object such as "create dpbp", but the user space API gets complex and fragile for no obvious value. Every object needs commands to create/destroy and get attributes. There is a sizeable dprc command set. Every time an object is enhanced (with a corresponding major or minor version rev) you have to change the ioctl interface.

Having a simple command passthrough interface reduces complexity in the kernel and provides an interface that should be very stable.

The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't seem to be anything that can be made generic here to provide more common benefit.

Thanks,
Stuart

#17 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 10 lines

Suppose you want to create and assign a network interface to a KVM virtual machine, you would do something like the following using a user space tool like restool:
-create a new (empty) dprc object
-create a new dpni and assign it to the dprc
-create a new dpio and assign it to the dprc
-create a new dpbp and assign it to the dprc
-create a new dpmcp and assign it to the dprc -create a new dpmac and assign it to the dprc -connect the dpni to the dpmac

Hi Stuart

It this connecting to a physical port at the bottom?

If so, i would expect that when you probe the device you just create all these for each physical port. You then just need to map one of them into the KVM, in the same way you map one PCI device into a KVM.

If these are virtual devices, VF devices you would normally do

echo 4 > /sys/class/net/<device name>/device/sriov_numvfs

on the physical device to create virtual devices.

Quoted 3 lines

The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't seem to be anything that can be made generic here to provide more common benefit.

Which is why you should try to avoid all of this. The user knows how to use standard linux commands and concepts. They don't want to have to learn the inside plumbing of your hardware.

Andrew

#18 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 11 lines · Andrew Lunn
Quoted 10 lines

Suppose you want to create and assign a network interface to a KVM virtual machine, you would do something like the following using a user space tool like restool:
-create a new (empty) dprc object
-create a new dpni and assign it to the dprc
-create a new dpio and assign it to the dprc
-create a new dpbp and assign it to the dprc
-create a new dpmcp and assign it to the dprc -create a new dpmac and assign it to the dprc -connect the dpni to the dpmac

Quoted 3 lines

Hi Stuart

It this connecting to a physical port at the bottom?

Yes.

Quoted 2 lines

If so, i would expect that when you probe the device you just create all these for each physical port.

The problem is that there is not just one set of objects to implement a network interface. For the highest throughput packet processing you need one dpio per core. So, it will depend on what the requirements are. You might want multiple dpbp (buffer pools) and set up pools of different size buffers for different
packet classifications.

You might want to have other objects like a crypto accelerator (dpseci) in the container as well.

The dprc is a container holding any combination of those objects. So you have complete flexibility.

Quoted 9 lines

You then just need to map one of
them into the KVM, in the same way you map one PCI device into a KVM.

If these are virtual devices, VF devices you would normally do

echo 4 > /sys/class/net/<device name>/device/sriov_numvfs

on the physical device to create virtual devices.

Quoted 7 lines
Quoted 3 lines

The fsl-mc bus and DPAA2 is very NXP-specific, so there doesn't seem to be anything that can be made generic here to provide more common benefit.

Which is why you should try to avoid all of this. The user knows how to use standard linux commands and concepts. They don't want to have to learn the inside plumbing of your hardware.

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Thanks,
Stuart

#19 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

Andrew

#20 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Quoted 7 lines

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

I know Ioana has other feedback she is addressing so a respin will be coming soon, and she can include those additional reviewers.

Thanks,
Stuart

#21 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

In reply to Andrew Lunn

Hello,

My 2c below.

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Quoted 8 lines

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking. It's just an ioctl for our mc-bus bus driver that is used to manage the devices on this bus through userspace tools.
In addition, I'd drop any mention of our reference user space app (restool) to emphasize that this ioctl is not added just for a particular user space app. I think Stuart also mentioned this.

---
Thanks & Best Regards, Laurentiu

#22 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 14 lines · Laurentiu Tudor

Hello,

My 2c below.

Quoted 9 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Hi Stuart

I see we are not making any progress here.

Quoted 7 lines
Quoted 4 lines

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking.

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Andrew

#23 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 23 lines · Andrew Lunn
Quoted 14 lines · Laurentiu Tudor

Hello,

My 2c below.

Quoted 9 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Hi Stuart

I see we are not making any progress here.

Quoted 7 lines
Quoted 4 lines

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking.

Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Absolutely!
In normal use cases the system designer, depending on the requirements, configures the various devices that it desires through a firmware configuration (think something like a device tree). The devices configured are presented on the mc-bus and probed normally by the kernel. The standard networking linux tools can be used as expected.

The ioctl is necessary only for more advanced use cases that are supported by this bus. Think "more dynamic" scenarios that involve linking & unlinking various devices at runtime, maybe some virtualization scenarios. Unfortunately I'm not the architect type of guy so I don't have more specific examples to better illustrate ...

---
Best Regards, Laurentiu

#24 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 8 lines
Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Absolutely!

Great.

Then the easiest way forwards is to simply drop the IOCTL code for the moment. Get the basic support for the hardware into the kernel first. Then come back later to look at dynamic behaviour which needs some form of configuration.

Quoted 5 lines

In normal use cases the system designer, depending on the requirements, configures the various devices that it desires through a firmware configuration (think something like a device tree). The devices configured are presented on the mc-bus and probed normally by the kernel. The standard networking linux tools can be used as expected.

So what you should probably do is start a discussion on what this device tree binding looks like. But you need to be careful even here. Device tree describes the hardware, not how you configure the hardware. So maybe DT does not actually fit.

Andrew

#25 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hi Andrew,

Quoted 7 lines · Andrew Lunn
Quoted 7 lines
Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Quoted 8 lines
Quoted 1 line

Absolutely!

Great.

Then the easiest way forwards is to simply drop the IOCTL code for the moment. Get the basic support for the hardware into the kernel first. Then come back later to look at dynamic behaviour which needs some form of configuration.

Hmm, not sure I understand. We already have a fully functional ethernet driver [1] and a switch driver [2] ...

Quoted 10 lines
Quoted 5 lines

In normal use cases the system designer, depending on the requirements, configures the various devices that it desires through a firmware configuration (think something like a device tree). The devices configured are presented on the mc-bus and probed normally by the kernel. The standard networking linux tools can be used as expected.

So what you should probably do is start a discussion on what this device tree binding looks like. But you need to be careful even here. Device tree describes the hardware, not how you configure the hardware. So maybe DT does not actually fit.

It's not an actual device tree, but a configuration file that happens to reuse the DTS format. I guess my analogy with a device tree was not the best.
Detailed documentation on the syntax can be found here [3], chapter 22.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/staging/fsl-dpaa2/ethernet
[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/staging/fsl-dpaa2/ethsw
[3] https://www.nxp.com/docs/en/user-guide/DPAA2_UM.pdf

---
Best Regards, Laurentiu

#26 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 14 lines · Laurentiu Tudor

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 8 lines
Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Absolutely!

Great.

Quoted 7 lines
Quoted 4 lines

Then the easiest way forwards is to simply drop the IOCTL code for the moment. Get the basic support for the hardware into the kernel first. Then come back later to look at dynamic behaviour which needs some form of configuration.

Hmm, not sure I understand. We already have a fully functional ethernet driver [1] and a switch driver [2] ...

In staging, the tree of crap. You want to get it out of there and into the main tree. But that effort is being side lined by the discussion around this IOCTL call. The best way forward is to to accept Greg is not going to take this patchset at the moment, and move on. As you said, it is not needed for the Ethernet and switchdev driver.

What needs to happen before the Ethernet driver can be reviewed for moving out of staging?

Andrew

#27 lore raw

RE: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 36 lines

-----Original Message-----
From: Andrew Lunn [mailto:[email protected]]
Sent: Thursday, April 5, 2018 6:24 PM
To: Laurentiu Tudor <[email protected]>
Cc: Stuart Yoder <[email protected]>; Arnd Bergmann <[email protected]>; Ioana Ciornei <[email protected]>; gregkh <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; Ruxandra Ioana Ciocoi Radulescu <[email protected]>; Razvan Stefanescu <[email protected]>; Roy Pledge <[email protected]>; Networking <[email protected]>
Subject: Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 14 lines · Laurentiu Tudor

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 8 lines
Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Absolutely!

Great.

Quoted 7 lines
Quoted 4 lines

Then the easiest way forwards is to simply drop the IOCTL code for the moment. Get the basic support for the hardware into the kernel first. Then come back later to look at dynamic behaviour which needs some form of configuration.

Hmm, not sure I understand. We already have a fully functional ethernet driver [1] and a switch driver [2] ...

Quoted 8 lines

In staging, the tree of crap. You want to get it out of there and into the main tree. But that effort is being side lined by the discussion around this IOCTL call. The best way forward is to to accept Greg is not going to take this patchset at the moment, and move on. As you said, it is not needed for the Ethernet and switchdev driver.

What needs to happen before the Ethernet driver can be reviewed for moving out of staging?

Hi Andrew,

We're waiting for the DPIO driver (which we depend on) to be moved out of staging first, it's currently under review:
https://lkml.org/lkml/2018/3/27/1086

Ioana

#28 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 42 lines · Ruxandra Ioana Ciocoi Radulescu
Quoted 42 lines

-----Original Message-----
From: Andrew Lunn [mailto:[email protected]]
Sent: Thursday, April 5, 2018 6:24 PM
To: Laurentiu Tudor <[email protected]>
Cc: Stuart Yoder <[email protected]>; Arnd Bergmann <[email protected]>; Ioana Ciornei <[email protected]>; gregkh <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; Ruxandra Ioana Ciocoi Radulescu <[email protected]>; Razvan Stefanescu <[email protected]>; Roy Pledge <[email protected]>; Networking <[email protected]>
Subject: Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 14 lines · Laurentiu Tudor

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 8 lines
Quoted 6 lines

Hi Laurentiu

So i can use switchdev without it? I can modprobe the switchdev driver, all the physical interfaces will appear, and i can use ip addr add etc. I do not need to use a user space tool at all in order to use the network functionality?

Absolutely!

Great.

Quoted 7 lines
Quoted 4 lines

Then the easiest way forwards is to simply drop the IOCTL code for the moment. Get the basic support for the hardware into the kernel first. Then come back later to look at dynamic behaviour which needs some form of configuration.

Hmm, not sure I understand. We already have a fully functional ethernet driver [1] and a switch driver [2] ...

In staging, the tree of crap. You want to get it out of there and into the main tree. But that effort is being side lined by the discussion around this IOCTL call. The best way forward is to to accept Greg is not going to take this patchset at the moment, and move on. As you said, it is not needed for the Ethernet and switchdev driver.

Quoted 8 lines
Quoted 2 lines

What needs to happen before the Ethernet driver can be reviewed for moving out of staging?

Hi Andrew,

We're waiting for the DPIO driver (which we depend on) to be moved out of staging first, it's currently under review:
https://lkml.org/lkml/2018/3/27/1086

That's stalled on my side right now as the merge window is open and I can't do any new stuff until after 4.17-rc1 is out. So everyone please be patient a bit...

thanks,

greg k-h

#29 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 9 lines
Quoted 5 lines

Hi Andrew,

We're waiting for the DPIO driver (which we depend on) to be moved out of staging first, it's currently under review:
https://lkml.org/lkml/2018/3/27/1086

That's stalled on my side right now as the merge window is open and I can't do any new stuff until after 4.17-rc1 is out. So everyone please be patient a bit...

I took a quick look.

There are a few inline functions in .c files which is generally frowned upon. Let the compiler decide.

e.g:

static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d,
int cpu)
static inline struct dpaa2_io *service_select(struct dpaa2_io *d)

dpaa2_io_down() seems to be too simple. dpaa2_io_create() sets up interrupt triggers, notifications, and adds the new object to the dpio_list. dpaa2_io_down() seems to just free the memory. Do notifications need to be disabled, the object taken off the list?

dpaa2_io_store_create() allocates memory using kzalloc() and then uses dma_map_single(,,DMA_FROM_DEVICE). The documentation says:

DMA_FROM_DEVICE synchronisation must be done before the driver accesses data that may be changed by the device. This memory should be treated as read-only by the driver. If the driver needs to write to it at any point, it should be DMA_BIDIRECTIONAL (see below).

Since it has just been allocated, this seems questionable.

I'm also not sure where the correct call to dma_map_single(,,DMA_FROM_DEVICE) is? Should dpaa2_io_store_next() doing this?

The DMA API usage might need a closer review.

Andrew

#30 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

In reply to Laurentiu Tudor
Quoted 19 lines · Laurentiu Tudor

Hello,

My 2c below.

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Quoted 8 lines

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

Quoted 7 lines

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking. It's just an ioctl for our mc-bus bus driver that is used to manage the devices on this bus through userspace tools.
In addition, I'd drop any mention of our reference user space app (restool) to emphasize that this ioctl is not added just for a particular user space app. I think Stuart also mentioned this.

I'm not going to take a "generic device configuration ioctl" patch unless it is documented to all exactly what it does, and why it is there.

thanks,

greg k-h

#31 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Hi Greg,

Quoted 28 lines · gregkh
Quoted 19 lines · Laurentiu Tudor

Hello,

My 2c below.

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Quoted 8 lines

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

Quoted 7 lines

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking. It's just an ioctl for our mc-bus bus driver that is used to manage the devices on this bus through userspace tools.
In addition, I'd drop any mention of our reference user space app (restool) to emphasize that this ioctl is not added just for a particular user space app. I think Stuart also mentioned this.

Quoted 3 lines

I'm not going to take a "generic device configuration ioctl" patch unless it is documented to all exactly what it does, and why it is there.

The ioctl() is just a simple pass-through interface to the firmware. It passes commands to the firmware and returns the response back to the userspace. Thus the ABI used by the firmware applies for this ioctl() and it is documented in detail here:

https://www.nxp.com/docs/en/user-guide/DPAA2_UM.pdf

---
Best Regards, Laurentiu

#32 lore raw

Re: [PATCH v3 2/4] bus: fsl-mc: add restool userspace support

Quoted 31 lines · Laurentiu Tudor

Hi Greg,

Quoted 28 lines · gregkh
Quoted 26 lines · Laurentiu Tudor

Hello,

My 2c below.

Quoted 5 lines · Andrew Lunn
Quoted 4 lines

I hear you. It is more complicated this way...having all these individual objects vs just a single "bundle" of them that represents a NIC. But, that's the way the DPAA2 hardware is, and we're implementing kernel support for the hardware as it is.

Quoted 8 lines

Hi Stuart

I see we are not making any progress here.

So what i suggest is you post the kernel code and configuration tool concept to netdev for a full review. You want reviews from David Miller, Jiri Pirko, Jakub Kicinski, David Ahern, etc.

I think that the discussion steered too much towards networking related topics, while this ioctl doesn't have much to do with networking. It's just an ioctl for our mc-bus bus driver that is used to manage the devices on this bus through userspace tools.
In addition, I'd drop any mention of our reference user space app (restool) to emphasize that this ioctl is not added just for a particular user space app. I think Stuart also mentioned this.

Quoted 5 lines
Quoted 3 lines

I'm not going to take a "generic device configuration ioctl" patch unless it is documented to all exactly what it does, and why it is there.

The ioctl() is just a simple pass-through interface to the firmware.

Ah, so a new syscall? :)

Quoted 5 lines

It passes commands to the firmware and returns the response back to the userspace. Thus the ABI used by the firmware applies for this ioctl() and it is documented in detail here:

https://www.nxp.com/docs/en/user-guide/DPAA2_UM.pdf

Let's wait on this until people all agree that it's ok to expose this directly.

thanks,

greg k-h

author maintainer
#33 lore raw

PATCH v3 3/4 bus: fsl-mc: add root dprc rescan attribute

In reply to Ioana Ciornei

Introduce the rescan attribute as a device attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  6 ++++++
 MAINTAINERS                               |  1 +
 drivers/bus/fsl-mc/dprc-driver.c          |  4 ++--
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 28 ++++++++++++++++++++++++++++
 drivers/bus/fsl-mc/fsl-mc-private.h       |  3 +++
 5 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +6 -0
new file mode 100644
index 0000000..e530e8c
@@ -0,0 +1,6 @@
+What:		/sys/bus/fsl-mc/devices/dprc.*/rescan
+Date:		March. 2018
+KernelVersion:	4.16
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Root dprc rescan attribute
+Users:		Userspace drivers and management tools
MAINTAINERS +1 -0
index 861cf1d..e179dc6 100644
@@ -11486,6 +11486,7 @@ F:	drivers/bus/fsl-mc/
 F:	Documentation/devicetree/bindings/misc/fsl,qoriq-mc.txt
 F:	Documentation/networking/dpaa2/overview.rst
 F:	include/uapi/linux/fsl_mc.h
+F:	Documentation/ABI/stable/sysfs-bus-fsl-mc
 
 QT1010 MEDIA DRIVER
 M:	Antti Palosaari <[email protected]>
drivers/bus/fsl-mc/dprc-driver.c +2 -2
index 52c7e15..be80e3a 100644
@@ -214,8 +214,8 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
  * populated before they can get allocation requests from probe callbacks
  * of the device drivers for the non-allocatable devices.
  */
-static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
-			     unsigned int *total_irq_count)
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
+		      unsigned int *total_irq_count)
 {
 	int num_child_objects;
 	int dprc_get_obj_failures;
drivers/bus/fsl-mc/fsl-mc-bus.c +28 -0
index 0ade415..9d02984 100644
@@ -137,8 +137,36 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t rescan_store(struct device *dev,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+	unsigned long val;
+
+	if (!fsl_mc_is_root_dprc(dev))
+		return -EINVAL;
+
+	root_mc_dev = to_fsl_mc_device(dev);
+	root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
+	if (val) {
+		mutex_lock(&root_mc_bus->scan_mutex);
+		dprc_scan_objects(root_mc_dev, NULL);
+		mutex_unlock(&root_mc_bus->scan_mutex);
+	}
+
+	return count;
+}
+static DEVICE_ATTR_WO(rescan);
+
 static struct attribute *fsl_mc_dev_attrs[] = {
 	&dev_attr_modalias.attr,
+	&dev_attr_rescan.attr,
 	NULL,
 };
 
drivers/bus/fsl-mc/fsl-mc-private.h +3 -0
index 00cca7d..c1fc80e 100644
@@ -545,6 +545,9 @@ int __must_check fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
 
 void dprc_driver_exit(void);
 
+int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
+		      unsigned int *total_irq_count);
+
 int __init fsl_mc_allocator_driver_init(void);
 
 void fsl_mc_allocator_driver_exit(void);
Signature · 1 line
1.9.1
#34 lore raw

Re: [PATCH v3 3/4] bus: fsl-mc: add root dprc rescan attribute

Quoted 28 lines · Ioana Ciornei

Introduce the rescan attribute as a device attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  6 ++++++
 MAINTAINERS                               |  1 +
 drivers/bus/fsl-mc/dprc-driver.c          |  4 ++--
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 28 ++++++++++++++++++++++++++++
 drivers/bus/fsl-mc/fsl-mc-private.h       |  3 +++
 5 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/ABI/stable/sysfs-bus-fsl-mc
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +0 -0
new file mode 100644
index 0000000..e530e8c

Documentation/ABI/stable/sysfs-bus-fsl-mc line 2

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +2 -0
@@ -0,0 +1,6 @@
+What:		/sys/bus/fsl-mc/devices/dprc.*/rescan
+Date:		March. 2018

"."?

Documentation/ABI/stable/sysfs-bus-fsl-mc line 3

Quoted 1 line
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +1 -0
+KernelVersion:	4.16

4.17 :)

Documentation/ABI/stable/sysfs-bus-fsl-mc line 5

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +2 -0
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Root dprc rescan attribute

What does this do? A bit more description please.

thanks,

greg k-h

author maintainer
#35 lore raw

RE: [PATCH v3 3/4] bus: fsl-mc: add root dprc rescan attribute

Quoted 35 lines · Ioana Ciornei
Quoted 29 lines

Introduce the rescan attribute as a device attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the root dprc only, e.g.
echo 1 > /sys/bus/fsl-mc/devices/dprc.1/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  6 ++++++
 MAINTAINERS                               |  1 +
 drivers/bus/fsl-mc/dprc-driver.c          |  4 ++--
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 28 ++++++++++++++++++++++++++++
 drivers/bus/fsl-mc/fsl-mc-private.h       |  3 +++
 5 files changed, 40 insertions(+), 2 deletions(-)  create mode 100644

Documentation/ABI/stable/sysfs-bus-fsl-mc

Documentation/ABI/stable/sysfs-bus-fsl-mc new file +0 -0
new file mode 100644
index 0000000..e530e8c

Documentation/ABI/stable/sysfs-bus-fsl-mc line 2

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +2 -0
@@ -0,0 +1,6 @@
+What:		/sys/bus/fsl-mc/devices/dprc.*/rescan
+Date:		March. 2018

"."?

Quoted 3 lines

Documentation/ABI/stable/sysfs-bus-fsl-mc line 3

Quoted 1 line
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +1 -0
+KernelVersion:	4.16

4.17 :)

Sorry for this. Will fix.

Quoted 5 lines

Documentation/ABI/stable/sysfs-bus-fsl-mc line 5

Quoted 3 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc new file +2 -0
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Root dprc rescan attribute

What does this do? A bit more description please.

Will update the description in the next version for both attributes.

Quoted 4 lines

thanks,

greg k-h

author maintainer
#36 lore raw

PATCH v3 4/4 bus: fsl-mc: add bus rescan attribute

In reply to Ioana Ciornei

Introduce the rescan attribute as a bus attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  7 +++++
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 48 +++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
Documentation/ABI/stable/sysfs-bus-fsl-mc +7 -0
index e530e8c..0663fbd 100644
@@ -4,3 +4,10 @@ KernelVersion:	4.16
 Contact:	Ioana Ciornei <[email protected]>
 Description:	Root dprc rescan attribute
 Users:		Userspace drivers and management tools
+
+What:		/sys/bus/fsl-mc/rescan
+Date:		March. 2018
+KernelVersion:	4.16
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Bus rescan attribute
+Users:		Userspace drivers and management tools
drivers/bus/fsl-mc/fsl-mc-bus.c +48 -0

59 lines not on this page · raw message

Signature · 1 line
1.9.1
#37 lore raw

Re: [PATCH v3 4/4] bus: fsl-mc: add bus rescan attribute

Quoted 23 lines · Ioana Ciornei

Introduce the rescan attribute as a bus attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

 Documentation/ABI/stable/sysfs-bus-fsl-mc |  7 +++++
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 48 +++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
Documentation/ABI/stable/sysfs-bus-fsl-mc +0 -0
index e530e8c..0663fbd 100644

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 10

Quoted 7 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +4 -0
@@ -4,3 +4,10 @@ KernelVersion:	4.16
 Contact:	Ioana Ciornei <[email protected]>
 Description:	Root dprc rescan attribute
 Users:		Userspace drivers and management tools
+
+What:		/sys/bus/fsl-mc/rescan
+Date:		March. 2018
+KernelVersion:	4.16

Same comments as previous review.

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 12

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +2 -0
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Bus rescan attribute

Again, describe this better please.

Quoted 31 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +1 -0
+Users:		Userspace drivers and management tools
drivers/bus/fsl-mc/fsl-mc-bus.c +22 -0
index 9d02984..80010d1 100644
@@ -172,11 +172,59 @@ static ssize_t rescan_store(struct device *dev,
 
 ATTRIBUTE_GROUPS(fsl_mc_dev);
 
+static int scan_fsl_mc_bus(struct device *dev, void *data)
+{
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+
+	if (!fsl_mc_is_root_dprc(dev))
+		goto exit;
+
+	root_mc_dev = to_fsl_mc_device(dev);
+	root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+	mutex_lock(&root_mc_bus->scan_mutex);
+	dprc_scan_objects(root_mc_dev, NULL);
+	mutex_unlock(&root_mc_bus->scan_mutex);
+
+exit:
+	return 0;
+}
+
+static ssize_t bus_rescan_store(struct bus_type *bus,
+				const char *buf, size_t count)
+{
+	unsigned long val;

drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t rescan_store(struct device *dev, · line 206

Quoted 10 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +10 -0
+
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
+	if (val)
+		bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
+
+	return count;
+}
+static BUS_ATTR(rescan, 0220, NULL, bus_rescan_store);

BUS_ATTR_RO()?

Quoted 4 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +4 -0
+
+static struct attribute *fsl_mc_bus_attrs[] = {
+	&bus_attr_rescan.attr,
+	NULL,

drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t rescan_store(struct device *dev, · line 220

Quoted 10 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +10 -0
+};
+
+static const struct attribute_group fsl_mc_bus_group = {
+	.attrs = fsl_mc_bus_attrs,
+};
+
+static const struct attribute_group *fsl_mc_bus_groups[] = {
+	&fsl_mc_bus_group,
+	NULL,
+};

ATTRIBUTE_GROUPS()?

thanks,

greg k-h

author maintainer
#38 lore raw

RE: [PATCH v3 4/4] bus: fsl-mc: add bus rescan attribute

Quoted 74 lines
Quoted 14 lines

Introduce the rescan attribute as a bus attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

Quoted 2 lines
 Documentation/ABI/stable/sysfs-bus-fsl-mc |  7 +++++
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 48

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

Quoted 8 lines
 2 files changed, 55 insertions(+)
Documentation/ABI/stable/sysfs-bus-fsl-mc +0 -0
index e530e8c..0663fbd 100644

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 10

Quoted 7 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +4 -0
@@ -4,3 +4,10 @@ KernelVersion:	4.16
 Contact:	Ioana Ciornei <[email protected]>
 Description:	Root dprc rescan attribute
 Users:		Userspace drivers and management tools
+
+What:		/sys/bus/fsl-mc/rescan
+Date:		March. 2018
+KernelVersion:	4.16

Same comments as previous review.

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 12

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +2 -0
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Bus rescan attribute

Again, describe this better please.

Quoted 34 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +1 -0
+Users:		Userspace drivers and management tools
(quoted diff) +0 -0

b/drivers/bus/fsl-mc/fsl-mc-bus.c index 9d02984..80010d1 100644

drivers/bus/fsl-mc/fsl-mc-bus.c +25 -0
@@ -172,11 +172,59 @@ static ssize_t rescan_store(struct device *dev,
 
 ATTRIBUTE_GROUPS(fsl_mc_dev);
 
+static int scan_fsl_mc_bus(struct device *dev, void *data) {
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+
+	if (!fsl_mc_is_root_dprc(dev))
+		goto exit;
+
+	root_mc_dev = to_fsl_mc_device(dev);
+	root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+	mutex_lock(&root_mc_bus->scan_mutex);
+	dprc_scan_objects(root_mc_dev, NULL);
+	mutex_unlock(&root_mc_bus->scan_mutex);
+
+exit:
+	return 0;
+}
+
+static ssize_t bus_rescan_store(struct bus_type *bus,
+				const char *buf, size_t count)
+{
+	unsigned long val;
+
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
Quoted 10 lines

drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t rescan_store(struct device *dev, · line 206

Quoted 6 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +6 -0
+	if (val)
+		bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
+
+	return count;
+}
+static BUS_ATTR(rescan, 0220, NULL, bus_rescan_store);

BUS_ATTR_RO()?

Since this is a write-only attribute, a BUS_ATTR_WO would be needed but there is no WO macro defined.

Ioana

Quoted 21 lines
Quoted 5 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +4 -0
+
+static struct attribute *fsl_mc_bus_attrs[] = {
+	&bus_attr_rescan.attr,
+	NULL,

drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t rescan_store(struct device *dev, · line 220

Quoted 10 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +10 -0
+};
+
+static const struct attribute_group fsl_mc_bus_group = {
+	.attrs = fsl_mc_bus_attrs,
+};
+
+static const struct attribute_group *fsl_mc_bus_groups[] = {
+	&fsl_mc_bus_group,
+	NULL,
+};

ATTRIBUTE_GROUPS()?

thanks,

greg k-h

#39 lore raw

Re: [PATCH v3 4/4] bus: fsl-mc: add bus rescan attribute

Quoted 85 lines · Ioana Ciornei
Quoted 74 lines
Quoted 14 lines

Introduce the rescan attribute as a bus attribute to synchronize the fsl-mc bus objects and the MC firmware.

To rescan the fsl-mc bus, e.g.,
echo 1 > /sys/bus/fsl-mc/rescan

---
Changes in v2:
- added proper documentation in /Documentation/ABI/
- updated the MAINTAINERS file
Changes in v3:
- no change

Quoted 2 lines
 Documentation/ABI/stable/sysfs-bus-fsl-mc |  7 +++++
 drivers/bus/fsl-mc/fsl-mc-bus.c           | 48

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

Quoted 8 lines
 2 files changed, 55 insertions(+)
Documentation/ABI/stable/sysfs-bus-fsl-mc +0 -0
index e530e8c..0663fbd 100644

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 10

Quoted 7 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +4 -0
@@ -4,3 +4,10 @@ KernelVersion:	4.16
 Contact:	Ioana Ciornei <[email protected]>
 Description:	Root dprc rescan attribute
 Users:		Userspace drivers and management tools
+
+What:		/sys/bus/fsl-mc/rescan
+Date:		March. 2018
+KernelVersion:	4.16

Same comments as previous review.

Documentation/ABI/stable/sysfs-bus-fsl-mc KernelVersion: 4.16 · line 12

Quoted 2 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +2 -0
+Contact:	Ioana Ciornei <[email protected]>
+Description:	Bus rescan attribute

Again, describe this better please.

Quoted 34 lines
Documentation/ABI/stable/sysfs-bus-fsl-mc +1 -0
+Users:		Userspace drivers and management tools
(quoted diff) +0 -0

b/drivers/bus/fsl-mc/fsl-mc-bus.c index 9d02984..80010d1 100644

drivers/bus/fsl-mc/fsl-mc-bus.c +25 -0
@@ -172,11 +172,59 @@ static ssize_t rescan_store(struct device *dev,
 
 ATTRIBUTE_GROUPS(fsl_mc_dev);
 
+static int scan_fsl_mc_bus(struct device *dev, void *data) {
+	struct fsl_mc_device *root_mc_dev;
+	struct fsl_mc_bus *root_mc_bus;
+
+	if (!fsl_mc_is_root_dprc(dev))
+		goto exit;
+
+	root_mc_dev = to_fsl_mc_device(dev);
+	root_mc_bus = to_fsl_mc_bus(root_mc_dev);
+	mutex_lock(&root_mc_bus->scan_mutex);
+	dprc_scan_objects(root_mc_dev, NULL);
+	mutex_unlock(&root_mc_bus->scan_mutex);
+
+exit:
+	return 0;
+}
+
+static ssize_t bus_rescan_store(struct bus_type *bus,
+				const char *buf, size_t count)
+{
+	unsigned long val;
+
+	if (kstrtoul(buf, 0, &val) < 0)
+		return -EINVAL;
+
Quoted 10 lines

drivers/bus/fsl-mc/fsl-mc-bus.c static ssize_t rescan_store(struct device *dev, · line 206

Quoted 6 lines
drivers/bus/fsl-mc/fsl-mc-bus.c +6 -0
+	if (val)
+		bus_for_each_dev(bus, NULL, NULL, scan_fsl_mc_bus);
+
+	return count;
+}
+static BUS_ATTR(rescan, 0220, NULL, bus_rescan_store);

BUS_ATTR_RO()?

Quoted 1 line

Since this is a write-only attribute, a BUS_ATTR_WO would be needed but there is no WO macro defined.

Oops, yes. We can easily fix that :)

thanks,

greg k-h