mpoa_caches.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef MPOA_CACHES_H
  3. #define MPOA_CACHES_H
  4. #include <linux/time64.h>
  5. #include <linux/netdevice.h>
  6. #include <linux/types.h>
  7. #include <linux/atm.h>
  8. #include <linux/atmdev.h>
  9. #include <linux/atmmpc.h>
  10. #include <linux/refcount.h>
  11. struct mpoa_client;
  12. void atm_mpoa_init_cache(struct mpoa_client *mpc);
  13. typedef struct in_cache_entry {
  14. struct in_cache_entry *next;
  15. struct in_cache_entry *prev;
  16. time64_t time;
  17. time64_t reply_wait;
  18. time64_t hold_down;
  19. uint32_t packets_fwded;
  20. uint16_t entry_state;
  21. uint32_t retry_time;
  22. uint32_t refresh_time;
  23. uint32_t count;
  24. struct atm_vcc *shortcut;
  25. uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN];
  26. struct in_ctrl_info ctrl_info;
  27. refcount_t use;
  28. } in_cache_entry;
  29. struct in_cache_ops{
  30. in_cache_entry *(*add_entry)(__be32 dst_ip,
  31. struct mpoa_client *client);
  32. in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client);
  33. in_cache_entry *(*get_with_mask)(__be32 dst_ip,
  34. struct mpoa_client *client,
  35. __be32 mask);
  36. in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc,
  37. struct mpoa_client *client);
  38. void (*put)(in_cache_entry *entry);
  39. void (*remove_entry)(in_cache_entry *delEntry,
  40. struct mpoa_client *client );
  41. int (*cache_hit)(in_cache_entry *entry,
  42. struct mpoa_client *client);
  43. void (*clear_count)(struct mpoa_client *client);
  44. void (*check_resolving)(struct mpoa_client *client);
  45. void (*refresh)(struct mpoa_client *client);
  46. void (*destroy_cache)(struct mpoa_client *mpc);
  47. };
  48. typedef struct eg_cache_entry{
  49. struct eg_cache_entry *next;
  50. struct eg_cache_entry *prev;
  51. time64_t time;
  52. uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN];
  53. struct atm_vcc *shortcut;
  54. uint32_t packets_rcvd;
  55. uint16_t entry_state;
  56. __be32 latest_ip_addr; /* The src IP address of the last packet */
  57. struct eg_ctrl_info ctrl_info;
  58. refcount_t use;
  59. } eg_cache_entry;
  60. struct eg_cache_ops{
  61. eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client);
  62. eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client);
  63. eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client);
  64. eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client);
  65. eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client);
  66. void (*put)(eg_cache_entry *entry);
  67. void (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client);
  68. void (*update)(eg_cache_entry *entry, uint16_t holding_time);
  69. void (*clear_expired)(struct mpoa_client *client);
  70. void (*destroy_cache)(struct mpoa_client *mpc);
  71. };
  72. /* Ingress cache entry states */
  73. #define INGRESS_REFRESHING 3
  74. #define INGRESS_RESOLVED 2
  75. #define INGRESS_RESOLVING 1
  76. #define INGRESS_INVALID 0
  77. /* VCC states */
  78. #define OPEN 1
  79. #define CLOSED 0
  80. /* Egress cache entry states */
  81. #define EGRESS_RESOLVED 2
  82. #define EGRESS_PURGE 1
  83. #define EGRESS_INVALID 0
  84. #endif