MCPcopy Create free account
hub / github.com/F-Stack/f-stack / efd_compute_update

Function efd_compute_update

dpdk/lib/efd/rte_efd.c:956–1157  ·  view source on GitHub ↗

* Computes an updated table entry where the supplied key points to a new host. * If no entry exists, one is inserted. * * This function does NOT modify the online table(s) * This function DOES modify the offline table * * @param table * EFD table to reference * @param socket_id * Socket ID to use to lookup existing values (ideally caller's socket id) * @param key * Key to insert

Source from the content-addressed store, hash-verified

954 * subsequent use of the entry content will likely be invalid
955 */
956static inline int
957efd_compute_update(struct rte_efd_table * const table,
958 const unsigned int socket_id, const void *key,
959 const efd_value_t value, uint32_t * const chunk_id,
960 uint32_t * const group_id, uint32_t * const bin_id,
961 uint8_t * const new_bin_choice,
962 struct efd_online_group_entry * const entry)
963{
964 unsigned int i;
965 int ret;
966 uint32_t new_idx;
967 void *new_k, *slot_id = NULL;
968 int status = EXIT_SUCCESS;
969 unsigned int found = 0;
970
971 efd_compute_ids(table, key, chunk_id, bin_id);
972
973 struct efd_offline_chunk_rules * const chunk =
974 &table->offline_chunks[*chunk_id];
975 struct efd_offline_group_rules *new_group;
976
977 uint8_t current_choice = efd_get_choice(table, socket_id,
978 *chunk_id, *bin_id);
979 uint32_t current_group_id = efd_bin_to_group[current_choice][*bin_id];
980 struct efd_offline_group_rules * const current_group =
981 &chunk->group_rules[current_group_id];
982 uint8_t bin_size = 0;
983 uint8_t key_changed_index = 0;
984 efd_value_t key_changed_previous_value = 0;
985 uint32_t key_idx_previous = 0;
986
987 /* Scan the current group and see if the key is already present */
988 for (i = 0; i < current_group->num_rules; i++) {
989 if (current_group->bin_id[i] == *bin_id)
990 bin_size++;
991 else
992 continue;
993
994 void *key_stored = EFD_KEY(current_group->key_idx[i], table);
995 if (found == 0 && unlikely(memcmp(key_stored, key,
996 table->key_len) == 0)) {
997 /* Key is already present */
998
999 /*
1000 * If previous value is same as new value,
1001 * no additional work is required
1002 */
1003 if (current_group->value[i] == value)
1004 return RTE_EFD_UPDATE_NO_CHANGE;
1005
1006 key_idx_previous = current_group->key_idx[i];
1007 key_changed_previous_value = current_group->value[i];
1008 key_changed_index = i;
1009 current_group->value[i] = value;
1010 found = 1;
1011 }
1012 }
1013

Callers 1

rte_efd_updateFunction · 0.85

Calls 8

efd_compute_idsFunction · 0.85
efd_get_choiceFunction · 0.85
rte_ring_sc_dequeueFunction · 0.85
move_groupsFunction · 0.85
efd_search_hashFunction · 0.85
revert_groupsFunction · 0.85
rte_prefetch0Function · 0.50
rte_memcpyFunction · 0.50

Tested by

no test coverage detected