mpt2sas_base.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /*
  2. * This is the Fusion MPT base driver providing common API layer interface
  3. * for access to MPT (Message Passing Technology) firmware.
  4. *
  5. * This code is based on drivers/scsi/mpt2sas/mpt2_base.h
  6. * Copyright (C) 2007-2008 LSI Corporation
  7. * (mailto:DL-MPTFusionLinux@lsi.com)
  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 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * NO WARRANTY
  20. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  21. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  22. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  23. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  24. * solely responsible for determining the appropriateness of using and
  25. * distributing the Program and assumes all risks associated with its
  26. * exercise of rights under this Agreement, including but not limited to
  27. * the risks and costs of program errors, damage to or loss of data,
  28. * programs or equipment, and unavailability or interruption of operations.
  29. * DISCLAIMER OF LIABILITY
  30. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  33. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  36. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program; if not, write to the Free Software
  39. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  40. * USA.
  41. */
  42. #ifndef MPT2SAS_BASE_H_INCLUDED
  43. #define MPT2SAS_BASE_H_INCLUDED
  44. #include "mpi/mpi2_type.h"
  45. #include "mpi/mpi2.h"
  46. #include "mpi/mpi2_ioc.h"
  47. #include "mpi/mpi2_cnfg.h"
  48. #include "mpi/mpi2_init.h"
  49. #include "mpi/mpi2_raid.h"
  50. #include "mpi/mpi2_tool.h"
  51. #include "mpi/mpi2_sas.h"
  52. #include <scsi/scsi.h>
  53. #include <scsi/scsi_cmnd.h>
  54. #include <scsi/scsi_device.h>
  55. #include <scsi/scsi_host.h>
  56. #include <scsi/scsi_tcq.h>
  57. #include <scsi/scsi_transport_sas.h>
  58. #include <scsi/scsi_dbg.h>
  59. #include "mpt2sas_debug.h"
  60. /* driver versioning info */
  61. #define MPT2SAS_DRIVER_NAME "mpt2sas"
  62. #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
  63. #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
  64. #define MPT2SAS_DRIVER_VERSION "00.100.11.16"
  65. #define MPT2SAS_MAJOR_VERSION 00
  66. #define MPT2SAS_MINOR_VERSION 100
  67. #define MPT2SAS_BUILD_VERSION 11
  68. #define MPT2SAS_RELEASE_VERSION 16
  69. /*
  70. * Set MPT2SAS_SG_DEPTH value based on user input.
  71. */
  72. #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
  73. #if CONFIG_SCSI_MPT2SAS_MAX_SGE < 16
  74. #define MPT2SAS_SG_DEPTH 16
  75. #elif CONFIG_SCSI_MPT2SAS_MAX_SGE > 128
  76. #define MPT2SAS_SG_DEPTH 128
  77. #else
  78. #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
  79. #endif
  80. #else
  81. #define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
  82. #endif
  83. /*
  84. * Generic Defines
  85. */
  86. #define MPT2SAS_SATA_QUEUE_DEPTH 32
  87. #define MPT2SAS_SAS_QUEUE_DEPTH 254
  88. #define MPT2SAS_RAID_QUEUE_DEPTH 128
  89. #define MPT_NAME_LENGTH 32 /* generic length of strings */
  90. #define MPT_STRING_LENGTH 64
  91. #define MPT_MAX_CALLBACKS 16
  92. #define CAN_SLEEP 1
  93. #define NO_SLEEP 0
  94. #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
  95. #define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
  96. #define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
  97. /*
  98. * reset phases
  99. */
  100. #define MPT2_IOC_PRE_RESET 1 /* prior to host reset */
  101. #define MPT2_IOC_AFTER_RESET 2 /* just after host reset */
  102. #define MPT2_IOC_DONE_RESET 3 /* links re-initialized */
  103. /*
  104. * logging format
  105. */
  106. #define MPT2SAS_FMT "%s: "
  107. #define MPT2SAS_DEBUG_FMT KERN_DEBUG MPT2SAS_FMT
  108. #define MPT2SAS_INFO_FMT KERN_INFO MPT2SAS_FMT
  109. #define MPT2SAS_NOTE_FMT KERN_NOTICE MPT2SAS_FMT
  110. #define MPT2SAS_WARN_FMT KERN_WARNING MPT2SAS_FMT
  111. #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT
  112. /*
  113. * per target private data
  114. */
  115. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  116. #define MPT_TARGET_FLAGS_VOLUME 0x02
  117. #define MPT_TARGET_FLAGS_DELETED 0x04
  118. /**
  119. * struct MPT2SAS_TARGET - starget private hostdata
  120. * @starget: starget object
  121. * @sas_address: target sas address
  122. * @handle: device handle
  123. * @num_luns: number luns
  124. * @flags: MPT_TARGET_FLAGS_XXX flags
  125. * @deleted: target flaged for deletion
  126. * @tm_busy: target is busy with TM request.
  127. */
  128. struct MPT2SAS_TARGET {
  129. struct scsi_target *starget;
  130. u64 sas_address;
  131. u16 handle;
  132. int num_luns;
  133. u32 flags;
  134. u8 deleted;
  135. u8 tm_busy;
  136. };
  137. /*
  138. * per device private data
  139. */
  140. #define MPT_DEVICE_FLAGS_INIT 0x01
  141. #define MPT_DEVICE_TLR_ON 0x02
  142. /**
  143. * struct MPT2SAS_DEVICE - sdev private hostdata
  144. * @sas_target: starget private hostdata
  145. * @lun: lun number
  146. * @flags: MPT_DEVICE_XXX flags
  147. * @configured_lun: lun is configured
  148. * @block: device is in SDEV_BLOCK state
  149. * @tlr_snoop_check: flag used in determining whether to disable TLR
  150. */
  151. struct MPT2SAS_DEVICE {
  152. struct MPT2SAS_TARGET *sas_target;
  153. unsigned int lun;
  154. u32 flags;
  155. u8 configured_lun;
  156. u8 block;
  157. u8 tlr_snoop_check;
  158. };
  159. #define MPT2_CMD_NOT_USED 0x8000 /* free */
  160. #define MPT2_CMD_COMPLETE 0x0001 /* completed */
  161. #define MPT2_CMD_PENDING 0x0002 /* pending */
  162. #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
  163. #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
  164. /**
  165. * struct _internal_cmd - internal commands struct
  166. * @mutex: mutex
  167. * @done: completion
  168. * @reply: reply message pointer
  169. * @status: MPT2_CMD_XXX status
  170. * @smid: system message id
  171. */
  172. struct _internal_cmd {
  173. struct mutex mutex;
  174. struct completion done;
  175. void *reply;
  176. u16 status;
  177. u16 smid;
  178. };
  179. /*
  180. * SAS Topology Structures
  181. */
  182. /**
  183. * struct _sas_device - attached device information
  184. * @list: sas device list
  185. * @starget: starget object
  186. * @sas_address: device sas address
  187. * @device_name: retrieved from the SAS IDENTIFY frame.
  188. * @handle: device handle
  189. * @parent_handle: handle to parent device
  190. * @enclosure_handle: enclosure handle
  191. * @enclosure_logical_id: enclosure logical identifier
  192. * @volume_handle: volume handle (valid when hidden raid member)
  193. * @volume_wwid: volume unique identifier
  194. * @device_info: bitfield provides detailed info about the device
  195. * @id: target id
  196. * @channel: target channel
  197. * @slot: number number
  198. * @hidden_raid_component: set to 1 when this is a raid member
  199. * @responding: used in _scsih_sas_device_mark_responding
  200. */
  201. struct _sas_device {
  202. struct list_head list;
  203. struct scsi_target *starget;
  204. u64 sas_address;
  205. u64 device_name;
  206. u16 handle;
  207. u16 parent_handle;
  208. u16 enclosure_handle;
  209. u64 enclosure_logical_id;
  210. u16 volume_handle;
  211. u64 volume_wwid;
  212. u32 device_info;
  213. int id;
  214. int channel;
  215. u16 slot;
  216. u8 hidden_raid_component;
  217. u8 responding;
  218. };
  219. /**
  220. * struct _raid_device - raid volume link list
  221. * @list: sas device list
  222. * @starget: starget object
  223. * @sdev: scsi device struct (volumes are single lun)
  224. * @wwid: unique identifier for the volume
  225. * @handle: device handle
  226. * @id: target id
  227. * @channel: target channel
  228. * @volume_type: the raid level
  229. * @device_info: bitfield provides detailed info about the hidden components
  230. * @num_pds: number of hidden raid components
  231. * @responding: used in _scsih_raid_device_mark_responding
  232. */
  233. struct _raid_device {
  234. struct list_head list;
  235. struct scsi_target *starget;
  236. struct scsi_device *sdev;
  237. u64 wwid;
  238. u16 handle;
  239. int id;
  240. int channel;
  241. u8 volume_type;
  242. u32 device_info;
  243. u8 num_pds;
  244. u8 responding;
  245. };
  246. /**
  247. * struct _boot_device - boot device info
  248. * @is_raid: flag to indicate whether this is volume
  249. * @device: holds pointer for either struct _sas_device or
  250. * struct _raid_device
  251. */
  252. struct _boot_device {
  253. u8 is_raid;
  254. void *device;
  255. };
  256. /**
  257. * struct _sas_port - wide/narrow sas port information
  258. * @port_list: list of ports belonging to expander
  259. * @handle: device handle for this port
  260. * @sas_address: sas address of this port
  261. * @num_phys: number of phys belonging to this port
  262. * @remote_identify: attached device identification
  263. * @rphy: sas transport rphy object
  264. * @port: sas transport wide/narrow port object
  265. * @phy_list: _sas_phy list objects belonging to this port
  266. */
  267. struct _sas_port {
  268. struct list_head port_list;
  269. u16 handle;
  270. u64 sas_address;
  271. u8 num_phys;
  272. struct sas_identify remote_identify;
  273. struct sas_rphy *rphy;
  274. struct sas_port *port;
  275. struct list_head phy_list;
  276. };
  277. /**
  278. * struct _sas_phy - phy information
  279. * @port_siblings: list of phys belonging to a port
  280. * @identify: phy identification
  281. * @remote_identify: attached device identification
  282. * @phy: sas transport phy object
  283. * @phy_id: unique phy id
  284. * @handle: device handle for this phy
  285. * @attached_handle: device handle for attached device
  286. */
  287. struct _sas_phy {
  288. struct list_head port_siblings;
  289. struct sas_identify identify;
  290. struct sas_identify remote_identify;
  291. struct sas_phy *phy;
  292. u8 phy_id;
  293. u16 handle;
  294. u16 attached_handle;
  295. };
  296. /**
  297. * struct _sas_node - sas_host/expander information
  298. * @list: list of expanders
  299. * @parent_dev: parent device class
  300. * @num_phys: number phys belonging to this sas_host/expander
  301. * @sas_address: sas address of this sas_host/expander
  302. * @handle: handle for this sas_host/expander
  303. * @parent_handle: parent handle
  304. * @enclosure_handle: handle for this a member of an enclosure
  305. * @device_info: bitwise defining capabilities of this sas_host/expander
  306. * @responding: used in _scsih_expander_device_mark_responding
  307. * @phy: a list of phys that make up this sas_host/expander
  308. * @sas_port_list: list of ports attached to this sas_host/expander
  309. */
  310. struct _sas_node {
  311. struct list_head list;
  312. struct device *parent_dev;
  313. u8 num_phys;
  314. u64 sas_address;
  315. u16 handle;
  316. u16 parent_handle;
  317. u16 enclosure_handle;
  318. u64 enclosure_logical_id;
  319. u8 responding;
  320. struct _sas_phy *phy;
  321. struct list_head sas_port_list;
  322. };
  323. /**
  324. * enum reset_type - reset state
  325. * @FORCE_BIG_HAMMER: issue diagnostic reset
  326. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  327. */
  328. enum reset_type {
  329. FORCE_BIG_HAMMER,
  330. SOFT_RESET,
  331. };
  332. /**
  333. * struct request_tracker - firmware request tracker
  334. * @smid: system message id
  335. * @scmd: scsi request pointer
  336. * @cb_idx: callback index
  337. * @chain_list: list of chains associated to this IO
  338. * @tracker_list: list of free request (ioc->free_list)
  339. */
  340. struct request_tracker {
  341. u16 smid;
  342. struct scsi_cmnd *scmd;
  343. u8 cb_idx;
  344. struct list_head tracker_list;
  345. };
  346. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  347. /**
  348. * struct MPT2SAS_ADAPTER - per adapter struct
  349. * @list: ioc_list
  350. * @shost: shost object
  351. * @id: unique adapter id
  352. * @pci_irq: irq number
  353. * @name: generic ioc string
  354. * @tmp_string: tmp string used for logging
  355. * @pdev: pci pdev object
  356. * @chip: memory mapped register space
  357. * @chip_phys: physical addrss prior to mapping
  358. * @pio_chip: I/O mapped register space
  359. * @logging_level: see mpt2sas_debug.h
  360. * @ir_firmware: IR firmware present
  361. * @bars: bitmask of BAR's that must be configured
  362. * @mask_interrupts: ignore interrupt
  363. * @fault_reset_work_q_name: fw fault work queue
  364. * @fault_reset_work_q: ""
  365. * @fault_reset_work: ""
  366. * @firmware_event_name: fw event work queue
  367. * @firmware_event_thread: ""
  368. * @fw_events_off: flag to turn off fw event handling
  369. * @fw_event_lock:
  370. * @fw_event_list: list of fw events
  371. * @aen_event_read_flag: event log was read
  372. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  373. * @ioc_reset_in_progress: host reset in progress
  374. * @ioc_reset_in_progress_lock:
  375. * @ioc_link_reset_in_progress: phy/hard reset in progress
  376. * @ignore_loginfos: ignore loginfos during task managment
  377. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  378. * @wait_for_port_enable_to_complete:
  379. * @msix_enable: flag indicating msix is enabled
  380. * @msix_vector_count: number msix vectors
  381. * @msix_table: virt address to the msix table
  382. * @msix_table_backup: backup msix table
  383. * @scsi_io_cb_idx: shost generated commands
  384. * @tm_cb_idx: task management commands
  385. * @transport_cb_idx: transport internal commands
  386. * @ctl_cb_idx: clt internal commands
  387. * @base_cb_idx: base internal commands
  388. * @config_cb_idx: base internal commands
  389. * @base_cmds:
  390. * @transport_cmds:
  391. * @tm_cmds:
  392. * @ctl_cmds:
  393. * @config_cmds:
  394. * @base_add_sg_single: handler for either 32/64 bit sgl's
  395. * @event_type: bits indicating which events to log
  396. * @event_context: unique id for each logged event
  397. * @event_log: event log pointer
  398. * @event_masks: events that are masked
  399. * @facts: static facts data
  400. * @pfacts: static port facts data
  401. * @manu_pg0: static manufacturing page 0
  402. * @bios_pg2: static bios page 2
  403. * @bios_pg3: static bios page 3
  404. * @ioc_pg8: static ioc page 8
  405. * @iounit_pg0: static iounit page 0
  406. * @iounit_pg1: static iounit page 1
  407. * @sas_hba: sas host object
  408. * @sas_expander_list: expander object list
  409. * @sas_node_lock:
  410. * @sas_device_list: sas device object list
  411. * @sas_device_init_list: sas device object list (used only at init time)
  412. * @sas_device_lock:
  413. * @io_missing_delay: time for IO completed by fw when PDR enabled
  414. * @device_missing_delay: time for device missing by fw when PDR enabled
  415. * @config_page_sz: config page size
  416. * @config_page: reserve memory for config page payload
  417. * @config_page_dma:
  418. * @sge_size: sg element size for either 32/64 bit
  419. * @request_depth: hba request queue depth
  420. * @request_sz: per request frame size
  421. * @request: pool of request frames
  422. * @request_dma:
  423. * @request_dma_sz:
  424. * @scsi_lookup: firmware request tracker list
  425. * @scsi_lookup_lock:
  426. * @free_list: free list of request
  427. * @chain: pool of chains
  428. * @pending_io_count:
  429. * @reset_wq:
  430. * @chain_dma:
  431. * @max_sges_in_main_message: number sg elements in main message
  432. * @max_sges_in_chain_message: number sg elements per chain
  433. * @chains_needed_per_io: max chains per io
  434. * @chain_offset_value_for_main_message: location 1st sg in main
  435. * @chain_depth: total chains allocated
  436. * @sense: pool of sense
  437. * @sense_dma:
  438. * @sense_dma_pool:
  439. * @reply_depth: hba reply queue depth:
  440. * @reply_sz: per reply frame size:
  441. * @reply: pool of replys:
  442. * @reply_dma:
  443. * @reply_dma_pool:
  444. * @reply_free_queue_depth: reply free depth
  445. * @reply_free: pool for reply free queue (32 bit addr)
  446. * @reply_free_dma:
  447. * @reply_free_dma_pool:
  448. * @reply_free_host_index: tail index in pool to insert free replys
  449. * @reply_post_queue_depth: reply post queue depth
  450. * @reply_post_free: pool for reply post (64bit descriptor)
  451. * @reply_post_free_dma:
  452. * @reply_post_free_dma_pool:
  453. * @reply_post_host_index: head index in the pool where FW completes IO
  454. */
  455. struct MPT2SAS_ADAPTER {
  456. struct list_head list;
  457. struct Scsi_Host *shost;
  458. u8 id;
  459. u32 pci_irq;
  460. char name[MPT_NAME_LENGTH];
  461. char tmp_string[MPT_STRING_LENGTH];
  462. struct pci_dev *pdev;
  463. Mpi2SystemInterfaceRegs_t __iomem *chip;
  464. unsigned long chip_phys;
  465. unsigned long pio_chip;
  466. int logging_level;
  467. u8 ir_firmware;
  468. int bars;
  469. u8 mask_interrupts;
  470. /* fw fault handler */
  471. char fault_reset_work_q_name[20];
  472. struct workqueue_struct *fault_reset_work_q;
  473. struct delayed_work fault_reset_work;
  474. /* fw event handler */
  475. char firmware_event_name[20];
  476. struct workqueue_struct *firmware_event_thread;
  477. u8 fw_events_off;
  478. spinlock_t fw_event_lock;
  479. struct list_head fw_event_list;
  480. /* misc flags */
  481. int aen_event_read_flag;
  482. u8 broadcast_aen_busy;
  483. u8 ioc_reset_in_progress;
  484. u8 shost_recovery;
  485. spinlock_t ioc_reset_in_progress_lock;
  486. u8 ioc_link_reset_in_progress;
  487. u8 ignore_loginfos;
  488. u8 remove_host;
  489. u8 wait_for_port_enable_to_complete;
  490. u8 msix_enable;
  491. u16 msix_vector_count;
  492. u32 *msix_table;
  493. u32 *msix_table_backup;
  494. /* internal commands, callback index */
  495. u8 scsi_io_cb_idx;
  496. u8 tm_cb_idx;
  497. u8 transport_cb_idx;
  498. u8 ctl_cb_idx;
  499. u8 base_cb_idx;
  500. u8 config_cb_idx;
  501. struct _internal_cmd base_cmds;
  502. struct _internal_cmd transport_cmds;
  503. struct _internal_cmd tm_cmds;
  504. struct _internal_cmd ctl_cmds;
  505. struct _internal_cmd config_cmds;
  506. MPT_ADD_SGE base_add_sg_single;
  507. /* event log */
  508. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  509. u32 event_context;
  510. void *event_log;
  511. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  512. /* static config pages */
  513. Mpi2IOCFactsReply_t facts;
  514. Mpi2PortFactsReply_t *pfacts;
  515. Mpi2ManufacturingPage0_t manu_pg0;
  516. Mpi2BiosPage2_t bios_pg2;
  517. Mpi2BiosPage3_t bios_pg3;
  518. Mpi2IOCPage8_t ioc_pg8;
  519. Mpi2IOUnitPage0_t iounit_pg0;
  520. Mpi2IOUnitPage1_t iounit_pg1;
  521. struct _boot_device req_boot_device;
  522. struct _boot_device req_alt_boot_device;
  523. struct _boot_device current_boot_device;
  524. /* sas hba, expander, and device list */
  525. struct _sas_node sas_hba;
  526. struct list_head sas_expander_list;
  527. spinlock_t sas_node_lock;
  528. struct list_head sas_device_list;
  529. struct list_head sas_device_init_list;
  530. spinlock_t sas_device_lock;
  531. struct list_head raid_device_list;
  532. spinlock_t raid_device_lock;
  533. u8 io_missing_delay;
  534. u16 device_missing_delay;
  535. int sas_id;
  536. /* config page */
  537. u16 config_page_sz;
  538. void *config_page;
  539. dma_addr_t config_page_dma;
  540. /* request */
  541. u16 sge_size;
  542. u16 request_depth;
  543. u16 request_sz;
  544. u8 *request;
  545. dma_addr_t request_dma;
  546. u32 request_dma_sz;
  547. struct request_tracker *scsi_lookup;
  548. spinlock_t scsi_lookup_lock;
  549. struct list_head free_list;
  550. int pending_io_count;
  551. wait_queue_head_t reset_wq;
  552. /* chain */
  553. u8 *chain;
  554. dma_addr_t chain_dma;
  555. u16 max_sges_in_main_message;
  556. u16 max_sges_in_chain_message;
  557. u16 chains_needed_per_io;
  558. u16 chain_offset_value_for_main_message;
  559. u16 chain_depth;
  560. /* sense */
  561. u8 *sense;
  562. dma_addr_t sense_dma;
  563. struct dma_pool *sense_dma_pool;
  564. /* reply */
  565. u16 reply_sz;
  566. u8 *reply;
  567. dma_addr_t reply_dma;
  568. struct dma_pool *reply_dma_pool;
  569. /* reply free queue */
  570. u16 reply_free_queue_depth;
  571. u32 *reply_free;
  572. dma_addr_t reply_free_dma;
  573. struct dma_pool *reply_free_dma_pool;
  574. u32 reply_free_host_index;
  575. /* reply post queue */
  576. u16 reply_post_queue_depth;
  577. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  578. dma_addr_t reply_post_free_dma;
  579. struct dma_pool *reply_post_free_dma_pool;
  580. u32 reply_post_host_index;
  581. /* diag buffer support */
  582. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  583. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  584. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  585. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  586. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  587. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  588. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  589. };
  590. typedef void (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID,
  591. u32 reply);
  592. /* base shared API */
  593. extern struct list_head mpt2sas_ioc_list;
  594. int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
  595. void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
  596. int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
  597. void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
  598. int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
  599. enum reset_type type);
  600. void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  601. void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  602. void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
  603. dma_addr_t mpt2sas_base_get_msg_frame_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  604. dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  605. u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  606. void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  607. void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id,
  608. u16 handle);
  609. void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id);
  610. void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  611. u8 vf_id, u16 io_index);
  612. void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 vf_id);
  613. void mpt2sas_base_initialize_callback_handler(void);
  614. u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  615. void mpt2sas_base_release_callback_handler(u8 cb_idx);
  616. void mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
  617. void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
  618. u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
  619. void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
  620. int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
  621. Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
  622. *mpi_request);
  623. int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
  624. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  625. void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
  626. /* scsih shared API */
  627. void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
  628. u8 type, u16 smid_task, ulong timeout);
  629. void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  630. void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  631. struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
  632. u16 handle);
  633. struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
  634. *ioc, u64 sas_address);
  635. struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
  636. struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  637. void mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply);
  638. void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  639. /* config shared API */
  640. void mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
  641. int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
  642. int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
  643. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  644. int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  645. *mpi_reply, Mpi2BiosPage2_t *config_page);
  646. int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  647. *mpi_reply, Mpi2BiosPage3_t *config_page);
  648. int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  649. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  650. int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  651. *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
  652. int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  653. *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
  654. int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  655. *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
  656. int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  657. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  658. int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  659. *mpi_reply, Mpi2IOUnitPage1_t config_page);
  660. int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  661. *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  662. int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  663. *mpi_reply, Mpi2IOCPage8_t *config_page);
  664. int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  665. *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
  666. int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  667. *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
  668. int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  669. *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
  670. int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  671. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  672. int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  673. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  674. int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  675. *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
  676. int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
  677. int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  678. *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
  679. int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  680. *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
  681. u32 form_specific);
  682. int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
  683. u16 *volume_handle);
  684. int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
  685. u64 *wwid);
  686. /* ctl shared API */
  687. extern struct device_attribute *mpt2sas_host_attrs[];
  688. extern struct device_attribute *mpt2sas_dev_attrs[];
  689. void mpt2sas_ctl_init(void);
  690. void mpt2sas_ctl_exit(void);
  691. void mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
  692. void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  693. void mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID, u32 reply);
  694. void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
  695. Mpi2EventNotificationReply_t *mpi_reply);
  696. /* transport shared API */
  697. void mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID, u32 reply);
  698. struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
  699. u16 handle, u16 parent_handle);
  700. void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
  701. u16 parent_handle);
  702. int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  703. *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  704. int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  705. *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
  706. void mpt2sas_transport_update_phy_link_change(struct MPT2SAS_ADAPTER *ioc, u16 handle,
  707. u16 attached_handle, u8 phy_number, u8 link_rate);
  708. extern struct sas_function_template mpt2sas_transport_functions;
  709. extern struct scsi_transport_template *mpt2sas_transport_template;
  710. #endif /* MPT2SAS_BASE_H_INCLUDED */