zfcp_diag.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #ifndef ZFCP_DIAG_H
  10. #define ZFCP_DIAG_H
  11. #include <linux/spinlock.h>
  12. #include "zfcp_fsf.h"
  13. #include "zfcp_def.h"
  14. /**
  15. * struct zfcp_diag_header - general part of a diagnostic buffer.
  16. * @access_lock: lock protecting all the data in this buffer.
  17. * @updating: flag showing that an update for this buffer is currently running.
  18. * @incomplete: flag showing that the data in @buffer is incomplete.
  19. * @timestamp: time in jiffies when the data of this buffer was last captured.
  20. * @buffer: implementation-depending data of this buffer
  21. * @buffer_size: size of @buffer
  22. */
  23. struct zfcp_diag_header {
  24. spinlock_t access_lock;
  25. /* Flags */
  26. u64 updating :1;
  27. u64 incomplete :1;
  28. unsigned long timestamp;
  29. void *buffer;
  30. size_t buffer_size;
  31. };
  32. /**
  33. * struct zfcp_diag_adapter - central storage for all diagnostics concerning an
  34. * adapter.
  35. * @sysfs_established: flag showing that the associated sysfs-group was created
  36. * during run of zfcp_adapter_enqueue().
  37. * @max_age: maximum age of data in diagnostic buffers before they need to be
  38. * refreshed (in ms).
  39. * @port_data: data retrieved using exchange port data.
  40. * @port_data.header: header with metadata for the cache in @port_data.data.
  41. * @port_data.data: cached QTCB Bottom of command exchange port data.
  42. * @config_data: data retrieved using exchange config data.
  43. * @config_data.header: header with metadata for the cache in @config_data.data.
  44. * @config_data.data: cached QTCB Bottom of command exchange config data.
  45. */
  46. struct zfcp_diag_adapter {
  47. u64 sysfs_established :1;
  48. unsigned long max_age;
  49. struct zfcp_diag_adapter_port_data {
  50. struct zfcp_diag_header header;
  51. struct fsf_qtcb_bottom_port data;
  52. } port_data;
  53. struct zfcp_diag_adapter_config_data {
  54. struct zfcp_diag_header header;
  55. struct fsf_qtcb_bottom_config data;
  56. } config_data;
  57. };
  58. int zfcp_diag_adapter_setup(struct zfcp_adapter *const adapter);
  59. void zfcp_diag_adapter_free(struct zfcp_adapter *const adapter);
  60. int zfcp_diag_sysfs_setup(struct zfcp_adapter *const adapter);
  61. void zfcp_diag_sysfs_destroy(struct zfcp_adapter *const adapter);
  62. void zfcp_diag_update_xdata(struct zfcp_diag_header *const hdr,
  63. const void *const data, const bool incomplete);
  64. /*
  65. * Function-Type used in zfcp_diag_update_buffer_limited() for the function
  66. * that does the buffer-implementation dependent work.
  67. */
  68. typedef int (*zfcp_diag_update_buffer_func)(struct zfcp_adapter *const adapter);
  69. int zfcp_diag_update_config_data_buffer(struct zfcp_adapter *const adapter);
  70. int zfcp_diag_update_port_data_buffer(struct zfcp_adapter *const adapter);
  71. int zfcp_diag_update_buffer_limited(struct zfcp_adapter *const adapter,
  72. struct zfcp_diag_header *const hdr,
  73. zfcp_diag_update_buffer_func buffer_update);
  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. #endif /* ZFCP_DIAG_H */