diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-13 14:32:56 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 12:01:16 -0400 |
commit | 76c52bbe5e5ffc6812dcd49729c09f5a207b4a9a (patch) | |
tree | d0005bb14fcbf914dd7fb5667aa5034c51f18fe4 | |
parent | 8681db445ed407167cd0d78c48727773b132367b (diff) |
hv: move "client/server_monitor_pending" bus attributes to dev_groups
This moves the "client_monitor_pending" and "server_monitor_pending" bus
attributes to the dev_groups structure, removing the need for it to be
in a temporary structure.
Tested-by: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/channel.c | 4 | ||||
-rw-r--r-- | drivers/hv/vmbus_drv.c | 56 | ||||
-rw-r--r-- | include/linux/hyperv.h | 2 |
3 files changed, 46 insertions, 16 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 04bf06560085..d600360ee788 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c | |||
@@ -70,8 +70,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, | |||
70 | u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; | 70 | u8 monitor_offset = (u8)channel->offermsg.monitorid % 32; |
71 | 71 | ||
72 | monitorpage = vmbus_connection.monitor_pages[0]; | 72 | monitorpage = vmbus_connection.monitor_pages[0]; |
73 | debuginfo->servermonitor_pending = | ||
74 | monitorpage->trigger_group[monitor_group].pending; | ||
75 | debuginfo->servermonitor_latency = | 73 | debuginfo->servermonitor_latency = |
76 | monitorpage->latency[monitor_group][monitor_offset]; | 74 | monitorpage->latency[monitor_group][monitor_offset]; |
77 | debuginfo->servermonitor_connectionid = | 75 | debuginfo->servermonitor_connectionid = |
@@ -79,8 +77,6 @@ void vmbus_get_debug_info(struct vmbus_channel *channel, | |||
79 | [monitor_offset].connectionid.u.id; | 77 | [monitor_offset].connectionid.u.id; |
80 | 78 | ||
81 | monitorpage = vmbus_connection.monitor_pages[1]; | 79 | monitorpage = vmbus_connection.monitor_pages[1]; |
82 | debuginfo->clientmonitor_pending = | ||
83 | monitorpage->trigger_group[monitor_group].pending; | ||
84 | debuginfo->clientmonitor_latency = | 80 | debuginfo->clientmonitor_latency = |
85 | monitorpage->latency[monitor_group][monitor_offset]; | 81 | monitorpage->latency[monitor_group][monitor_offset]; |
86 | debuginfo->clientmonitor_connectionid = | 82 | debuginfo->clientmonitor_connectionid = |
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 944dc4b0b54d..5a44957b7064 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c | |||
@@ -47,10 +47,8 @@ static struct completion probe_event; | |||
47 | static int irq; | 47 | static int irq; |
48 | 48 | ||
49 | struct hv_device_info { | 49 | struct hv_device_info { |
50 | u32 server_monitor_pending; | ||
51 | u32 server_monitor_latency; | 50 | u32 server_monitor_latency; |
52 | u32 server_monitor_conn_id; | 51 | u32 server_monitor_conn_id; |
53 | u32 client_monitor_pending; | ||
54 | u32 client_monitor_latency; | 52 | u32 client_monitor_latency; |
55 | u32 client_monitor_conn_id; | 53 | u32 client_monitor_conn_id; |
56 | 54 | ||
@@ -77,11 +75,9 @@ static void get_channel_info(struct hv_device *device, | |||
77 | 75 | ||
78 | vmbus_get_debug_info(device->channel, &debug_info); | 76 | vmbus_get_debug_info(device->channel, &debug_info); |
79 | 77 | ||
80 | info->server_monitor_pending = debug_info.servermonitor_pending; | ||
81 | info->server_monitor_latency = debug_info.servermonitor_latency; | 78 | info->server_monitor_latency = debug_info.servermonitor_latency; |
82 | info->server_monitor_conn_id = debug_info.servermonitor_connectionid; | 79 | info->server_monitor_conn_id = debug_info.servermonitor_connectionid; |
83 | 80 | ||
84 | info->client_monitor_pending = debug_info.clientmonitor_pending; | ||
85 | info->client_monitor_latency = debug_info.clientmonitor_latency; | 81 | info->client_monitor_latency = debug_info.clientmonitor_latency; |
86 | info->client_monitor_conn_id = debug_info.clientmonitor_connectionid; | 82 | info->client_monitor_conn_id = debug_info.clientmonitor_connectionid; |
87 | 83 | ||
@@ -155,15 +151,11 @@ static ssize_t vmbus_show_device_attr(struct device *dev, | |||
155 | } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) { | 151 | } else if (!strcmp(dev_attr->attr.name, "in_write_bytes_avail")) { |
156 | ret = sprintf(buf, "%d\n", | 152 | ret = sprintf(buf, "%d\n", |
157 | device_info->inbound.bytes_avail_towrite); | 153 | device_info->inbound.bytes_avail_towrite); |
158 | } else if (!strcmp(dev_attr->attr.name, "server_monitor_pending")) { | ||
159 | ret = sprintf(buf, "%d\n", device_info->server_monitor_pending); | ||
160 | } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) { | 154 | } else if (!strcmp(dev_attr->attr.name, "server_monitor_latency")) { |
161 | ret = sprintf(buf, "%d\n", device_info->server_monitor_latency); | 155 | ret = sprintf(buf, "%d\n", device_info->server_monitor_latency); |
162 | } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) { | 156 | } else if (!strcmp(dev_attr->attr.name, "server_monitor_conn_id")) { |
163 | ret = sprintf(buf, "%d\n", | 157 | ret = sprintf(buf, "%d\n", |
164 | device_info->server_monitor_conn_id); | 158 | device_info->server_monitor_conn_id); |
165 | } else if (!strcmp(dev_attr->attr.name, "client_monitor_pending")) { | ||
166 | ret = sprintf(buf, "%d\n", device_info->client_monitor_pending); | ||
167 | } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) { | 159 | } else if (!strcmp(dev_attr->attr.name, "client_monitor_latency")) { |
168 | ret = sprintf(buf, "%d\n", device_info->client_monitor_latency); | 160 | ret = sprintf(buf, "%d\n", device_info->client_monitor_latency); |
169 | } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) { | 161 | } else if (!strcmp(dev_attr->attr.name, "client_monitor_conn_id")) { |
@@ -175,6 +167,23 @@ static ssize_t vmbus_show_device_attr(struct device *dev, | |||
175 | return ret; | 167 | return ret; |
176 | } | 168 | } |
177 | 169 | ||
170 | static u8 channel_monitor_group(struct vmbus_channel *channel) | ||
171 | { | ||
172 | return (u8)channel->offermsg.monitorid / 32; | ||
173 | } | ||
174 | |||
175 | static u8 channel_monitor_offset(struct vmbus_channel *channel) | ||
176 | { | ||
177 | return (u8)channel->offermsg.monitorid % 32; | ||
178 | } | ||
179 | |||
180 | static u32 channel_pending(struct vmbus_channel *channel, | ||
181 | struct hv_monitor_page *monitor_page) | ||
182 | { | ||
183 | u8 monitor_group = channel_monitor_group(channel); | ||
184 | return monitor_page->trigger_group[monitor_group].pending; | ||
185 | } | ||
186 | |||
178 | static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr, | 187 | static ssize_t id_show(struct device *dev, struct device_attribute *dev_attr, |
179 | char *buf) | 188 | char *buf) |
180 | { | 189 | { |
@@ -243,6 +252,33 @@ static ssize_t modalias_show(struct device *dev, | |||
243 | } | 252 | } |
244 | static DEVICE_ATTR_RO(modalias); | 253 | static DEVICE_ATTR_RO(modalias); |
245 | 254 | ||
255 | static ssize_t server_monitor_pending_show(struct device *dev, | ||
256 | struct device_attribute *dev_attr, | ||
257 | char *buf) | ||
258 | { | ||
259 | struct hv_device *hv_dev = device_to_hv_device(dev); | ||
260 | |||
261 | if (!hv_dev->channel) | ||
262 | return -ENODEV; | ||
263 | return sprintf(buf, "%d\n", | ||
264 | channel_pending(hv_dev->channel, | ||
265 | vmbus_connection.monitor_pages[1])); | ||
266 | } | ||
267 | static DEVICE_ATTR_RO(server_monitor_pending); | ||
268 | |||
269 | static ssize_t client_monitor_pending_show(struct device *dev, | ||
270 | struct device_attribute *dev_attr, | ||
271 | char *buf) | ||
272 | { | ||
273 | struct hv_device *hv_dev = device_to_hv_device(dev); | ||
274 | |||
275 | if (!hv_dev->channel) | ||
276 | return -ENODEV; | ||
277 | return sprintf(buf, "%d\n", | ||
278 | channel_pending(hv_dev->channel, | ||
279 | vmbus_connection.monitor_pages[1])); | ||
280 | } | ||
281 | static DEVICE_ATTR_RO(client_monitor_pending); | ||
246 | 282 | ||
247 | static struct attribute *vmbus_attrs[] = { | 283 | static struct attribute *vmbus_attrs[] = { |
248 | &dev_attr_id.attr, | 284 | &dev_attr_id.attr, |
@@ -251,17 +287,17 @@ static struct attribute *vmbus_attrs[] = { | |||
251 | &dev_attr_class_id.attr, | 287 | &dev_attr_class_id.attr, |
252 | &dev_attr_device_id.attr, | 288 | &dev_attr_device_id.attr, |
253 | &dev_attr_modalias.attr, | 289 | &dev_attr_modalias.attr, |
290 | &dev_attr_server_monitor_pending.attr, | ||
291 | &dev_attr_client_monitor_pending.attr, | ||
254 | NULL, | 292 | NULL, |
255 | }; | 293 | }; |
256 | ATTRIBUTE_GROUPS(vmbus); | 294 | ATTRIBUTE_GROUPS(vmbus); |
257 | 295 | ||
258 | /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ | 296 | /* Set up per device attributes in /sys/bus/vmbus/devices/<bus device> */ |
259 | static struct device_attribute vmbus_device_attrs[] = { | 297 | static struct device_attribute vmbus_device_attrs[] = { |
260 | __ATTR(server_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL), | ||
261 | __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL), | 298 | __ATTR(server_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL), |
262 | __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL), | 299 | __ATTR(server_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL), |
263 | 300 | ||
264 | __ATTR(client_monitor_pending, S_IRUGO, vmbus_show_device_attr, NULL), | ||
265 | __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL), | 301 | __ATTR(client_monitor_latency, S_IRUGO, vmbus_show_device_attr, NULL), |
266 | __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL), | 302 | __ATTR(client_monitor_conn_id, S_IRUGO, vmbus_show_device_attr, NULL), |
267 | 303 | ||
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 687c01b85037..f0a7d27ffb21 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
@@ -900,10 +900,8 @@ enum vmbus_channel_state { | |||
900 | }; | 900 | }; |
901 | 901 | ||
902 | struct vmbus_channel_debug_info { | 902 | struct vmbus_channel_debug_info { |
903 | u32 servermonitor_pending; | ||
904 | u32 servermonitor_latency; | 903 | u32 servermonitor_latency; |
905 | u32 servermonitor_connectionid; | 904 | u32 servermonitor_connectionid; |
906 | u32 clientmonitor_pending; | ||
907 | u32 clientmonitor_latency; | 905 | u32 clientmonitor_latency; |
908 | u32 clientmonitor_connectionid; | 906 | u32 clientmonitor_connectionid; |
909 | 907 | ||