diff options
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_sysfs.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_sysfs.c | 115 |
1 files changed, 7 insertions, 108 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c index f323791cc495..b98821d7801d 100644 --- a/drivers/infiniband/hw/ipath/ipath_sysfs.c +++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c | |||
@@ -1,4 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2006 QLogic, Inc. All rights reserved. | ||
2 | * Copyright (c) 2006 PathScale, Inc. All rights reserved. | 3 | * Copyright (c) 2006 PathScale, Inc. All rights reserved. |
3 | * | 4 | * |
4 | * This software is available to you under a choice of one of two | 5 | * This software is available to you under a choice of one of two |
@@ -34,8 +35,8 @@ | |||
34 | #include <linux/pci.h> | 35 | #include <linux/pci.h> |
35 | 36 | ||
36 | #include "ipath_kernel.h" | 37 | #include "ipath_kernel.h" |
37 | #include "ips_common.h" | ||
38 | #include "ipath_layer.h" | 38 | #include "ipath_layer.h" |
39 | #include "ipath_common.h" | ||
39 | 40 | ||
40 | /** | 41 | /** |
41 | * ipath_parse_ushort - parse an unsigned short value in an arbitrary base | 42 | * ipath_parse_ushort - parse an unsigned short value in an arbitrary base |
@@ -84,99 +85,6 @@ static ssize_t show_num_units(struct device_driver *dev, char *buf) | |||
84 | ipath_count_units(NULL, NULL, NULL)); | 85 | ipath_count_units(NULL, NULL, NULL)); |
85 | } | 86 | } |
86 | 87 | ||
87 | #define DRIVER_STAT(name, attr) \ | ||
88 | static ssize_t show_stat_##name(struct device_driver *dev, \ | ||
89 | char *buf) \ | ||
90 | { \ | ||
91 | return scnprintf( \ | ||
92 | buf, PAGE_SIZE, "%llu\n", \ | ||
93 | (unsigned long long) ipath_stats.sps_ ##attr); \ | ||
94 | } \ | ||
95 | static DRIVER_ATTR(name, S_IRUGO, show_stat_##name, NULL) | ||
96 | |||
97 | DRIVER_STAT(intrs, ints); | ||
98 | DRIVER_STAT(err_intrs, errints); | ||
99 | DRIVER_STAT(errs, errs); | ||
100 | DRIVER_STAT(pkt_errs, pkterrs); | ||
101 | DRIVER_STAT(crc_errs, crcerrs); | ||
102 | DRIVER_STAT(hw_errs, hwerrs); | ||
103 | DRIVER_STAT(ib_link, iblink); | ||
104 | DRIVER_STAT(port0_pkts, port0pkts); | ||
105 | DRIVER_STAT(ether_spkts, ether_spkts); | ||
106 | DRIVER_STAT(ether_rpkts, ether_rpkts); | ||
107 | DRIVER_STAT(sma_spkts, sma_spkts); | ||
108 | DRIVER_STAT(sma_rpkts, sma_rpkts); | ||
109 | DRIVER_STAT(hdrq_full, hdrqfull); | ||
110 | DRIVER_STAT(etid_full, etidfull); | ||
111 | DRIVER_STAT(no_piobufs, nopiobufs); | ||
112 | DRIVER_STAT(ports, ports); | ||
113 | DRIVER_STAT(pkey0, pkeys[0]); | ||
114 | DRIVER_STAT(pkey1, pkeys[1]); | ||
115 | DRIVER_STAT(pkey2, pkeys[2]); | ||
116 | DRIVER_STAT(pkey3, pkeys[3]); | ||
117 | /* XXX fix the following when dynamic table of devices used */ | ||
118 | DRIVER_STAT(lid0, lid[0]); | ||
119 | DRIVER_STAT(lid1, lid[1]); | ||
120 | DRIVER_STAT(lid2, lid[2]); | ||
121 | DRIVER_STAT(lid3, lid[3]); | ||
122 | |||
123 | DRIVER_STAT(nports, nports); | ||
124 | DRIVER_STAT(null_intr, nullintr); | ||
125 | DRIVER_STAT(max_pkts_call, maxpkts_call); | ||
126 | DRIVER_STAT(avg_pkts_call, avgpkts_call); | ||
127 | DRIVER_STAT(page_locks, pagelocks); | ||
128 | DRIVER_STAT(page_unlocks, pageunlocks); | ||
129 | DRIVER_STAT(krdrops, krdrops); | ||
130 | /* XXX fix the following when dynamic table of devices used */ | ||
131 | DRIVER_STAT(mlid0, mlid[0]); | ||
132 | DRIVER_STAT(mlid1, mlid[1]); | ||
133 | DRIVER_STAT(mlid2, mlid[2]); | ||
134 | DRIVER_STAT(mlid3, mlid[3]); | ||
135 | |||
136 | static struct attribute *driver_stat_attributes[] = { | ||
137 | &driver_attr_intrs.attr, | ||
138 | &driver_attr_err_intrs.attr, | ||
139 | &driver_attr_errs.attr, | ||
140 | &driver_attr_pkt_errs.attr, | ||
141 | &driver_attr_crc_errs.attr, | ||
142 | &driver_attr_hw_errs.attr, | ||
143 | &driver_attr_ib_link.attr, | ||
144 | &driver_attr_port0_pkts.attr, | ||
145 | &driver_attr_ether_spkts.attr, | ||
146 | &driver_attr_ether_rpkts.attr, | ||
147 | &driver_attr_sma_spkts.attr, | ||
148 | &driver_attr_sma_rpkts.attr, | ||
149 | &driver_attr_hdrq_full.attr, | ||
150 | &driver_attr_etid_full.attr, | ||
151 | &driver_attr_no_piobufs.attr, | ||
152 | &driver_attr_ports.attr, | ||
153 | &driver_attr_pkey0.attr, | ||
154 | &driver_attr_pkey1.attr, | ||
155 | &driver_attr_pkey2.attr, | ||
156 | &driver_attr_pkey3.attr, | ||
157 | &driver_attr_lid0.attr, | ||
158 | &driver_attr_lid1.attr, | ||
159 | &driver_attr_lid2.attr, | ||
160 | &driver_attr_lid3.attr, | ||
161 | &driver_attr_nports.attr, | ||
162 | &driver_attr_null_intr.attr, | ||
163 | &driver_attr_max_pkts_call.attr, | ||
164 | &driver_attr_avg_pkts_call.attr, | ||
165 | &driver_attr_page_locks.attr, | ||
166 | &driver_attr_page_unlocks.attr, | ||
167 | &driver_attr_krdrops.attr, | ||
168 | &driver_attr_mlid0.attr, | ||
169 | &driver_attr_mlid1.attr, | ||
170 | &driver_attr_mlid2.attr, | ||
171 | &driver_attr_mlid3.attr, | ||
172 | NULL | ||
173 | }; | ||
174 | |||
175 | static struct attribute_group driver_stat_attr_group = { | ||
176 | .name = "stats", | ||
177 | .attrs = driver_stat_attributes | ||
178 | }; | ||
179 | |||
180 | static ssize_t show_status(struct device *dev, | 88 | static ssize_t show_status(struct device *dev, |
181 | struct device_attribute *attr, | 89 | struct device_attribute *attr, |
182 | char *buf) | 90 | char *buf) |
@@ -272,23 +180,23 @@ static ssize_t store_lid(struct device *dev, | |||
272 | size_t count) | 180 | size_t count) |
273 | { | 181 | { |
274 | struct ipath_devdata *dd = dev_get_drvdata(dev); | 182 | struct ipath_devdata *dd = dev_get_drvdata(dev); |
275 | u16 lid; | 183 | u16 lid = 0; |
276 | int ret; | 184 | int ret; |
277 | 185 | ||
278 | ret = ipath_parse_ushort(buf, &lid); | 186 | ret = ipath_parse_ushort(buf, &lid); |
279 | if (ret < 0) | 187 | if (ret < 0) |
280 | goto invalid; | 188 | goto invalid; |
281 | 189 | ||
282 | if (lid == 0 || lid >= 0xc000) { | 190 | if (lid == 0 || lid >= IPATH_MULTICAST_LID_BASE) { |
283 | ret = -EINVAL; | 191 | ret = -EINVAL; |
284 | goto invalid; | 192 | goto invalid; |
285 | } | 193 | } |
286 | 194 | ||
287 | ipath_set_sps_lid(dd, lid, 0); | 195 | ipath_set_lid(dd, lid, 0); |
288 | 196 | ||
289 | goto bail; | 197 | goto bail; |
290 | invalid: | 198 | invalid: |
291 | ipath_dev_err(dd, "attempt to set invalid LID\n"); | 199 | ipath_dev_err(dd, "attempt to set invalid LID 0x%x\n", lid); |
292 | bail: | 200 | bail: |
293 | return ret; | 201 | return ret; |
294 | } | 202 | } |
@@ -313,13 +221,12 @@ static ssize_t store_mlid(struct device *dev, | |||
313 | int ret; | 221 | int ret; |
314 | 222 | ||
315 | ret = ipath_parse_ushort(buf, &mlid); | 223 | ret = ipath_parse_ushort(buf, &mlid); |
316 | if (ret < 0) | 224 | if (ret < 0 || mlid < IPATH_MULTICAST_LID_BASE) |
317 | goto invalid; | 225 | goto invalid; |
318 | 226 | ||
319 | unit = dd->ipath_unit; | 227 | unit = dd->ipath_unit; |
320 | 228 | ||
321 | dd->ipath_mlid = mlid; | 229 | dd->ipath_mlid = mlid; |
322 | ipath_stats.sps_mlid[unit] = mlid; | ||
323 | ipath_layer_intr(dd, IPATH_LAYER_INT_BCAST); | 230 | ipath_layer_intr(dd, IPATH_LAYER_INT_BCAST); |
324 | 231 | ||
325 | goto bail; | 232 | goto bail; |
@@ -734,20 +641,12 @@ int ipath_driver_create_group(struct device_driver *drv) | |||
734 | int ret; | 641 | int ret; |
735 | 642 | ||
736 | ret = sysfs_create_group(&drv->kobj, &driver_attr_group); | 643 | ret = sysfs_create_group(&drv->kobj, &driver_attr_group); |
737 | if (ret) | ||
738 | goto bail; | ||
739 | 644 | ||
740 | ret = sysfs_create_group(&drv->kobj, &driver_stat_attr_group); | ||
741 | if (ret) | ||
742 | sysfs_remove_group(&drv->kobj, &driver_attr_group); | ||
743 | |||
744 | bail: | ||
745 | return ret; | 645 | return ret; |
746 | } | 646 | } |
747 | 647 | ||
748 | void ipath_driver_remove_group(struct device_driver *drv) | 648 | void ipath_driver_remove_group(struct device_driver *drv) |
749 | { | 649 | { |
750 | sysfs_remove_group(&drv->kobj, &driver_stat_attr_group); | ||
751 | sysfs_remove_group(&drv->kobj, &driver_attr_group); | 650 | sysfs_remove_group(&drv->kobj, &driver_attr_group); |
752 | } | 651 | } |
753 | 652 | ||