35 #include <linux/slab.h>
36 #include <linux/string.h>
37 #include <linux/stat.h>
50 int guid_index_in_rec;
56 record_num = mlx4_ib_iov_dentry->
entry_num / 8 ;
57 guid_index_in_rec = mlx4_ib_iov_dentry->
entry_num % 8 ;
61 ports_guid[port->
num - 1].
62 all_rec_per_port[record_num].
63 all_recs[8 * guid_index_in_rec]));
74 const char *buf,
size_t count)
77 int guid_index_in_rec;
84 record_num = mlx4_ib_iov_dentry->
entry_num / 8;
85 guid_index_in_rec = mlx4_ib_iov_dentry->
entry_num % 8;
86 if (0 == record_num && 0 == guid_index_in_rec) {
87 pr_err(
"GUID 0 block 0 is RO\n");
90 sscanf(buf,
"%llx", &sysadmin_ag_val);
92 all_rec_per_port[record_num].
103 switch (sysadmin_ag_val) {
107 mdev->
sriov.alias_guid.ports_guid[port->
num - 1].all_rec_per_port[
record_num].ownership
112 mdev->
sriov.alias_guid.ports_guid[port->
num - 1].all_rec_per_port[
record_num].ownership
117 mdev->
sriov.alias_guid.ports_guid[port->
num - 1].all_rec_per_port[
record_num].ownership
123 mdev->
sriov.alias_guid.ports_guid[port->
num - 1].all_rec_per_port[
record_num].guid_indexes
146 ret =
sprintf(buf,
"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
170 mlx4_ib_iov_dentry->
entry_num, &pkey, 1);
174 return sprintf(buf,
"0x%04x\n", pkey);
177 #define DENTRY_REMOVE(_dentry) \
179 sysfs_remove_file((_dentry)->kobj, &(_dentry)->dentry.attr); \
183 char *_name,
struct kobject *_kobj,
189 const char *buf,
size_t count)
200 vdentry->
dentry.attr.mode = 0;
201 vdentry->
kobj = _kobj;
204 if (vdentry->
dentry.store)
212 pr_err(
"failed to create %s\n", vdentry->
dentry.attr.name);
275 goto kobj_create_err;
282 goto err_admin_guids;
284 for (i = 0 ; i < attr.gid_tbl_len; i++) {
287 ret = create_sysfs_entry(port, &port->
dentr_ar->dentries[i],
289 show_admin_alias_guid, store_admin_alias_guid);
291 goto err_admin_alias_parent;
302 for (i = 0 ; i < attr.gid_tbl_len; i++) {
304 port->
dentr_ar->dentries[attr.gid_tbl_len +
i].entry_num =
i;
305 ret = create_sysfs_entry(port,
306 &port->
dentr_ar->dentries[attr.gid_tbl_len + i],
310 goto err_gids_parent;
321 for (i = 0 ; i < attr.pkey_tbl_len; i++) {
323 port->
dentr_ar->dentries[2 * attr.gid_tbl_len +
i].entry_num =
i;
324 ret = create_sysfs_entry(port,
325 &port->
dentr_ar->dentries[2 * attr.gid_tbl_len + i],
327 show_phys_port_pkey,
NULL);
329 goto err_pkeys_parent;
356 err_admin_alias_parent:
368 pr_err(
"add_port_entries FAILED: for port:%d, error: %d\n",
384 sprintf(name,
"%s%.2d.%d", base_name, (i/8), (i%8));
397 static void mlx4_port_release(
struct kobject *kobj)
426 if (!port_attr->
show)
428 return port_attr->
show(p, port_attr, buf);
433 const char *buf,
size_t size)
439 if (!port_attr->
store)
441 return port_attr->
store(p, port_attr, buf, size);
444 static const struct sysfs_ops port_sysfs_ops = {
445 .show = port_attr_show,
446 .store = port_attr_store,
451 .sysfs_ops = &port_sysfs_ops,
472 p->
dev->pkeys.virt2phys_pkey[p->
slave]
478 const char *buf,
size_t count)
486 if (p->
slave == mlx4_master_func_num(p->
dev->dev))
490 idx = p->
dev->dev->phys_caps.pkey_phys_table_len[p->
port_num] - 1;
491 else if (
sscanf(buf,
"%i", &idx) != 1 ||
492 idx >= p->
dev->dev->caps.pkey_table_len[p->
port_num] ||
499 tab_attr->
index, idx);
502 pr_err(
"mlx4_gen_pkey_eqe failed for slave %d,"
519 const char *buf,
size_t count),
530 for (i = 0; i < len; i++) {
541 element->
attr.attr.name = element->
name;
550 tab_attr[
i] = &element->
attr.attr;
583 alloc_group_attrs(show_port_pkey, store_port_pkey,
584 dev->
dev->caps.pkey_table_len[port_num]);
593 p->
gid_group.attrs = alloc_group_attrs(show_port_gid_idx,
NULL, 1);
609 for (i = 0; i < dev->
dev->caps.pkey_table_len[
port_num]; ++
i)
619 static int register_one_pkey_tree(
struct mlx4_ib_dev *dev,
int slave)
627 get_name(dev, name, slave,
sizeof name);
632 if (!dev->
pkeys.device_parent[slave]) {
637 INIT_LIST_HEAD(&dev->
pkeys.pkey_port_list[slave]);
648 for (port = 1; port <= dev->
dev->caps.num_ports; ++
port) {
649 err = add_port(dev, port, slave);
657 &dev->
pkeys.pkey_port_list[slave],
677 static int register_pkey_tree(
struct mlx4_ib_dev *device)
681 if (!mlx4_is_master(device->
dev))
684 for (i = 0; i <= device->
dev->num_vfs; ++
i)
685 register_one_pkey_tree(device, i);
690 static void unregister_pkey_tree(
struct mlx4_ib_dev *device)
696 if (!mlx4_is_master(device->
dev))
699 for (slave = device->
dev->num_vfs; slave >= 0; --slave) {
701 &device->
pkeys.pkey_port_list[slave],
722 if (!mlx4_is_master(dev->
dev))
740 for (i = 1; i <= dev->
ib_dev.phys_port_cnt; ++
i) {
741 ret = add_port_entries(dev, i);
743 goto err_add_entries;
746 ret = register_pkey_tree(dev);
748 goto err_add_entries;
758 pr_err(
"mlx4_ib_device_register_sysfs error (%d)\n", ret);
762 static void unregister_alias_guid_tree(
struct mlx4_ib_dev *device)
767 if (!mlx4_is_master(device->
dev))
770 for (i = 0; i < device->
dev->caps.num_ports; i++) {
788 unregister_alias_guid_tree(device);
789 unregister_pkey_tree(device);