aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/ipath/ipath_sysfs.c
diff options
context:
space:
mode:
authorRalph Campbell <ralph.campbell@qlogic.com>2007-09-12 18:00:58 -0400
committerRoland Dreier <rolandd@cisco.com>2007-10-09 23:53:50 -0400
commit15cba26f42c13ca30cbb4388f132ac0ddf4df538 (patch)
treee1b0d4efd1078987c7416642aeaddb694bf4aa90 /drivers/infiniband/hw/ipath/ipath_sysfs.c
parent6cff2faaf135b602c914710f3414630c3fc1ee83 (diff)
IB/ipath: Add ability to set the LMC via the sysfs debugging interface
This patch adds the ability to set the LMC via a sysfs file as if the SM sent a SubnSet(PortInfo) MAD. It is useful for debugging when no SM is running. Signed-off-by: Ralph Campbell <ralph.campbell@qlogic.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_sysfs.c')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index 16238cd3a036..e1ad7cfc21fd 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -163,6 +163,42 @@ static ssize_t show_boardversion(struct device *dev,
163 return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_boardversion); 163 return scnprintf(buf, PAGE_SIZE, "%s", dd->ipath_boardversion);
164} 164}
165 165
166static ssize_t show_lmc(struct device *dev,
167 struct device_attribute *attr,
168 char *buf)
169{
170 struct ipath_devdata *dd = dev_get_drvdata(dev);
171
172 return scnprintf(buf, PAGE_SIZE, "%u\n", dd->ipath_lmc);
173}
174
175static ssize_t store_lmc(struct device *dev,
176 struct device_attribute *attr,
177 const char *buf,
178 size_t count)
179{
180 struct ipath_devdata *dd = dev_get_drvdata(dev);
181 u16 lmc = 0;
182 int ret;
183
184 ret = ipath_parse_ushort(buf, &lmc);
185 if (ret < 0)
186 goto invalid;
187
188 if (lmc > 7) {
189 ret = -EINVAL;
190 goto invalid;
191 }
192
193 ipath_set_lid(dd, dd->ipath_lid, lmc);
194
195 goto bail;
196invalid:
197 ipath_dev_err(dd, "attempt to set invalid LMC %u\n", lmc);
198bail:
199 return ret;
200}
201
166static ssize_t show_lid(struct device *dev, 202static ssize_t show_lid(struct device *dev,
167 struct device_attribute *attr, 203 struct device_attribute *attr,
168 char *buf) 204 char *buf)
@@ -190,7 +226,7 @@ static ssize_t store_lid(struct device *dev,
190 goto invalid; 226 goto invalid;
191 } 227 }
192 228
193 ipath_set_lid(dd, lid, 0); 229 ipath_set_lid(dd, lid, dd->ipath_lmc);
194 230
195 goto bail; 231 goto bail;
196invalid: 232invalid:
@@ -648,6 +684,7 @@ static struct attribute_group driver_attr_group = {
648}; 684};
649 685
650static DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid); 686static DEVICE_ATTR(guid, S_IWUSR | S_IRUGO, show_guid, store_guid);
687static DEVICE_ATTR(lmc, S_IWUSR | S_IRUGO, show_lmc, store_lmc);
651static DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid); 688static DEVICE_ATTR(lid, S_IWUSR | S_IRUGO, show_lid, store_lid);
652static DEVICE_ATTR(link_state, S_IWUSR, NULL, store_link_state); 689static DEVICE_ATTR(link_state, S_IWUSR, NULL, store_link_state);
653static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid); 690static DEVICE_ATTR(mlid, S_IWUSR | S_IRUGO, show_mlid, store_mlid);
@@ -667,6 +704,7 @@ static DEVICE_ATTR(logged_errors, S_IRUGO, show_logged_errs, NULL);
667 704
668static struct attribute *dev_attributes[] = { 705static struct attribute *dev_attributes[] = {
669 &dev_attr_guid.attr, 706 &dev_attr_guid.attr,
707 &dev_attr_lmc.attr,
670 &dev_attr_lid.attr, 708 &dev_attr_lid.attr,
671 &dev_attr_link_state.attr, 709 &dev_attr_link_state.attr,
672 &dev_attr_mlid.attr, 710 &dev_attr_mlid.attr,