* [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
@ 2014-11-06 22:06 ira.weiny-ral2JQCrhuEAvxtiuMwx3w
[not found] ` <1415311595-29720-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: ira.weiny-ral2JQCrhuEAvxtiuMwx3w @ 2014-11-06 22:06 UTC (permalink / raw)
To: roland-DgEjT+Ai2ygdnm+yROfE0A
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Ira Weiny
From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
ib_build_node_desc - prints src node description into dest while mapping format
specifiers
Specifiers supported:
%h system hostname
%d device name
Define a default Node Description format to be "%h %d"
Original work done by Mike Heinz.
The function signature is generic to support some devices which are not
processing an ib_smp object when calling this function.
Reviewed-by: John Fleck <john.fleck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Reviewed-by: Michael Heinz <michael.william.heinz-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
Changes from V1
remove unnecessary ib_smi include
drivers/infiniband/core/mad.c | 37 +++++++++++++++++++++++++++++++++++++
include/rdma/ib_mad.h | 17 +++++++++++++++++
include/rdma/ib_verbs.h | 6 ++++--
3 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 74c30f4..93cf8a0 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -39,6 +39,7 @@
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/utsname.h>
#include <rdma/ib_cache.h>
#include "mad_priv.h"
@@ -996,6 +997,42 @@ int ib_get_mad_data_offset(u8 mgmt_class)
}
EXPORT_SYMBOL(ib_get_mad_data_offset);
+void ib_build_node_desc(char *dest, char *src, int dest_len,
+ struct ib_device *dev)
+{
+ char *end = dest + dest_len-1;
+ char *field;
+
+ while (*src && (dest < end)) {
+ if (*src != '%') {
+ *dest++ = *src++;
+ } else {
+ src++;
+ switch (*src) {
+ case 'h':
+ field = init_utsname()->nodename;
+ src++;
+ while (*field && (*field != '.') && (dest < end))
+ *dest++ = *field++;
+ break;
+ case 'd':
+ field = dev->name;
+ src++;
+ while (*field && (dest < end))
+ *dest++ = *field++;
+ break;
+ default:
+ src++;
+ }
+ }
+ }
+ if (dest < end)
+ *dest = 0;
+ else
+ *end = 0;
+}
+EXPORT_SYMBOL(ib_build_node_desc);
+
int ib_is_mad_class_rmpp(u8 mgmt_class)
{
if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 9bb99e9..975642e 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -677,4 +677,21 @@ void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
*/
int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent);
+#define IB_DEFAULT_ND_FORMAT "%h %d"
+/**
+ * ib_build_node_desc - prints src node description into dest while mapping
+ * format specifiers
+ *
+ * Specifiers supported:
+ * %h system hostname
+ * %d device name
+ *
+ * @dest: destination buffer
+ * @src: source buffer
+ * @dest_len: destination buffer length
+ * @dev: ib_device
+ */
+void ib_build_node_desc(char *dest, char *src, int dest_len,
+ struct ib_device *dev);
+
#endif /* IB_MAD_H */
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 470a011..f3ec6de 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -55,6 +55,8 @@
extern struct workqueue_struct *ib_wq;
+#define IB_DEVICE_DESC_MAX 64
+
union ib_gid {
u8 raw[16];
struct {
@@ -351,7 +353,7 @@ enum ib_device_modify_flags {
struct ib_device_modify {
u64 sys_image_guid;
- char node_desc[64];
+ char node_desc[IB_DEVICE_DESC_MAX];
};
enum ib_port_modify_flags {
@@ -1625,7 +1627,7 @@ struct ib_device {
u64 uverbs_cmd_mask;
u64 uverbs_ex_cmd_mask;
- char node_desc[64];
+ char node_desc[IB_DEVICE_DESC_MAX];
__be64 node_guid;
u32 local_dma_lkey;
u8 node_type;
--
1.8.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
[not found] ` <1415311595-29720-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
@ 2014-11-06 22:55 ` Hefty, Sean
2014-11-07 12:17 ` Hal Rosenstock
1 sibling, 0 replies; 6+ messages in thread
From: Hefty, Sean @ 2014-11-06 22:55 UTC (permalink / raw)
To: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Weiny, Ira
> +void ib_build_node_desc(char *dest, char *src, int dest_len,
> + struct ib_device *dev)
> +{
> + char *end = dest + dest_len-1;
> + char *field;
> +
> + while (*src && (dest < end)) {
> + if (*src != '%') {
> + *dest++ = *src++;
> + } else {
> + src++;
> + switch (*src) {
> + case 'h':
> + field = init_utsname()->nodename;
> + src++;
> + while (*field && (*field != '.') && (dest < end))
> + *dest++ = *field++;
> + break;
Indentation is off
> + case 'd':
> + field = dev->name;
> + src++;
> + while (*field && (dest < end))
> + *dest++ = *field++;
> + break;
> + default:
> + src++;
> + }
> + }
src++ is called in every case and could be moved outside
> + }
> + if (dest < end)
> + *dest = 0;
> + else
> + *end = 0;
*dest = '\0'; should be sufficient in all cases
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
[not found] ` <1415311595-29720-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-06 22:55 ` Hefty, Sean
@ 2014-11-07 12:17 ` Hal Rosenstock
[not found] ` <545CB845.6070104-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
1 sibling, 1 reply; 6+ messages in thread
From: Hal Rosenstock @ 2014-11-07 12:17 UTC (permalink / raw)
To: ira.weiny-ral2JQCrhuEAvxtiuMwx3w
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
Eitan Zahavi
On 11/6/2014 5:06 PM, ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> ib_build_node_desc - prints src node description into dest while mapping format
> specifiers
>
> Specifiers supported:
> %h system hostname
> %d device name
>
> Define a default Node Description format to be "%h %d"
There are a lot of Node Description schemes in use in the field
currently. New format needs to be made as unlikely as possible to
interfere with those. So perhaps H:%h D:%d ?
Also, in order to support such installations, whether or not to use this
format should be configurable.
-- Hal
> Original work done by Mike Heinz.
>
> The function signature is generic to support some devices which are not
> processing an ib_smp object when calling this function.
>
> Reviewed-by: John Fleck <john.fleck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Michael Heinz <michael.william.heinz-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Reviewed-by: Mike Marciniszyn <mike.marciniszyn-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> ---
>
> Changes from V1
> remove unnecessary ib_smi include
>
> drivers/infiniband/core/mad.c | 37 +++++++++++++++++++++++++++++++++++++
> include/rdma/ib_mad.h | 17 +++++++++++++++++
> include/rdma/ib_verbs.h | 6 ++++--
> 3 files changed, 58 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
> index 74c30f4..93cf8a0 100644
> --- a/drivers/infiniband/core/mad.c
> +++ b/drivers/infiniband/core/mad.c
> @@ -39,6 +39,7 @@
> #include <linux/dma-mapping.h>
> #include <linux/slab.h>
> #include <linux/module.h>
> +#include <linux/utsname.h>
> #include <rdma/ib_cache.h>
>
> #include "mad_priv.h"
> @@ -996,6 +997,42 @@ int ib_get_mad_data_offset(u8 mgmt_class)
> }
> EXPORT_SYMBOL(ib_get_mad_data_offset);
>
> +void ib_build_node_desc(char *dest, char *src, int dest_len,
> + struct ib_device *dev)
> +{
> + char *end = dest + dest_len-1;
> + char *field;
> +
> + while (*src && (dest < end)) {
> + if (*src != '%') {
> + *dest++ = *src++;
> + } else {
> + src++;
> + switch (*src) {
> + case 'h':
> + field = init_utsname()->nodename;
> + src++;
> + while (*field && (*field != '.') && (dest < end))
> + *dest++ = *field++;
> + break;
> + case 'd':
> + field = dev->name;
> + src++;
> + while (*field && (dest < end))
> + *dest++ = *field++;
> + break;
> + default:
> + src++;
> + }
> + }
> + }
> + if (dest < end)
> + *dest = 0;
> + else
> + *end = 0;
> +}
> +EXPORT_SYMBOL(ib_build_node_desc);
> +
> int ib_is_mad_class_rmpp(u8 mgmt_class)
> {
> if ((mgmt_class == IB_MGMT_CLASS_SUBN_ADM) ||
> diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
> index 9bb99e9..975642e 100644
> --- a/include/rdma/ib_mad.h
> +++ b/include/rdma/ib_mad.h
> @@ -677,4 +677,21 @@ void ib_free_send_mad(struct ib_mad_send_buf *send_buf);
> */
> int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent);
>
> +#define IB_DEFAULT_ND_FORMAT "%h %d"
> +/**
> + * ib_build_node_desc - prints src node description into dest while mapping
> + * format specifiers
> + *
> + * Specifiers supported:
> + * %h system hostname
> + * %d device name
> + *
> + * @dest: destination buffer
> + * @src: source buffer
> + * @dest_len: destination buffer length
> + * @dev: ib_device
> + */
> +void ib_build_node_desc(char *dest, char *src, int dest_len,
> + struct ib_device *dev);
> +
> #endif /* IB_MAD_H */
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 470a011..f3ec6de 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -55,6 +55,8 @@
>
> extern struct workqueue_struct *ib_wq;
>
> +#define IB_DEVICE_DESC_MAX 64
> +
> union ib_gid {
> u8 raw[16];
> struct {
> @@ -351,7 +353,7 @@ enum ib_device_modify_flags {
>
> struct ib_device_modify {
> u64 sys_image_guid;
> - char node_desc[64];
> + char node_desc[IB_DEVICE_DESC_MAX];
> };
>
> enum ib_port_modify_flags {
> @@ -1625,7 +1627,7 @@ struct ib_device {
> u64 uverbs_cmd_mask;
> u64 uverbs_ex_cmd_mask;
>
> - char node_desc[64];
> + char node_desc[IB_DEVICE_DESC_MAX];
> __be64 node_guid;
> u32 local_dma_lkey;
> u8 node_type;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
[not found] ` <545CB845.6070104-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
@ 2014-11-07 20:53 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399DFFD90-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-11-09 23:33 ` Weiny, Ira
1 sibling, 1 reply; 6+ messages in thread
From: Hefty, Sean @ 2014-11-07 20:53 UTC (permalink / raw)
To: Hal Rosenstock, Weiny, Ira
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Eitan Zahavi
> > Define a default Node Description format to be "%h %d"
>
> There are a lot of Node Description schemes in use in the field
> currently. New format needs to be made as unlikely as possible to
> interfere with those. So perhaps H:%h D:%d ?
Is there something for this in the upstream kernel code already?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399DFFD90-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2014-11-07 22:44 ` Hal Rosenstock
0 siblings, 0 replies; 6+ messages in thread
From: Hal Rosenstock @ 2014-11-07 22:44 UTC (permalink / raw)
To: Hefty, Sean
Cc: Weiny, Ira, roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Eitan Zahavi
On 11/7/2014 3:53 PM, Hefty, Sean wrote:
>>> Define a default Node Description format to be "%h %d"
>>
>> There are a lot of Node Description schemes in use in the field
>> currently. New format needs to be made as unlikely as possible to
>> interfere with those. So perhaps H:%h D:%d ?
>
> Is there something for this in the upstream kernel code already?
No; not AFAIK.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description
[not found] ` <545CB845.6070104-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-11-07 20:53 ` Hefty, Sean
@ 2014-11-09 23:33 ` Weiny, Ira
1 sibling, 0 replies; 6+ messages in thread
From: Weiny, Ira @ 2014-11-09 23:33 UTC (permalink / raw)
To: Hal Rosenstock
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Eitan Zahavi
>
> On 11/6/2014 5:06 PM, ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> > From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> >
> > ib_build_node_desc - prints src node description into dest while
> > mapping format specifiers
> >
> > Specifiers supported:
> > %h system hostname
> > %d device name
> >
> > Define a default Node Description format to be "%h %d"
>
> There are a lot of Node Description schemes in use in the field currently. New
> format needs to be made as unlikely as possible to interfere with those. So
> perhaps H:%h D:%d ?
What I am proposing was generally agreed upon to be a reasonable default in this thread:
http://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg07295.html
Furthermore RHEL 6.4 has started to use this naming scheme in their rdma start up script as was proposed and agreed upon by Doug Ledford in this thread:
https://www.mail-archive.com/linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg11282.html
>
> Also, in order to support such installations, whether or not to use this format
> should be configurable.
It is configurable. You can overwrite the node_desc field anyway you want just as before and no current user space software needs to change if a user has customizations there.
What is nice about this addition is that _if_ the user does _not_ have customizations the defaults are, IMHO, much more usable "by default".
-- Ira
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-09 23:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 22:06 [PATCH v2 1/6] ib/mad: Add function to support format specifiers for node description ira.weiny-ral2JQCrhuEAvxtiuMwx3w
[not found] ` <1415311595-29720-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-06 22:55 ` Hefty, Sean
2014-11-07 12:17 ` Hal Rosenstock
[not found] ` <545CB845.6070104-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2014-11-07 20:53 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A8237399DFFD90-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-11-07 22:44 ` Hal Rosenstock
2014-11-09 23:33 ` Weiny, Ira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox