1 /* SPDX-License-Identifier: GPL-2.0 */
5 * Definitions for handling diagnostics in the zfcp device driver.
7 * Copyright IBM Corp. 2018, 2020
13 #include <linux/spinlock.h>
19 * struct zfcp_diag_header - general part of a diagnostic buffer.
20 * @access_lock: lock protecting all the data in this buffer.
21 * @updating: flag showing that an update for this buffer is currently running.
22 * @incomplete: flag showing that the data in @buffer is incomplete.
23 * @timestamp: time in jiffies when the data of this buffer was last captured.
24 * @buffer: implementation-depending data of this buffer
25 * @buffer_size: size of @buffer
27 struct zfcp_diag_header {
28 spinlock_t access_lock;
34 unsigned long timestamp;
41 * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
43 * @max_age: maximum age of data in diagnostic buffers before they need to be
45 * @port_data: data retrieved using exchange port data.
46 * @port_data.header: header with metadata for the cache in @port_data.data.
47 * @port_data.data: cached QTCB Bottom of command exchange port data.
48 * @config_data: data retrieved using exchange config data.
49 * @config_data.header: header with metadata for the cache in @config_data.data.
50 * @config_data.data: cached QTCB Bottom of command exchange config data.
52 struct zfcp_diag_adapter {
53 unsigned long max_age;
55 struct zfcp_diag_adapter_port_data {
56 struct zfcp_diag_header header;
57 struct fsf_qtcb_bottom_port data;
59 struct zfcp_diag_adapter_config_data {
60 struct zfcp_diag_header header;
61 struct fsf_qtcb_bottom_config data;
65 int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
66 void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
68 void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
69 const void *const data, const bool incomplete);
72 * Function-Type used in zfcp_diag_update_buffer_limited() for the function
73 * that does the buffer-implementation dependent work.
75 typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
77 int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
78 int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
79 int zfcp_diag_update_buffer_limited(struct zfcp_adapter *const adapter,
80 struct zfcp_diag_header *const hdr,
81 zfcp_diag_update_buffer_func buffer_update);
84 * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
86 * @adapter: adapter to test the availability of SFP Data reporting for.
89 zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
91 return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
94 #endif /* ZFCP_DIAG_H */