summaryrefslogtreecommitdiffstats
path: root/src/vnet/bier/bier_disp_table.h
blob: c5b211001e2fe077688f4e9b7c7d5bd25ba0a894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __BIER_DISP_TABLE_H__
#define __BIER_DISP_TABLE_H__

#include <vnet/ip/ip.h>
#include <vnet/adj/adj.h>
#include <vnet/dpo/replicate_dpo.h>

#include <vnet/bier/bier_types.h>
#include <vnet/bier/bier_disp_entry.h>

/**
 * @brief
 *   A protocol Independent IP multicast FIB table
 */
typedef struct bier_disp_table_t_
{
    /**
     * Required for pool_get_aligned
     */
    CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);

    /**
     * number of locks on the table
     */
    u16 bdt_locks;

    /**
     * Table ID (hash key) for this FIB.
     */
    u32 bdt_table_id;

    /**
     * The lookup DB based on sender BP. Value is the index of the
     * BIER disp object.
     */
    index_t bdt_db[BIER_BP_MAX];
} bier_disp_table_t;

/**
 * @brief
 *  Format the description/name of the table
 */
extern u8* format_bier_disp_table(u8* s, va_list *ap);

extern void bier_disp_table_entry_path_add(u32 table_id,
                                           bier_bp_t src,
                                           bier_hdr_proto_id_t payload_proto,
                                           const fib_route_path_t *rpath);

extern void bier_disp_table_entry_path_remove(u32 table_id,
                                              bier_bp_t src,
                                              bier_hdr_proto_id_t payload_proto,
                                              const fib_route_path_t *paths);

extern index_t bier_disp_table_find(u32 table_id);


extern index_t bier_disp_table_add_or_lock(u32 table_id);
extern void bier_disp_table_unlock_w_table_id(u32 table_id);

extern void bier_disp_table_unlock(index_t bdti);
extern void bier_disp_table_lock(index_t bdti);
extern void bier_disp_table_contribute_forwarding(index_t bdti,
                                                  dpo_id_t *dpo);

/**
 * Types and functions to walk all the entries in one BIER Table
 */
typedef void (*bier_disp_table_walk_fn_t)(const bier_disp_table_t *bdt,
                                          const bier_disp_entry_t *bde,
                                          u16 bp,
                                          void *ctx);
extern void bier_disp_table_walk(u32 table_id,
                                 bier_disp_table_walk_fn_t fn,
                                 void *ctx);

/**
 * @brief
 * Get a pointer to a FIB table
 */
extern bier_disp_table_t *bier_disp_table_pool;

static inline bier_disp_table_t *
bier_disp_table_get (index_t bdti)
{
    return (pool_elt_at_index(bier_disp_table_pool, bdti));
}

static inline index_t
bier_disp_table_lookup (index_t bdti,
                        bier_hdr_src_id_t src)
{
    bier_disp_table_t *bdt;

    bdt = bier_disp_table_get(bdti);

    return (bdt->bdt_db[src]);
}

#endif
y_name; /* bitmap[p][c][i] says whether sub-command i has character c in position p. */ vlib_cli_parse_position_t *sub_command_positions; /* Hash table mapping name (e.g. last path element) to sub rule index. */ uword *sub_rule_index_by_name; /* Vector of possible parse rules for this path. */ vlib_cli_sub_rule_t *sub_rules; /* List of CLI commands, built by constructors */ struct vlib_cli_command_t *next_cli_command; } vlib_cli_command_t; typedef void (vlib_cli_output_function_t) (uword arg, u8 * buffer, uword buffer_bytes); typedef struct { /* Vector of all known commands. */ vlib_cli_command_t *commands; /* Hash table mapping normalized path to index into all_commands. */ uword *command_index_by_path; /* Vector of all known parse rules. */ vlib_cli_parse_rule_t *parse_rules; /* Hash table mapping parse rule name to index into parse_rule vector. */ uword *parse_rule_index_by_name; /* Data parsed for rules. */ void **parse_rule_data; /* registration list added by constructors */ vlib_cli_command_t *cli_command_registrations; } vlib_cli_main_t; #ifndef CLIB_MARCH_VARIANT #define VLIB_CLI_COMMAND(x,...) \ __VA_ARGS__ vlib_cli_command_t x; \ static void __vlib_cli_command_registration_##x (void) \ __attribute__((__constructor__)) ; \ static void __vlib_cli_command_registration_##x (void) \ { \ vlib_main_t * vm = vlib_get_main(); \ vlib_cli_main_t *cm = &vm->cli_main; \ x.next_cli_command = cm->cli_command_registrations; \ cm->cli_command_registrations = &x; \ } \ static void __vlib_cli_command_unregistration_##x (void) \ __attribute__((__destructor__)) ; \ static void __vlib_cli_command_unregistration_##x (void) \ { \ vlib_main_t * vm = vlib_get_main(); \ vlib_cli_main_t *cm = &vm->cli_main; \ VLIB_REMOVE_FROM_LINKED_LIST (cm->cli_command_registrations, &x, \ next_cli_command); \ } \ __VA_ARGS__ vlib_cli_command_t x #else /* create unused pointer to silence compiler warnings and get whole function optimized out */ #define VLIB_CLI_COMMAND(x,...) \ static __clib_unused vlib_cli_command_t __clib_unused_##x #endif #define VLIB_CLI_PARSE_RULE(x) \ vlib_cli_parse_rule_t x /* Output to current CLI connection. */ void vlib_cli_output (struct vlib_main_t *vm, char *fmt, ...); /* Process CLI input. */ void vlib_cli_input (struct vlib_main_t *vm, unformat_input_t * input, vlib_cli_output_function_t * function, uword function_arg); clib_error_t *vlib_cli_register (struct vlib_main_t *vm, vlib_cli_command_t * c); clib_error_t *vlib_cli_register_parse_rule (struct vlib_main_t *vm, vlib_cli_parse_rule_t * c); uword unformat_vlib_cli_sub_input (unformat_input_t * i, va_list * args); /* Return an vector of strings consisting of possible auto-completions * for a given input string */ u8 **vlib_cli_get_possible_completions (u8 * input_str); #endif /* included_vlib_cli_h */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */