From 74b648a86c16933680b03a736afe3f0305b4f6d2 Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 8 Oct 2015 08:34:43 +0200 Subject: some file renaming --- src/stateless/cp/trex_stateless.cpp | 2 +- src/stateless/cp/trex_stateless.h | 142 +++++++++++++++++++++ src/stateless/cp/trex_stateless_api.h | 142 --------------------- src/stateless/cp/trex_stateless_port.cpp | 2 +- src/stateless/cp/trex_stateless_port.h | 2 +- src/stateless/cp/trex_stream.cpp | 2 +- src/stateless/cp/trex_stream.h | 209 +++++++++++++++++++++++++++++++ src/stateless/cp/trex_stream_api.h | 209 ------------------------------- 8 files changed, 355 insertions(+), 355 deletions(-) create mode 100644 src/stateless/cp/trex_stateless.h delete mode 100644 src/stateless/cp/trex_stateless_api.h create mode 100644 src/stateless/cp/trex_stream.h delete mode 100644 src/stateless/cp/trex_stream_api.h (limited to 'src/stateless') diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp index 0b7947a0..92f54bc4 100644 --- a/src/stateless/cp/trex_stateless.cpp +++ b/src/stateless/cp/trex_stateless.cpp @@ -18,7 +18,7 @@ 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 using namespace std; diff --git a/src/stateless/cp/trex_stateless.h b/src/stateless/cp/trex_stateless.h new file mode 100644 index 00000000..74e88846 --- /dev/null +++ b/src/stateless/cp/trex_stateless.h @@ -0,0 +1,142 @@ +/* + 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 __TREX_STATELESS_H__ +#define __TREX_STATELESS_H__ + +#include +#include +#include + +#include + +/** + * generic exception for errors + * TODO: move this to a better place + */ +class TrexException : public std::runtime_error +{ +public: + TrexException() : std::runtime_error("") { + + } + TrexException(const std::string &what) : std::runtime_error(what) { + } +}; + +class TrexStatelessPort; + +/** + * unified stats + * + * @author imarom (06-Oct-15) + */ +class TrexStatelessStats { +public: + TrexStatelessStats() { + m_stats = {0}; + } + + struct { + double m_cpu_util; + + double m_tx_bps; + double m_rx_bps; + + double m_tx_pps; + double m_rx_pps; + + uint64_t m_total_tx_pkts; + uint64_t m_total_rx_pkts; + + uint64_t m_total_tx_bytes; + uint64_t m_total_rx_bytes; + + uint64_t m_tx_rx_errors; + } m_stats; +}; + +/** + * defines the T-Rex stateless operation mode + * + */ +class TrexStateless { +public: + + /** + * configure the stateless object singelton + * reconfiguration is not allowed + * an exception will be thrown + */ + static void configure(uint8_t port_count); + + /** + * singleton public get instance + * + */ + static TrexStateless& get_instance() { + TrexStateless& instance = get_instance_internal(); + + if (!instance.m_is_configured) { + throw TrexException("object is not configured"); + } + + return instance; + } + + TrexStatelessPort * get_port_by_id(uint8_t port_id); + uint8_t get_port_count(); + + /** + * update all the stats (deep update) + * (include all the ports and global stats) + * + */ + void update_stats(); + + /** + * fetch all the stats + * + */ + void encode_stats(Json::Value &global); + + +protected: + TrexStateless(); + ~TrexStateless(); + + static TrexStateless& get_instance_internal () { + static TrexStateless instance; + return instance; + } + + /* c++ 2011 style singleton */ + TrexStateless(TrexStateless const&) = delete; + void operator=(TrexStateless const&) = delete; + + bool m_is_configured; + TrexStatelessPort **m_ports; + uint8_t m_port_count; + + TrexStatelessStats m_stats; +}; + +#endif /* __TREX_STATELESS_H__ */ + diff --git a/src/stateless/cp/trex_stateless_api.h b/src/stateless/cp/trex_stateless_api.h deleted file mode 100644 index e2bf4e1c..00000000 --- a/src/stateless/cp/trex_stateless_api.h +++ /dev/null @@ -1,142 +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 __TREX_STATELESS_API_H__ -#define __TREX_STATELESS_API_H__ - -#include -#include -#include - -#include - -/** - * generic exception for errors - * TODO: move this to a better place - */ -class TrexException : public std::runtime_error -{ -public: - TrexException() : std::runtime_error("") { - - } - TrexException(const std::string &what) : std::runtime_error(what) { - } -}; - -class TrexStatelessPort; - -/** - * unified stats - * - * @author imarom (06-Oct-15) - */ -class TrexStatelessStats { -public: - TrexStatelessStats() { - m_stats = {0}; - } - - struct { - double m_cpu_util; - - double m_tx_bps; - double m_rx_bps; - - double m_tx_pps; - double m_rx_pps; - - uint64_t m_total_tx_pkts; - uint64_t m_total_rx_pkts; - - uint64_t m_total_tx_bytes; - uint64_t m_total_rx_bytes; - - uint64_t m_tx_rx_errors; - } m_stats; -}; - -/** - * defines the T-Rex stateless operation mode - * - */ -class TrexStateless { -public: - - /** - * configure the stateless object singelton - * reconfiguration is not allowed - * an exception will be thrown - */ - static void configure(uint8_t port_count); - - /** - * singleton public get instance - * - */ - static TrexStateless& get_instance() { - TrexStateless& instance = get_instance_internal(); - - if (!instance.m_is_configured) { - throw TrexException("object is not configured"); - } - - return instance; - } - - TrexStatelessPort * get_port_by_id(uint8_t port_id); - uint8_t get_port_count(); - - /** - * update all the stats (deep update) - * (include all the ports and global stats) - * - */ - void update_stats(); - - /** - * fetch all the stats - * - */ - void encode_stats(Json::Value &global); - - -protected: - TrexStateless(); - ~TrexStateless(); - - static TrexStateless& get_instance_internal () { - static TrexStateless instance; - return instance; - } - - /* c++ 2011 style singleton */ - TrexStateless(TrexStateless const&) = delete; - void operator=(TrexStateless const&) = delete; - - bool m_is_configured; - TrexStatelessPort **m_ports; - uint8_t m_port_count; - - TrexStatelessStats m_stats; -}; - -#endif /* __TREX_STATELESS_API_H__ */ - diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 7322ef8a..031efb58 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -18,7 +18,7 @@ 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 diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index ea98ddae..a19fd981 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -21,7 +21,7 @@ limitations under the License. #ifndef __TREX_STATELESS_PORT_H__ #define __TREX_STATELESS_PORT_H__ -#include +#include /** * TRex stateless port stats diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp index 8bf04748..182036f1 100644 --- a/src/stateless/cp/trex_stream.cpp +++ b/src/stateless/cp/trex_stream.cpp @@ -18,7 +18,7 @@ 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 /************************************** diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h new file mode 100644 index 00000000..f5bc96ef --- /dev/null +++ b/src/stateless/cp/trex_stream.h @@ -0,0 +1,209 @@ +/* + 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 __TREX_STREAM_H__ +#define __TREX_STREAM_H__ + +#include +#include +#include +#include + +#include + +#include + +class TrexRpcCmdAddStream; + +/** + * Stateless Stream + * + */ +class TrexStream { + /* provide the RPC parser a way to access private fields */ + friend class TrexRpcCmdAddStream; + friend class TrexRpcCmdGetStream; + friend class TrexStreamTable; + +public: + TrexStream(uint8_t port_id, uint32_t stream_id); + virtual ~TrexStream() = 0; + + /* defines the min max per packet supported */ + static const uint32_t MIN_PKT_SIZE_BYTES = 1; + static const uint32_t MAX_PKT_SIZE_BYTES = 9000; + + /* provides storage for the stream json*/ + void store_stream_json(const Json::Value &stream_json); + + /* access the stream json */ + const Json::Value & get_stream_json(); + +protected: + /* basic */ + uint8_t m_port_id; + uint32_t m_stream_id; + + + /* config fields */ + double m_isg_usec; + int m_next_stream_id; + + /* indicators */ + bool m_enabled; + bool m_self_start; + + /* pkt */ + struct { + uint8_t *binary; + uint16_t len; + std::string meta; + } m_pkt; + + /* VM */ + StreamVm m_vm; + + /* RX check */ + struct { + bool m_enable; + bool m_seq_enabled; + bool m_latency; + uint32_t m_stream_id; + + } m_rx_check; + + + /* original template provided by requester */ + Json::Value m_stream_json; +}; + +/** + * continuous stream + * + */ +class TrexStreamContinuous : public TrexStream { +public: + TrexStreamContinuous(uint8_t port_id, uint32_t stream_id, double pps) : TrexStream(port_id, stream_id), m_pps(pps) { + } + + double get_pps() { + return m_pps; + } + +protected: + double m_pps; +}; + +/** + * single burst + * + */ +class TrexStreamBurst : public TrexStream { +public: + TrexStreamBurst(uint8_t port_id, uint32_t stream_id, uint32_t total_pkts, double pps) : + TrexStream(port_id, stream_id), + m_total_pkts(total_pkts), + m_pps(pps) { + } + +protected: + uint32_t m_total_pkts; + double m_pps; +}; + +/** + * multi burst + * + */ +class TrexStreamMultiBurst : public TrexStreamBurst { +public: + TrexStreamMultiBurst(uint8_t port_id, + uint32_t stream_id, + uint32_t pkts_per_burst, + double pps, + uint32_t num_bursts, + double ibg_usec) : TrexStreamBurst(port_id, stream_id, pkts_per_burst, pps), m_num_bursts(num_bursts), m_ibg_usec(ibg_usec) { + + } +protected: + uint32_t m_num_bursts; + double m_ibg_usec; + +}; + +/** + * holds all the streams + * + */ +class TrexStreamTable { +public: + + TrexStreamTable(); + ~TrexStreamTable(); + + /** + * add a stream + * if a previous one exists, the old one will be deleted + */ + void add_stream(TrexStream *stream); + + /** + * remove a stream + */ + void remove_stream(TrexStream *stream); + + /** + * remove all streams on the table + * memory will be deleted + */ + void remove_and_delete_all_streams(); + + /** + * fetch a stream if exists + * o.w NULL + * + */ + TrexStream * get_stream_by_id(uint32_t stream_id); + + /** + * populate a list with all the stream IDs + * + * @author imarom (06-Sep-15) + * + * @param stream_list + */ + void get_stream_list(std::vector &stream_list); + + /** + * get the table size + * + */ + int size(); + +private: + /** + * holds all the stream in a hash table by stream id + * + */ + std::unordered_map m_stream_table; +}; + +#endif /* __TREX_STREAM_H__ */ + diff --git a/src/stateless/cp/trex_stream_api.h b/src/stateless/cp/trex_stream_api.h deleted file mode 100644 index d3c0fb29..00000000 --- a/src/stateless/cp/trex_stream_api.h +++ /dev/null @@ -1,209 +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 __TREX_STREAM_API_H__ -#define __TREX_STREAM_API_H__ - -#include -#include -#include -#include - -#include - -#include - -class TrexRpcCmdAddStream; - -/** - * Stateless Stream - * - */ -class TrexStream { - /* provide the RPC parser a way to access private fields */ - friend class TrexRpcCmdAddStream; - friend class TrexRpcCmdGetStream; - friend class TrexStreamTable; - -public: - TrexStream(uint8_t port_id, uint32_t stream_id); - virtual ~TrexStream() = 0; - - /* defines the min max per packet supported */ - static const uint32_t MIN_PKT_SIZE_BYTES = 1; - static const uint32_t MAX_PKT_SIZE_BYTES = 9000; - - /* provides storage for the stream json*/ - void store_stream_json(const Json::Value &stream_json); - - /* access the stream json */ - const Json::Value & get_stream_json(); - -protected: - /* basic */ - uint8_t m_port_id; - uint32_t m_stream_id; - - - /* config fields */ - double m_isg_usec; - int m_next_stream_id; - - /* indicators */ - bool m_enabled; - bool m_self_start; - - /* pkt */ - struct { - uint8_t *binary; - uint16_t len; - std::string meta; - } m_pkt; - - /* VM */ - StreamVm m_vm; - - /* RX check */ - struct { - bool m_enable; - bool m_seq_enabled; - bool m_latency; - uint32_t m_stream_id; - - } m_rx_check; - - - /* original template provided by requester */ - Json::Value m_stream_json; -}; - -/** - * continuous stream - * - */ -class TrexStreamContinuous : public TrexStream { -public: - TrexStreamContinuous(uint8_t port_id, uint32_t stream_id, double pps) : TrexStream(port_id, stream_id), m_pps(pps) { - } - - double get_pps() { - return m_pps; - } - -protected: - double m_pps; -}; - -/** - * single burst - * - */ -class TrexStreamBurst : public TrexStream { -public: - TrexStreamBurst(uint8_t port_id, uint32_t stream_id, uint32_t total_pkts, double pps) : - TrexStream(port_id, stream_id), - m_total_pkts(total_pkts), - m_pps(pps) { - } - -protected: - uint32_t m_total_pkts; - double m_pps; -}; - -/** - * multi burst - * - */ -class TrexStreamMultiBurst : public TrexStreamBurst { -public: - TrexStreamMultiBurst(uint8_t port_id, - uint32_t stream_id, - uint32_t pkts_per_burst, - double pps, - uint32_t num_bursts, - double ibg_usec) : TrexStreamBurst(port_id, stream_id, pkts_per_burst, pps), m_num_bursts(num_bursts), m_ibg_usec(ibg_usec) { - - } -protected: - uint32_t m_num_bursts; - double m_ibg_usec; - -}; - -/** - * holds all the streams - * - */ -class TrexStreamTable { -public: - - TrexStreamTable(); - ~TrexStreamTable(); - - /** - * add a stream - * if a previous one exists, the old one will be deleted - */ - void add_stream(TrexStream *stream); - - /** - * remove a stream - */ - void remove_stream(TrexStream *stream); - - /** - * remove all streams on the table - * memory will be deleted - */ - void remove_and_delete_all_streams(); - - /** - * fetch a stream if exists - * o.w NULL - * - */ - TrexStream * get_stream_by_id(uint32_t stream_id); - - /** - * populate a list with all the stream IDs - * - * @author imarom (06-Sep-15) - * - * @param stream_list - */ - void get_stream_list(std::vector &stream_list); - - /** - * get the table size - * - */ - int size(); - -private: - /** - * holds all the stream in a hash table by stream id - * - */ - std::unordered_map m_stream_table; -}; - -#endif /* __TREX_STREAM_API_H__ */ - -- cgit