megaraid_mbox.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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.5.1"
  20. #define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 16 15:32:35 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 PCI_SUBSYS_ID_CERC_ATA100_4CH 0x0511
  65. #define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel
  66. #define MBOX_MAX_USER_CMDS 32 // number of cmds for applications
  67. #define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun
  68. #define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw
  69. #define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size
  70. #define MBOX_MAX_SECTORS 128 // maximum sectors per IO
  71. #define MBOX_TIMEOUT 30 // timeout value for internal cmds
  72. #define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox
  73. #define MBOX_RESET_WAIT 180 // wait these many seconds in reset
  74. #define MBOX_RESET_EXT_WAIT 120 // extended wait reset
  75. #define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode
  76. #define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds
  77. /*
  78. * maximum transfer that can happen through the firmware commands issued
  79. * internnaly from the driver.
  80. */
  81. #define MBOX_IBUF_SIZE 4096
  82. /**
  83. * mbox_ccb_t - command control block specific to mailbox based controllers
  84. * @raw_mbox : raw mailbox pointer
  85. * @mbox : mailbox
  86. * @mbox64 : extended mailbox
  87. * @mbox_dma_h : maibox dma address
  88. * @sgl64 : 64-bit scatter-gather list
  89. * @sgl32 : 32-bit scatter-gather list
  90. * @sgl_dma_h : dma handle for the scatter-gather list
  91. * @pthru : passthru structure
  92. * @pthru_dma_h : dma handle for the passthru structure
  93. * @epthru : extended passthru structure
  94. * @epthru_dma_h : dma handle for extended passthru structure
  95. * @buf_dma_h : dma handle for buffers w/o sg list
  96. *
  97. * command control block specific to the mailbox based controllers
  98. */
  99. typedef struct {
  100. uint8_t *raw_mbox;
  101. mbox_t *mbox;
  102. mbox64_t *mbox64;
  103. dma_addr_t mbox_dma_h;
  104. mbox_sgl64 *sgl64;
  105. mbox_sgl32 *sgl32;
  106. dma_addr_t sgl_dma_h;
  107. mraid_passthru_t *pthru;
  108. dma_addr_t pthru_dma_h;
  109. mraid_epassthru_t *epthru;
  110. dma_addr_t epthru_dma_h;
  111. dma_addr_t buf_dma_h;
  112. } mbox_ccb_t;
  113. /**
  114. * mraid_device_t - adapter soft state structure for mailbox controllers
  115. * @una_mbox64 : 64-bit mbox - unaligned
  116. * @una_mbox64_dma : mbox dma addr - unaligned
  117. * @mbox : 32-bit mbox - aligned
  118. * @mbox64 : 64-bit mbox - aligned
  119. * @mbox_dma : mbox dma addr - aligned
  120. * @mailbox_lock : exclusion lock for the mailbox
  121. * @baseport : base port of hba memory
  122. * @baseaddr : mapped addr of hba memory
  123. * @mbox_pool : pool of mailboxes
  124. * @mbox_pool_handle : handle for the mailbox pool memory
  125. * @epthru_pool : a pool for extended passthru commands
  126. * @epthru_pool_handle : handle to the pool above
  127. * @sg_pool : pool of scatter-gather lists for this driver
  128. * @sg_pool_handle : handle to the pool above
  129. * @ccb_list : list of our command control blocks
  130. * @uccb_list : list of cmd control blocks for mgmt module
  131. * @umbox64 : array of mailbox for user commands (cmm)
  132. * @pdrv_state : array for state of each physical drive.
  133. * @last_disp : flag used to show device scanning
  134. * @hw_error : set if FW not responding
  135. * @fast_load : If set, skip physical device scanning
  136. * @channel_class : channel class, RAID or SCSI
  137. * @sysfs_mtx : mutex to serialize access to sysfs res.
  138. * @sysfs_uioc : management packet to issue FW calls from sysfs
  139. * @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs
  140. * @sysfs_buffer : data buffer for FW commands issued from sysfs
  141. * @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs
  142. * @sysfs_wait_q : wait queue for sysfs operations
  143. * @random_del_supported : set if the random deletion is supported
  144. * @curr_ldmap : current LDID map
  145. *
  146. * Initialization structure for mailbox controllers: memory based and IO based
  147. * All the fields in this structure are LLD specific and may be discovered at
  148. * init() or start() time.
  149. *
  150. * NOTE: The fields of this structures are placed to minimize cache misses
  151. */
  152. #define MAX_LD_EXTENDED64 64
  153. typedef struct {
  154. mbox64_t *una_mbox64;
  155. dma_addr_t una_mbox64_dma;
  156. mbox_t *mbox;
  157. mbox64_t *mbox64;
  158. dma_addr_t mbox_dma;
  159. spinlock_t mailbox_lock;
  160. unsigned long baseport;
  161. void __iomem * baseaddr;
  162. struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS];
  163. struct dma_pool *mbox_pool_handle;
  164. struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS];
  165. struct dma_pool *epthru_pool_handle;
  166. struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS];
  167. struct dma_pool *sg_pool_handle;
  168. mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS];
  169. mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS];
  170. mbox64_t umbox64[MBOX_MAX_USER_CMDS];
  171. uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
  172. uint32_t last_disp;
  173. int hw_error;
  174. int fast_load;
  175. uint8_t channel_class;
  176. struct mutex sysfs_mtx;
  177. uioc_t *sysfs_uioc;
  178. mbox64_t *sysfs_mbox64;
  179. caddr_t sysfs_buffer;
  180. dma_addr_t sysfs_buffer_dma;
  181. wait_queue_head_t sysfs_wait_q;
  182. int random_del_supported;
  183. uint16_t curr_ldmap[MAX_LD_EXTENDED64];
  184. } mraid_device_t;
  185. // route to raid device from adapter
  186. #define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device))
  187. #define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock)
  188. // Find out if this channel is a RAID or SCSI
  189. #define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01)
  190. #define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20)
  191. #define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C)
  192. #define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20)
  193. #define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C)
  194. #endif // _MEGARAID_H_
  195. // vim: set ts=8 sw=8 tw=78: