remote_node_context.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  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. #include "sci_base_state_machine.h"
  56. #include "scic_sds_controller.h"
  57. #include "scic_sds_port.h"
  58. #include "remote_device.h"
  59. #include "remote_node_context.h"
  60. #include "sci_environment.h"
  61. #include "sci_util.h"
  62. #include "scu_event_codes.h"
  63. #include "scu_task_context.h"
  64. /**
  65. *
  66. * @sci_rnc: The RNC for which the is posted request is being made.
  67. *
  68. * This method will return true if the RNC is not in the initial state. In all
  69. * other states the RNC is considered active and this will return true. The
  70. * destroy request of the state machine drives the RNC back to the initial
  71. * state. If the state machine changes then this routine will also have to be
  72. * changed. bool true if the state machine is not in the initial state false if
  73. * the state machine is in the initial state
  74. */
  75. /**
  76. *
  77. * @sci_rnc: The state of the remote node context object to check.
  78. *
  79. * This method will return true if the remote node context is in a READY state
  80. * otherwise it will return false bool true if the remote node context is in
  81. * the ready state. false if the remote node context is not in the ready state.
  82. */
  83. bool scic_sds_remote_node_context_is_ready(
  84. struct scic_sds_remote_node_context *sci_rnc)
  85. {
  86. u32 current_state = sci_base_state_machine_get_state(&sci_rnc->state_machine);
  87. if (current_state == SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE) {
  88. return true;
  89. }
  90. return false;
  91. }
  92. /**
  93. *
  94. * @sci_dev: The remote device to use to construct the RNC buffer.
  95. * @rnc: The buffer into which the remote device data will be copied.
  96. *
  97. * This method will construct the RNC buffer for this remote device object. none
  98. */
  99. static void scic_sds_remote_node_context_construct_buffer(
  100. struct scic_sds_remote_node_context *sci_rnc)
  101. {
  102. struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
  103. struct domain_device *dev = sci_dev_to_domain(sci_dev);
  104. int rni = sci_rnc->remote_node_index;
  105. union scu_remote_node_context *rnc;
  106. struct scic_sds_controller *scic;
  107. __le64 sas_addr;
  108. scic = scic_sds_remote_device_get_controller(sci_dev);
  109. rnc = scic_sds_controller_get_remote_node_context_buffer(scic, rni);
  110. memset(rnc, 0, sizeof(union scu_remote_node_context)
  111. * scic_sds_remote_device_node_count(sci_dev));
  112. rnc->ssp.remote_node_index = rni;
  113. rnc->ssp.remote_node_port_width = sci_dev->device_port_width;
  114. rnc->ssp.logical_port_index = sci_dev->owning_port->physical_port_index;
  115. /* sas address is __be64, context ram format is __le64 */
  116. sas_addr = cpu_to_le64(SAS_ADDR(dev->sas_addr));
  117. rnc->ssp.remote_sas_address_hi = upper_32_bits(sas_addr);
  118. rnc->ssp.remote_sas_address_lo = lower_32_bits(sas_addr);
  119. rnc->ssp.nexus_loss_timer_enable = true;
  120. rnc->ssp.check_bit = false;
  121. rnc->ssp.is_valid = false;
  122. rnc->ssp.is_remote_node_context = true;
  123. rnc->ssp.function_number = 0;
  124. rnc->ssp.arbitration_wait_time = 0;
  125. if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
  126. rnc->ssp.connection_occupancy_timeout =
  127. scic->user_parameters.sds1.stp_max_occupancy_timeout;
  128. rnc->ssp.connection_inactivity_timeout =
  129. scic->user_parameters.sds1.stp_inactivity_timeout;
  130. } else {
  131. rnc->ssp.connection_occupancy_timeout =
  132. scic->user_parameters.sds1.ssp_max_occupancy_timeout;
  133. rnc->ssp.connection_inactivity_timeout =
  134. scic->user_parameters.sds1.ssp_inactivity_timeout;
  135. }
  136. rnc->ssp.initial_arbitration_wait_time = 0;
  137. /* Open Address Frame Parameters */
  138. rnc->ssp.oaf_connection_rate = sci_dev->connection_rate;
  139. rnc->ssp.oaf_features = 0;
  140. rnc->ssp.oaf_source_zone_group = 0;
  141. rnc->ssp.oaf_more_compatibility_features = 0;
  142. }
  143. /**
  144. *
  145. * @sci_rnc:
  146. * @callback:
  147. * @callback_parameter:
  148. *
  149. * This method will setup the remote node context object so it will transition
  150. * to its ready state. If the remote node context is already setup to
  151. * transition to its final state then this function does nothing. none
  152. */
  153. static void scic_sds_remote_node_context_setup_to_resume(
  154. struct scic_sds_remote_node_context *sci_rnc,
  155. scics_sds_remote_node_context_callback callback,
  156. void *callback_parameter)
  157. {
  158. if (sci_rnc->destination_state != SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) {
  159. sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY;
  160. sci_rnc->user_callback = callback;
  161. sci_rnc->user_cookie = callback_parameter;
  162. }
  163. }
  164. /**
  165. *
  166. * @sci_rnc:
  167. * @callback:
  168. * @callback_parameter:
  169. *
  170. * This method will setup the remote node context object so it will transistion
  171. * to its final state. none
  172. */
  173. static void scic_sds_remote_node_context_setup_to_destory(
  174. struct scic_sds_remote_node_context *sci_rnc,
  175. scics_sds_remote_node_context_callback callback,
  176. void *callback_parameter)
  177. {
  178. sci_rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL;
  179. sci_rnc->user_callback = callback;
  180. sci_rnc->user_cookie = callback_parameter;
  181. }
  182. /**
  183. *
  184. * @sci_rnc:
  185. * @callback:
  186. *
  187. * This method will continue to resume a remote node context. This is used in
  188. * the states where a resume is requested while a resume is in progress.
  189. */
  190. static enum sci_status scic_sds_remote_node_context_continue_to_resume_handler(
  191. struct scic_sds_remote_node_context *sci_rnc,
  192. scics_sds_remote_node_context_callback callback,
  193. void *callback_parameter)
  194. {
  195. if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) {
  196. sci_rnc->user_callback = callback;
  197. sci_rnc->user_cookie = callback_parameter;
  198. return SCI_SUCCESS;
  199. }
  200. return SCI_FAILURE_INVALID_STATE;
  201. }
  202. /* --------------------------------------------------------------------------- */
  203. static enum sci_status scic_sds_remote_node_context_default_destruct_handler(
  204. struct scic_sds_remote_node_context *sci_rnc,
  205. scics_sds_remote_node_context_callback callback,
  206. void *callback_parameter)
  207. {
  208. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  209. "%s: SCIC Remote Node Context 0x%p requested to stop while "
  210. "in unexpected state %d\n",
  211. __func__,
  212. sci_rnc,
  213. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  214. /*
  215. * We have decided that the destruct request on the remote node context can not fail
  216. * since it is either in the initial/destroyed state or is can be destroyed. */
  217. return SCI_SUCCESS;
  218. }
  219. static enum sci_status scic_sds_remote_node_context_default_suspend_handler(
  220. struct scic_sds_remote_node_context *sci_rnc,
  221. u32 suspend_type,
  222. scics_sds_remote_node_context_callback callback,
  223. void *callback_parameter)
  224. {
  225. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  226. "%s: SCIC Remote Node Context 0x%p requested to suspend "
  227. "while in wrong state %d\n",
  228. __func__,
  229. sci_rnc,
  230. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  231. return SCI_FAILURE_INVALID_STATE;
  232. }
  233. static enum sci_status scic_sds_remote_node_context_default_resume_handler(
  234. struct scic_sds_remote_node_context *sci_rnc,
  235. scics_sds_remote_node_context_callback callback,
  236. void *callback_parameter)
  237. {
  238. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  239. "%s: SCIC Remote Node Context 0x%p requested to resume "
  240. "while in wrong state %d\n",
  241. __func__,
  242. sci_rnc,
  243. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  244. return SCI_FAILURE_INVALID_STATE;
  245. }
  246. static enum sci_status scic_sds_remote_node_context_default_start_io_handler(
  247. struct scic_sds_remote_node_context *sci_rnc,
  248. struct scic_sds_request *sci_req)
  249. {
  250. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  251. "%s: SCIC Remote Node Context 0x%p requested to start io "
  252. "0x%p while in wrong state %d\n",
  253. __func__,
  254. sci_rnc,
  255. sci_req,
  256. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  257. return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
  258. }
  259. static enum sci_status scic_sds_remote_node_context_default_start_task_handler(
  260. struct scic_sds_remote_node_context *sci_rnc,
  261. struct scic_sds_request *sci_req)
  262. {
  263. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  264. "%s: SCIC Remote Node Context 0x%p requested to start "
  265. "task 0x%p while in wrong state %d\n",
  266. __func__,
  267. sci_rnc,
  268. sci_req,
  269. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  270. return SCI_FAILURE;
  271. }
  272. static enum sci_status scic_sds_remote_node_context_default_event_handler(
  273. struct scic_sds_remote_node_context *sci_rnc,
  274. u32 event_code)
  275. {
  276. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  277. "%s: SCIC Remote Node Context 0x%p requested to process "
  278. "event 0x%x while in wrong state %d\n",
  279. __func__,
  280. sci_rnc,
  281. event_code,
  282. sci_base_state_machine_get_state(&sci_rnc->state_machine));
  283. return SCI_FAILURE_INVALID_STATE;
  284. }
  285. /**
  286. *
  287. * @sci_rnc: The rnc for which the task request is targeted.
  288. * @sci_req: The request which is going to be started.
  289. *
  290. * This method determines if the task request can be started by the SCU
  291. * hardware. When the RNC is in the ready state any task can be started.
  292. * enum sci_status SCI_SUCCESS
  293. */
  294. static enum sci_status scic_sds_remote_node_context_success_start_task_handler(
  295. struct scic_sds_remote_node_context *sci_rnc,
  296. struct scic_sds_request *sci_req)
  297. {
  298. return SCI_SUCCESS;
  299. }
  300. /**
  301. *
  302. * @sci_rnc:
  303. * @callback:
  304. * @callback_parameter:
  305. *
  306. * This method handles destruct calls from the various state handlers. The
  307. * remote node context can be requested to destroy from any state. If there was
  308. * a user callback it is always replaced with the request to destroy user
  309. * callback. enum sci_status
  310. */
  311. static enum sci_status scic_sds_remote_node_context_general_destruct_handler(
  312. struct scic_sds_remote_node_context *sci_rnc,
  313. scics_sds_remote_node_context_callback callback,
  314. void *callback_parameter)
  315. {
  316. scic_sds_remote_node_context_setup_to_destory(
  317. sci_rnc, callback, callback_parameter
  318. );
  319. sci_base_state_machine_change_state(
  320. &sci_rnc->state_machine,
  321. SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
  322. );
  323. return SCI_SUCCESS;
  324. }
  325. /* --------------------------------------------------------------------------- */
  326. static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler(
  327. struct scic_sds_remote_node_context *sci_rnc,
  328. scics_sds_remote_node_context_callback callback,
  329. void *callback_parameter)
  330. {
  331. if (sci_rnc->remote_node_index != SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
  332. scic_sds_remote_node_context_setup_to_resume(
  333. sci_rnc, callback, callback_parameter
  334. );
  335. scic_sds_remote_node_context_construct_buffer(sci_rnc);
  336. sci_base_state_machine_change_state(
  337. &sci_rnc->state_machine,
  338. SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
  339. );
  340. return SCI_SUCCESS;
  341. }
  342. return SCI_FAILURE_INVALID_STATE;
  343. }
  344. /* --------------------------------------------------------------------------- */
  345. static enum sci_status scic_sds_remote_node_context_posting_state_event_handler(
  346. struct scic_sds_remote_node_context *sci_rnc,
  347. u32 event_code)
  348. {
  349. enum sci_status status;
  350. switch (scu_get_event_code(event_code)) {
  351. case SCU_EVENT_POST_RNC_COMPLETE:
  352. status = SCI_SUCCESS;
  353. sci_base_state_machine_change_state(
  354. &sci_rnc->state_machine,
  355. SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
  356. );
  357. break;
  358. default:
  359. status = SCI_FAILURE;
  360. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  361. "%s: SCIC Remote Node Context 0x%p requested to "
  362. "process unexpected event 0x%x while in posting "
  363. "state\n",
  364. __func__,
  365. sci_rnc,
  366. event_code);
  367. break;
  368. }
  369. return status;
  370. }
  371. /* --------------------------------------------------------------------------- */
  372. static enum sci_status scic_sds_remote_node_context_invalidating_state_destruct_handler(
  373. struct scic_sds_remote_node_context *sci_rnc,
  374. scics_sds_remote_node_context_callback callback,
  375. void *callback_parameter)
  376. {
  377. scic_sds_remote_node_context_setup_to_destory(
  378. sci_rnc, callback, callback_parameter
  379. );
  380. return SCI_SUCCESS;
  381. }
  382. static enum sci_status scic_sds_remote_node_context_invalidating_state_event_handler(
  383. struct scic_sds_remote_node_context *sci_rnc,
  384. u32 event_code)
  385. {
  386. enum sci_status status;
  387. if (scu_get_event_code(event_code) == SCU_EVENT_POST_RNC_INVALIDATE_COMPLETE) {
  388. status = SCI_SUCCESS;
  389. if (sci_rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL) {
  390. sci_base_state_machine_change_state(
  391. &sci_rnc->state_machine,
  392. SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
  393. );
  394. } else {
  395. sci_base_state_machine_change_state(
  396. &sci_rnc->state_machine,
  397. SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
  398. );
  399. }
  400. } else {
  401. switch (scu_get_event_type(event_code)) {
  402. case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
  403. case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
  404. /*
  405. * We really dont care if the hardware is going to suspend
  406. * the device since it's being invalidated anyway */
  407. dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  408. "%s: SCIC Remote Node Context 0x%p was "
  409. "suspeneded by hardware while being "
  410. "invalidated.\n",
  411. __func__,
  412. sci_rnc);
  413. status = SCI_SUCCESS;
  414. break;
  415. default:
  416. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  417. "%s: SCIC Remote Node Context 0x%p "
  418. "requested to process event 0x%x while "
  419. "in state %d.\n",
  420. __func__,
  421. sci_rnc,
  422. event_code,
  423. sci_base_state_machine_get_state(
  424. &sci_rnc->state_machine));
  425. status = SCI_FAILURE;
  426. break;
  427. }
  428. }
  429. return status;
  430. }
  431. /* --------------------------------------------------------------------------- */
  432. static enum sci_status scic_sds_remote_node_context_resuming_state_event_handler(
  433. struct scic_sds_remote_node_context *sci_rnc,
  434. u32 event_code)
  435. {
  436. enum sci_status status;
  437. if (scu_get_event_code(event_code) == SCU_EVENT_POST_RCN_RELEASE) {
  438. status = SCI_SUCCESS;
  439. sci_base_state_machine_change_state(
  440. &sci_rnc->state_machine,
  441. SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
  442. );
  443. } else {
  444. switch (scu_get_event_type(event_code)) {
  445. case SCU_EVENT_TYPE_RNC_SUSPEND_TX:
  446. case SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX:
  447. /*
  448. * We really dont care if the hardware is going to suspend
  449. * the device since it's being resumed anyway */
  450. dev_dbg(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  451. "%s: SCIC Remote Node Context 0x%p was "
  452. "suspeneded by hardware while being resumed.\n",
  453. __func__,
  454. sci_rnc);
  455. status = SCI_SUCCESS;
  456. break;
  457. default:
  458. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  459. "%s: SCIC Remote Node Context 0x%p requested "
  460. "to process event 0x%x while in state %d.\n",
  461. __func__,
  462. sci_rnc,
  463. event_code,
  464. sci_base_state_machine_get_state(
  465. &sci_rnc->state_machine));
  466. status = SCI_FAILURE;
  467. break;
  468. }
  469. }
  470. return status;
  471. }
  472. /* --------------------------------------------------------------------------- */
  473. /**
  474. *
  475. * @sci_rnc: The remote node context object being suspended.
  476. * @callback: The callback when the suspension is complete.
  477. * @callback_parameter: The parameter that is to be passed into the callback.
  478. *
  479. * This method will handle the suspend requests from the ready state.
  480. * SCI_SUCCESS
  481. */
  482. static enum sci_status scic_sds_remote_node_context_ready_state_suspend_handler(
  483. struct scic_sds_remote_node_context *sci_rnc,
  484. u32 suspend_type,
  485. scics_sds_remote_node_context_callback callback,
  486. void *callback_parameter)
  487. {
  488. sci_rnc->user_callback = callback;
  489. sci_rnc->user_cookie = callback_parameter;
  490. sci_rnc->suspension_code = suspend_type;
  491. if (suspend_type == SCI_SOFTWARE_SUSPENSION) {
  492. scic_sds_remote_device_post_request(rnc_to_dev(sci_rnc),
  493. SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX);
  494. }
  495. sci_base_state_machine_change_state(
  496. &sci_rnc->state_machine,
  497. SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE
  498. );
  499. return SCI_SUCCESS;
  500. }
  501. /**
  502. *
  503. * @sci_rnc: The rnc for which the io request is targeted.
  504. * @sci_req: The request which is going to be started.
  505. *
  506. * This method determines if the io request can be started by the SCU hardware.
  507. * When the RNC is in the ready state any io request can be started. enum sci_status
  508. * SCI_SUCCESS
  509. */
  510. static enum sci_status scic_sds_remote_node_context_ready_state_start_io_handler(
  511. struct scic_sds_remote_node_context *sci_rnc,
  512. struct scic_sds_request *sci_req)
  513. {
  514. return SCI_SUCCESS;
  515. }
  516. static enum sci_status scic_sds_remote_node_context_ready_state_event_handler(
  517. struct scic_sds_remote_node_context *sci_rnc,
  518. u32 event_code)
  519. {
  520. enum sci_status status;
  521. switch (scu_get_event_type(event_code)) {
  522. case SCU_EVENT_TL_RNC_SUSPEND_TX:
  523. sci_base_state_machine_change_state(
  524. &sci_rnc->state_machine,
  525. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
  526. );
  527. sci_rnc->suspension_code = scu_get_event_specifier(event_code);
  528. status = SCI_SUCCESS;
  529. break;
  530. case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
  531. sci_base_state_machine_change_state(
  532. &sci_rnc->state_machine,
  533. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
  534. );
  535. sci_rnc->suspension_code = scu_get_event_specifier(event_code);
  536. status = SCI_SUCCESS;
  537. break;
  538. default:
  539. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  540. "%s: SCIC Remote Node Context 0x%p requested to "
  541. "process event 0x%x while in state %d.\n",
  542. __func__,
  543. sci_rnc,
  544. event_code,
  545. sci_base_state_machine_get_state(
  546. &sci_rnc->state_machine));
  547. status = SCI_FAILURE;
  548. break;
  549. }
  550. return status;
  551. }
  552. /* --------------------------------------------------------------------------- */
  553. static enum sci_status scic_sds_remote_node_context_tx_suspended_state_resume_handler(
  554. struct scic_sds_remote_node_context *sci_rnc,
  555. scics_sds_remote_node_context_callback callback,
  556. void *callback_parameter)
  557. {
  558. struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
  559. struct domain_device *dev = sci_dev_to_domain(sci_dev);
  560. enum sci_status status = SCI_SUCCESS;
  561. scic_sds_remote_node_context_setup_to_resume(sci_rnc, callback,
  562. callback_parameter);
  563. /* TODO: consider adding a resume action of NONE, INVALIDATE, WRITE_TLCR */
  564. if (dev->dev_type == SAS_END_DEV || dev_is_expander(dev))
  565. sci_base_state_machine_change_state(&sci_rnc->state_machine,
  566. SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
  567. else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
  568. if (sci_dev->is_direct_attached) {
  569. /* @todo Fix this since I am being silly in writing to the STPTLDARNI register. */
  570. sci_base_state_machine_change_state(
  571. &sci_rnc->state_machine,
  572. SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE);
  573. } else {
  574. sci_base_state_machine_change_state(
  575. &sci_rnc->state_machine,
  576. SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
  577. }
  578. } else
  579. status = SCI_FAILURE;
  580. return status;
  581. }
  582. /**
  583. *
  584. * @sci_rnc: The remote node context which is to receive the task request.
  585. * @sci_req: The task request to be transmitted to to the remote target
  586. * device.
  587. *
  588. * This method will report a success or failure attempt to start a new task
  589. * request to the hardware. Since all task requests are sent on the high
  590. * priority queue they can be sent when the RCN is in a TX suspend state.
  591. * enum sci_status SCI_SUCCESS
  592. */
  593. static enum sci_status scic_sds_remote_node_context_suspended_start_task_handler(
  594. struct scic_sds_remote_node_context *sci_rnc,
  595. struct scic_sds_request *sci_req)
  596. {
  597. scic_sds_remote_node_context_resume(sci_rnc, NULL, NULL);
  598. return SCI_SUCCESS;
  599. }
  600. /* --------------------------------------------------------------------------- */
  601. static enum sci_status scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler(
  602. struct scic_sds_remote_node_context *sci_rnc,
  603. scics_sds_remote_node_context_callback callback,
  604. void *callback_parameter)
  605. {
  606. scic_sds_remote_node_context_setup_to_resume(
  607. sci_rnc, callback, callback_parameter
  608. );
  609. sci_base_state_machine_change_state(
  610. &sci_rnc->state_machine,
  611. SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE
  612. );
  613. return SCI_FAILURE_INVALID_STATE;
  614. }
  615. /* --------------------------------------------------------------------------- */
  616. /**
  617. *
  618. *
  619. *
  620. */
  621. static enum sci_status scic_sds_remote_node_context_await_suspension_state_resume_handler(
  622. struct scic_sds_remote_node_context *sci_rnc,
  623. scics_sds_remote_node_context_callback callback,
  624. void *callback_parameter)
  625. {
  626. scic_sds_remote_node_context_setup_to_resume(
  627. sci_rnc, callback, callback_parameter
  628. );
  629. return SCI_SUCCESS;
  630. }
  631. /**
  632. *
  633. * @sci_rnc: The remote node context which is to receive the task request.
  634. * @sci_req: The task request to be transmitted to to the remote target
  635. * device.
  636. *
  637. * This method will report a success or failure attempt to start a new task
  638. * request to the hardware. Since all task requests are sent on the high
  639. * priority queue they can be sent when the RCN is in a TX suspend state.
  640. * enum sci_status SCI_SUCCESS
  641. */
  642. static enum sci_status scic_sds_remote_node_context_await_suspension_state_start_task_handler(
  643. struct scic_sds_remote_node_context *sci_rnc,
  644. struct scic_sds_request *sci_req)
  645. {
  646. return SCI_SUCCESS;
  647. }
  648. static enum sci_status scic_sds_remote_node_context_await_suspension_state_event_handler(
  649. struct scic_sds_remote_node_context *sci_rnc,
  650. u32 event_code)
  651. {
  652. enum sci_status status;
  653. switch (scu_get_event_type(event_code)) {
  654. case SCU_EVENT_TL_RNC_SUSPEND_TX:
  655. sci_base_state_machine_change_state(
  656. &sci_rnc->state_machine,
  657. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
  658. );
  659. sci_rnc->suspension_code = scu_get_event_specifier(event_code);
  660. status = SCI_SUCCESS;
  661. break;
  662. case SCU_EVENT_TL_RNC_SUSPEND_TX_RX:
  663. sci_base_state_machine_change_state(
  664. &sci_rnc->state_machine,
  665. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
  666. );
  667. sci_rnc->suspension_code = scu_get_event_specifier(event_code);
  668. status = SCI_SUCCESS;
  669. break;
  670. default:
  671. dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
  672. "%s: SCIC Remote Node Context 0x%p requested to "
  673. "process event 0x%x while in state %d.\n",
  674. __func__,
  675. sci_rnc,
  676. event_code,
  677. sci_base_state_machine_get_state(
  678. &sci_rnc->state_machine));
  679. status = SCI_FAILURE;
  680. break;
  681. }
  682. return status;
  683. }
  684. /* --------------------------------------------------------------------------- */
  685. static struct scic_sds_remote_node_context_handlers
  686. scic_sds_remote_node_context_state_handler_table[
  687. SCIC_SDS_REMOTE_NODE_CONTEXT_MAX_STATES] =
  688. {
  689. /* SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE */
  690. {
  691. scic_sds_remote_node_context_default_destruct_handler,
  692. scic_sds_remote_node_context_default_suspend_handler,
  693. scic_sds_remote_node_context_initial_state_resume_handler,
  694. scic_sds_remote_node_context_default_start_io_handler,
  695. scic_sds_remote_node_context_default_start_task_handler,
  696. scic_sds_remote_node_context_default_event_handler
  697. },
  698. /* SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE */
  699. {
  700. scic_sds_remote_node_context_general_destruct_handler,
  701. scic_sds_remote_node_context_default_suspend_handler,
  702. scic_sds_remote_node_context_continue_to_resume_handler,
  703. scic_sds_remote_node_context_default_start_io_handler,
  704. scic_sds_remote_node_context_default_start_task_handler,
  705. scic_sds_remote_node_context_posting_state_event_handler
  706. },
  707. /* SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE */
  708. {
  709. scic_sds_remote_node_context_invalidating_state_destruct_handler,
  710. scic_sds_remote_node_context_default_suspend_handler,
  711. scic_sds_remote_node_context_continue_to_resume_handler,
  712. scic_sds_remote_node_context_default_start_io_handler,
  713. scic_sds_remote_node_context_default_start_task_handler,
  714. scic_sds_remote_node_context_invalidating_state_event_handler
  715. },
  716. /* SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE */
  717. {
  718. scic_sds_remote_node_context_general_destruct_handler,
  719. scic_sds_remote_node_context_default_suspend_handler,
  720. scic_sds_remote_node_context_continue_to_resume_handler,
  721. scic_sds_remote_node_context_default_start_io_handler,
  722. scic_sds_remote_node_context_success_start_task_handler,
  723. scic_sds_remote_node_context_resuming_state_event_handler
  724. },
  725. /* SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE */
  726. {
  727. scic_sds_remote_node_context_general_destruct_handler,
  728. scic_sds_remote_node_context_ready_state_suspend_handler,
  729. scic_sds_remote_node_context_default_resume_handler,
  730. scic_sds_remote_node_context_ready_state_start_io_handler,
  731. scic_sds_remote_node_context_success_start_task_handler,
  732. scic_sds_remote_node_context_ready_state_event_handler
  733. },
  734. /* SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE */
  735. {
  736. scic_sds_remote_node_context_general_destruct_handler,
  737. scic_sds_remote_node_context_default_suspend_handler,
  738. scic_sds_remote_node_context_tx_suspended_state_resume_handler,
  739. scic_sds_remote_node_context_default_start_io_handler,
  740. scic_sds_remote_node_context_suspended_start_task_handler,
  741. scic_sds_remote_node_context_default_event_handler
  742. },
  743. /* SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE */
  744. {
  745. scic_sds_remote_node_context_general_destruct_handler,
  746. scic_sds_remote_node_context_default_suspend_handler,
  747. scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler,
  748. scic_sds_remote_node_context_default_start_io_handler,
  749. scic_sds_remote_node_context_suspended_start_task_handler,
  750. scic_sds_remote_node_context_default_event_handler
  751. },
  752. /* SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE */
  753. {
  754. scic_sds_remote_node_context_general_destruct_handler,
  755. scic_sds_remote_node_context_default_suspend_handler,
  756. scic_sds_remote_node_context_await_suspension_state_resume_handler,
  757. scic_sds_remote_node_context_default_start_io_handler,
  758. scic_sds_remote_node_context_await_suspension_state_start_task_handler,
  759. scic_sds_remote_node_context_await_suspension_state_event_handler
  760. }
  761. };
  762. /*
  763. * *****************************************************************************
  764. * * REMOTE NODE CONTEXT PRIVATE METHODS
  765. * ***************************************************************************** */
  766. /**
  767. *
  768. *
  769. * This method just calls the user callback function and then resets the
  770. * callback.
  771. */
  772. static void scic_sds_remote_node_context_notify_user(
  773. struct scic_sds_remote_node_context *rnc)
  774. {
  775. if (rnc->user_callback != NULL) {
  776. (*rnc->user_callback)(rnc->user_cookie);
  777. rnc->user_callback = NULL;
  778. rnc->user_cookie = NULL;
  779. }
  780. }
  781. /**
  782. *
  783. *
  784. * This method will continue the remote node context state machine by
  785. * requesting to resume the remote node context state machine from its current
  786. * state.
  787. */
  788. static void scic_sds_remote_node_context_continue_state_transitions(
  789. struct scic_sds_remote_node_context *rnc)
  790. {
  791. if (rnc->destination_state == SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY) {
  792. rnc->state_handlers->resume_handler(
  793. rnc, rnc->user_callback, rnc->user_cookie
  794. );
  795. }
  796. }
  797. /**
  798. *
  799. * @sci_rnc: The remote node context object that is to be validated.
  800. *
  801. * This method will mark the rnc buffer as being valid and post the request to
  802. * the hardware. none
  803. */
  804. static void scic_sds_remote_node_context_validate_context_buffer(
  805. struct scic_sds_remote_node_context *sci_rnc)
  806. {
  807. struct scic_sds_remote_device *sci_dev = rnc_to_dev(sci_rnc);
  808. struct domain_device *dev = sci_dev_to_domain(sci_dev);
  809. union scu_remote_node_context *rnc_buffer;
  810. rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
  811. scic_sds_remote_device_get_controller(sci_dev),
  812. sci_rnc->remote_node_index
  813. );
  814. rnc_buffer->ssp.is_valid = true;
  815. if (!sci_dev->is_direct_attached &&
  816. (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP))) {
  817. scic_sds_remote_device_post_request(sci_dev,
  818. SCU_CONTEXT_COMMAND_POST_RNC_96);
  819. } else {
  820. scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_32);
  821. if (sci_dev->is_direct_attached) {
  822. scic_sds_port_setup_transports(sci_dev->owning_port,
  823. sci_rnc->remote_node_index);
  824. }
  825. }
  826. }
  827. /**
  828. *
  829. * @sci_rnc: The remote node context object that is to be invalidated.
  830. *
  831. * This method will update the RNC buffer and post the invalidate request. none
  832. */
  833. static void scic_sds_remote_node_context_invalidate_context_buffer(
  834. struct scic_sds_remote_node_context *sci_rnc)
  835. {
  836. union scu_remote_node_context *rnc_buffer;
  837. rnc_buffer = scic_sds_controller_get_remote_node_context_buffer(
  838. scic_sds_remote_device_get_controller(rnc_to_dev(sci_rnc)),
  839. sci_rnc->remote_node_index);
  840. rnc_buffer->ssp.is_valid = false;
  841. scic_sds_remote_device_post_request(rnc_to_dev(sci_rnc),
  842. SCU_CONTEXT_COMMAND_POST_RNC_INVALIDATE);
  843. }
  844. /*
  845. * *****************************************************************************
  846. * * REMOTE NODE CONTEXT STATE ENTER AND EXIT METHODS
  847. * ***************************************************************************** */
  848. /**
  849. *
  850. *
  851. *
  852. */
  853. static void scic_sds_remote_node_context_initial_state_enter(void *object)
  854. {
  855. struct scic_sds_remote_node_context *rnc;
  856. rnc = (struct scic_sds_remote_node_context *)object;
  857. SET_STATE_HANDLER(
  858. rnc,
  859. scic_sds_remote_node_context_state_handler_table,
  860. SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
  861. );
  862. /*
  863. * Check to see if we have gotten back to the initial state because someone
  864. * requested to destroy the remote node context object. */
  865. if (
  866. rnc->state_machine.previous_state_id
  867. == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
  868. ) {
  869. rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
  870. scic_sds_remote_node_context_notify_user(rnc);
  871. }
  872. }
  873. /**
  874. *
  875. *
  876. *
  877. */
  878. static void scic_sds_remote_node_context_posting_state_enter(void *object)
  879. {
  880. struct scic_sds_remote_node_context *sci_rnc;
  881. sci_rnc = (struct scic_sds_remote_node_context *)object;
  882. SET_STATE_HANDLER(
  883. sci_rnc,
  884. scic_sds_remote_node_context_state_handler_table,
  885. SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE
  886. );
  887. scic_sds_remote_node_context_validate_context_buffer(sci_rnc);
  888. }
  889. /**
  890. *
  891. *
  892. *
  893. */
  894. static void scic_sds_remote_node_context_invalidating_state_enter(void *object)
  895. {
  896. struct scic_sds_remote_node_context *rnc;
  897. rnc = (struct scic_sds_remote_node_context *)object;
  898. SET_STATE_HANDLER(
  899. rnc,
  900. scic_sds_remote_node_context_state_handler_table,
  901. SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
  902. );
  903. scic_sds_remote_node_context_invalidate_context_buffer(rnc);
  904. }
  905. /**
  906. *
  907. *
  908. *
  909. */
  910. static void scic_sds_remote_node_context_resuming_state_enter(void *object)
  911. {
  912. struct scic_sds_remote_node_context *rnc;
  913. struct scic_sds_remote_device *sci_dev;
  914. struct domain_device *dev;
  915. rnc = (struct scic_sds_remote_node_context *)object;
  916. sci_dev = rnc_to_dev(rnc);
  917. dev = sci_dev_to_domain(sci_dev);
  918. SET_STATE_HANDLER(
  919. rnc,
  920. scic_sds_remote_node_context_state_handler_table,
  921. SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE
  922. );
  923. /*
  924. * For direct attached SATA devices we need to clear the TLCR
  925. * NCQ to TCi tag mapping on the phy and in cases where we
  926. * resume because of a target reset we also need to update
  927. * the STPTLDARNI register with the RNi of the device
  928. */
  929. if ((dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) &&
  930. sci_dev->is_direct_attached)
  931. scic_sds_port_setup_transports(sci_dev->owning_port,
  932. rnc->remote_node_index);
  933. scic_sds_remote_device_post_request(sci_dev, SCU_CONTEXT_COMMAND_POST_RNC_RESUME);
  934. }
  935. /**
  936. *
  937. *
  938. *
  939. */
  940. static void scic_sds_remote_node_context_ready_state_enter(void *object)
  941. {
  942. struct scic_sds_remote_node_context *rnc;
  943. rnc = (struct scic_sds_remote_node_context *)object;
  944. SET_STATE_HANDLER(
  945. rnc,
  946. scic_sds_remote_node_context_state_handler_table,
  947. SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE
  948. );
  949. rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
  950. if (rnc->user_callback != NULL) {
  951. scic_sds_remote_node_context_notify_user(rnc);
  952. }
  953. }
  954. /**
  955. *
  956. *
  957. *
  958. */
  959. static void scic_sds_remote_node_context_tx_suspended_state_enter(void *object)
  960. {
  961. struct scic_sds_remote_node_context *rnc;
  962. rnc = (struct scic_sds_remote_node_context *)object;
  963. SET_STATE_HANDLER(
  964. rnc,
  965. scic_sds_remote_node_context_state_handler_table,
  966. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE
  967. );
  968. scic_sds_remote_node_context_continue_state_transitions(rnc);
  969. }
  970. /**
  971. *
  972. *
  973. *
  974. */
  975. static void scic_sds_remote_node_context_tx_rx_suspended_state_enter(
  976. void *object)
  977. {
  978. struct scic_sds_remote_node_context *rnc;
  979. rnc = (struct scic_sds_remote_node_context *)object;
  980. SET_STATE_HANDLER(
  981. rnc,
  982. scic_sds_remote_node_context_state_handler_table,
  983. SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE
  984. );
  985. scic_sds_remote_node_context_continue_state_transitions(rnc);
  986. }
  987. /**
  988. *
  989. *
  990. *
  991. */
  992. static void scic_sds_remote_node_context_await_suspension_state_enter(
  993. void *object)
  994. {
  995. struct scic_sds_remote_node_context *rnc;
  996. rnc = (struct scic_sds_remote_node_context *)object;
  997. SET_STATE_HANDLER(
  998. rnc,
  999. scic_sds_remote_node_context_state_handler_table,
  1000. SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE
  1001. );
  1002. }
  1003. /* --------------------------------------------------------------------------- */
  1004. static const struct sci_base_state scic_sds_remote_node_context_state_table[] = {
  1005. [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
  1006. .enter_state = scic_sds_remote_node_context_initial_state_enter,
  1007. },
  1008. [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
  1009. .enter_state = scic_sds_remote_node_context_posting_state_enter,
  1010. },
  1011. [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
  1012. .enter_state = scic_sds_remote_node_context_invalidating_state_enter,
  1013. },
  1014. [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
  1015. .enter_state = scic_sds_remote_node_context_resuming_state_enter,
  1016. },
  1017. [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
  1018. .enter_state = scic_sds_remote_node_context_ready_state_enter,
  1019. },
  1020. [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
  1021. .enter_state = scic_sds_remote_node_context_tx_suspended_state_enter,
  1022. },
  1023. [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
  1024. .enter_state = scic_sds_remote_node_context_tx_rx_suspended_state_enter,
  1025. },
  1026. [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = {
  1027. .enter_state = scic_sds_remote_node_context_await_suspension_state_enter,
  1028. },
  1029. };
  1030. void scic_sds_remote_node_context_construct(struct scic_sds_remote_node_context *rnc,
  1031. u16 remote_node_index)
  1032. {
  1033. memset(rnc, 0, sizeof(struct scic_sds_remote_node_context));
  1034. rnc->remote_node_index = remote_node_index;
  1035. rnc->destination_state = SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED;
  1036. sci_base_state_machine_construct(
  1037. &rnc->state_machine,
  1038. &rnc->parent,
  1039. scic_sds_remote_node_context_state_table,
  1040. SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE
  1041. );
  1042. sci_base_state_machine_start(&rnc->state_machine);
  1043. }