1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
8 #include <rte_malloc.h>
10 #include "rte_table_stub.h"
12 #ifdef RTE_TABLE_STATS_COLLECT
14 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val) \
15 table->stats.n_pkts_in += val
16 #define RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(table, val) \
17 table->stats.n_pkts_lookup_miss += val
21 #define RTE_TABLE_LPM_STATS_PKTS_IN_ADD(table, val)
22 #define RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(table, val)
26 struct rte_table_stub {
27 struct rte_table_stats stats;
31 rte_table_stub_create(__rte_unused void *params,
32 __rte_unused int socket_id,
33 __rte_unused uint32_t entry_size)
35 struct rte_table_stub *stub;
38 size = sizeof(struct rte_table_stub);
39 stub = rte_zmalloc_socket("TABLE", size, RTE_CACHE_LINE_SIZE,
43 "%s: Cannot allocate %u bytes for stub table\n",
52 rte_table_stub_lookup(
53 __rte_unused void *table,
54 __rte_unused struct rte_mbuf **pkts,
55 __rte_unused uint64_t pkts_mask,
56 uint64_t *lookup_hit_mask,
57 __rte_unused void **entries)
59 __rte_unused struct rte_table_stub *stub = (struct rte_table_stub *) table;
60 __rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
62 RTE_TABLE_LPM_STATS_PKTS_IN_ADD(stub, n_pkts_in);
64 RTE_TABLE_LPM_STATS_PKTS_LOOKUP_MISS(stub, n_pkts_in);
70 rte_table_stub_stats_read(void *table, struct rte_table_stats *stats, int clear)
72 struct rte_table_stub *t = table;
75 memcpy(stats, &t->stats, sizeof(t->stats));
78 memset(&t->stats, 0, sizeof(t->stats));
83 struct rte_table_ops rte_table_stub_ops = {
84 .f_create = rte_table_stub_create,
89 .f_delete_bulk = NULL,
90 .f_lookup = rte_table_stub_lookup,
91 .f_stats = rte_table_stub_stats_read,