Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * zfcp device driver
0004  *
0005  * Definitions for handling diagnostics in the zfcp device driver.
0006  *
0007  * Copyright IBM Corp. 2018, 2020
0008  */
0009 
0010 #ifndef ZFCP_DIAG_H
0011 #define ZFCP_DIAG_H
0012 
0013 #include <linux/spinlock.h>
0014 
0015 #include "zfcp_fsf.h"
0016 #include "zfcp_def.h"
0017 
0018 /**
0019  * struct zfcp_diag_header - general part of a diagnostic buffer.
0020  * @access_lock: lock protecting all the data in this buffer.
0021  * @updating: flag showing that an update for this buffer is currently running.
0022  * @incomplete: flag showing that the data in @buffer is incomplete.
0023  * @timestamp: time in jiffies when the data of this buffer was last captured.
0024  * @buffer: implementation-depending data of this buffer
0025  * @buffer_size: size of @buffer
0026  */
0027 struct zfcp_diag_header {
0028     spinlock_t  access_lock;
0029 
0030     /* Flags */
0031     u64     updating    :1;
0032     u64     incomplete  :1;
0033 
0034     unsigned long   timestamp;
0035 
0036     void        *buffer;
0037     size_t      buffer_size;
0038 };
0039 
0040 /**
0041  * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
0042  *                adapter.
0043  * @max_age: maximum age of data in diagnostic buffers before they need to be
0044  *       refreshed (in ms).
0045  * @port_data: data retrieved using exchange port data.
0046  * @port_data.header: header with metadata for the cache in @port_data.data.
0047  * @port_data.data: cached QTCB Bottom of command exchange port data.
0048  * @config_data: data retrieved using exchange config data.
0049  * @config_data.header: header with metadata for the cache in @config_data.data.
0050  * @config_data.data: cached QTCB Bottom of command exchange config data.
0051  */
0052 struct zfcp_diag_adapter {
0053     unsigned long   max_age;
0054 
0055     struct zfcp_diag_adapter_port_data {
0056         struct zfcp_diag_header     header;
0057         struct fsf_qtcb_bottom_port data;
0058     } port_data;
0059     struct zfcp_diag_adapter_config_data {
0060         struct zfcp_diag_header     header;
0061         struct fsf_qtcb_bottom_config   data;
0062     } config_data;
0063 };
0064 
0065 int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
0066 void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
0067 
0068 void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
0069                 const void *const data, const bool incomplete);
0070 
0071 /*
0072  * Function-Type used in zfcp_diag_update_buffer_limited() for the function
0073  * that does the buffer-implementation dependent work.
0074  */
0075 typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
0076 
0077 int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
0078 int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
0079 int zfcp_diag_update_buffer_limited(struct zfcp_adapter *const adapter,
0080                     struct zfcp_diag_header *const hdr,
0081                     zfcp_diag_update_buffer_func buffer_update);
0082 
0083 /**
0084  * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
0085  *               SFP Data.
0086  * @adapter: adapter to test the availability of SFP Data reporting for.
0087  */
0088 static inline bool
0089 zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
0090 {
0091     return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
0092 }
0093 
0094 #endif /* ZFCP_DIAG_H */