main.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * CXL Flash Device Driver
  4. *
  5. * Written by: Manoj N. Kumar <[email protected]>, IBM Corporation
  6. * Matthew R. Ochs <[email protected]>, IBM Corporation
  7. *
  8. * Copyright (C) 2015 IBM Corporation
  9. */
  10. #ifndef _CXLFLASH_MAIN_H
  11. #define _CXLFLASH_MAIN_H
  12. #include <linux/list.h>
  13. #include <linux/types.h>
  14. #include <scsi/scsi.h>
  15. #include <scsi/scsi_device.h>
  16. #include "backend.h"
  17. #define CXLFLASH_NAME "cxlflash"
  18. #define CXLFLASH_ADAPTER_NAME "IBM POWER CXL Flash Adapter"
  19. #define CXLFLASH_MAX_ADAPTERS 32
  20. #define PCI_DEVICE_ID_IBM_CORSA 0x04F0
  21. #define PCI_DEVICE_ID_IBM_FLASH_GT 0x0600
  22. #define PCI_DEVICE_ID_IBM_BRIARD 0x0624
  23. /* Since there is only one target, make it 0 */
  24. #define CXLFLASH_TARGET 0
  25. #define CXLFLASH_MAX_CDB_LEN 16
  26. /* Really only one target per bus since the Texan is directly attached */
  27. #define CXLFLASH_MAX_NUM_TARGETS_PER_BUS 1
  28. #define CXLFLASH_MAX_NUM_LUNS_PER_TARGET 65536
  29. #define CXLFLASH_PCI_ERROR_RECOVERY_TIMEOUT (120 * HZ)
  30. /* FC defines */
  31. #define FC_MTIP_CMDCONFIG 0x010
  32. #define FC_MTIP_STATUS 0x018
  33. #define FC_MAX_NUM_LUNS 0x080 /* Max LUNs host can provision for port */
  34. #define FC_CUR_NUM_LUNS 0x088 /* Cur number LUNs provisioned for port */
  35. #define FC_MAX_CAP_PORT 0x090 /* Max capacity all LUNs for port (4K blocks) */
  36. #define FC_CUR_CAP_PORT 0x098 /* Cur capacity all LUNs for port (4K blocks) */
  37. #define FC_PNAME 0x300
  38. #define FC_CONFIG 0x320
  39. #define FC_CONFIG2 0x328
  40. #define FC_STATUS 0x330
  41. #define FC_ERROR 0x380
  42. #define FC_ERRCAP 0x388
  43. #define FC_ERRMSK 0x390
  44. #define FC_CNT_CRCERR 0x538
  45. #define FC_CRC_THRESH 0x580
  46. #define FC_MTIP_CMDCONFIG_ONLINE 0x20ULL
  47. #define FC_MTIP_CMDCONFIG_OFFLINE 0x40ULL
  48. #define FC_MTIP_STATUS_MASK 0x30ULL
  49. #define FC_MTIP_STATUS_ONLINE 0x20ULL
  50. #define FC_MTIP_STATUS_OFFLINE 0x10ULL
  51. /* TIMEOUT and RETRY definitions */
  52. /* AFU command timeout values */
  53. #define MC_AFU_SYNC_TIMEOUT 5 /* 5 secs */
  54. #define MC_LUN_PROV_TIMEOUT 5 /* 5 secs */
  55. #define MC_AFU_DEBUG_TIMEOUT 5 /* 5 secs */
  56. /* AFU command room retry limit */
  57. #define MC_ROOM_RETRY_CNT 10
  58. /* FC CRC clear periodic timer */
  59. #define MC_CRC_THRESH 100 /* threshold in 5 mins */
  60. #define FC_PORT_STATUS_RETRY_CNT 100 /* 100 100ms retries = 10 seconds */
  61. #define FC_PORT_STATUS_RETRY_INTERVAL_US 100000 /* microseconds */
  62. /* VPD defines */
  63. #define CXLFLASH_VPD_LEN 256
  64. #define WWPN_LEN 16
  65. #define WWPN_BUF_LEN (WWPN_LEN + 1)
  66. enum undo_level {
  67. UNDO_NOOP = 0,
  68. FREE_IRQ,
  69. UNMAP_ONE,
  70. UNMAP_TWO,
  71. UNMAP_THREE
  72. };
  73. struct dev_dependent_vals {
  74. u64 max_sectors;
  75. u64 flags;
  76. #define CXLFLASH_NOTIFY_SHUTDOWN 0x0000000000000001ULL
  77. #define CXLFLASH_WWPN_VPD_REQUIRED 0x0000000000000002ULL
  78. #define CXLFLASH_OCXL_DEV 0x0000000000000004ULL
  79. };
  80. static inline const struct cxlflash_backend_ops *
  81. cxlflash_assign_ops(struct dev_dependent_vals *ddv)
  82. {
  83. const struct cxlflash_backend_ops *ops = NULL;
  84. #ifdef CONFIG_OCXL_BASE
  85. if (ddv->flags & CXLFLASH_OCXL_DEV)
  86. ops = &cxlflash_ocxl_ops;
  87. #endif
  88. #ifdef CONFIG_CXL_BASE
  89. if (!(ddv->flags & CXLFLASH_OCXL_DEV))
  90. ops = &cxlflash_cxl_ops;
  91. #endif
  92. return ops;
  93. }
  94. struct asyc_intr_info {
  95. u64 status;
  96. char *desc;
  97. u8 port;
  98. u8 action;
  99. #define CLR_FC_ERROR 0x01
  100. #define LINK_RESET 0x02
  101. #define SCAN_HOST 0x04
  102. };
  103. #endif /* _CXLFLASH_MAIN_H */