summaryrefslogtreecommitdiffstats
path: root/src/vnet/bier/bier_imp.h
blob: fa53989fc93fc98eea965d2d6a4a7fe6947bed40 (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
/*
 * 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.
 */
/**
 * bier_imposition : The BIER imposition object
 *
 * A BIER imposition object is present in the IP mcast output list
 * and represents the imposition of a BIER bitmask. After BIER header
 * imposition the packet is forward within the appropriate/specifid
 * BIER table
 */

#ifndef __BIER_IMPOSITION_H__
#define __BIER_IMPOSITION_H__

#include <vnet/bier/bier_types.h>
#include <vnet/fib/fib_types.h>
#include <vnet/dpo/dpo.h>

/**
 * The BIER imposition object
 */
typedef struct bier_imp_t_ {
    /**
     * The BIER table into which to forward the post imposed packet
     */
    bier_table_id_t bi_tbl;

    /**
     * number of locks
     */
    u32 bi_locks;

    /**
     * The DPO contirubted from the resolving BIER table.
     * One per-IP protocol. This allows us to share a BIER imposition
     * object for a IPv4 and IPv6 mfib path.
     */
    dpo_id_t bi_dpo[FIB_PROTOCOL_IP_MAX];

    /**
     * The Header to impose.
     */
    bier_hdr_t bi_hdr;

    /**
     * The bit string.
     *  This is a memory v. speed tradeoff. We inline here the
     *  largest header type so as the bitstring is on the same
     *  cacheline as the header.
     */
    bier_bit_mask_4096_t bi_bits;
} bier_imp_t;

extern index_t bier_imp_add_or_lock(const bier_table_id_t *bt,
                                    bier_bp_t sender,
                                    const bier_bit_string_t *bs);

extern void bier_imp_unlock(index_t bii);
extern void bier_imp_lock(index_t bii);

extern u8* format_bier_imp(u8* s, va_list *ap);

extern void bier_imp_contribute_forwarding(index_t bii,
                                           dpo_proto_t proto,
                                           dpo_id_t *dpo);

extern bier_imp_t *bier_imp_pool;

always_inline bier_imp_t*
bier_imp_get (index_t bii)
{
    return (pool_elt_at_index(bier_imp_pool, bii));
}

#endif