treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / s390 / scsi / zfcp_diag.h
blobb9c93d15f67c76a271c910dc3b97fdbba95c3de7
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * zfcp device driver
5 * Definitions for handling diagnostics in the the zfcp device driver.
7 * Copyright IBM Corp. 2018
8 */
10 #ifndef ZFCP_DIAG_H
11 #define ZFCP_DIAG_H
13 #include <linux/spinlock.h>
15 #include "zfcp_fsf.h"
16 #include "zfcp_def.h"
18 /**
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;
30 /* Flags */
31 u64 updating :1;
32 u64 incomplete :1;
34 unsigned long timestamp;
36 void *buffer;
37 size_t buffer_size;
40 /**
41 * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
42 * adapter.
43 * @sysfs_established: flag showing that the associated sysfs-group was created
44 * during run of zfcp_adapter_enqueue().
45 * @max_age: maximum age of data in diagnostic buffers before they need to be
46 * refreshed (in ms).
47 * @port_data: data retrieved using exchange port data.
48 * @port_data.header: header with metadata for the cache in @port_data.data.
49 * @port_data.data: cached QTCB Bottom of command exchange port data.
50 * @config_data: data retrieved using exchange config data.
51 * @config_data.header: header with metadata for the cache in @config_data.data.
52 * @config_data.data: cached QTCB Bottom of command exchange config data.
54 struct zfcp_diag_adapter {
55 u64 sysfs_established :1;
57 unsigned long max_age;
59 struct {
60 struct zfcp_diag_header header;
61 struct fsf_qtcb_bottom_port data;
62 } port_data;
63 struct {
64 struct zfcp_diag_header header;
65 struct fsf_qtcb_bottom_config data;
66 } config_data;
69 int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
70 void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
72 int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
73 void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
75 void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
76 const void *const data, const bool incomplete);
79 * Function-Type used in zfcp_diag_update_buffer_limited() for the function
80 * that does the buffer-implementation dependent work.
82 typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
84 int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
85 int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
86 int zfcp_diag_update_buffer_limited(struct zfcp_adapter *const adapter,
87 struct zfcp_diag_header *const hdr,
88 zfcp_diag_update_buffer_func buffer_update);
90 /**
91 * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
92 * SFP Data.
93 * @adapter: adapter to test the availability of SFP Data reporting for.
95 static inline bool
96 zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
98 return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
101 #endif /* ZFCP_DIAG_H */