0001
0002
0003
0004
0005
0006 #ifndef METER_H
0007 #define METER_H 1
0008
0009 #include <linux/init.h>
0010 #include <linux/module.h>
0011 #include <linux/kernel.h>
0012 #include <linux/netlink.h>
0013 #include <linux/openvswitch.h>
0014 #include <linux/genetlink.h>
0015 #include <linux/skbuff.h>
0016 #include <linux/bits.h>
0017
0018 #include "flow.h"
0019 struct datapath;
0020
0021 #define DP_MAX_BANDS 1
0022 #define DP_METER_ARRAY_SIZE_MIN BIT_ULL(10)
0023 #define DP_METER_NUM_MAX (200000UL)
0024
0025 struct dp_meter_band {
0026 u32 type;
0027 u32 rate;
0028 u32 burst_size;
0029 u64 bucket;
0030 struct ovs_flow_stats stats;
0031 };
0032
0033 struct dp_meter {
0034 spinlock_t lock;
0035 struct rcu_head rcu;
0036 u32 id;
0037 u16 kbps:1, keep_stats:1;
0038 u16 n_bands;
0039 u32 max_delta_t;
0040 u64 used;
0041 struct ovs_flow_stats stats;
0042 struct dp_meter_band bands[];
0043 };
0044
0045 struct dp_meter_instance {
0046 struct rcu_head rcu;
0047 u32 n_meters;
0048 struct dp_meter __rcu *dp_meters[];
0049 };
0050
0051 struct dp_meter_table {
0052 struct dp_meter_instance __rcu *ti;
0053 u32 count;
0054 u32 max_meters_allowed;
0055 };
0056
0057 extern struct genl_family dp_meter_genl_family;
0058 int ovs_meters_init(struct datapath *dp);
0059 void ovs_meters_exit(struct datapath *dp);
0060 bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
0061 struct sw_flow_key *key, u32 meter_id);
0062
0063 #endif