Blame view

net/openvswitch/meter.h 1.29 KB
25763b3c8   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
96fbc13d7   Andy Zhou   openvswitch: Add ...
2
3
  /*
   * Copyright (c) 2017 Nicira, Inc.
96fbc13d7   Andy Zhou   openvswitch: Add ...
4
5
6
7
8
9
10
11
12
13
14
15
   */
  
  #ifndef METER_H
  #define METER_H 1
  
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/kernel.h>
  #include <linux/netlink.h>
  #include <linux/openvswitch.h>
  #include <linux/genetlink.h>
  #include <linux/skbuff.h>
c7c4c44c9   Tonghao Zhang   net: openvswitch:...
16
  #include <linux/bits.h>
96fbc13d7   Andy Zhou   openvswitch: Add ...
17
18
19
20
21
  
  #include "flow.h"
  struct datapath;
  
  #define DP_MAX_BANDS		1
c7c4c44c9   Tonghao Zhang   net: openvswitch:...
22
  #define DP_METER_ARRAY_SIZE_MIN	BIT_ULL(10)
eb58eebc7   Tonghao Zhang   net: openvswitch:...
23
  #define DP_METER_NUM_MAX	(200000UL)
96fbc13d7   Andy Zhou   openvswitch: Add ...
24
25
26
27
28
  
  struct dp_meter_band {
  	u32 type;
  	u32 rate;
  	u32 burst_size;
e57358873   Tonghao Zhang   net: openvswitch:...
29
  	u64 bucket; /* 1/1000 packets, or in bits */
96fbc13d7   Andy Zhou   openvswitch: Add ...
30
31
32
33
34
35
  	struct ovs_flow_stats stats;
  };
  
  struct dp_meter {
  	spinlock_t lock;    /* Per meter lock */
  	struct rcu_head rcu;
96fbc13d7   Andy Zhou   openvswitch: Add ...
36
37
38
39
40
41
42
43
  	u32 id;
  	u16 kbps:1, keep_stats:1;
  	u16 n_bands;
  	u32 max_delta_t;
  	u64 used;
  	struct ovs_flow_stats stats;
  	struct dp_meter_band bands[];
  };
c7c4c44c9   Tonghao Zhang   net: openvswitch:...
44
45
46
47
48
49
50
51
52
  struct dp_meter_instance {
  	struct rcu_head rcu;
  	u32 n_meters;
  	struct dp_meter __rcu *dp_meters[];
  };
  
  struct dp_meter_table {
  	struct dp_meter_instance __rcu *ti;
  	u32 count;
eb58eebc7   Tonghao Zhang   net: openvswitch:...
53
  	u32 max_meters_allowed;
c7c4c44c9   Tonghao Zhang   net: openvswitch:...
54
  };
96fbc13d7   Andy Zhou   openvswitch: Add ...
55
56
57
58
59
60
61
  extern struct genl_family dp_meter_genl_family;
  int ovs_meters_init(struct datapath *dp);
  void ovs_meters_exit(struct datapath *dp);
  bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
  		       struct sw_flow_key *key, u32 meter_id);
  
  #endif /* meter.h */