blob: 7480ebc7df1cec0c1633308321e1129a169f3dca [file] [log] [blame]
Neale Rannsd792d9c2017-10-21 10:53:20 -07001/*
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
Jim Thompsonf324dec2019-04-08 03:22:21 -050020 * imposition the packet is forward within the appropriate/specified
Neale Rannsd792d9c2017-10-21 10:53:20 -070021 * 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 */
34typedef struct bier_imp_t_ {
35 /**
Dave Baracheb987d32018-05-03 08:26:39 -040036 * Required for pool_get_aligned
37 */
38 CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
39
40 /**
Paul Vinciguerrae6eefb62019-05-13 15:56:41 -040041 * The DPO contributed from the resolving BIER table.
Neale Rannsd792d9c2017-10-21 10:53:20 -070042 * One per-IP protocol. This allows us to share a BIER imposition
43 * object for a IPv4 and IPv6 mfib path.
44 */
45 dpo_id_t bi_dpo[FIB_PROTOCOL_IP_MAX];
46
47 /**
48 * The Header to impose.
49 */
50 bier_hdr_t bi_hdr;
51
52 /**
53 * The bit string.
54 * This is a memory v. speed tradeoff. We inline here the
55 * largest header type so as the bitstring is on the same
56 * cacheline as the header.
57 */
Neale Rannsf0510722018-01-31 11:35:41 -080058 u8 bi_bits[BIER_HDR_BUCKETS_1024];
59
60 /**
61 * The BIER table into which to forward the post imposed packet
62 */
63 bier_table_id_t bi_tbl;
64
65 /**
66 * number of locks
67 */
68 u32 bi_locks;
69
Neale Rannsd792d9c2017-10-21 10:53:20 -070070} bier_imp_t;
71
72extern index_t bier_imp_add_or_lock(const bier_table_id_t *bt,
73 bier_bp_t sender,
74 const bier_bit_string_t *bs);
75
76extern void bier_imp_unlock(index_t bii);
77extern void bier_imp_lock(index_t bii);
78
79extern u8* format_bier_imp(u8* s, va_list *ap);
80
81extern void bier_imp_contribute_forwarding(index_t bii,
82 dpo_proto_t proto,
83 dpo_id_t *dpo);
84
85extern bier_imp_t *bier_imp_pool;
86
87always_inline bier_imp_t*
88bier_imp_get (index_t bii)
89{
90 return (pool_elt_at_index(bier_imp_pool, bii));
91}
92
93#endif