flow_table.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2007-2013 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. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301, USA
  17. */
  18. #ifndef FLOW_TABLE_H
  19. #define FLOW_TABLE_H 1
  20. #include <linux/kernel.h>
  21. #include <linux/netlink.h>
  22. #include <linux/openvswitch.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/types.h>
  25. #include <linux/rcupdate.h>
  26. #include <linux/if_ether.h>
  27. #include <linux/in6.h>
  28. #include <linux/jiffies.h>
  29. #include <linux/time.h>
  30. #include <linux/flex_array.h>
  31. #include <net/inet_ecn.h>
  32. #include <net/ip_tunnels.h>
  33. #include "flow.h"
  34. struct table_instance {
  35. struct flex_array *buckets;
  36. unsigned int n_buckets;
  37. struct rcu_head rcu;
  38. int node_ver;
  39. u32 hash_seed;
  40. bool keep_flows;
  41. };
  42. struct flow_table {
  43. struct table_instance __rcu *ti;
  44. struct list_head mask_list;
  45. unsigned long last_rehash;
  46. unsigned int count;
  47. };
  48. int ovs_flow_init(void);
  49. void ovs_flow_exit(void);
  50. struct sw_flow *ovs_flow_alloc(void);
  51. void ovs_flow_free(struct sw_flow *, bool deferred);
  52. int ovs_flow_tbl_init(struct flow_table *);
  53. int ovs_flow_tbl_count(struct flow_table *table);
  54. void ovs_flow_tbl_destroy(struct flow_table *table);
  55. int ovs_flow_tbl_flush(struct flow_table *flow_table);
  56. int ovs_flow_tbl_insert(struct flow_table *table, struct sw_flow *flow,
  57. struct sw_flow_mask *mask);
  58. void ovs_flow_tbl_remove(struct flow_table *table, struct sw_flow *flow);
  59. int ovs_flow_tbl_num_masks(const struct flow_table *table);
  60. struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *table,
  61. u32 *bucket, u32 *idx);
  62. struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *,
  63. const struct sw_flow_key *,
  64. u32 *n_mask_hit);
  65. bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow,
  66. struct sw_flow_match *match);
  67. void ovs_flow_mask_key(struct sw_flow_key *dst, const struct sw_flow_key *src,
  68. const struct sw_flow_mask *mask);
  69. #endif /* flow_table.h */