mpoa_caches.h revision 30d492da738a8d5f4ec884b3e1a13eef97714994
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef MPOA_CACHES_H
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define MPOA_CACHES_H
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/netdevice.h>
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/types.h>
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/atm.h>
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/atmdev.h>
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/atmmpc.h>
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct mpoa_client;
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsvoid atm_mpoa_init_cache(struct mpoa_client *mpc);
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldstypedef struct in_cache_entry {
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct in_cache_entry *next;
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct in_cache_entry *prev;
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct timeval  tv;
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct timeval  reply_wait;
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct timeval  hold_down;
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint32_t  packets_fwded;
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint16_t  entry_state;
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint32_t retry_time;
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint32_t refresh_time;
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint32_t count;
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct   atm_vcc *shortcut;
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint8_t  MPS_ctrl_ATM_addr[ATM_ESA_LEN];
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct   in_ctrl_info ctrl_info;
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        atomic_t use;
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} in_cache_entry;
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct in_cache_ops{
3230d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        in_cache_entry *(*add_entry)(__be32 dst_ip,
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds                                      struct mpoa_client *client);
3430d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client);
3530d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        in_cache_entry *(*get_with_mask)(__be32 dst_ip,
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					 struct mpoa_client *client,
3730d492da738a8d5f4ec884b3e1a13eef97714994Al Viro					 __be32 mask);
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc,
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds                                      struct mpoa_client *client);
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*put)(in_cache_entry *entry);
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*remove_entry)(in_cache_entry *delEntry,
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds					struct mpoa_client *client );
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        int             (*cache_hit)(in_cache_entry *entry,
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds                                     struct mpoa_client *client);
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*clear_count)(struct mpoa_client *client);
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*check_resolving)(struct mpoa_client *client);
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*refresh)(struct mpoa_client *client);
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*destroy_cache)(struct mpoa_client *mpc);
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldstypedef struct eg_cache_entry{
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct               eg_cache_entry *next;
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct               eg_cache_entry *prev;
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct               timeval  tv;
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint8_t              MPS_ctrl_ATM_addr[ATM_ESA_LEN];
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct atm_vcc       *shortcut;
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint32_t             packets_rcvd;
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        uint16_t             entry_state;
5930d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        __be32             latest_ip_addr;    /* The src IP address of the last packet */
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        struct eg_ctrl_info  ctrl_info;
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        atomic_t             use;
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} eg_cache_entry;
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct eg_cache_ops{
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client);
6630d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client);
6730d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client);
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client);
6930d492da738a8d5f4ec884b3e1a13eef97714994Al Viro        eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client);
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*put)(eg_cache_entry *entry);
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client);
721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*update)(eg_cache_entry *entry, uint16_t holding_time);
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*clear_expired)(struct mpoa_client *client);
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds        void            (*destroy_cache)(struct mpoa_client *mpc);
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Ingress cache entry states */
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INGRESS_REFRESHING 3
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INGRESS_RESOLVED   2
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INGRESS_RESOLVING  1
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INGRESS_INVALID    0
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* VCC states */
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define OPEN   1
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define CLOSED 0
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Egress cache entry states */
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define EGRESS_RESOLVED 2
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define EGRESS_PURGE    1
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define EGRESS_INVALID  0
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
97