/* *------------------------------------------------------------------ * Copyright (c) 2017 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. *------------------------------------------------------------------ */ #include #include #include #include #include #include #include #include #include #include #include #include #include DEFINE_VAPI_MSG_IDS_VPE_API_JSON; DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON; DEFINE_VAPI_MSG_IDS_L2_API_JSON; DEFINE_VAPI_MSG_IDS_STATS_API_JSON; DEFINE_VAPI_MSG_IDS_FAKE_API_JSON; static char *app_name = NULL; static char *api_prefix = NULL; static const int max_outstanding_requests = 64; static const int response_queue_size = 32; /* centos has ancient check so we hack our way around here * to make it work somehow */ #ifndef ck_assert_ptr_eq #define ck_assert_ptr_eq(X,Y) ck_assert_int_eq((long)X, (long)Y) #endif #ifndef ck_assert_ptr_ne #define ck_assert_ptr_ne(X,Y) ck_assert_int_ne((long)X, (long)Y) #endif START_TEST (test_invalid_values) { vapi_ctx_t ctx; vapi_error_e rv = vapi_ctx_alloc (&ctx); ck_assert_int_eq (VAPI_OK, rv); vapi_msg_show_version *sv = vapi_alloc_show_version (ctx); ck_assert_ptr_eq (NULL, sv); rv = vapi_send (ctx, sv); ck_assert_int_eq (VAPI_EINVAL, rv); rv = vapi_connect (ctx, app_name, api_prefix, max_outstanding_requests, response_queue_size, VAPI_MODE_BLOCKING, true); ck_assert_int_eq (VAPI_OK, rv); rv = vapi_send (ctx, NULL); ck_assert_int_eq (VAPI_EINVAL, rv); rv = vapi_send (NULL, NULL); ck_assert_int_eq (VAPI_EINVAL, rv); rv = vapi_recv (NULL, NULL, NULL, 0, 0); ck_assert_int_eq (VAPI_EINVAL, rv); rv = vapi_recv (ctx, NULL, NULL, 0, 0); ck_assert_int_eq (VAPI_EINVAL, rv); vapi_msg_show_version_reply *reply; rv = vapi_recv (ctx, (void **) &reply, NULL, 0, 0); ck_assert_int_eq (VAPI_EINVAL, rv); rv = vapi_disconnect (ctx); ck_assert_int_eq (VAPI_OK, rv); vapi_ctx_free (ctx); } END_TEST; START_TEST (test_hton_1) { const u16 _vl_msg_id = 1; vapi_type_msg_header1_t h; h._vl_msg_id = _vl_msg_id; vapi_type_msg_header1_t_hton (&h); ck_assert_int_eq (be16toh (h._vl_msg_id), _vl_msg_id); } END_TEST; START_TEST (test_hton_2) { const u16 _vl_msg_id = 1; const u32 client_index = 3; vapi_type_msg_header2_t h; h._vl_msg_id = _vl_msg_id; h.client_index = client_index; vapi_type_msg_header2_t_hton (&h); ck_assert_int_eq (be16toh (h._vl_msg_id), _vl_msg_id); ck_assert_int_eq (h.client_index, client_index); } END_TEST; START_TEST (test_hton_3) { const size_t data_size = 10; vapi_msg_vnet_interface_combined_counters *m = malloc (sizeof (vapi_msg_vnet_interface_combined_counters) + data_size * sizeof (vapi_type_vlib_counter)); ck_assert_ptr_ne (NULL, m); vapi_payload_vnet_interface_combined_counters *p = &m->payload; const u16 _vl_msg_id = 1; p->_vl_msg_id = _vl_msg_id; const u32 first_sw_if_index = 2; p->first_sw_if_index = first_sw_if_index; p->count = data_size; const u64 packets = 1234; const u64 bytes = 2345; int i; for (i = 0; i < data_size; ++i) { p->data[i].packets = packets; p->data[i].bytes = bytes; } vapi_msg_vnet_interface_combined_counters_hton (m); ck_assert_int_eq (_vl_msg_id, be16toh (p->_vl_msg_id)); ck_assert_int_eq (first_sw_if_index, be32toh (p->first_sw_if_index)); ck_assert_int_eq (data_size, be32toh (p->count)); for (i = 0; i < data_size; ++i) { ck_assert_int_eq (packets, be64toh (p->data[i].packets)); ck_assert_int_eq (bytes, be64toh (p->data[i].bytes)); } free (p); } END_TEST; #define verify_hton_swap(expr, value) \ if (4 == sizeof (expr)) \ { \ ck_assert_int_eq (expr, htobe32 (value)); \ } \ else if (2 == sizeof (expr)) \ { \ ck_assert_int_eq (expr, htobe16 (value)); \ } \ else \ { \ ck_assert_int_eq (expr, value); \ } START_TEST (test_hton_4) { const int vla_count = 3; char x[sizeof (vapi_msg_bridge_domain_details) + vla_count * sizeof (vapi_type_bridge_domain_sw_if)]; vapi_msg_bridge_domain_details *d = (void *) x; int cnt = 1; d->header._vl_msg_id = cnt++; d->header.context = cnt++; d->payload.bd_id = cnt++; d->payload.flood = cnt++; d->payload.uu_flood = cnt++; d->payload.forward = cnt++; d->payload.learn = cnt++; d->payload.arp_term = cnt++; d->payload.mac_age = cnt++; d->payload.bvi_sw_if_index = cnt++; d->payload.n_sw_ifs = vla_count; int i; for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; det->context = cnt++; det->sw_if_index = cnt++; det->shg = cnt++; } ck_assert_int_eq (sizeof (x), vapi_calc_bridge_domain_details_msg_size (d)); vapi_msg_bridge_domain_details_hton (d); int tmp = 1; verify_hton_swap (d->header._vl_msg_id, tmp); ++tmp; ck_assert_int_eq (d->header.context, tmp); ++tmp; verify_hton_swap (d->payload.bd_id, tmp); ++tmp; verify_hton_swap (d->payload.flood, tmp); ++tmp; verify_hton_swap (d->payload.uu_flood, tmp); ++tmp; verify_hton_swap (d->payload.forward, tmp); ++tmp; verify_hton_swap (d->payload.learn, tmp); ++tmp; verify_hton_swap (d->payload.arp_term, tmp); ++tmp; verify_hton_swap (d->payload.mac_age, tmp); ++tmp; verify_hton_swap (d->payload.bvi_sw_if_index, tmp); ++tmp; ck_assert_int_eq (d->payload.n_sw_ifs, htobe32 (vla_count)); for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; verify_hton_swap (det->context, tmp); ++tmp; verify_hton_swap (det->sw_if_index, tmp); ++tmp; verify_hton_swap (det->shg, tmp); ++tmp; } vapi_msg_bridge_domain_details_ntoh (d); tmp = 1; ck_assert_int_eq (d->header._vl_msg_id, tmp); ++tmp; ck_assert_int_eq (d->header.context, tmp); ++tmp; ck_assert_int_eq (d->payload.bd_id, tmp); ++tmp; ck_assert_int_eq (d->payload.flood, tmp); ++tmp; ck_assert_int_eq (d->payload.uu_flood, tmp); ++tmp; ck_assert_int_eq (d->payload.forward, tmp); ++tmp; ck_assert_int_eq (d->payload.learn, tmp); ++tmp; ck_assert_int_eq (d->payload.arp_term, tmp); ++tmp; ck_assert_int_eq (d->payload.mac_age, tmp); ++tmp; ck_assert_int_eq (d->payload.bvi_sw_if_index, tmp); ++tmp; ck_assert_int_eq (d->payload.n_sw_ifs, vla_count); for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; ck_assert_int_eq (det->context, tmp); ++tmp; ck_assert_int_eq (det->sw_if_index, tmp); ++tmp; ck_assert_int_eq (det->shg, tmp); ++tmp; } ck_assert_int_eq (sizeof (x), vapi_calc_bridge_domain_details_msg_size (d)); } END_TEST; START_TEST (test_ntoh_1) { const u16 _vl_msg_id = 1; vapi_type_msg_header1_t h; h._vl_msg_id = _vl_msg_id; vapi_type_msg_header1_t_ntoh (&h); ck_assert_int_eq (htobe16 (h._vl_msg_id), _vl_msg_id); } END_TEST; START_TEST (test_ntoh_2) { const u16 _vl_msg_id = 1; const u32 client_index = 3; vapi_type_msg_header2_t h; h._vl_msg_id = _vl_msg_id; h.client_index = client_index; vapi_type_msg_header2_t_ntoh (&h); ck_assert_int_eq (htobe16 (h._vl_msg_id), _vl_msg_id); ck_assert_int_eq (h.client_index, client_index); } END_TEST; START_TEST (test_ntoh_3) { const size_t data_size = 10; vapi_msg_vnet_interface_combined_counters *m = malloc (sizeof (vapi_msg_vnet_interface_combined_counters) + data_size * sizeof (vapi_type_vlib_counter)); ck_assert_ptr_ne (NULL, m); vapi_payload_vnet_interface_combined_counters *p = &m->payload; const u16 _vl_msg_id = 1; p->_vl_msg_id = _vl_msg_id; const u32 first_sw_if_index = 2; p->first_sw_if_index = first_sw_if_index; const size_t be_data_size = htobe32 (data_size); p->count = be_data_size; const u64 packets = 1234; const u64 bytes = 2345; int i; for (i = 0; i < data_size; ++i) { p->data[i].packets = packets; p->data[i].bytes = bytes; } vapi_msg_vnet_interface_combined_counters_ntoh (m); ck_assert_int_eq (_vl_msg_id, be16toh (p->_vl_msg_id)); ck_assert_int_eq (first_sw_if_index, be32toh (p->first_sw_if_index)); ck_assert_int_eq (be_data_size, be32toh (p->count)); for (i = 0; i < data_size; ++i) { ck_assert_int_eq (packets, htobe64 (p->data[i].packets)); ck_assert_int_eq (bytes, htobe64 (p->data[i].bytes)); } free (p); } END_TEST; #define verify_ntoh_swap(expr, value) \ if (4 == sizeof (expr)) \ { \ ck_assert_int_eq (expr, be32toh (value)); \ } \ else if (2 == sizeof (expr)) \ { \ ck_assert_int_eq (expr, be16toh (value)); \ } \ else \ { \ ck_assert_int_eq (expr, value); \ } START_TEST (test_ntoh_4) { const int vla_count = 3; char x[sizeof (vapi_msg_bridge_domain_details) + vla_count * sizeof (vapi_type_bridge_domain_sw_if)]; vapi_msg_bridge_domain_details *d = (void *) x; int cnt = 1; d->header._vl_msg_id = cnt++; d->header.context = cnt++; d->payload.bd_id = cnt++; d->payload.flood = cnt++; d->payload.uu_flood = cnt++; d->payload.forward = cnt++; d->payload.learn = cnt++; d->payload.arp_term = cnt++; d->payload.mac_age = cnt++; d->payload.bvi_sw_if_index = cnt++; d->payload.n_sw_ifs = htobe32 (vla_count); int i; for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; det->context = cnt++; det->sw_if_index = cnt++; det->shg = cnt++; } vapi_msg_bridge_domain_details_ntoh (d); ck_assert_int_eq (sizeof (x), vapi_calc_bridge_domain_details_msg_size (d)); int tmp = 1; verify_ntoh_swap (d->header._vl_msg_id, tmp); ++tmp; ck_assert_int_eq (d->header.context, tmp); ++tmp; verify_ntoh_swap (d->payload.bd_id, tmp); ++tmp; verify_ntoh_swap (d->payload.flood, tmp); ++tmp; verify_ntoh_swap (d->payload.uu_flood, tmp); ++tmp; verify_ntoh_swap (d->payload.forward, tmp); ++tmp; verify_ntoh_swap (d->payload.learn, tmp); ++tmp; verify_ntoh_swap (d->payload.arp_term, tmp); ++tmp; verify_ntoh_swap (d->payload.mac_age, tmp); ++tmp; verify_ntoh_swap (d->payload.bvi_sw_if_index, tmp); ++tmp; ck_assert_int_eq (d->payload.n_sw_ifs, vla_count); for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; verify_ntoh_swap (det->context, tmp); ++tmp; verify_ntoh_swap (det->sw_if_index, tmp); ++tmp; verify_ntoh_swap (det->shg, tmp); ++tmp; } vapi_msg_bridge_domain_details_hton (d); tmp = 1; ck_assert_int_eq (d->header._vl_msg_id, tmp); ++tmp; ck_assert_int_eq (d->header.context, tmp); ++tmp; ck_assert_int_eq (d->payload.bd_id, tmp); ++tmp; ck_assert_int_eq (d->payload.flood, tmp); ++tmp; ck_assert_int_eq (d->payload.uu_flood, tmp); ++tmp; ck_assert_int_eq (d->payload.forward, tmp); ++tmp; ck_assert_int_eq (d->payload.learn, tmp); ++tmp; ck_assert_int_eq (d->payload.arp_term, tmp); ++tmp; ck_assert_int_eq (d->payload.mac_age, tmp); ++tmp; ck_assert_int_eq (d->payload.bvi_sw_if_index, tmp); ++tmp; ck_assert_int_eq (d->payload.n_sw_ifs, htobe32 (vla_count)); for (i = 0; i < vla_count; ++i) { vapi_type_bridge_domain_sw_if *det = &d->payload.sw_if_details[i]; ck_assert_int_eq (det->context, tmp); ++tmp; ck_assert_int_eq (det->sw_if_index, tmp); ++tmp; ck_assert_int_eq (det->shg, tmp); ++tmp; } } END_TEST; vapi_error_e show_version_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, vapi_payload_show_version_reply * p) { ck_assert_int_eq (VAPI_OK, rv); ck_assert_int_eq (true, is_last); ck_assert_str_eq ("vpe", (char *) p->program); printf ("show_version_reply: program: `%s', version: `%s', build directory: " "`%s', build date: `%s'\n", p->program, p->version, p->build_directory, p->build_date); ++*(int *) caller_ctx; return VAPI_OK; } typedef struct { int called; int expected_retval; u32 *sw_if_index_storage; } test_create_loopback_ctx_t; vapi_error_e loopback_create_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, vapi_payload_create_loopback_reply * p) { test_create_loopback_ctx_t *clc = caller_ctx; ck_assert_int_eq (clc->expected_retval, p->retval); *clc->sw_if_index_storage = p->sw_if_index; ++clc->called; return VAPI_OK; } typedef struct { int called; int expected_retval; u32 *sw_if_index_storage; } test_delete_loopback_ctx_t; vapi_error_e loopback_delete_cb (vapi_ctx_t ctx, void *caller_ctx, vapi_error_e rv, bool is_last, vapi_payload_delete_loopback_reply * p) { test_delete_loopback_ctx_t *dlc = caller_ctx; ck_assert_int_eq (dlc->expected_retval, p->retval); ++dlc->called; return VAPI_OK; } START_TEST (test_connect) { vapi_ctx_t ctx; vapi_error_e rv = vapi_ctx_alloc (&ctx); ck_assert_int_eq (VAPI_OK, rv); rv = vapi_connect (ctx, app_name, api_prefix, max_outstanding_requests, response_queue_size, VAPI_MODE_BLOCKING, true); ck_assert_int_eq (VAPI_OK, rv); rv = vapi_disconnect (ctx); ck_assert_int_eq (VAPI_OK, rv); vapi_ctx_free (ctx); } END_TEST; vapi_ctx_t ctx; void setup_blocking (void) { vapi_error_e rv = vapi_ctx_alloc (&ctx); ck_assert_int_eq (VAPI_OK, rv); rv = vapi_connect (ctx, app_name, api_prefix, max_outstanding_requests, response_queue_size, VAPI_MODE_BLOCKING, true); ck_assert_int_eq (VAPI_OK, rv); } v
# Copyright (c) 2019 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 ***
| Resource | resources/libraries/robot/shared/default.robot
| ...
| Force Tags | 3_NODE_SINGLE_LINK_TOPO | PERFTEST | HW_ENV | NDRPDR
| ... | NIC_Intel-X710 | ETH | L2BDMACLRN | BASE | L2BDBASE
| ...
| Suite Setup | Setup suite single link | performance
| Suite Teardown | Tear down suite | performance
| Test Setup | Setup test
| Test Teardown | Tear down test | performance
| ...
| Test Template | Local Template
| ...
| Documentation | *RFC2544: Pkt throughput L2BD test cases*
| ...
| ... | *[Top] Network Topologies:* TG-DUT1-DUT2-TG 3-node circular topology\
| ... | with single links between nodes.
| ... | *[Enc] Packet Encapsulations:* Eth-IPv4 for L2 switching of IPv4.
| ... | *[Cfg] DUT configuration:* DUT1 and DUT2 are configured with L2 bridge-\
| ... | domain and MAC learning enabled. DUT1 and DUT2 tested with ${nic_name}.\
| ... | *[Ver] TG verification:* TG finds and reports throughput NDR (Non Drop\
| ... | Rate) with zero packet loss tolerance and throughput PDR (Partial Drop\
| ... | Rate) with non-zero packet loss tolerance (LT) expressed in percentage\
| ... | of packets transmitted. NDR and PDR are discovered for different\
| ... | Ethernet L2 frame sizes using MLRsearch library.\
| ... | Test packets are generated by TG on links to DUTs. TG traffic profile\
| ... | contains two L3 flow-groups (flow-group per direction, 254 flows per\
| ... | flow-group) with all packets containing Ethernet header, IPv4 header\
| ... | with IP protocol=61 and static payload. MAC addresses are matching MAC\
| ... | addresses of the TG node interfaces.
| ... | *[Ref] Applicable standard specifications:* RFC2544.

*** Variables ***
| @{plugins_to_enable}= | dpdk_plugin.so
| ${osi_layer}= | L2
| ${nic_name}= | Intel-X710
| ${overhead}= | ${0}
# Traffic profile:
| ${traffic_profile}= | trex-sl-3n-ethip4-ip4src254

*** Keywords ***
| Local Template
| | [Documentation]
| | ... | [Cfg] Each DUT runs L2BD switching config and uses ${phy_cores}\
| | ... | physical core(s) for worker threads.
| | ... | [Ver] Measure NDR and PDR values using MLRsearch algorithm.\
| | ...
| | ... | *Arguments:*
| | ... | - frame_size - Framesize in Bytes in integer or string (IMIX_v4_1).
| | ... | Type: integer, string
| | ... | - phy_cores - Number of physical cores. Type: integer
| | ... | - rxq - Number of RX queues, default value: ${None}. Type: integer
| | ...
| | [Arguments] | ${frame_size} | ${phy_cores} | ${rxq}=${None}
| | ...
| | Set Test Variable | \${frame_size}
| | ...
| | Given Add worker threads and rxqueues to all DUTs | ${phy_cores} | ${rxq}
| | And Add PCI devices to all DUTs
| | And Set Max Rate And Jumbo And Handle Multi Seg
| | And Apply startup configuration on all VPP DUTs
| | And Initialize L2 bridge domain in circular topology
| | Then Find NDR and PDR intervals using optimized search

*** Test Cases ***
| tc01-64B-1c-eth-l2bdbasemaclrn-ndrpdr
| | [Tags] | 64B | 1C
| | frame_size=${64} | phy_cores=${1}

| tc02-64B-2c-eth-l2bdbasemaclrn-ndrpdr
| | [Tags] | 64B | 2C
| | frame_size=${64} | phy_cores=${2}

| tc03-64B-4c-eth-l2bdbasemaclrn-ndrpdr