Lines Matching +full:diag +full:- +full:version
1 // SPDX-License-Identifier: GPL-2.0
25 * zfcp_diag_adapter_setup() - Setup storage for adapter diagnostics.
28 * Creates the data-structures to store the diagnostics for an adapter. This
29 * overwrites whatever was stored before at &zfcp_adapter->diagnostics!
32 * * 0 - Everyting is OK
33 * * -ENOMEM - Could not allocate all/parts of the data-structures;
34 * &zfcp_adapter->diagnostics remains unchanged
38 struct zfcp_diag_adapter *diag; in zfcp_diag_adapter_setup() local
41 diag = kzalloc(sizeof(*diag), GFP_KERNEL); in zfcp_diag_adapter_setup()
42 if (diag == NULL) in zfcp_diag_adapter_setup()
43 return -ENOMEM; in zfcp_diag_adapter_setup()
45 diag->max_age = (5 * 1000); /* default value: 5 s */ in zfcp_diag_adapter_setup()
48 hdr = &diag->port_data.header; in zfcp_diag_adapter_setup()
50 spin_lock_init(&hdr->access_lock); in zfcp_diag_adapter_setup()
51 hdr->buffer = &diag->port_data.data; in zfcp_diag_adapter_setup()
52 hdr->buffer_size = sizeof(diag->port_data.data); in zfcp_diag_adapter_setup()
54 hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age); in zfcp_diag_adapter_setup()
57 hdr = &diag->config_data.header; in zfcp_diag_adapter_setup()
59 spin_lock_init(&hdr->access_lock); in zfcp_diag_adapter_setup()
60 hdr->buffer = &diag->config_data.data; in zfcp_diag_adapter_setup()
61 hdr->buffer_size = sizeof(diag->config_data.data); in zfcp_diag_adapter_setup()
63 hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age); in zfcp_diag_adapter_setup()
65 adapter->diagnostics = diag; in zfcp_diag_adapter_setup()
70 * zfcp_diag_adapter_free() - Frees all adapter diagnostics allocations.
73 * Frees all data-structures in the given adapter that store diagnostics
78 kfree(adapter->diagnostics); in zfcp_diag_adapter_free()
79 adapter->diagnostics = NULL; in zfcp_diag_adapter_free()
83 * zfcp_diag_sysfs_setup() - Setup the sysfs-group for adapter-diagnostics.
90 int rc = sysfs_create_group(&adapter->ccw_device->dev.kobj, in zfcp_diag_sysfs_setup()
93 adapter->diagnostics->sysfs_established = 1; in zfcp_diag_sysfs_setup()
99 * zfcp_diag_sysfs_destroy() - Remove the sysfs-group for adapter-diagnostics.
104 if (adapter->diagnostics == NULL || in zfcp_diag_sysfs_destroy()
105 !adapter->diagnostics->sysfs_established) in zfcp_diag_sysfs_destroy()
109 * We need this state-handling so we can prevent warnings being printed in zfcp_diag_sysfs_destroy()
110 * on the kernel-console in case we have to abort a halfway done in zfcp_diag_sysfs_destroy()
111 * zfcp_adapter_enqueue(), in which the sysfs-group was not yet in zfcp_diag_sysfs_destroy()
116 adapter->diagnostics->sysfs_established = 0; in zfcp_diag_sysfs_destroy()
117 sysfs_remove_group(&adapter->ccw_device->dev.kobj, in zfcp_diag_sysfs_destroy()
123 * zfcp_diag_update_xdata() - Update a diagnostics buffer.
134 spin_lock_irqsave(&hdr->access_lock, flags); in zfcp_diag_update_xdata()
137 if (!time_after_eq(capture_timestamp, hdr->timestamp)) in zfcp_diag_update_xdata()
140 hdr->timestamp = capture_timestamp; in zfcp_diag_update_xdata()
141 hdr->incomplete = incomplete; in zfcp_diag_update_xdata()
142 memcpy(hdr->buffer, data, hdr->buffer_size); in zfcp_diag_update_xdata()
144 spin_unlock_irqrestore(&hdr->access_lock, flags); in zfcp_diag_update_xdata()
148 * zfcp_diag_update_port_data_buffer() - Implementation of
157 * * 0 - Successfully retrieved new Diagnostics and Updated the buffer;
161 * * see zfcp_fsf_exchange_port_data_sync() for possible error-codes (
162 * excluding -EAGAIN)
168 rc = zfcp_fsf_exchange_port_data_sync(adapter->qdio, NULL); in zfcp_diag_update_port_data_buffer()
169 if (rc == -EAGAIN) in zfcp_diag_update_port_data_buffer()
172 /* buffer-data was updated in zfcp_fsf_exchange_port_data_handler() */ in zfcp_diag_update_port_data_buffer()
178 * zfcp_diag_update_config_data_buffer() - Implementation of
187 * * 0 - Successfully retrieved new Diagnostics and Updated the buffer;
191 * * see zfcp_fsf_exchange_config_data_sync() for possible error-codes (
192 * excluding -EAGAIN)
198 rc = zfcp_fsf_exchange_config_data_sync(adapter->qdio, NULL); in zfcp_diag_update_config_data_buffer()
199 if (rc == -EAGAIN) in zfcp_diag_update_config_data_buffer()
202 /* buffer-data was updated in zfcp_fsf_exchange_config_data_handler() */ in zfcp_diag_update_config_data_buffer()
211 __must_hold(hdr->access_lock) in __zfcp_diag_update_buffer()
215 if (hdr->updating == 1) { in __zfcp_diag_update_buffer()
217 hdr->updating == 0, in __zfcp_diag_update_buffer()
218 hdr->access_lock); in __zfcp_diag_update_buffer()
219 rc = (rc == 0 ? -EAGAIN : -EINTR); in __zfcp_diag_update_buffer()
221 hdr->updating = 1; in __zfcp_diag_update_buffer()
222 spin_unlock_irqrestore(&hdr->access_lock, *flags); in __zfcp_diag_update_buffer()
227 spin_lock_irqsave(&hdr->access_lock, *flags); in __zfcp_diag_update_buffer()
228 hdr->updating = 0; in __zfcp_diag_update_buffer()
241 __zfcp_diag_test_buffer_age_isfresh(const struct zfcp_diag_adapter *const diag, in __zfcp_diag_test_buffer_age_isfresh() argument
243 __must_hold(hdr->access_lock) in __zfcp_diag_test_buffer_age_isfresh()
251 if (!time_after_eq(now, hdr->timestamp)) in __zfcp_diag_test_buffer_age_isfresh()
254 if (jiffies_to_msecs(now - hdr->timestamp) >= diag->max_age) in __zfcp_diag_test_buffer_age_isfresh()
261 * zfcp_diag_update_buffer_limited() - Collect diagnostics and update a
264 * @hdr: buffer-header for which to update with the collected diagnostics.
273 * Additionally this version is rate-limited and will only exit if either the
274 * buffer is fresh enough (within the limit) - it will do nothing if the buffer
275 * is fresh enough to begin with -, or if the source/thread that started this
279 * * 0 - If the update was successfully published and/or the buffer is
281 * * -EINTR - If the thread went into the wait-state and was interrupted
291 spin_lock_irqsave(&hdr->access_lock, flags); in zfcp_diag_update_buffer_limited()
294 !__zfcp_diag_test_buffer_age_isfresh(adapter->diagnostics, hdr); in zfcp_diag_update_buffer_limited()
298 if (rc != -EAGAIN) in zfcp_diag_update_buffer_limited()
302 spin_unlock_irqrestore(&hdr->access_lock, flags); in zfcp_diag_update_buffer_limited()