raw/cnxk_gpio: support multi-process mode
PATCH 1/2 raw/cnxk_gpio: support multi-process mode
GPIO PMD uses a mixture of standard sysfs attributes and custom ioctl()s to control behaviour of respective GPIOs available in the system.
This means that each userspace application, either running as a primary or a secondary, should be able to control a set of distinct GPIOs.
In rare cases where multiple processes need to control the same set of GPIOs userspace application is responsible for synchronizing accesses.
--- doc/guides/rawdevs/cnxk_gpio.rst | 7 ++ drivers/raw/cnxk_gpio/cnxk_gpio.c | 143 ++++++++++++++++++++---------- 2 files changed, 104 insertions(+), 46 deletions(-)
doc/guides/rawdevs/cnxk_gpio.rst +7 -0
@@ -21,6 +21,7 @@ Following features are available: - set GPIO edge that triggers interrupt - set GPIO active low - register interrupt handler for specific GPIO +- multiprocess aware Requirements ------------
@@ -30,6 +31,12 @@ for installing interrupt handlers for low latency signal processing. Driver is shipped with Marvell SDK. +Limitations +----------- + +In multiprocess mode user-space application must ensure no GPIO sharing across +processes takes place. + Device Setup ------------
drivers/raw/cnxk_gpio/cnxk_gpio.c +97 -46
292 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/2 raw/cnxk_gpio: add bunch of newlines
Improve log output by adding some newlines.
--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio.c +4 -4
@@ -713,7 +713,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)cnxk_gpio_format_name (name,sizeof (name)); rawdev =rte_rawdev_pmd_allocate (name,sizeof (*gpiochip),rte_socket_id ());if (!rawdev) { -RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev" , name); +RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev\n" , name);return -ENOMEM ; }
@@ -753,7 +753,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/base" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->base);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; }
@@ -761,7 +761,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/ngpio" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->num_gpios);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; } gpiochip->num_queues = gpiochip->num_gpios;
@@ -774,7 +774,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev) gpiochip->gpios =rte_calloc (NULL , gpiochip->num_gpios,sizeof (struct cnxk_gpio *),0 );if (!gpiochip->gpios) { -RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory" ); +RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory\n" ); ret = -ENOMEM ; goto out; }
Signature · 1 line
2.34.1
Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlines
Quoted 41 lines · On Tue, 3 Oct 2023 22:46:03 +0200 Tomasz Duszynski <[email protected]>…
Improve log output by adding some newlines.
Signed-off-by Tomasz Duszynski <[email protected]>Reviewed-by Jerin Jacob Kollanukkaran <[email protected]>--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/raw/cnxk_gpio/cnxk_gpio.c +3
-3@@ -713,7 +713,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)cnxk_gpio_format_name (name,sizeof (name)); rawdev =rte_rawdev_pmd_allocate (name,sizeof (*gpiochip),rte_socket_id ());if (!rawdev) { -RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev" , name); +RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev\n" , name);return -ENOMEM ; }@@ -753,7 +753,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/base" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->base);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; }@@ -761,7 +761,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/ngpio" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->num_gpios);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; } gpiochip->num_queues = gpiochip->num_gpios;
drivers/raw/cnxk_gpio/cnxk_gpio.c cnxk_gpio_probe(struct rte_vdev_device *dev) · line 780
Quoted 8 lines
drivers/raw/cnxk_gpio/cnxk_gpio.c +1
-1@@ -774,7 +774,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev) gpiochip->gpios =rte_calloc (NULL , gpiochip->num_gpios,sizeof (struct cnxk_gpio *),0 );if (!gpiochip->gpios) { -RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory" ); +RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory\n" ); ret = -ENOMEM ; goto out; }
No driver should be using the PMD logtype. It should always be using a dynamically allocated log type.
RE: [EXT] Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlines
Quoted 59 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, October 4, 2023 12:26 AM
To: Tomasz Duszynski <[email protected]>
Cc: [email protected]; Jakub Palider <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlinesExternal Email
----------------------------------------------------------------------
Quoted 43 lines · On Tue, 3 Oct 2023 22:46:03 +0200 Tomasz Duszynski <[email protected]>…
Improve log output by adding some newlines.
Signed-off-by Tomasz Duszynski <[email protected]>Reviewed-by Jerin Jacob Kollanukkaran <[email protected]>--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/raw/cnxk_gpio/cnxk_gpio.c +3
-3@@ -713,7 +713,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)cnxk_gpio_format_name (name,sizeof (name)); rawdev =rte_rawdev_pmd_allocate (name,sizeof (*gpiochip),rte_socket_id ());if (!rawdev) { -RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev" , name); +RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev\n" , name);return -ENOMEM ; }@@ -753,7 +753,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/base" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->base);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; }@@ -761,7 +761,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/ngpio" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->num_gpios);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; } gpiochip->num_queues = gpiochip->num_gpios; @@ -774,7 +774,7 @@
cnxk_gpio_probe(struct rte_vdev_device *dev)
Quoted 11 lines
drivers/raw/cnxk_gpio/cnxk_gpio.c cnxk_gpio_probe(struct rte_vdev_device *dev) · line 780
Quoted 7 lines
drivers/raw/cnxk_gpio/cnxk_gpio.c +1
-1gpiochip->gpios =rte_calloc (NULL , gpiochip->num_gpios,sizeof (struct cnxk_gpio *),0 );if (!gpiochip->gpios) { -RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory" ); +RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory\n" ); ret = -ENOMEM ; goto out; }No driver should be using the PMD logtype. It should always be using a dynamically allocated log type.
Even though it uses old-fashioned logging that change could still improve output for some users out there.
Anyway, if you don't want any extra commit noise let's abandon that and these improvements will show up in dynamic logging patch.
Re: [EXT] Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlines
Quoted 8 lines · On Wed, 4 Oct 2023 20:42:47 +0000 Tomasz Duszynski <[email protected]>…
Quoted 3 lines
No driver should be using the PMD logtype. It should always be using a dynamically allocated log type.
Even though it uses old-fashioned logging that change could still improve output for some users out there.
Anyway, if you don't want any extra commit noise let's abandon that and these improvements will show up in dynamic logging patch.
Keep it for now, but soon RTE_LOGTYPE_PMD will be marked deprecated.
RE: [EXT] Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlines
Quoted 17 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, October 5, 2023 4:55 AM
To: Tomasz Duszynski <[email protected]>
Cc: [email protected]; Jakub Palider <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: Re: [EXT] Re: [PATCH 2/2] raw/cnxk_gpio: add bunch of newlinesQuoted 4 lines · On Wed, 4 Oct 2023 20:42:47 +0000 Tomasz Duszynski <[email protected]>…
Quoted 3 lines
No driver should be using the PMD logtype. It should always be using a dynamically allocated log type.
Quoted 7 lines
Quoted 4 lines
Even though it uses old-fashioned logging that change could still improve output for some users out there.
Anyway, if you don't want any extra commit noise let's abandon that and these improvements will
show up in dynamic logging patch.
Keep it for now, but soon
RTE_LOGTYPE_PMDwill be marked deprecated.
Okay. Will respin that and send separate patch that uses dynamic logging instead.
drivers/raw/cnxk_gpio/cnxk_gpio.c line 27
Quoted 5 lines · On Tue, 3 Oct 2023 22:46:02 +0200 Tomasz Duszynski <[email protected]>…
drivers/raw/cnxk_gpio/cnxk_gpio.c +5
-0+ +struct cnxk_gpio_params { +char allowlist[CNXK_GPIO_BUFSZ ]; +int num; +};
Should be using unsigned for number of params since can't be negative. You could also use a flex array to avoid any buf size issues.
Quoted 14 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Wednesday, October 4, 2023 12:29 AM
To: Tomasz Duszynski <[email protected]>
Cc: [email protected]; Jakub Palider <[email protected]>; Anatoly Burakov <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH 1/2] raw/cnxk_gpio: support multi-process modeExternal Email
----------------------------------------------------------------------
On Tue, 3 Oct 2023 22:46:02 +0200
Tomasz Duszynski <[email protected]> wrote:
Quoted 7 lines
drivers/raw/cnxk_gpio/cnxk_gpio.c line 27
Quoted 5 lines
drivers/raw/cnxk_gpio/cnxk_gpio.c +5
-0+ +struct cnxk_gpio_params { +char allowlist[CNXK_GPIO_BUFSZ ]; +int num; +};Should be using unsigned for number of params since can't be negative.
I don't think that it breaks anything currently i.e in worst case scenario chip won't be found in sysfs but from correctness pov you are right. Will change that in v2.
Quoted 1 line
You could also use a flex array to avoid any buf size issues.
Okay, will address that in v2.
PATCH v2 1/2 raw/cnxk_gpio: support multi-process mode
In reply to Tomasz DuszynskiGPIO PMD uses a mixture of standard sysfs attributes and custom ioctl()s to control behaviour of respective GPIOs available in the system.
This means that each userspace application, either running as a primary or a secondary, should be able to control a set of distinct GPIOs.
In rare cases where multiple processes need to control the same set of GPIOs userspace application is responsible for synchronizing accesses.
---
v2:
- make gpiochip number unsigned
- do not hardcode length of PMD cmd line parameters buffer
doc/guides/rawdevs/cnxk_gpio.rst | 7 ++ drivers/raw/cnxk_gpio/cnxk_gpio.c | 184 ++++++++++++++++++++---------- 2 files changed, 131 insertions(+), 60 deletions(-)
doc/guides/rawdevs/cnxk_gpio.rst +7 -0
@@ -21,6 +21,7 @@ Following features are available: - set GPIO edge that triggers interrupt - set GPIO active low - register interrupt handler for specific GPIO +- multiprocess aware Requirements ------------
@@ -30,6 +31,12 @@ for installing interrupt handlers for low latency signal processing. Driver is shipped with Marvell SDK. +Limitations +----------- + +In multiprocess mode user-space application must ensure no GPIO sharing across +processes takes place. + Device Setup ------------
drivers/raw/cnxk_gpio/cnxk_gpio.c +124 -60
333 lines not on this page · raw message
--
2.34.1
PATCH v2 2/2 raw/cnxk_gpio: add bunch of newlines
Improve log output by adding some newlines.
--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio.c +4 -4
@@ -737,7 +737,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)cnxk_gpio_format_name (name,sizeof (name)); rawdev =rte_rawdev_pmd_allocate (name,sizeof (*gpiochip),rte_socket_id ());if (!rawdev) { -RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev" , name); +RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev\n" , name);return -ENOMEM ; }
@@ -766,7 +766,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/base" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->base);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; }
@@ -774,7 +774,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/ngpio" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->num_gpios);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; } gpiochip->num_queues = gpiochip->num_gpios;
@@ -787,7 +787,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev) gpiochip->gpios =rte_calloc (NULL , gpiochip->num_gpios,sizeof (struct cnxk_gpio *),0 );if (!gpiochip->gpios) { -RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory" ); +RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory\n" ); ret = -ENOMEM ; goto out; }
Signature · 1 line
2.34.1
PATCH v3 1/2 raw/cnxk_gpio: support multi-process mode
In reply to Tomasz DuszynskiGPIO PMD uses a mixture of standard sysfs attributes and custom ioctl()s to control behaviour of respective GPIOs available in the system.
This means that each userspace application, either running as a primary or a secondary, should be able to control a set of distinct GPIOs.
In rare cases where multiple processes need to control the same set of GPIOs userspace application is responsible for synchronizing accesses.
---
v3:
- make gpiochip number unsigned
- do not hardcode length of PMD cmd line parameters buffer
- fix unchecked sscanf return value warning
doc/guides/rawdevs/cnxk_gpio.rst | 7 ++ drivers/raw/cnxk_gpio/cnxk_gpio.c | 188 ++++++++++++++++++++---------- 2 files changed, 134 insertions(+), 61 deletions(-)
doc/guides/rawdevs/cnxk_gpio.rst +7 -0
@@ -21,6 +21,7 @@ Following features are available: - set GPIO edge that triggers interrupt - set GPIO active low - register interrupt handler for specific GPIO +- multiprocess aware Requirements ------------
@@ -30,6 +31,12 @@ for installing interrupt handlers for low latency signal processing. Driver is shipped with Marvell SDK. +Limitations +----------- + +In multiprocess mode user-space application must ensure no GPIO sharing across +processes takes place. + Device Setup ------------
drivers/raw/cnxk_gpio/cnxk_gpio.c +127 -61
337 lines not on this page · raw message
--
2.34.1
PATCH v3 2/2 raw/cnxk_gpio: add bunch of newlines
Improve log output by adding some newlines.
--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/raw/cnxk_gpio/cnxk_gpio.c +4 -4
@@ -739,7 +739,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)cnxk_gpio_format_name (name,sizeof (name)); rawdev =rte_rawdev_pmd_allocate (name,sizeof (*gpiochip),rte_socket_id ());if (!rawdev) { -RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev" , name); +RTE_LOG (ERR ,PMD ,"failed to allocate %s rawdev\n" , name);return -ENOMEM ; }
@@ -768,7 +768,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/base" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->base);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; }
@@ -776,7 +776,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev)snprintf (buf,sizeof (buf),"%s/gpiochip%d/ngpio" ,CNXK_GPIO_CLASS_PATH , gpiochip->num); ret =cnxk_gpio_read_attr_int (buf, &gpiochip->num_gpios);if (ret) { -RTE_LOG (ERR ,PMD ,"failed to read %s" , buf); +RTE_LOG (ERR ,PMD ,"failed to read %s\n" , buf); goto out; } gpiochip->num_queues = gpiochip->num_gpios;
@@ -789,7 +789,7 @@ cnxk_gpio_probe(struct rte_vdev_device *dev) gpiochip->gpios =rte_calloc (NULL , gpiochip->num_gpios,sizeof (struct cnxk_gpio *),0 );if (!gpiochip->gpios) { -RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory" ); +RTE_LOG (ERR ,PMD ,"failed to allocate gpios memory\n" ); ret = -ENOMEM ; goto out; }
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] raw/cnxk_gpio: add bunch of newlines
Quoted 8 lines · Tomasz Duszynski
Improve log output by adding some newlines.
Signed-off-by Tomasz Duszynski <[email protected]>Reviewed-by Jerin Jacob Kollanukkaran <[email protected]>--- drivers/raw/cnxk_gpio/cnxk_gpio.c | 8 ++++----
Updated the git commit as follows and applied to
dpdk-next-net-mrvl/for-next-net. Thanks
commit 26e04c2f64f80bb8323c2e32a4f1b59ce1cb283a (HEAD -> for-next-net, origin/for-next-net)
Author: Tomasz Duszynski <[email protected]> Date: Mon Oct 16 12:04:22 2023 +0200
raw/cnxk_gpio: improve log output
Improve log output by adding some newlines.
commit 31f8e6cd63fb5c4eaa4e689fdabc4bce4a0074d7
Author: Tomasz Duszynski <[email protected]> Date: Mon Oct 16 12:04:21 2023 +0200
raw/cnxk_gpio: support multi-process mode
GPIO PMD uses a mixture of standard sysfs attributes and custom ioctl()s to control behaviour of respective GPIOs available in the system.
This means that each userspace application, either running as a primary or a secondary, should be able to control a set of distinct GPIOs.
In rare cases where multiple processes need to control the same set of GPIOs userspace application is responsible for synchronizing accesses.