remote_node_table.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. /*
  56. * This file contains the implementation of the SCIC_SDS_REMOTE_NODE_TABLE
  57. * public, protected, and private methods.
  58. */
  59. #include "remote_node_table.h"
  60. #include "remote_node_context.h"
  61. /**
  62. * sci_remote_node_table_get_group_index()
  63. * @remote_node_table: This is the remote node index table from which the
  64. * selection will be made.
  65. * @group_table_index: This is the index to the group table from which to
  66. * search for an available selection.
  67. *
  68. * This routine will find the bit position in absolute bit terms of the next 32
  69. * + bit position. If there are available bits in the first u32 then it is
  70. * just bit position. u32 This is the absolute bit position for an available
  71. * group.
  72. */
  73. static u32 sci_remote_node_table_get_group_index(
  74. struct sci_remote_node_table *remote_node_table,
  75. u32 group_table_index)
  76. {
  77. u32 dword_index;
  78. u32 *group_table;
  79. u32 bit_index;
  80. group_table = remote_node_table->remote_node_groups[group_table_index];
  81. for (dword_index = 0; dword_index < remote_node_table->group_array_size; dword_index++) {
  82. if (group_table[dword_index] != 0) {
  83. for (bit_index = 0; bit_index < 32; bit_index++) {
  84. if ((group_table[dword_index] & (1 << bit_index)) != 0) {
  85. return (dword_index * 32) + bit_index;
  86. }
  87. }
  88. }
  89. }
  90. return SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX;
  91. }
  92. /**
  93. * sci_remote_node_table_clear_group_index()
  94. * @remote_node_table: This the remote node table in which to clear the
  95. * selector.
  96. * @group_table_index: This is the remote node selector in which the change will be
  97. * made.
  98. * @group_index: This is the bit index in the table to be modified.
  99. *
  100. * This method will clear the group index entry in the specified group index
  101. * table. none
  102. */
  103. static void sci_remote_node_table_clear_group_index(
  104. struct sci_remote_node_table *remote_node_table,
  105. u32 group_table_index,
  106. u32 group_index)
  107. {
  108. u32 dword_index;
  109. u32 bit_index;
  110. u32 *group_table;
  111. BUG_ON(group_table_index >= SCU_STP_REMOTE_NODE_COUNT);
  112. BUG_ON(group_index >= (u32)(remote_node_table->group_array_size * 32));
  113. dword_index = group_index / 32;
  114. bit_index = group_index % 32;
  115. group_table = remote_node_table->remote_node_groups[group_table_index];
  116. group_table[dword_index] = group_table[dword_index] & ~(1 << bit_index);
  117. }
  118. /**
  119. * sci_remote_node_table_set_group_index()
  120. * @remote_node_table: This the remote node table in which to set the
  121. * selector.
  122. * @group_table_index: This is the remote node selector in which the change
  123. * will be made.
  124. * @group_index: This is the bit position in the table to be modified.
  125. *
  126. * This method will set the group index bit entry in the specified gropu index
  127. * table. none
  128. */
  129. static void sci_remote_node_table_set_group_index(
  130. struct sci_remote_node_table *remote_node_table,
  131. u32 group_table_index,
  132. u32 group_index)
  133. {
  134. u32 dword_index;
  135. u32 bit_index;
  136. u32 *group_table;
  137. BUG_ON(group_table_index >= SCU_STP_REMOTE_NODE_COUNT);
  138. BUG_ON(group_index >= (u32)(remote_node_table->group_array_size * 32));
  139. dword_index = group_index / 32;
  140. bit_index = group_index % 32;
  141. group_table = remote_node_table->remote_node_groups[group_table_index];
  142. group_table[dword_index] = group_table[dword_index] | (1 << bit_index);
  143. }
  144. /**
  145. * sci_remote_node_table_set_node_index()
  146. * @remote_node_table: This is the remote node table in which to modify
  147. * the remote node availability.
  148. * @remote_node_index: This is the remote node index that is being returned to
  149. * the table.
  150. *
  151. * This method will set the remote to available in the remote node allocation
  152. * table. none
  153. */
  154. static void sci_remote_node_table_set_node_index(
  155. struct sci_remote_node_table *remote_node_table,
  156. u32 remote_node_index)
  157. {
  158. u32 dword_location;
  159. u32 dword_remainder;
  160. u32 slot_normalized;
  161. u32 slot_position;
  162. BUG_ON(
  163. (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD)
  164. <= (remote_node_index / SCU_STP_REMOTE_NODE_COUNT)
  165. );
  166. dword_location = remote_node_index / SCIC_SDS_REMOTE_NODES_PER_DWORD;
  167. dword_remainder = remote_node_index % SCIC_SDS_REMOTE_NODES_PER_DWORD;
  168. slot_normalized = (dword_remainder / SCU_STP_REMOTE_NODE_COUNT) * sizeof(u32);
  169. slot_position = remote_node_index % SCU_STP_REMOTE_NODE_COUNT;
  170. remote_node_table->available_remote_nodes[dword_location] |=
  171. 1 << (slot_normalized + slot_position);
  172. }
  173. /**
  174. * sci_remote_node_table_clear_node_index()
  175. * @remote_node_table: This is the remote node table from which to clear
  176. * the available remote node bit.
  177. * @remote_node_index: This is the remote node index which is to be cleared
  178. * from the table.
  179. *
  180. * This method clears the remote node index from the table of available remote
  181. * nodes. none
  182. */
  183. static void sci_remote_node_table_clear_node_index(
  184. struct sci_remote_node_table *remote_node_table,
  185. u32 remote_node_index)
  186. {
  187. u32 dword_location;
  188. u32 dword_remainder;
  189. u32 slot_position;
  190. u32 slot_normalized;
  191. BUG_ON(
  192. (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD)
  193. <= (remote_node_index / SCU_STP_REMOTE_NODE_COUNT)
  194. );
  195. dword_location = remote_node_index / SCIC_SDS_REMOTE_NODES_PER_DWORD;
  196. dword_remainder = remote_node_index % SCIC_SDS_REMOTE_NODES_PER_DWORD;
  197. slot_normalized = (dword_remainder / SCU_STP_REMOTE_NODE_COUNT) * sizeof(u32);
  198. slot_position = remote_node_index % SCU_STP_REMOTE_NODE_COUNT;
  199. remote_node_table->available_remote_nodes[dword_location] &=
  200. ~(1 << (slot_normalized + slot_position));
  201. }
  202. /**
  203. * sci_remote_node_table_clear_group()
  204. * @remote_node_table: The remote node table from which the slot will be
  205. * cleared.
  206. * @group_index: The index for the slot that is to be cleared.
  207. *
  208. * This method clears the entire table slot at the specified slot index. none
  209. */
  210. static void sci_remote_node_table_clear_group(
  211. struct sci_remote_node_table *remote_node_table,
  212. u32 group_index)
  213. {
  214. u32 dword_location;
  215. u32 dword_remainder;
  216. u32 dword_value;
  217. BUG_ON(
  218. (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD)
  219. <= (group_index / SCU_STP_REMOTE_NODE_COUNT)
  220. );
  221. dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  222. dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  223. dword_value = remote_node_table->available_remote_nodes[dword_location];
  224. dword_value &= ~(SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4));
  225. remote_node_table->available_remote_nodes[dword_location] = dword_value;
  226. }
  227. /*
  228. * sci_remote_node_table_set_group()
  229. *
  230. * THis method sets an entire remote node group in the remote node table.
  231. */
  232. static void sci_remote_node_table_set_group(
  233. struct sci_remote_node_table *remote_node_table,
  234. u32 group_index)
  235. {
  236. u32 dword_location;
  237. u32 dword_remainder;
  238. u32 dword_value;
  239. BUG_ON(
  240. (remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD)
  241. <= (group_index / SCU_STP_REMOTE_NODE_COUNT)
  242. );
  243. dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  244. dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  245. dword_value = remote_node_table->available_remote_nodes[dword_location];
  246. dword_value |= (SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4));
  247. remote_node_table->available_remote_nodes[dword_location] = dword_value;
  248. }
  249. /**
  250. * sci_remote_node_table_get_group_value()
  251. * @remote_node_table: This is the remote node table that for which the group
  252. * value is to be returned.
  253. * @group_index: This is the group index to use to find the group value.
  254. *
  255. * This method will return the group value for the specified group index. The
  256. * bit values at the specified remote node group index.
  257. */
  258. static u8 sci_remote_node_table_get_group_value(
  259. struct sci_remote_node_table *remote_node_table,
  260. u32 group_index)
  261. {
  262. u32 dword_location;
  263. u32 dword_remainder;
  264. u32 dword_value;
  265. dword_location = group_index / SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  266. dword_remainder = group_index % SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD;
  267. dword_value = remote_node_table->available_remote_nodes[dword_location];
  268. dword_value &= (SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE << (dword_remainder * 4));
  269. dword_value = dword_value >> (dword_remainder * 4);
  270. return (u8)dword_value;
  271. }
  272. /**
  273. * sci_remote_node_table_initialize()
  274. * @remote_node_table: The remote that which is to be initialized.
  275. * @remote_node_entries: The number of entries to put in the table.
  276. *
  277. * This method will initialize the remote node table for use. none
  278. */
  279. void sci_remote_node_table_initialize(
  280. struct sci_remote_node_table *remote_node_table,
  281. u32 remote_node_entries)
  282. {
  283. u32 index;
  284. /*
  285. * Initialize the raw data we could improve the speed by only initializing
  286. * those entries that we are actually going to be used */
  287. memset(
  288. remote_node_table->available_remote_nodes,
  289. 0x00,
  290. sizeof(remote_node_table->available_remote_nodes)
  291. );
  292. memset(
  293. remote_node_table->remote_node_groups,
  294. 0x00,
  295. sizeof(remote_node_table->remote_node_groups)
  296. );
  297. /* Initialize the available remote node sets */
  298. remote_node_table->available_nodes_array_size = (u16)
  299. (remote_node_entries / SCIC_SDS_REMOTE_NODES_PER_DWORD)
  300. + ((remote_node_entries % SCIC_SDS_REMOTE_NODES_PER_DWORD) != 0);
  301. /* Initialize each full DWORD to a FULL SET of remote nodes */
  302. for (index = 0; index < remote_node_entries; index++) {
  303. sci_remote_node_table_set_node_index(remote_node_table, index);
  304. }
  305. remote_node_table->group_array_size = (u16)
  306. (remote_node_entries / (SCU_STP_REMOTE_NODE_COUNT * 32))
  307. + ((remote_node_entries % (SCU_STP_REMOTE_NODE_COUNT * 32)) != 0);
  308. for (index = 0; index < (remote_node_entries / SCU_STP_REMOTE_NODE_COUNT); index++) {
  309. /*
  310. * These are all guaranteed to be full slot values so fill them in the
  311. * available sets of 3 remote nodes */
  312. sci_remote_node_table_set_group_index(remote_node_table, 2, index);
  313. }
  314. /* Now fill in any remainders that we may find */
  315. if ((remote_node_entries % SCU_STP_REMOTE_NODE_COUNT) == 2) {
  316. sci_remote_node_table_set_group_index(remote_node_table, 1, index);
  317. } else if ((remote_node_entries % SCU_STP_REMOTE_NODE_COUNT) == 1) {
  318. sci_remote_node_table_set_group_index(remote_node_table, 0, index);
  319. }
  320. }
  321. /**
  322. * sci_remote_node_table_allocate_single_remote_node()
  323. * @remote_node_table: The remote node table from which to allocate a
  324. * remote node.
  325. * @group_table_index: The group index that is to be used for the search.
  326. *
  327. * This method will allocate a single RNi from the remote node table. The
  328. * table index will determine from which remote node group table to search.
  329. * This search may fail and another group node table can be specified. The
  330. * function is designed to allow a serach of the available single remote node
  331. * group up to the triple remote node group. If an entry is found in the
  332. * specified table the remote node is removed and the remote node groups are
  333. * updated. The RNi value or an invalid remote node context if an RNi can not
  334. * be found.
  335. */
  336. static u16 sci_remote_node_table_allocate_single_remote_node(
  337. struct sci_remote_node_table *remote_node_table,
  338. u32 group_table_index)
  339. {
  340. u8 index;
  341. u8 group_value;
  342. u32 group_index;
  343. u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
  344. group_index = sci_remote_node_table_get_group_index(
  345. remote_node_table, group_table_index);
  346. /* We could not find an available slot in the table selector 0 */
  347. if (group_index != SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX) {
  348. group_value = sci_remote_node_table_get_group_value(
  349. remote_node_table, group_index);
  350. for (index = 0; index < SCU_STP_REMOTE_NODE_COUNT; index++) {
  351. if (((1 << index) & group_value) != 0) {
  352. /* We have selected a bit now clear it */
  353. remote_node_index = (u16)(group_index * SCU_STP_REMOTE_NODE_COUNT
  354. + index);
  355. sci_remote_node_table_clear_group_index(
  356. remote_node_table, group_table_index, group_index
  357. );
  358. sci_remote_node_table_clear_node_index(
  359. remote_node_table, remote_node_index
  360. );
  361. if (group_table_index > 0) {
  362. sci_remote_node_table_set_group_index(
  363. remote_node_table, group_table_index - 1, group_index
  364. );
  365. }
  366. break;
  367. }
  368. }
  369. }
  370. return remote_node_index;
  371. }
  372. /**
  373. * sci_remote_node_table_allocate_triple_remote_node()
  374. * @remote_node_table: This is the remote node table from which to allocate the
  375. * remote node entries.
  376. * @group_table_index: This is the group table index which must equal two (2)
  377. * for this operation.
  378. *
  379. * This method will allocate three consecutive remote node context entries. If
  380. * there are no remaining triple entries the function will return a failure.
  381. * The remote node index that represents three consecutive remote node entries
  382. * or an invalid remote node context if none can be found.
  383. */
  384. static u16 sci_remote_node_table_allocate_triple_remote_node(
  385. struct sci_remote_node_table *remote_node_table,
  386. u32 group_table_index)
  387. {
  388. u32 group_index;
  389. u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
  390. group_index = sci_remote_node_table_get_group_index(
  391. remote_node_table, group_table_index);
  392. if (group_index != SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX) {
  393. remote_node_index = (u16)group_index * SCU_STP_REMOTE_NODE_COUNT;
  394. sci_remote_node_table_clear_group_index(
  395. remote_node_table, group_table_index, group_index
  396. );
  397. sci_remote_node_table_clear_group(
  398. remote_node_table, group_index
  399. );
  400. }
  401. return remote_node_index;
  402. }
  403. /**
  404. * sci_remote_node_table_allocate_remote_node()
  405. * @remote_node_table: This is the remote node table from which the remote node
  406. * allocation is to take place.
  407. * @remote_node_count: This is ther remote node count which is one of
  408. * SCU_SSP_REMOTE_NODE_COUNT(1) or SCU_STP_REMOTE_NODE_COUNT(3).
  409. *
  410. * This method will allocate a remote node that mataches the remote node count
  411. * specified by the caller. Valid values for remote node count is
  412. * SCU_SSP_REMOTE_NODE_COUNT(1) or SCU_STP_REMOTE_NODE_COUNT(3). u16 This is
  413. * the remote node index that is returned or an invalid remote node context.
  414. */
  415. u16 sci_remote_node_table_allocate_remote_node(
  416. struct sci_remote_node_table *remote_node_table,
  417. u32 remote_node_count)
  418. {
  419. u16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
  420. if (remote_node_count == SCU_SSP_REMOTE_NODE_COUNT) {
  421. remote_node_index =
  422. sci_remote_node_table_allocate_single_remote_node(
  423. remote_node_table, 0);
  424. if (remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
  425. remote_node_index =
  426. sci_remote_node_table_allocate_single_remote_node(
  427. remote_node_table, 1);
  428. }
  429. if (remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) {
  430. remote_node_index =
  431. sci_remote_node_table_allocate_single_remote_node(
  432. remote_node_table, 2);
  433. }
  434. } else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) {
  435. remote_node_index =
  436. sci_remote_node_table_allocate_triple_remote_node(
  437. remote_node_table, 2);
  438. }
  439. return remote_node_index;
  440. }
  441. /**
  442. * sci_remote_node_table_release_single_remote_node()
  443. * @remote_node_table: This is the remote node table from which the remote node
  444. * release is to take place.
  445. * @remote_node_index: This is the remote node index that is being released.
  446. * This method will free a single remote node index back to the remote node
  447. * table. This routine will update the remote node groups
  448. */
  449. static void sci_remote_node_table_release_single_remote_node(
  450. struct sci_remote_node_table *remote_node_table,
  451. u16 remote_node_index)
  452. {
  453. u32 group_index;
  454. u8 group_value;
  455. group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT;
  456. group_value = sci_remote_node_table_get_group_value(remote_node_table, group_index);
  457. /*
  458. * Assert that we are not trying to add an entry to a slot that is already
  459. * full. */
  460. BUG_ON(group_value == SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE);
  461. if (group_value == 0x00) {
  462. /*
  463. * There are no entries in this slot so it must be added to the single
  464. * slot table. */
  465. sci_remote_node_table_set_group_index(remote_node_table, 0, group_index);
  466. } else if ((group_value & (group_value - 1)) == 0) {
  467. /*
  468. * There is only one entry in this slot so it must be moved from the
  469. * single slot table to the dual slot table */
  470. sci_remote_node_table_clear_group_index(remote_node_table, 0, group_index);
  471. sci_remote_node_table_set_group_index(remote_node_table, 1, group_index);
  472. } else {
  473. /*
  474. * There are two entries in the slot so it must be moved from the dual
  475. * slot table to the tripple slot table. */
  476. sci_remote_node_table_clear_group_index(remote_node_table, 1, group_index);
  477. sci_remote_node_table_set_group_index(remote_node_table, 2, group_index);
  478. }
  479. sci_remote_node_table_set_node_index(remote_node_table, remote_node_index);
  480. }
  481. /**
  482. * sci_remote_node_table_release_triple_remote_node()
  483. * @remote_node_table: This is the remote node table to which the remote node
  484. * index is to be freed.
  485. * @remote_node_index: This is the remote node index that is being released.
  486. *
  487. * This method will release a group of three consecutive remote nodes back to
  488. * the free remote nodes.
  489. */
  490. static void sci_remote_node_table_release_triple_remote_node(
  491. struct sci_remote_node_table *remote_node_table,
  492. u16 remote_node_index)
  493. {
  494. u32 group_index;
  495. group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT;
  496. sci_remote_node_table_set_group_index(
  497. remote_node_table, 2, group_index
  498. );
  499. sci_remote_node_table_set_group(remote_node_table, group_index);
  500. }
  501. /**
  502. * sci_remote_node_table_release_remote_node_index()
  503. * @remote_node_table: The remote node table to which the remote node index is
  504. * to be freed.
  505. * @remote_node_count: This is the count of consecutive remote nodes that are
  506. * to be freed.
  507. * @remote_node_index: This is the remote node index that is being released.
  508. *
  509. * This method will release the remote node index back into the remote node
  510. * table free pool.
  511. */
  512. void sci_remote_node_table_release_remote_node_index(
  513. struct sci_remote_node_table *remote_node_table,
  514. u32 remote_node_count,
  515. u16 remote_node_index)
  516. {
  517. if (remote_node_count == SCU_SSP_REMOTE_NODE_COUNT) {
  518. sci_remote_node_table_release_single_remote_node(
  519. remote_node_table, remote_node_index);
  520. } else if (remote_node_count == SCU_STP_REMOTE_NODE_COUNT) {
  521. sci_remote_node_table_release_triple_remote_node(
  522. remote_node_table, remote_node_index);
  523. }
  524. }