diff mbox

[v2,rdma-next,4/5] RDMA/NLDEV: helper functions to add provider attributes

Message ID 5974409947a16e6a7ef89d42c003cc125e44acc6.1522341686.git.swise@opengridcomputing.com (mailing list archive)
State Superseded
Headers show

Commit Message

Steve Wise March 29, 2018, 4:09 p.m. UTC
These help rdma providers to fill out the provider entries.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---
 drivers/infiniband/core/nldev.c | 79 +++++++++++++++++++++++++++++++++++++++++
 include/rdma/restrack.h         | 19 ++++++++++
 2 files changed, 98 insertions(+)

Comments

Leon Romanovsky March 30, 2018, 2:45 p.m. UTC | #1
On Thu, Mar 29, 2018 at 09:09:54AM -0700, Steve Wise wrote:
> These help rdma providers to fill out the provider entries.
>
> Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> ---
>  drivers/infiniband/core/nldev.c | 79 +++++++++++++++++++++++++++++++++++++++++
>  include/rdma/restrack.h         | 19 ++++++++++
>  2 files changed, 98 insertions(+)
>
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 902517f..301646b 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -131,6 +131,85 @@ static int provider_fill_port_info(struct sk_buff *msg,
>  		device->res.fill_port_info(msg, cb, device, port) : 0;
>  }
>
> +static int put_provider_name_print_type(struct sk_buff *msg, const char *name,
> +					enum rdma_nldev_print_type print_type)
> +{
> +	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING, name))
> +		return -EMSGSIZE;
> +	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
> +	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE, print_type))
> +		return -EMSGSIZE;
> +
> +	return 0;
> +}
> +
> +int rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,
> +			     enum rdma_nldev_print_type print_type,
> +			     u32 value)
> +{
> +	if (put_provider_name_print_type(msg, name, print_type))
> +		return -EMSGSIZE;
> +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
> +		return -EMSGSIZE;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(rdma_nl_put_provider_u32);

Let's do two functions
1. rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,u32 value)
2. rdma_nl_put_provider_u32_hex(struct sk_buff *msg, const char *name, u32 value)

And save from drivers the need to specify type (and _UNSPEC)

Please implement only functions which you are using, other functions
will be implemented later.

Thanks
Steve Wise March 30, 2018, 2:51 p.m. UTC | #2
> On Thu, Mar 29, 2018 at 09:09:54AM -0700, Steve Wise wrote:
> > These help rdma providers to fill out the provider entries.
> >
> > Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> > ---
> >  drivers/infiniband/core/nldev.c | 79
> +++++++++++++++++++++++++++++++++++++++++
> >  include/rdma/restrack.h         | 19 ++++++++++
> >  2 files changed, 98 insertions(+)
> >
> > diff --git a/drivers/infiniband/core/nldev.c
> b/drivers/infiniband/core/nldev.c
> > index 902517f..301646b 100644
> > --- a/drivers/infiniband/core/nldev.c
> > +++ b/drivers/infiniband/core/nldev.c
> > @@ -131,6 +131,85 @@ static int provider_fill_port_info(struct sk_buff
> *msg,
> >  		device->res.fill_port_info(msg, cb, device, port) : 0;
> >  }
> >
> > +static int put_provider_name_print_type(struct sk_buff *msg, const char
> *name,
> > +					enum rdma_nldev_print_type
> print_type)
> > +{
> > +	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING,
> name))
> > +		return -EMSGSIZE;
> > +	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
> > +	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE,
> print_type))
> > +		return -EMSGSIZE;
> > +
> > +	return 0;
> > +}
> > +
> > +int rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,
> > +			     enum rdma_nldev_print_type print_type,
> > +			     u32 value)
> > +{
> > +	if (put_provider_name_print_type(msg, name, print_type))
> > +		return -EMSGSIZE;
> > +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
> > +		return -EMSGSIZE;
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(rdma_nl_put_provider_u32);
> 
> Let's do two functions
> 1. rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,u32
> value)
> 2. rdma_nl_put_provider_u32_hex(struct sk_buff *msg, const char *name,
> u32 value)
> 
> And save from drivers the need to specify type (and _UNSPEC)
> 
> Please implement only functions which you are using, other functions
> will be implemented later.
> 
> Thanks

The last patch uses u64 as well.  I need u32 and u64. 



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky March 30, 2018, 2:56 p.m. UTC | #3
On Fri, Mar 30, 2018 at 09:51:09AM -0500, Steve Wise wrote:
> > On Thu, Mar 29, 2018 at 09:09:54AM -0700, Steve Wise wrote:
> > > These help rdma providers to fill out the provider entries.
> > >
> > > Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> > > ---
> > >  drivers/infiniband/core/nldev.c | 79
> > +++++++++++++++++++++++++++++++++++++++++
> > >  include/rdma/restrack.h         | 19 ++++++++++
> > >  2 files changed, 98 insertions(+)
> > >
> > > diff --git a/drivers/infiniband/core/nldev.c
> > b/drivers/infiniband/core/nldev.c
> > > index 902517f..301646b 100644
> > > --- a/drivers/infiniband/core/nldev.c
> > > +++ b/drivers/infiniband/core/nldev.c
> > > @@ -131,6 +131,85 @@ static int provider_fill_port_info(struct sk_buff
> > *msg,
> > >  		device->res.fill_port_info(msg, cb, device, port) : 0;
> > >  }
> > >
> > > +static int put_provider_name_print_type(struct sk_buff *msg, const char
> > *name,
> > > +					enum rdma_nldev_print_type
> > print_type)
> > > +{
> > > +	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING,
> > name))
> > > +		return -EMSGSIZE;
> > > +	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
> > > +	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE,
> > print_type))
> > > +		return -EMSGSIZE;
> > > +
> > > +	return 0;
> > > +}
> > > +
> > > +int rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,
> > > +			     enum rdma_nldev_print_type print_type,
> > > +			     u32 value)
> > > +{
> > > +	if (put_provider_name_print_type(msg, name, print_type))
> > > +		return -EMSGSIZE;
> > > +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
> > > +		return -EMSGSIZE;
> > > +
> > > +	return 0;
> > > +}
> > > +EXPORT_SYMBOL(rdma_nl_put_provider_u32);
> >
> > Let's do two functions
> > 1. rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,u32
> > value)
> > 2. rdma_nl_put_provider_u32_hex(struct sk_buff *msg, const char *name,
> > u32 value)
> >
> > And save from drivers the need to specify type (and _UNSPEC)
> >
> > Please implement only functions which you are using, other functions
> > will be implemented later.
> >
> > Thanks
>
> The last patch uses u64 as well.  I need u32 and u64.

I meant that if you don't need u32_hex, so don't implement it :)
>
>
>
Steve Wise March 30, 2018, 2:59 p.m. UTC | #4
> -----Original Message-----
> From: Leon Romanovsky <leon@kernel.org>
> Sent: Friday, March 30, 2018 9:56 AM
> To: Steve Wise <swise@opengridcomputing.com>
> Cc: jgg@mellanox.com; dledford@redhat.com; linux-rdma@vger.kernel.org
> Subject: Re: [PATCH v2 rdma-next 4/5] RDMA/NLDEV: helper functions to
> add provider attributes
> 
> On Fri, Mar 30, 2018 at 09:51:09AM -0500, Steve Wise wrote:
> > > On Thu, Mar 29, 2018 at 09:09:54AM -0700, Steve Wise wrote:
> > > > These help rdma providers to fill out the provider entries.
> > > >
> > > > Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> > > > ---
> > > >  drivers/infiniband/core/nldev.c | 79
> > > +++++++++++++++++++++++++++++++++++++++++
> > > >  include/rdma/restrack.h         | 19 ++++++++++
> > > >  2 files changed, 98 insertions(+)
> > > >
> > > > diff --git a/drivers/infiniband/core/nldev.c
> > > b/drivers/infiniband/core/nldev.c
> > > > index 902517f..301646b 100644
> > > > --- a/drivers/infiniband/core/nldev.c
> > > > +++ b/drivers/infiniband/core/nldev.c
> > > > @@ -131,6 +131,85 @@ static int provider_fill_port_info(struct
> sk_buff
> > > *msg,
> > > >  		device->res.fill_port_info(msg, cb, device, port) :
0;
> > > >  }
> > > >
> > > > +static int put_provider_name_print_type(struct sk_buff *msg, const
> char
> > > *name,
> > > > +					enum rdma_nldev_print_type
> > > print_type)
> > > > +{
> > > > +	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING,
> > > name))
> > > > +		return -EMSGSIZE;
> > > > +	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
> > > > +	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE,
> > > print_type))
> > > > +		return -EMSGSIZE;
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +
> > > > +int rdma_nl_put_provider_u32(struct sk_buff *msg, const char
> *name,
> > > > +			     enum rdma_nldev_print_type print_type,
> > > > +			     u32 value)
> > > > +{
> > > > +	if (put_provider_name_print_type(msg, name, print_type))
> > > > +		return -EMSGSIZE;
> > > > +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
> > > > +		return -EMSGSIZE;
> > > > +
> > > > +	return 0;
> > > > +}
> > > > +EXPORT_SYMBOL(rdma_nl_put_provider_u32);
> > >
> > > Let's do two functions
> > > 1. rdma_nl_put_provider_u32(struct sk_buff *msg, const char
> *name,u32
> > > value)
> > > 2. rdma_nl_put_provider_u32_hex(struct sk_buff *msg, const char
> *name,
> > > u32 value)
> > >
> > > And save from drivers the need to specify type (and _UNSPEC)
> > >
> > > Please implement only functions which you are using, other functions
> > > will be implemented later.
> > >
> > > Thanks
> >
> > The last patch uses u64 as well.  I need u32 and u64.
> 
> I meant that if you don't need u32_hex, so don't implement it :)
> >


Let's nail this down so the next respin will stick:

- remove cb from provider fill API functions
- null out function pointers explicitly
- remove BIN print type
- have u32/u64 unspec and hex helpers, and only the ones I need for patch 4
(I'll add more if I need them in a subsequent series).

Is this list complete?

thanks

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve Wise March 30, 2018, 3:01 p.m. UTC | #5
> > >
> > > The last patch uses u64 as well.  I need u32 and u64.
> >
> > I meant that if you don't need u32_hex, so don't implement it :)
> > >

Oh, and patch 4 uses u32_hex and u64_hex so I will implement them.

> 
> 
> Let's nail this down so the next respin will stick:
> 
> - remove cb from provider fill API functions
> - null out function pointers explicitly
> - remove BIN print type
> - have u32/u64 unspec and hex helpers, and only the ones I need for patch
> 4 (I'll add more if I need them in a subsequent series).
> 
> Is this list complete?
> 
> thanks

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky March 30, 2018, 3:22 p.m. UTC | #6
On Fri, Mar 30, 2018 at 09:59:33AM -0500, Steve Wise wrote:
>
>
> > -----Original Message-----
> > From: Leon Romanovsky <leon@kernel.org>
> > Sent: Friday, March 30, 2018 9:56 AM
> > To: Steve Wise <swise@opengridcomputing.com>
> > Cc: jgg@mellanox.com; dledford@redhat.com; linux-rdma@vger.kernel.org
> > Subject: Re: [PATCH v2 rdma-next 4/5] RDMA/NLDEV: helper functions to
> > add provider attributes
> >
> > On Fri, Mar 30, 2018 at 09:51:09AM -0500, Steve Wise wrote:
> > > > On Thu, Mar 29, 2018 at 09:09:54AM -0700, Steve Wise wrote:
> > > > > These help rdma providers to fill out the provider entries.
> > > > >
> > > > > Signed-off-by: Steve Wise <swise@opengridcomputing.com>
> > > > > ---
> > > > >  drivers/infiniband/core/nldev.c | 79
> > > > +++++++++++++++++++++++++++++++++++++++++
> > > > >  include/rdma/restrack.h         | 19 ++++++++++
> > > > >  2 files changed, 98 insertions(+)
> > > > >
> > > > > diff --git a/drivers/infiniband/core/nldev.c
> > > > b/drivers/infiniband/core/nldev.c
> > > > > index 902517f..301646b 100644
> > > > > --- a/drivers/infiniband/core/nldev.c
> > > > > +++ b/drivers/infiniband/core/nldev.c
> > > > > @@ -131,6 +131,85 @@ static int provider_fill_port_info(struct
> > sk_buff
> > > > *msg,
> > > > >  		device->res.fill_port_info(msg, cb, device, port) :
> 0;
> > > > >  }
> > > > >
> > > > > +static int put_provider_name_print_type(struct sk_buff *msg, const
> > char
> > > > *name,
> > > > > +					enum rdma_nldev_print_type
> > > > print_type)
> > > > > +{
> > > > > +	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING,
> > > > name))
> > > > > +		return -EMSGSIZE;
> > > > > +	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
> > > > > +	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE,
> > > > print_type))
> > > > > +		return -EMSGSIZE;
> > > > > +
> > > > > +	return 0;
> > > > > +}
> > > > > +
> > > > > +int rdma_nl_put_provider_u32(struct sk_buff *msg, const char
> > *name,
> > > > > +			     enum rdma_nldev_print_type print_type,
> > > > > +			     u32 value)
> > > > > +{
> > > > > +	if (put_provider_name_print_type(msg, name, print_type))
> > > > > +		return -EMSGSIZE;
> > > > > +	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
> > > > > +		return -EMSGSIZE;
> > > > > +
> > > > > +	return 0;
> > > > > +}
> > > > > +EXPORT_SYMBOL(rdma_nl_put_provider_u32);
> > > >
> > > > Let's do two functions
> > > > 1. rdma_nl_put_provider_u32(struct sk_buff *msg, const char
> > *name,u32
> > > > value)
> > > > 2. rdma_nl_put_provider_u32_hex(struct sk_buff *msg, const char
> > *name,
> > > > u32 value)
> > > >
> > > > And save from drivers the need to specify type (and _UNSPEC)
> > > >
> > > > Please implement only functions which you are using, other functions
> > > > will be implemented later.
> > > >
> > > > Thanks
> > >
> > > The last patch uses u64 as well.  I need u32 and u64.
> >
> > I meant that if you don't need u32_hex, so don't implement it :)
> > >
>
>
> Let's nail this down so the next respin will stick:
>
> - remove cb from provider fill API functions
> - null out function pointers explicitly
> - remove BIN print type
> - have u32/u64 unspec and hex helpers, and only the ones I need for patch 4
> (I'll add more if I need them in a subsequent series).
>
> Is this list complete?

Yes

>
> thanks
>
diff mbox

Patch

diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 902517f..301646b 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -131,6 +131,85 @@  static int provider_fill_port_info(struct sk_buff *msg,
 		device->res.fill_port_info(msg, cb, device, port) : 0;
 }
 
+static int put_provider_name_print_type(struct sk_buff *msg, const char *name,
+					enum rdma_nldev_print_type print_type)
+{
+	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING, name))
+		return -EMSGSIZE;
+	if (print_type != RDMA_NLDEV_PRINT_TYPE_UNSPEC &&
+	    nla_put_u8(msg, RDMA_NLDEV_ATTR_PROVIDER_PRINT_TYPE, print_type))
+		return -EMSGSIZE;
+
+	return 0;
+}
+
+int rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     u32 value)
+{
+	if (put_provider_name_print_type(msg, name, print_type))
+		return -EMSGSIZE;
+	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PROVIDER_U32, value))
+		return -EMSGSIZE;
+
+	return 0;
+}
+EXPORT_SYMBOL(rdma_nl_put_provider_u32);
+
+int rdma_nl_put_provider_s32(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     s32 value)
+{
+	if (put_provider_name_print_type(msg, name, print_type))
+		return -EMSGSIZE;
+	if (nla_put_s32(msg, RDMA_NLDEV_ATTR_PROVIDER_S32, value))
+		return -EMSGSIZE;
+
+	return 0;
+}
+EXPORT_SYMBOL(rdma_nl_put_provider_s32);
+
+int rdma_nl_put_provider_u64(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     u64 value)
+{
+	if (put_provider_name_print_type(msg, name, print_type))
+		return -EMSGSIZE;
+	if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_PROVIDER_U64, value,
+			      RDMA_NLDEV_ATTR_PAD))
+		return -EMSGSIZE;
+
+	return 0;
+}
+EXPORT_SYMBOL(rdma_nl_put_provider_u64);
+
+int rdma_nl_put_provider_s64(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     s64 value)
+{
+	if (put_provider_name_print_type(msg, name, print_type))
+		return -EMSGSIZE;
+	if (nla_put_s64(msg, RDMA_NLDEV_ATTR_PROVIDER_S64, value,
+			RDMA_NLDEV_ATTR_PAD))
+		return -EMSGSIZE;
+
+	return 0;
+}
+EXPORT_SYMBOL(rdma_nl_put_provider_s64);
+
+int rdma_nl_put_provider_string(struct sk_buff *msg, const char *name,
+				const char *value)
+{
+	if (put_provider_name_print_type(msg, name,
+					 RDMA_NLDEV_PRINT_TYPE_UNSPEC))
+		return -EMSGSIZE;
+	if (nla_put_string(msg, RDMA_NLDEV_ATTR_PROVIDER_STRING, value))
+		return -EMSGSIZE;
+
+	return 0;
+}
+EXPORT_SYMBOL(rdma_nl_put_provider_string);
+
 static int fill_nldev_handle(struct sk_buff *msg, struct ib_device *device)
 {
 	if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index))
diff --git a/include/rdma/restrack.h b/include/rdma/restrack.h
index 936b56f..094a209 100644
--- a/include/rdma/restrack.h
+++ b/include/rdma/restrack.h
@@ -12,6 +12,7 @@ 
 #include <linux/kref.h>
 #include <linux/completion.h>
 #include <linux/sched/task.h>
+#include <uapi/rdma/rdma_netlink.h>
 
 /**
  * enum rdma_restrack_type - HW objects to track
@@ -199,4 +200,22 @@  static inline void rdma_restrack_set_task(struct rdma_restrack_entry *res,
 	res->task = task;
 }
 
+/*
+ * Helper functions for rdma providers when filling out
+ * nldev provider attributes.
+ */
+int rdma_nl_put_provider_u32(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     u32 value);
+int rdma_nl_put_provider_s32(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     s32 value);
+int rdma_nl_put_provider_u64(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     u64 value);
+int rdma_nl_put_provider_s64(struct sk_buff *msg, const char *name,
+			     enum rdma_nldev_print_type print_type,
+			     s64 value);
+int rdma_nl_put_provider_string(struct sk_buff *msg, const char *name,
+				const char *value);
 #endif /* _RDMA_RESTRACK_H_ */