FD.io VPP  v16.06
Vector Packet Processing
l2_rw.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 /*
17  * l2_rw is based on vnet classifier and provides a way
18  * to modify packets matching a given table.
19  *
20  * Tables must be created using vnet's classify features.
21  * Entries contained within these tables must have their
22  * opaque index set to the rewrite entry created with l2_rw_mod_entry.
23  */
24 
25 #ifndef L2_RW_H_
26 #define L2_RW_H_
27 
28 #include <vnet/l2/l2_input.h>
29 
30 typedef CLIB_PACKED(struct _l2_rw_entry {
31  u16 skip_n_vectors;
32  u16 rewrite_n_vectors;
33  u64 hit_count;
34  u32x4 *mask;
35  u32x4 *value;
36 }) l2_rw_entry_t;
37 
38 // l2_rw configuration for one interface
39 typedef CLIB_PACKED(struct _l2_rw_config {
40  u32 table_index; //Which classify table to use
41  u32 miss_index; //Rewrite entry to use if table does not match
42 }) l2_rw_config_t;
43 
44 typedef struct {
45  /* Next feature node indexes */
46  u32 feat_next_node_index[32];
47 
48  /* A pool of entries */
49  l2_rw_entry_t *entries;
50 
51  /* Config vector indexed by sw_if_index */
52  l2_rw_config_t *configs;
54 } l2_rw_main_t;
55 
57 
58 /*
59  * Specifies which classify table and miss_index should be used
60  * with the given interface.
61  * Use special values ~0 in order to un-set table_index
62  * or miss_index.
63  * l2_rw feature is automatically enabled for the interface
64  * when table_index or miss_index is not ~0.
65  * returns 0 on success and something else on error.
66  */
67 int l2_rw_interface_set_table(u32 sw_if_index,
68  u32 table_index,
69  u32 miss_index);
70 
71 /*
72  * Creates, modifies or delete a rewrite entry.
73  * If *index != ~0, modifies an existing entry (or simply
74  * deletes it if is_del is set).
75  * If *index == ~0, creates a new entry and the created
76  * entry index is stored in *index (Does nothing if is_del
77  * is set).
78  * returns 0 on success and something else on error.
79  */
80 int l2_rw_mod_entry(u32 *index,
81  u8 *mask, u8 *value, u32 len,
82  u32 skip, u8 is_del);
83 
84 #endif /* L2_FW_H_ */
l2_rw_config_t * configs
Definition: l2_rw.h:52
int l2_rw_mod_entry(u32 *index, u8 *mask, u8 *value, u32 len, u32 skip, u8 is_del)
Definition: l2_rw.c:320
l2_rw_main_t l2_rw_main
Definition: l2_rw.c:20
unsigned long u64
Definition: types.h:89
uword * configs_bitmap
Definition: l2_rw.h:53
unsigned int u32
Definition: types.h:88
u64 uword
Definition: types.h:112
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
typedef CLIB_PACKED(struct _l2_rw_entry{u16 skip_n_vectors;u16 rewrite_n_vectors;u64 hit_count;u32x4 *mask;u32x4 *value;}) l2_rw_entry_t
int l2_rw_interface_set_table(u32 sw_if_index, u32 table_index, u32 miss_index)
Definition: l2_rw.c:410
l2_rw_entry_t * entries
Definition: l2_rw.h:49