linux/drivers/s390/scsi/zfcp_diag.h
<<
>>
Prefs
   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, 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 */
  27struct 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 * @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.
  53 */
  54struct zfcp_diag_adapter {
  55        u64     sysfs_established       :1;
  56
  57        unsigned long   max_age;
  58
  59        struct zfcp_diag_adapter_port_data {
  60                struct zfcp_diag_header         header;
  61                struct fsf_qtcb_bottom_port     data;
  62        } port_data;
  63        struct zfcp_diag_adapter_config_data {
  64                struct zfcp_diag_header         header;
  65                struct fsf_qtcb_bottom_config   data;
  66        } config_data;
  67};
  68
  69int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
  70void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
  71
  72int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
  73void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
  74
  75void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
  76                            const void *const data, const bool incomplete);
  77
  78/*
  79 * Function-Type used in zfcp_diag_update_buffer_limited() for the function
  80 * that does the buffer-implementation dependent work.
  81 */
  82typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
  83
  84int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
  85int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
  86int 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);
  89
  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.
  94 */
  95static inline bool
  96zfcp_diag_support_sfp(const struct zfcp_adapter *const adapter)
  97{
  98        return !!(adapter->adapter_features & FSF_FEATURE_REPORT_SFP_DATA);
  99}
 100
 101#endif /* ZFCP_DIAG_H */
 102