cleaned up engine
[ana-net.git] / src / xt_engine.c
blob7da3f43db74e1d6425148836195e2dc2ad109a2e
1 /*
2 * Lightweight Autonomic Network Architecture
4 * LANA packet processing engines. Incoming packtes are scheduled onto one
5 * of the CPU-affine engines and processed on the Functional Block stack.
6 * There are two queues where packets can be added, one from PHY direction
7 * for incoming packets (ingress) and one from the socket handler direction
8 * for outgoing packets (egress). Support for NUMA-affinity added.
10 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
11 * Swiss federal institute of technology (ETH Zurich)
12 * Subject to the GPL.
15 #include <linux/kernel.h>
16 #include <linux/skbuff.h>
17 #include <linux/prefetch.h>
19 #include "xt_engine.h"
20 #include "xt_skb.h"
21 #include "xt_fblock.h"
23 /* Main function */
24 int process_packet(struct sk_buff *skb, enum path_type dir)
26 int ret = PPE_ERROR;
27 idp_t cont;
28 struct fblock *fb;
29 prefetch(skb->cb);
30 rcu_read_lock();
31 while ((cont = read_next_idp_from_skb(skb))) {
32 fb = __search_fblock(cont);
33 if (unlikely(!fb)) {
34 ret = PPE_ERROR;
35 break;
37 ret = fb->netfb_rx(fb, skb, &dir);
38 put_fblock(fb);
39 if (ret == PPE_DROPPED) {
40 ret = PPE_DROPPED;
41 break;
43 prefetch(skb->cb);
45 rcu_read_unlock();
46 return ret;
48 EXPORT_SYMBOL_GPL(process_packet);