BIER: fix support for longer bit-string lengths
[vpp.git] / src / vnet / bier / bier_imp.h
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /**
16  * bier_imposition : The BIER imposition object
17  *
18  * A BIER imposition object is present in the IP mcast output list
19  * and represents the imposition of a BIER bitmask. After BIER header
20  * imposition the packet is forward within the appropriate/specifid
21  * BIER table
22  */
23
24 #ifndef __BIER_IMPOSITION_H__
25 #define __BIER_IMPOSITION_H__
26
27 #include <vnet/bier/bier_types.h>
28 #include <vnet/fib/fib_types.h>
29 #include <vnet/dpo/dpo.h>
30
31 /**
32  * The BIER imposition object
33  */
34 typedef struct bier_imp_t_ {
35     /**
36      * The DPO contirubted from the resolving BIER table.
37      * One per-IP protocol. This allows us to share a BIER imposition
38      * object for a IPv4 and IPv6 mfib path.
39      */
40     dpo_id_t bi_dpo[FIB_PROTOCOL_IP_MAX];
41
42     /**
43      * The Header to impose.
44      */
45     bier_hdr_t bi_hdr;
46
47     /**
48      * The bit string.
49      *  This is a memory v. speed tradeoff. We inline here the
50      *  largest header type so as the bitstring is on the same
51      *  cacheline as the header.
52      */
53     u8 bi_bits[BIER_HDR_BUCKETS_1024];
54
55     /**
56      * The BIER table into which to forward the post imposed packet
57      */
58     bier_table_id_t bi_tbl;
59
60     /**
61      * number of locks
62      */
63     u32 bi_locks;
64
65 } bier_imp_t;
66
67 extern index_t bier_imp_add_or_lock(const bier_table_id_t *bt,
68                                     bier_bp_t sender,
69                                     const bier_bit_string_t *bs);
70
71 extern void bier_imp_unlock(index_t bii);
72 extern void bier_imp_lock(index_t bii);
73
74 extern u8* format_bier_imp(u8* s, va_list *ap);
75
76 extern void bier_imp_contribute_forwarding(index_t bii,
77                                            dpo_proto_t proto,
78                                            dpo_id_t *dpo);
79
80 extern bier_imp_t *bier_imp_pool;
81
82 always_inline bier_imp_t*
83 bier_imp_get (index_t bii)
84 {
85     return (pool_elt_at_index(bier_imp_pool, bii));
86 }
87
88 #endif