summaryrefslogtreecommitdiffstats
path: root/test/vpp_gre_interface.py
blob: 91293c3d28c1e87c782fa2c161413264bce5bd91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from vpp_interface import VppInterface
import socket


class VppGreInterface(VppInterface):
    """
    VPP GRE interface
    """

    def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
                 session=0):
        """ Create VPP GRE interface """
        self._sw_if_index = 0
        super(VppGreInterface, self).__init__(test)
        self._test = test
        self.t_src = src_ip
        self.t_dst = dst_ip
        self.t_outer_fib = outer_fib_id
        self.t_type = type
        self.t_session = session

    def add_vpp_config(self):
        s = socket.inet_pton(socket.AF_INET, self.t_src)
        d = socket.inet_pton(socket.AF_INET, self.t_dst)
        r = self.test.vapi.gre_tunnel_add_del(s, d,
                                              outer_fib_id=self.t_outer_fib,
                                              tunnel_type=self.t_type,
                                              session_id=self.t_session)
        self._sw_if_index = r.sw_if_index
        self.generate_remote_hosts()
        self._test.registry.register(self, self._test.logger)

    def remove_vpp_config(self):
        s = socket.inet_pton(socket.AF_INET, self.t_src)
        d = socket.inet_pton(socket.AF_INET, self.t_dst)
        self.unconfig()
        self.test.vapi.gre_tunnel_add_del(s, d,
                                          outer_fib_id=self.t_outer_fib,
                                          tunnel_type=self.t_type,
                                          session_id=self.t_session,
                                          is_add=0)

    def __str__(self):
        return self.object_id()

    def object_id(self):
        return "gre-%d" % self._sw_if_index


class VppGre6Interface(VppInterface):
    """
    VPP GRE IPv6 interface
    """

    def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, type=0,
                 session=0):
        """ Create VPP GRE interface """
        self._sw_if_index = 0
        super(VppGre6Interface, self).__init__(test)
        self._test = test
        self.t_src = src_ip
        self.t_dst = dst_ip
        self.t_outer_fib = outer_fib_id
        self.t_type = type
        self.t_session = session

    def add_vpp_config(self):
        s = socket.inet_pton(socket.AF_INET6, self.t_src)
        d = socket.inet_pton(socket.AF_INET6, self.t_dst)
        r = self.test.vapi.gre_tunnel_add_del(s, d,
                                              outer_fib_id=self.t_outer_fib,
                                              tunnel_type=self.t_type,
                                              session_id=self.t_session,
                                              is_ip6=1)
        self._sw_if_index = r.sw_if_index
        self.generate_remote_hosts()
        self._test.registry.register(self, self._test.logger)

    def remove_vpp_config(self):
        s = socket.inet_pton(socket.AF_INET6, self.t_src)
        d = socket.inet_pton(socket.AF_INET6, self.t_dst)
        self.unconfig()
        self.test.vapi.gre_tunnel_add_del(s, d,
                                          outer_fib_id=self.t_outer_fib,
                                          tunnel_type=self.t_type,
                                          session_id=self.t_session,
                                          is_add=0,
                                          is_ip6=1)

    def __str__(self):
        return self.object_id()

    def object_id(self):
        return "gre-%d" % self._sw_if_index
class="p">); u32 n_left_from, n_left_to_next, *to_next, next_index, next0; int pi, pi_limit; n_left_from = frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); pi_limit = clib_min (n_left_from, n_left_to_next); for (pi = 0; pi < NSTAGES - 1; pi++) { if (pi == pi_limit) break; stage0 (vm, node, from[pi]); } for (; pi < pi_limit; pi++) { stage0 (vm, node, from[pi]); to_next[0] = from[pi - 1]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 1]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 1], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } for (; pi < (pi_limit + (NSTAGES - 1)); pi++) { if (((pi - 1) >= 0) && ((pi - 1) < pi_limit)) { to_next[0] = from[pi - 1]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 1]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 1], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } vlib_put_next_frame (vm, node, next_index, n_left_to_next); from += pi_limit; } return frame->n_vectors; } #endif #if NSTAGES == 3 static STAGE_INLINE uword dispatch_pipeline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 *from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, *to_next, next_index, next0; int pi, pi_limit; n_left_from = frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); pi_limit = clib_min (n_left_from, n_left_to_next); for (pi = 0; pi < NSTAGES - 1; pi++) { if (pi == pi_limit) break; stage0 (vm, node, from[pi]); if (pi - 1 >= 0) stage1 (vm, node, from[pi - 1]); } for (; pi < pi_limit; pi++) { stage0 (vm, node, from[pi]); stage1 (vm, node, from[pi - 1]); to_next[0] = from[pi - 2]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 2]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 2], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } for (; pi < (pi_limit + (NSTAGES - 1)); pi++) { if (((pi - 1) >= 0) && ((pi - 1) < pi_limit)) stage1 (vm, node, from[pi - 1]); if (((pi - 2) >= 0) && ((pi - 2) < pi_limit)) { to_next[0] = from[pi - 2]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 2]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 2], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } vlib_put_next_frame (vm, node, next_index, n_left_to_next); from += pi_limit; } return frame->n_vectors; } #endif #if NSTAGES == 4 static STAGE_INLINE uword dispatch_pipeline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 *from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, *to_next, next_index, next0; int pi, pi_limit; n_left_from = frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); pi_limit = clib_min (n_left_from, n_left_to_next); for (pi = 0; pi < NSTAGES - 1; pi++) { if (pi == pi_limit) break; stage0 (vm, node, from[pi]); if (pi - 1 >= 0) stage1 (vm, node, from[pi - 1]); if (pi - 2 >= 0) stage2 (vm, node, from[pi - 2]); } for (; pi < pi_limit; pi++) { stage0 (vm, node, from[pi]); stage1 (vm, node, from[pi - 1]); stage2 (vm, node, from[pi - 2]); to_next[0] = from[pi - 3]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 3]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 3], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } for (; pi < (pi_limit + (NSTAGES - 1)); pi++) { if (((pi - 1) >= 0) && ((pi - 1) < pi_limit)) stage1 (vm, node, from[pi - 1]); if (((pi - 2) >= 0) && ((pi - 2) < pi_limit)) stage2 (vm, node, from[pi - 2]); if (((pi - 3) >= 0) && ((pi - 3) < pi_limit)) { to_next[0] = from[pi - 3]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 3]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 3], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } vlib_put_next_frame (vm, node, next_index, n_left_to_next); from += pi_limit; } return frame->n_vectors; } #endif #if NSTAGES == 5 static STAGE_INLINE uword dispatch_pipeline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 *from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, *to_next, next_index, next0; int pi, pi_limit; n_left_from = frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); pi_limit = clib_min (n_left_from, n_left_to_next); for (pi = 0; pi < NSTAGES - 1; pi++) { if (pi == pi_limit) break; stage0 (vm, node, from[pi]); if (pi - 1 >= 0) stage1 (vm, node, from[pi - 1]); if (pi - 2 >= 0) stage2 (vm, node, from[pi - 2]); if (pi - 3 >= 0) stage3 (vm, node, from[pi - 3]); } for (; pi < pi_limit; pi++) { stage0 (vm, node, from[pi]); stage1 (vm, node, from[pi - 1]); stage2 (vm, node, from[pi - 2]); stage3 (vm, node, from[pi - 3]); to_next[0] = from[pi - 4]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 4]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 4], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } for (; pi < (pi_limit + (NSTAGES - 1)); pi++) { if (((pi - 1) >= 0) && ((pi - 1) < pi_limit)) stage1 (vm, node, from[pi - 1]); if (((pi - 2) >= 0) && ((pi - 2) < pi_limit)) stage2 (vm, node, from[pi - 2]); if (((pi - 3) >= 0) && ((pi - 3) < pi_limit)) stage3 (vm, node, from[pi - 3]); if (((pi - 4) >= 0) && ((pi - 4) < pi_limit)) { to_next[0] = from[pi - 4]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 4]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 4], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } vlib_put_next_frame (vm, node, next_index, n_left_to_next); from += pi_limit; } return frame->n_vectors; } #endif #if NSTAGES == 6 static STAGE_INLINE uword dispatch_pipeline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 *from = vlib_frame_vector_args (frame); u32 n_left_from, n_left_to_next, *to_next, next_index, next0; int pi, pi_limit; n_left_from = frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); pi_limit = clib_min (n_left_from, n_left_to_next); for (pi = 0; pi < NSTAGES - 1; pi++) { if (pi == pi_limit) break; stage0 (vm, node, from[pi]); if (pi - 1 >= 0) stage1 (vm, node, from[pi - 1]); if (pi - 2 >= 0) stage2 (vm, node, from[pi - 2]); if (pi - 3 >= 0) stage3 (vm, node, from[pi - 3]); if (pi - 4 >= 0) stage4 (vm, node, from[pi - 4]); } for (; pi < pi_limit; pi++) { stage0 (vm, node, from[pi]); stage1 (vm, node, from[pi - 1]); stage2 (vm, node, from[pi - 2]); stage3 (vm, node, from[pi - 3]); stage4 (vm, node, from[pi - 4]); to_next[0] = from[pi - 5]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 5]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 5], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } for (; pi < (pi_limit + (NSTAGES - 1)); pi++) { if (((pi - 1) >= 0) && ((pi - 1) < pi_limit)) stage1 (vm, node, from[pi - 1]); if (((pi - 2) >= 0) && ((pi - 2) < pi_limit)) stage2 (vm, node, from[pi - 2]); if (((pi - 3) >= 0) && ((pi - 3) < pi_limit)) stage3 (vm, node, from[pi - 3]); if (((pi - 4) >= 0) && ((pi - 4) < pi_limit)) stage4 (vm, node, from[pi - 4]); if (((pi - 5) >= 0) && ((pi - 5) < pi_limit)) { to_next[0] = from[pi - 5]; to_next++; n_left_to_next--; next0 = last_stage (vm, node, from[pi - 5]); vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, n_left_to_next, from[pi - 5], next0); n_left_from--; if ((int) n_left_to_next < 0 && n_left_from > 0) vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); } } vlib_put_next_frame (vm, node, next_index, n_left_to_next); from += pi_limit; } return frame->n_vectors; } #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */