mactime: add a "top" command to watch device stats
[vpp.git] / src / plugins / mactime / mactime.h
1
2 /*
3  * mactime.h - time-based src mac address filtration
4  *
5  * Copyright (c) <current-year> <your-organization>
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #ifndef __included_mactime_h__
19 #define __included_mactime_h__
20
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/ethernet/ethernet.h>
24 #include <vnet/ethernet/arp.h>
25 #include <vlib/counter.h>
26
27 #include <vppinfra/hash.h>
28 #include <vppinfra/error.h>
29 #include <vppinfra/time_range.h>
30 #include <vppinfra/bihash_8_8.h>
31
32 #include <mactime/mactime_device.h>
33
34 typedef struct
35 {
36   union
37   {
38     u8 mac_address[6];
39     u64 as_u64;
40   };
41 } mactime_key_t;
42
43 typedef struct
44 {
45   /* API message ID base */
46   u16 msg_id_base;
47
48   /* Timebase */
49   clib_timebase_t timebase;
50
51   /* cached sunday midnight */
52   f64 sunday_midnight;
53
54   /* Lookup table */
55   clib_bihash_8_8_t lookup_table;
56
57   /* Device table */
58   mactime_device_t *devices;
59   u32 device_table_epoch;
60
61   /* Counters */
62   vlib_combined_counter_main_t allow_counters;
63   vlib_combined_counter_main_t drop_counters;
64
65   /* config parameters */
66   u32 lookup_table_num_buckets;
67   uword lookup_table_memory_size;
68   i32 timezone_offset;
69
70   /* Once-only data structure create flag */
71   int feature_initialized;
72
73   /* arp cache copy, for "show mactime" */
74   ethernet_arp_ip4_entry_t *arp_cache_copy;
75
76   /* convenience */
77   vlib_main_t *vlib_main;
78   vnet_main_t *vnet_main;
79   ethernet_main_t *ethernet_main;
80 } mactime_main_t;
81
82 /* size for an hgw use-case */
83 #define MACTIME_NUM_BUCKETS     128
84 #define MACTIME_MEMORY_SIZE     (256<<10)
85
86 extern mactime_main_t mactime_main;
87
88 extern vlib_node_registration_t mactime_node;
89 extern vlib_node_registration_t mactime_tx_node;
90
91 void mactime_send_create_entry_message (u8 * mac_address);
92
93 /* Periodic function events */
94 #define MACTIME_EVENT1 1
95 #define MACTIME_EVENT2 2
96 #define MACTIME_EVENT_PERIODIC_ENABLE_DISABLE 3
97
98 #endif /* __included_mactime_h__ */
99
100 /*
101  * fd.io coding-style-patch-verification: ON
102  *
103  * Local Variables:
104  * eval: (c-set-style "gnu")
105  * End:
106  */