Lines Matching +full:diag +full:- +full:version
1 // SPDX-License-Identifier: GPL-2.0
23 * zfcp_diag_adapter_setup() - Setup storage for adapter diagnostics.
26 * Creates the data-structures to store the diagnostics for an adapter. This
27 * overwrites whatever was stored before at &zfcp_adapter->diagnostics!
30 * * 0 - Everyting is OK
31 * * -ENOMEM - Could not allocate all/parts of the data-structures;
32 * &zfcp_adapter->diagnostics remains unchanged
36 struct zfcp_diag_adapter *diag; in zfcp_diag_adapter_setup() local
39 diag = kzalloc(sizeof(*diag), GFP_KERNEL); in zfcp_diag_adapter_setup()
40 if (diag == NULL) in zfcp_diag_adapter_setup()
41 return -ENOMEM; in zfcp_diag_adapter_setup()
43 diag->max_age = (5 * 1000); /* default value: 5 s */ in zfcp_diag_adapter_setup()
46 hdr = &diag->port_data.header; in zfcp_diag_adapter_setup()
48 spin_lock_init(&hdr->access_lock); in zfcp_diag_adapter_setup()
49 hdr->buffer = &diag->port_data.data; in zfcp_diag_adapter_setup()
50 hdr->buffer_size = sizeof(diag->port_data.data); in zfcp_diag_adapter_setup()
52 hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age); in zfcp_diag_adapter_setup()
55 hdr = &diag->config_data.header; in zfcp_diag_adapter_setup()
57 spin_lock_init(&hdr->access_lock); in zfcp_diag_adapter_setup()
58 hdr->buffer = &diag->config_data.data; in zfcp_diag_adapter_setup()
59 hdr->buffer_size = sizeof(diag->config_data.data); in zfcp_diag_adapter_setup()
61 hdr->timestamp = jiffies - msecs_to_jiffies(diag->max_age); in zfcp_diag_adapter_setup()
63 adapter->diagnostics = diag; in zfcp_diag_adapter_setup()
68 * zfcp_diag_adapter_free() - Frees all adapter diagnostics allocations.
71 * Frees all data-structures in the given adapter that store diagnostics
76 kfree(adapter->diagnostics); in zfcp_diag_adapter_free()
77 adapter->diagnostics = NULL; in zfcp_diag_adapter_free()
81 * zfcp_diag_update_xdata() - Update a diagnostics buffer.
92 spin_lock_irqsave(&hdr->access_lock, flags); in zfcp_diag_update_xdata()
95 if (!time_after_eq(capture_timestamp, hdr->timestamp)) in zfcp_diag_update_xdata()
98 hdr->timestamp = capture_timestamp; in zfcp_diag_update_xdata()
99 hdr->incomplete = incomplete; in zfcp_diag_update_xdata()
100 memcpy(hdr->buffer, data, hdr->buffer_size); in zfcp_diag_update_xdata()
102 spin_unlock_irqrestore(&hdr->access_lock, flags); in zfcp_diag_update_xdata()
106 * zfcp_diag_update_port_data_buffer() - Implementation of
115 * * 0 - Successfully retrieved new Diagnostics and Updated the buffer;
119 * * see zfcp_fsf_exchange_port_data_sync() for possible error-codes (
120 * excluding -EAGAIN)
126 rc = zfcp_fsf_exchange_port_data_sync(adapter->qdio, NULL); in zfcp_diag_update_port_data_buffer()
127 if (rc == -EAGAIN) in zfcp_diag_update_port_data_buffer()
130 /* buffer-data was updated in zfcp_fsf_exchange_port_data_handler() */ in zfcp_diag_update_port_data_buffer()
136 * zfcp_diag_update_config_data_buffer() - Implementation of
145 * * 0 - Successfully retrieved new Diagnostics and Updated the buffer;
149 * * see zfcp_fsf_exchange_config_data_sync() for possible error-codes (
150 * excluding -EAGAIN)
156 rc = zfcp_fsf_exchange_config_data_sync(adapter->qdio, NULL); in zfcp_diag_update_config_data_buffer()
157 if (rc == -EAGAIN) in zfcp_diag_update_config_data_buffer()
160 /* buffer-data was updated in zfcp_fsf_exchange_config_data_handler() */ in zfcp_diag_update_config_data_buffer()
169 __must_hold(hdr->access_lock) in __zfcp_diag_update_buffer()
173 if (hdr->updating == 1) { in __zfcp_diag_update_buffer()
175 hdr->updating == 0, in __zfcp_diag_update_buffer()
176 hdr->access_lock); in __zfcp_diag_update_buffer()
177 rc = (rc == 0 ? -EAGAIN : -EINTR); in __zfcp_diag_update_buffer()
179 hdr->updating = 1; in __zfcp_diag_update_buffer()
180 spin_unlock_irqrestore(&hdr->access_lock, *flags); in __zfcp_diag_update_buffer()
185 spin_lock_irqsave(&hdr->access_lock, *flags); in __zfcp_diag_update_buffer()
186 hdr->updating = 0; in __zfcp_diag_update_buffer()
199 __zfcp_diag_test_buffer_age_isfresh(const struct zfcp_diag_adapter *const diag, in __zfcp_diag_test_buffer_age_isfresh() argument
201 __must_hold(hdr->access_lock) in __zfcp_diag_test_buffer_age_isfresh()
209 if (!time_after_eq(now, hdr->timestamp)) in __zfcp_diag_test_buffer_age_isfresh()
212 if (jiffies_to_msecs(now - hdr->timestamp) >= diag->max_age) in __zfcp_diag_test_buffer_age_isfresh()
219 * zfcp_diag_update_buffer_limited() - Collect diagnostics and update a
222 * @hdr: buffer-header for which to update with the collected diagnostics.
231 * Additionally this version is rate-limited and will only exit if either the
232 * buffer is fresh enough (within the limit) - it will do nothing if the buffer
233 * is fresh enough to begin with -, or if the source/thread that started this
237 * * 0 - If the update was successfully published and/or the buffer is
239 * * -EINTR - If the thread went into the wait-state and was interrupted
249 spin_lock_irqsave(&hdr->access_lock, flags); in zfcp_diag_update_buffer_limited()
252 !__zfcp_diag_test_buffer_age_isfresh(adapter->diagnostics, hdr); in zfcp_diag_update_buffer_limited()
256 if (rc != -EAGAIN) in zfcp_diag_update_buffer_limited()
260 spin_unlock_irqrestore(&hdr->access_lock, flags); in zfcp_diag_update_buffer_limited()