meter.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) 2017 Nicira, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of version 2 of the GNU General Public
  6. * License as published by the Free Software Foundation.
  7. */
  8. #ifndef METER_H
  9. #define METER_H 1
  10. #include <linux/init.h>
  11. #include <linux/module.h>
  12. #include <linux/kernel.h>
  13. #include <linux/netlink.h>
  14. #include <linux/openvswitch.h>
  15. #include <linux/genetlink.h>
  16. #include <linux/skbuff.h>
  17. #include "flow.h"
  18. struct datapath;
  19. #define DP_MAX_BANDS 1
  20. struct dp_meter_band {
  21. u32 type;
  22. u32 rate;
  23. u32 burst_size;
  24. u32 bucket; /* 1/1000 packets, or in bits */
  25. struct ovs_flow_stats stats;
  26. };
  27. struct dp_meter {
  28. spinlock_t lock; /* Per meter lock */
  29. struct rcu_head rcu;
  30. struct hlist_node dp_hash_node; /*Element in datapath->meters
  31. * hash table.
  32. */
  33. u32 id;
  34. u16 kbps:1, keep_stats:1;
  35. u16 n_bands;
  36. u32 max_delta_t;
  37. u64 used;
  38. struct ovs_flow_stats stats;
  39. struct dp_meter_band bands[];
  40. };
  41. extern struct genl_family dp_meter_genl_family;
  42. int ovs_meters_init(struct datapath *dp);
  43. void ovs_meters_exit(struct datapath *dp);
  44. bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
  45. struct sw_flow_key *key, u32 meter_id);
  46. #endif /* meter.h */