sysfs.c (1c7fd72687d619207e0f075dd1f1c749879d8021) sysfs.c (45808361d4491217de11cdf0661d657081f8f422)
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:

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

112 struct device_attribute *attr,
113 char *buf)
114{
115 struct mlx4_ib_iov_sysfs_attr *mlx4_ib_iov_dentry =
116 container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);
117 struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
118 struct mlx4_ib_dev *mdev = port->dev;
119 union ib_gid gid;
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:

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

112 struct device_attribute *attr,
113 char *buf)
114{
115 struct mlx4_ib_iov_sysfs_attr *mlx4_ib_iov_dentry =
116 container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);
117 struct mlx4_ib_iov_port *port = mlx4_ib_iov_dentry->ctx;
118 struct mlx4_ib_dev *mdev = port->dev;
119 union ib_gid gid;
120 ssize_t ret;
120 int ret;
121 __be16 *raw;
121
122 ret = __mlx4_ib_query_gid(&mdev->ib_dev, port->num,
123 mlx4_ib_iov_dentry->entry_num, &gid, 1);
124 if (ret)
125 return ret;
122
123 ret = __mlx4_ib_query_gid(&mdev->ib_dev, port->num,
124 mlx4_ib_iov_dentry->entry_num, &gid, 1);
125 if (ret)
126 return ret;
126 ret = sysfs_emit(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
127 be16_to_cpu(((__be16 *)gid.raw)[0]),
128 be16_to_cpu(((__be16 *)gid.raw)[1]),
129 be16_to_cpu(((__be16 *)gid.raw)[2]),
130 be16_to_cpu(((__be16 *)gid.raw)[3]),
131 be16_to_cpu(((__be16 *)gid.raw)[4]),
132 be16_to_cpu(((__be16 *)gid.raw)[5]),
133 be16_to_cpu(((__be16 *)gid.raw)[6]),
134 be16_to_cpu(((__be16 *)gid.raw)[7]));
135 return ret;
127
128 raw = (__be16 *)gid.raw;
129 return sysfs_emit(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
130 be16_to_cpu(raw[0]),
131 be16_to_cpu(raw[1]),
132 be16_to_cpu(raw[2]),
133 be16_to_cpu(raw[3]),
134 be16_to_cpu(raw[4]),
135 be16_to_cpu(raw[5]),
136 be16_to_cpu(raw[6]),
137 be16_to_cpu(raw[7]));
136}
137
138static ssize_t show_phys_port_pkey(struct device *dev,
139 struct device_attribute *attr,
140 char *buf)
141{
142 struct mlx4_ib_iov_sysfs_attr *mlx4_ib_iov_dentry =
143 container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);

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

537 return NULL;
538}
539
540static ssize_t sysfs_show_smi_enabled(struct device *dev,
541 struct device_attribute *attr, char *buf)
542{
543 struct mlx4_port *p =
544 container_of(attr, struct mlx4_port, smi_enabled);
138}
139
140static ssize_t show_phys_port_pkey(struct device *dev,
141 struct device_attribute *attr,
142 char *buf)
143{
144 struct mlx4_ib_iov_sysfs_attr *mlx4_ib_iov_dentry =
145 container_of(attr, struct mlx4_ib_iov_sysfs_attr, dentry);

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

539 return NULL;
540}
541
542static ssize_t sysfs_show_smi_enabled(struct device *dev,
543 struct device_attribute *attr, char *buf)
544{
545 struct mlx4_port *p =
546 container_of(attr, struct mlx4_port, smi_enabled);
545 ssize_t len = 0;
546
547
547 if (mlx4_vf_smi_enabled(p->dev->dev, p->slave, p->port_num))
548 len = sysfs_emit(buf, "%d\n", 1);
549 else
550 len = sysfs_emit(buf, "%d\n", 0);
551
552 return len;
548 return sysfs_emit(buf, "%d\n",
549 !!mlx4_vf_smi_enabled(p->dev->dev, p->slave,
550 p->port_num));
553}
554
555static ssize_t sysfs_show_enable_smi_admin(struct device *dev,
556 struct device_attribute *attr,
557 char *buf)
558{
559 struct mlx4_port *p =
560 container_of(attr, struct mlx4_port, enable_smi_admin);
551}
552
553static ssize_t sysfs_show_enable_smi_admin(struct device *dev,
554 struct device_attribute *attr,
555 char *buf)
556{
557 struct mlx4_port *p =
558 container_of(attr, struct mlx4_port, enable_smi_admin);
561 ssize_t len = 0;
562
559
563 if (mlx4_vf_get_enable_smi_admin(p->dev->dev, p->slave, p->port_num))
564 len = sysfs_emit(buf, "%d\n", 1);
565 else
566 len = sysfs_emit(buf, "%d\n", 0);
567
568 return len;
560 return sysfs_emit(buf, "%d\n",
561 !!mlx4_vf_get_enable_smi_admin(p->dev->dev, p->slave,
562 p->port_num));
569}
570
571static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
572 struct device_attribute *attr,
573 const char *buf, size_t count)
574{
575 struct mlx4_port *p =
576 container_of(attr, struct mlx4_port, enable_smi_admin);

--- 306 unchanged lines hidden ---
563}
564
565static ssize_t sysfs_store_enable_smi_admin(struct device *dev,
566 struct device_attribute *attr,
567 const char *buf, size_t count)
568{
569 struct mlx4_port *p =
570 container_of(attr, struct mlx4_port, enable_smi_admin);

--- 306 unchanged lines hidden ---