162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef MPOA_CACHES_H 362306a36Sopenharmony_ci#define MPOA_CACHES_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/time64.h> 662306a36Sopenharmony_ci#include <linux/netdevice.h> 762306a36Sopenharmony_ci#include <linux/types.h> 862306a36Sopenharmony_ci#include <linux/atm.h> 962306a36Sopenharmony_ci#include <linux/atmdev.h> 1062306a36Sopenharmony_ci#include <linux/atmmpc.h> 1162306a36Sopenharmony_ci#include <linux/refcount.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistruct mpoa_client; 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_civoid atm_mpoa_init_cache(struct mpoa_client *mpc); 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_citypedef struct in_cache_entry { 1862306a36Sopenharmony_ci struct in_cache_entry *next; 1962306a36Sopenharmony_ci struct in_cache_entry *prev; 2062306a36Sopenharmony_ci time64_t time; 2162306a36Sopenharmony_ci time64_t reply_wait; 2262306a36Sopenharmony_ci time64_t hold_down; 2362306a36Sopenharmony_ci uint32_t packets_fwded; 2462306a36Sopenharmony_ci uint16_t entry_state; 2562306a36Sopenharmony_ci uint32_t retry_time; 2662306a36Sopenharmony_ci uint32_t refresh_time; 2762306a36Sopenharmony_ci uint32_t count; 2862306a36Sopenharmony_ci struct atm_vcc *shortcut; 2962306a36Sopenharmony_ci uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN]; 3062306a36Sopenharmony_ci struct in_ctrl_info ctrl_info; 3162306a36Sopenharmony_ci refcount_t use; 3262306a36Sopenharmony_ci} in_cache_entry; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_cistruct in_cache_ops{ 3562306a36Sopenharmony_ci in_cache_entry *(*add_entry)(__be32 dst_ip, 3662306a36Sopenharmony_ci struct mpoa_client *client); 3762306a36Sopenharmony_ci in_cache_entry *(*get)(__be32 dst_ip, struct mpoa_client *client); 3862306a36Sopenharmony_ci in_cache_entry *(*get_with_mask)(__be32 dst_ip, 3962306a36Sopenharmony_ci struct mpoa_client *client, 4062306a36Sopenharmony_ci __be32 mask); 4162306a36Sopenharmony_ci in_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, 4262306a36Sopenharmony_ci struct mpoa_client *client); 4362306a36Sopenharmony_ci void (*put)(in_cache_entry *entry); 4462306a36Sopenharmony_ci void (*remove_entry)(in_cache_entry *delEntry, 4562306a36Sopenharmony_ci struct mpoa_client *client ); 4662306a36Sopenharmony_ci int (*cache_hit)(in_cache_entry *entry, 4762306a36Sopenharmony_ci struct mpoa_client *client); 4862306a36Sopenharmony_ci void (*clear_count)(struct mpoa_client *client); 4962306a36Sopenharmony_ci void (*check_resolving)(struct mpoa_client *client); 5062306a36Sopenharmony_ci void (*refresh)(struct mpoa_client *client); 5162306a36Sopenharmony_ci void (*destroy_cache)(struct mpoa_client *mpc); 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_citypedef struct eg_cache_entry{ 5562306a36Sopenharmony_ci struct eg_cache_entry *next; 5662306a36Sopenharmony_ci struct eg_cache_entry *prev; 5762306a36Sopenharmony_ci time64_t time; 5862306a36Sopenharmony_ci uint8_t MPS_ctrl_ATM_addr[ATM_ESA_LEN]; 5962306a36Sopenharmony_ci struct atm_vcc *shortcut; 6062306a36Sopenharmony_ci uint32_t packets_rcvd; 6162306a36Sopenharmony_ci uint16_t entry_state; 6262306a36Sopenharmony_ci __be32 latest_ip_addr; /* The src IP address of the last packet */ 6362306a36Sopenharmony_ci struct eg_ctrl_info ctrl_info; 6462306a36Sopenharmony_ci refcount_t use; 6562306a36Sopenharmony_ci} eg_cache_entry; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistruct eg_cache_ops{ 6862306a36Sopenharmony_ci eg_cache_entry *(*add_entry)(struct k_message *msg, struct mpoa_client *client); 6962306a36Sopenharmony_ci eg_cache_entry *(*get_by_cache_id)(__be32 cache_id, struct mpoa_client *client); 7062306a36Sopenharmony_ci eg_cache_entry *(*get_by_tag)(__be32 cache_id, struct mpoa_client *client); 7162306a36Sopenharmony_ci eg_cache_entry *(*get_by_vcc)(struct atm_vcc *vcc, struct mpoa_client *client); 7262306a36Sopenharmony_ci eg_cache_entry *(*get_by_src_ip)(__be32 ipaddr, struct mpoa_client *client); 7362306a36Sopenharmony_ci void (*put)(eg_cache_entry *entry); 7462306a36Sopenharmony_ci void (*remove_entry)(eg_cache_entry *entry, struct mpoa_client *client); 7562306a36Sopenharmony_ci void (*update)(eg_cache_entry *entry, uint16_t holding_time); 7662306a36Sopenharmony_ci void (*clear_expired)(struct mpoa_client *client); 7762306a36Sopenharmony_ci void (*destroy_cache)(struct mpoa_client *mpc); 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* Ingress cache entry states */ 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci#define INGRESS_REFRESHING 3 8462306a36Sopenharmony_ci#define INGRESS_RESOLVED 2 8562306a36Sopenharmony_ci#define INGRESS_RESOLVING 1 8662306a36Sopenharmony_ci#define INGRESS_INVALID 0 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* VCC states */ 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define OPEN 1 9162306a36Sopenharmony_ci#define CLOSED 0 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci/* Egress cache entry states */ 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define EGRESS_RESOLVED 2 9662306a36Sopenharmony_ci#define EGRESS_PURGE 1 9762306a36Sopenharmony_ci#define EGRESS_INVALID 0 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#endif 100