Lines Matching refs:lpm

162 tbl8_pool_init(struct rte_lpm6 *lpm)  in tbl8_pool_init()  argument
167 for (i = 0; i < lpm->number_tbl8s; i++) in tbl8_pool_init()
168 lpm->tbl8_pool[i] = i; in tbl8_pool_init()
170 lpm->tbl8_pool_pos = 0; in tbl8_pool_init()
177 tbl8_get(struct rte_lpm6 *lpm, uint32_t *tbl8_ind) in tbl8_get() argument
179 if (lpm->tbl8_pool_pos == lpm->number_tbl8s) in tbl8_get()
184 *tbl8_ind = lpm->tbl8_pool[lpm->tbl8_pool_pos++]; in tbl8_get()
192 tbl8_put(struct rte_lpm6 *lpm, uint32_t tbl8_ind) in tbl8_put() argument
194 if (lpm->tbl8_pool_pos == 0) in tbl8_put()
198 lpm->tbl8_pool[--lpm->tbl8_pool_pos] = tbl8_ind; in tbl8_put()
206 tbl8_available(struct rte_lpm6 *lpm) in tbl8_available() argument
208 return lpm->number_tbl8s - lpm->tbl8_pool_pos; in tbl8_available()
227 rebuild_lpm(struct rte_lpm6 *lpm)
233 while (rte_hash_iterate(lpm->rules_tbl, (void *) &rule_key,
235 rte_lpm6_add(lpm, rule_key->ip, rule_key->depth,
248 struct rte_lpm6 *lpm = NULL; in rte_lpm6_create() local
315 mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) * in rte_lpm6_create()
323 lpm = (struct rte_lpm6 *) te->data; in rte_lpm6_create()
324 if (strncmp(name, lpm->name, RTE_LPM6_NAMESIZE) == 0) in rte_lpm6_create()
327 lpm = NULL; in rte_lpm6_create()
343 lpm = rte_zmalloc_socket(mem_name, (size_t)mem_size, in rte_lpm6_create()
346 if (lpm == NULL) { in rte_lpm6_create()
355 lpm->number_tbl8s = config->number_tbl8s; in rte_lpm6_create()
356 strlcpy(lpm->name, name, sizeof(lpm->name)); in rte_lpm6_create()
358 lpm->tbl8_pool = tbl8_pool; in rte_lpm6_create()
359 lpm->tbl8_hdrs = tbl8_hdrs; in rte_lpm6_create()
362 tbl8_pool_init(lpm); in rte_lpm6_create()
368 return lpm; in rte_lpm6_create()
415 rte_lpm6_free(struct rte_lpm6 *lpm) in rte_lpm6_free() argument
422 if (lpm == NULL) in rte_lpm6_free()
431 if (te->data == (void *) lpm) in rte_lpm6_free()
441 rte_free(lpm->tbl8_hdrs); in rte_lpm6_free()
442 rte_free(lpm->tbl8_pool); in rte_lpm6_free()
444 rte_free(lpm); in rte_lpm6_free()
451 rule_find_with_key(struct rte_lpm6 *lpm,
459 ret = rte_hash_lookup_data(lpm->rules_tbl, (const void *) rule_key,
471 rule_find(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
479 return rule_find_with_key(lpm, &rule_key, next_hop);
492 rule_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth, uint32_t next_hop)
502 rule_exist = rule_find_with_key(lpm, &rule_key, &unused);
508 if (!rule_exist && lpm->used_rules == lpm->max_rules)
512 ret = rte_hash_add_key_data(lpm->rules_tbl, &rule_key,
519 lpm->used_rules++;
533 expand_rule(struct rte_lpm6 *lpm, uint32_t tbl8_gindex, uint8_t old_depth, in expand_rule() argument
549 if (!lpm->tbl8[j].valid || (lpm->tbl8[j].ext_entry == 0 in expand_rule()
550 && lpm->tbl8[j].depth <= old_depth)) { in expand_rule()
552 lpm->tbl8[j] = new_tbl8_entry; in expand_rule()
554 } else if (lpm->tbl8[j].ext_entry == 1) { in expand_rule()
556 tbl8_gindex_next = lpm->tbl8[j].lpm6_tbl8_gindex in expand_rule()
558 expand_rule(lpm, tbl8_gindex_next, old_depth, new_depth, in expand_rule()
568 init_tbl8_header(struct rte_lpm6 *lpm, uint32_t tbl_ind, in init_tbl8_header() argument
571 struct rte_lpm_tbl8_hdr *tbl_hdr = &lpm->tbl8_hdrs[tbl_ind]; in init_tbl8_header()
607 simulate_add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl, in simulate_add_step() argument
647 *next_tbl = &(lpm->tbl8[next_tbl_ind * in simulate_add_step()
659 add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl, in add_step() argument
708 expand_rule(lpm, tbl8_gindex, depth, depth, in add_step()
715 lpm->tbl8_hdrs[tbl_ind].ref_cnt++; in add_step()
727 ret = tbl8_get(lpm, &tbl8_gindex); in add_step()
734 memset(&lpm->tbl8[tbl8_group_start], 0, in add_step()
741 init_tbl8_header(lpm, tbl8_gindex, tbl_ind, entry_ind); in add_step()
756 lpm->tbl8_hdrs[tbl_ind].ref_cnt++; in add_step()
764 ret = tbl8_get(lpm, &tbl8_gindex); in add_step()
783 lpm->tbl8[i] = tbl_entry; in add_step()
788 init_tbl8_header(lpm, tbl8_gindex, tbl_ind, entry_ind); in add_step()
807 lpm->tbl8_hdrs[tbl_ind].ref_cnt++; in add_step()
811 *next_tbl = &(lpm->tbl8[*next_tbl_ind * in add_step()
826 simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth) in simulate_add() argument
838 ret = simulate_add_step(lpm, lpm->tbl24, &tbl_next, masked_ip, in simulate_add()
847 ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1, in simulate_add()
852 if (tbl8_available(lpm) < total_need_tbl_nb) in simulate_add()
863 rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, in rte_lpm6_add() argument
875 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH)) in rte_lpm6_add()
883 int ret = simulate_add(lpm, masked_ip, depth); in rte_lpm6_add()
889 int is_new_rule = rule_add(lpm, masked_ip, depth, next_hop); in rte_lpm6_add()
896 tbl = lpm->tbl24; in rte_lpm6_add()
897 status = add_step(lpm, tbl, TBL24_IND, &tbl_next, &tbl_next_num, in rte_lpm6_add()
908 status = add_step(lpm, tbl, tbl_next_num, &tbl_next, in rte_lpm6_add()
923 lookup_step(const struct rte_lpm6 *lpm, const struct rte_lpm6_tbl_entry *tbl, in lookup_step() argument
940 *tbl_next = &lpm->tbl8[tbl8_index]; in lookup_step()
954 rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, in rte_lpm6_lookup() argument
964 if ((lpm == NULL) || (ip == NULL) || (next_hop == NULL)) in rte_lpm6_lookup()
971 tbl = &lpm->tbl24[tbl24_index]; in rte_lpm6_lookup()
975 status = lookup_step(lpm, tbl, &tbl_next, ip, first_byte++, next_hop); in rte_lpm6_lookup()
986 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm, in rte_lpm6_lookup_bulk_func() argument
998 if ((lpm == NULL) || (ips == NULL) || (next_hops == NULL)) in rte_lpm6_lookup_bulk_func()
1007 tbl = &lpm->tbl24[tbl24_index]; in rte_lpm6_lookup_bulk_func()
1013 status = lookup_step(lpm, tbl, &tbl_next, ips[i], in rte_lpm6_lookup_bulk_func()
1044 rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
1050 if ((lpm == NULL) || next_hop == NULL || ip == NULL ||
1058 return rule_find(lpm, masked_ip, depth, next_hop);
1069 rule_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth)
1078 ret = rte_hash_del_key(lpm->rules_tbl, (void *) &rule_key);
1080 lpm->used_rules--;
1093 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
1101 if ((lpm == NULL) || (ips == NULL) || (depths == NULL))
1107 rule_delete(lpm, masked_ip, depths[i]);
1114 memset(lpm->tbl24, 0, sizeof(lpm->tbl24));
1115 memset(lpm->tbl8, 0, sizeof(lpm->tbl8[0])
1116 * RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * lpm->number_tbl8s);
1117 tbl8_pool_init(lpm);
1123 rebuild_lpm(lpm);
1132 rte_lpm6_delete_all(struct rte_lpm6 *lpm)
1135 lpm->used_rules = 0;
1138 memset(lpm->tbl24, 0, sizeof(lpm->tbl24));
1141 memset(lpm->tbl8, 0, sizeof(lpm->tbl8[0]) *
1142 RTE_LPM6_TBL8_GROUP_NUM_ENTRIES * lpm->number_tbl8s);
1145 tbl8_pool_init(lpm);
1148 rte_hash_reset(lpm->rules_tbl);
1170 rule_find_less_specific(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
1194 ret = rule_find_with_key(lpm, &rule_key, &next_hop);
1211 rule_find_range(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, in rule_find_range() argument
1222 *from = &lpm->tbl24[ind]; in rule_find_range()
1224 *to = &lpm->tbl24[ind]; in rule_find_range()
1228 struct rte_lpm6_tbl_entry *tbl = &lpm->tbl24[first_3bytes]; in rule_find_range()
1232 tbl = &lpm->tbl8[tbl_ind * in rule_find_range()
1247 tbl = &lpm->tbl8[tbl_ind * in rule_find_range()
1266 remove_tbl(struct rte_lpm6 *lpm, struct rte_lpm_tbl8_hdr *tbl_hdr, in remove_tbl() argument
1272 owner_entry = &lpm->tbl24[tbl_hdr->owner_entry_ind]; in remove_tbl()
1275 owner_entry = &lpm->tbl8[ in remove_tbl()
1280 &lpm->tbl8_hdrs[owner_tbl_ind]; in remove_tbl()
1282 remove_tbl(lpm, owner_tbl_hdr, owner_tbl_ind, lsp_rule); in remove_tbl()
1311 tbl8_put(lpm, tbl_ind); in remove_tbl()
1318 rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth, in rte_lpm6_delete() argument
1329 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH)) in rte_lpm6_delete()
1338 ret = rule_delete(lpm, masked_ip, depth); in rte_lpm6_delete()
1344 rule_find_range(lpm, masked_ip, depth, &from, &to, &tbl_ind); in rte_lpm6_delete()
1350 ret = rule_find_less_specific(lpm, masked_ip, depth, in rte_lpm6_delete()
1358 struct rte_lpm_tbl8_hdr *tbl_hdr = &lpm->tbl8_hdrs[tbl_ind]; in rte_lpm6_delete()
1361 remove_tbl(lpm, tbl_hdr, tbl_ind, lsp_rule); in rte_lpm6_delete()
1376 expand_rule(lpm, in rte_lpm6_delete()
1385 expand_rule(lpm, in rte_lpm6_delete()