remote_device.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * * Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. * * Redistributions in binary form must reproduce the above copyright
  36. * notice, this list of conditions and the following disclaimer in
  37. * the documentation and/or other materials provided with the
  38. * distribution.
  39. * * Neither the name of Intel Corporation nor the names of its
  40. * contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  46. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  47. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  49. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. #ifndef _ISCI_REMOTE_DEVICE_H_
  56. #define _ISCI_REMOTE_DEVICE_H_
  57. #include <scsi/libsas.h>
  58. #include "sci_status.h"
  59. #include "intel_sas.h"
  60. #include "scu_remote_node_context.h"
  61. #include "remote_node_context.h"
  62. #include "port.h"
  63. enum scic_remote_device_not_ready_reason_code {
  64. SCIC_REMOTE_DEVICE_NOT_READY_START_REQUESTED,
  65. SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED,
  66. SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED,
  67. SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED,
  68. SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED,
  69. SCIC_REMOTE_DEVICE_NOT_READY_REASON_CODE_MAX
  70. };
  71. struct scic_sds_remote_device {
  72. /**
  73. * The field specifies that the parent object for the base remote
  74. * device is the base object itself.
  75. */
  76. struct sci_base_object parent;
  77. /**
  78. * This field contains the information for the base remote device state
  79. * machine.
  80. */
  81. struct sci_base_state_machine state_machine;
  82. /**
  83. * This field is the programmed device port width. This value is
  84. * written to the RCN data structure to tell the SCU how many open
  85. * connections this device can have.
  86. */
  87. u32 device_port_width;
  88. /**
  89. * This field is the programmed connection rate for this remote device. It is
  90. * used to program the TC with the maximum allowed connection rate.
  91. */
  92. enum sas_linkrate connection_rate;
  93. /**
  94. * This filed is assinged the value of true if the device is directly
  95. * attached to the port.
  96. */
  97. bool is_direct_attached;
  98. #if !defined(DISABLE_ATAPI)
  99. /**
  100. * This filed is assinged the value of true if the device is an ATAPI
  101. * device.
  102. */
  103. bool is_atapi;
  104. #endif
  105. /**
  106. * This filed contains a pointer back to the port to which this device
  107. * is assigned.
  108. */
  109. struct scic_sds_port *owning_port;
  110. /**
  111. * This field contains the SCU silicon remote node context specific
  112. * information.
  113. */
  114. struct scic_sds_remote_node_context rnc;
  115. /**
  116. * This field contains the stated request count for the remote device. The
  117. * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all
  118. * requests are complete and the rnc_posted value is false.
  119. */
  120. u32 started_request_count;
  121. /**
  122. * This field contains a pointer to the working request object. It is only
  123. * used only for SATA requests since the unsolicited frames we get from the
  124. * hardware have no Tag value to look up the io request object.
  125. */
  126. struct scic_sds_request *working_request;
  127. /**
  128. * This field contains the reason for the remote device going not_ready. It is
  129. * assigned in the state handlers and used in the state transition.
  130. */
  131. u32 not_ready_reason;
  132. /**
  133. * This field is true if this remote device has an initialzied ready substate
  134. * machine. SSP devices do not have a ready substate machine and STP devices
  135. * have a ready substate machine.
  136. */
  137. bool has_ready_substate_machine;
  138. /**
  139. * This field contains the state machine for the ready substate machine for
  140. * this struct scic_sds_remote_device object.
  141. */
  142. struct sci_base_state_machine ready_substate_machine;
  143. /**
  144. * This field maintains the set of state handlers for the remote device
  145. * object. These are changed each time the remote device enters a new state.
  146. */
  147. const struct scic_sds_remote_device_state_handler *state_handlers;
  148. };
  149. struct isci_remote_device {
  150. enum isci_status status;
  151. #define IDEV_START_PENDING 0
  152. #define IDEV_STOP_PENDING 1
  153. #define IDEV_ALLOCATED 2
  154. unsigned long flags;
  155. struct isci_port *isci_port;
  156. struct domain_device *domain_dev;
  157. struct list_head node;
  158. struct list_head reqs_in_process;
  159. spinlock_t state_lock;
  160. struct scic_sds_remote_device sci;
  161. };
  162. #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
  163. enum sci_status isci_remote_device_stop(struct isci_host *ihost,
  164. struct isci_remote_device *idev);
  165. void isci_remote_device_nuke_requests(struct isci_host *ihost,
  166. struct isci_remote_device *idev);
  167. void isci_remote_device_ready(struct isci_host *ihost,
  168. struct isci_remote_device *idev);
  169. void isci_remote_device_not_ready(struct isci_host *ihost,
  170. struct isci_remote_device *idev, u32 reason);
  171. void isci_remote_device_gone(struct domain_device *domain_dev);
  172. int isci_remote_device_found(struct domain_device *domain_dev);
  173. bool isci_device_is_reset_pending(struct isci_host *ihost,
  174. struct isci_remote_device *idev);
  175. void isci_device_clear_reset_pending(struct isci_host *ihost,
  176. struct isci_remote_device *idev);
  177. void isci_remote_device_change_state(struct isci_remote_device *idev,
  178. enum isci_status status);
  179. /**
  180. * scic_remote_device_stop() - This method will stop both transmission and
  181. * reception of link activity for the supplied remote device. This method
  182. * disables normal IO requests from flowing through to the remote device.
  183. * @remote_device: This parameter specifies the device to be stopped.
  184. * @timeout: This parameter specifies the number of milliseconds in which the
  185. * stop operation should complete.
  186. *
  187. * An indication of whether the device was successfully stopped. SCI_SUCCESS
  188. * This value is returned if the transmission and reception for the device was
  189. * successfully stopped.
  190. */
  191. enum sci_status scic_remote_device_stop(
  192. struct scic_sds_remote_device *remote_device,
  193. u32 timeout);
  194. /**
  195. * scic_remote_device_reset() - This method will reset the device making it
  196. * ready for operation. This method must be called anytime the device is
  197. * reset either through a SMP phy control or a port hard reset request.
  198. * @remote_device: This parameter specifies the device to be reset.
  199. *
  200. * This method does not actually cause the device hardware to be reset. This
  201. * method resets the software object so that it will be operational after a
  202. * device hardware reset completes. An indication of whether the device reset
  203. * was accepted. SCI_SUCCESS This value is returned if the device reset is
  204. * started.
  205. */
  206. enum sci_status scic_remote_device_reset(
  207. struct scic_sds_remote_device *remote_device);
  208. /**
  209. * scic_remote_device_reset_complete() - This method informs the device object
  210. * that the reset operation is complete and the device can resume operation
  211. * again.
  212. * @remote_device: This parameter specifies the device which is to be informed
  213. * of the reset complete operation.
  214. *
  215. * An indication that the device is resuming operation. SCI_SUCCESS the device
  216. * is resuming operation.
  217. */
  218. enum sci_status scic_remote_device_reset_complete(
  219. struct scic_sds_remote_device *remote_device);
  220. /**
  221. * scic_remote_device_get_connection_rate() - This method simply returns the
  222. * link rate at which communications to the remote device occur.
  223. * @remote_device: This parameter specifies the device for which to get the
  224. * connection rate.
  225. *
  226. * Return the link rate at which we transfer for the supplied remote device.
  227. */
  228. enum sas_linkrate scic_remote_device_get_connection_rate(
  229. struct scic_sds_remote_device *remote_device);
  230. #if !defined(DISABLE_ATAPI)
  231. /**
  232. * scic_remote_device_is_atapi() -
  233. * @this_device: The device whose type is to be decided.
  234. *
  235. * This method first decide whether a device is a stp target, then decode the
  236. * signature fis of a DA STP device to tell whether it is a standard end disk
  237. * or an ATAPI device. bool Indicate a device is ATAPI device or not.
  238. */
  239. bool scic_remote_device_is_atapi(
  240. struct scic_sds_remote_device *device_handle);
  241. #else /* !defined(DISABLE_ATAPI) */
  242. #define scic_remote_device_is_atapi(device_handle) false
  243. #endif /* !defined(DISABLE_ATAPI) */
  244. /**
  245. * enum scic_sds_remote_device_states - This enumeration depicts all the states
  246. * for the common remote device state machine.
  247. *
  248. *
  249. */
  250. enum scic_sds_remote_device_states {
  251. /**
  252. * Simply the initial state for the base remote device state machine.
  253. */
  254. SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
  255. /**
  256. * This state indicates that the remote device has successfully been
  257. * stopped. In this state no new IO operations are permitted.
  258. * This state is entered from the INITIAL state.
  259. * This state is entered from the STOPPING state.
  260. */
  261. SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
  262. /**
  263. * This state indicates the the remote device is in the process of
  264. * becoming ready (i.e. starting). In this state no new IO operations
  265. * are permitted.
  266. * This state is entered from the STOPPED state.
  267. */
  268. SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
  269. /**
  270. * This state indicates the remote device is now ready. Thus, the user
  271. * is able to perform IO operations on the remote device.
  272. * This state is entered from the STARTING state.
  273. */
  274. SCI_BASE_REMOTE_DEVICE_STATE_READY,
  275. /**
  276. * This state indicates that the remote device is in the process of
  277. * stopping. In this state no new IO operations are permitted, but
  278. * existing IO operations are allowed to complete.
  279. * This state is entered from the READY state.
  280. * This state is entered from the FAILED state.
  281. */
  282. SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
  283. /**
  284. * This state indicates that the remote device has failed.
  285. * In this state no new IO operations are permitted.
  286. * This state is entered from the INITIALIZING state.
  287. * This state is entered from the READY state.
  288. */
  289. SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
  290. /**
  291. * This state indicates the device is being reset.
  292. * In this state no new IO operations are permitted.
  293. * This state is entered from the READY state.
  294. */
  295. SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
  296. /**
  297. * Simply the final state for the base remote device state machine.
  298. */
  299. SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
  300. };
  301. /**
  302. * enum scic_sds_ssp_remote_device_ready_substates -
  303. *
  304. * This is the enumeration of the ready substates for the
  305. * struct scic_sds_remote_device.
  306. */
  307. enum scic_sds_ssp_remote_device_ready_substates {
  308. /**
  309. * This is the initial state for the remote device ready substate.
  310. */
  311. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL,
  312. /**
  313. * This is the ready operational substate for the remote device.
  314. * This is the normal operational state for a remote device.
  315. */
  316. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL,
  317. /**
  318. * This is the suspended state for the remote device. This is the state
  319. * that the device is placed in when a RNC suspend is received by
  320. * the SCU hardware.
  321. */
  322. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED,
  323. /**
  324. * This is the final state that the device is placed in before a change
  325. * to the base state machine.
  326. */
  327. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL,
  328. SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES
  329. };
  330. /**
  331. * enum scic_sds_stp_remote_device_ready_substates -
  332. *
  333. * This is the enumeration for the struct scic_sds_remote_device ready substates
  334. * for the STP remote device.
  335. */
  336. enum scic_sds_stp_remote_device_ready_substates {
  337. /**
  338. * This is the idle substate for the stp remote device. When there are no
  339. * active IO for the device it is is in this state.
  340. */
  341. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
  342. /**
  343. * This is the command state for for the STP remote device. This state is
  344. * entered when the device is processing a non-NCQ command. The device object
  345. * will fail any new start IO requests until this command is complete.
  346. */
  347. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
  348. /**
  349. * This is the NCQ state for the STP remote device. This state is entered
  350. * when the device is processing an NCQ reuqest. It will remain in this state
  351. * so long as there is one or more NCQ requests being processed.
  352. */
  353. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ,
  354. /**
  355. * This is the NCQ error state for the STP remote device. This state is
  356. * entered when an SDB error FIS is received by the device object while in the
  357. * NCQ state. The device object will only accept a READ LOG command while in
  358. * this state.
  359. */
  360. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR,
  361. #if !defined(DISABLE_ATAPI)
  362. /**
  363. * This is the ATAPI error state for the STP ATAPI remote device. This state is
  364. * entered when ATAPI device sends error status FIS without data while the device
  365. * object is in CMD state. A suspension event is expected in this state. The device
  366. * object will resume right away.
  367. */
  368. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_ATAPI_ERROR,
  369. #endif
  370. /**
  371. * This is the READY substate indicates the device is waiting for the RESET task
  372. * coming to be recovered from certain hardware specific error.
  373. */
  374. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET,
  375. };
  376. /**
  377. * enum scic_sds_smp_remote_device_ready_substates -
  378. *
  379. * This is the enumeration of the ready substates for the SMP REMOTE DEVICE.
  380. */
  381. enum scic_sds_smp_remote_device_ready_substates {
  382. /**
  383. * This is the ready operational substate for the remote device. This is the
  384. * normal operational state for a remote device.
  385. */
  386. SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
  387. /**
  388. * This is the suspended state for the remote device. This is the state that
  389. * the device is placed in when a RNC suspend is received by the SCU hardware.
  390. */
  391. SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
  392. };
  393. static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
  394. {
  395. struct scic_sds_remote_device *sci_dev;
  396. sci_dev = container_of(rnc, typeof(*sci_dev), rnc);
  397. return sci_dev;
  398. }
  399. static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev)
  400. {
  401. struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci);
  402. return idev->domain_dev;
  403. }
  404. static inline bool dev_is_expander(struct domain_device *dev)
  405. {
  406. return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV;
  407. }
  408. typedef enum sci_status (*scic_sds_remote_device_request_handler_t)(
  409. struct scic_sds_remote_device *device,
  410. struct scic_sds_request *request);
  411. typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)(
  412. struct scic_sds_remote_device *device,
  413. struct scic_sds_request *request,
  414. void *,
  415. enum sci_io_status);
  416. typedef enum sci_status (*scic_sds_remote_device_handler_t)(
  417. struct scic_sds_remote_device *sci_dev);
  418. typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)(
  419. struct scic_sds_remote_device *sci_dev,
  420. u32 suspend_type);
  421. typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)(
  422. struct scic_sds_remote_device *sci_dev);
  423. typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)(
  424. struct scic_sds_remote_device *sci_dev,
  425. u32 frame_index);
  426. typedef enum sci_status (*scic_sds_remote_device_event_handler_t)(
  427. struct scic_sds_remote_device *sci_dev,
  428. u32 event_code);
  429. typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)(
  430. struct scic_sds_remote_device *sci_dev);
  431. /**
  432. * struct scic_sds_remote_device_state_handler - This structure conains the
  433. * state handlers that are needed to process requests for the SCU remote
  434. * device objects.
  435. *
  436. *
  437. */
  438. struct scic_sds_remote_device_state_handler {
  439. /**
  440. * The start_handler specifies the method invoked when a user
  441. * attempts to start a remote device.
  442. */
  443. scic_sds_remote_device_handler_t start_handler;
  444. /**
  445. * The stop_handler specifies the method invoked when a user attempts to
  446. * stop a remote device.
  447. */
  448. scic_sds_remote_device_handler_t stop_handler;
  449. /**
  450. * The fail_handler specifies the method invoked when a remote device
  451. * failure has occurred. A failure may be due to an inability to
  452. * initialize/configure the device.
  453. */
  454. scic_sds_remote_device_handler_t fail_handler;
  455. /**
  456. * The destruct_handler specifies the method invoked when attempting to
  457. * destruct a remote device.
  458. */
  459. scic_sds_remote_device_handler_t destruct_handler;
  460. /**
  461. * The reset handler specifies the method invloked when requesting to
  462. * reset a remote device.
  463. */
  464. scic_sds_remote_device_handler_t reset_handler;
  465. /**
  466. * The reset complete handler specifies the method invloked when
  467. * reporting that a reset has completed to the remote device.
  468. */
  469. scic_sds_remote_device_handler_t reset_complete_handler;
  470. /**
  471. * The start_io_handler specifies the method invoked when a user
  472. * attempts to start an IO request for a remote device.
  473. */
  474. scic_sds_remote_device_request_handler_t start_io_handler;
  475. /**
  476. * The complete_io_handler specifies the method invoked when a user
  477. * attempts to complete an IO request for a remote device.
  478. */
  479. scic_sds_remote_device_request_handler_t complete_io_handler;
  480. /**
  481. * The continue_io_handler specifies the method invoked when a user
  482. * attempts to continue an IO request for a remote device.
  483. */
  484. scic_sds_remote_device_request_handler_t continue_io_handler;
  485. /**
  486. * The start_task_handler specifies the method invoked when a user
  487. * attempts to start a task management request for a remote device.
  488. */
  489. scic_sds_remote_device_request_handler_t start_task_handler;
  490. /**
  491. * The complete_task_handler specifies the method invoked when a user
  492. * attempts to complete a task management request for a remote device.
  493. */
  494. scic_sds_remote_device_request_handler_t complete_task_handler;
  495. scic_sds_remote_device_suspend_handler_t suspend_handler;
  496. scic_sds_remote_device_resume_handler_t resume_handler;
  497. scic_sds_remote_device_event_handler_t event_handler;
  498. scic_sds_remote_device_frame_handler_t frame_handler;
  499. };
  500. extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[];
  501. extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[];
  502. extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[];
  503. /**
  504. * scic_sds_remote_device_increment_request_count() -
  505. *
  506. * This macro incrments the request count for this device
  507. */
  508. #define scic_sds_remote_device_increment_request_count(sci_dev) \
  509. ((sci_dev)->started_request_count++)
  510. /**
  511. * scic_sds_remote_device_decrement_request_count() -
  512. *
  513. * This macro decrements the request count for this device. This count will
  514. * never decrment past 0.
  515. */
  516. #define scic_sds_remote_device_decrement_request_count(sci_dev) \
  517. ((sci_dev)->started_request_count > 0 ? \
  518. (sci_dev)->started_request_count-- : 0)
  519. /**
  520. * scic_sds_remote_device_get_request_count() -
  521. *
  522. * This is a helper macro to return the current device request count.
  523. */
  524. #define scic_sds_remote_device_get_request_count(sci_dev) \
  525. ((sci_dev)->started_request_count)
  526. /**
  527. * scic_sds_remote_device_get_port() -
  528. *
  529. * This macro returns the owning port of this remote device obejct.
  530. */
  531. #define scic_sds_remote_device_get_port(sci_dev) \
  532. ((sci_dev)->owning_port)
  533. /**
  534. * scic_sds_remote_device_get_controller() -
  535. *
  536. * This macro returns the controller object that contains this device object
  537. */
  538. #define scic_sds_remote_device_get_controller(sci_dev) \
  539. scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev))
  540. /**
  541. * scic_sds_remote_device_set_state_handlers() -
  542. *
  543. * This macro sets the remote device state handlers pointer and is set on entry
  544. * to each device state.
  545. */
  546. #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \
  547. ((sci_dev)->state_handlers = (handlers))
  548. /**
  549. * scic_sds_remote_device_get_port() -
  550. *
  551. * This macro returns the owning port of this device
  552. */
  553. #define scic_sds_remote_device_get_port(sci_dev) \
  554. ((sci_dev)->owning_port)
  555. /**
  556. * scic_sds_remote_device_get_sequence() -
  557. *
  558. * This macro returns the remote device sequence value
  559. */
  560. #define scic_sds_remote_device_get_sequence(sci_dev) \
  561. (\
  562. scic_sds_remote_device_get_controller(sci_dev)-> \
  563. remote_device_sequence[(sci_dev)->rnc.remote_node_index] \
  564. )
  565. /**
  566. * scic_sds_remote_device_get_controller_peg() -
  567. *
  568. * This macro returns the controllers protocol engine group
  569. */
  570. #define scic_sds_remote_device_get_controller_peg(sci_dev) \
  571. (\
  572. scic_sds_controller_get_protocol_engine_group(\
  573. scic_sds_port_get_controller(\
  574. scic_sds_remote_device_get_port(sci_dev) \
  575. ) \
  576. ) \
  577. )
  578. /**
  579. * scic_sds_remote_device_get_port_index() -
  580. *
  581. * This macro returns the port index for the devices owning port
  582. */
  583. #define scic_sds_remote_device_get_port_index(sci_dev) \
  584. (scic_sds_port_get_index(scic_sds_remote_device_get_port(sci_dev)))
  585. /**
  586. * scic_sds_remote_device_get_index() -
  587. *
  588. * This macro returns the remote node index for this device object
  589. */
  590. #define scic_sds_remote_device_get_index(sci_dev) \
  591. ((sci_dev)->rnc.remote_node_index)
  592. /**
  593. * scic_sds_remote_device_build_command_context() -
  594. *
  595. * This macro builds a remote device context for the SCU post request operation
  596. */
  597. #define scic_sds_remote_device_build_command_context(device, command) \
  598. ((command) \
  599. | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \
  600. | (scic_sds_remote_device_get_port_index((device)) << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \
  601. | (scic_sds_remote_device_get_index((device))) \
  602. )
  603. /**
  604. * scic_sds_remote_device_set_working_request() -
  605. *
  606. * This macro makes the working request assingment for the remote device
  607. * object. To clear the working request use this macro with a NULL request
  608. * object.
  609. */
  610. #define scic_sds_remote_device_set_working_request(device, request) \
  611. ((device)->working_request = (request))
  612. enum sci_status scic_sds_remote_device_frame_handler(
  613. struct scic_sds_remote_device *sci_dev,
  614. u32 frame_index);
  615. enum sci_status scic_sds_remote_device_event_handler(
  616. struct scic_sds_remote_device *sci_dev,
  617. u32 event_code);
  618. enum sci_status scic_sds_remote_device_start_io(
  619. struct scic_sds_controller *controller,
  620. struct scic_sds_remote_device *sci_dev,
  621. struct scic_sds_request *io_request);
  622. enum sci_status scic_sds_remote_device_complete_io(
  623. struct scic_sds_controller *controller,
  624. struct scic_sds_remote_device *sci_dev,
  625. struct scic_sds_request *io_request);
  626. enum sci_status scic_sds_remote_device_resume(
  627. struct scic_sds_remote_device *sci_dev);
  628. enum sci_status scic_sds_remote_device_suspend(
  629. struct scic_sds_remote_device *sci_dev,
  630. u32 suspend_type);
  631. enum sci_status scic_sds_remote_device_start_task(
  632. struct scic_sds_controller *controller,
  633. struct scic_sds_remote_device *sci_dev,
  634. struct scic_sds_request *io_request);
  635. void scic_sds_remote_device_post_request(
  636. struct scic_sds_remote_device *sci_dev,
  637. u32 request);
  638. #if !defined(DISABLE_ATAPI)
  639. bool scic_sds_remote_device_is_atapi(
  640. struct scic_sds_remote_device *sci_dev);
  641. #else /* !defined(DISABLE_ATAPI) */
  642. #define scic_sds_remote_device_is_atapi(sci_dev) false
  643. #endif /* !defined(DISABLE_ATAPI) */
  644. void scic_sds_remote_device_start_request(
  645. struct scic_sds_remote_device *sci_dev,
  646. struct scic_sds_request *sci_req,
  647. enum sci_status status);
  648. void scic_sds_remote_device_continue_request(void *sci_dev);
  649. enum sci_status scic_sds_remote_device_default_start_handler(
  650. struct scic_sds_remote_device *sci_dev);
  651. enum sci_status scic_sds_remote_device_default_fail_handler(
  652. struct scic_sds_remote_device *sci_dev);
  653. enum sci_status scic_sds_remote_device_default_destruct_handler(
  654. struct scic_sds_remote_device *sci_dev);
  655. enum sci_status scic_sds_remote_device_default_reset_handler(
  656. struct scic_sds_remote_device *device);
  657. enum sci_status scic_sds_remote_device_default_reset_complete_handler(
  658. struct scic_sds_remote_device *device);
  659. enum sci_status scic_sds_remote_device_default_start_request_handler(
  660. struct scic_sds_remote_device *device,
  661. struct scic_sds_request *request);
  662. enum sci_status scic_sds_remote_device_default_complete_request_handler(
  663. struct scic_sds_remote_device *device,
  664. struct scic_sds_request *request);
  665. enum sci_status scic_sds_remote_device_default_continue_request_handler(
  666. struct scic_sds_remote_device *device,
  667. struct scic_sds_request *request);
  668. enum sci_status scic_sds_remote_device_default_suspend_handler(
  669. struct scic_sds_remote_device *sci_dev,
  670. u32 suspend_type);
  671. enum sci_status scic_sds_remote_device_default_resume_handler(
  672. struct scic_sds_remote_device *sci_dev);
  673. enum sci_status scic_sds_remote_device_default_frame_handler(
  674. struct scic_sds_remote_device *sci_dev,
  675. u32 frame_index);
  676. enum sci_status scic_sds_remote_device_ready_state_stop_handler(
  677. struct scic_sds_remote_device *device);
  678. enum sci_status scic_sds_remote_device_ready_state_reset_handler(
  679. struct scic_sds_remote_device *device);
  680. enum sci_status scic_sds_remote_device_general_frame_handler(
  681. struct scic_sds_remote_device *sci_dev,
  682. u32 frame_index);
  683. enum sci_status scic_sds_remote_device_general_event_handler(
  684. struct scic_sds_remote_device *sci_dev,
  685. u32 event_code);
  686. enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler(
  687. struct scic_sds_remote_device *sci_dev);
  688. #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */