| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* |
| 3 |
* zfcp device driver |
| 4 |
* |
| 5 |
* Definitions for handling diagnostics in the zfcp device driver. |
| 6 |
* |
| 7 |
* Copyright IBM Corp. 2018, 2020 |
| 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 |
* @max_age: maximum age of data in diagnostic buffers before they need to be |
| 44 |
* refreshed (in ms). |
| 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 |
unsigned long max_age; |
| 54 |
|
| 55 |
struct zfcp_diag_adapter_port_data { |
| 56 |
struct zfcp_diag_header header; |
| 57 |
struct fsf_qtcb_bottom_port data; |
| 58 |
} port_data; |
| 59 |
struct zfcp_diag_adapter_config_data { |
| 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 |
void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr, |
| 69 |
const void *const data, const bool incomplete); |
| 70 |
|
| 71 |
/* |
| 72 |
* Function-Type used in zfcp_diag_update_buffer_limited() for the function |
| 73 |
* that does the buffer-implementation dependent work. |
| 74 |
*/ |
| 75 |
typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter); |
| 76 |
|
| 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); |
| 82 |
|
| 83 |
/** |
| 84 |
* zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting |
| 85 |
* SFP Data. |
| 86 |
* @adapter: adapter to test the availability of SFP Data reporting for. |
| 87 |
*/ |
| 88 |
static inline bool |
| 89 |
zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter) |
| 90 |
{ |
| 91 |
return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA); |
| 92 |
} |
| 93 |
|
| 94 |
#endif /* ZFCP_DIAG_H */ |