remote_node_context.c 36 KB

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