DPDK 22.11.5
rte_member_sketch.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
3 */
4
5#ifndef RTE_MEMBER_SKETCH_H
6#define RTE_MEMBER_SKETCH_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <rte_vect.h>
13#include <rte_ring_elem.h>
14
15#define NUM_ROW_SCALAR 5
16#define INTERVAL (1 << 15)
17
18#if !RTE_IS_POWER_OF_2(INTERVAL)
19#error sketch INTERVAL macro must be a power of 2
20#endif
21
22int
23rte_member_create_sketch(struct rte_member_setsum *ss,
24 const struct rte_member_parameters *params,
25 struct rte_ring *r);
26
27int
28rte_member_lookup_sketch(const struct rte_member_setsum *setsum,
29 const void *key, member_set_t *set_id);
30
31int
32rte_member_add_sketch(const struct rte_member_setsum *setsum,
33 const void *key,
34 member_set_t set_id);
35
36int
37rte_member_add_sketch_byte_count(const struct rte_member_setsum *ss,
38 const void *key, uint32_t byte_count);
39
40void
41sketch_update_scalar(const struct rte_member_setsum *ss,
42 const void *key,
43 uint32_t count);
44
45uint64_t
46sketch_lookup_scalar(const struct rte_member_setsum *ss,
47 const void *key);
48
49void
50sketch_delete_scalar(const struct rte_member_setsum *ss,
51 const void *key);
52
53int
54rte_member_delete_sketch(const struct rte_member_setsum *setsum,
55 const void *key);
56
57int
58rte_member_query_sketch(const struct rte_member_setsum *setsum,
59 const void *key, uint64_t *output);
60
61void
62rte_member_free_sketch(struct rte_member_setsum *ss);
63
64void
65rte_member_reset_sketch(const struct rte_member_setsum *setsum);
66
67int
68rte_member_report_heavyhitter_sketch(const struct rte_member_setsum *setsum,
69 void **key, uint64_t *count);
70
71void
72rte_member_update_heap(const struct rte_member_setsum *ss);
73
74static __rte_always_inline uint64_t
75count_min(const struct rte_member_setsum *ss, const uint32_t *hash_results)
76{
77 uint64_t *count_array = ss->table;
78 uint64_t count;
79 uint32_t cur_row;
80 uint64_t min = UINT64_MAX;
81
82 for (cur_row = 0; cur_row < ss->num_row; cur_row++) {
83 uint64_t cnt = count_array[cur_row * ss->num_col + hash_results[cur_row]];
84
85 if (cnt < min)
86 min = cnt;
87 }
88 count = min;
89
90 return count;
91}
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif /* RTE_MEMBER_SKETCH_H */
#define __rte_always_inline
Definition: rte_common.h:255
uint16_t member_set_t
Definition: rte_member.h:72