From 11be4868b77d49174afafcd515d1037325796d04 Mon Sep 17 00:00:00 2001
From: Christian Trautman <ctrautma@redhat.com>
Date: Thu, 17 May 2018 17:46:29 -0400
Subject: Xena_Flow_Fix: Fixes multistream of greater than 64k values

Adds calculations to deal with values greater than 64k by doing
a square root of the multistream value and using two mods
to create the closet possible value that will work within the
current implementation of multistream in VSPerf.

JIRA: VSPERF-575

Change-Id: I9dab4bbac094a394a11ed74fe2cd88fbe7079fc7
Signed-off-by: Christian Trautman <ctrautma@redhat.com>
---
 tools/pkt_gen/xena/json/xena_json.py | 106 +++++++++++++++++++++++++++--------
 1 file changed, 82 insertions(+), 24 deletions(-)

(limited to 'tools/pkt_gen/xena/json')

diff --git a/tools/pkt_gen/xena/json/xena_json.py b/tools/pkt_gen/xena/json/xena_json.py
index df2aa55f..e56b4125 100644
--- a/tools/pkt_gen/xena/json/xena_json.py
+++ b/tools/pkt_gen/xena/json/xena_json.py
@@ -26,6 +26,7 @@ Xena JSON module
 from collections import OrderedDict
 import locale
 import logging
+import math
 import os
 
 from tools.pkt_gen.xena.json import json_utilities
@@ -71,30 +72,87 @@ class XenaJSON(object):
             3: ('Dest IP Addr', 'Src IP Addr'),
             4: ('Dest Port', 'Src Port')
         }
-        segments = [
-            {
-                "Offset": 0,
-                "Mask": "//8=",  # mask of 255/255
-                "Action": "INC",
-                "StartValue": 0,
-                "StopValue": stop_value,
-                "StepValue": 1,
-                "RepeatCount": 1,
-                "SegmentId": seg_uuid,
-                "FieldName": field_name[int(layer)][0]
-            },
-            {
-                "Offset": 0,
-                "Mask": "//8=",  # mask of 255/255
-                "Action": "INC",
-                "StartValue": 0,
-                "StopValue": stop_value,
-                "StepValue": 1,
-                "RepeatCount": 1,
-                "SegmentId": seg_uuid,
-                "FieldName": field_name[int(layer)][1]
-            }
-        ]
+
+        if stop_value > 4294836225:
+            _LOGGER.debug('Flow mods exceeds highest value, changing to 4294836225')
+            stop_value = 4294836225
+
+        if stop_value <= 65535 or layer == 4:
+            segments = [
+                {
+                    "Offset": 0 if layer == 4 else 2,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": 1,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][0]
+                },
+                {
+                    "Offset": 0 if layer == 4 else 2,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": 1,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][1]
+                }
+            ]
+        else:
+            stop_value = int(math.sqrt(stop_value))
+            _LOGGER.debug('Flow count modified to %s', stop_value * stop_value)
+            segments = [
+                {
+                    "Offset": 0 if layer == 3 else 1,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": stop_value,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][0]
+                },
+                {
+                    "Offset": 2 if layer == 3 else 3,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": 1,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][0]
+                },
+                {
+                    "Offset": 0 if layer == 3 else 1,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": stop_value,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][1]
+                },
+                {
+                    "Offset": 2 if layer == 3 else 3,
+                    "Mask": "//8=",  # mask of 255/255
+                    "Action": "INC",
+                    "StartValue": 0,
+                    "StopValue": stop_value - 1,
+                    "StepValue": 1,
+                    "RepeatCount": 1,
+                    "SegmentId": seg_uuid,
+                    "FieldName": field_name[int(layer)][1]
+                }
+            ]
+
+
 
         self.json_data['StreamProfileHandler']['EntityList'][entity][
             'StreamConfig']['HwModifiers'] = (segments)
-- 
cgit