blob: 4fef2811b10a40a52da93c8a1e070e6d589cbbbd [file] [log] [blame]
Neale Rannsf068c3e2018-01-03 04:18:48 -08001/*
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#ifndef __DVR_DPO_H__
17#define __DVR_DPO_H__
18
19#include <vnet/dpo/dpo.h>
20
21/**
Neale Rannsa342da22019-06-06 10:35:07 +000022 * Control how the reinject is performed
23 */
24typedef enum dvr_dpo_reinject_t_
25{
26 DVR_REINJECT_L2,
27 DVR_REINJECT_L3,
28} __clib_packed dvr_dpo_reinject_t;
29
30/**
Neale Rannsf068c3e2018-01-03 04:18:48 -080031 * @brief
32 * The DVR DPO. Used as the resolving object for a DVR route.
33 * This is used, in place of the usual L3 Adjacency, to retransmit
34 * the packet with the original L2 header intact but also to run L3 features.
35 * After running L3 features the packet is re-injected back into the L2 path
36 * so it can pick up the necessary VLAN tags of the egress interface.
37 * This re-injection is done with an output feature.
38 */
39typedef struct dvr_dpo_t_
40{
41 /**
42 * The Software interface index that the packets will output on
43 */
44 u32 dd_sw_if_index;
45
46 /**
47 * The protocol of packets using this DPO
48 */
49 dpo_proto_t dd_proto;
50
51 /**
Neale Rannsa342da22019-06-06 10:35:07 +000052 * Control for how the re-inject is performed
53 */
54 dvr_dpo_reinject_t dd_reinject;
55
56 /**
Neale Rannsf068c3e2018-01-03 04:18:48 -080057 * number of locks.
58 */
59 u16 dd_locks;
60} dvr_dpo_t;
61
Neale Rannsa342da22019-06-06 10:35:07 +000062/* 8 bytes is a factor of cache line size so this struct will never span */
63STATIC_ASSERT_SIZEOF(dvr_dpo_t, 8);
64
Neale Rannsf068c3e2018-01-03 04:18:48 -080065extern void dvr_dpo_add_or_lock (u32 sw_if_index,
66 dpo_proto_t dproto,
67 dpo_id_t *dpo);
68
69extern void dvr_dpo_module_init(void);
70
71/**
72 * @brief pool of all interface DPOs
73 */
BenoƮt Ganne47727c02019-02-12 13:35:08 +010074extern dvr_dpo_t *dvr_dpo_pool;
Neale Rannsf068c3e2018-01-03 04:18:48 -080075
76static inline dvr_dpo_t *
77dvr_dpo_get (index_t index)
78{
79 return (pool_elt_at_index(dvr_dpo_pool, index));
80}
81
82#endif