megaraid_mbox.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. *
  3. * Linux MegaRAID device driver
  4. *
  5. * Copyright (c) 2003-2004 LSI Logic Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * FILE : megaraid_mbox.h
  13. */
  14. #ifndef _MEGARAID_H_
  15. #define _MEGARAID_H_
  16. #include "mega_common.h"
  17. #include "mbox_defs.h"
  18. #include "megaraid_ioctl.h"
  19. #define MEGARAID_VERSION "2.20.4.9"
  20. #define MEGARAID_EXT_VERSION "(Release Date: Sun Jul 16 12:27:22 EST 2006)"
  21. /*
  22. * Define some PCI values here until they are put in the kernel
  23. */
  24. #define PCI_DEVICE_ID_PERC4_DI_DISCOVERY 0x000E
  25. #define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY 0x0123
  26. #define PCI_DEVICE_ID_PERC4_SC 0x1960
  27. #define PCI_SUBSYS_ID_PERC4_SC 0x0520
  28. #define PCI_DEVICE_ID_PERC4_DC 0x1960
  29. #define PCI_SUBSYS_ID_PERC4_DC 0x0518
  30. #define PCI_DEVICE_ID_VERDE 0x0407
  31. #define PCI_DEVICE_ID_PERC4_DI_EVERGLADES 0x000F
  32. #define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES 0x014A
  33. #define PCI_DEVICE_ID_PERC4E_SI_BIGBEND 0x0013
  34. #define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND 0x016c
  35. #define PCI_DEVICE_ID_PERC4E_DI_KOBUK 0x0013
  36. #define PCI_SUBSYS_ID_PERC4E_DI_KOBUK 0x016d
  37. #define PCI_DEVICE_ID_PERC4E_DI_CORVETTE 0x0013
  38. #define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE 0x016e
  39. #define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION 0x0013
  40. #define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION 0x016f
  41. #define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE 0x0013
  42. #define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE 0x0170
  43. #define PCI_DEVICE_ID_DOBSON 0x0408
  44. #define PCI_DEVICE_ID_MEGARAID_SCSI_320_0 0x1960
  45. #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0 0xA520
  46. #define PCI_DEVICE_ID_MEGARAID_SCSI_320_1 0x1960
  47. #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1 0x0520
  48. #define PCI_DEVICE_ID_MEGARAID_SCSI_320_2 0x1960
  49. #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2 0x0518
  50. #define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960
  51. #define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522
  52. #define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960
  53. #define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523
  54. #define PCI_DEVICE_ID_MEGARAID_SATA_150_6 0x1960
  55. #define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523
  56. #define PCI_DEVICE_ID_LINDSAY 0x0409
  57. #define PCI_DEVICE_ID_INTEL_RAID_SRCS16 0x1960
  58. #define PCI_SUBSYS_ID_INTEL_RAID_SRCS16 0x0523
  59. #define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x1960
  60. #define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x0520
  61. #define PCI_SUBSYS_ID_PERC3_QC 0x0471
  62. #define PCI_SUBSYS_ID_PERC3_DC 0x0493
  63. #define PCI_SUBSYS_ID_PERC3_SC 0x0475
  64. #define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel
  65. #define MBOX_MAX_USER_CMDS 32 // number of cmds for applications
  66. #define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun
  67. #define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw
  68. #define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size
  69. #define MBOX_MAX_SECTORS 128 // maximum sectors per IO
  70. #define MBOX_TIMEOUT 30 // timeout value for internal cmds
  71. #define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox
  72. #define MBOX_RESET_WAIT 180 // wait these many seconds in reset
  73. #define MBOX_RESET_EXT_WAIT 120 // extended wait reset
  74. #define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode
  75. #define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds
  76. /*
  77. * maximum transfer that can happen through the firmware commands issued
  78. * internnaly from the driver.
  79. */
  80. #define MBOX_IBUF_SIZE 4096
  81. /**
  82. * mbox_ccb_t - command control block specific to mailbox based controllers
  83. * @raw_mbox : raw mailbox pointer
  84. * @mbox : mailbox
  85. * @mbox64 : extended mailbox
  86. * @mbox_dma_h : maibox dma address
  87. * @sgl64 : 64-bit scatter-gather list
  88. * @sgl32 : 32-bit scatter-gather list
  89. * @sgl_dma_h : dma handle for the scatter-gather list
  90. * @pthru : passthru structure
  91. * @pthru_dma_h : dma handle for the passthru structure
  92. * @epthru : extended passthru structure
  93. * @epthru_dma_h : dma handle for extended passthru structure
  94. * @buf_dma_h : dma handle for buffers w/o sg list
  95. *
  96. * command control block specific to the mailbox based controllers
  97. */
  98. typedef struct {
  99. uint8_t *raw_mbox;
  100. mbox_t *mbox;
  101. mbox64_t *mbox64;
  102. dma_addr_t mbox_dma_h;
  103. mbox_sgl64 *sgl64;
  104. mbox_sgl32 *sgl32;
  105. dma_addr_t sgl_dma_h;
  106. mraid_passthru_t *pthru;
  107. dma_addr_t pthru_dma_h;
  108. mraid_epassthru_t *epthru;
  109. dma_addr_t epthru_dma_h;
  110. dma_addr_t buf_dma_h;
  111. } mbox_ccb_t;
  112. /**
  113. * mraid_device_t - adapter soft state structure for mailbox controllers
  114. * @param una_mbox64 : 64-bit mbox - unaligned
  115. * @param una_mbox64_dma : mbox dma addr - unaligned
  116. * @param mbox : 32-bit mbox - aligned
  117. * @param mbox64 : 64-bit mbox - aligned
  118. * @param mbox_dma : mbox dma addr - aligned
  119. * @param mailbox_lock : exclusion lock for the mailbox
  120. * @param baseport : base port of hba memory
  121. * @param baseaddr : mapped addr of hba memory
  122. * @param mbox_pool : pool of mailboxes
  123. * @param mbox_pool_handle : handle for the mailbox pool memory
  124. * @param epthru_pool : a pool for extended passthru commands
  125. * @param epthru_pool_handle : handle to the pool above
  126. * @param sg_pool : pool of scatter-gather lists for this driver
  127. * @param sg_pool_handle : handle to the pool above
  128. * @param ccb_list : list of our command control blocks
  129. * @param uccb_list : list of cmd control blocks for mgmt module
  130. * @param umbox64 : array of mailbox for user commands (cmm)
  131. * @param pdrv_state : array for state of each physical drive.
  132. * @param last_disp : flag used to show device scanning
  133. * @param hw_error : set if FW not responding
  134. * @param fast_load : If set, skip physical device scanning
  135. * @channel_class : channel class, RAID or SCSI
  136. * @sysfs_sem : semaphore to serialize access to sysfs res.
  137. * @sysfs_uioc : management packet to issue FW calls from sysfs
  138. * @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs
  139. * @sysfs_buffer : data buffer for FW commands issued from sysfs
  140. * @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs
  141. * @sysfs_wait_q : wait queue for sysfs operations
  142. * @random_del_supported : set if the random deletion is supported
  143. * @curr_ldmap : current LDID map
  144. *
  145. * Initialization structure for mailbox controllers: memory based and IO based
  146. * All the fields in this structure are LLD specific and may be discovered at
  147. * init() or start() time.
  148. *
  149. * NOTE: The fields of this structures are placed to minimize cache misses
  150. */
  151. #define MAX_LD_EXTENDED64 64
  152. typedef struct {
  153. mbox64_t *una_mbox64;
  154. dma_addr_t una_mbox64_dma;
  155. mbox_t *mbox;
  156. mbox64_t *mbox64;
  157. dma_addr_t mbox_dma;
  158. spinlock_t mailbox_lock;
  159. unsigned long baseport;
  160. void __iomem * baseaddr;
  161. struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS];
  162. struct dma_pool *mbox_pool_handle;
  163. struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS];
  164. struct dma_pool *epthru_pool_handle;
  165. struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS];
  166. struct dma_pool *sg_pool_handle;
  167. mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS];
  168. mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS];
  169. mbox64_t umbox64[MBOX_MAX_USER_CMDS];
  170. uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
  171. uint32_t last_disp;
  172. int hw_error;
  173. int fast_load;
  174. uint8_t channel_class;
  175. struct semaphore sysfs_sem;
  176. uioc_t *sysfs_uioc;
  177. mbox64_t *sysfs_mbox64;
  178. caddr_t sysfs_buffer;
  179. dma_addr_t sysfs_buffer_dma;
  180. wait_queue_head_t sysfs_wait_q;
  181. int random_del_supported;
  182. uint16_t curr_ldmap[MAX_LD_EXTENDED64];
  183. } mraid_device_t;
  184. // route to raid device from adapter
  185. #define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device))
  186. #define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock)
  187. // Find out if this channel is a RAID or SCSI
  188. #define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01)
  189. #define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20)
  190. #define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C)
  191. #define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20)
  192. #define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C)
  193. #endif // _MEGARAID_H_
  194. // vim: set ts=8 sw=8 tw=78: