* [RFC] IB/mlx4: Add sysfs entry for VF node_guid
@ 2016-07-21 9:32 Yuval Shaia
[not found] ` <1469093572-6793-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Yuval Shaia @ 2016-07-21 9:32 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
dledford-H+wXaHxf7aLQT0dZR+AlfA,
sean.hefty-ral2JQCrhuEAvxtiuMwx3w,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w
Adding sysfs entries to read/write VF's Node GUID.
This abbility will enable sys-admin to configure node GUID for VFs the same
way it is done for VF's port GUIDs.
Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
drivers/infiniband/hw/mlx4/sysfs.c | 72 ++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c
index 69fb5ba..6fc4366 100644
--- a/drivers/infiniband/hw/mlx4/sysfs.c
+++ b/drivers/infiniband/hw/mlx4/sysfs.c
@@ -371,6 +371,7 @@ struct mlx4_port {
struct attribute_group gid_group;
struct device_attribute enable_smi_admin;
struct device_attribute smi_enabled;
+ struct device_attribute node_guid;
int slave;
u8 port_num;
};
@@ -620,6 +621,7 @@ static int add_vf_smi_entries(struct mlx4_port *p)
sysfs_remove_file(&p->kobj, &p->smi_enabled.attr);
return ret;
}
+
return 0;
}
@@ -635,6 +637,69 @@ static void remove_vf_smi_entries(struct mlx4_port *p)
sysfs_remove_file(&p->kobj, &p->enable_smi_admin.attr);
}
+static ssize_t sysfs_show_node_guid(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct mlx4_port *p = container_of(attr, struct mlx4_port, node_guid);
+ ssize_t len = 0;
+ __be64 guid = mlx4_get_slave_node_guid(p->dev->dev, p->slave);
+
+ len = sprintf(buf, "slave %d 0x%llx\n", p->slave, be64_to_cpu(guid));
+
+ return len;
+}
+
+static ssize_t sysfs_store_node_guid(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct mlx4_port *p = container_of(attr, struct mlx4_port, node_guid);
+ __be64 guid;
+
+ if (sscanf(buf, "0x%llx", &guid) != 1)
+ return -EINVAL;
+
+ mlx4_put_slave_node_guid(p->dev->dev, p->slave, cpu_to_be64(guid));
+
+ return count;
+}
+
+static int add_vf_admin_guid_entry(struct mlx4_port *p)
+{
+ int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
+ IB_LINK_LAYER_ETHERNET;
+ int ret;
+
+ /* do not display entries if eth transport, or if master */
+ if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
+ return 0;
+
+ sysfs_attr_init(&p->node_guid.attr);
+ p->node_guid.show = sysfs_show_node_guid;
+ p->node_guid.store = sysfs_store_node_guid;
+ p->node_guid.attr.name = "node_guid";
+ p->node_guid.attr.mode = 0644;
+ ret = sysfs_create_file(&p->kobj, &p->node_guid.attr);
+ if (ret) {
+ pr_err("failed to create sysfs entry for node_guid\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static void remove_vf_node_guid_entry(struct mlx4_port *p)
+{
+ int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) ==
+ IB_LINK_LAYER_ETHERNET;
+
+ if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev))
+ return;
+
+ sysfs_remove_file(&p->kobj, &p->node_guid.attr);
+}
+
static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
{
struct mlx4_port *p;
@@ -686,6 +751,10 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave)
if (ret)
goto err_free_gid;
+ ret = add_vf_admin_guid_entry(p);
+ if (ret)
+ goto err_free_gid;
+
list_add_tail(&p->kobj.entry, &dev->pkeys.pkey_port_list[slave]);
return 0;
@@ -743,6 +812,7 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave)
if (err)
goto err_add;
}
+
return 0;
err_add:
@@ -754,6 +824,7 @@ err_add:
sysfs_remove_group(p, &mport->pkey_group);
sysfs_remove_group(p, &mport->gid_group);
remove_vf_smi_entries(mport);
+ remove_vf_node_guid_entry(mport);
kobject_put(p);
}
kobject_put(dev->dev_ports_parent[slave]);
@@ -799,6 +870,7 @@ static void unregister_pkey_tree(struct mlx4_ib_dev *device)
sysfs_remove_group(p, &port->pkey_group);
sysfs_remove_group(p, &port->gid_group);
remove_vf_smi_entries(port);
+ remove_vf_node_guid_entry(port);
kobject_put(p);
kobject_put(device->dev_ports_parent[slave]);
}
--
1.7.1
--
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] 5+ messages in thread[parent not found: <1469093572-6793-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [RFC] IB/mlx4: Add sysfs entry for VF node_guid [not found] ` <1469093572-6793-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2016-07-21 15:12 ` Santosh Shilimkar [not found] ` <7129f7b7-1e33-c170-7ab7-56ab5e22ff48-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Santosh Shilimkar @ 2016-07-21 15:12 UTC (permalink / raw) To: Yuval Shaia, linux-rdma-u79uwXL29TY76Z2rM5mHXA, dledford-H+wXaHxf7aLQT0dZR+AlfA, sean.hefty-ral2JQCrhuEAvxtiuMwx3w, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w On 7/21/2016 2:32 AM, Yuval Shaia wrote: > Adding sysfs entries to read/write VF's Node GUID. > This abbility will enable sys-admin to configure node GUID for VFs the same > way it is done for VF's port GUIDs. > > Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> > --- This is inline with port GUID for paravirtualized HCAs and seems reasonable to me. > drivers/infiniband/hw/mlx4/sysfs.c | 72 ++++++++++++++++++++++++++++++++++++ > 1 files changed, 72 insertions(+), 0 deletions(-) > > diff --git a/drivers/infiniband/hw/mlx4/sysfs.c b/drivers/infiniband/hw/mlx4/sysfs.c > index 69fb5ba..6fc4366 100644 > --- a/drivers/infiniband/hw/mlx4/sysfs.c > +++ b/drivers/infiniband/hw/mlx4/sysfs.c > @@ -371,6 +371,7 @@ struct mlx4_port { > struct attribute_group gid_group; > struct device_attribute enable_smi_admin; > struct device_attribute smi_enabled; > + struct device_attribute node_guid; > int slave; > u8 port_num; > }; > @@ -620,6 +621,7 @@ static int add_vf_smi_entries(struct mlx4_port *p) > sysfs_remove_file(&p->kobj, &p->smi_enabled.attr); > return ret; > } > + Stray change. > return 0; > } > > @@ -635,6 +637,69 @@ static void remove_vf_smi_entries(struct mlx4_port *p) > sysfs_remove_file(&p->kobj, &p->enable_smi_admin.attr); > } > > +static ssize_t sysfs_show_node_guid(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct mlx4_port *p = container_of(attr, struct mlx4_port, node_guid); > + ssize_t len = 0; > + __be64 guid = mlx4_get_slave_node_guid(p->dev->dev, p->slave); > + > + len = sprintf(buf, "slave %d 0x%llx\n", p->slave, be64_to_cpu(guid)); > + > + return len; > +} > + > +static ssize_t sysfs_store_node_guid(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct mlx4_port *p = container_of(attr, struct mlx4_port, node_guid); > + __be64 guid; > + Shouldn't we check only master can set this up ? > + if (sscanf(buf, "0x%llx", &guid) != 1) > + return -EINVAL; > + > + mlx4_put_slave_node_guid(p->dev->dev, p->slave, cpu_to_be64(guid)); > + > + return count; > +} > + > +static int add_vf_admin_guid_entry(struct mlx4_port *p) > +{ > + int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) == > + IB_LINK_LAYER_ETHERNET; > + int ret; > + > + /* do not display entries if eth transport, or if master */ > + if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev)) > + return 0; > + > + sysfs_attr_init(&p->node_guid.attr); > + p->node_guid.show = sysfs_show_node_guid; > + p->node_guid.store = sysfs_store_node_guid; > + p->node_guid.attr.name = "node_guid"; > + p->node_guid.attr.mode = 0644; > + ret = sysfs_create_file(&p->kobj, &p->node_guid.attr); > + if (ret) { > + pr_err("failed to create sysfs entry for node_guid\n"); Use existing driver macro or append print with "mlx4_core:" > + return ret; > + } > + > + return 0; > +} > + > +static void remove_vf_node_guid_entry(struct mlx4_port *p) > +{ > + int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, p->port_num) == > + IB_LINK_LAYER_ETHERNET; > + > + if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev)) > + return; > + > + sysfs_remove_file(&p->kobj, &p->node_guid.attr); > +} > + > static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave) > { > struct mlx4_port *p; > @@ -686,6 +751,10 @@ static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave) > if (ret) > goto err_free_gid; > > + ret = add_vf_admin_guid_entry(p); > + if (ret) > + goto err_free_gid; > + > list_add_tail(&p->kobj.entry, &dev->pkeys.pkey_port_list[slave]); > return 0; > > @@ -743,6 +812,7 @@ static int register_one_pkey_tree(struct mlx4_ib_dev *dev, int slave) > if (err) > goto err_add; > } > + Stray change. Regards, Santosh -- 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] 5+ messages in thread
[parent not found: <7129f7b7-1e33-c170-7ab7-56ab5e22ff48-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>]
* Re: [RFC] IB/mlx4: Add sysfs entry for VF node_guid [not found] ` <7129f7b7-1e33-c170-7ab7-56ab5e22ff48-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> @ 2016-07-21 15:53 ` Majd Dibbiny [not found] ` <02d9149b-cddc-bc44-6284-67c249c97f69-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Majd Dibbiny @ 2016-07-21 15:53 UTC (permalink / raw) To: Santosh Shilimkar, Yuval Shaia, linux-rdma-u79uwXL29TY76Z2rM5mHXA, dledford-H+wXaHxf7aLQT0dZR+AlfA, sean.hefty-ral2JQCrhuEAvxtiuMwx3w, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w On 7/21/2016 6:12 PM, Santosh Shilimkar wrote: > On 7/21/2016 2:32 AM, Yuval Shaia wrote: >> Adding sysfs entries to read/write VF's Node GUID. >> This abbility will enable sys-admin to configure node GUID for VFs the typo >> same >> way it is done for VF's port GUIDs. >> Hi Yuval, The following commit in iproute2 by Eli Cohen added a standard way to configure node/port GUID using IPoIB netdev: d91fb3f4c7e4 Add support for configuring Infiniband GUIDs The configuration will be done in the following way: ip link set dev ib0 vf 0 node_guid 00:02:c9:03:00:21:6e:70 ip link set dev ib0 vf 0 port_guid 00:02:c9:03:00:21:6e:78 Can't this be used here as well? Thanks >> Signed-off-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> >> --- > This is inline with port GUID for paravirtualized HCAs and seems > reasonable to me. > >> drivers/infiniband/hw/mlx4/sysfs.c | 72 >> ++++++++++++++++++++++++++++++++++++ >> 1 files changed, 72 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/infiniband/hw/mlx4/sysfs.c >> b/drivers/infiniband/hw/mlx4/sysfs.c >> index 69fb5ba..6fc4366 100644 >> --- a/drivers/infiniband/hw/mlx4/sysfs.c >> +++ b/drivers/infiniband/hw/mlx4/sysfs.c >> @@ -371,6 +371,7 @@ struct mlx4_port { >> struct attribute_group gid_group; >> struct device_attribute enable_smi_admin; >> struct device_attribute smi_enabled; >> + struct device_attribute node_guid; >> int slave; >> u8 port_num; >> }; >> @@ -620,6 +621,7 @@ static int add_vf_smi_entries(struct mlx4_port *p) >> sysfs_remove_file(&p->kobj, &p->smi_enabled.attr); >> return ret; >> } >> + > Stray change. > >> return 0; >> } >> >> @@ -635,6 +637,69 @@ static void remove_vf_smi_entries(struct >> mlx4_port *p) >> sysfs_remove_file(&p->kobj, &p->enable_smi_admin.attr); >> } >> >> +static ssize_t sysfs_show_node_guid(struct device *dev, >> + struct device_attribute *attr, >> + char *buf) >> +{ >> + struct mlx4_port *p = container_of(attr, struct mlx4_port, >> node_guid); >> + ssize_t len = 0; >> + __be64 guid = mlx4_get_slave_node_guid(p->dev->dev, p->slave); >> + >> + len = sprintf(buf, "slave %d 0x%llx\n", p->slave, >> be64_to_cpu(guid)); >> + >> + return len; >> +} >> + >> +static ssize_t sysfs_store_node_guid(struct device *dev, >> + struct device_attribute *attr, >> + const char *buf, size_t count) >> +{ >> + struct mlx4_port *p = container_of(attr, struct mlx4_port, >> node_guid); >> + __be64 guid; >> + > Shouldn't we check only master can set this up ? > >> + if (sscanf(buf, "0x%llx", &guid) != 1) >> + return -EINVAL; >> + >> + mlx4_put_slave_node_guid(p->dev->dev, p->slave, cpu_to_be64(guid)); >> + >> + return count; >> +} >> + >> +static int add_vf_admin_guid_entry(struct mlx4_port *p) >> +{ >> + int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, >> p->port_num) == >> + IB_LINK_LAYER_ETHERNET; >> + int ret; >> + >> + /* do not display entries if eth transport, or if master */ >> + if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev)) >> + return 0; >> + >> + sysfs_attr_init(&p->node_guid.attr); >> + p->node_guid.show = sysfs_show_node_guid; >> + p->node_guid.store = sysfs_store_node_guid; >> + p->node_guid.attr.name = "node_guid"; >> + p->node_guid.attr.mode = 0644; >> + ret = sysfs_create_file(&p->kobj, &p->node_guid.attr); >> + if (ret) { >> + pr_err("failed to create sysfs entry for node_guid\n"); > Use existing driver macro or append print with "mlx4_core:" >> + return ret; >> + } >> + >> + return 0; >> +} >> + >> +static void remove_vf_node_guid_entry(struct mlx4_port *p) >> +{ >> + int is_eth = rdma_port_get_link_layer(&p->dev->ib_dev, >> p->port_num) == >> + IB_LINK_LAYER_ETHERNET; >> + >> + if (is_eth || p->slave == mlx4_master_func_num(p->dev->dev)) >> + return; >> + >> + sysfs_remove_file(&p->kobj, &p->node_guid.attr); >> +} >> + >> static int add_port(struct mlx4_ib_dev *dev, int port_num, int slave) >> { >> struct mlx4_port *p; >> @@ -686,6 +751,10 @@ static int add_port(struct mlx4_ib_dev *dev, int >> port_num, int slave) >> if (ret) >> goto err_free_gid; >> >> + ret = add_vf_admin_guid_entry(p); >> + if (ret) >> + goto err_free_gid; >> + >> list_add_tail(&p->kobj.entry, &dev->pkeys.pkey_port_list[slave]); >> return 0; >> >> @@ -743,6 +812,7 @@ static int register_one_pkey_tree(struct >> mlx4_ib_dev *dev, int slave) >> if (err) >> goto err_add; >> } >> + > Stray change. > > Regards, > Santosh > -- > 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 -- 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] 5+ messages in thread
[parent not found: <02d9149b-cddc-bc44-6284-67c249c97f69-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>]
* Re: [RFC] IB/mlx4: Add sysfs entry for VF node_guid [not found] ` <02d9149b-cddc-bc44-6284-67c249c97f69-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> @ 2016-07-21 17:37 ` Santosh Shilimkar 2016-07-21 22:58 ` Or Gerlitz 1 sibling, 0 replies; 5+ messages in thread From: Santosh Shilimkar @ 2016-07-21 17:37 UTC (permalink / raw) To: Majd Dibbiny, Yuval Shaia, linux-rdma-u79uwXL29TY76Z2rM5mHXA, dledford-H+wXaHxf7aLQT0dZR+AlfA, sean.hefty-ral2JQCrhuEAvxtiuMwx3w, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w On 7/21/2016 8:53 AM, Majd Dibbiny wrote: > On 7/21/2016 6:12 PM, Santosh Shilimkar wrote: >> On 7/21/2016 2:32 AM, Yuval Shaia wrote: >>> Adding sysfs entries to read/write VF's Node GUID. >>> This abbility will enable sys-admin to configure node GUID for VFs the > typo >>> same >>> way it is done for VF's port GUIDs. >>> > > Hi Yuval, > > The following commit in iproute2 by Eli Cohen added a standard way to > configure node/port GUID using IPoIB netdev: > > d91fb3f4c7e4 Add support for configuring Infiniband GUIDs > > The configuration will be done in the following way: > ip link set dev ib0 vf 0 node_guid 00:02:c9:03:00:21:6e:70 > ip link set dev ib0 vf 0 port_guid 00:02:c9:03:00:21:6e:78 > > Can't this be used here as well? > This could work as well. Does this has any dependency with 'iproute' version ? In other words does this kernel patch needs any iproute patch ? -- 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] 5+ messages in thread
* Re: [RFC] IB/mlx4: Add sysfs entry for VF node_guid [not found] ` <02d9149b-cddc-bc44-6284-67c249c97f69-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> 2016-07-21 17:37 ` Santosh Shilimkar @ 2016-07-21 22:58 ` Or Gerlitz 1 sibling, 0 replies; 5+ messages in thread From: Or Gerlitz @ 2016-07-21 22:58 UTC (permalink / raw) To: Majd Dibbiny, Doug Ledford Cc: Santosh Shilimkar, Yuval Shaia, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Jul 21, 2016 at 6:53 PM, Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote: > On 7/21/2016 6:12 PM, Santosh Shilimkar wrote: >> On 7/21/2016 2:32 AM, Yuval Shaia wrote: >>> Adding sysfs entries to read/write VF's Node GUID. >>> This ability will enable sys-admin to configure node GUID for VFs the > Hi Yuval, > The following commit in iproute2 by Eli Cohen added a standard way to > configure node/port GUID using IPoIB netdev: > > d91fb3f4c7e4 Add support for configuring Infiniband GUIDs > > The configuration will be done in the following way: > ip link set dev ib0 vf 0 node_guid 00:02:c9:03:00:21:6e:70 > ip link set dev ib0 vf 0 port_guid 00:02:c9:03:00:21:6e:78 > > Can't this be used here as well? correct, NAK for adding more proprietary sysfs entries here, use the standard rtnl way as in mlx5 Or. -- 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] 5+ messages in thread
end of thread, other threads:[~2016-07-21 22:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-21 9:32 [RFC] IB/mlx4: Add sysfs entry for VF node_guid Yuval Shaia
[not found] ` <1469093572-6793-1-git-send-email-yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-07-21 15:12 ` Santosh Shilimkar
[not found] ` <7129f7b7-1e33-c170-7ab7-56ab5e22ff48-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-07-21 15:53 ` Majd Dibbiny
[not found] ` <02d9149b-cddc-bc44-6284-67c249c97f69-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2016-07-21 17:37 ` Santosh Shilimkar
2016-07-21 22:58 ` Or Gerlitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox