draft
authorimarom <[email protected]>
Tue, 1 Sep 2015 12:14:27 +0000 (15:14 +0300)
committerimarom <[email protected]>
Tue, 1 Sep 2015 12:14:27 +0000 (15:14 +0300)
scripts/automation/trex_control_plane/client_utils/jsonrpc_client.py
scripts/automation/trex_control_plane/console/trex_status.py
src/rpc-server/commands/trex_rpc_cmd_stream.cpp
src/stateless/trex_stateless_api.h
src/stateless/trex_stream.cpp
src/stateless/trex_stream_api.h

index 48ff231..054dc1a 100644 (file)
@@ -12,7 +12,7 @@ class bcolors:
     GREEN = '\033[32m'
     YELLOW = '\033[93m'
     RED = '\033[31m'
-    MAGENTA = '\033[95m'
+    MAGENTA = '\033[35m'
     ENDC = '\033[0m'
     BOLD = '\033[1m'
     UNDERLINE = '\033[4m'
index 8ee669b..54853ea 100644 (file)
@@ -126,7 +126,7 @@ class TrexStatus():
         self.max_x = self.stdscr.getmaxyx()[1]
 
         # create cls panel
-        self.main_panel = TrexStatusPanel(int(self.max_y * 0.8), self.max_x / 2, 0,0, "Trex Activity:")
+        self.main_panel = TrexStatusPanel(int(self.max_y * 0.8), self.max_x / 2, 0,0, "Trex Ports:")
 
         self.general_panel = TrexStatusPanel(int(self.max_y * 0.6), self.max_x / 2, 0, self.max_x /2, "General Statistics:")
 
index 25dee50..57fa23d 100644 (file)
@@ -41,14 +41,17 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
     const Json::Value &mode = parse_object(section, "mode", result);
     string type = parse_string(mode, "type", result);
 
+    /* allocate a new stream based on the type */
     TrexStream *stream = allocate_new_stream(section, result);
 
-    /* create a new steram and populate it */
-   
+    /* some fields */
+    stream->m_enabled         = parse_bool(section, "enabled", result);
+    stream->m_self_start      = parse_bool(section, "self_start", result);
+
+    /* inter stream gap */
     stream->m_isg_usec  = parse_double(section, "Is", result);
 
     stream->m_next_stream_id = parse_int(section, "next_stream_id", result);
-    stream->m_loop_count     = parse_int(section, "loop_count", result);
 
     const Json::Value &pkt = parse_array(section, "packet", result);
 
@@ -95,19 +98,19 @@ TrexRpcCmdAddStream::allocate_new_stream(const Json::Value &section, Json::Value
 
     } else if (type == "single_burst") {
 
-        uint32_t pps = parse_int(mode, "pps", result);
-        uint32_t packets = parse_int(type, "packets", result);
+        uint32_t total_pkts      = parse_int(mode, "total_pkts", result);
+        uint32_t pps             = parse_int(mode, "pps", result);
 
-        stream = new TrexStreamSingleBurst(port_id, stream_id, pps, packets);
+        stream = new TrexStreamBurst(port_id, stream_id, total_pkts, pps);
 
     } else if (type == "multi_burst") {
 
-        uint32_t  pps           = parse_int(mode, "pps", result);
-        double    ibg_usec      = parse_double(mode, "ibg", result);
-        uint32_t  num_bursts    = parse_int(mode, "number_of_bursts", result);
-        uint32_t  pkt_per_burst = parse_int(mode, "pkt_per_burst", result);
+        uint32_t  pps              = parse_int(mode, "pps", result);
+        double    ibg_usec         = parse_double(mode, "ibg", result);
+        uint32_t  num_bursts       = parse_int(mode, "number_of_bursts", result);
+        uint32_t  pkts_per_burst   = parse_int(mode, "pkts_per_burst", result);
 
-        stream = new TrexStreamMultiBurst(port_id, stream_id, pps, ibg_usec, num_bursts, pkt_per_burst);
+        stream = new TrexStreamMultiBurst(port_id, stream_id, pkts_per_burst, pps, num_bursts, ibg_usec);
         
 
     } else {
index 50cc394..6406a94 100644 (file)
@@ -29,7 +29,7 @@ limitations under the License.
 
 /**
  * generic exception for errors
- * 
+ * TODO: move this to a better place
  */
 class TrexException : public std::runtime_error 
 {
@@ -42,7 +42,7 @@ public:
 };
 
 /**
- * 
+ * describes a stateless port
  * 
  * @author imarom (31-Aug-15)
  */
@@ -52,12 +52,15 @@ public:
     TrexStatelessPort(uint8_t port_id) : m_port_id(port_id) {
     }
 
+    /**
+     * access the stream table
+     * 
+     */
     TrexStreamTable *get_stream_table() {
         return &m_stream_table;
     }
 
 private:
-    /* a stream table per port */
     TrexStreamTable  m_stream_table;
     uint8_t          m_port_id;
 };
index 1a78ab3..5bc9421 100644 (file)
@@ -27,11 +27,10 @@ limitations under the License.
 TrexStream::TrexStream(uint8_t port_id, uint32_t stream_id) : m_port_id(port_id), m_stream_id(stream_id) {
 
     /* default values */
-    m_isg_usec = 0;
-    m_next_stream_id = -1;
-    m_loop_count = 0;
-    m_enable = false;
-    m_start = false;
+    m_isg_usec        = 0;
+    m_next_stream_id  = -1;
+    m_enabled    = false;
+    m_self_start = false;
 
     m_pkt = NULL;
     m_pkt_len = 0;
index 7ae25c6..bae8286 100644 (file)
@@ -39,6 +39,7 @@ 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;
 
@@ -51,11 +52,10 @@ private:
     /* config fields */
     double        m_isg_usec;
     uint32_t      m_next_stream_id;
-    uint32_t      m_loop_count;
 
     /* indicators */
-    bool          m_enable;
-    bool          m_start;
+    bool          m_enabled;
+    bool          m_self_start;
     
     /* pkt */
     uint8_t      *m_pkt;
@@ -90,35 +90,37 @@ protected:
  * single burst
  * 
  */
-class TrexStreamSingleBurst : public TrexStream {
+class TrexStreamBurst : public TrexStream {
 public:
-    TrexStreamSingleBurst(uint8_t port_id, uint32_t stream_id, uint32_t packets, uint32_t pps) : TrexStream(port_id, stream_id), m_pps(pps), m_packets(packets) {
+    TrexStreamBurst(uint8_t port_id, uint32_t stream_id, uint32_t total_pkts, uint32_t pps) : 
+        TrexStream(port_id, stream_id),
+        m_total_pkts(total_pkts),
+        m_pps(pps) {
     }
+
 protected:
-    uint32_t m_pps;
-    uint32_t m_packets;
-    
+    uint32_t   m_total_pkts;
+    uint32_t   m_pps;
 };
 
 /**
  * multi burst
  * 
  */
-class TrexStreamMultiBurst : public TrexStream {
+class TrexStreamMultiBurst : public TrexStreamBurst {
 public:
-    TrexStreamMultiBurst(uint8_t port_id,
+    TrexStreamMultiBurst(uint8_t  port_id,
                          uint32_t stream_id,
-                         uint32_t pps,
-                         double   ibg_usec,
                          uint32_t pkts_per_burst,
-                         uint32_t num_bursts) : TrexStream(port_id, stream_id), m_pps(pps), m_ibg_usec(ibg_usec), m_num_bursts(num_bursts), m_pkts_per_burst(pkts_per_burst) {
+                         uint32_t 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_pps;
-    double   m_ibg_usec;
     uint32_t m_num_bursts;
-    uint32_t m_pkts_per_burst;
+    double   m_ibg_usec;
+    
 };
 
 /**