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

Function rte_efd_delete

dpdk/lib/efd/rte_efd.c:1182–1237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1180}
1181
1182int
1183rte_efd_delete(struct rte_efd_table * const table, const unsigned int socket_id,
1184 const void *key, efd_value_t * const prev_value)
1185{
1186 unsigned int i;
1187 uint32_t chunk_id, bin_id;
1188 uint8_t not_found = 1;
1189
1190 efd_compute_ids(table, key, &chunk_id, &bin_id);
1191
1192 struct efd_offline_chunk_rules * const chunk =
1193 &table->offline_chunks[chunk_id];
1194
1195 uint8_t current_choice = efd_get_choice(table, socket_id,
1196 chunk_id, bin_id);
1197 uint32_t current_group_id = efd_bin_to_group[current_choice][bin_id];
1198 struct efd_offline_group_rules * const current_group =
1199 &chunk->group_rules[current_group_id];
1200
1201 /*
1202 * Search the current group for the specified key.
1203 * If it exists, remove it and re-pack the other values
1204 */
1205 for (i = 0; i < current_group->num_rules; i++) {
1206 if (not_found) {
1207 /* Found key that needs to be removed */
1208 if (memcmp(EFD_KEY(current_group->key_idx[i], table),
1209 key, table->key_len) == 0) {
1210 /* Store previous value if requested by caller */
1211 if (prev_value != NULL)
1212 *prev_value = current_group->value[i];
1213
1214 not_found = 0;
1215 rte_ring_sp_enqueue(table->free_slots,
1216 (void *)((uintptr_t)current_group->key_idx[i]));
1217 }
1218 } else {
1219 /*
1220 * If the desired key has been found,
1221 * need to shift other values up one
1222 */
1223
1224 /* Need to shift this entry back up one index */
1225 current_group->key_idx[i - 1] = current_group->key_idx[i];
1226 current_group->value[i - 1] = current_group->value[i];
1227 current_group->bin_id[i - 1] = current_group->bin_id[i];
1228 }
1229 }
1230
1231 if (not_found == 0) {
1232 table->num_rules--;
1233 current_group->num_rules--;
1234 }
1235
1236 return not_found;
1237}
1238
1239static inline efd_value_t

Callers 4

test_add_deleteFunction · 0.85
test_add_update_deleteFunction · 0.85
test_five_keysFunction · 0.85
timed_deletesFunction · 0.85

Calls 3

efd_compute_idsFunction · 0.85
efd_get_choiceFunction · 0.85
rte_ring_sp_enqueueFunction · 0.85

Tested by 4

test_add_deleteFunction · 0.68
test_add_update_deleteFunction · 0.68
test_five_keysFunction · 0.68
timed_deletesFunction · 0.68