remote_device.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  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. /**
  99. * This filed contains a pointer back to the port to which this device
  100. * is assigned.
  101. */
  102. struct scic_sds_port *owning_port;
  103. /**
  104. * This field contains the SCU silicon remote node context specific
  105. * information.
  106. */
  107. struct scic_sds_remote_node_context rnc;
  108. /**
  109. * This field contains the stated request count for the remote device. The
  110. * device can not reach the SCI_BASE_REMOTE_DEVICE_STATE_STOPPED until all
  111. * requests are complete and the rnc_posted value is false.
  112. */
  113. u32 started_request_count;
  114. /**
  115. * This field contains a pointer to the working request object. It is only
  116. * used only for SATA requests since the unsolicited frames we get from the
  117. * hardware have no Tag value to look up the io request object.
  118. */
  119. struct scic_sds_request *working_request;
  120. /**
  121. * This field contains the reason for the remote device going not_ready. It is
  122. * assigned in the state handlers and used in the state transition.
  123. */
  124. u32 not_ready_reason;
  125. /**
  126. * This field is true if this remote device has an initialzied ready substate
  127. * machine. SSP devices do not have a ready substate machine and STP devices
  128. * have a ready substate machine.
  129. */
  130. bool has_ready_substate_machine;
  131. /**
  132. * This field contains the state machine for the ready substate machine for
  133. * this struct scic_sds_remote_device object.
  134. */
  135. struct sci_base_state_machine ready_substate_machine;
  136. /**
  137. * This field maintains the set of state handlers for the remote device
  138. * object. These are changed each time the remote device enters a new state.
  139. */
  140. const struct scic_sds_remote_device_state_handler *state_handlers;
  141. };
  142. struct isci_remote_device {
  143. enum isci_status status;
  144. #define IDEV_START_PENDING 0
  145. #define IDEV_STOP_PENDING 1
  146. #define IDEV_ALLOCATED 2
  147. unsigned long flags;
  148. struct isci_port *isci_port;
  149. struct domain_device *domain_dev;
  150. struct list_head node;
  151. struct list_head reqs_in_process;
  152. spinlock_t state_lock;
  153. struct scic_sds_remote_device sci;
  154. };
  155. #define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
  156. enum sci_status isci_remote_device_stop(struct isci_host *ihost,
  157. struct isci_remote_device *idev);
  158. void isci_remote_device_nuke_requests(struct isci_host *ihost,
  159. struct isci_remote_device *idev);
  160. void isci_remote_device_ready(struct isci_host *ihost,
  161. struct isci_remote_device *idev);
  162. void isci_remote_device_not_ready(struct isci_host *ihost,
  163. struct isci_remote_device *idev, u32 reason);
  164. void isci_remote_device_gone(struct domain_device *domain_dev);
  165. int isci_remote_device_found(struct domain_device *domain_dev);
  166. bool isci_device_is_reset_pending(struct isci_host *ihost,
  167. struct isci_remote_device *idev);
  168. void isci_device_clear_reset_pending(struct isci_host *ihost,
  169. struct isci_remote_device *idev);
  170. void isci_remote_device_change_state(struct isci_remote_device *idev,
  171. enum isci_status status);
  172. /**
  173. * scic_remote_device_stop() - This method will stop both transmission and
  174. * reception of link activity for the supplied remote device. This method
  175. * disables normal IO requests from flowing through to the remote device.
  176. * @remote_device: This parameter specifies the device to be stopped.
  177. * @timeout: This parameter specifies the number of milliseconds in which the
  178. * stop operation should complete.
  179. *
  180. * An indication of whether the device was successfully stopped. SCI_SUCCESS
  181. * This value is returned if the transmission and reception for the device was
  182. * successfully stopped.
  183. */
  184. enum sci_status scic_remote_device_stop(
  185. struct scic_sds_remote_device *remote_device,
  186. u32 timeout);
  187. /**
  188. * scic_remote_device_reset() - This method will reset the device making it
  189. * ready for operation. This method must be called anytime the device is
  190. * reset either through a SMP phy control or a port hard reset request.
  191. * @remote_device: This parameter specifies the device to be reset.
  192. *
  193. * This method does not actually cause the device hardware to be reset. This
  194. * method resets the software object so that it will be operational after a
  195. * device hardware reset completes. An indication of whether the device reset
  196. * was accepted. SCI_SUCCESS This value is returned if the device reset is
  197. * started.
  198. */
  199. enum sci_status scic_remote_device_reset(
  200. struct scic_sds_remote_device *remote_device);
  201. /**
  202. * scic_remote_device_reset_complete() - This method informs the device object
  203. * that the reset operation is complete and the device can resume operation
  204. * again.
  205. * @remote_device: This parameter specifies the device which is to be informed
  206. * of the reset complete operation.
  207. *
  208. * An indication that the device is resuming operation. SCI_SUCCESS the device
  209. * is resuming operation.
  210. */
  211. enum sci_status scic_remote_device_reset_complete(
  212. struct scic_sds_remote_device *remote_device);
  213. /**
  214. * scic_remote_device_get_connection_rate() - This method simply returns the
  215. * link rate at which communications to the remote device occur.
  216. * @remote_device: This parameter specifies the device for which to get the
  217. * connection rate.
  218. *
  219. * Return the link rate at which we transfer for the supplied remote device.
  220. */
  221. enum sas_linkrate scic_remote_device_get_connection_rate(
  222. struct scic_sds_remote_device *remote_device);
  223. #define scic_remote_device_is_atapi(device_handle) false
  224. /**
  225. * enum scic_sds_remote_device_states - This enumeration depicts all the states
  226. * for the common remote device state machine.
  227. *
  228. *
  229. */
  230. enum scic_sds_remote_device_states {
  231. /**
  232. * Simply the initial state for the base remote device state machine.
  233. */
  234. SCI_BASE_REMOTE_DEVICE_STATE_INITIAL,
  235. /**
  236. * This state indicates that the remote device has successfully been
  237. * stopped. In this state no new IO operations are permitted.
  238. * This state is entered from the INITIAL state.
  239. * This state is entered from the STOPPING state.
  240. */
  241. SCI_BASE_REMOTE_DEVICE_STATE_STOPPED,
  242. /**
  243. * This state indicates the the remote device is in the process of
  244. * becoming ready (i.e. starting). In this state no new IO operations
  245. * are permitted.
  246. * This state is entered from the STOPPED state.
  247. */
  248. SCI_BASE_REMOTE_DEVICE_STATE_STARTING,
  249. /**
  250. * This state indicates the remote device is now ready. Thus, the user
  251. * is able to perform IO operations on the remote device.
  252. * This state is entered from the STARTING state.
  253. */
  254. SCI_BASE_REMOTE_DEVICE_STATE_READY,
  255. /**
  256. * This state indicates that the remote device is in the process of
  257. * stopping. In this state no new IO operations are permitted, but
  258. * existing IO operations are allowed to complete.
  259. * This state is entered from the READY state.
  260. * This state is entered from the FAILED state.
  261. */
  262. SCI_BASE_REMOTE_DEVICE_STATE_STOPPING,
  263. /**
  264. * This state indicates that the remote device has failed.
  265. * In this state no new IO operations are permitted.
  266. * This state is entered from the INITIALIZING state.
  267. * This state is entered from the READY state.
  268. */
  269. SCI_BASE_REMOTE_DEVICE_STATE_FAILED,
  270. /**
  271. * This state indicates the device is being reset.
  272. * In this state no new IO operations are permitted.
  273. * This state is entered from the READY state.
  274. */
  275. SCI_BASE_REMOTE_DEVICE_STATE_RESETTING,
  276. /**
  277. * Simply the final state for the base remote device state machine.
  278. */
  279. SCI_BASE_REMOTE_DEVICE_STATE_FINAL,
  280. };
  281. /**
  282. * enum scic_sds_ssp_remote_device_ready_substates -
  283. *
  284. * This is the enumeration of the ready substates for the
  285. * struct scic_sds_remote_device.
  286. */
  287. enum scic_sds_ssp_remote_device_ready_substates {
  288. /**
  289. * This is the initial state for the remote device ready substate.
  290. */
  291. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_INITIAL,
  292. /**
  293. * This is the ready operational substate for the remote device.
  294. * This is the normal operational state for a remote device.
  295. */
  296. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_OPERATIONAL,
  297. /**
  298. * This is the suspended state for the remote device. This is the state
  299. * that the device is placed in when a RNC suspend is received by
  300. * the SCU hardware.
  301. */
  302. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_SUSPENDED,
  303. /**
  304. * This is the final state that the device is placed in before a change
  305. * to the base state machine.
  306. */
  307. SCIC_SDS_SSP_REMOTE_DEVICE_READY_SUBSTATE_FINAL,
  308. SCIC_SDS_SSP_REMOTE_DEVICE_READY_MAX_SUBSTATES
  309. };
  310. /**
  311. * enum scic_sds_stp_remote_device_ready_substates -
  312. *
  313. * This is the enumeration for the struct scic_sds_remote_device ready substates
  314. * for the STP remote device.
  315. */
  316. enum scic_sds_stp_remote_device_ready_substates {
  317. /**
  318. * This is the idle substate for the stp remote device. When there are no
  319. * active IO for the device it is is in this state.
  320. */
  321. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
  322. /**
  323. * This is the command state for for the STP remote device. This state is
  324. * entered when the device is processing a non-NCQ command. The device object
  325. * will fail any new start IO requests until this command is complete.
  326. */
  327. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
  328. /**
  329. * This is the NCQ state for the STP remote device. This state is entered
  330. * when the device is processing an NCQ reuqest. It will remain in this state
  331. * so long as there is one or more NCQ requests being processed.
  332. */
  333. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ,
  334. /**
  335. * This is the NCQ error state for the STP remote device. This state is
  336. * entered when an SDB error FIS is received by the device object while in the
  337. * NCQ state. The device object will only accept a READ LOG command while in
  338. * this state.
  339. */
  340. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR,
  341. /**
  342. * This is the READY substate indicates the device is waiting for the RESET task
  343. * coming to be recovered from certain hardware specific error.
  344. */
  345. SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET,
  346. };
  347. /**
  348. * enum scic_sds_smp_remote_device_ready_substates -
  349. *
  350. * This is the enumeration of the ready substates for the SMP REMOTE DEVICE.
  351. */
  352. enum scic_sds_smp_remote_device_ready_substates {
  353. /**
  354. * This is the ready operational substate for the remote device. This is the
  355. * normal operational state for a remote device.
  356. */
  357. SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE,
  358. /**
  359. * This is the suspended state for the remote device. This is the state that
  360. * the device is placed in when a RNC suspend is received by the SCU hardware.
  361. */
  362. SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD,
  363. };
  364. static inline struct scic_sds_remote_device *rnc_to_dev(struct scic_sds_remote_node_context *rnc)
  365. {
  366. struct scic_sds_remote_device *sci_dev;
  367. sci_dev = container_of(rnc, typeof(*sci_dev), rnc);
  368. return sci_dev;
  369. }
  370. static inline struct domain_device *sci_dev_to_domain(struct scic_sds_remote_device *sci_dev)
  371. {
  372. struct isci_remote_device *idev = container_of(sci_dev, typeof(*idev), sci);
  373. return idev->domain_dev;
  374. }
  375. static inline bool dev_is_expander(struct domain_device *dev)
  376. {
  377. return dev->dev_type == EDGE_DEV || dev->dev_type == FANOUT_DEV;
  378. }
  379. typedef enum sci_status (*scic_sds_remote_device_request_handler_t)(
  380. struct scic_sds_remote_device *device,
  381. struct scic_sds_request *request);
  382. typedef enum sci_status (*scic_sds_remote_device_high_priority_request_complete_handler_t)(
  383. struct scic_sds_remote_device *device,
  384. struct scic_sds_request *request,
  385. void *,
  386. enum sci_io_status);
  387. typedef enum sci_status (*scic_sds_remote_device_handler_t)(
  388. struct scic_sds_remote_device *sci_dev);
  389. typedef enum sci_status (*scic_sds_remote_device_suspend_handler_t)(
  390. struct scic_sds_remote_device *sci_dev,
  391. u32 suspend_type);
  392. typedef enum sci_status (*scic_sds_remote_device_resume_handler_t)(
  393. struct scic_sds_remote_device *sci_dev);
  394. typedef enum sci_status (*scic_sds_remote_device_frame_handler_t)(
  395. struct scic_sds_remote_device *sci_dev,
  396. u32 frame_index);
  397. typedef enum sci_status (*scic_sds_remote_device_event_handler_t)(
  398. struct scic_sds_remote_device *sci_dev,
  399. u32 event_code);
  400. typedef void (*scic_sds_remote_device_ready_not_ready_handler_t)(
  401. struct scic_sds_remote_device *sci_dev);
  402. /**
  403. * struct scic_sds_remote_device_state_handler - This structure conains the
  404. * state handlers that are needed to process requests for the SCU remote
  405. * device objects.
  406. *
  407. *
  408. */
  409. struct scic_sds_remote_device_state_handler {
  410. /**
  411. * The start_handler specifies the method invoked when a user
  412. * attempts to start a remote device.
  413. */
  414. scic_sds_remote_device_handler_t start_handler;
  415. /**
  416. * The stop_handler specifies the method invoked when a user attempts to
  417. * stop a remote device.
  418. */
  419. scic_sds_remote_device_handler_t stop_handler;
  420. /**
  421. * The fail_handler specifies the method invoked when a remote device
  422. * failure has occurred. A failure may be due to an inability to
  423. * initialize/configure the device.
  424. */
  425. scic_sds_remote_device_handler_t fail_handler;
  426. /**
  427. * The destruct_handler specifies the method invoked when attempting to
  428. * destruct a remote device.
  429. */
  430. scic_sds_remote_device_handler_t destruct_handler;
  431. /**
  432. * The reset handler specifies the method invloked when requesting to
  433. * reset a remote device.
  434. */
  435. scic_sds_remote_device_handler_t reset_handler;
  436. /**
  437. * The reset complete handler specifies the method invloked when
  438. * reporting that a reset has completed to the remote device.
  439. */
  440. scic_sds_remote_device_handler_t reset_complete_handler;
  441. /**
  442. * The start_io_handler specifies the method invoked when a user
  443. * attempts to start an IO request for a remote device.
  444. */
  445. scic_sds_remote_device_request_handler_t start_io_handler;
  446. /**
  447. * The complete_io_handler specifies the method invoked when a user
  448. * attempts to complete an IO request for a remote device.
  449. */
  450. scic_sds_remote_device_request_handler_t complete_io_handler;
  451. /**
  452. * The continue_io_handler specifies the method invoked when a user
  453. * attempts to continue an IO request for a remote device.
  454. */
  455. scic_sds_remote_device_request_handler_t continue_io_handler;
  456. /**
  457. * The start_task_handler specifies the method invoked when a user
  458. * attempts to start a task management request for a remote device.
  459. */
  460. scic_sds_remote_device_request_handler_t start_task_handler;
  461. /**
  462. * The complete_task_handler specifies the method invoked when a user
  463. * attempts to complete a task management request for a remote device.
  464. */
  465. scic_sds_remote_device_request_handler_t complete_task_handler;
  466. scic_sds_remote_device_suspend_handler_t suspend_handler;
  467. scic_sds_remote_device_resume_handler_t resume_handler;
  468. scic_sds_remote_device_event_handler_t event_handler;
  469. scic_sds_remote_device_frame_handler_t frame_handler;
  470. };
  471. extern const struct sci_base_state scic_sds_ssp_remote_device_ready_substate_table[];
  472. extern const struct sci_base_state scic_sds_stp_remote_device_ready_substate_table[];
  473. extern const struct sci_base_state scic_sds_smp_remote_device_ready_substate_table[];
  474. /**
  475. * scic_sds_remote_device_increment_request_count() -
  476. *
  477. * This macro incrments the request count for this device
  478. */
  479. #define scic_sds_remote_device_increment_request_count(sci_dev) \
  480. ((sci_dev)->started_request_count++)
  481. /**
  482. * scic_sds_remote_device_decrement_request_count() -
  483. *
  484. * This macro decrements the request count for this device. This count will
  485. * never decrment past 0.
  486. */
  487. #define scic_sds_remote_device_decrement_request_count(sci_dev) \
  488. ((sci_dev)->started_request_count > 0 ? \
  489. (sci_dev)->started_request_count-- : 0)
  490. /**
  491. * scic_sds_remote_device_get_request_count() -
  492. *
  493. * This is a helper macro to return the current device request count.
  494. */
  495. #define scic_sds_remote_device_get_request_count(sci_dev) \
  496. ((sci_dev)->started_request_count)
  497. /**
  498. * scic_sds_remote_device_get_port() -
  499. *
  500. * This macro returns the owning port of this remote device obejct.
  501. */
  502. #define scic_sds_remote_device_get_port(sci_dev) \
  503. ((sci_dev)->owning_port)
  504. /**
  505. * scic_sds_remote_device_get_controller() -
  506. *
  507. * This macro returns the controller object that contains this device object
  508. */
  509. #define scic_sds_remote_device_get_controller(sci_dev) \
  510. scic_sds_port_get_controller(scic_sds_remote_device_get_port(sci_dev))
  511. /**
  512. * scic_sds_remote_device_set_state_handlers() -
  513. *
  514. * This macro sets the remote device state handlers pointer and is set on entry
  515. * to each device state.
  516. */
  517. #define scic_sds_remote_device_set_state_handlers(sci_dev, handlers) \
  518. ((sci_dev)->state_handlers = (handlers))
  519. /**
  520. * scic_sds_remote_device_get_port() -
  521. *
  522. * This macro returns the owning port of this device
  523. */
  524. #define scic_sds_remote_device_get_port(sci_dev) \
  525. ((sci_dev)->owning_port)
  526. /**
  527. * scic_sds_remote_device_get_sequence() -
  528. *
  529. * This macro returns the remote device sequence value
  530. */
  531. #define scic_sds_remote_device_get_sequence(sci_dev) \
  532. (\
  533. scic_sds_remote_device_get_controller(sci_dev)-> \
  534. remote_device_sequence[(sci_dev)->rnc.remote_node_index] \
  535. )
  536. /**
  537. * scic_sds_remote_device_get_controller_peg() -
  538. *
  539. * This macro returns the controllers protocol engine group
  540. */
  541. #define scic_sds_remote_device_get_controller_peg(sci_dev) \
  542. (\
  543. scic_sds_controller_get_protocol_engine_group(\
  544. scic_sds_port_get_controller(\
  545. scic_sds_remote_device_get_port(sci_dev) \
  546. ) \
  547. ) \
  548. )
  549. /**
  550. * scic_sds_remote_device_get_index() -
  551. *
  552. * This macro returns the remote node index for this device object
  553. */
  554. #define scic_sds_remote_device_get_index(sci_dev) \
  555. ((sci_dev)->rnc.remote_node_index)
  556. /**
  557. * scic_sds_remote_device_build_command_context() -
  558. *
  559. * This macro builds a remote device context for the SCU post request operation
  560. */
  561. #define scic_sds_remote_device_build_command_context(device, command) \
  562. ((command) \
  563. | (scic_sds_remote_device_get_controller_peg((device)) << SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) \
  564. | ((device)->owning_port->physical_port_index << SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) \
  565. | (scic_sds_remote_device_get_index((device))) \
  566. )
  567. /**
  568. * scic_sds_remote_device_set_working_request() -
  569. *
  570. * This macro makes the working request assingment for the remote device
  571. * object. To clear the working request use this macro with a NULL request
  572. * object.
  573. */
  574. #define scic_sds_remote_device_set_working_request(device, request) \
  575. ((device)->working_request = (request))
  576. enum sci_status scic_sds_remote_device_frame_handler(
  577. struct scic_sds_remote_device *sci_dev,
  578. u32 frame_index);
  579. enum sci_status scic_sds_remote_device_event_handler(
  580. struct scic_sds_remote_device *sci_dev,
  581. u32 event_code);
  582. enum sci_status scic_sds_remote_device_start_io(
  583. struct scic_sds_controller *controller,
  584. struct scic_sds_remote_device *sci_dev,
  585. struct scic_sds_request *io_request);
  586. enum sci_status scic_sds_remote_device_complete_io(
  587. struct scic_sds_controller *controller,
  588. struct scic_sds_remote_device *sci_dev,
  589. struct scic_sds_request *io_request);
  590. enum sci_status scic_sds_remote_device_resume(
  591. struct scic_sds_remote_device *sci_dev);
  592. enum sci_status scic_sds_remote_device_suspend(
  593. struct scic_sds_remote_device *sci_dev,
  594. u32 suspend_type);
  595. enum sci_status scic_sds_remote_device_start_task(
  596. struct scic_sds_controller *controller,
  597. struct scic_sds_remote_device *sci_dev,
  598. struct scic_sds_request *io_request);
  599. void scic_sds_remote_device_post_request(
  600. struct scic_sds_remote_device *sci_dev,
  601. u32 request);
  602. #define scic_sds_remote_device_is_atapi(sci_dev) false
  603. void scic_sds_remote_device_start_request(
  604. struct scic_sds_remote_device *sci_dev,
  605. struct scic_sds_request *sci_req,
  606. enum sci_status status);
  607. void scic_sds_remote_device_continue_request(void *sci_dev);
  608. enum sci_status scic_sds_remote_device_default_start_handler(
  609. struct scic_sds_remote_device *sci_dev);
  610. enum sci_status scic_sds_remote_device_default_fail_handler(
  611. struct scic_sds_remote_device *sci_dev);
  612. enum sci_status scic_sds_remote_device_default_destruct_handler(
  613. struct scic_sds_remote_device *sci_dev);
  614. enum sci_status scic_sds_remote_device_default_reset_handler(
  615. struct scic_sds_remote_device *device);
  616. enum sci_status scic_sds_remote_device_default_reset_complete_handler(
  617. struct scic_sds_remote_device *device);
  618. enum sci_status scic_sds_remote_device_default_start_request_handler(
  619. struct scic_sds_remote_device *device,
  620. struct scic_sds_request *request);
  621. enum sci_status scic_sds_remote_device_default_complete_request_handler(
  622. struct scic_sds_remote_device *device,
  623. struct scic_sds_request *request);
  624. enum sci_status scic_sds_remote_device_default_continue_request_handler(
  625. struct scic_sds_remote_device *device,
  626. struct scic_sds_request *request);
  627. enum sci_status scic_sds_remote_device_default_suspend_handler(
  628. struct scic_sds_remote_device *sci_dev,
  629. u32 suspend_type);
  630. enum sci_status scic_sds_remote_device_default_resume_handler(
  631. struct scic_sds_remote_device *sci_dev);
  632. enum sci_status scic_sds_remote_device_default_frame_handler(
  633. struct scic_sds_remote_device *sci_dev,
  634. u32 frame_index);
  635. enum sci_status scic_sds_remote_device_ready_state_stop_handler(
  636. struct scic_sds_remote_device *device);
  637. enum sci_status scic_sds_remote_device_ready_state_reset_handler(
  638. struct scic_sds_remote_device *device);
  639. enum sci_status scic_sds_remote_device_general_frame_handler(
  640. struct scic_sds_remote_device *sci_dev,
  641. u32 frame_index);
  642. enum sci_status scic_sds_remote_device_general_event_handler(
  643. struct scic_sds_remote_device *sci_dev,
  644. u32 event_code);
  645. enum sci_status scic_sds_ssp_remote_device_ready_suspended_substate_resume_handler(
  646. struct scic_sds_remote_device *sci_dev);
  647. #endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */