aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/robot/honeycomb/vxlan_gpe.robot
blob: 2f2cfc50b4f49c6388d919d3dc1ecf9dc801eff3 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

*** Settings ***
| Library | resources.libraries.python.InterfaceUtil
| Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords

*** Variables ***
# Translation table used to convert values received from Honeycomb to values
# received from VAT.
| &{protocols}=
| ... | -=0
| ... | ipv4=1
| ... | ipv6=2
| ... | ethernet=3
| ... | nsh=4

*** Keywords ***
| Honeycomb creates VxLAN GPE interface
| | [Documentation] | Uses Honeycomb API to configure a VxLAN tunnel.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface to be created. Type: string
| | ... | - base_settings - configuration data common for all interfaces.\
| | ... | Type: dictionary
| | ... | - vxlan_gpe_settings - VxLAN GPE specific parameters. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| Honeycomb creates VxLAN GPE interface \
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \| ${base_params} \
| | ... | \| ${vxlan_gpe_params} \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ... | ${base_settings} | ${vxlan_gpe_settings}
| | ...
| | Create VxLAN GPE interface
| | ... | ${node} | ${interface} | &{base_settings} | &{vxlan_gpe_settings}

| Honeycomb removes VxLAN GPE interface
| | [Documentation] | Uses Honeycomb API to remove VxLAN GPE interface from\
| | ... | node.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of the interface to be removed. Type: string
| | ...
| | ... | *Example:*
| | ...
| | ... | \| Honeycomb removes VxLAN GPE interface \
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ...
| | Delete interface | ${node} | ${interface}

| VxLAN GPE Operational Data From Honeycomb Should Be
| | [Documentation] | Uses Honeycomb API to get operational data about the\
| | ... | given interface and compares them to the values provided as arguments.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface to be checked. Type: string
| | ... | - base_settings - configuration data common for all interfaces.\
| | ... | Type: dictionary
| | ... | - vxlan_gpe_settings - VxLAN GPE specific parameters. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| VxLAN GPE Operational Data From Honeycomb Should Be \
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \| ${base_params} \
| | ... | \| ${vxlan_gpe_params} \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ... | ${base_settings} | ${vxlan_gpe_settings}
| | ...
| | ${api_data}= | Get interface oper data | ${node} | ${interface}
| | Should be equal as strings
| | ... | ${api_data['name']} | ${base_settings['name']}
| | Should be equal as strings
| | ... | ${api_data['type']} | v3po:vxlan-gpe-tunnel
| | Run keyword if | $base_settings['enabled'] == True
| | ... | Run keywords
| | ... | Should be equal as strings | ${api_data['admin-status']} | up
| | ... | AND
| | ... | Should be equal as strings | ${api_data['oper-status']} | up
| | ... | ELSE
| | ... | Run keywords
| | ... | Should be equal as strings | ${api_data['admin-status']} | down
| | ... | AND
| | ... | Should be equal as strings | ${api_data['oper-status']} | down

| VxLAN GPE Operational Data From VAT Should Be
| | [Documentation] | Uses VAT to get operational data about the given\
| | ... | interface and compares them to the values provided as arguments.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface to be checked. Type: string
| | ... | - vxlan_gpe_settings - VxLAN GPE specific parameters. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| VxLAN GPE Operational Data From VAT Should Be \
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \| ${vxlan_gpe_params} \|
| | ...
| | [Arguments] | ${node} | ${interface} | ${vxlan_gpe_params}
| | ...
| | ${vat_data}= | VxLAN GPE Dump | ${node} | ${interface}
| | Should be equal as strings
| | ... | ${vat_data['local']} | ${vxlan_gpe_params['local']}
| | Should be equal as strings
| | ... | ${vat_data['remote']} | ${vxlan_gpe_params['remote']}
| | Should be equal as strings
| | ... | ${vat_data['vni']} | ${vxlan_gpe_params['vni']}
| | Should be equal as strings
| | ... | ${vat_data['encap_vrf_id']} | ${vxlan_gpe_params['encap-vrf-id']}
| | Should be equal as strings
| | ... | ${vat_data['decap_vrf_id']} | ${vxlan_gpe_params['decap-vrf-id']}
# VAT dump multiplies protocol value by 16777216
| | Should be equal as strings | ${vat_data['protocol']/16777216}
| | ... | ${protocols['${vxlan_gpe_params['next-protocol']}']}

| VxLAN GPE Interface indices from Honeycomb and VAT should correspond
| | [Documentation] | Uses VAT and Honeycomb to get operational data about the \
| | ... | given VxLAN GPE interface and compares the interface indexes. The \
| | ... | VxLAN GPE interface index from Honeycomb should be greater than \
| | ... | index from VAT by one.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of the interface to be checked. Type: string
| | ...
| | ... | *Example:*
| | ...
| | ... | \| VxLAN GPE Interface indices from Honeycomb and VAT should \
| | ... | correspond \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ...
| | ${api_data}= | Get interface oper data | ${node} | ${interface}
| | ${vat_data}= | VxLAN GPE Dump | ${node} | ${interface}
| | ${sw_if_index}= | EVALUATE | ${vat_data['sw_if_index']} + 1
| | Should be equal as strings
| | ... | ${api_data['if-index']} | ${sw_if_index}

| VxLAN GPE Operational Data From Honeycomb Should Be empty
| | [Documentation] | Uses Honeycomb API to get operational data about\
| | ... | the given interface and expects to fail.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| VxLAN GPE Operational Data From Honeycomb Should Be empty\
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ...
| | ${api_data}= | Get interface oper data | ${node} | ${interface}
| | Should be empty | ${api_data}

| VxLAN GPE Operational Data From VAT Should Be empty
| | [Documentation] | Uses VAT to get operational data about the given\
| | ... | interface and expects an empty dictionary.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| VxLAN GPE Operational Data From VAT Should Be empty\
| | ... | \| ${nodes['DUT1']} \|
| | ...
| | [Arguments] | ${node}
| | ...
| | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
| | ... | VxLAN Dump | ${node}

| Honeycomb fails to create VxLAN GPE interface
| | [Documentation] | Uses Honeycomb API to configure a VxLAN tunnel with wrong\
| | ... | configuration data.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface to be created. Type: string
| | ... | - base_settings - Configuration data common for all interfaces.\
| | ... | Type: dictionary
| | ... | - vxlan_gpe_settings - VxLAN GPE specific parameters. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| Honeycomb fails to create VxLAN GPE interface \
| | ... | \| ${nodes['DUT1']} \| vxlan_gpe_tunnel0 \| ${wrong_base_params} \
| | ... | \| ${vxlan_gpe_params} \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ... | ${base_settings} | ${vxlan_gpe_settings}
| | ...
| | Run keyword and expect error | *HoneycombError*not successful. * code: *00.
| | ... | Create VxLAN GPE interface
| | ... | ${node} | ${interface} | &{base_settings} | &{vxlan_gpe_settings}
pan> vm->mbuf_alloc_list, n) < 0) return 0; _vec_len (vm->mbuf_alloc_list) = n; i = 0; while (i < (n - 7)) { vlib_prefetch_buffer_header (vlib_buffer_from_rte_mbuf (vm->mbuf_alloc_list[i + 4]), STORE); vlib_prefetch_buffer_header (vlib_buffer_from_rte_mbuf (vm->mbuf_alloc_list[i + 5]), STORE); vlib_prefetch_buffer_header (vlib_buffer_from_rte_mbuf (vm->mbuf_alloc_list[i + 6]), STORE); vlib_prefetch_buffer_header (vlib_buffer_from_rte_mbuf (vm->mbuf_alloc_list[i + 7]), STORE); mb0 = vm->mbuf_alloc_list[i]; mb1 = vm->mbuf_alloc_list[i + 1]; mb2 = vm->mbuf_alloc_list[i + 2]; mb3 = vm->mbuf_alloc_list[i + 3]; #if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0) ASSERT (rte_mbuf_refcnt_read (mb0) == 0); ASSERT (rte_mbuf_refcnt_read (mb1) == 0); ASSERT (rte_mbuf_refcnt_read (mb2) == 0); ASSERT (rte_mbuf_refcnt_read (mb3) == 0); rte_mbuf_refcnt_set (mb0, 1); rte_mbuf_refcnt_set (mb1, 1); rte_mbuf_refcnt_set (mb2, 1); rte_mbuf_refcnt_set (mb3, 1); #endif b0 = vlib_buffer_from_rte_mbuf (mb0); b1 = vlib_buffer_from_rte_mbuf (mb1); b2 = vlib_buffer_from_rte_mbuf (mb2); b3 = vlib_buffer_from_rte_mbuf (mb3); bi0 = vlib_get_buffer_index (vm, b0); bi1 = vlib_get_buffer_index (vm, b1); bi2 = vlib_get_buffer_index (vm, b2); bi3 = vlib_get_buffer_index (vm, b3); vec_add1_aligned (fl->buffers, bi0, CLIB_CACHE_LINE_BYTES); vec_add1_aligned (fl->buffers, bi1, CLIB_CACHE_LINE_BYTES); vec_add1_aligned (fl->buffers, bi2, CLIB_CACHE_LINE_BYTES); vec_add1_aligned (fl->buffers, bi3, CLIB_CACHE_LINE_BYTES); vlib_buffer_init_for_free_list (b0, fl); vlib_buffer_init_for_free_list (b1, fl); vlib_buffer_init_for_free_list (b2, fl); vlib_buffer_init_for_free_list (b3, fl); if (fl->buffer_init_function) { fl->buffer_init_function (vm, fl, &bi0, 1); fl->buffer_init_function (vm, fl, &bi1, 1); fl->buffer_init_function (vm, fl, &bi2, 1); fl->buffer_init_function (vm, fl, &bi3, 1); } i += 4; } while (i < n) { mb0 = vm->mbuf_alloc_list[i]; #if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 0) ASSERT (rte_mbuf_refcnt_read (mb0) == 0); rte_mbuf_refcnt_set (mb0, 1); #endif b0 = vlib_buffer_from_rte_mbuf (mb0); bi0 = vlib_get_buffer_index (vm, b0); vec_add1_aligned (fl->buffers, bi0, CLIB_CACHE_LINE_BYTES); vlib_buffer_init_for_free_list (b0, fl); if (fl->buffer_init_function) fl->buffer_init_function (vm, fl, &bi0, 1); i++; } fl->n_alloc += n; return n; } static u32 alloc_from_free_list (vlib_main_t * vm, vlib_buffer_free_list_t * free_list, u32 * alloc_buffers, u32 n_alloc_buffers) { u32 *dst, *src; uword len, n_filled; dst = alloc_buffers; n_filled = fill_free_list (vm, free_list, n_alloc_buffers); if (n_filled == 0) return 0; len = vec_len (free_list->buffers); ASSERT (len >= n_alloc_buffers); src = free_list->buffers + len - n_alloc_buffers; clib_memcpy (dst, src, n_alloc_buffers * sizeof (u32)); _vec_len (free_list->buffers) -= n_alloc_buffers; return n_alloc_buffers; } /* Allocate a given number of buffers into given array. Returns number actually allocated which will be either zero or number requested. */ u32 dpdk_buffer_alloc (vlib_main_t * vm, u32 * buffers, u32 n_buffers) { vlib_buffer_main_t *bm = vm->buffer_main; return alloc_from_free_list (vm, pool_elt_at_index (bm->buffer_free_list_pool, VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX), buffers, n_buffers); } u32 dpdk_buffer_alloc_from_free_list (vlib_main_t * vm, u32 * buffers, u32 n_buffers, u32 free_list_index) { vlib_buffer_main_t *bm = vm->buffer_main; vlib_buffer_free_list_t *f; f = pool_elt_at_index (bm->buffer_free_list_pool, free_list_index); return alloc_from_free_list (vm, f, buffers, n_buffers); } static_always_inline void vlib_buffer_free_inline (vlib_main_t * vm, u32 * buffers, u32 n_buffers, u32 follow_buffer_next) { vlib_buffer_main_t *bm = vm->buffer_main; vlib_buffer_free_list_t *fl; u32 fi; int i; u32 (*cb) (vlib_main_t * vm, u32 * buffers, u32 n_buffers, u32 follow_buffer_next); cb = bm->buffer_free_callback; if (PREDICT_FALSE (cb != 0)) n_buffers = (*cb) (vm, buffers, n_buffers, follow_buffer_next); if (!n_buffers) return; for (i = 0; i < n_buffers; i++) { vlib_buffer_t *b; b = vlib_get_buffer (vm, buffers[i]); fl = vlib_buffer_get_buffer_free_list (vm, b, &fi); /* The only current use of this callback: multicast recycle */ if (PREDICT_FALSE (fl->buffers_added_to_freelist_function != 0)) { int j; vlib_buffer_add_to_free_list (vm, fl, buffers[i], (b->flags & VLIB_BUFFER_RECYCLE) == 0); for (j = 0; j < vec_len (bm->announce_list); j++) { if (fl == bm->announce_list[j]) goto already_announced; } vec_add1 (bm->announce_list, fl); already_announced: ; } else { if (PREDICT_TRUE ((b->flags & VLIB_BUFFER_RECYCLE) == 0)) dpdk_rte_pktmbuf_free (vm, b); } } if (vec_len (bm->announce_list)) { vlib_buffer_free_list_t *fl; for (i = 0; i < vec_len (bm->announce_list); i++) { fl = bm->announce_list[i]; fl->buffers_added_to_freelist_function (vm, fl); } _vec_len (bm->announce_list) = 0; } } static void dpdk_buffer_free (vlib_main_t * vm, u32 * buffers, u32 n_buffers) { vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */ 1); } static void dpdk_buffer_free_no_next (vlib_main_t * vm, u32 * buffers, u32 n_buffers) { vlib_buffer_free_inline (vm, buffers, n_buffers, /* follow_buffer_next */ 0); } static void dpdk_packet_template_init (vlib_main_t * vm, void *vt, void *packet_data, uword n_packet_data_bytes, uword min_n_buffers_each_physmem_alloc, u8 * name) { vlib_packet_template_t *t = (vlib_packet_template_t *) vt; vlib_worker_thread_barrier_sync (vm); memset (t, 0, sizeof (t[0])); vec_add (t->packet_data, packet_data, n_packet_data_bytes); vlib_worker_thread_barrier_release (vm); } clib_error_t * vlib_buffer_pool_create (vlib_main_t * vm, unsigned num_mbufs, unsigned socket_id) { dpdk_main_t *dm = &dpdk_main; vlib_physmem_main_t *vpm = &vm->physmem_main; struct rte_mempool *rmp; int i; vec_validate_aligned (dm->pktmbuf_pools, socket_id, CLIB_CACHE_LINE_BYTES); /* pool already exists, nothing to do */ if (dm->pktmbuf_pools[socket_id]) return 0; u8 *pool_name = format (0, "mbuf_pool_socket%u%c", socket_id, 0); rmp = rte_pktmbuf_pool_create ((char *) pool_name, /* pool name */ num_mbufs, /* number of mbufs */ 512, /* cache size */ VLIB_BUFFER_HDR_SIZE, /* priv size */ VLIB_BUFFER_PRE_DATA_SIZE + VLIB_BUFFER_DATA_SIZE, /* dataroom size */ socket_id); /* cpu socket */ if (rmp) { { uword this_pool_end; uword this_pool_start; uword this_pool_size; uword save_vpm_start, save_vpm_end, save_vpm_size; struct rte_mempool_memhdr *memhdr; this_pool_start = ~0; this_pool_end = 0; STAILQ_FOREACH (memhdr, &rmp->mem_list, next) { if (((uword) (memhdr->addr + memhdr->len)) > this_pool_end) this_pool_end = (uword) (memhdr->addr + memhdr->len); if (((uword) memhdr->addr) < this_pool_start) this_pool_start = (uword) (memhdr->addr); } ASSERT (this_pool_start < ~0 && this_pool_end > 0); this_pool_size = this_pool_end - this_pool_start; if (CLIB_DEBUG > 1) { clib_warning ("%s: pool start %llx pool end %llx pool size %lld", pool_name, this_pool_start, this_pool_end, this_pool_size); clib_warning ("before: virtual.start %llx virtual.end %llx virtual.size %lld", vpm->virtual.start, vpm->virtual.end, vpm->virtual.size); } save_vpm_start = vpm->virtual.start; save_vpm_end = vpm->virtual.end; save_vpm_size = vpm->virtual.size; if ((this_pool_start < vpm->virtual.start) || vpm->virtual.start == 0) vpm->virtual.start = this_pool_start; if (this_pool_end > vpm->virtual.end) vpm->virtual.end = this_pool_end; vpm->virtual.size = vpm->virtual.end - vpm->virtual.start; if (CLIB_DEBUG > 1) { clib_warning ("after: virtual.start %llx virtual.end %llx virtual.size %lld", vpm->virtual.start, vpm->virtual.end, vpm->virtual.size); } /* check if fits into buffer index range */ if ((u64) vpm->virtual.size > ((u64) 1 << (32 + CLIB_LOG2_CACHE_LINE_BYTES))) { clib_warning ("physmem: virtual size out of range!"); vpm->virtual.start = save_vpm_start; vpm->virtual.end = save_vpm_end; vpm->virtual.size = save_vpm_size; rmp = 0; } } if (rmp) { dm->pktmbuf_pools[socket_id] = rmp; vec_free (pool_name); return 0; } } vec_free (pool_name); /* no usable pool for this socket, try to use pool from another one */ for (i = 0; i < vec_len (dm->pktmbuf_pools); i++) { if (dm->pktmbuf_pools[i]) { clib_warning ("WARNING: Failed to allocate mempool for CPU socket %u. " "Threads running on socket %u will use socket %u mempool.", socket_id, socket_id, i); dm->pktmbuf_pools[socket_id] = dm->pktmbuf_pools[i]; return 0; } } return clib_error_return (0, "failed to allocate mempool on socket %u", socket_id); } #if CLIB_DEBUG > 0 u32 *vlib_buffer_state_validation_lock; uword *vlib_buffer_state_validation_hash; void *vlib_buffer_state_heap; static clib_error_t * buffer_state_validation_init (vlib_main_t * vm) { void *oldheap; vlib_buffer_state_heap = mheap_alloc (0, 10 << 20); oldheap = clib_mem_set_heap (vlib_buffer_state_heap); vlib_buffer_state_validation_hash = hash_create (0, sizeof (uword)); vec_validate_aligned (vlib_buffer_state_validation_lock, 0, CLIB_CACHE_LINE_BYTES); clib_mem_set_heap (oldheap); return 0; } VLIB_INIT_FUNCTION (buffer_state_validation_init); #endif static vlib_buffer_callbacks_t callbacks = { .vlib_buffer_alloc_cb = &dpdk_buffer_alloc, .vlib_buffer_alloc_from_free_list_cb = &dpdk_buffer_alloc_from_free_list, .vlib_buffer_free_cb = &dpdk_buffer_free, .vlib_buffer_free_no_next_cb = &dpdk_buffer_free_no_next, .vlib_packet_template_init_cb = &dpdk_packet_template_init, .vlib_buffer_delete_free_list_cb = &dpdk_buffer_delete_free_list, }; static clib_error_t * dpdk_buffer_init (vlib_main_t * vm) { vlib_buffer_cb_register (vm, &callbacks); return 0; } VLIB_INIT_FUNCTION (dpdk_buffer_init); /** @endcond */ /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */