mpt2sas_base.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  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-2009 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 <scsi/scsi_eh.h>
  60. #include "mpt2sas_debug.h"
  61. /* driver versioning info */
  62. #define MPT2SAS_DRIVER_NAME "mpt2sas"
  63. #define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
  64. #define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
  65. #define MPT2SAS_DRIVER_VERSION "02.100.03.00"
  66. #define MPT2SAS_MAJOR_VERSION 02
  67. #define MPT2SAS_MINOR_VERSION 100
  68. #define MPT2SAS_BUILD_VERSION 03
  69. #define MPT2SAS_RELEASE_VERSION 00
  70. /*
  71. * Set MPT2SAS_SG_DEPTH value based on user input.
  72. */
  73. #ifdef CONFIG_SCSI_MPT2SAS_MAX_SGE
  74. #if CONFIG_SCSI_MPT2SAS_MAX_SGE < 16
  75. #define MPT2SAS_SG_DEPTH 16
  76. #elif CONFIG_SCSI_MPT2SAS_MAX_SGE > 128
  77. #define MPT2SAS_SG_DEPTH 128
  78. #else
  79. #define MPT2SAS_SG_DEPTH CONFIG_SCSI_MPT2SAS_MAX_SGE
  80. #endif
  81. #else
  82. #define MPT2SAS_SG_DEPTH 128 /* MAX_HW_SEGMENTS */
  83. #endif
  84. /*
  85. * Generic Defines
  86. */
  87. #define MPT2SAS_SATA_QUEUE_DEPTH 32
  88. #define MPT2SAS_SAS_QUEUE_DEPTH 254
  89. #define MPT2SAS_RAID_QUEUE_DEPTH 128
  90. #define MPT_NAME_LENGTH 32 /* generic length of strings */
  91. #define MPT_STRING_LENGTH 64
  92. #define MPT_MAX_CALLBACKS 16
  93. #define CAN_SLEEP 1
  94. #define NO_SLEEP 0
  95. #define INTERNAL_CMDS_COUNT 10 /* reserved cmds */
  96. #define MPI2_HIM_MASK 0xFFFFFFFF /* mask every bit*/
  97. #define MPT2SAS_INVALID_DEVICE_HANDLE 0xFFFF
  98. /*
  99. * reset phases
  100. */
  101. #define MPT2_IOC_PRE_RESET 1 /* prior to host reset */
  102. #define MPT2_IOC_AFTER_RESET 2 /* just after host reset */
  103. #define MPT2_IOC_DONE_RESET 3 /* links re-initialized */
  104. #define MPT2_IOC_RUNNING 4 /* shost running */
  105. /*
  106. * logging format
  107. */
  108. #define MPT2SAS_FMT "%s: "
  109. #define MPT2SAS_DEBUG_FMT KERN_DEBUG MPT2SAS_FMT
  110. #define MPT2SAS_INFO_FMT KERN_INFO MPT2SAS_FMT
  111. #define MPT2SAS_NOTE_FMT KERN_NOTICE MPT2SAS_FMT
  112. #define MPT2SAS_WARN_FMT KERN_WARNING MPT2SAS_FMT
  113. #define MPT2SAS_ERR_FMT KERN_ERR MPT2SAS_FMT
  114. /*
  115. * Dell HBA branding
  116. */
  117. #define MPT2SAS_DELL_BRANDING_SIZE 32
  118. #define MPT2SAS_DELL_6GBPS_SAS_HBA_BRANDING "Dell 6Gbps SAS HBA"
  119. #define MPT2SAS_DELL_PERC_H200_ADAPTER_BRANDING "Dell PERC H200 Adapter"
  120. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_BRANDING "Dell PERC H200 Integrated"
  121. #define MPT2SAS_DELL_PERC_H200_MODULAR_BRANDING "Dell PERC H200 Modular"
  122. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_BRANDING "Dell PERC H200 Embedded"
  123. #define MPT2SAS_DELL_PERC_H200_BRANDING "Dell PERC H200"
  124. #define MPT2SAS_DELL_6GBPS_SAS_BRANDING "Dell 6Gbps SAS"
  125. /*
  126. * Dell HBA SSDIDs
  127. */
  128. #define MPT2SAS_DELL_6GBPS_SAS_HBA_SSDID 0x1F1C
  129. #define MPT2SAS_DELL_PERC_H200_ADAPTER_SSDID 0x1F1D
  130. #define MPT2SAS_DELL_PERC_H200_INTEGRATED_SSDID 0x1F1E
  131. #define MPT2SAS_DELL_PERC_H200_MODULAR_SSDID 0x1F1F
  132. #define MPT2SAS_DELL_PERC_H200_EMBEDDED_SSDID 0x1F20
  133. #define MPT2SAS_DELL_PERC_H200_SSDID 0x1F21
  134. #define MPT2SAS_DELL_6GBPS_SAS_SSDID 0x1F22
  135. /*
  136. * per target private data
  137. */
  138. #define MPT_TARGET_FLAGS_RAID_COMPONENT 0x01
  139. #define MPT_TARGET_FLAGS_VOLUME 0x02
  140. #define MPT_TARGET_FLAGS_DELETED 0x04
  141. /**
  142. * struct MPT2SAS_TARGET - starget private hostdata
  143. * @starget: starget object
  144. * @sas_address: target sas address
  145. * @handle: device handle
  146. * @num_luns: number luns
  147. * @flags: MPT_TARGET_FLAGS_XXX flags
  148. * @deleted: target flaged for deletion
  149. * @tm_busy: target is busy with TM request.
  150. */
  151. struct MPT2SAS_TARGET {
  152. struct scsi_target *starget;
  153. u64 sas_address;
  154. u16 handle;
  155. int num_luns;
  156. u32 flags;
  157. u8 deleted;
  158. u8 tm_busy;
  159. };
  160. /*
  161. * per device private data
  162. */
  163. #define MPT_DEVICE_FLAGS_INIT 0x01
  164. #define MPT_DEVICE_TLR_ON 0x02
  165. /**
  166. * struct MPT2SAS_DEVICE - sdev private hostdata
  167. * @sas_target: starget private hostdata
  168. * @lun: lun number
  169. * @flags: MPT_DEVICE_XXX flags
  170. * @configured_lun: lun is configured
  171. * @block: device is in SDEV_BLOCK state
  172. * @tlr_snoop_check: flag used in determining whether to disable TLR
  173. */
  174. /* OEM Identifiers */
  175. #define MFG10_OEM_ID_INVALID (0x00000000)
  176. #define MFG10_OEM_ID_DELL (0x00000001)
  177. #define MFG10_OEM_ID_FSC (0x00000002)
  178. #define MFG10_OEM_ID_SUN (0x00000003)
  179. #define MFG10_OEM_ID_IBM (0x00000004)
  180. /* GENERIC Flags 0*/
  181. #define MFG10_GF0_OCE_DISABLED (0x00000001)
  182. #define MFG10_GF0_R1E_DRIVE_COUNT (0x00000002)
  183. #define MFG10_GF0_R10_DISPLAY (0x00000004)
  184. #define MFG10_GF0_SSD_DATA_SCRUB_DISABLE (0x00000008)
  185. #define MFG10_GF0_SINGLE_DRIVE_R0 (0x00000010)
  186. /* OEM Specific Flags will come from OEM specific header files */
  187. typedef struct _MPI2_CONFIG_PAGE_MAN_10 {
  188. MPI2_CONFIG_PAGE_HEADER Header; /* 00h */
  189. U8 OEMIdentifier; /* 04h */
  190. U8 Reserved1; /* 05h */
  191. U16 Reserved2; /* 08h */
  192. U32 Reserved3; /* 0Ch */
  193. U32 GenericFlags0; /* 10h */
  194. U32 GenericFlags1; /* 14h */
  195. U32 Reserved4; /* 18h */
  196. U32 OEMSpecificFlags0; /* 1Ch */
  197. U32 OEMSpecificFlags1; /* 20h */
  198. U32 Reserved5[18]; /* 24h-60h*/
  199. } MPI2_CONFIG_PAGE_MAN_10,
  200. MPI2_POINTER PTR_MPI2_CONFIG_PAGE_MAN_10,
  201. Mpi2ManufacturingPage10_t, MPI2_POINTER pMpi2ManufacturingPage10_t;
  202. struct MPT2SAS_DEVICE {
  203. struct MPT2SAS_TARGET *sas_target;
  204. unsigned int lun;
  205. u32 flags;
  206. u8 configured_lun;
  207. u8 block;
  208. u8 tlr_snoop_check;
  209. };
  210. #define MPT2_CMD_NOT_USED 0x8000 /* free */
  211. #define MPT2_CMD_COMPLETE 0x0001 /* completed */
  212. #define MPT2_CMD_PENDING 0x0002 /* pending */
  213. #define MPT2_CMD_REPLY_VALID 0x0004 /* reply is valid */
  214. #define MPT2_CMD_RESET 0x0008 /* host reset dropped the command */
  215. /**
  216. * struct _internal_cmd - internal commands struct
  217. * @mutex: mutex
  218. * @done: completion
  219. * @reply: reply message pointer
  220. * @status: MPT2_CMD_XXX status
  221. * @smid: system message id
  222. */
  223. struct _internal_cmd {
  224. struct mutex mutex;
  225. struct completion done;
  226. void *reply;
  227. u16 status;
  228. u16 smid;
  229. };
  230. /*
  231. * SAS Topology Structures
  232. */
  233. #define MPTSAS_STATE_TR_SEND 0x0001
  234. #define MPTSAS_STATE_TR_COMPLETE 0x0002
  235. #define MPTSAS_STATE_CNTRL_SEND 0x0004
  236. #define MPTSAS_STATE_CNTRL_COMPLETE 0x0008
  237. #define MPT2SAS_REQ_SAS_CNTRL 0x0010
  238. /**
  239. * struct _sas_device - attached device information
  240. * @list: sas device list
  241. * @starget: starget object
  242. * @sas_address: device sas address
  243. * @device_name: retrieved from the SAS IDENTIFY frame.
  244. * @handle: device handle
  245. * @sas_address_parent: sas address of parent expander or sas host
  246. * @enclosure_handle: enclosure handle
  247. * @enclosure_logical_id: enclosure logical identifier
  248. * @volume_handle: volume handle (valid when hidden raid member)
  249. * @volume_wwid: volume unique identifier
  250. * @device_info: bitfield provides detailed info about the device
  251. * @id: target id
  252. * @channel: target channel
  253. * @slot: number number
  254. * @hidden_raid_component: set to 1 when this is a raid member
  255. * @responding: used in _scsih_sas_device_mark_responding
  256. */
  257. struct _sas_device {
  258. struct list_head list;
  259. struct scsi_target *starget;
  260. u64 sas_address;
  261. u64 device_name;
  262. u16 handle;
  263. u64 sas_address_parent;
  264. u16 enclosure_handle;
  265. u64 enclosure_logical_id;
  266. u16 volume_handle;
  267. u64 volume_wwid;
  268. u32 device_info;
  269. int id;
  270. int channel;
  271. u16 slot;
  272. u8 hidden_raid_component;
  273. u8 responding;
  274. u16 state;
  275. };
  276. /**
  277. * struct _raid_device - raid volume link list
  278. * @list: sas device list
  279. * @starget: starget object
  280. * @sdev: scsi device struct (volumes are single lun)
  281. * @wwid: unique identifier for the volume
  282. * @handle: device handle
  283. * @id: target id
  284. * @channel: target channel
  285. * @volume_type: the raid level
  286. * @device_info: bitfield provides detailed info about the hidden components
  287. * @num_pds: number of hidden raid components
  288. * @responding: used in _scsih_raid_device_mark_responding
  289. */
  290. struct _raid_device {
  291. struct list_head list;
  292. struct scsi_target *starget;
  293. struct scsi_device *sdev;
  294. u64 wwid;
  295. u16 handle;
  296. int id;
  297. int channel;
  298. u8 volume_type;
  299. u32 device_info;
  300. u8 num_pds;
  301. u8 responding;
  302. };
  303. /**
  304. * struct _boot_device - boot device info
  305. * @is_raid: flag to indicate whether this is volume
  306. * @device: holds pointer for either struct _sas_device or
  307. * struct _raid_device
  308. */
  309. struct _boot_device {
  310. u8 is_raid;
  311. void *device;
  312. };
  313. /**
  314. * struct _sas_port - wide/narrow sas port information
  315. * @port_list: list of ports belonging to expander
  316. * @num_phys: number of phys belonging to this port
  317. * @remote_identify: attached device identification
  318. * @rphy: sas transport rphy object
  319. * @port: sas transport wide/narrow port object
  320. * @phy_list: _sas_phy list objects belonging to this port
  321. */
  322. struct _sas_port {
  323. struct list_head port_list;
  324. u8 num_phys;
  325. struct sas_identify remote_identify;
  326. struct sas_rphy *rphy;
  327. struct sas_port *port;
  328. struct list_head phy_list;
  329. };
  330. /**
  331. * struct _sas_phy - phy information
  332. * @port_siblings: list of phys belonging to a port
  333. * @identify: phy identification
  334. * @remote_identify: attached device identification
  335. * @phy: sas transport phy object
  336. * @phy_id: unique phy id
  337. * @handle: device handle for this phy
  338. * @attached_handle: device handle for attached device
  339. */
  340. struct _sas_phy {
  341. struct list_head port_siblings;
  342. struct sas_identify identify;
  343. struct sas_identify remote_identify;
  344. struct sas_phy *phy;
  345. u8 phy_id;
  346. u16 handle;
  347. u16 attached_handle;
  348. };
  349. /**
  350. * struct _sas_node - sas_host/expander information
  351. * @list: list of expanders
  352. * @parent_dev: parent device class
  353. * @num_phys: number phys belonging to this sas_host/expander
  354. * @sas_address: sas address of this sas_host/expander
  355. * @handle: handle for this sas_host/expander
  356. * @sas_address_parent: sas address of parent expander or sas host
  357. * @enclosure_handle: handle for this a member of an enclosure
  358. * @device_info: bitwise defining capabilities of this sas_host/expander
  359. * @responding: used in _scsih_expander_device_mark_responding
  360. * @phy: a list of phys that make up this sas_host/expander
  361. * @sas_port_list: list of ports attached to this sas_host/expander
  362. */
  363. struct _sas_node {
  364. struct list_head list;
  365. struct device *parent_dev;
  366. u8 num_phys;
  367. u64 sas_address;
  368. u16 handle;
  369. u64 sas_address_parent;
  370. u16 enclosure_handle;
  371. u64 enclosure_logical_id;
  372. u8 responding;
  373. struct _sas_phy *phy;
  374. struct list_head sas_port_list;
  375. };
  376. /**
  377. * enum reset_type - reset state
  378. * @FORCE_BIG_HAMMER: issue diagnostic reset
  379. * @SOFT_RESET: issue message_unit_reset, if fails to to big hammer
  380. */
  381. enum reset_type {
  382. FORCE_BIG_HAMMER,
  383. SOFT_RESET,
  384. };
  385. /**
  386. * struct request_tracker - firmware request tracker
  387. * @smid: system message id
  388. * @scmd: scsi request pointer
  389. * @cb_idx: callback index
  390. * @chain_list: list of chains associated to this IO
  391. * @tracker_list: list of free request (ioc->free_list)
  392. */
  393. struct request_tracker {
  394. u16 smid;
  395. struct scsi_cmnd *scmd;
  396. u8 cb_idx;
  397. struct list_head tracker_list;
  398. };
  399. /**
  400. * struct _tr_list - target reset list
  401. * @handle: device handle
  402. * @state: state machine
  403. */
  404. struct _tr_list {
  405. struct list_head list;
  406. u16 handle;
  407. u16 state;
  408. };
  409. typedef void (*MPT_ADD_SGE)(void *paddr, u32 flags_length, dma_addr_t dma_addr);
  410. /**
  411. * struct MPT2SAS_ADAPTER - per adapter struct
  412. * @list: ioc_list
  413. * @shost: shost object
  414. * @id: unique adapter id
  415. * @pci_irq: irq number
  416. * @name: generic ioc string
  417. * @tmp_string: tmp string used for logging
  418. * @pdev: pci pdev object
  419. * @chip: memory mapped register space
  420. * @chip_phys: physical addrss prior to mapping
  421. * @pio_chip: I/O mapped register space
  422. * @logging_level: see mpt2sas_debug.h
  423. * @fwfault_debug: debuging FW timeouts
  424. * @ir_firmware: IR firmware present
  425. * @bars: bitmask of BAR's that must be configured
  426. * @mask_interrupts: ignore interrupt
  427. * @fault_reset_work_q_name: fw fault work queue
  428. * @fault_reset_work_q: ""
  429. * @fault_reset_work: ""
  430. * @firmware_event_name: fw event work queue
  431. * @firmware_event_thread: ""
  432. * @fw_events_off: flag to turn off fw event handling
  433. * @fw_event_lock:
  434. * @fw_event_list: list of fw events
  435. * @aen_event_read_flag: event log was read
  436. * @broadcast_aen_busy: broadcast aen waiting to be serviced
  437. * @shost_recovery: host reset in progress
  438. * @ioc_reset_in_progress_lock:
  439. * @ioc_link_reset_in_progress: phy/hard reset in progress
  440. * @ignore_loginfos: ignore loginfos during task managment
  441. * @remove_host: flag for when driver unloads, to avoid sending dev resets
  442. * @wait_for_port_enable_to_complete:
  443. * @msix_enable: flag indicating msix is enabled
  444. * @msix_vector_count: number msix vectors
  445. * @msix_table: virt address to the msix table
  446. * @msix_table_backup: backup msix table
  447. * @scsi_io_cb_idx: shost generated commands
  448. * @tm_cb_idx: task management commands
  449. * @transport_cb_idx: transport internal commands
  450. * @ctl_cb_idx: clt internal commands
  451. * @base_cb_idx: base internal commands
  452. * @config_cb_idx: base internal commands
  453. * @base_cmds:
  454. * @transport_cmds:
  455. * @tm_cmds:
  456. * @ctl_cmds:
  457. * @config_cmds:
  458. * @base_add_sg_single: handler for either 32/64 bit sgl's
  459. * @event_type: bits indicating which events to log
  460. * @event_context: unique id for each logged event
  461. * @event_log: event log pointer
  462. * @event_masks: events that are masked
  463. * @facts: static facts data
  464. * @pfacts: static port facts data
  465. * @manu_pg0: static manufacturing page 0
  466. * @manu_pg10: static manufacturing page 10
  467. * @bios_pg2: static bios page 2
  468. * @bios_pg3: static bios page 3
  469. * @ioc_pg8: static ioc page 8
  470. * @iounit_pg0: static iounit page 0
  471. * @iounit_pg1: static iounit page 1
  472. * @sas_hba: sas host object
  473. * @sas_expander_list: expander object list
  474. * @sas_node_lock:
  475. * @sas_device_list: sas device object list
  476. * @sas_device_init_list: sas device object list (used only at init time)
  477. * @sas_device_lock:
  478. * @io_missing_delay: time for IO completed by fw when PDR enabled
  479. * @device_missing_delay: time for device missing by fw when PDR enabled
  480. * @config_page_sz: config page size
  481. * @config_page: reserve memory for config page payload
  482. * @config_page_dma:
  483. * @hba_queue_depth: hba request queue depth
  484. * @sge_size: sg element size for either 32/64 bit
  485. * @scsiio_depth: SCSI_IO queue depth
  486. * @request_sz: per request frame size
  487. * @request: pool of request frames
  488. * @request_dma:
  489. * @request_dma_sz:
  490. * @scsi_lookup: firmware request tracker list
  491. * @scsi_lookup_lock:
  492. * @free_list: free list of request
  493. * @chain: pool of chains
  494. * @pending_io_count:
  495. * @reset_wq:
  496. * @chain_dma:
  497. * @max_sges_in_main_message: number sg elements in main message
  498. * @max_sges_in_chain_message: number sg elements per chain
  499. * @chains_needed_per_io: max chains per io
  500. * @chain_offset_value_for_main_message: location 1st sg in main
  501. * @chain_depth: total chains allocated
  502. * @hi_priority_smid:
  503. * @hi_priority:
  504. * @hi_priority_dma:
  505. * @hi_priority_depth:
  506. * @hpr_lookup:
  507. * @hpr_free_list:
  508. * @internal_smid:
  509. * @internal:
  510. * @internal_dma:
  511. * @internal_depth:
  512. * @internal_lookup:
  513. * @internal_free_list:
  514. * @sense: pool of sense
  515. * @sense_dma:
  516. * @sense_dma_pool:
  517. * @reply_depth: hba reply queue depth:
  518. * @reply_sz: per reply frame size:
  519. * @reply: pool of replys:
  520. * @reply_dma:
  521. * @reply_dma_pool:
  522. * @reply_free_queue_depth: reply free depth
  523. * @reply_free: pool for reply free queue (32 bit addr)
  524. * @reply_free_dma:
  525. * @reply_free_dma_pool:
  526. * @reply_free_host_index: tail index in pool to insert free replys
  527. * @reply_post_queue_depth: reply post queue depth
  528. * @reply_post_free: pool for reply post (64bit descriptor)
  529. * @reply_post_free_dma:
  530. * @reply_post_free_dma_pool:
  531. * @reply_post_host_index: head index in the pool where FW completes IO
  532. */
  533. struct MPT2SAS_ADAPTER {
  534. struct list_head list;
  535. struct Scsi_Host *shost;
  536. u8 id;
  537. u32 pci_irq;
  538. char name[MPT_NAME_LENGTH];
  539. char tmp_string[MPT_STRING_LENGTH];
  540. struct pci_dev *pdev;
  541. Mpi2SystemInterfaceRegs_t __iomem *chip;
  542. unsigned long chip_phys;
  543. unsigned long pio_chip;
  544. int logging_level;
  545. int fwfault_debug;
  546. u8 ir_firmware;
  547. int bars;
  548. u8 mask_interrupts;
  549. /* fw fault handler */
  550. char fault_reset_work_q_name[20];
  551. struct workqueue_struct *fault_reset_work_q;
  552. struct delayed_work fault_reset_work;
  553. /* fw event handler */
  554. char firmware_event_name[20];
  555. struct workqueue_struct *firmware_event_thread;
  556. u8 fw_events_off;
  557. spinlock_t fw_event_lock;
  558. struct list_head fw_event_list;
  559. /* misc flags */
  560. int aen_event_read_flag;
  561. u8 broadcast_aen_busy;
  562. u8 shost_recovery;
  563. spinlock_t ioc_reset_in_progress_lock;
  564. u8 ioc_link_reset_in_progress;
  565. u8 ignore_loginfos;
  566. u8 remove_host;
  567. u8 wait_for_port_enable_to_complete;
  568. u8 msix_enable;
  569. u16 msix_vector_count;
  570. u32 *msix_table;
  571. u32 *msix_table_backup;
  572. /* internal commands, callback index */
  573. u8 scsi_io_cb_idx;
  574. u8 tm_cb_idx;
  575. u8 transport_cb_idx;
  576. u8 ctl_cb_idx;
  577. u8 base_cb_idx;
  578. u8 config_cb_idx;
  579. u8 tm_tr_cb_idx;
  580. u8 tm_sas_control_cb_idx;
  581. struct _internal_cmd base_cmds;
  582. struct _internal_cmd transport_cmds;
  583. struct _internal_cmd tm_cmds;
  584. struct _internal_cmd ctl_cmds;
  585. struct _internal_cmd config_cmds;
  586. MPT_ADD_SGE base_add_sg_single;
  587. /* event log */
  588. u32 event_type[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  589. u32 event_context;
  590. void *event_log;
  591. u32 event_masks[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  592. /* static config pages */
  593. Mpi2IOCFactsReply_t facts;
  594. Mpi2PortFactsReply_t *pfacts;
  595. Mpi2ManufacturingPage0_t manu_pg0;
  596. Mpi2BiosPage2_t bios_pg2;
  597. Mpi2BiosPage3_t bios_pg3;
  598. Mpi2IOCPage8_t ioc_pg8;
  599. Mpi2IOUnitPage0_t iounit_pg0;
  600. Mpi2IOUnitPage1_t iounit_pg1;
  601. struct _boot_device req_boot_device;
  602. struct _boot_device req_alt_boot_device;
  603. struct _boot_device current_boot_device;
  604. /* sas hba, expander, and device list */
  605. struct _sas_node sas_hba;
  606. struct list_head sas_expander_list;
  607. spinlock_t sas_node_lock;
  608. struct list_head sas_device_list;
  609. struct list_head sas_device_init_list;
  610. spinlock_t sas_device_lock;
  611. struct list_head raid_device_list;
  612. spinlock_t raid_device_lock;
  613. u8 io_missing_delay;
  614. u16 device_missing_delay;
  615. int sas_id;
  616. /* config page */
  617. u16 config_page_sz;
  618. void *config_page;
  619. dma_addr_t config_page_dma;
  620. /* scsiio request */
  621. u16 hba_queue_depth;
  622. u16 sge_size;
  623. u16 scsiio_depth;
  624. u16 request_sz;
  625. u8 *request;
  626. dma_addr_t request_dma;
  627. u32 request_dma_sz;
  628. struct request_tracker *scsi_lookup;
  629. spinlock_t scsi_lookup_lock;
  630. struct list_head free_list;
  631. int pending_io_count;
  632. wait_queue_head_t reset_wq;
  633. /* chain */
  634. u8 *chain;
  635. dma_addr_t chain_dma;
  636. u16 max_sges_in_main_message;
  637. u16 max_sges_in_chain_message;
  638. u16 chains_needed_per_io;
  639. u16 chain_offset_value_for_main_message;
  640. u16 chain_depth;
  641. /* hi-priority queue */
  642. u16 hi_priority_smid;
  643. u8 *hi_priority;
  644. dma_addr_t hi_priority_dma;
  645. u16 hi_priority_depth;
  646. struct request_tracker *hpr_lookup;
  647. struct list_head hpr_free_list;
  648. /* internal queue */
  649. u16 internal_smid;
  650. u8 *internal;
  651. dma_addr_t internal_dma;
  652. u16 internal_depth;
  653. struct request_tracker *internal_lookup;
  654. struct list_head internal_free_list;
  655. /* sense */
  656. u8 *sense;
  657. dma_addr_t sense_dma;
  658. struct dma_pool *sense_dma_pool;
  659. /* reply */
  660. u16 reply_sz;
  661. u8 *reply;
  662. dma_addr_t reply_dma;
  663. struct dma_pool *reply_dma_pool;
  664. /* reply free queue */
  665. u16 reply_free_queue_depth;
  666. u32 *reply_free;
  667. dma_addr_t reply_free_dma;
  668. struct dma_pool *reply_free_dma_pool;
  669. u32 reply_free_host_index;
  670. /* reply post queue */
  671. u16 reply_post_queue_depth;
  672. Mpi2ReplyDescriptorsUnion_t *reply_post_free;
  673. dma_addr_t reply_post_free_dma;
  674. struct dma_pool *reply_post_free_dma_pool;
  675. u32 reply_post_host_index;
  676. struct list_head delayed_tr_list;
  677. /* diag buffer support */
  678. u8 *diag_buffer[MPI2_DIAG_BUF_TYPE_COUNT];
  679. u32 diag_buffer_sz[MPI2_DIAG_BUF_TYPE_COUNT];
  680. dma_addr_t diag_buffer_dma[MPI2_DIAG_BUF_TYPE_COUNT];
  681. u8 diag_buffer_status[MPI2_DIAG_BUF_TYPE_COUNT];
  682. u32 unique_id[MPI2_DIAG_BUF_TYPE_COUNT];
  683. Mpi2ManufacturingPage10_t manu_pg10;
  684. u32 product_specific[MPI2_DIAG_BUF_TYPE_COUNT][23];
  685. u32 diagnostic_flags[MPI2_DIAG_BUF_TYPE_COUNT];
  686. };
  687. typedef u8 (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  688. u32 reply);
  689. /* base shared API */
  690. extern struct list_head mpt2sas_ioc_list;
  691. void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
  692. void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
  693. int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
  694. void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
  695. int mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc);
  696. void mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc);
  697. int mpt2sas_base_hard_reset_handler(struct MPT2SAS_ADAPTER *ioc, int sleep_flag,
  698. enum reset_type type);
  699. void *mpt2sas_base_get_msg_frame(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  700. void *mpt2sas_base_get_sense_buffer(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  701. void mpt2sas_base_build_zero_len_sge(struct MPT2SAS_ADAPTER *ioc, void *paddr);
  702. dma_addr_t mpt2sas_base_get_sense_buffer_dma(struct MPT2SAS_ADAPTER *ioc,
  703. u16 smid);
  704. /* hi-priority queue */
  705. u16 mpt2sas_base_get_smid_hpr(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  706. u16 mpt2sas_base_get_smid_scsiio(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx,
  707. struct scsi_cmnd *scmd);
  708. u16 mpt2sas_base_get_smid(struct MPT2SAS_ADAPTER *ioc, u8 cb_idx);
  709. void mpt2sas_base_free_smid(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  710. void mpt2sas_base_put_smid_scsi_io(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  711. u16 handle);
  712. void mpt2sas_base_put_smid_hi_priority(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  713. void mpt2sas_base_put_smid_target_assist(struct MPT2SAS_ADAPTER *ioc, u16 smid,
  714. u16 io_index);
  715. void mpt2sas_base_put_smid_default(struct MPT2SAS_ADAPTER *ioc, u16 smid);
  716. void mpt2sas_base_initialize_callback_handler(void);
  717. u8 mpt2sas_base_register_callback_handler(MPT_CALLBACK cb_func);
  718. void mpt2sas_base_release_callback_handler(u8 cb_idx);
  719. u8 mpt2sas_base_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  720. u32 reply);
  721. void *mpt2sas_base_get_reply_virt_addr(struct MPT2SAS_ADAPTER *ioc, u32 phys_addr);
  722. u32 mpt2sas_base_get_iocstate(struct MPT2SAS_ADAPTER *ioc, int cooked);
  723. void mpt2sas_base_fault_info(struct MPT2SAS_ADAPTER *ioc , u16 fault_code);
  724. int mpt2sas_base_sas_iounit_control(struct MPT2SAS_ADAPTER *ioc,
  725. Mpi2SasIoUnitControlReply_t *mpi_reply, Mpi2SasIoUnitControlRequest_t
  726. *mpi_request);
  727. int mpt2sas_base_scsi_enclosure_processor(struct MPT2SAS_ADAPTER *ioc,
  728. Mpi2SepReply_t *mpi_reply, Mpi2SepRequest_t *mpi_request);
  729. void mpt2sas_base_validate_event_type(struct MPT2SAS_ADAPTER *ioc, u32 *event_type);
  730. void mpt2sas_halt_firmware(struct MPT2SAS_ADAPTER *ioc);
  731. /* scsih shared API */
  732. u8 mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  733. u32 reply);
  734. void mpt2sas_scsih_issue_tm(struct MPT2SAS_ADAPTER *ioc, u16 handle, uint lun,
  735. u8 type, u16 smid_task, ulong timeout);
  736. void mpt2sas_scsih_set_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  737. void mpt2sas_scsih_clear_tm_flag(struct MPT2SAS_ADAPTER *ioc, u16 handle);
  738. struct _sas_node *mpt2sas_scsih_expander_find_by_handle(struct MPT2SAS_ADAPTER *ioc,
  739. u16 handle);
  740. struct _sas_node *mpt2sas_scsih_expander_find_by_sas_address(struct MPT2SAS_ADAPTER
  741. *ioc, u64 sas_address);
  742. struct _sas_device *mpt2sas_scsih_sas_device_find_by_sas_address(
  743. struct MPT2SAS_ADAPTER *ioc, u64 sas_address);
  744. void mpt2sas_scsih_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  745. /* config shared API */
  746. u8 mpt2sas_config_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  747. u32 reply);
  748. int mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys);
  749. int mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
  750. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage0_t *config_page);
  751. int mpt2sas_config_get_manufacturing_pg10(struct MPT2SAS_ADAPTER *ioc,
  752. Mpi2ConfigReply_t *mpi_reply, Mpi2ManufacturingPage10_t *config_page);
  753. int mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  754. *mpi_reply, Mpi2BiosPage2_t *config_page);
  755. int mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  756. *mpi_reply, Mpi2BiosPage3_t *config_page);
  757. int mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  758. *mpi_reply, Mpi2IOUnitPage0_t *config_page);
  759. int mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  760. *mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u32 handle);
  761. int mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  762. *mpi_reply, Mpi2SasDevicePage1_t *config_page, u32 form, u32 handle);
  763. int mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  764. *mpi_reply, Mpi2SasIOUnitPage0_t *config_page, u16 sz);
  765. int mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  766. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  767. int mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  768. *mpi_reply, Mpi2IOUnitPage1_t *config_page);
  769. int mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  770. *mpi_reply, Mpi2SasIOUnitPage1_t *config_page, u16 sz);
  771. int mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  772. *mpi_reply, Mpi2IOCPage8_t *config_page);
  773. int mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  774. *mpi_reply, Mpi2ExpanderPage0_t *config_page, u32 form, u32 handle);
  775. int mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  776. *mpi_reply, Mpi2ExpanderPage1_t *config_page, u32 phy_number, u16 handle);
  777. int mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  778. *mpi_reply, Mpi2SasEnclosurePage0_t *config_page, u32 form, u32 handle);
  779. int mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  780. *mpi_reply, Mpi2SasPhyPage0_t *config_page, u32 phy_number);
  781. int mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  782. *mpi_reply, Mpi2SasPhyPage1_t *config_page, u32 phy_number);
  783. int mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  784. *mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u32 handle);
  785. int mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 *num_pds);
  786. int mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  787. *mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 form, u32 handle, u16 sz);
  788. int mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
  789. *mpi_reply, Mpi2RaidPhysDiskPage0_t *config_page, u32 form,
  790. u32 form_specific);
  791. int mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
  792. u16 *volume_handle);
  793. int mpt2sas_config_get_volume_wwid(struct MPT2SAS_ADAPTER *ioc, u16 volume_handle,
  794. u64 *wwid);
  795. /* ctl shared API */
  796. extern struct device_attribute *mpt2sas_host_attrs[];
  797. extern struct device_attribute *mpt2sas_dev_attrs[];
  798. void mpt2sas_ctl_init(void);
  799. void mpt2sas_ctl_exit(void);
  800. u8 mpt2sas_ctl_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  801. u32 reply);
  802. void mpt2sas_ctl_reset_handler(struct MPT2SAS_ADAPTER *ioc, int reset_phase);
  803. u8 mpt2sas_ctl_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
  804. u32 reply);
  805. void mpt2sas_ctl_add_to_event_log(struct MPT2SAS_ADAPTER *ioc,
  806. Mpi2EventNotificationReply_t *mpi_reply);
  807. /* transport shared API */
  808. u8 mpt2sas_transport_done(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
  809. u32 reply);
  810. struct _sas_port *mpt2sas_transport_port_add(struct MPT2SAS_ADAPTER *ioc,
  811. u16 handle, u64 sas_address);
  812. void mpt2sas_transport_port_remove(struct MPT2SAS_ADAPTER *ioc, u64 sas_address,
  813. u64 sas_address_parent);
  814. int mpt2sas_transport_add_host_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  815. *mpt2sas_phy, Mpi2SasPhyPage0_t phy_pg0, struct device *parent_dev);
  816. int mpt2sas_transport_add_expander_phy(struct MPT2SAS_ADAPTER *ioc, struct _sas_phy
  817. *mpt2sas_phy, Mpi2ExpanderPage1_t expander_pg1, struct device *parent_dev);
  818. void mpt2sas_transport_update_links(struct MPT2SAS_ADAPTER *ioc,
  819. u64 sas_address, u16 handle, u8 phy_number, u8 link_rate);
  820. extern struct sas_function_template mpt2sas_transport_functions;
  821. extern struct scsi_transport_template *mpt2sas_transport_template;
  822. extern int scsi_internal_device_block(struct scsi_device *sdev);
  823. extern u8 mpt2sas_stm_zero_smid_handler(struct MPT2SAS_ADAPTER *ioc,
  824. u8 msix_index, u32 reply);
  825. extern int scsi_internal_device_unblock(struct scsi_device *sdev);
  826. #endif /* MPT2SAS_BASE_H_INCLUDED */