summaryrefslogtreecommitdiffstats
path: root/src/mock
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-25 09:54:45 -0500
committerimarom <imarom@cisco.com>2016-02-25 09:57:23 -0500
commitaaef3f95683bfa1574537c543e4ffc86afb0480f (patch)
tree01bf5d21786fb59d13338a75b644eb0fa9a5f20d /src/mock
parented7c04b5d7d5bb15aa13144e62caa786e73f7d05 (diff)
port attributes - promiscuous and etc.
Diffstat (limited to 'src/mock')
-rw-r--r--src/mock/rte_ethdev.h44
-rw-r--r--src/mock/trex_platform_api_mock.cpp54
-rw-r--r--src/mock/trex_rpc_server_mock.cpp191
3 files changed, 0 insertions, 289 deletions
diff --git a/src/mock/rte_ethdev.h b/src/mock/rte_ethdev.h
deleted file mode 100644
index 046d8366..00000000
--- a/src/mock/rte_ethdev.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Itay Marom
- Cisco Systems, Inc.
-*/
-
-/*
-Copyright (c) 2015-2015 Cisco Systems, Inc.
-
-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.
-*/
-#ifndef __MOCK_FILE_RTE_ETHDEV_H__
-#define __MOCK_FILE_RTE_ETHDEV_H__
-
-#include <string.h>
-
-struct rte_eth_stats {
- uint64_t obytes;
- uint64_t ibytes;
- uint64_t opackets;
- uint64_t ipackets;
-};
-
-static inline void
-rte_eth_stats_get(uint8_t port_id, struct rte_eth_stats *stats) {
- memset(stats, 0, sizeof(rte_eth_stats));
-}
-
-static inline uint16_t
-rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id,
- struct rte_mbuf **tx_pkts, uint16_t nb_pkts) {
- return (0);
-}
-
-#endif /* __MOCK_FILE_RTE_ETHDEV_H__ */
diff --git a/src/mock/trex_platform_api_mock.cpp b/src/mock/trex_platform_api_mock.cpp
deleted file mode 100644
index 7cacd96c..00000000
--- a/src/mock/trex_platform_api_mock.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Itay Marom
- Cisco Systems, Inc.
-*/
-
-/*
-Copyright (c) 2015-2015 Cisco Systems, Inc.
-
-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 <internal_api/trex_platform_api.h>
-
-void
-TrexMockPlatformApi::get_global_stats(TrexPlatformGlobalStats &stats) const {
-
- stats.m_stats.m_cpu_util = 0;
-
- stats.m_stats.m_tx_bps = 0;
- stats.m_stats.m_tx_pps = 0;
- stats.m_stats.m_total_tx_pkts = 0;
- stats.m_stats.m_total_tx_bytes = 0;
-
- stats.m_stats.m_rx_bps = 0;
- stats.m_stats.m_rx_pps = 0;
- stats.m_stats.m_total_rx_pkts = 0;
- stats.m_stats.m_total_rx_bytes = 0;
-}
-
-void
-TrexMockPlatformApi::get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const {
-
-}
-
-uint8_t
-TrexMockPlatformApi::get_dp_core_count() const {
- return (1);
-}
-
-void
-TrexMockPlatformApi::port_id_to_cores(uint8_t port_id, std::vector<std::pair<uint8_t, uint8_t>> &cores_id_list) const {
- cores_id_list.push_back(std::make_pair(0, 0));
-}
-
diff --git a/src/mock/trex_rpc_server_mock.cpp b/src/mock/trex_rpc_server_mock.cpp
deleted file mode 100644
index ecfa308d..00000000
--- a/src/mock/trex_rpc_server_mock.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- Itay Marom
- Cisco Systems, Inc.
-*/
-
-/*
-Copyright (c) 2015-2015 Cisco Systems, Inc.
-
-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 <trex_rpc_server_api.h>
-#include <trex_stateless.h>
-#include <trex_stateless_dp_core.h>
-
-#include <msg_manager.h>
-
-#include <iostream>
-#include <sstream>
-#include <unistd.h>
-#include <string.h>
-#include <zmq.h>
-#include <bp_sim.h>
-
-using namespace std;
-
-static TrexStateless *g_trex_stateless;
-static uint16_t g_rpc_port;
-
-static bool
-verify_tcp_port_is_free(uint16_t port) {
- void *m_context = zmq_ctx_new();
- void *m_socket = zmq_socket (m_context, ZMQ_REP);
- std::stringstream ss;
- ss << "tcp://*:";
- ss << port;
-
- int rc = zmq_bind (m_socket, ss.str().c_str());
-
- zmq_close(m_socket);
- zmq_term(m_context);
-
- return (rc == 0);
-}
-
-static uint16_t
-find_free_tcp_port(uint16_t start_port = 5050) {
- void *m_context = zmq_ctx_new();
- void *m_socket = zmq_socket (m_context, ZMQ_REP);
-
- uint16_t port = start_port;
- while (true) {
- std::stringstream ss;
- ss << "tcp://*:";
- ss << port;
-
- int rc = zmq_bind (m_socket, ss.str().c_str());
- if (rc == 0) {
- break;
- }
-
- port++;
- }
-
- zmq_close(m_socket);
- zmq_term(m_context);
-
- return port;
-}
-
-uint16_t gtest_get_mock_server_port() {
- return g_rpc_port;
-}
-
-/**
- * on simulation this is not rebuild every version
- * (improved stub)
- *
- */
-extern "C" const char * get_build_date(void){
- return (__DATE__);
-}
-
-extern "C" const char * get_build_time(void){
- return (__TIME__ );
-}
-
-int gtest_main(int argc, char **argv);
-
-static bool parse_uint16(const string arg, uint16_t &port) {
- stringstream ss(arg);
-
- bool x = (ss >> port);
-
- return (x);
-}
-
-static void
-run_dummy_core() {
- //TODO: connect this to the scheduler
-
- //CFlowGenList fl;
- //fl.Create();
- //CFlowGenListPerThread *lp = new CFlowGenListPerThread();
- //lp->Create(0, 0, NULL, 0);
- //TrexStatelessDpCore dummy_core(0, lp);
- //lp->start_stateless_daemon();
-}
-
-int main(int argc, char *argv[]) {
- bool is_gtest = false;
-
- time_init();
- CGlobalInfo::m_socket.Create(0);
-
- CGlobalInfo::init_pools(1000);
- assert( CMsgIns::Ins()->Create(1));
-
- std::thread *m_thread = new std::thread(run_dummy_core);
- (void)m_thread;
-
- // gtest ?
- if (argc > 1) {
- string arg = string(argv[1]);
-
- if (arg == "--ut") {
- g_rpc_port = find_free_tcp_port();
- is_gtest = true;
- } else if (parse_uint16(arg, g_rpc_port)) {
- bool rc = verify_tcp_port_is_free(g_rpc_port);
- if (!rc) {
- cout << "port " << g_rpc_port << " is not available to use\n";
- exit(-1);
- }
- } else {
-
- cout << "\n[Usage] " << argv[0] << ": " << " [--ut] or [port number < 65535]\n\n";
- exit(-1);
- }
-
- } else {
- g_rpc_port = find_free_tcp_port();
- }
-
- /* configure the stateless object with 4 ports */
- TrexStatelessCfg cfg;
-
- TrexRpcServerConfig rpc_req_resp_cfg(TrexRpcServerConfig::RPC_PROT_TCP, g_rpc_port);
- //TrexRpcServerConfig rpc_async_cfg(TrexRpcServerConfig::RPC_PROT_TCP, 5051);
-
- cfg.m_port_count = 4;
- cfg.m_rpc_req_resp_cfg = &rpc_req_resp_cfg;
- cfg.m_rpc_async_cfg = NULL;
- cfg.m_rpc_server_verbose = (is_gtest ? false : true);
- cfg.m_platform_api = new TrexMockPlatformApi();
-
- g_trex_stateless = new TrexStateless(cfg);
-
- g_trex_stateless->launch_control_plane();
-
- /* gtest handling */
- if (is_gtest) {
- int rc = gtest_main(argc, argv);
- delete g_trex_stateless;
- g_trex_stateless = NULL;
- return rc;
- }
-
- cout << "\n-= Starting RPC Server Mock =-\n\n";
- cout << "Listening on tcp://localhost:" << g_rpc_port << " [ZMQ]\n\n";
-
- cout << "Server Started\n\n";
-
- while (true) {
- sleep(1);
- }
-
- delete g_trex_stateless;
- g_trex_stateless = NULL;
-}
-