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