Message ID | 20190605183252.6687-2-jgg@ziepe.ca (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Doug Ledford |
Headers | show |
Series | Add RDMA_NLDEV_GET_CHARDEV | expand |
On Wed, Jun 05, 2019 at 03:32:50PM -0300, Jason Gunthorpe wrote: > From: Jason Gunthorpe <jgg@mellanox.com> > > This enum is exposed over the sysfs file 'node_type' and over netlink via > RDMA_NLDEV_ATTR_DEV_NODE_TYPE, so declare it in the uapi headers. > > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> > --- > drivers/infiniband/core/verbs.c | 2 +- > include/rdma/ib_verbs.h | 13 +------------ > include/uapi/rdma/rdma_netlink.h | 12 ++++++++++++ > 3 files changed, 14 insertions(+), 13 deletions(-) > > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c > index e666a1f7608d86..56af18456ba776 100644 > --- a/drivers/infiniband/core/verbs.c > +++ b/drivers/infiniband/core/verbs.c > @@ -209,7 +209,7 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate) > EXPORT_SYMBOL(ib_rate_to_mbps); > > __attribute_const__ enum rdma_transport_type > -rdma_node_get_transport(enum rdma_node_type node_type) > +rdma_node_get_transport(unsigned int node_type) > { > > if (node_type == RDMA_NODE_USNIC) > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > index cdfeeda1db7f31..d5dd3cb7fcf702 100644 > --- a/include/rdma/ib_verbs.h > +++ b/include/rdma/ib_verbs.h > @@ -132,17 +132,6 @@ struct ib_gid_attr { > u8 port_num; > }; > > -enum rdma_node_type { Why did you drop "enum rdma_node_type" and changed to be anonymous enum? > - /* IB values map to NodeInfo:NodeType. */ > - RDMA_NODE_IB_CA = 1, > - RDMA_NODE_IB_SWITCH, > - RDMA_NODE_IB_ROUTER, > - RDMA_NODE_RNIC, > - RDMA_NODE_USNIC, > - RDMA_NODE_USNIC_UDP, > - RDMA_NODE_UNSPECIFIED, > -}; > - > enum { > /* set the local administered indication */ > IB_SA_WELL_KNOWN_GUID = BIT_ULL(57) | 2, > @@ -164,7 +153,7 @@ enum rdma_protocol_type { > }; > > __attribute_const__ enum rdma_transport_type > -rdma_node_get_transport(enum rdma_node_type node_type); > +rdma_node_get_transport(unsigned int node_type); > > enum rdma_network_type { > RDMA_NETWORK_IB, > diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h > index 41db51367efafb..f588e8551c6cea 100644 > --- a/include/uapi/rdma/rdma_netlink.h > +++ b/include/uapi/rdma/rdma_netlink.h > @@ -147,6 +147,18 @@ enum { > IWPM_NLA_HELLO_MAX > }; > > +/* For RDMA_NLDEV_ATTR_DEV_NODE_TYPE */ > +enum { > + /* IB values map to NodeInfo:NodeType. */ > + RDMA_NODE_IB_CA = 1, > + RDMA_NODE_IB_SWITCH, > + RDMA_NODE_IB_ROUTER, > + RDMA_NODE_RNIC, > + RDMA_NODE_USNIC, > + RDMA_NODE_USNIC_UDP, > + RDMA_NODE_UNSPECIFIED, > +}; > + > /* > * Local service operations: > * RESOLVE - The client requests the local service to resolve a path. > -- > 2.21.0 >
On Mon, Jun 10, 2019 at 05:13:34PM +0300, Leon Romanovsky wrote: > On Wed, Jun 05, 2019 at 03:32:50PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe <jgg@mellanox.com> > > > > This enum is exposed over the sysfs file 'node_type' and over netlink via > > RDMA_NLDEV_ATTR_DEV_NODE_TYPE, so declare it in the uapi headers. > > > > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> > > drivers/infiniband/core/verbs.c | 2 +- > > include/rdma/ib_verbs.h | 13 +------------ > > include/uapi/rdma/rdma_netlink.h | 12 ++++++++++++ > > 3 files changed, 14 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c > > index e666a1f7608d86..56af18456ba776 100644 > > +++ b/drivers/infiniband/core/verbs.c > > @@ -209,7 +209,7 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate) > > EXPORT_SYMBOL(ib_rate_to_mbps); > > > > __attribute_const__ enum rdma_transport_type > > -rdma_node_get_transport(enum rdma_node_type node_type) > > +rdma_node_get_transport(unsigned int node_type) > > { > > > > if (node_type == RDMA_NODE_USNIC) > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > > index cdfeeda1db7f31..d5dd3cb7fcf702 100644 > > +++ b/include/rdma/ib_verbs.h > > @@ -132,17 +132,6 @@ struct ib_gid_attr { > > u8 port_num; > > }; > > > > -enum rdma_node_type { > > Why did you drop "enum rdma_node_type" and changed to be anonymous enum? To avoid namespace pollution in a user header Jason
On Mon, Jun 10, 2019 at 02:45:40PM +0000, Jason Gunthorpe wrote: > On Mon, Jun 10, 2019 at 05:13:34PM +0300, Leon Romanovsky wrote: > > On Wed, Jun 05, 2019 at 03:32:50PM -0300, Jason Gunthorpe wrote: > > > From: Jason Gunthorpe <jgg@mellanox.com> > > > > > > This enum is exposed over the sysfs file 'node_type' and over netlink via > > > RDMA_NLDEV_ATTR_DEV_NODE_TYPE, so declare it in the uapi headers. > > > > > > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> > > > drivers/infiniband/core/verbs.c | 2 +- > > > include/rdma/ib_verbs.h | 13 +------------ > > > include/uapi/rdma/rdma_netlink.h | 12 ++++++++++++ > > > 3 files changed, 14 insertions(+), 13 deletions(-) > > > > > > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c > > > index e666a1f7608d86..56af18456ba776 100644 > > > +++ b/drivers/infiniband/core/verbs.c > > > @@ -209,7 +209,7 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate) > > > EXPORT_SYMBOL(ib_rate_to_mbps); > > > > > > __attribute_const__ enum rdma_transport_type > > > -rdma_node_get_transport(enum rdma_node_type node_type) > > > +rdma_node_get_transport(unsigned int node_type) > > > { > > > > > > if (node_type == RDMA_NODE_USNIC) > > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > > > index cdfeeda1db7f31..d5dd3cb7fcf702 100644 > > > +++ b/include/rdma/ib_verbs.h > > > @@ -132,17 +132,6 @@ struct ib_gid_attr { > > > u8 port_num; > > > }; > > > > > > -enum rdma_node_type { > > > > Why did you drop "enum rdma_node_type" and changed to be anonymous enum? > > To avoid namespace pollution in a user header IMHO, better to have type safety. > > Jason
On Mon, Jun 10, 2019 at 06:05:44PM +0300, Leon Romanovsky wrote: > On Mon, Jun 10, 2019 at 02:45:40PM +0000, Jason Gunthorpe wrote: > > On Mon, Jun 10, 2019 at 05:13:34PM +0300, Leon Romanovsky wrote: > > > On Wed, Jun 05, 2019 at 03:32:50PM -0300, Jason Gunthorpe wrote: > > > > From: Jason Gunthorpe <jgg@mellanox.com> > > > > > > > > This enum is exposed over the sysfs file 'node_type' and over netlink via > > > > RDMA_NLDEV_ATTR_DEV_NODE_TYPE, so declare it in the uapi headers. > > > > > > > > Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> > > > > drivers/infiniband/core/verbs.c | 2 +- > > > > include/rdma/ib_verbs.h | 13 +------------ > > > > include/uapi/rdma/rdma_netlink.h | 12 ++++++++++++ > > > > 3 files changed, 14 insertions(+), 13 deletions(-) > > > > > > > > diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c > > > > index e666a1f7608d86..56af18456ba776 100644 > > > > +++ b/drivers/infiniband/core/verbs.c > > > > @@ -209,7 +209,7 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate) > > > > EXPORT_SYMBOL(ib_rate_to_mbps); > > > > > > > > __attribute_const__ enum rdma_transport_type > > > > -rdma_node_get_transport(enum rdma_node_type node_type) > > > > +rdma_node_get_transport(unsigned int node_type) > > > > { > > > > > > > > if (node_type == RDMA_NODE_USNIC) > > > > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h > > > > index cdfeeda1db7f31..d5dd3cb7fcf702 100644 > > > > +++ b/include/rdma/ib_verbs.h > > > > @@ -132,17 +132,6 @@ struct ib_gid_attr { > > > > u8 port_num; > > > > }; > > > > > > > > -enum rdma_node_type { > > > > > > Why did you drop "enum rdma_node_type" and changed to be anonymous enum? > > > > To avoid namespace pollution in a user header > > IMHO, better to have type safety. The enum type cannot be safely used in userspace, it is better to have anonymous enums in uapi headers to avoid mistakes. The type safety from enums is very minimal. Jason
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index e666a1f7608d86..56af18456ba776 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -209,7 +209,7 @@ __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate) EXPORT_SYMBOL(ib_rate_to_mbps); __attribute_const__ enum rdma_transport_type -rdma_node_get_transport(enum rdma_node_type node_type) +rdma_node_get_transport(unsigned int node_type) { if (node_type == RDMA_NODE_USNIC) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index cdfeeda1db7f31..d5dd3cb7fcf702 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -132,17 +132,6 @@ struct ib_gid_attr { u8 port_num; }; -enum rdma_node_type { - /* IB values map to NodeInfo:NodeType. */ - RDMA_NODE_IB_CA = 1, - RDMA_NODE_IB_SWITCH, - RDMA_NODE_IB_ROUTER, - RDMA_NODE_RNIC, - RDMA_NODE_USNIC, - RDMA_NODE_USNIC_UDP, - RDMA_NODE_UNSPECIFIED, -}; - enum { /* set the local administered indication */ IB_SA_WELL_KNOWN_GUID = BIT_ULL(57) | 2, @@ -164,7 +153,7 @@ enum rdma_protocol_type { }; __attribute_const__ enum rdma_transport_type -rdma_node_get_transport(enum rdma_node_type node_type); +rdma_node_get_transport(unsigned int node_type); enum rdma_network_type { RDMA_NETWORK_IB, diff --git a/include/uapi/rdma/rdma_netlink.h b/include/uapi/rdma/rdma_netlink.h index 41db51367efafb..f588e8551c6cea 100644 --- a/include/uapi/rdma/rdma_netlink.h +++ b/include/uapi/rdma/rdma_netlink.h @@ -147,6 +147,18 @@ enum { IWPM_NLA_HELLO_MAX }; +/* For RDMA_NLDEV_ATTR_DEV_NODE_TYPE */ +enum { + /* IB values map to NodeInfo:NodeType. */ + RDMA_NODE_IB_CA = 1, + RDMA_NODE_IB_SWITCH, + RDMA_NODE_IB_ROUTER, + RDMA_NODE_RNIC, + RDMA_NODE_USNIC, + RDMA_NODE_USNIC_UDP, + RDMA_NODE_UNSPECIFIED, +}; + /* * Local service operations: * RESOLVE - The client requests the local service to resolve a path.