1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef _UPCALL_CACHE_H
6 #define _UPCALL_CACHE_H
8 #define UC_CACHE_NEW 0x01
9 #define UC_CACHE_ACQUIRING 0x02
10 #define UC_CACHE_INVALID 0x04
11 #define UC_CACHE_EXPIRED 0x08
13 #define UC_CACHE_IS_NEW(i) ((i)->ue_flags & UC_CACHE_NEW)
14 #define UC_CACHE_IS_INVALID(i) ((i)->ue_flags & UC_CACHE_INVALID)
15 #define UC_CACHE_IS_ACQUIRING(i) ((i)->ue_flags & UC_CACHE_ACQUIRING)
16 #define UC_CACHE_IS_EXPIRED(i) ((i)->ue_flags & UC_CACHE_EXPIRED)
17 #define UC_CACHE_IS_VALID(i) ((i)->ue_flags == 0)
19 #define UC_CACHE_SET_NEW(i) (i)->ue_flags |= UC_CACHE_NEW
20 #define UC_CACHE_SET_INVALID(i) (i)->ue_flags |= UC_CACHE_INVALID
21 #define UC_CACHE_SET_ACQUIRING(i) (i)->ue_flags |= UC_CACHE_ACQUIRING
22 #define UC_CACHE_SET_EXPIRED(i) (i)->ue_flags |= UC_CACHE_EXPIRED
23 #define UC_CACHE_SET_VALID(i) (i)->ue_flags = 0
25 #define UC_CACHE_CLEAR_NEW(i) (i)->ue_flags &= ~UC_CACHE_NEW
26 #define UC_CACHE_CLEAR_ACQUIRING(i) (i)->ue_flags &= ~UC_CACHE_ACQUIRING
27 #define UC_CACHE_CLEAR_INVALID(i) (i)->ue_flags &= ~UC_CACHE_INVALID
28 #define UC_CACHE_CLEAR_EXPIRED(i) (i)->ue_flags &= ~UC_CACHE_EXPIRED
32 struct upcall_cache_entry {
33 struct list_head ue_hash;
36 struct upcall_cache *ue_cache;
38 wait_queue_head_t ue_waitq;
39 unsigned long ue_acquire_expire;
40 unsigned long ue_expire;
43 #define UC_CACHE_UPCALL_MAXPATH (1024)
46 struct list_head *uc_hashtable;
51 char uc_upcall[UC_CACHE_UPCALL_MAXPATH];
52 unsigned long uc_acquire_expire; /* max acquire time */
53 unsigned long uc_entry_expire; /* max entry life time */
54 unsigned long uc_err_entry_expire; /* err entry life time */
57 unsigned int (*hash)(struct upcall_cache *, __u64);
58 struct upcall_cache_entry* (*alloc_entry)(struct upcall_cache *, __u64);
59 void (*free_entry)(struct upcall_cache *,
60 struct upcall_cache_entry *);
61 int (*make_upcall)(struct upcall_cache *,
62 struct upcall_cache_entry *);
63 int (*parse_downcall)(struct upcall_cache *,
64 struct upcall_cache_entry *,
68 void upcall_cache_init_entry(struct upcall_cache *cache,
69 struct upcall_cache_entry *entry,
71 struct upcall_cache_entry *
72 upcall_cache_get_entry(struct upcall_cache *cache, __u64 key);
73 void upcall_cache_put_entry(struct upcall_cache_entry *entry);
74 int upcall_cache_downcall(struct upcall_cache *cache, __u64 key, void *args);
75 void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key);
76 void upcall_cache_flush_idle(struct upcall_cache *cache);
77 void upcall_cache_flush_all(struct upcall_cache *cache);
79 #endif /* _UPCALL_CACHE_H */