xref: /openbmc/linux/drivers/s390/scsi/zfcp_diag.h (revision 6028f7c4)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * zfcp device driver
4  *
5  * Definitions for handling diagnostics in the the zfcp device driver.
6  *
7  * Copyright IBM Corp. 2018
8  */
9 
10 #ifndef ZFCP_DIAG_H
11 #define ZFCP_DIAG_H
12 
13 #include <linux/spinlock.h>
14 
15 #include "zfcp_fsf.h"
16 #include "zfcp_def.h"
17 
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
26  */
27 struct zfcp_diag_header {
28 	spinlock_t	access_lock;
29 
30 	/* Flags */
31 	u64		updating	:1;
32 	u64		incomplete	:1;
33 
34 	unsigned long	timestamp;
35 
36 	void		*buffer;
37 	size_t		buffer_size;
38 };
39 
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  * @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.
51  */
52 struct zfcp_diag_adapter {
53 	u64	sysfs_established	:1;
54 
55 	struct {
56 		struct zfcp_diag_header		header;
57 		struct fsf_qtcb_bottom_port	data;
58 	} port_data;
59 	struct {
60 		struct zfcp_diag_header		header;
61 		struct fsf_qtcb_bottom_config	data;
62 	} config_data;
63 };
64 
65 int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
66 void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
67 
68 int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
69 void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
70 
71 void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
72 			    const void *const data, const bool incomplete);
73 
74 /**
75  * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
76  *			     SFP Data.
77  * @adapter: adapter to test the availability of SFP Data reporting for.
78  */
79 static inline bool
80 zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
81 {
82 	return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
83 }
84 
85 #endif /* ZFCP_DIAG_H */
86