sysfs.c (45808361d4491217de11cdf0661d657081f8f422) sysfs.c (e28bf1f03b01b135dc0052b3a195c2860e10f216)
1/*
2 * Copyright (c) 2012 Mellanox Technologies. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 429 unchanged lines hidden (view full) ---

438 int index;
439};
440
441static ssize_t show_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
442 char *buf)
443{
444 struct port_table_attribute *tab_attr =
445 container_of(attr, struct port_table_attribute, attr);
1/*
2 * Copyright (c) 2012 Mellanox Technologies. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:

--- 429 unchanged lines hidden (view full) ---

438 int index;
439};
440
441static ssize_t show_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
442 char *buf)
443{
444 struct port_table_attribute *tab_attr =
445 container_of(attr, struct port_table_attribute, attr);
446 ssize_t ret = -ENODEV;
446 struct pkey_mgt *m = &p->dev->pkeys;
447 u8 key = m->virt2phys_pkey[p->slave][p->port_num - 1][tab_attr->index];
447
448
448 if (p->dev->pkeys.virt2phys_pkey[p->slave][p->port_num - 1][tab_attr->index] >=
449 (p->dev->dev->caps.pkey_table_len[p->port_num]))
450 ret = sprintf(buf, "none\n");
451 else
452 ret = sprintf(buf, "%d\n",
453 p->dev->pkeys.virt2phys_pkey[p->slave]
454 [p->port_num - 1][tab_attr->index]);
455 return ret;
449 if (key >= p->dev->dev->caps.pkey_table_len[p->port_num])
450 return sysfs_emit(buf, "none\n");
451 return sysfs_emit(buf, "%d\n", key);
456}
457
458static ssize_t store_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
459 const char *buf, size_t count)
460{
461 struct port_table_attribute *tab_attr =
462 container_of(attr, struct port_table_attribute, attr);
463 int idx;

--- 21 unchanged lines hidden (view full) ---

485 return err;
486 }
487 return count;
488}
489
490static ssize_t show_port_gid_idx(struct mlx4_port *p,
491 struct port_attribute *attr, char *buf)
492{
452}
453
454static ssize_t store_port_pkey(struct mlx4_port *p, struct port_attribute *attr,
455 const char *buf, size_t count)
456{
457 struct port_table_attribute *tab_attr =
458 container_of(attr, struct port_table_attribute, attr);
459 int idx;

--- 21 unchanged lines hidden (view full) ---

481 return err;
482 }
483 return count;
484}
485
486static ssize_t show_port_gid_idx(struct mlx4_port *p,
487 struct port_attribute *attr, char *buf)
488{
493 return sprintf(buf, "%d\n", p->slave);
489 return sysfs_emit(buf, "%d\n", p->slave);
494}
495
496static struct attribute **
497alloc_group_attrs(ssize_t (*show)(struct mlx4_port *,
498 struct port_attribute *, char *buf),
499 ssize_t (*store)(struct mlx4_port *, struct port_attribute *,
500 const char *buf, size_t count),
501 int len)

--- 375 unchanged lines hidden ---
490}
491
492static struct attribute **
493alloc_group_attrs(ssize_t (*show)(struct mlx4_port *,
494 struct port_attribute *, char *buf),
495 ssize_t (*store)(struct mlx4_port *, struct port_attribute *,
496 const char *buf, size_t count),
497 int len)

--- 375 unchanged lines hidden ---