/** * This method will allocate a single RNi from the remote node table. The * table index will determine from which remote node group table to search. * This search may fail and another group node table can be specified. The * function is designed to allow a serach of the available single remote node * group up to the triple remote node group. If an entry is found in the * specified table the remote node is removed and the remote node groups are * updated. * * @param[in out] remote_node_table The remote node table from which to * allocate a remote node. * @param[in] table_index The group index that is to be used for the search. * * @return The RNi value or an invalid remote node context if an RNi can not * be found. */ static U16 scic_sds_remote_node_table_allocate_single_remote_node( SCIC_REMOTE_NODE_TABLE_T * remote_node_table, U32 group_table_index ) { U8 index; U8 group_value; U32 group_index; U16 remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; group_index = scic_sds_remote_node_table_get_group_index( remote_node_table, group_table_index); // We could not find an available slot in the table selector 0 if (group_index != SCIC_SDS_REMOTE_NODE_TABLE_INVALID_INDEX) { group_value = scic_sds_remote_node_table_get_group_value( remote_node_table, group_index); for (index = 0; index < SCU_STP_REMOTE_NODE_COUNT; index++) { if (((1 << index) & group_value) != 0) { // We have selected a bit now clear it remote_node_index = (U16) (group_index * SCU_STP_REMOTE_NODE_COUNT + index); scic_sds_remote_node_table_clear_group_index( remote_node_table, group_table_index, group_index ); scic_sds_remote_node_table_clear_node_index( remote_node_table, remote_node_index ); if (group_table_index > 0) { scic_sds_remote_node_table_set_group_index( remote_node_table, group_table_index - 1, group_index ); } break; } } } return remote_node_index; }
/** * This method will free a single remote node index back to the remote node * table. This routine will update the remote node groups * * @param[in] remote_node_table * @param[in] remote_node_index */ static void scic_sds_remote_node_table_release_single_remote_node( SCIC_REMOTE_NODE_TABLE_T * remote_node_table, U16 remote_node_index ) { U32 group_index; U8 group_value; group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT; group_value = scic_sds_remote_node_table_get_group_value(remote_node_table, group_index); // Assert that we are not trying to add an entry to a slot that is already // full. ASSERT(group_value != SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE); if (group_value == 0x00) { // There are no entries in this slot so it must be added to the single // slot table. scic_sds_remote_node_table_set_group_index(remote_node_table, 0, group_index); } else if ((group_value & (group_value -1)) == 0) { // There is only one entry in this slot so it must be moved from the // single slot table to the dual slot table scic_sds_remote_node_table_clear_group_index(remote_node_table, 0, group_index); scic_sds_remote_node_table_set_group_index(remote_node_table, 1, group_index); } else { // There are two entries in the slot so it must be moved from the dual // slot table to the tripple slot table. scic_sds_remote_node_table_clear_group_index(remote_node_table, 1, group_index); scic_sds_remote_node_table_set_group_index(remote_node_table, 2, group_index); } scic_sds_remote_node_table_set_node_index(remote_node_table, remote_node_index); }
/** * * @remote_node_table: * * This method will free a single remote node index back to the remote node * table. This routine will update the remote node groups */ static void scic_sds_remote_node_table_release_single_remote_node( struct scic_remote_node_table *remote_node_table, u16 remote_node_index) { u32 group_index; u8 group_value; group_index = remote_node_index / SCU_STP_REMOTE_NODE_COUNT; group_value = scic_sds_remote_node_table_get_group_value(remote_node_table, group_index); /* * Assert that we are not trying to add an entry to a slot that is already * full. */ BUG_ON(group_value == SCIC_SDS_REMOTE_NODE_TABLE_FULL_SLOT_VALUE); if (group_value == 0x00) { /* * There are no entries in this slot so it must be added to the single * slot table. */ scic_sds_remote_node_table_set_group_index(remote_node_table, 0, group_index); } else if ((group_value & (group_value - 1)) == 0) { /* * There is only one entry in this slot so it must be moved from the * single slot table to the dual slot table */ scic_sds_remote_node_table_clear_group_index(remote_node_table, 0, group_index); scic_sds_remote_node_table_set_group_index(remote_node_table, 1, group_index); } else { /* * There are two entries in the slot so it must be moved from the dual * slot table to the tripple slot table. */ scic_sds_remote_node_table_clear_group_index(remote_node_table, 1, group_index); scic_sds_remote_node_table_set_group_index(remote_node_table, 2, group_index); } scic_sds_remote_node_table_set_node_index(remote_node_table, remote_node_index); }