fb migration, part 2
[ana-net.git] / src / xt_engine.h
blobfd6545059cb31eefcee978dabf514000a883968c
1 /*
2 * Lightweight Autonomic Network Architecture
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL.
7 */
9 #ifndef XT_ENGINE_H
10 #define XT_ENGINE_H
12 #include <linux/skbuff.h>
13 #include <linux/wait.h>
14 #include <linux/cpu.h>
15 #include <linux/sched.h>
16 #include <linux/u64_stats_sync.h>
17 #include <linux/atomic.h>
19 #include "xt_fblock.h"
21 #define NUM_QUEUES NUM_TYPES
23 #define PPE_SUCCESS 0
24 #define PPE_DROPPED 1
25 #define PPE_ERROR 2
27 struct worker_estats {
28 u64 packets;
29 u64 bytes;
30 u64 dropped;
31 struct u64_stats_sync syncp;
32 u32 errors;
35 struct ppe_queue {
36 enum path_type type;
37 struct sk_buff_head queue;
38 struct worker_estats stats;
39 struct ppe_queue *next;
40 } ____cacheline_aligned_in_smp;
42 struct ppe_squeue {
43 struct ppe_queue *head;
44 struct ppe_queue *ptrs[NUM_QUEUES];
47 struct worker_engine {
48 unsigned int cpu;
49 struct proc_dir_entry *proc;
50 struct task_struct *thread;
51 struct ppe_squeue inqs;
52 wait_queue_head_t wait_queue;
53 atomic64_t load;
54 } ____cacheline_aligned_in_smp;
56 extern int init_worker_engines(void);
57 extern void cleanup_worker_engines(void);
58 extern struct worker_engine __percpu *engines;
60 static inline void enqueue_egress_on_engine(struct sk_buff *skb,
61 unsigned int cpu)
63 struct worker_engine *ppe = per_cpu_ptr(engines, cpu);
64 skb_queue_tail(&ppe->inqs.ptrs[TYPE_EGRESS]->queue, skb);
65 atomic64_inc(&ppe->load);
66 wake_up_interruptible(&ppe->wait_queue);
69 static inline void enqueue_ingress_on_engine(struct sk_buff *skb,
70 unsigned int cpu)
72 struct worker_engine *ppe = per_cpu_ptr(engines, cpu);
73 skb_queue_tail(&ppe->inqs.ptrs[TYPE_INGRESS]->queue, skb);
74 atomic64_inc(&ppe->load);
75 wake_up_interruptible(&ppe->wait_queue);
78 #endif /* XT_ENGINE_H */