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

Function mana_mr_btree_insert

dpdk/drivers/net/mana/mr.c:320–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

318}
319
320int
321mana_mr_btree_insert(struct mana_mr_btree *bt, struct mana_mr_cache *entry)
322{
323 struct mana_mr_cache *table;
324 uint16_t idx = 0;
325 uint16_t shift;
326 int ret;
327
328 ret = mana_mr_btree_lookup(bt, &idx, entry->addr, entry->len, &table);
329 if (ret)
330 return ret;
331
332 if (table) {
333 DP_LOG(DEBUG, "Addr 0x%" PRIxPTR " len %zu exists in btree",
334 entry->addr, entry->len);
335 return 0;
336 }
337
338 if (bt->len >= bt->size) {
339 DP_LOG(ERR, "Btree overflow detected len %u size %u",
340 bt->len, bt->size);
341 bt->overflow = 1;
342 return -1;
343 }
344
345 table = bt->table;
346
347 idx++;
348 shift = (bt->len - idx) * sizeof(struct mana_mr_cache);
349 if (shift) {
350 DP_LOG(DEBUG, "Moving %u bytes from idx %u to %u",
351 shift, idx, idx + 1);
352 memmove(&table[idx + 1], &table[idx], shift);
353 }
354
355 table[idx] = *entry;
356 bt->len++;
357
358 DP_LOG(DEBUG,
359 "Inserted MR b-tree table %p idx %d addr 0x%" PRIxPTR " len %zu",
360 table, idx, entry->addr, entry->len);
361
362 return 0;
363}

Callers 3

mana_mp_mr_createFunction · 0.85
mana_new_pmd_mrFunction · 0.85
mana_find_pmd_mrFunction · 0.85

Calls 2

mana_mr_btree_lookupFunction · 0.85
memmoveFunction · 0.50

Tested by

no test coverage detected