[NFVBENCH-96] Enhance utils to get NIC PCI addresses with slot/port
[nfvbench.git] / nfvbench / nfvbench.py
index 90b16d4..e0b5786 100644 (file)
@@ -105,7 +105,7 @@ class NFVBench(object):
                         new_frame_sizes.append(frame_size)
                 except ValueError:
                     new_frame_sizes.append(frame_size)
-            self.config.frame_sizes = tuple(new_frame_sizes)
+            self.config.actual_frame_sizes = tuple(new_frame_sizes)
             result = {
                 "date": datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
                 "nfvbench_version": __version__,
@@ -177,6 +177,7 @@ class NFVBench(object):
 
         self.config.duration_sec = float(self.config.duration_sec)
         self.config.interval_sec = float(self.config.interval_sec)
+        self.config.pause_sec = float(self.config.pause_sec)
 
         # Get traffic generator profile config
         if not self.config.generator_profile:
@@ -434,6 +435,11 @@ def parse_opts_from_cli():
                         action='store',
                         help='Custom label for performance records')
 
+    parser.add_argument('--l2-loopback', '--l2loopback', dest='l2_loopback',
+                        action='store',
+                        metavar='<vlan>',
+                        help='Port to port or port to switch to port L2 loopback with VLAN id')
+
     opts, unknown_opts = parser.parse_known_args()
     return opts, unknown_opts
 
@@ -569,8 +575,22 @@ def main():
         if opts.no_int_config:
             config.no_int_config = opts.no_int_config
 
+        # port to port loopback (direct or through switch)
+        if opts.l2_loopback:
+            config.l2_loopback = True
+            if config.service_chain != ChainType.EXT:
+                LOG.info('Changing service chain type to EXT')
+                config.service_chain = ChainType.EXT
+            if not config.no_arp:
+                LOG.info('Disabling ARP')
+                config.no_arp = True
+            config.vlans = [int(opts.l2_loopback), int(opts.l2_loopback)]
+            # disable any form of interface config since we loop at the switch level
+            config.no_int_config = True
+            LOG.info('Running L2 loopback: using EXT chain/no ARP')
+
         if opts.use_sriov_middle_net:
-            if (not config.sriov) or (not config.service_chain == ChainType.PVVP):
+            if (not config.sriov) or (config.service_chain != ChainType.PVVP):
                 raise Exception("--use-sriov-middle-net is only valid for PVVP with SRIOV")
             config.use_sriov_middle_net = True