• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/sys/contrib/dpdk_rte_lpm/

Lines Matching defs:lpm

93 	char name[RTE_LPM6_NAMESIZE];    /**< Name of the lpm. */
162 tbl8_pool_init(struct rte_lpm6 *lpm)
167 for (i = 0; i < lpm->number_tbl8s; i++)
168 lpm->tbl8_pool[i] = i;
170 lpm->tbl8_pool_pos = 0;
177 tbl8_get(struct rte_lpm6 *lpm, uint32_t *tbl8_ind)
179 if (lpm->tbl8_pool_pos == lpm->number_tbl8s)
184 *tbl8_ind = lpm->tbl8_pool[lpm->tbl8_pool_pos++];
192 tbl8_put(struct rte_lpm6 *lpm, uint32_t tbl8_ind)
194 if (lpm->tbl8_pool_pos == 0)
198 lpm->tbl8_pool[--lpm->tbl8_pool_pos] = tbl8_ind;
206 tbl8_available(struct rte_lpm6 *lpm)
208 return lpm->number_tbl8s - lpm->tbl8_pool_pos;
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;
315 mem_size = sizeof(*lpm) + (sizeof(lpm->tbl8[0]) *
323 lpm = (struct rte_lpm6 *) te->data;
324 if (strncmp(name, lpm->name, RTE_LPM6_NAMESIZE) == 0)
327 lpm = NULL;
343 lpm = rte_zmalloc_socket(mem_name, (size_t)mem_size,
346 if (lpm == NULL) {
354 //lpm->max_rules = config->max_rules;
355 lpm->number_tbl8s = config->number_tbl8s;
356 strlcpy(lpm->name, name, sizeof(lpm->name));
357 //lpm->rules_tbl = rules_tbl;
358 lpm->tbl8_pool = tbl8_pool;
359 lpm->tbl8_hdrs = tbl8_hdrs;
362 tbl8_pool_init(lpm);
364 //te->data = (void *) lpm;
368 return lpm;
383 * Find an existing lpm table and return a pointer to it.
415 rte_lpm6_free(struct rte_lpm6 *lpm)
422 if (lpm == NULL)
431 if (te->data == (void *) lpm)
441 rte_free(lpm->tbl8_hdrs);
442 rte_free(lpm->tbl8_pool);
443 //rte_hash_free(lpm->rules_tbl);
444 rte_free(lpm);
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,
549 if (!lpm->tbl8[j].valid || (lpm->tbl8[j].ext_entry == 0
550 && lpm->tbl8[j].depth <= old_depth)) {
552 lpm->tbl8[j] = new_tbl8_entry;
554 } else if (lpm->tbl8[j].ext_entry == 1) {
556 tbl8_gindex_next = lpm->tbl8[j].lpm6_tbl8_gindex
558 expand_rule(lpm, tbl8_gindex_next, old_depth, new_depth,
568 init_tbl8_header(struct rte_lpm6 *lpm, uint32_t tbl_ind,
571 struct rte_lpm_tbl8_hdr *tbl_hdr = &lpm->tbl8_hdrs[tbl_ind];
607 simulate_add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
647 *next_tbl = &(lpm->tbl8[next_tbl_ind *
659 add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
708 expand_rule(lpm, tbl8_gindex, depth, depth,
715 lpm->tbl8_hdrs[tbl_ind].ref_cnt++;
727 ret = tbl8_get(lpm, &tbl8_gindex);
734 memset(&lpm->tbl8[tbl8_group_start], 0,
741 init_tbl8_header(lpm, tbl8_gindex, tbl_ind, entry_ind);
756 lpm->tbl8_hdrs[tbl_ind].ref_cnt++;
764 ret = tbl8_get(lpm, &tbl8_gindex);
783 lpm->tbl8[i] = tbl_entry;
788 init_tbl8_header(lpm, tbl8_gindex, tbl_ind, entry_ind);
807 lpm->tbl8_hdrs[tbl_ind].ref_cnt++;
811 *next_tbl = &(lpm->tbl8[*next_tbl_ind *
826 simulate_add(struct rte_lpm6 *lpm, const uint8_t *masked_ip, uint8_t depth)
838 ret = simulate_add_step(lpm, lpm->tbl24, &tbl_next, masked_ip,
847 ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
852 if (tbl8_available(lpm) < total_need_tbl_nb)
863 rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
875 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
883 int ret = simulate_add(lpm, masked_ip, depth);
889 int is_new_rule = rule_add(lpm, masked_ip, depth, next_hop);
896 tbl = lpm->tbl24;
897 status = add_step(lpm, tbl, TBL24_IND, &tbl_next, &tbl_next_num,
908 status = add_step(lpm, tbl, tbl_next_num, &tbl_next,
923 lookup_step(const struct rte_lpm6 *lpm, const struct rte_lpm6_tbl_entry *tbl,
940 *tbl_next = &lpm->tbl8[tbl8_index];
954 rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip,
964 if ((lpm == NULL) || (ip == NULL) || (next_hop == NULL))
971 tbl = &lpm->tbl24[tbl24_index];
975 status = lookup_step(lpm, tbl, &tbl_next, ip, first_byte++, next_hop);
986 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
998 if ((lpm == NULL) || (ips == NULL) || (next_hops == NULL))
1007 tbl = &lpm->tbl24[tbl24_index];
1013 status = lookup_step(lpm, tbl, &tbl_next, ips[i],
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--;
1088 * Note that the function rebuilds the lpm table,
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,
1222 *from = &lpm->tbl24[ind];
1224 *to = &lpm->tbl24[ind];
1228 struct rte_lpm6_tbl_entry *tbl = &lpm->tbl24[first_3bytes];
1232 tbl = &lpm->tbl8[tbl_ind *
1247 tbl = &lpm->tbl8[tbl_ind *
1266 remove_tbl(struct rte_lpm6 *lpm, struct rte_lpm_tbl8_hdr *tbl_hdr,
1272 owner_entry = &lpm->tbl24[tbl_hdr->owner_entry_ind];
1275 owner_entry = &lpm->tbl8[
1280 &lpm->tbl8_hdrs[owner_tbl_ind];
1282 remove_tbl(lpm, owner_tbl_hdr, owner_tbl_ind, lsp_rule);
1311 tbl8_put(lpm, tbl_ind);
1318 rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
1329 if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
1338 ret = rule_delete(lpm, masked_ip, depth);
1344 rule_find_range(lpm, masked_ip, depth, &from, &to, &tbl_ind);
1350 ret = rule_find_less_specific(lpm, masked_ip, depth,
1358 struct rte_lpm_tbl8_hdr *tbl_hdr = &lpm->tbl8_hdrs[tbl_ind];
1361 remove_tbl(lpm, tbl_hdr, tbl_ind, lsp_rule);
1376 expand_rule(lpm,
1385 expand_rule(lpm,