^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * zfcp device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Definitions for handling diagnostics in the the zfcp device driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright IBM Corp. 2018, 2020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef ZFCP_DIAG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define ZFCP_DIAG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "zfcp_fsf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "zfcp_def.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * struct zfcp_diag_header - general part of a diagnostic buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * @access_lock: lock protecting all the data in this buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * @updating: flag showing that an update for this buffer is currently running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * @incomplete: flag showing that the data in @buffer is incomplete.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @timestamp: time in jiffies when the data of this buffer was last captured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * @buffer: implementation-depending data of this buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @buffer_size: size of @buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct zfcp_diag_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) spinlock_t access_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* Flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u64 updating :1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) u64 incomplete :1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) unsigned long timestamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) size_t buffer_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * adapter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @sysfs_established: flag showing that the associated sysfs-group was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * during run of zfcp_adapter_enqueue().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * @max_age: maximum age of data in diagnostic buffers before they need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * refreshed (in ms).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * @port_data: data retrieved using exchange port data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @port_data.header: header with metadata for the cache in @port_data.data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @port_data.data: cached QTCB Bottom of command exchange port data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @config_data: data retrieved using exchange config data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @config_data.header: header with metadata for the cache in @config_data.data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @config_data.data: cached QTCB Bottom of command exchange config data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct zfcp_diag_adapter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u64 sysfs_established :1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) unsigned long max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct zfcp_diag_adapter_port_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct zfcp_diag_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct fsf_qtcb_bottom_port data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) } port_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct zfcp_diag_adapter_config_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct zfcp_diag_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct fsf_qtcb_bottom_config data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) } config_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) const void *const data, const bool incomplete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * Function-Type used in zfcp_diag_update_buffer_limited() for the function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * that does the buffer-implementation dependent work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int zfcp_diag_update_buffer_limited(struct zfcp_adapter *const adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct zfcp_diag_header *const hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) zfcp_diag_update_buffer_func buffer_update);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * zfcp_diag_support_sfp() - Return %true if the @adapter supports reporting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * SFP Data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @adapter: adapter to test the availability of SFP Data reporting for.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #endif /* ZFCP_DIAG_H */