Skip to contentSkip to conversation

rpmsg: core: Add wildcard match for name service

PATCH Superseded Mathieu Poirier 3 participants 11 messages Mar 10, 2020 – Apr 9, 2020 Remote processor messaging (rpmsg)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Mathieu Poirier

author maintainer
#0 lore raw

PATCH v2 1/1 rpmsg: core: Add wildcard match for name service

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
 				  const struct rpmsg_device_id *id)
 {
-	return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+	size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+	/*
+	 * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+	 * is:
+	 *
+	 * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+	 *      { .name = "rpmsg-client-sample" },
+	 *      { },
+	 * }
+	 *
+	 * Then it is possible to support "rpmsg-client-sample*", i.e:
+	 *	rpmsg-client-sample
+	 *	rpmsg-client-sample_instance0
+	 *	rpmsg-client-sample_instance1
+	 *	...
+	 *	rpmsg-client-sample_instanceX
+	 */
+	return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
Signature · 1 line
2.20.1
#1 lore raw

Hi Mathieu,

Quoted 6 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
 				  const struct rpmsg_device_id *id)
 {
-	return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+	size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+	/*
+	 * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+	 * is:
+	 *
+	 * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+	 *      { .name = "rpmsg-client-sample" },
+	 *      { },
+	 * }
+	 *
+	 * Then it is possible to support "rpmsg-client-sample*", i.e:
+	 *	rpmsg-client-sample
+	 *	rpmsg-client-sample_instance0
+	 *	rpmsg-client-sample_instance1
+	 *	...
+	 *	rpmsg-client-sample_instanceX
+	 */
+	return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
author maintainer
#2 lore raw
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Thanks,
Mathieu

Quoted 44 lines

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
#3 lore raw
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

regards
Suman

Quoted 48 lines

Thanks,
Mathieu

Quoted 44 lines

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
author maintainer
#4 lore raw
Quoted 28 lines · Suman Anna
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

Quoted 53 lines

regards
Suman

Quoted 48 lines

Thanks,
Mathieu

Quoted 44 lines

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
#5 lore raw

Hi

Quoted 29 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 25 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 7 lines
Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

+1 for Suman's concern.

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

But perhaps the need is also to provide a short description of the service?

Suman, could you share some examples of your need?

Regards
Arnaud

Quoted 54 lines
Quoted 54 lines

regards
Suman

Quoted 48 lines

Thanks,
Mathieu

Quoted 44 lines

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
author maintainer
#6 lore raw
Quoted 42 lines · Arnaud POULIQUEN

Hi

Quoted 29 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 25 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 7 lines
Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

+1 for Suman's concern.

Quoted 8 lines

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

But perhaps the need is also to provide a short description of the service?

Suman, could you share some examples of your need?

Looking at things further it is possible to extend the name of the service to 64 byte while keeping backward compatibility by looking up the size of @len in function rpmsg_ns_cb(). From there work with an rpmsg_ns_msg or a new rpmsg_ns_msg64, pretty much the way you did in your patch[1]. In fact the approach is the same except you are using 2 arrays of 32 byte and I'm using one of 64.

As Arnaud mentioned, is there an immediate need to support a 64-byte name? If not than I suggest to move forward with this patch and address the issue when we get there - at least we know there is room for extention. Otherwise I'll spin off another revision but it will be bigger and more complex.

Thanks,
Mathieu

[1]. https://patchwork.kernel.org/patch/11096599/

Quoted 58 lines

Regards
Arnaud

Quoted 54 lines
Quoted 54 lines

regards
Suman

Quoted 48 lines

Thanks,
Mathieu

Quoted 44 lines

regards
Suman

Quoted 40 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
#7 lore raw

Hi Mathieu, Arnaud,

Quoted 41 lines · Mathieu Poirier
Quoted 40 lines · Arnaud POULIQUEN

Hi

Quoted 36 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

Quoted 6 lines
Quoted 6 lines

+1 for Suman's concern.

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

Remember that the rpmsg_device_id name takes some space within here. So, the shorter the rpmsg_device_id table name, the more room you have.

Quoted 2 lines
Quoted 2 lines

But perhaps the need is also to provide a short description of the service?

I am mostly using it to provide a unique instantiation name. In anycase, I have cross-checked against my current firmwares, and so far all of them happen to have the name + desc < 31 bytes.

Quoted 10 lines
Quoted 2 lines

Suman, could you share some examples of your need?

Looking at things further it is possible to extend the name of the service to 64 byte while keeping backward compatibility by looking up the size of @len in function rpmsg_ns_cb(). From there work with an rpmsg_ns_msg or a new rpmsg_ns_msg64, pretty much the way you did in your patch[1]. In fact the approach is the same except you are using 2 arrays of 32 byte and I'm using one of 64.

Quoted 4 lines

As Arnaud mentioned, is there an immediate need to support a 64-byte name? If not than I suggest to move forward with this patch and address the issue when we get there - at least we know there is room for extention. Otherwise I'll spin off another revision but it will be bigger and more complex.

Yeah ok. I have managed to get my downstream drivers that use the desc field working with this patch after modifying the firmwares to publish using combined name, and adding logic in probe to get the trailing portion of the name.

So, the only thing that is missing or content for another patch is if we need to add some tooling/helper stuff for giving the trailing stuff to rpmsg drivers?

regards
Suman

Quoted 49 lines

Thanks,
Mathieu

[1]. https://patchwork.kernel.org/patch/11096599/

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
author maintainer
#8 lore raw
Quoted 78 lines · Suman Anna

Hi Mathieu, Arnaud,

Quoted 41 lines · Mathieu Poirier
Quoted 40 lines · Arnaud POULIQUEN

Hi

Quoted 36 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

Quoted 6 lines
Quoted 6 lines

+1 for Suman's concern.

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

Remember that the rpmsg_device_id name takes some space within here. So, the shorter the rpmsg_device_id table name, the more room you have.

Quoted 2 lines
Quoted 2 lines

But perhaps the need is also to provide a short description of the service?

I am mostly using it to provide a unique instantiation name. In anycase, I have cross-checked against my current firmwares, and so far all of them happen to have the name + desc < 31 bytes.

Quoted 10 lines
Quoted 2 lines

Suman, could you share some examples of your need?

Looking at things further it is possible to extend the name of the service to 64 byte while keeping backward compatibility by looking up the size of @len in function rpmsg_ns_cb(). From there work with an rpmsg_ns_msg or a new rpmsg_ns_msg64, pretty much the way you did in your patch[1]. In fact the approach is the same except you are using 2 arrays of 32 byte and I'm using one of 64.

Quoted 4 lines

As Arnaud mentioned, is there an immediate need to support a 64-byte name? If not than I suggest to move forward with this patch and address the issue when we get there - at least we know there is room for extention. Otherwise I'll spin off another revision but it will be bigger and more complex.

Quoted 4 lines

Yeah ok. I have managed to get my downstream drivers that use the desc field working with this patch after modifying the firmwares to publish using combined name, and adding logic in probe to get the trailing portion of the name.

Perfect

Quoted 4 lines

So, the only thing that is missing or content for another patch is if we need to add some tooling/helper stuff for giving the trailing stuff to rpmsg drivers?

So that all rpmsg drivers don't come up with their own parsing that ends up doing the same thing. Let me think about that - I may have to get back to you...

Quoted 54 lines

regards
Suman

Quoted 49 lines

Thanks,
Mathieu

[1]. https://patchwork.kernel.org/patch/11096599/

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
#9 lore raw
Quoted 87 lines · Mathieu Poirier
Quoted 78 lines · Suman Anna

Hi Mathieu, Arnaud,

Quoted 41 lines · Mathieu Poirier
Quoted 40 lines · Arnaud POULIQUEN

Hi

Quoted 36 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

Quoted 6 lines
Quoted 6 lines

+1 for Suman's concern.

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

Remember that the rpmsg_device_id name takes some space within here. So, the shorter the rpmsg_device_id table name, the more room you have.

Quoted 2 lines
Quoted 2 lines

But perhaps the need is also to provide a short description of the service?

I am mostly using it to provide a unique instantiation name. In anycase, I have cross-checked against my current firmwares, and so far all of them happen to have the name + desc < 31 bytes.

Quoted 10 lines
Quoted 2 lines

Suman, could you share some examples of your need?

Looking at things further it is possible to extend the name of the service to 64 byte while keeping backward compatibility by looking up the size of @len in function rpmsg_ns_cb(). From there work with an rpmsg_ns_msg or a new rpmsg_ns_msg64, pretty much the way you did in your patch[1]. In fact the approach is the same except you are using 2 arrays of 32 byte and I'm using one of 64.

Quoted 4 lines

As Arnaud mentioned, is there an immediate need to support a 64-byte name? If not than I suggest to move forward with this patch and address the issue when we get there - at least we know there is room for extention. Otherwise I'll spin off another revision but it will be bigger and more complex.

Quoted 4 lines

Yeah ok. I have managed to get my downstream drivers that use the desc field working with this patch after modifying the firmwares to publish using combined name, and adding logic in probe to get the trailing portion of the name.

Perfect

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

So, the only thing that is missing or content for another patch is if we need to add some tooling/helper stuff for giving the trailing stuff to rpmsg drivers?

So that all rpmsg drivers don't come up with their own parsing that ends up doing the same thing. Let me think about that - I may have to get back to you...

Yep. Sure no problem. It can be a patch on top of this as well.

Arnaud,
Do you have immediate need for the tooling stuff for the rpmsg-tty driver?

regards
Suman

Quoted 55 lines
Quoted 55 lines

regards
Suman

Quoted 49 lines

Thanks,
Mathieu

[1]. https://patchwork.kernel.org/patch/11096599/

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */
#10 lore raw

Hi Suman,

Quoted 92 lines · Suman Anna
Quoted 91 lines · Mathieu Poirier
Quoted 78 lines · Suman Anna

Hi Mathieu, Arnaud,

Quoted 41 lines · Mathieu Poirier
Quoted 40 lines · Arnaud POULIQUEN

Hi

Quoted 36 lines · Mathieu Poirier
Quoted 28 lines · Suman Anna
Quoted 18 lines · Mathieu Poirier
Quoted 8 lines · Suman Anna

Hi Mathieu,

Quoted 4 lines · Mathieu Poirier

Adding the capability to supplement the base definition published by an rpmsg_driver with a postfix description so that it is possible for several entity to use the same service.

Quoted 8 lines
Quoted 2 lines

So, the concern I have here is that we are retrofitting this into the existing 32-byte name field, and the question is if it is going to be enough in general. That's the reason I went with the additional 32-byte field with the "rpmsg: add a description field" patch.

Quoted 7 lines

That's a valid concern.

Did you consider increasing the size of RPMSG_NAME_SIZE to 64? Have you found cases where that wouldn't work? I did a survey of all the places the #define is used and all destination buffers are also using the same #define in their definition. It would also be backward compatible with firmware implementations that use 32 byte.

Quoted 4 lines

You can't directly bump the size without breaking the compatibility on the existing rpmsg_ns_msg in firmwares right? All the Linux-side drivers will be ok since they use the same macro but rpmsg_ns_msg has presence on both kernel and firmware-sides.

Ah yes yes... The amount of bytes coming out of the pipe won't match. Let me think a little...

Quoted 6 lines
Quoted 6 lines

+1 for Suman's concern.

Anyway i would like to challenge the need of more than 32 bytes to differentiate service instances. "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", seems to me enough if we only need to differentiate the instances.

Remember that the rpmsg_device_id name takes some space within here. So, the shorter the rpmsg_device_id table name, the more room you have.

Quoted 2 lines
Quoted 2 lines

But perhaps the need is also to provide a short description of the service?

I am mostly using it to provide a unique instantiation name. In anycase, I have cross-checked against my current firmwares, and so far all of them happen to have the name + desc < 31 bytes.

Quoted 10 lines
Quoted 2 lines

Suman, could you share some examples of your need?

Looking at things further it is possible to extend the name of the service to 64 byte while keeping backward compatibility by looking up the size of @len in function rpmsg_ns_cb(). From there work with an rpmsg_ns_msg or a new rpmsg_ns_msg64, pretty much the way you did in your patch[1]. In fact the approach is the same except you are using 2 arrays of 32 byte and I'm using one of 64.

Quoted 4 lines

As Arnaud mentioned, is there an immediate need to support a 64-byte name? If not than I suggest to move forward with this patch and address the issue when we get there - at least we know there is room for extention. Otherwise I'll spin off another revision but it will be bigger and more complex.

Quoted 4 lines

Yeah ok. I have managed to get my downstream drivers that use the desc field working with this patch after modifying the firmwares to publish using combined name, and adding logic in probe to get the trailing portion of the name.

Perfect

Quoted 4 lines

So, the only thing that is missing or content for another patch is if we need to add some tooling/helper stuff for giving the trailing stuff to rpmsg drivers?

Quoted 8 lines
Quoted 3 lines

So that all rpmsg drivers don't come up with their own parsing that ends up doing the same thing. Let me think about that - I may have to get back to you...

Yep. Sure no problem. It can be a patch on top of this as well.

Arnaud,
Do you have immediate need for the tooling stuff for the rpmsg-tty driver?

Before moving forward on rpmsg_tty i would prefer that we are aligned with Bjorn on the implementation of the rpmsg_tty itself and the evolution of the service name... Then rpmsg_tty could be a good threadfor a first implementation...

Concerning the name service, having a discussion around the name service skeleton would be nice. This could be an good input for the helpers function definition.

Propositions in rpmsg_tty thread are

<service_name>-<feature>
or
<service_name>-<feature>-<sub_service>

don't hesitate to comment and/or propose alternatives

Regards,
Arnaud

Quoted 61 lines

regards
Suman

Quoted 55 lines
Quoted 55 lines

regards
Suman

Quoted 49 lines

Thanks,
Mathieu

[1]. https://patchwork.kernel.org/patch/11096599/

Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines

---
Changes for V2:
- Added Arnaud's Acked-by.
- Rebased to latest rproc-next.

 drivers/rpmsg/rpmsg_core.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_core.c +19 -1
index e330ec4dfc33..bfd25978fa35 100644
@@ -399,7 +399,25 @@ ATTRIBUTE_GROUPS(rpmsg_dev);
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
                                const struct rpmsg_device_id *id)
 {
-     return strncmp(id->name, rpdev->id.name, RPMSG_NAME_SIZE) == 0;
+     size_t len = min_t(size_t, strlen(id->name), RPMSG_NAME_SIZE);
+
+     /*
+      * Allow for wildcard matches.  For example if rpmsg_driver::id_table
+      * is:
+      *
+      * static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = {
+      *      { .name = "rpmsg-client-sample" },
+      *      { },
+      * }
+      *
+      * Then it is possible to support "rpmsg-client-sample*", i.e:
+      *      rpmsg-client-sample
+      *      rpmsg-client-sample_instance0
+      *      rpmsg-client-sample_instance1
+      *      ...
+      *      rpmsg-client-sample_instanceX
+      */
+     return strncmp(id->name, rpdev->id.name, len) == 0;
 }
 
 /* match rpmsg channel and rpmsg driver */