main.h 3.4 KB

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