Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 00/29] Update SPP Container tools
@ 2020-02-25 10:34 Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 01/29] tools/sppc: update options for assigning devices Yasufumi Ogawa
                   ` (28 more replies)
  0 siblings, 29 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

SPP Container tools do not work correctly with the latest SPP because
vdev or other options are updated.

This series of patches is for updating options of the tools for the
latest SPP. Vdevs other than vhost are added to supported devices by
this update. It also includes revising implementations, and updating
documentation.

Yasufumi Ogawa (29):
  tools/sppc: update options for assigning devices
  tools/sppc: update dev options of l2fwd
  tools/sppc: add container name option
  tools/sppc: update l2fwd app for name option
  tools/sppc: update dev options of l3fwd
  tools/sppc: update dev options of l3fwd-acl
  tools/sppc: update dev options of testpmd
  tools/sppc: update dev options of pktgen
  tools/sppc: update dev options of load-balancer
  tools/sppc: version checker for container DPDK ver
  tools/sppc: check DPDK ver in load-balancer
  tools/sppc: setup spp_pri opts in app_helper
  tools/sppc: define file prefix for SPP
  tools/sppc: update dev options of spp_primary
  tools/sppc: setup with docker opts in SPP pri
  tools/sppc: update calling setup_docker_opts()
  tools/sppc: update dev options of helloworld
  tools/sppc: update dev options of suricata
  tools/sppc: update dev options of spp_nfv
  tools/sppc: change to gen EAL opts with app name
  tools/sppc: remove nouse variable
  bin: remove sock files created by docker
  tools/sppc: skip checking rule file if dry run
  docs: revise examples in sppc
  docs: update versions in examples in sppc
  docs: update old example in spp_primary container
  tools/sppc: python3 support for sppc build tool
  docs: update app container help msg
  docs: update howto define app container guide

 bin/spp_pri.sh                             |   4 +-
 docs/guides/tools/sppc/app_launcher.rst    | 447 +++++++++++----------
 docs/guides/tools/sppc/build_img.rst       |  44 +-
 docs/guides/tools/sppc/getting_started.rst | 167 ++++----
 docs/guides/tools/sppc/howto_launcher.rst  | 210 ++++------
 docs/guides/tools/sppc/usecases.rst        | 119 +++---
 tools/sppc/app/helloworld.py               |  31 +-
 tools/sppc/app/l2fwd.py                    |  48 ++-
 tools/sppc/app/l3fwd-acl.py                |  76 ++--
 tools/sppc/app/l3fwd.py                    |  72 ++--
 tools/sppc/app/load-balancer.py            |  66 +--
 tools/sppc/app/pktgen.py                   |  44 +-
 tools/sppc/app/spp-nfv.py                  |  41 +-
 tools/sppc/app/spp-primary.py              |  87 +---
 tools/sppc/app/suricata.py                 |  20 +-
 tools/sppc/app/testpmd.py                  | 201 ++++-----
 tools/sppc/build/main.py                   |  81 ++--
 tools/sppc/lib/app_helper.py               | 384 +++++++++++++-----
 tools/sppc/lib/common.py                   |   3 +
 19 files changed, 1125 insertions(+), 1020 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 01/29] tools/sppc: update options for assigning devices
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 02/29] tools/sppc: update dev options of l2fwd Yasufumi Ogawa
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

For non SPP container apps, such as l2fwd or testpmd, it is connected
with SPP via vhost. This update is to add other PMDs to the interface.
There are two types of PMDs, vhost and memif, supported SPP container.

This patch includes two updates, one is for revising `-d` option, and
another is for adding `-v` of docker and `--vdev` of DPDK to make givin
devices directly.

Option `-d` for device ID is changed from getting a list of numbers to a
list of resouce UIDs because it should take not only vhost, but also
other types. Devices are described as a comma separated list of resource
UIDs. Full name of the option is also changed from `--dev-ids` to
`--dev-uids` because it is not just ID but res UIDs.

  $ python3 app/l2fwd.py -l 5-6 ... -d memif:0,memif:1 ...

If you use `-d`, app container launcher generates `-v` for docker and
`--vdev` for DPDK options with appropriate parameters for the container
app. However, you might want to customize the params sometimes. You can
assign devices directly with `-v` and `--vdev` in this case, but the
launcher does not validate the options.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/lib/app_helper.py | 262 +++++++++++++++++++++--------------
 1 file changed, 159 insertions(+), 103 deletions(-)

diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index 7ab1982..b5669da 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -3,10 +3,17 @@
 
 from . import common
 import os
+import secrets
 import sys
 
 
+# Supported vdev types of SPP Container.
+VDEV_TYPES = ['vhost', 'memif']
+
+
 def add_eal_args(parser, mem_size=1024, mem_channel=4):
+    """Add EAL args to app."""
+
     parser.add_argument(
         '-l', '--core-list',
         type=str,
@@ -20,6 +27,10 @@ def add_eal_args(parser, mem_size=1024, mem_channel=4):
         type=int,
         default=mem_size,
         help='Memory size (default is %s)' % mem_size)
+    parser.add_argument(
+        '--vdev',
+        nargs='*', type=str,
+        help='Virtual device in the format of DPDK')
     parser.add_argument(
         '--socket-mem',
         type=str,
@@ -44,6 +55,80 @@ def add_eal_args(parser, mem_size=1024, mem_channel=4):
     return parser
 
 
+def add_sppc_args(parser):
+    """Add args of SPP Container to app."""
+
+    parser.add_argument(
+        '--dist-name',
+        type=str,
+        default='ubuntu',
+        help="Name of Linux distribution")
+    parser.add_argument(
+        '--dist-ver',
+        type=str,
+        default='latest',
+        help="Version of Linux distribution")
+    parser.add_argument(
+        '--workdir',
+        type=str,
+        help="Path of directory in which the command is launched")
+    parser.add_argument(
+        '-ci', '--container-image',
+        type=str,
+        help="Name of container image")
+    parser.add_argument(
+        '-fg', '--foreground',
+        action='store_true',
+        help="Run container as foreground mode")
+    parser.add_argument(
+        '--dry-run',
+        action='store_true',
+        help="Only print matrix, do not run, and exit")
+    return parser
+
+
+def add_appc_args(parser):
+    """Add docker options and other common args."""
+
+    parser.add_argument(
+        '-d', '--dev-uids',
+        type=str,
+        help='Virtual devices of SPP in resource UID format')
+    parser.add_argument(
+        '-v', '--volume',
+        nargs='*', type=str,
+        help='Bind mount a volume (for docker)')
+    parser.add_argument(
+        '-nq', '--nof-queues',
+        type=int,
+        default=1,
+        help="Number of queues of virtio (default is 1)")
+    parser.add_argument(
+        '--no-privileged',
+        action='store_true',
+        help="Disable docker's privileged mode if it's needed")
+    return parser
+
+
+def is_valid_dev_uids(dev_uids):
+    """Return True if value of --dev-uids is valid.
+
+    dev_uids should be a list of resource UIDs separated with ',', for example
+    'vhost:0,vhost:1'.
+
+    If given port type is not supported in SPP Container, it returns False.
+    """
+
+    if dev_uids is None:
+        return False
+
+    for dev_uid in dev_uids.split(','):
+        if dev_uid.split(':')[0] not in VDEV_TYPES:
+            return False
+
+    return True
+
+
 def get_core_opt(args):
     # Check core_mask or core_list is defined.
     if args.core_mask is not None:
@@ -74,21 +159,22 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', hugedir=None):
         mem_opt['attr'], mem_opt['val'], '\\',
         '--proc-type', proc_type, '\\']
 
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
-    else:
-        dev_ids = dev_ids_to_list(args.dev_ids)
+    if args.dev_uids is not None:
+        dev_uids_list = args.dev_uids.split(',')
 
-    socks = []
-    for dev_id in dev_ids:
-        socks.append({
-            'host': '/tmp/sock%d' % dev_id,
-            'guest': '/var/run/usvhost%d' % dev_id})
+        socks = sock_files(dev_uids_list)
 
-    for i in range(len(dev_ids)):
-        eal_opts += [
-            '--vdev', 'virtio_user%d,queues=%d,path=%s' % (
-                dev_ids[i], args.nof_queues, socks[i]['guest']), '\\']
+        # Configure '--vdev' options
+        for i in range(len(dev_uids_list)):
+            dev_uid = dev_uids_list[i].split(':')
+            if dev_uid[0] == 'vhost':
+                eal_opts += [
+                    '--vdev', 'virtio_user{},queues={},path={}'.format(
+                        dev_uid[1], args.nof_queues, socks[i]['guest']), '\\']
+            elif dev_uid[0] == 'memif':  # Only 'slave' role is supported.
+                eal_opts += [
+                    '--vdev', 'net_memif{0},id={0},socket={1}'.format(
+                        dev_uid[1], socks[0]['guest']), '\\']
 
     if (args.pci_blacklist is not None) and (args.pci_whitelist is not None):
         common.error_exit("Cannot use both of '-b' and '-w' at once")
@@ -109,36 +195,6 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', hugedir=None):
     return eal_opts
 
 
-def add_sppc_args(parser):
-    parser.add_argument(
-        '--dist-name',
-        type=str,
-        default='ubuntu',
-        help="Name of Linux distribution")
-    parser.add_argument(
-        '--dist-ver',
-        type=str,
-        default='latest',
-        help="Version of Linux distribution")
-    parser.add_argument(
-        '--workdir',
-        type=str,
-        help="Path of directory in which the command is launched")
-    parser.add_argument(
-        '-ci', '--container-image',
-        type=str,
-        help="Name of container image")
-    parser.add_argument(
-        '-fg', '--foreground',
-        action='store_true',
-        help="Run container as foreground mode")
-    parser.add_argument(
-        '--dry-run',
-        action='store_true',
-        help="Only print matrix, do not run, and exit")
-    return parser
-
-
 def setup_docker_opts(args, container_image, sock_files, workdir=None):
     docker_opts = []
 
@@ -153,9 +209,10 @@ def setup_docker_opts(args, container_image, sock_files, workdir=None):
     if args.no_privileged is not True:
         docker_opts += ['--privileged', '\\']
 
-    for sock in sock_files:
-        docker_opts += [
-            '-v', '%s:%s' % (sock['host'], sock['guest']), '\\']
+    if sock_files is not None:
+        for sock in sock_files:
+            docker_opts += [
+                '-v', '%s:%s' % (sock['host'], sock['guest']), '\\']
 
     docker_opts += [
         '-v', '/dev/hugepages:/dev/hugepages', '\\',
@@ -164,73 +221,57 @@ def setup_docker_opts(args, container_image, sock_files, workdir=None):
     return docker_opts
 
 
-def add_appc_args(parser):
-    parser.add_argument(
-        '-d', '--dev-ids',
-        type=str,
-        help='two or more even vhost device IDs')
-    parser.add_argument(
-        '-nq', '--nof-queues',
-        type=int,
-        default=1,
-        help="Number of queues of virtio (default is 1)")
-    parser.add_argument(
-        '--no-privileged',
-        action='store_true',
-        help="Disable docker's privileged mode if it's needed")
-    return parser
-
-
-def uniq(dup_list):
-    """Remove duplicated elements in a list and return a unique list
-
-    Example: [1,1,2,2,3,3] #=> [1,2,3]
-    """
-
-    return list(set(dup_list))
-
-
-def dev_ids_to_list(dev_ids):
-    """Parse vhost device IDs and return as a list.
-
-    Example:
-    '1,3-5' #=> [1,3,4,5]
-    """
-
-    res = []
-    for dev_id_part in dev_ids.split(','):
-        if '-' in dev_id_part:
-            cl = dev_id_part.split('-')
-            res = res + list(range(int(cl[0]), int(cl[1])+1))
-        else:
-            res.append(int(dev_id_part))
-    return res
-
-
-def is_sufficient_dev_ids(dev_ids, port_mask):
-    """Check if ports can be reserved for dev_ids
+def is_sufficient_ports(args):
+    """Check if ports can be reserved.
 
-    Return true if the number of dev IDs equals or more than given ports.
-    'dev_ids' is a value of '-d' or '--dev-ids' such as '1,2'.
+    Return True if the number of vdevs is enogh for given ports.
     """
 
-    dev_ids_list = dev_ids_to_list(dev_ids)
-    if not ('0x' in port_mask):  # invalid port mask
+    # TODO(yasufum): It doesn't check if no given portmask and dev_uids, so
+    # add this additional check.
+    if (args.port_mask is None) or (args.dev_uids is None):
+        return False
+    elif not ('0x' in args.port_mask):  # invalid port mask
         return False
 
-    ports_in_binary = format(int(port_mask, 16), 'b')
-    if len(dev_ids_list) >= len(ports_in_binary):
+    dev_uids_list = args.dev_uids.split(',')
+
+    ports_in_binary = format(int(args.port_mask, 16), 'b')
+    if len(dev_uids_list) >= len(ports_in_binary):
         return True
     else:
         return False
 
 
-def sock_files(dev_ids_list):
+def sock_files(dev_uids_list):
+    """Return list of socket files on host and containers.
+
+    The name of socket files is defined with a conventional ones described
+    in DPDK doc, though you can use any name actually.
+
+    Here is an example of two vhost devices.
+        [vhost:0, vhost:1]
+        => [
+              {'host': '/tmp/sock0, 'guest': '/var/run/usvhost0'},
+              {'host': '/tmp/sock1, 'guest': '/var/run/usvhost1'}
+            ]
+    """
     socks = []
-    for dev_id in dev_ids_list:
-        socks.append({
-            'host': '/tmp/sock%d' % dev_id,
-            'guest': '/var/run/usvhost%d' % dev_id})
+    for dev_uid in dev_uids_list:
+        dev_uid = dev_uid.split(':')
+        if dev_uid[0] == 'vhost':
+            socks.append({
+                'host': '/tmp/sock{}'.format(dev_uid[1]),
+                'guest': '/var/run/usvhost{}'.format(dev_uid[1])})
+        elif dev_uid[0] == 'memif':
+            # Single sock file is enough for memif because it is just used for
+            # negotiation between master and slaves processes.
+            socks.append({
+                'host': '/tmp/spp-memif.sock',
+                'guest': '/var/run/spp-memif.sock'})
+            break
+        else:
+            break
     return socks
 
 
@@ -278,6 +319,21 @@ def cores_to_list(core_opt):
                 res.append(int(core_part))
     else:
         pass
-    res = uniq(res)
+    res = _uniq(res)
     res.sort()
     return res
+
+
+def gen_sppc_file_prefix(app_name):
+    """Generate a unique file prefix of DPDK for SPP Container app."""
+
+    return 'sppc-{}-{}'.format(app_name, secrets.token_hex(8))
+
+
+def _uniq(dup_list):
+    """Remove duplicated elements in a list and return a unique list.
+
+    Example: [1,1,2,2,3,3] #=> [1,2,3]
+    """
+
+    return list(set(dup_list))
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 02/29] tools/sppc: update dev options of l2fwd
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 01/29] tools/sppc: update options for assigning devices Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 03/29] tools/sppc: add container name option Yasufumi Ogawa
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of l2fwd container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l2fwd.py | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index a658d6c..1ddb6a9 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -45,12 +45,17 @@ def main():
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
 
     # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
+
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
@@ -64,24 +69,25 @@ def main():
         exit()
 
     # Setup l2fwd command run on container.
-    cmd_path = '%s/examples/l2fwd/%s/l2fwd' % (
+    cmd_path = '{}/examples/l2fwd/{}/l2fwd'.format(
         env.RTE_SDK, env.RTE_TARGET)
 
     l2fwd_cmd = [cmd_path, '\\']
 
-    file_prefix = 'spp-l2fwd-container%d' % dev_ids_list[0]
+    file_prefix = app_helper.gen_sppc_file_prefix('l2fwd')
+
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     l2fwd_opts = ['-p', args.port_mask, '\\']
 
-    # Parse vhost device IDs and Check the number of devices is
-    # sufficient for port mask.
-    if app_helper.is_sufficient_dev_ids(
-            args.dev_ids, args.port_mask) is not True:
-        print("Error: Cannot reserve ports '%s (= 0b%s)' on '%s'." % (
+    # Check given number of ports is enough for portmask.
+    if (args.port_mask is None) or (args.dev_uids is None):
+        pass
+    elif app_helper.is_sufficient_ports(args) is not True:
+        print("Error: Not enough ports, {} devs for '{}(=0b{})'.".format(
+            len(args.dev_uids.split(',')),
             args.port_mask,
-            format(int(args.port_mask, 16), 'b'),
-            args.dev_ids))
+            format(int(args.port_mask, 16), 'b')))
         exit()
 
     cmds = docker_cmd + docker_opts + l2fwd_cmd + eal_opts + l2fwd_opts
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 03/29] tools/sppc: add container name option
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 01/29] tools/sppc: update options for assigning devices Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 02/29] tools/sppc: update dev options of l2fwd Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 04/29] tools/sppc: update l2fwd app for " Yasufumi Ogawa
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

To assign a name of container, add `--name` option for docker.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/lib/app_helper.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index b5669da..cc042e5 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -98,6 +98,10 @@ def add_appc_args(parser):
         '-v', '--volume',
         nargs='*', type=str,
         help='Bind mount a volume (for docker)')
+    parser.add_argument(
+        '--name',
+        type=str,
+        help='Name of container')
     parser.add_argument(
         '-nq', '--nof-queues',
         type=int,
@@ -206,6 +210,9 @@ def setup_docker_opts(args, container_image, sock_files, workdir=None):
     if workdir is not None:
         docker_opts += ['--workdir', workdir, '\\']
 
+    if args.name is not None:
+        docker_opts += ['--name', args.name, '\\']
+
     if args.no_privileged is not True:
         docker_opts += ['--privileged', '\\']
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 04/29] tools/sppc: update l2fwd app for name option
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (2 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 03/29] tools/sppc: add container name option Yasufumi Ogawa
@ 2020-02-25 10:34 ` " Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 05/29] tools/sppc: update dev options of l3fwd Yasufumi Ogawa
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

As `--name` option is added, update l2fwd app for the option. If a name
is given, it is used also for file prefix of DPDK.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l2fwd.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index 1ddb6a9..d6156a8 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -46,7 +46,7 @@ def main():
     if args.port_mask is None:
         common.error_exit('--port-mask')
 
-    # Setup for vhost devices with given device IDs.
+    # Setup devices with given device UIDs.
     dev_uids = None
     sock_files = None
     if args.dev_uids is not None:
@@ -69,25 +69,28 @@ def main():
         exit()
 
     # Setup l2fwd command run on container.
-    cmd_path = '{}/examples/l2fwd/{}/l2fwd'.format(
+    cmd_path = '{0:s}/examples/l2fwd/{1:s}/l2fwd'.format(
         env.RTE_SDK, env.RTE_TARGET)
 
     l2fwd_cmd = [cmd_path, '\\']
 
-    file_prefix = app_helper.gen_sppc_file_prefix('l2fwd')
-
+    # Setup EAL options.
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix('l2fwd')
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
+    # Setup l2fwd options.
     l2fwd_opts = ['-p', args.port_mask, '\\']
 
     # Check given number of ports is enough for portmask.
     if (args.port_mask is None) or (args.dev_uids is None):
         pass
     elif app_helper.is_sufficient_ports(args) is not True:
-        print("Error: Not enough ports, {} devs for '{}(=0b{})'.".format(
-            len(args.dev_uids.split(',')),
-            args.port_mask,
-            format(int(args.port_mask, 16), 'b')))
+        print("Error: Not enough ports, {0:d} devs for '{1:s}(=0b{2:s})'.".
+              format(len(args.dev_uids.split(',')), args.port_mask,
+                     format(int(args.port_mask, 16), 'b')))
         exit()
 
     cmds = docker_cmd + docker_opts + l2fwd_cmd + eal_opts + l2fwd_opts
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 05/29] tools/sppc: update dev options of l3fwd
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (3 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 04/29] tools/sppc: update l2fwd app for " Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 06/29] tools/sppc: update dev options of l3fwd-acl Yasufumi Ogawa
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of l3fwd container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l3fwd.py | 61 +++++++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 27 deletions(-)

diff --git a/tools/sppc/app/l3fwd.py b/tools/sppc/app/l3fwd.py
index 131eb66..356b281 100755
--- a/tools/sppc/app/l3fwd.py
+++ b/tools/sppc/app/l3fwd.py
@@ -81,7 +81,7 @@ def parse_args():
 
 
 def check_config_format(config_opt, nof_queues):
-    """Check if config format is valid
+    """Check if config format is valid.
 
     Config options is for Determining which queues from which ports
     are mapped to which cores.
@@ -121,8 +121,8 @@ def check_config_format(config_opt, nof_queues):
             i = i + 1
 
     if nof_tx_queues > nof_queues:
-        print('Error: %s=%d should be equal or less than %s=%d!' %
-              ('tx_queues', nof_tx_queues, 'nof_queues', nof_queues))
+        print('Error: {0:s}={1:d} should be equal or less than {2:s}={3:d}!'.
+              format('tx_queues', nof_tx_queues, 'nof_queues', nof_queues))
         print("\tnof_queues is defiend with '-nq' or '--nof-queues' option")
         return False
 
@@ -130,7 +130,7 @@ def check_config_format(config_opt, nof_queues):
 
 
 def check_jumbo_opt(enable_jumbo, max_pkt_len):
-    """Check if jumbo frame option is valid
+    """Check if jumbo frame option is valid.
 
     Jumbo frame is enabled with '--enable-jumbo' and max packet size is
     defined with '--max-pkt-len'.
@@ -143,8 +143,8 @@ def check_jumbo_opt(enable_jumbo, max_pkt_len):
 
     if max_pkt_len is not None:
         if (max_pkt_len < 64) or (max_pkt_len > 9600):
-            print('Error: --max-pkt-len %s should be %d-%d' % (
-                max_pkt_len, 64, 9600))
+            print('Error: --max-pkt-len {0:d} should be {1:d}-{2:d}'.
+                  format(max_pkt_len, 64, 9600))
             return False
 
     return True
@@ -161,7 +161,7 @@ def check_eth_dest(eth_dests):
 
     xx = '[0-9A-Fa-f][0-9A-Fa-f]'
     ptn = re.compile(
-        r'(\d+),(%s:%s:%s:%s:%s:%s)' % (xx, xx, xx, xx, xx, xx))
+            r'(\d+),({0:s}:{0:s}:{0:s}:{0:s}:{0:s}:{0:s}\Z)'.format(xx))
     for eth_dest in eth_dests:
         m = re.match(ptn, eth_dest[0])
         if m is None:
@@ -184,36 +184,43 @@ def main():
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
+
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
         args, container_image, sock_files)
 
-    # Parse vhost device IDs and Check the number of devices is
-    # sufficient for port mask.
-    if app_helper.is_sufficient_dev_ids(
-            args.dev_ids, args.port_mask) is not True:
-        print("Error: Cannot reserve ports '%s (= 0b%s)' on '%s'." % (
-            args.port_mask,
-            format(int(args.port_mask, 16), 'b'),
-            args.dev_ids))
+    # Check given number of ports is enough for portmask.
+    if (args.port_mask is None) or (args.dev_uids is None):
+        pass
+    elif app_helper.is_sufficient_ports(args) is not True:
+        print("Error: Not enough ports, {0:d} devs for '{1:s}(=0b{2:s})'.".
+              format(len(args.dev_uids.split(',')), args.port_mask,
+                     format(int(args.port_mask, 16), 'b')))
         exit()
 
     # Setup l3fwd command runs on container.
-    cmd_path = '%s/examples/l3fwd/%s/l3fwd' % (
+    cmd_path = '{0:s}/examples/l3fwd/{1:s}/l3fwd'.format(
         env.RTE_SDK, env.RTE_TARGET)
 
     l3fwd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    file_prefix = 'spp-l3fwd-container%d' % dev_ids_list[0]
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix('l3fwd')
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     # Setup l3fwd options.
@@ -222,10 +229,10 @@ def main():
     if args.config is None:
         common.error_exit('--config')
     elif check_config_format(args.config, args.nof_queues) is not True:
-        print('Invalid config: %s' % args.config)
+        print('Invalid config: {}'.format(args.config))
         exit()
     else:
-        l3fwd_opts += ['--config', '"%s"' % args.config, '\\']
+        l3fwd_opts += ['--config', '"{:s}"'.format(args.config), '\\']
 
     # '--parse-ptype' is optional on host, but not on container.
     if args.parse_ptype == 'ipv4' or args.parse_ptype == 'ipv6':
@@ -233,7 +240,7 @@ def main():
     else:
         ptype_valid = False
     if ptype_valid is False:
-        print('Error: invalid --parse-ptype %s' % args.parse_ptype)
+        print('Error: invalid --parse-ptype {}'.format(args.parse_ptype))
         exit()
     else:
         l3fwd_opts += ['--parse-ptype', args.parse_ptype, '\\']
@@ -266,11 +273,11 @@ def main():
         l3fwd_opts += ['-L', '\\']
     if (args.eth_dest is not None) and (eth_dest_opt_valid is True):
         for eth_dest in args.eth_dest:  # args.eth_dest is a double array
-            l3fwd_opts += ['--eth-dest %s' % eth_dest[0], '\\']
+            l3fwd_opts += ['--eth-dest {:s}'.format(eth_dest[0]), '\\']
     if (args.enable_jumbo is not None) and (jumbo_opt_valid is True):
         l3fwd_opts += ['--enable-jumbo', '\\']
         if args.max_pkt_len is not None:
-            l3fwd_opts += ['--max-pkt-len %d' % args.max_pkt_len, '\\']
+            l3fwd_opts += ['--max-pkt-len {:d}'.format(args.max_pkt_len), '\\']
     if args.no_numa is True:
         l3fwd_opts += ['--no-numa', '\\']
     if args.hash_entry_num is True:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 06/29] tools/sppc: update dev options of l3fwd-acl
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (4 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 05/29] tools/sppc: update dev options of l3fwd Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 07/29] tools/sppc: update dev options of testpmd Yasufumi Ogawa
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of l3fwd-acl container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l3fwd-acl.py | 59 +++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index d1e2178..46163f4 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -66,7 +66,7 @@ def parse_args():
 
 
 def check_config_format(config_opt, nof_queues):
-    """Check if config format is valid
+    """Check if config format is valid.
 
     Config options is for Determining which queues from which ports
     are mapped to which cores.
@@ -106,8 +106,8 @@ def check_config_format(config_opt, nof_queues):
             i = i + 1
 
     if nof_tx_queues > nof_queues:
-        print('Error: {}={} should be equal or less than {}={}!'.format(
-              'tx_queues', nof_tx_queues, 'nof_queues', nof_queues))
+        print('Error: {0:s}={1:d} should be equal or less than {2:s}={3:d}!'.
+              format('tx_queues', nof_tx_queues, 'nof_queues', nof_queues))
         print("\tnof_queues is defiend with '-nq' or '--nof-queues' option")
         return False
 
@@ -115,7 +115,7 @@ def check_config_format(config_opt, nof_queues):
 
 
 def check_jumbo_opt(enable_jumbo, max_pkt_len):
-    """Check if jumbo frame option is valid
+    """Check if jumbo frame option is valid.
 
     Jumbo frame is enabled with '--enable-jumbo' and max packet size is
     defined with '--max-pkt-len'.
@@ -128,8 +128,8 @@ def check_jumbo_opt(enable_jumbo, max_pkt_len):
 
     if max_pkt_len is not None:
         if (max_pkt_len < 64) or (max_pkt_len > 9600):
-            print('Error: --max-pkt-len {} should be {}-{}'.format(
-                max_pkt_len, 64, 9600))
+            print('Error: --max-pkt-len {0:d} should be {1:d}-{2:d}'.
+                  format(max_pkt_len, 64, 9600))
             return False
 
     return True
@@ -149,39 +149,46 @@ def main():
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
+
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
         args, container_image, sock_files)
 
-    # Parse vhost device IDs and Check the number of devices is
-    # sufficient for port mask.
-    if app_helper.is_sufficient_dev_ids(
-            args.dev_ids, args.port_mask) is not True:
-        print("Error: Cannot reserve ports '{} (= 0b{})' on '{}'.".format(
-            args.port_mask,
-            format(int(args.port_mask, 16), 'b'),
-            args.dev_ids))
+    # Check given number of ports is enough for portmask.
+    if (args.port_mask is None) or (args.dev_uids is None):
+        pass
+    elif app_helper.is_sufficient_ports(args) is not True:
+        print("Error: Not enough ports, {0:d} devs for '{1:s}(=0b{2:s})'.".
+              format(len(args.dev_uids.split(',')), args.port_mask,
+                     format(int(args.port_mask, 16), 'b')))
         exit()
 
     # Setup l3fwd-acl command runs on container.
-    cmd_path = '{}/examples/l3fwd-acl/{}/l3fwd-acl'.format(
+    cmd_path = '{0:s}/examples/l3fwd-acl/{1:s}/l3fwd-acl'.format(
         env.RTE_SDK, env.RTE_TARGET)
 
     l3fwd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    file_prefix = 'spp-l3fwd-acl-container{}'.format(dev_ids_list[0])
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix('l3fwd-acl')
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
-    # Setup l3fwd options.
+    # Setup l3fwd-acl options.
     l3fwd_opts = ['-p', args.port_mask, '\\']
 
     if args.config is None:
@@ -190,7 +197,7 @@ def main():
         print('Invalid config: {}'.format(args.config))
         exit()
     else:
-        l3fwd_opts += ['--config', '"{}"'.format(args.config), '\\']
+        l3fwd_opts += ['--config', '"{:s}"'.format(args.config), '\\']
 
     jumbo_opt_valid = False
     if args.enable_jumbo is True:
@@ -202,13 +209,13 @@ def main():
 
     if args.rule_ipv4 is not None:
         if os.path.exists(args.rule_ipv4):
-            l3fwd_opts += ['--rule_ipv4', '"{}"'.format(args.rule_ipv4), '\\']
+            l3fwd_opts += ['--rule_ipv4', '"{:s}"'.format(args.rule_ipv4), '\\']
         else:
             print('Error: "{}" does not exist'.format(args.rule_ipv4))
             exit()
     if args.rule_ipv6 is not None:
         if os.path.exists(args.rule_ipv6):
-            l3fwd_opts += ['--rule_ipv6', '"{}"'.format(args.rule_ipv6), '\\']
+            l3fwd_opts += ['--rule_ipv6', '"{:s}"'.format(args.rule_ipv6), '\\']
         else:
             print('Error: "{}" does not exist'.format(args.rule_ipv6))
             exit()
@@ -220,7 +227,7 @@ def main():
     if (args.enable_jumbo is not None) and (jumbo_opt_valid is True):
         l3fwd_opts += ['--enable-jumbo', '\\']
         if args.max_pkt_len is not None:
-            l3fwd_opts += ['--max-pkt-len {}'.format(args.max_pkt_len), '\\']
+            l3fwd_opts += ['--max-pkt-len {:d}'.format(args.max_pkt_len), '\\']
     if args.no_numa is True:
         l3fwd_opts += ['--no-numa', '\\']
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 07/29] tools/sppc: update dev options of testpmd
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (5 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 06/29] tools/sppc: update dev options of l3fwd-acl Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 08/29] tools/sppc: update dev options of pktgen Yasufumi Ogawa
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of testpmd container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/testpmd.py | 192 +++++++++++++++++++-------------------
 1 file changed, 98 insertions(+), 94 deletions(-)

diff --git a/tools/sppc/app/testpmd.py b/tools/sppc/app/testpmd.py
index ff84335..1ffb6eb 100755
--- a/tools/sppc/app/testpmd.py
+++ b/tools/sppc/app/testpmd.py
@@ -317,22 +317,22 @@ def parse_args():
 
 
 def check_eth_peer(eth_peer):
-    """Check if --eth-peer option is valied
+    """Check if --eth-peer option is valied.
 
     Format of --eth-peer for port X should be 'N,XX:XX:XX:XX:XX:XX'.
     """
 
     xx = '[0-9A-Fa-f][0-9A-Fa-f]'
     ptn = re.compile(
-        r'(\d+),(%s:%s:%s:%s:%s:%s)' % (xx, xx, xx, xx, xx, xx))
+        r'(\d+),({0:s}:{0:s}:{0:s}:{0:s}:{0:s}:{0:s}\Z)'.format(xx))
     m = re.match(ptn, eth_peer)
     if m is None:
-            return False
+        return False
     return True
 
 
 def check_pkt_filter_mode(mode):
-    """Check if Flow Director mode is valid
+    """Check if Flow Director mode is valid.
 
     There are three modes for Flow Director.
       * none (default)
@@ -347,7 +347,7 @@ def check_pkt_filter_mode(mode):
 
 
 def check_pkt_filter_report_hash(mode):
-    """Check if Flow Director hash match reporting mode is valid
+    """Check if Flow Director hash match reporting mode is valid.
 
     There are three modes for the reporting mode.
       * none
@@ -362,7 +362,7 @@ def check_pkt_filter_report_hash(mode):
 
 
 def check_pkt_filter_size(pkt_size):
-    """Check if Flow Director size is valid
+    """Check if Flow Director size is valid.
 
     Packet size should be 64K, 128K or 256K
     """
@@ -406,7 +406,7 @@ def check_port_topology(mode):
 
 def check_forward_mode(mode):
     modes = ['io', 'mac', 'macswap', 'flowgen', 'rxonly', 'txonly', 'csum',
-            'icmpecho', 'ieee1588', 'tm', 'noisy']
+             'icmpecho', 'ieee1588', 'tm', 'noisy']
     if mode in modes:
         return True
     else:
@@ -441,7 +441,7 @@ def check_ring_numa_config(rnconf):
     return True
 
 
-def error_exit(opt):
+def invalid_opt_exit(opt):
     print("Error: invalid '{}' option".format(opt))
     exit()
 
@@ -462,13 +462,16 @@ def main():
             common.IMG_BASE_NAMES['dpdk'],
             args.dist_name, args.dist_ver)
 
-    # Check for other mandatory opitons.
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
@@ -480,8 +483,11 @@ def main():
     # Setup testpmd command.
     testpmd_cmd = [cmd_path, '\\']
 
-    # Setup EAL options
-    file_prefix = 'spp-testpmd-container%d' % dev_ids_list[0]
+    # Setup EAL options.
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix('testpmd')
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     # Setup testpmd options
@@ -497,7 +503,7 @@ def main():
         if args.interactive is not True:
             testpmd_opts += ['--tx-first', '\\']
         else:
-            print("Error: '%s' cannot be used in interactive mode" % (
+            print("Error: '{}' cannot be used in interactive mode".format(
                 '--tx-first'))
             exit()
 
@@ -505,13 +511,13 @@ def main():
         testpmd_opts += ['--stats-period', str(args.stats_period), '\\']
 
     if args.nb_cores is not None:
-        testpmd_opts += ['--nb-cores=%d' % args.nb_cores, '\\']
+        testpmd_opts += ['--nb-cores={:d}'.format(args.nb_cores), '\\']
 
     if args.coremask is not None:
-        testpmd_opts += ['--coremask=%s' % args.coremask, '\\']
+        testpmd_opts += ['--coremask={:s}'.format(args.coremask), '\\']
 
     if args.portmask is not None:
-        testpmd_opts += ['--portmask=%s' % args.portmask, '\\']
+        testpmd_opts += ['--portmask={:s}'.format(args.portmask), '\\']
 
     if args.no_numa is True:
         testpmd_opts += ['--no-numa', '\\']
@@ -519,66 +525,64 @@ def main():
     if args.port_numa_config is not None:
         if check_port_numa_config(args.port_numa_config) is True:
             testpmd_opts += [
-                    '--port-numa-config={}'.format(
-                        args.port_numa_config),
-                    '\\']
+                    '--port-numa-config={:s}'.format(
+                        args.port_numa_config), '\\']
 
     if args.ring_numa_config is not None:
         if check_ring_numa_config(args.ring_numa_config) is True:
             testpmd_opts += [
-                    '--ring-numa-config={}'.format(
-                        args.ring_numa_config),
-                    '\\']
+                    '--ring-numa-config={:s}'.format(
+                        args.ring_numa_config), '\\']
 
     if args.socket_num is not None:
-        testpmd_opts += ['%s=%d' % (
+        testpmd_opts += ['{0:s}={1:d}'.format(
             '--socket-num', args.socket_num), '\\']
 
     if args.mbuf_size is not None:
         mbuf_limit = 65536
         if args.mbuf_size > mbuf_limit:
-            print("Error: '%s' should be less than %d" % (
+            print("Error: '{0:s}' should be less than {1:d}".format(
                 '--mbuf-size', mbuf_limit))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % (
+            testpmd_opts += ['{0:s}={1:d}'.format(
                 '--mbuf-size', args.mbuf_size), '\\']
 
     if args.total_num_mbufs is not None:
         nof_mbuf_limit = 1024
         if args.total_num_mbufs <= nof_mbuf_limit:
-            print("Error: '%s' should be more than %d" % (
+            print("Error: '{}' should be more than {}".format(
                 '--total-num-mbufs', nof_mbuf_limit))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % (
+            testpmd_opts += ['{0:s}={1:d}'.format(
                 '--total-num-mbufs', args.total_num_mbufs), '\\']
 
     if args.max_pkt_len is not None:
         pkt_len_limit = 64
         if args.max_pkt_len < pkt_len_limit:
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--max-pkt-len', pkt_len_limit))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % (
+            testpmd_opts += ['{0:s}={1:d}'.format(
                 '--max-pkt-len', args.max_pkt_len), '\\']
 
     if args.eth_peers_configfile is not None:
-        testpmd_opts += ['%s=%s' % (
+        testpmd_opts += ['{0:s}={1:s}'.format(
             '--eth-peers-configfile',
             args.eth_peers_configfile), '\\']
 
     if args.eth_peer is not None:
         if check_eth_peer(args.eth_peer) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--eth-peer', args.eth_peer), '\\']
         else:
-            error_exit('--eth-peer')
+            invalid_opt_exit('--eth-peer')
 
     if args.pkt_filter_mode is not None:
         if check_pkt_filter_mode(args.pkt_filter_mode) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--pkt-filter-mode', args.pkt_filter_mode), '\\']
         else:
             print("Error: '--pkt-filter-mode' should be " +
@@ -587,7 +591,7 @@ def main():
 
     if args.pkt_filter_report_hash is not None:
         if check_pkt_filter_report_hash(args.pkt_filter_report_hash) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--pkt-filter-report-hash',
                 args.pkt_filter_report_hash), '\\']
         else:
@@ -597,33 +601,29 @@ def main():
 
     if args.pkt_filter_size is not None:
         if check_pkt_filter_size(args.pkt_filter_size) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--pkt-filter-size', args.pkt_filter_size), '\\']
         else:
             print("Error: '--pkt-filter-size' should be " +
                   "'64K', '128K' or '256K'")
             exit()
 
-    # TODO(yasufum) Confirm this option is supported in dpdk 18.02
-    if args.pkt_filter_flexbytes_offset is not None:
-        not_supported_exit('--pkt-filter-flexbytes-offset')
-
     # It causes 'unrecognized option' error.
     # if args.pkt_filter_flexbytes_offset is not None:
     #     f_offset = args.pkt_filter_flexbytes_offset
     #     f_offset_min = 0
     #     f_offset_max = 32
     #     if (f_offset < f_offset_min) or (f_offset > f_offset_max):
-    #         print("Error: '%s' should be %d-%d" % (
+    #         print("Error: '{0:s}' should be {1:d}-{2:d}".format(
     #             '--pkt-filter-flexbytes-offset',
     #             f_offset_min, f_offset_max))
     #         exit()
     #     else:
-    #         testpmd_opts += ['%s=%d' % (
+    #         testpmd_opts += ['{0:s}={1:d}'.format(
     #             '--pkt-filter-flexbytes-offset', f_offset), '\\']
 
     if args.pkt_filter_drop_queue is not None:
-        testpmd_opts += ['%s=%d' % (
+        testpmd_opts += ['{0:s}={1:d}'.format(
             '--pkt-filter-drop-queue', args.pkt_filter_drop_queue), '\\']
 
     if args.disable_crc_strip is True:
@@ -659,16 +659,16 @@ def main():
     if args.port_topology is not None:
         if check_port_topology(args.port_topology) is True:
             testpmd_opts += [
-                    '--port-topology={}'.format(args.port_topology), '\\']
+                    '--port-topology={:s}'.format(args.port_topology), '\\']
         else:
-            error_exit('--port-topology')
+            invalid_opt_exit('--port-topology')
 
     if args.forward_mode is not None:
         if check_forward_mode(args.forward_mode) is True:
             testpmd_opts += [
-                    '--forward-mode={}'.format(args.forward_mode), '\\']
+                    '--forward-mode={:s}'.format(args.forward_mode), '\\']
         else:
-            error_exit('--forward-mode')
+            invalid_opt_exit('--forward-mode')
 
     if args.rss_ip is True:
         testpmd_opts += ['--rss-ip', '\\']
@@ -680,77 +680,79 @@ def main():
         nof_q_min = 1
         nof_q_max = 65535
         if (args.rxq < nof_q_min) or (nof_q_max < args.rxq):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--rxq', nof_q_min, nof_q_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxq', args.rxq), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxq', args.rxq), '\\']
 
     if args.rxd is not None:
         nof_d_min = 1
         if (args.rxd < nof_d_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--rxd', nof_d_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxd', args.rxd), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxd', args.rxd), '\\']
 
     if args.txq is not None:
         nof_q_min = 1
         nof_q_max = 65535
         if (args.txq < nof_q_min) or (nof_q_max < args.txq):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--txq', nof_q_min, nof_q_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txq', args.txq), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txq', args.txq), '\\']
 
     if args.txd is not None:
         nof_d_min = 1
         if (args.txd < nof_d_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--txd', nof_d_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txd', args.txd), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txd', args.txd), '\\']
 
     if args.burst is not None:
         b_min = 1
         b_max = 512
         if (args.burst < b_min) or (b_max < args.burst):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--burst', b_min, b_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--burst', args.burst), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--burst', args.burst),
+                             '\\']
 
     if args.mbcache is not None:
         mb_min = 0
         mb_max = 512
         if (args.mbcache < mb_min) or (mb_max < args.mbcache):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--mbcache', mb_min, mb_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--mbcache', args.mbcache), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--mbcache', args.mbcache),
+                             '\\']
 
     if args.rxpt is not None:
         nof_p_min = 0
         if (args.rxpt < nof_p_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--rxpt', nof_p_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxpt', args.rxpt), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxpt', args.rxpt), '\\']
 
     if args.rxht is not None:
         nof_h_min = 0
         if (args.rxht < nof_h_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--rxht', nof_h_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxht', args.rxht), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxht', args.rxht), '\\']
 
     if args.rxfreet is not None:
         nof_f_min = 0
@@ -759,47 +761,48 @@ def main():
         else:
             nof_f_max = 128 - 1  # as default of rxd - 1
         if (args.rxfreet < nof_f_min) or (nof_f_max < args.rxfreet):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--rxfreet', nof_f_min, nof_f_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxfreet', args.rxfreet), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxfreet', args.rxfreet),
+                             '\\']
 
     if args.rxwt is not None:
         nof_w_min = 0
         if (args.rxwt < nof_w_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--rxwt', nof_w_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--rxwt', args.rxwt), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--rxwt', args.rxwt), '\\']
 
     if args.txpt is not None:
         nof_p_min = 0
         if (args.txpt < nof_p_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--txpt', nof_p_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txpt', args.txpt), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txpt', args.txpt), '\\']
 
     if args.txht is not None:
         nof_h_min = 0
         if (args.txht < nof_h_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--txht', nof_h_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txht', args.txht), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txht', args.txht), '\\']
 
     if args.txwt is not None:
         nof_w_min = 0
         if (args.txwt < nof_w_min):
-            print("Error: '%s' should be equal or more than %d" % (
+            print("Error: '{0:s}' should be equal or more than {1:d}".format(
                 '--txwt', nof_w_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txwt', args.txwt), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txwt', args.txwt), '\\']
 
     if args.txfreet is not None:
         nof_f_min = 0
@@ -808,11 +811,12 @@ def main():
         else:
             nof_f_max = 512  # as default of txd
         if (args.txfreet < nof_f_min) or (nof_f_max < args.txfreet):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--txfreet', nof_f_min, nof_f_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txfreet', args.txfreet), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txfreet', args.txfreet),
+                             '\\']
 
     if args.txrst is not None:
         nof_r_min = 0
@@ -821,21 +825,21 @@ def main():
         else:
             nof_r_max = 512  # as default of txd
         if (args.txrst < nof_r_min) or (nof_r_max < args.txrst):
-            print("Error: '%s' should be %d-%d" % (
+            print("Error: '{0:s}' should be {1:d}-{2:d}".format(
                 '--txrst', nof_r_min, nof_r_max))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % ('--txrst', args.txrst), '\\']
+            testpmd_opts += ['{0:s}={1:d}'.format('--txrst', args.txrst), '\\']
 
     if args.rx_queue_stats_mapping is not None:
         testpmd_opts += [
-                '--rx-queue-stats-mapping={}'.format(
+                '--rx-queue-stats-mapping={:s}'.format(
                     args.rx_queue_stats_mapping),
                 '\\']
 
     if args.tx_queue_stats_mapping is not None:
         testpmd_opts += [
-                '--tx-queue-stats-mapping={}'.format(
+                '--tx-queue-stats-mapping={:s}'.format(
                     args.tx_queue_stats_mapping),
                 '\\']
 
@@ -844,10 +848,10 @@ def main():
 
     if args.txpkts is not None:
         if check_txpkts(args.txpkts) is True:
-            testpmd_opts += ['%s=%s' % (
-                '--txpkts', args.txpkts), '\\']
+            testpmd_opts += ['{0:s}={1:s}'.format('--txpkts', args.txpkts),
+                             '\\']
         else:
-            error_exit('--txpkts')
+            invalid_opt_exit('--txpkts')
 
     if args.disable_link_check is True:
         testpmd_opts += ['--disable-link-check', '\\']
@@ -862,7 +866,7 @@ def main():
         # --bitrate-stats can be several
         for stat in args.bitrate_stats:
             if stat[0] >= 0:
-                testpmd_opts += ['%s=%d' % (
+                testpmd_opts += ['{0:s}={1:d}'.format(
                     '--bitrate-stats', stat[0]), '\\']
             else:
                 print("Error: '--bitrate-stats' should be <= 0")
@@ -870,17 +874,17 @@ def main():
 
     if args.print_event is not None:
         if check_event(args.print_event) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--print-event', args.print_event), '\\']
         else:
-            error_exit('--print-event')
+            invalid_opt_exit('--print-event')
 
     if args.mask_event is not None:
         if check_event(args.mask_event) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--mask-event', args.mask_event), '\\']
         else:
-            error_exit('--mask-event')
+            invalid_opt_exit('--mask-event')
 
     if args.flow_isolate_all is True:
         testpmd_opts += ['--flow-isolate-all', '\\']
@@ -888,10 +892,10 @@ def main():
     if args.tx_offloads is not None:
         ptn = r'^0x[0-9aA-Fa-f]+$'  # should be hexadecimal
         if re.match(ptn, args.tx_offloads) is True:
-            testpmd_opts += ['%s=%s' % (
+            testpmd_opts += ['{0:s}={1:s}'.format(
                 '--tx-offloads', args.tx_offloads), '\\']
         else:
-            error_exit('--tx-offloads')
+            invalid_opt_exit('--tx-offloads')
 
     if args.hot_plug is True:
         testpmd_opts += ['--hot-plug', '\\']
@@ -899,11 +903,11 @@ def main():
     if args.vxlan_gpe_port is not None:
         nof_p_min = 0
         if (args.vxlan_gpe_port < nof_p_min):
-            print("Error: '%s' should be <= %d" % (
+            print("Error: '{0:s}' should be <= {1:d}".format(
                 '--vxlan-gpe-port', nof_p_min))
             exit()
         else:
-            testpmd_opts += ['%s=%d' % (
+            testpmd_opts += ['{0:s}={1:d}'.format(
                 '--vxlan-gpe-port', args.vxlan_gpe_port), '\\']
 
     if args.mlockall is True:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 08/29] tools/sppc: update dev options of pktgen
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (6 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 07/29] tools/sppc: update dev options of testpmd Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 09/29] tools/sppc: update dev options of load-balancer Yasufumi Ogawa
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of pktgen container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/pktgen.py | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/tools/sppc/app/pktgen.py b/tools/sppc/app/pktgen.py
index 319557c..a7112e6 100755
--- a/tools/sppc/app/pktgen.py
+++ b/tools/sppc/app/pktgen.py
@@ -75,9 +75,16 @@ def main():
             common.IMG_BASE_NAMES['pktgen'],
             args.dist_name, args.dist_ver)
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
+
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     if args.workdir is not None:
@@ -91,7 +98,11 @@ def main():
     # Setup pktgen command
     pktgen_cmd = ['pktgen', '\\']
 
-    file_prefix = 'spp-pktgen-container%d' % dev_ids_list[0]
+    # Setup EAL options.
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix('pktgen')
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     # Setup matrix for assignment of cores and ports.
@@ -107,31 +118,31 @@ def main():
 
         slave_core_list = core_list[1:]
         nof_slave_cores = len(slave_core_list)
-        nof_ports = len(dev_ids_list)
+        nof_ports = len(dev_uids_list)
         nof_cores_each_port = nof_slave_cores / nof_ports
         if nof_cores_each_port < 1:
-            print("Error: Too few cores for given port(s)!")
-            print("%d cores required for %d port(s)" % (
+            print('Error: Too few cores for given port(s)!')
+            print('{0:d} cores required for {1:d} port(s)'.format(
                 (nof_slave_cores + 1), nof_ports))
             exit()
 
         matrix_list = []
         if nof_cores_each_port == 1:
             for i in range(0, nof_ports):
-                matrix_list.append('%d.%d' % (slave_core_list[i], i))
+                matrix_list.append('{0:d}.{1:d}'.format(slave_core_list[i], i))
         elif nof_cores_each_port == 2:
             for i in range(0, nof_ports):
-                matrix_list.append('[%d:%d].%d' % (
+                matrix_list.append('[{0:d}:{1:d}].{2:d}'.format(
                     slave_core_list[2*i], slave_core_list[2*i + 1], i))
         elif nof_cores_each_port == 3:  # Two cores for rx, one for tx
             for i in range(0, nof_ports):
-                matrix_list.append('[%d-%d:%d].%d' % (
+                matrix_list.append('[{0:d}-{1:d}:{2:d}].{3:d}'.format(
                     slave_core_list[3*i],
                     slave_core_list[3*i + 1],
                     slave_core_list[3*i + 2], i))
         elif nof_cores_each_port == 4:
             for i in range(0, nof_ports):
-                matrix_list.append('[%d-%d:%d-%d].%d' % (
+                matrix_list.append('[{0:d}-{1:d}:{2:d}-{3:d}].{4:d}'.format(
                     slave_core_list[4*i],
                     slave_core_list[4*i + 1],
                     slave_core_list[4*i + 2],
@@ -139,7 +150,7 @@ def main():
         # Do not support more than five because it is rare case and
         # calculation is complex.
         else:
-            print("Error: Too many cores for calculation for ports!")
+            print('Error: Too many cores for calculation for ports!')
             print("Consider to use '--matrix' for assigning directly")
             exit()
         matrix = ','.join(matrix_list)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 09/29] tools/sppc: update dev options of load-balancer
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (7 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 08/29] tools/sppc: update dev options of pktgen Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 10/29] tools/sppc: version checker for container DPDK ver Yasufumi Ogawa
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of load-balancer container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/load-balancer.py | 51 +++++++++++++++++----------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index 687bfe5..d86a04b 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -31,7 +31,7 @@ def parse_args():
         type=str,
         help="List of tx ports and queues handled by the I/O tx lcores")
     parser.add_argument(
-        '-w', '--worker-lcores',
+        '-wl', '--worker-lcores',
         type=str,
         help="List of worker lcores")
     parser.add_argument(
@@ -58,6 +58,8 @@ def parse_args():
 def main():
     args = parse_args()
 
+    app_name = 'load_balancer'
+
     # Container image name such as 'sppc/dpdk-ubuntu:18.04'
     if args.container_image is not None:
         container_image = args.container_image
@@ -66,27 +68,33 @@ def main():
             common.IMG_BASE_NAMES['dpdk'],
             args.dist_name, args.dist_ver)
 
-    # Check for other mandatory opitons.
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
         args, container_image, sock_files)
 
-    app_name = 'load_balancer'
-    cmd_path = '%s/examples/%s/%s/%s' % (
-        env.RTE_SDK, app_name, env.RTE_TARGET, app_name)
+    cmd_path = '{0:s}/examples/{1:s}/{2:s}/{1:s}'.format(
+        env.RTE_SDK, app_name, env.RTE_TARGET)
 
     # Setup testpmd command.
     lb_cmd = [cmd_path, '\\']
 
-    file_prefix = 'spp-lb-container%d' % dev_ids_list[0]
+    # Setup EAL options.
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix(app_name)
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     lb_opts = []
@@ -95,37 +103,30 @@ def main():
     if args.rx_ports is None:
         common.error_exit('--rx-ports')
     else:
-        rx_ports = '"%s"' % args.rx_ports
-        lb_opts += ['--rx', rx_ports, '\\']
+        lb_opts += ['--rx', '"{:s}"'.format(args.rx_ports), '\\']
 
     if args.tx_ports is None:
         common.error_exit('--tx-ports')
     else:
-        tx_ports = '"%s"' % args.tx_ports
-        lb_opts += ['--tx', tx_ports, '\\']
+        lb_opts += ['--tx', '"{:s}"'.format(args.tx_ports), '\\']
 
     if args.worker_lcores is None:
         common.error_exit('--worker-lcores')
     else:
-        worker_lcores = '%s' % args.worker_lcores
-        lb_opts += ['--w', worker_lcores, '\\']
+        lb_opts += ['--w', '{:s}'.format(args.worker_lcores), '\\']
 
     if args.lpm is None:
         common.error_exit('--lpm')
     else:
-        lpm = '"%s"' % args.lpm
-        lb_opts += ['--lpm', lpm, '\\']
+        lb_opts += ['--lpm', '"{:s}"'.format(args.lpm), '\\']
 
     # Check optional opitons.
     if args.ring_sizes is not None:
-        lb_opts += [
-            '--ring-sizes', args.ring_sizes, '\\']
+        lb_opts += ['--ring-sizes', args.ring_sizes, '\\']
     if args.burst_sizes is not None:
-        lb_opts += [
-            '--burst-sizes', args.burst_sizes, '\\']
+        lb_opts += ['--burst-sizes', args.burst_sizes, '\\']
     if args.pos_lb is not None:
-        lb_opts += [
-            '--pos-lb', str(args.pos_lb)]
+        lb_opts += ['--pos-lb', str(args.pos_lb)]
 
     cmds = docker_cmd + docker_opts + lb_cmd + eal_opts + lb_opts
     if cmds[-1] == '\\':
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 10/29] tools/sppc: version checker for container DPDK ver
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (8 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 09/29] tools/sppc: update dev options of load-balancer Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 11/29] tools/sppc: check DPDK ver in load-balancer Yasufumi Ogawa
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

You need to check version of DPDK on a container because some of
application might be deprecated or removed from some specific version.
For instance, load balancer example app was removed after v19.08-rc.

This update is to add methods for getting DPDK version from container,
and comparing it with expected version.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/lib/app_helper.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index cc042e5..b918aeb 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -4,6 +4,7 @@
 from . import common
 import os
 import secrets
+import subprocess
 import sys
 
 
@@ -337,6 +338,34 @@ def gen_sppc_file_prefix(app_name):
     return 'sppc-{}-{}'.format(app_name, secrets.token_hex(8))
 
 
+def get_dpdk_ver_in_container(rte_sdk, c_image):
+    """Get DPDK version on a container.
+
+    The version is retrieved by reading `${RTE_SDK/VERION` file.
+    """
+
+    cmd = ['cat', '{:s}/VERSION'.format(rte_sdk)]
+    cmd = ['docker', 'run', '-it', c_image] + cmd
+    # Decode the result of byte type to utf-8.
+    return subprocess.check_output(cmd).decode('utf-8').strip()
+
+
+def compare_version(expected, target):
+    """Compare given versions.
+
+    If two versions are equal, return 0. On the other hand, return -1 if
+    expected ver is less than target, or return 1.
+    """
+
+    from distutils.version import LooseVersion
+    if LooseVersion(expected) == LooseVersion(target):
+        return 0
+    elif LooseVersion(expected) < LooseVersion(target):
+        return 1
+    else:
+        return -1
+
+
 def _uniq(dup_list):
     """Remove duplicated elements in a list and return a unique list.
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 11/29] tools/sppc: check DPDK ver in load-balancer
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (9 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 10/29] tools/sppc: version checker for container DPDK ver Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 12/29] tools/sppc: setup spp_pri opts in app_helper Yasufumi Ogawa
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This update is to add checking DPDK version in load-balancer app
launcher because this example app was removed from v19.08-rc1. If DPDK
version on container is larger than v19.08-rc1, launcher stops
launching.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/load-balancer.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index d86a04b..ec504e7 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -68,6 +68,16 @@ def main():
             common.IMG_BASE_NAMES['dpdk'],
             args.dist_name, args.dist_ver)
 
+    c_dpdk_ver = app_helper.get_dpdk_ver_in_container(
+            env.RTE_SDK, container_image)
+    expected = '19.08-rc1'
+    if app_helper.compare_version(expected, c_dpdk_ver) > 0:
+        print("Load-balancer example was removed after DPDK 'v{}'.".
+              format(expected))
+        print("You cannot run it because DPDK in the container is 'v{}'.".
+              format(c_dpdk_ver))
+        exit()
+
     # Setup devices with given device UIDs.
     dev_uids = None
     sock_files = None
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 12/29] tools/sppc: setup spp_pri opts in app_helper
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (10 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 11/29] tools/sppc: check DPDK ver in load-balancer Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 13/29] tools/sppc: define file prefix for SPP Yasufumi Ogawa
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Setup options for spp_primary is separated with other apps because
name of devices are a bit different, although steps of building options
are similar. It should be merged considering maintainability.

This update is to add setup of spp_primary into `lib/app_helper.py`
module to merge them.

* Setup options of apps including spp_primary is done in add_sppc_args()
  in app_helper.py.

* Add attaching TAP interfaces in the method, mainly for spp_primary.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/lib/app_helper.py | 119 +++++++++++++++++++++++++----------
 1 file changed, 87 insertions(+), 32 deletions(-)

diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index b918aeb..411b3f5 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -9,7 +9,10 @@ import sys
 
 
 # Supported vdev types of SPP Container.
-VDEV_TYPES = ['vhost', 'memif']
+VDEV_TYPES = ['vhost', 'memif', 'tap']
+
+# Prefix of tap interface which is named as 'spp_tap0', 'spp_tap1' or so.
+TAP_PREFIX = 'spp_tap'
 
 
 def add_eal_args(parser, mem_size=1024, mem_channel=4):
@@ -73,6 +76,10 @@ def add_sppc_args(parser):
         '--workdir',
         type=str,
         help="Path of directory in which the command is launched")
+    parser.add_argument(
+        '--name',
+        type=str,
+        help='Name of container')
     parser.add_argument(
         '-ci', '--container-image',
         type=str,
@@ -99,10 +106,6 @@ def add_appc_args(parser):
         '-v', '--volume',
         nargs='*', type=str,
         help='Bind mount a volume (for docker)')
-    parser.add_argument(
-        '--name',
-        type=str,
-        help='Name of container')
     parser.add_argument(
         '-nq', '--nof-queues',
         type=int,
@@ -128,7 +131,9 @@ def is_valid_dev_uids(dev_uids):
         return False
 
     for dev_uid in dev_uids.split(','):
-        if dev_uid.split(':')[0] not in VDEV_TYPES:
+        dtype = dev_uid.split(':')[0]
+        if dtype not in VDEV_TYPES:
+            print('Error: `{}` is not supported.'.format(dtype))
             return False
 
     return True
@@ -154,7 +159,8 @@ def get_mem_opt(args):
     return mem_opt
 
 
-def setup_eal_opts(args, file_prefix, proc_type='auto', hugedir=None):
+def setup_eal_opts(args, file_prefix, proc_type='auto', is_spp_pri=False,
+                   hugedir=None):
     core_opt = get_core_opt(args)
     mem_opt = get_mem_opt(args)
 
@@ -167,19 +173,44 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', hugedir=None):
     if args.dev_uids is not None:
         dev_uids_list = args.dev_uids.split(',')
 
-        socks = sock_files(dev_uids_list)
+        socks = sock_files(dev_uids_list, is_spp_pri)
 
         # Configure '--vdev' options
         for i in range(len(dev_uids_list)):
             dev_uid = dev_uids_list[i].split(':')
             if dev_uid[0] == 'vhost':
+                if not is_spp_pri:
+                    eal_opts += [
+                            '--vdev',
+                            'virtio_user{0:s},queues={1:d},path={2:s}'.
+                            format(dev_uid[1], args.nof_queues,
+                                   socks[i]['guest']),
+                            '\\']
+                else:
+                    # TODO(yasufum) Support `queues` option.
+                    eal_opts += [
+                            '--vdev',
+                            'eth_vhost{0:s},iface={1:s}'.
+                            format(dev_uid[1], socks[i]['guest']),
+                            '\\']
+            elif dev_uid[0] == 'memif':
+                if not is_spp_pri:
+                    eal_opts += [
+                            '--vdev',
+                            'net_memif{0:s},id={0:s},socket={1:s}'.
+                            format(dev_uid[1], socks[0]['guest']),
+                            '\\']
+                else:
+                    eal_opts += [
+                            '--vdev',
+                            'net_memif{0:s},id={0:s},role={1:s},socket={2:s}'.
+                            format(dev_uid[1], 'master', socks[0]['guest']),
+                            '\\']
+            elif dev_uid[0] == 'tap':
                 eal_opts += [
-                    '--vdev', 'virtio_user{},queues={},path={}'.format(
-                        dev_uid[1], args.nof_queues, socks[i]['guest']), '\\']
-            elif dev_uid[0] == 'memif':  # Only 'slave' role is supported.
-                eal_opts += [
-                    '--vdev', 'net_memif{0},id={0},socket={1}'.format(
-                        dev_uid[1], socks[0]['guest']), '\\']
+                        '--vdev',
+                        'net_tap{0:s},iface={1:s}{0:s}'.
+                        format(dev_uid[1], TAP_PREFIX), '\\']
 
     if (args.pci_blacklist is not None) and (args.pci_whitelist is not None):
         common.error_exit("Cannot use both of '-b' and '-w' at once")
@@ -200,7 +231,7 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', hugedir=None):
     return eal_opts
 
 
-def setup_docker_opts(args, container_image, sock_files, workdir=None):
+def setup_docker_opts(args, container_image, socks, workdir=None):
     docker_opts = []
 
     if args.foreground is True:
@@ -217,8 +248,8 @@ def setup_docker_opts(args, container_image, sock_files, workdir=None):
     if args.no_privileged is not True:
         docker_opts += ['--privileged', '\\']
 
-    if sock_files is not None:
-        for sock in sock_files:
+    if socks is not None:
+        for sock in socks:
             docker_opts += [
                 '-v', '%s:%s' % (sock['host'], sock['guest']), '\\']
 
@@ -251,12 +282,15 @@ def is_sufficient_ports(args):
         return False
 
 
-def sock_files(dev_uids_list):
+def sock_files(dev_uids_list, is_spp_pri=False):
     """Return list of socket files on host and containers.
 
     The name of socket files is defined with a conventional ones described
     in DPDK doc, though you can use any name actually.
 
+    For spp_primary, path of sock file is just bit different because it is
+    shared among other SPP processes.
+
     Here is an example of two vhost devices.
         [vhost:0, vhost:1]
         => [
@@ -264,23 +298,44 @@ def sock_files(dev_uids_list):
               {'host': '/tmp/sock1, 'guest': '/var/run/usvhost1'}
             ]
     """
-    socks = []
+
+    socks = {
+            'vhost': {
+                'host': '/tmp/sock{:s}',
+                'guest': '/var/run/usvhost{:s}'},
+            'memif': {
+                'host': '/tmp/spp-memif.sock',
+                'guest': '/var/run/spp-memif.sock'}}
+
+    res = []
+    is_memif_added = False
     for dev_uid in dev_uids_list:
         dev_uid = dev_uid.split(':')
-        if dev_uid[0] == 'vhost':
-            socks.append({
-                'host': '/tmp/sock{}'.format(dev_uid[1]),
-                'guest': '/var/run/usvhost{}'.format(dev_uid[1])})
-        elif dev_uid[0] == 'memif':
+
+        if (dev_uid[0] == 'memif') and (not is_memif_added):
             # Single sock file is enough for memif because it is just used for
             # negotiation between master and slaves processes.
-            socks.append({
-                'host': '/tmp/spp-memif.sock',
-                'guest': '/var/run/spp-memif.sock'})
-            break
-        else:
-            break
-    return socks
+            if is_spp_pri:
+                res.append({
+                    'host': socks['memif']['host'],
+                    'guest': socks['memif']['host']})
+            else:
+                res.append({
+                    'host': socks['memif']['host'],
+                    'guest': socks['memif']['guest']})
+            is_memif_added = True
+
+        elif dev_uid[0] == 'vhost':
+            if is_spp_pri:
+                res.append({
+                    'host': socks['vhost']['host'].format(dev_uid[1]),
+                    'guest': socks['vhost']['host'].format(dev_uid[1])})
+            else:
+                res.append({
+                    'host': socks['vhost']['host'].format(dev_uid[1]),
+                    'guest': socks['vhost']['guest'].format(dev_uid[1])})
+
+    return res
 
 
 def count_ports(port_mask):
@@ -335,7 +390,7 @@ def cores_to_list(core_opt):
 def gen_sppc_file_prefix(app_name):
     """Generate a unique file prefix of DPDK for SPP Container app."""
 
-    return 'sppc-{}-{}'.format(app_name, secrets.token_hex(8))
+    return 'sppc-{:s}-{:s}'.format(app_name, secrets.token_hex(8))
 
 
 def get_dpdk_ver_in_container(rte_sdk, c_image):
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 13/29] tools/sppc: define file prefix for SPP
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (11 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 12/29] tools/sppc: setup spp_pri opts in app_helper Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 14/29] tools/sppc: update dev options of spp_primary Yasufumi Ogawa
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Considering running multiple DPDK processes on the same host, add file
prefix for containerized SPP processes.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/lib/common.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/sppc/lib/common.py b/tools/sppc/lib/common.py
index 657f812..a17a0dc 100644
--- a/tools/sppc/lib/common.py
+++ b/tools/sppc/lib/common.py
@@ -10,6 +10,9 @@ IMG_BASE_NAMES = {
     }
 
 
+SPPC_FILE_PREFIX = 'sppc_spp_fp'
+
+
 def print_pretty_commands(cmds):
     """Print given command in pretty format."""
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 14/29] tools/sppc: update dev options of spp_primary
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (12 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 13/29] tools/sppc: define file prefix for SPP Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 15/29] tools/sppc: setup with docker opts in SPP pri Yasufumi Ogawa
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of spp_primary container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/spp-primary.py | 84 ++++++++++++-----------------------
 1 file changed, 28 insertions(+), 56 deletions(-)

diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 7ebee68..3e5b2ba 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -18,8 +18,17 @@ def parse_args():
         description="Launcher for spp-primary application container")
 
     parser = app_helper.add_eal_args(parser)
+    parser = app_helper.add_sppc_args(parser)
 
     # Application specific arguments
+    parser.add_argument(
+        '-d', '--dev-uids',
+        type=str,
+        help='Virtual devices of SPP in resource UID format')
+    parser.add_argument(
+        '-v', '--volume',
+        nargs='*', type=str,
+        help='Bind mount a volume (for docker)')
     parser.add_argument(
         '-n', '--nof-ring',
         type=int,
@@ -29,14 +38,6 @@ def parse_args():
         '-p', '--port-mask',
         type=str,
         help='Port mask')
-    parser.add_argument(
-        '-dv', '--dev-vhost-ids',
-        type=str,
-        help='vhost device IDs')
-    parser.add_argument(
-        '-dt', '--dev-tap-ids',
-        type=str,
-        help='TAP device IDs')
     parser.add_argument(
         '-ip', '--ctl-ip',
         type=str,
@@ -47,14 +48,14 @@ def parse_args():
         default=5555,
         help="Port for primary of spp-ctl")
 
-    parser = app_helper.add_sppc_args(parser)
-
     return parser.parse_args()
 
 
 def main():
     args = parse_args()
 
+    app_name = 'spp_primary'
+
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = []
@@ -74,60 +75,31 @@ def main():
         docker_opts += ['-it', '\\']
 
     docker_opts += [
-        '--privileged', '\\',  # should be privileged
+        '--privileged', '\\',  # must be privileged
         '-v', '/dev/hugepages:/dev/hugepages', '\\',
-        '-v', '/var/run/:/var/run/', '\\']
+        '-v', '/var/run/:/var/run/', '\\',
+        '-v', '/tmp:/tmp', '\\']
 
-    if args.dev_vhost_ids is not None:
-        docker_opts += ['-v', '/tmp:/tmp', '\\']
+    # Setup devices with given device UIDs.
+    dev_uids_list = None
+    sock_files = []
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
 
-    # Setup for TAP devices with given device IDs.
-    if args.dev_tap_ids is not None:
-        dev_tap_ids = app_helper.dev_ids_to_list(args.dev_tap_ids)
-    else:
-        dev_tap_ids = []
-
-    # Setup for vhost devices with given device IDs.
-    if args.dev_vhost_ids is not None:
-        dev_vhost_ids = app_helper.dev_ids_to_list(args.dev_vhost_ids)
-        socks = []
-        for dev_id in dev_vhost_ids:
-            socks.append({
-                'host': '/tmp/sock{}'.format(dev_id),
-                'guest': '/tmp/sock{}'.format(dev_id)})
-    else:
-        dev_vhost_ids = []
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list, is_spp_pri=True)
 
     docker_opts += [
         container_image, '\\']
 
     # Setup spp primary command.
-    spp_cmd = ['spp_primary', '\\']
-
-    # Do not use 'app_helper.setup_eal_opts()' because spp_primary does
-    # not use virtio vdev but TAP or vhost, which should be added manually.
-    core_opt = app_helper.get_core_opt(args)
-    mem_opt = app_helper.get_mem_opt(args)
-    eal_opts = [
-        core_opt['attr'], core_opt['val'], '\\',
-        '-n', str(args.nof_memchan), '\\',
-        mem_opt['attr'], mem_opt['val'], '\\',
-        '--huge-dir', '/dev/hugepages', '\\',
-        '--proc-type', 'primary', '\\']
-
-    # Add TAP vdevs
-    for i in range(len(dev_tap_ids)):
-        eal_opts += [
-            '--vdev', 'net_tap{},iface=foo{}'.format(
-                dev_tap_ids[i], dev_tap_ids[i]), '\\']
-
-    # Add vhost vdevs
-    for i in range(len(dev_vhost_ids)):
-        eal_opts += [
-            '--vdev', 'eth_vhost{},iface={}'.format(
-                dev_vhost_ids[i], socks[i]['guest']), '\\']
-
-    eal_opts += ['--', '\\']
+    spp_cmd = [app_name, '\\']
+
+    eal_opts = app_helper.setup_eal_opts(args, common.SPPC_FILE_PREFIX,
+                                         proc_type='primary',
+                                         is_spp_pri=True)
 
     spp_opts = []
     # Check for other mandatory opitons.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 15/29] tools/sppc: setup with docker opts in SPP pri
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (13 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 14/29] tools/sppc: update dev options of spp_primary Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 16/29] tools/sppc: update calling setup_docker_opts() Yasufumi Ogawa
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

spp_primary launcher only does not use setup_docker_opts() because some
options are different from others, but almost similar actually. This
update is to merge primary's setup process into the method.

As a refactoring, name of container image is excluded from the result of
the method because it is not a option, but a mandatory param.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/spp-primary.py | 37 ++++++++++++-----------------------
 tools/sppc/lib/app_helper.py  | 33 +++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 3e5b2ba..25f94ef 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -18,17 +18,9 @@ def parse_args():
         description="Launcher for spp-primary application container")
 
     parser = app_helper.add_eal_args(parser)
-    parser = app_helper.add_sppc_args(parser)
+    parser = app_helper.add_appc_args(parser)
 
     # Application specific arguments
-    parser.add_argument(
-        '-d', '--dev-uids',
-        type=str,
-        help='Virtual devices of SPP in resource UID format')
-    parser.add_argument(
-        '-v', '--volume',
-        nargs='*', type=str,
-        help='Bind mount a volume (for docker)')
     parser.add_argument(
         '-n', '--nof-ring',
         type=int,
@@ -48,6 +40,7 @@ def parse_args():
         default=5555,
         help="Port for primary of spp-ctl")
 
+    parser = app_helper.add_sppc_args(parser)
     return parser.parse_args()
 
 
@@ -58,7 +51,6 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = []
 
     # Container image name such as 'sppc/spp-ubuntu:18.04'
     if args.container_image is not None:
@@ -68,18 +60,6 @@ def main():
             common.IMG_BASE_NAMES['spp'],
             args.dist_name, args.dist_ver)
 
-    # This container is running in backgroud in defualt.
-    if args.foreground is not True:
-        docker_opts += ['-d', '\\']
-    else:
-        docker_opts += ['-it', '\\']
-
-    docker_opts += [
-        '--privileged', '\\',  # must be privileged
-        '-v', '/dev/hugepages:/dev/hugepages', '\\',
-        '-v', '/var/run/:/var/run/', '\\',
-        '-v', '/tmp:/tmp', '\\']
-
     # Setup devices with given device UIDs.
     dev_uids_list = None
     sock_files = []
@@ -91,8 +71,13 @@ def main():
         dev_uids_list = args.dev_uids.split(',')
         sock_files = app_helper.sock_files(dev_uids_list, is_spp_pri=True)
 
-    docker_opts += [
-        container_image, '\\']
+    app_opts = [
+        '-v', '/var/run/:/var/run/', '\\',
+        '-v', '/tmp:/tmp', '\\',
+        '--net', 'host', '\\']
+
+    docker_opts = app_helper.setup_docker_opts(
+            args, None, app_opts)
 
     # Setup spp primary command.
     spp_cmd = [app_name, '\\']
@@ -118,7 +103,9 @@ def main():
     else:
         spp_opts += ['-s', '{}:{}'.format(ctl_ip, args.ctl_port), '\\']
 
-    cmds = docker_cmd + docker_opts + spp_cmd + eal_opts + spp_opts
+    cmds = docker_cmd + docker_opts + [container_image] + spp_cmd + \
+        eal_opts + spp_opts
+
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index 411b3f5..f5c65f8 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -231,7 +231,18 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', is_spp_pri=False,
     return eal_opts
 
 
-def setup_docker_opts(args, container_image, socks, workdir=None):
+def setup_docker_opts(args, socks=None, app_opts=None, workdir=None):
+    """Return docker options as a list.
+
+    socks must be None if process behaves as master role, such as
+    spp_primary, or failed to initialize the process.
+
+    :param args: Parsed args with argparse
+    :param socks: Socket files, it must be None in spp-primary
+    :param app_opts: Application specific option
+    :returns: A list of docker options
+    """
+
     docker_opts = []
 
     if args.foreground is True:
@@ -239,24 +250,26 @@ def setup_docker_opts(args, container_image, socks, workdir=None):
     else:
         docker_opts = ['-d', '\\']
 
-    if workdir is not None:
-        docker_opts += ['--workdir', workdir, '\\']
+    if args.no_privileged is not True:
+        docker_opts += ['--privileged', '\\']
+
+    docker_opts += [
+        '-v', '/dev/hugepages:/dev/hugepages', '\\']
+
+    if app_opts is not None:
+        docker_opts += app_opts
+
+    if args.workdir is not None:
+        docker_opts += ['--workdir', args.workdir, '\\']
 
     if args.name is not None:
         docker_opts += ['--name', args.name, '\\']
 
-    if args.no_privileged is not True:
-        docker_opts += ['--privileged', '\\']
-
     if socks is not None:
         for sock in socks:
             docker_opts += [
                 '-v', '%s:%s' % (sock['host'], sock['guest']), '\\']
 
-    docker_opts += [
-        '-v', '/dev/hugepages:/dev/hugepages', '\\',
-        container_image, '\\']
-
     return docker_opts
 
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 16/29] tools/sppc: update calling setup_docker_opts()
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (14 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 15/29] tools/sppc: setup with docker opts in SPP pri Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 17/29] tools/sppc: update dev options of helloworld Yasufumi Ogawa
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

As getting args of setup_docker_opts() was changed for supporting
spp_primary, this update is to change the method call.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l2fwd.py         |  6 +++---
 tools/sppc/app/l3fwd-acl.py     | 12 +++++++-----
 tools/sppc/app/l3fwd.py         |  6 +++---
 tools/sppc/app/load-balancer.py |  6 +++---
 tools/sppc/app/pktgen.py        |  6 +++---
 tools/sppc/app/spp-primary.py   |  4 ++--
 tools/sppc/app/testpmd.py       |  6 +++---
 7 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index d6156a8..3bbaf34 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -59,8 +59,7 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     # Check if the number of ports is even for l2fwd.
     nof_ports = app_helper.count_ports(args.port_mask)
@@ -93,7 +92,8 @@ def main():
                      format(int(args.port_mask, 16), 'b')))
         exit()
 
-    cmds = docker_cmd + docker_opts + l2fwd_cmd + eal_opts + l2fwd_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        l2fwd_cmd + eal_opts + l2fwd_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index 46163f4..93c4866 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -163,8 +163,7 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     # Check given number of ports is enough for portmask.
     if (args.port_mask is None) or (args.dev_uids is None):
@@ -209,13 +208,15 @@ def main():
 
     if args.rule_ipv4 is not None:
         if os.path.exists(args.rule_ipv4):
-            l3fwd_opts += ['--rule_ipv4', '"{:s}"'.format(args.rule_ipv4), '\\']
+            l3fwd_opts += ['--rule_ipv4', '"{:s}"'.format(args.rule_ipv4),
+                           '\\']
         else:
             print('Error: "{}" does not exist'.format(args.rule_ipv4))
             exit()
     if args.rule_ipv6 is not None:
         if os.path.exists(args.rule_ipv6):
-            l3fwd_opts += ['--rule_ipv6', '"{:s}"'.format(args.rule_ipv6), '\\']
+            l3fwd_opts += ['--rule_ipv6', '"{:s}"'.format(args.rule_ipv6),
+                           '\\']
         else:
             print('Error: "{}" does not exist'.format(args.rule_ipv6))
             exit()
@@ -231,7 +232,8 @@ def main():
     if args.no_numa is True:
         l3fwd_opts += ['--no-numa', '\\']
 
-    cmds = docker_cmd + docker_opts + l3fwd_cmd + eal_opts + l3fwd_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        l3fwd_cmd + eal_opts + l3fwd_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/l3fwd.py b/tools/sppc/app/l3fwd.py
index 356b281..4a3d2a2 100755
--- a/tools/sppc/app/l3fwd.py
+++ b/tools/sppc/app/l3fwd.py
@@ -198,8 +198,7 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     # Check given number of ports is enough for portmask.
     if (args.port_mask is None) or (args.dev_uids is None):
@@ -285,7 +284,8 @@ def main():
     if args.ipv6 is True:
         l3fwd_opts += ['--ipv6', '\\']
 
-    cmds = docker_cmd + docker_opts + l3fwd_cmd + eal_opts + l3fwd_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        l3fwd_cmd + eal_opts + l3fwd_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index ec504e7..ea5fa19 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -91,8 +91,7 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     cmd_path = '{0:s}/examples/{1:s}/{2:s}/{1:s}'.format(
         env.RTE_SDK, app_name, env.RTE_TARGET)
@@ -138,7 +137,8 @@ def main():
     if args.pos_lb is not None:
         lb_opts += ['--pos-lb', str(args.pos_lb)]
 
-    cmds = docker_cmd + docker_opts + lb_cmd + eal_opts + lb_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        lb_cmd + eal_opts + lb_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/pktgen.py b/tools/sppc/app/pktgen.py
index a7112e6..bcc8d42 100755
--- a/tools/sppc/app/pktgen.py
+++ b/tools/sppc/app/pktgen.py
@@ -92,8 +92,7 @@ def main():
     else:
         wd = '/root/pktgen-dpdk'
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-            args, container_image, sock_files, wd)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files, wd)
 
     # Setup pktgen command
     pktgen_cmd = ['pktgen', '\\']
@@ -181,7 +180,8 @@ def main():
     if args.numa is True:
         pktgen_opts += ['-N', '\\']
 
-    cmds = docker_cmd + docker_opts + pktgen_cmd + eal_opts + pktgen_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        pktgen_cmd + eal_opts + pktgen_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 25f94ef..80b0c7b 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -103,8 +103,8 @@ def main():
     else:
         spp_opts += ['-s', '{}:{}'.format(ctl_ip, args.ctl_port), '\\']
 
-    cmds = docker_cmd + docker_opts + [container_image] + spp_cmd + \
-        eal_opts + spp_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        spp_cmd + eal_opts + spp_opts
 
     if cmds[-1] == '\\':
         cmds.pop()
diff --git a/tools/sppc/app/testpmd.py b/tools/sppc/app/testpmd.py
index 1ffb6eb..a84a175 100755
--- a/tools/sppc/app/testpmd.py
+++ b/tools/sppc/app/testpmd.py
@@ -475,8 +475,7 @@ def main():
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     cmd_path = 'testpmd'
 
@@ -916,7 +915,8 @@ def main():
     if args.no_mlockall is True:
         testpmd_opts += ['--no-mlockall', '\\']
 
-    cmds = docker_cmd + docker_opts + testpmd_cmd + eal_opts + testpmd_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        testpmd_cmd + eal_opts + testpmd_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 17/29] tools/sppc: update dev options of helloworld
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (15 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 16/29] tools/sppc: update calling setup_docker_opts() Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 18/29] tools/sppc: update dev options of suricata Yasufumi Ogawa
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of helloworld container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/helloworld.py | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/tools/sppc/app/helloworld.py b/tools/sppc/app/helloworld.py
index d155b64..3b0b021 100755
--- a/tools/sppc/app/helloworld.py
+++ b/tools/sppc/app/helloworld.py
@@ -29,6 +29,7 @@ def parse_args():
 
 def main():
     args = parse_args()
+    app_name = 'helloworld'
 
     # Container image name such as 'sppc/dpdk-ubuntu:18.04'
     if args.container_image is not None:
@@ -38,32 +39,38 @@ def main():
             common.IMG_BASE_NAMES['dpdk'],
             args.dist_name, args.dist_ver)
 
-    # Check for other mandatory opitons.
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     # Setup helloworld run on container.
-    cmd_path = '%s/examples/helloworld/%s/helloworld' % (
-        env.RTE_SDK, env.RTE_TARGET)
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, app_name)
 
     hello_cmd = [cmd_path, '\\']
 
-    file_prefix = 'spp-hello-container%d' % dev_ids_list[0]
+    if args.name is not None:
+        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
+    else:
+        file_prefix = app_helper.gen_sppc_file_prefix(app_name)
     eal_opts = app_helper.setup_eal_opts(args, file_prefix)
 
     # No application specific options for helloworld
     hello_opts = []
 
-    cmds = docker_cmd + docker_opts + hello_cmd + eal_opts + hello_opts
+    cmds = docker_cmd + docker_opts + [container_image] + hello_cmd + \
+        eal_opts + hello_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 18/29] tools/sppc: update dev options of suricata
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (16 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 17/29] tools/sppc: update dev options of helloworld Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 19/29] tools/sppc: update dev options of spp_nfv Yasufumi Ogawa
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of suricata container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/suricata.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tools/sppc/app/suricata.py b/tools/sppc/app/suricata.py
index 2ac01c0..34601e1 100755
--- a/tools/sppc/app/suricata.py
+++ b/tools/sppc/app/suricata.py
@@ -35,24 +35,26 @@ def main():
             common.IMG_BASE_NAMES['suricata'],
             args.dist_name, args.dist_ver)
 
-    # Check for other mandatory opitons.
-    if args.dev_ids is None:
-        common.error_exit('--dev-ids')
+    # Setup devices with given device UIDs.
+    dev_uids = None
+    sock_files = None
+    if args.dev_uids is not None:
+        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
+            print('Invalid option: {}'.format(args.dev_uids))
+            exit()
 
-    # Setup for vhost devices with given device IDs.
-    dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-    sock_files = app_helper.sock_files(dev_ids_list)
+        dev_uids_list = args.dev_uids.split(',')
+        sock_files = app_helper.sock_files(dev_uids_list)
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, container_image, sock_files)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
     cmd_path = '/bin/bash'
 
     cmd = [cmd_path, '\\']
 
-    cmds = docker_cmd + docker_opts + cmd
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + cmd
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 19/29] tools/sppc: update dev options of spp_nfv
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (17 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 18/29] tools/sppc: update dev options of suricata Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 20/29] tools/sppc: change to gen EAL opts with app name Yasufumi Ogawa
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update options for vdevs of spp_nfv container app.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/spp-nfv.py     | 45 ++++++++++++++++-------------------
 tools/sppc/app/spp-primary.py |  1 +
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index da9853b..3d608f3 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -18,6 +18,7 @@ def parse_args():
         description="Launcher for spp-nfv application container")
 
     parser = app_helper.add_eal_args(parser)
+    parser = app_helper.add_appc_args(parser)
 
     # Application specific arguments
     parser.add_argument(
@@ -35,16 +36,16 @@ def parse_args():
         help="Port for secondary of spp-ctl")
 
     parser = app_helper.add_sppc_args(parser)
-
     return parser.parse_args()
 
 
 def main():
     args = parse_args()
 
+    app_name = 'spp_nfv'
+
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = []
 
     # Container image name such as 'sppc/spp-ubuntu:18.04'
     if args.container_image is not None:
@@ -54,33 +55,28 @@ def main():
             common.IMG_BASE_NAMES['spp'],
             args.dist_name, args.dist_ver)
 
-    # This container is running in backgroud in defualt.
-    if args.foreground is not True:
-        docker_opts += ['-d', '\\']
-    else:
-        docker_opts += ['-it', '\\']
-
-    docker_opts += [
-        '--privileged', '\\',  # should be privileged
-        '-v', '/dev/hugepages:/dev/hugepages', '\\',
+    app_opts = [
         '-v', '/var/run/:/var/run/', '\\',
-        '-v', '/tmp/:/tmp/', '\\',
-        container_image, '\\'
-    ]
+        '-v', '/tmp/:/tmp/', '\\']
+
+    docker_opts = app_helper.setup_docker_opts(
+            args, None, app_opts)
 
     # Setup spp_nfv command.
-    spp_cmd = ['spp_nfv', '\\']
+    spp_cmd = [app_name, '\\']
 
     # Do not use 'app_helper.setup_eal_opts()' because spp_nfv does
     # not use virtio.
-    core_opt = app_helper.get_core_opt(args)
-    mem_opt = app_helper.get_mem_opt(args)
-    eal_opts = [
-        core_opt['attr'], core_opt['val'], '\\',
-        '-n', str(args.nof_memchan), '\\',
-        mem_opt['attr'], mem_opt['val'], '\\',
-        '--proc-type', 'secondary', '\\',
-        '--', '\\']
+    #core_opt = app_helper.get_core_opt(args)
+    #mem_opt = app_helper.get_mem_opt(args)
+    #eal_opts = [
+    #    core_opt['attr'], core_opt['val'], '\\',
+    #    '-n', str(args.nof_memchan), '\\',
+    #    mem_opt['attr'], mem_opt['val'], '\\',
+    #    '--proc-type', 'secondary', '\\',
+    #    '--', '\\']
+    eal_opts = app_helper.setup_eal_opts(args, common.SPPC_FILE_PREFIX,
+                                         proc_type='secondary')
 
     spp_opts = []
     # Check for other mandatory opitons.
@@ -97,7 +93,8 @@ def main():
     else:
         spp_opts += ['-s', '{}:{}'.format(ctl_ip, args.ctl_port), '\\']
 
-    cmds = docker_cmd + docker_opts + spp_cmd + eal_opts + spp_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        spp_cmd + eal_opts + spp_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 80b0c7b..5cc12ed 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -62,6 +62,7 @@ def main():
 
     # Setup devices with given device UIDs.
     dev_uids_list = None
+    # TODO(yasufum) Remove no need sock_files
     sock_files = []
     if args.dev_uids is not None:
         if app_helper.is_valid_dev_uids(args.dev_uids) is False:
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 20/29] tools/sppc: change to gen EAL opts with app name
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (18 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 19/29] tools/sppc: update dev options of spp_nfv Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 21/29] tools/sppc: remove nouse variable Yasufumi Ogawa
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

EAL options are setup in setup_eal_opts() which takes file prefix as an
argument. The file prefix is generated before calling the method
dynamically by using app name. However, the file prefix is only used by
the method, so it is better to give app name to the method directly.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/helloworld.py    | 12 +++++-------
 tools/sppc/app/l2fwd.py         | 13 ++++++-------
 tools/sppc/app/l3fwd-acl.py     | 13 ++++++-------
 tools/sppc/app/l3fwd.py         | 13 ++++++-------
 tools/sppc/app/load-balancer.py | 15 ++++++---------
 tools/sppc/app/pktgen.py        | 13 ++++++-------
 tools/sppc/app/spp-nfv.py       | 12 +-----------
 tools/sppc/app/spp-primary.py   | 13 ++++++++-----
 tools/sppc/app/testpmd.py       | 11 +++++------
 tools/sppc/lib/app_helper.py    | 12 ++++++++++--
 10 files changed, 59 insertions(+), 68 deletions(-)

diff --git a/tools/sppc/app/helloworld.py b/tools/sppc/app/helloworld.py
index 3b0b021..f6088e5 100755
--- a/tools/sppc/app/helloworld.py
+++ b/tools/sppc/app/helloworld.py
@@ -14,6 +14,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'helloworld'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for l2fwd application container")
@@ -29,7 +32,6 @@ def parse_args():
 
 def main():
     args = parse_args()
-    app_name = 'helloworld'
 
     # Container image name such as 'sppc/dpdk-ubuntu:18.04'
     if args.container_image is not None:
@@ -56,15 +58,11 @@ def main():
 
     # Setup helloworld run on container.
     cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
-        env.RTE_SDK, env.RTE_TARGET, app_name)
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
     hello_cmd = [cmd_path, '\\']
 
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix(app_name)
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # No application specific options for helloworld
     hello_opts = []
diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index 3bbaf34..654a512 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -14,6 +14,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'l2fwd'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for l2fwd application container")
@@ -68,17 +71,13 @@ def main():
         exit()
 
     # Setup l2fwd command run on container.
-    cmd_path = '{0:s}/examples/l2fwd/{1:s}/l2fwd'.format(
-        env.RTE_SDK, env.RTE_TARGET)
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
     l2fwd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix('l2fwd')
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # Setup l2fwd options.
     l2fwd_opts = ['-p', args.port_mask, '\\']
diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index 93c4866..11dcc85 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -15,6 +15,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'l3fwd-acl'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for l3fwd-acl application container")
@@ -175,17 +178,13 @@ def main():
         exit()
 
     # Setup l3fwd-acl command runs on container.
-    cmd_path = '{0:s}/examples/l3fwd-acl/{1:s}/l3fwd-acl'.format(
-        env.RTE_SDK, env.RTE_TARGET)
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
     l3fwd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix('l3fwd-acl')
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # Setup l3fwd-acl options.
     l3fwd_opts = ['-p', args.port_mask, '\\']
diff --git a/tools/sppc/app/l3fwd.py b/tools/sppc/app/l3fwd.py
index 4a3d2a2..7c6146f 100755
--- a/tools/sppc/app/l3fwd.py
+++ b/tools/sppc/app/l3fwd.py
@@ -15,6 +15,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'l3fwd'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for l3fwd application container")
@@ -210,17 +213,13 @@ def main():
         exit()
 
     # Setup l3fwd command runs on container.
-    cmd_path = '{0:s}/examples/l3fwd/{1:s}/l3fwd'.format(
-        env.RTE_SDK, env.RTE_TARGET)
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
     l3fwd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix('l3fwd')
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # Setup l3fwd options.
     l3fwd_opts = ['-p', args.port_mask, '\\']
diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index ea5fa19..3a3aa47 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -14,6 +14,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'load_balancer'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for load-balancer application container")
@@ -58,8 +61,6 @@ def parse_args():
 def main():
     args = parse_args()
 
-    app_name = 'load_balancer'
-
     # Container image name such as 'sppc/dpdk-ubuntu:18.04'
     if args.container_image is not None:
         container_image = args.container_image
@@ -93,18 +94,14 @@ def main():
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
-    cmd_path = '{0:s}/examples/{1:s}/{2:s}/{1:s}'.format(
-        env.RTE_SDK, app_name, env.RTE_TARGET)
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
     # Setup testpmd command.
     lb_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix(app_name)
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     lb_opts = []
 
diff --git a/tools/sppc/app/pktgen.py b/tools/sppc/app/pktgen.py
index bcc8d42..6b2f87e 100755
--- a/tools/sppc/app/pktgen.py
+++ b/tools/sppc/app/pktgen.py
@@ -14,6 +14,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'pktgen'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for pktgen-dpdk application container")
@@ -92,17 +95,13 @@ def main():
     else:
         wd = '/root/pktgen-dpdk'
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(args, sock_files, wd)
+    docker_opts = app_helper.setup_docker_opts(args, sock_files, None, wd)
 
     # Setup pktgen command
-    pktgen_cmd = ['pktgen', '\\']
+    pktgen_cmd = [APP_NAME, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix('pktgen')
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # Setup matrix for assignment of cores and ports.
     if args.matrix is not None:
diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index 3d608f3..2019552 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -65,17 +65,7 @@ def main():
     # Setup spp_nfv command.
     spp_cmd = [app_name, '\\']
 
-    # Do not use 'app_helper.setup_eal_opts()' because spp_nfv does
-    # not use virtio.
-    #core_opt = app_helper.get_core_opt(args)
-    #mem_opt = app_helper.get_mem_opt(args)
-    #eal_opts = [
-    #    core_opt['attr'], core_opt['val'], '\\',
-    #    '-n', str(args.nof_memchan), '\\',
-    #    mem_opt['attr'], mem_opt['val'], '\\',
-    #    '--proc-type', 'secondary', '\\',
-    #    '--', '\\']
-    eal_opts = app_helper.setup_eal_opts(args, common.SPPC_FILE_PREFIX,
+    eal_opts = app_helper.setup_eal_opts(args, app_name=None,
                                          proc_type='secondary')
 
     spp_opts = []
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 5cc12ed..c719760 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -74,8 +74,12 @@ def main():
 
     app_opts = [
         '-v', '/var/run/:/var/run/', '\\',
-        '-v', '/tmp:/tmp', '\\',
-        '--net', 'host', '\\']
+        '-v', '/tmp:/tmp', '\\']
+
+    # Use host network if attaching TAP device to show them on the host.
+    for dev_uid in args.dev_uids.split(','):
+        if 'tap' in dev_uid:
+            app_opts += ['--net', 'host', '\\']
 
     docker_opts = app_helper.setup_docker_opts(
             args, None, app_opts)
@@ -83,9 +87,8 @@ def main():
     # Setup spp primary command.
     spp_cmd = [app_name, '\\']
 
-    eal_opts = app_helper.setup_eal_opts(args, common.SPPC_FILE_PREFIX,
-                                         proc_type='primary',
-                                         is_spp_pri=True)
+    eal_opts = app_helper.setup_eal_opts(args, app_name=None,
+                                         proc_type='primary', is_spp_pri=True)
 
     spp_opts = []
     # Check for other mandatory opitons.
diff --git a/tools/sppc/app/testpmd.py b/tools/sppc/app/testpmd.py
index a84a175..225a85d 100755
--- a/tools/sppc/app/testpmd.py
+++ b/tools/sppc/app/testpmd.py
@@ -15,6 +15,9 @@ from lib import app_helper
 from lib import common
 
 
+APP_NAME = 'testpmd'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(
         description="Launcher for testpmd application container")
@@ -477,17 +480,13 @@ def main():
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
-    cmd_path = 'testpmd'
+    cmd_path = APP_NAME  # testpmd is included in $PATH on container
 
     # Setup testpmd command.
     testpmd_cmd = [cmd_path, '\\']
 
     # Setup EAL options.
-    if args.name is not None:
-        file_prefix = app_helper.gen_sppc_file_prefix(args.name)
-    else:
-        file_prefix = app_helper.gen_sppc_file_prefix('testpmd')
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
     # Setup testpmd options
     testpmd_opts = []
diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index f5c65f8..7c48198 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -159,7 +159,7 @@ def get_mem_opt(args):
     return mem_opt
 
 
-def setup_eal_opts(args, file_prefix, proc_type='auto', is_spp_pri=False,
+def setup_eal_opts(args, app_name=None, proc_type='auto', is_spp_pri=False,
                    hugedir=None):
     core_opt = get_core_opt(args)
     mem_opt = get_mem_opt(args)
@@ -224,6 +224,14 @@ def setup_eal_opts(args, file_prefix, proc_type='auto', is_spp_pri=False,
     if args.single_file_segments is True:
         eal_opts += ['--single-file-segments', '\\']
 
+    # Generate unique --file-prefix value for app container, or use common
+    # value for spp_primary and secondary.
+    if args.name is not None:
+        file_prefix = _gen_sppc_file_prefix(args.name)
+    elif app_name is not None and app_name.__class__ is str:
+        file_prefix = _gen_sppc_file_prefix(app_name)
+    else:
+        file_prefix = common.SPPC_FILE_PREFIX
     eal_opts += [
         '--file-prefix', file_prefix, '\\',
         '--', '\\']
@@ -400,7 +408,7 @@ def cores_to_list(core_opt):
     return res
 
 
-def gen_sppc_file_prefix(app_name):
+def _gen_sppc_file_prefix(app_name):
     """Generate a unique file prefix of DPDK for SPP Container app."""
 
     return 'sppc-{:s}-{:s}'.format(app_name, secrets.token_hex(8))
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 21/29] tools/sppc: remove nouse variable
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (19 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 20/29] tools/sppc: change to gen EAL opts with app name Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 22/29] bin: remove sock files created by docker Yasufumi Ogawa
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This update is to remove variable `sock_files` which is not used
anymore.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/spp-primary.py | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index c719760..aa2bc81 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -60,18 +60,6 @@ def main():
             common.IMG_BASE_NAMES['spp'],
             args.dist_name, args.dist_ver)
 
-    # Setup devices with given device UIDs.
-    dev_uids_list = None
-    # TODO(yasufum) Remove no need sock_files
-    sock_files = []
-    if args.dev_uids is not None:
-        if app_helper.is_valid_dev_uids(args.dev_uids) is False:
-            print('Invalid option: {}'.format(args.dev_uids))
-            exit()
-
-        dev_uids_list = args.dev_uids.split(',')
-        sock_files = app_helper.sock_files(dev_uids_list, is_spp_pri=True)
-
     app_opts = [
         '-v', '/var/run/:/var/run/', '\\',
         '-v', '/tmp:/tmp', '\\']
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 22/29] bin: remove sock files created by docker
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (20 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 21/29] tools/sppc: remove nouse variable Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 23/29] tools/sppc: skip checking rule file if dry run Yasufumi Ogawa
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

If docker does mount a sock file without created before from DPDK while
launching a container, docker create an empty directory which name is
the same as the sock file.

SPP startup script removes existing sock files before launching SPP
processes, but does not directories. This update is to enable to remove
directory.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 bin/spp_pri.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/spp_pri.sh b/bin/spp_pri.sh
index c0b0e1e..aca23a9 100644
--- a/bin/spp_pri.sh
+++ b/bin/spp_pri.sh
@@ -15,8 +15,8 @@ SOCK_MEMIF="/tmp/spp-memif.sock"
 
 function clean_sock_files() {
     # clean /tmp/sock*
-    sudo rm -f ${SOCK_VHOST}*
-    sudo rm -f ${SOCK_MEMIF}
+    sudo rm -rf ${SOCK_VHOST}*
+    sudo rm -rf ${SOCK_MEMIF}
 }
 
 # Add vhost vdevs named as such as `eth_vhost0`.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 23/29] tools/sppc: skip checking rule file if dry run
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (21 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 22/29] bin: remove sock files created by docker Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 24/29] docs: revise examples in sppc Yasufumi Ogawa
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

In l3fwd-acl container app, it checks rule file is existing even if for
--dry-run, but has no meaning. This update is disable useless checking
for --dry-run.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/l3fwd-acl.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index 11dcc85..15d0a26 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -209,14 +209,14 @@ def main():
         if os.path.exists(args.rule_ipv4):
             l3fwd_opts += ['--rule_ipv4', '"{:s}"'.format(args.rule_ipv4),
                            '\\']
-        else:
+        elif args.dry_run is not True:
             print('Error: "{}" does not exist'.format(args.rule_ipv4))
             exit()
     if args.rule_ipv6 is not None:
         if os.path.exists(args.rule_ipv6):
             l3fwd_opts += ['--rule_ipv6', '"{:s}"'.format(args.rule_ipv6),
                            '\\']
-        else:
+        elif args.dry_run is not True:
             print('Error: "{}" does not exist'.format(args.rule_ipv6))
             exit()
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 24/29] docs: revise examples in sppc
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (22 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 23/29] tools/sppc: skip checking rule file if dry run Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 25/29] docs: update versions in " Yasufumi Ogawa
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Some of examples in SPP container are wrong because for old or just
typo. This update is to revise the examples.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/app_launcher.rst    | 220 ++++++++++-----------
 docs/guides/tools/sppc/getting_started.rst | 137 ++++++-------
 docs/guides/tools/sppc/usecases.rst        | 104 +++++-----
 3 files changed, 217 insertions(+), 244 deletions(-)

diff --git a/docs/guides/tools/sppc/app_launcher.rst b/docs/guides/tools/sppc/app_launcher.rst
index 3dc4bbb..4d6492b 100644
--- a/docs/guides/tools/sppc/app_launcher.rst
+++ b/docs/guides/tools/sppc/app_launcher.rst
@@ -62,7 +62,7 @@ SPP controller should be launched before other SPP processes.
 .. code-block:: console
 
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 
 .. _sppc_appl_spp_primary:
@@ -98,25 +98,20 @@ physical ports.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary -l 0-1 -p 0x03 -fg
+    $ python3 app/spp-primary -l 0-1 -p 0x03 -fg
 
 It is another example with one core and two ports in background mode.
 
 .. code-block:: console
 
-    $ python app/spp-primary -l 0 -p 0x03
+    $ python3 app/spp-primary -l 0 -p 0x03
 
-SPP primary is able to run with virtual devices instead of
-physical NICs for a case
-you do not have dedicated NICs for DPDK.
-SPP container supports two types of virtual device with options.
-
-* ``--dev-tap-ids`` or ``-dt``:  Add TAP devices
-* ``--dev-vhost-ids`` or ``-dv``: Add vhost devices
+SPP primary is able to run with virtual devices instead of physical NICs
+for a case you do not have dedicated NICs for DPDK.
 
 .. code-block:: console
 
-    $ python app/spp-primary -l 0 -dt 1,2 -p 0x03
+    $ python3 app/spp-primary -l 0 -d vhost:1,vhost:2 -p 0x03
 
 
 
@@ -141,7 +136,7 @@ On the other hand, application specific options are different each other.
 
 .. code-block:: console
 
-    $ python app/spp-primary.py -h
+    $ python3 app/spp-primary.py -h
     usage: spp-primary.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                           [--socket-mem SOCKET_MEM]
                           [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -211,7 +206,7 @@ options for secondary ID and core list (or core mask).
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-nfv.py -i 1 -l 2-3
+    $ python3 app/spp-nfv.py -i 1 -l 2-3
 
 Refer help for all of options and usges.
 It shows only application specific options for simplicity.
@@ -219,7 +214,7 @@ It shows only application specific options for simplicity.
 
 .. code-block:: console
 
-    $ python app/spp-nfv.py -h
+    $ python3 app/spp-nfv.py -h
     usage: spp-nfv.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                       [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
                       [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -260,7 +255,7 @@ ports should be even number.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/l2fwd.py -l 6-7 -d 1,2 -p 0x03 -fg
+    $ python3 app/l2fwd.py -l 6-7 -d vhost:1,vhost:2 -p 0x03 -fg
     ...
 
 Refer help for all of options and usges.
@@ -271,7 +266,7 @@ It shows options without of EAL and container for simplicity.
 
 .. code-block:: console
 
-    $ python app/l2fwd.py -h
+    $ python3 app/l2fwd.py -h
     usage: l2fwd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                     [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
                     [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -332,35 +327,35 @@ defined as ``virtio_...,queues=2,...``.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/l3fwd.py -l 1-2 -nq 2 -d 1,2 \
+    $ python3 app/l3fwd.py -l 1-2 -nq 2 -d vhost:1,vhost:2 \
       -p 0x03 --config="(0,0,1),(1,0,2)" -fg
-      sudo docker run \
-      -it \
-      ...
-      --vdev virtio_user1,queues=2,path=/var/run/usvhost1 \
-      --vdev virtio_user2,queues=2,path=/var/run/usvhost2 \
-      --file-prefix spp-l3fwd-container1 \
-      -- \
-      -p 0x03 \
-      --config "(0,0,8),(1,0,9)" \
-      --parse-ptype ipv4
-      EAL: Detected 16 lcore(s)
-      EAL: Auto-detected process type: PRIMARY
-      EAL: Multi-process socket /var/run/.spp-l3fwd-container1_unix
-      EAL: Probing VFIO support...
-      soft parse-ptype is enabled
-      LPM or EM none selected, default LPM on
-      Initializing port 0 ... Creating queues: nb_rxq=1 nb_txq=2...
-      LPM: Adding route 0x01010100 / 24 (0)
-      LPM: Adding route 0x02010100 / 24 (1)
-      LPM: Adding route IPV6 / 48 (0)
-      LPM: Adding route IPV6 / 48 (1)
-      txq=8,0,0 txq=9,1,0
-      Initializing port 1 ... Creating queues: nb_rxq=1 nb_txq=2...
-
-      Initializing rx queues on lcore 8 ... rxq=0,0,0
-      Initializing rx queues on lcore 9 ... rxq=1,0,0
-      ...
+     sudo docker run \
+     -it \
+     ...
+     --vdev virtio_user1,queues=2,path=/var/run/usvhost1 \
+     --vdev virtio_user2,queues=2,path=/var/run/usvhost2 \
+     --file-prefix spp-l3fwd-container1 \
+     -- \
+     -p 0x03 \
+     --config "(0,0,8),(1,0,9)" \
+     --parse-ptype ipv4
+    EAL: Detected 16 lcore(s)
+    EAL: Auto-detected process type: PRIMARY
+    EAL: Multi-process socket /var/run/.spp-l3fwd-container1_unix
+    EAL: Probing VFIO support...
+    soft parse-ptype is enabled
+    LPM or EM none selected, default LPM on
+    Initializing port 0 ... Creating queues: nb_rxq=1 nb_txq=2...
+    LPM: Adding route 0x01010100 / 24 (0)
+    LPM: Adding route 0x02010100 / 24 (1)
+    LPM: Adding route IPV6 / 48 (0)
+    LPM: Adding route IPV6 / 48 (1)
+    txq=8,0,0 txq=9,1,0
+    Initializing port 1 ... Creating queues: nb_rxq=1 nb_txq=2...
+
+    Initializing rx queues on lcore 8 ... rxq=0,0,0
+    Initializing rx queues on lcore 9 ... rxq=1,0,0
+    ...
 
 You can increase lcores more than the number of ports, for instance,
 four lcores for two ports.
@@ -389,7 +384,7 @@ It shows options without of EAL and container for simplicity.
 
 .. code-block:: console
 
-    $ python app/l3fwd.py -h
+    $ python3 app/l3fwd.py -h
     usage: l3fwd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                     [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
                     [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -472,38 +467,38 @@ defined as ``virtio_...,queues=2,...``.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/l3fwd-acl.py -l 1-2 -nq 2 -d 1,2 \
-      --rule_ipv4="./rule_ipv4.db" -- rule_ipv6="./rule_ipv6.db" --scalar \
+    $ python3 app/l3fwd-acl.py -l 1-2 -nq 2 -d vhost:1,vhost:2 \
+      --rule_ipv4="./rule_ipv4.db" --rule_ipv6="./rule_ipv6.db" --scalar \
       -p 0x03 --config="(0,0,1),(1,0,2)" -fg
-      sudo docker run \
-      -it \
-      ...
-      --vdev virtio_user1,queues=2,path=/var/run/usvhost1 \
-      --vdev virtio_user2,queues=2,path=/var/run/usvhost2 \
-      --file-prefix spp-l3fwd-container1 \
-      -- \
-      -p 0x03 \
-      --config "(0,0,8),(1,0,9)" \
-      --rule_ipv4="./rule_ipv4.db" \
-      --rule_ipv6="./rule_ipv6.db" \
-      --scalar
-      EAL: Detected 16 lcore(s)
-      EAL: Auto-detected process type: PRIMARY
-      EAL: Multi-process socket /var/run/.spp-l3fwd-container1_unix
-      EAL: Probing VFIO support...
-      soft parse-ptype is enabled
-      LPM or EM none selected, default LPM on
-      Initializing port 0 ... Creating queues: nb_rxq=1 nb_txq=2...
-      LPM: Adding route 0x01010100 / 24 (0)
-      LPM: Adding route 0x02010100 / 24 (1)
-      LPM: Adding route IPV6 / 48 (0)
-      LPM: Adding route IPV6 / 48 (1)
-      txq=8,0,0 txq=9,1,0
-      Initializing port 1 ... Creating queues: nb_rxq=1 nb_txq=2...
-
-      Initializing rx queues on lcore 8 ... rxq=0,0,0
-      Initializing rx queues on lcore 9 ... rxq=1,0,0
-      ...
+     sudo docker run \
+     -it \
+     ...
+     --vdev virtio_user1,queues=2,path=/var/run/usvhost1 \
+     --vdev virtio_user2,queues=2,path=/var/run/usvhost2 \
+     --file-prefix spp-l3fwd-container1 \
+     -- \
+     -p 0x03 \
+     --config "(0,0,8),(1,0,9)" \
+     --rule_ipv4="./rule_ipv4.db" \
+     --rule_ipv6="./rule_ipv6.db" \
+     --scalar
+    EAL: Detected 16 lcore(s)
+    EAL: Auto-detected process type: PRIMARY
+    EAL: Multi-process socket /var/run/.spp-l3fwd-container1_unix
+    EAL: Probing VFIO support...
+    soft parse-ptype is enabled
+    LPM or EM none selected, default LPM on
+    Initializing port 0 ... Creating queues: nb_rxq=1 nb_txq=2...
+    LPM: Adding route 0x01010100 / 24 (0)
+    LPM: Adding route 0x02010100 / 24 (1)
+    LPM: Adding route IPV6 / 48 (0)
+    LPM: Adding route IPV6 / 48 (1)
+    txq=8,0,0 txq=9,1,0
+    Initializing port 1 ... Creating queues: nb_rxq=1 nb_txq=2...
+
+    Initializing rx queues on lcore 8 ... rxq=0,0,0
+    Initializing rx queues on lcore 9 ... rxq=1,0,0
+    ...
 
 You can increase lcores more than the number of ports, for instance,
 four lcores for two ports.
@@ -515,7 +510,7 @@ It shows options without of EAL and container for simplicity.
 
 .. code-block:: console
 
-    $ python app/l3fwd-acl.py -h
+    $ python3 app/l3fwd-acl.py -h
     usage: l3fwd-acl.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                         [--socket-mem SOCKET_MEM]
                         [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -577,15 +572,15 @@ This example is for launching ``testpmd`` in interactive mode.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/testpmd.py -l 6-8 -d 1,2 -fg -i
-    sudo docker run \
+    $ python3 app/testpmd.py -l 6-8 -d vhost:1,vhost:2 -fg -i
+     sudo docker run \
      ...
      -- \
      --interactive
      ...
-     Checking link statuses...
-     Done
-     testpmd>
+    Checking link statuses...
+    Done
+    testpmd>
 
 Testpmd has many useful options. Please refer to
 `Running the Application
@@ -600,7 +595,8 @@ section for instructions.
 
     .. code-block:: console
 
-        $ python app/testpmd.py -l 1,2 -d 1,2 --port-topology=chained
+        $ python3 app/testpmd.py -l 1,2 -d vhost:1,vhost:2 \
+          --port-topology=chained
         Error: '--port-topology' is not supported yet
 
 
@@ -609,7 +605,7 @@ It shows options without of EAL and container.
 
 .. code-block:: console
 
-    $ python app/testpmd.py -h
+    $ python3 app/testpmd.py -h
     usage: testpmd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                       [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
                       [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -819,8 +815,9 @@ and three vhost interfaces.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/pktgen.py -l 8-14 -d 1-3 -fg --dist-ver 16.04
-    sudo docker run \
+    $ python3 app/pktgen.py -l 8-14 -d vhost:1,vhost:2,vhost:3 \
+      -fg --dist-ver 16.04
+     sudo docker run \
      ...
      sppc/pktgen-ubuntu:16.04 \
      /root/dpdk/../pktgen-dpdk/app/x86_64-native-linuxapp-gcc/pktgen \
@@ -846,7 +843,7 @@ calculation is to be complicated.
 .. code-block:: console
 
     # Assign five lcores for a slave is failed to launch
-    $ python app/pktgen.py -l 6-11 -d 1
+    $ python3 app/pktgen.py -l 6-11 -d vhost:1
     Error: Too many cores for calculation for port assignment!
     Please consider to use '--matrix' for assigning directly
 
@@ -859,7 +856,7 @@ Assign one lcore to master and two lcores two slaves for two ports.
 
 .. code-block:: console
 
-    $ python app/pktgen.py -l 6-8 -d 1,2
+    $ python3 app/pktgen.py -l 6-8 -d vhost:1,vhost:2
      ...
      -m 7.0,8.1 \
 
@@ -871,7 +868,7 @@ three slaves for three ports.
 
 .. code-block:: console
 
-    $ python app/pktgen.py -l 6-12 -d 1,2,3
+    $ python3 app/pktgen.py -l 6-12 -d vhost:1,vhost:2,vhost:3
      ...
      -m [7:8].0,[9:10].1,[11:12].2 \
 
@@ -885,7 +882,7 @@ equally, so given two lcores to rx and one core to tx.
 
 .. code-block:: console
 
-    $ python app/pktgen.py -l 6-12 -d 1,2
+    $ python3 app/pktgen.py -l 6-12 -d vhost:1,vhost:2
      ...
      -m [7-8:9].0,[10-11:12].1 \
 
@@ -895,7 +892,7 @@ It shows options without of EAL and container for simplicity.
 
 .. code-block:: console
 
-    $ python app/pktgen.py -h
+    $ python3 app/pktgen.py -h
     usage: pktgen.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                      [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
                      [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -975,9 +972,9 @@ The destination port is defined as ``--lpm`` option.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/load-balancer.py -fg -l 8-10  -d 1,2 \
-    -rx "(0,0,8)" -tx "(0,8),(1,8)" -w 9,10 \
-    --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1;"
+    $ python3 app/load-balancer.py -fg -l 8-10  -d vhost:1,vhost:2 \
+      -rx "(0,0,8)" -tx "(0,8),(1,8)" -w 9,10 \
+      --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1;"
 
 If you are succeeded to launch the app container,
 it shows details of rx, tx, worker lcores and LPM rules
@@ -1076,11 +1073,11 @@ You notice that rx and tx have different lcore number, 8 and 9.
 
 .. code-block:: console
 
-    $ python app/load-balancer.py -fg -l 8-11 -d 1,2 \
-    -rx "(0,0,8)" \
-    -tx "(0,9),(1,9)" \
-    -w 10,11 \
-    --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1;"
+    $ python3 app/load-balancer.py -fg -l 8-11 -d vhost:1,vhost:2 \
+      -rx "(0,0,8)" \
+      -tx "(0,9),(1,9)" \
+      -w 10,11 \
+      --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1;"
 
 **2. Assign multiple queues for rx**
 
@@ -1092,18 +1089,20 @@ or failed to launch.
 
 .. code-block:: console
 
-    $ python app/load-balancer.py -fg -l 8-13 -d 1,2,3 -nq 2 \
-    -rx "(0,0,8),(0,1,8)" \
-    -tx "(0,9),(1,9),(2,9)" \
-    -w 10,11,12,13 \
-    --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1; 1.0.2.0/24=>2;"
+    $ python3 app/load-balancer.py -fg -l 8-13 \
+      -d vhost:1,vhost:2,vhost:3 \
+      -nq 2 \
+      -rx "(0,0,8),(0,1,8)" \
+      -tx "(0,9),(1,9),(2,9)" \
+      -w 10,11,12,13 \
+      --lpm "1.0.0.0/24=>0; 1.0.1.0/24=>1; 1.0.2.0/24=>2;"
 
 
 Refer options and usages by ``load-balancer.py -h``.
 
 .. code-block:: console
 
-    $ python app/load-balancer.py -h
+    $ python3 app/load-balancer.py -h
     usage: load-balancer.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                             [--socket-mem SOCKET_MEM]
                             [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -1171,7 +1170,7 @@ which is built as described in
 .. code-block:: console
 
     $ docker cp your.cnf CONTAINER_ID:/path/to/conf/your.conf
-    $ ./suricata.py -d 1,2 -fg -ci sppc/suricata-ubuntu2:latest
+    $ ./suricata.py -d vhost:1,vhost:2 -fg -ci sppc/suricata-ubuntu2:latest
     # suricata --dpdk=/path/to/config
 
 
@@ -1179,7 +1178,7 @@ Refer options and usages by ``load-balancer.py -h``.
 
 .. code-block:: console
 
-    $ python app/suricata.py -h
+    $ python3 app/suricata.py -h
     usage: suricata.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
                        [--socket-mem SOCKET_MEM]
                        [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
@@ -1223,13 +1222,10 @@ An instruction for developing app container script is described in
 
 Helloworld app container has no application specific options. There are
 only EAL and app container options.
-You should give ``-l``  and ``-d`` options for the simplest app
-container.
-Helloworld application does not use vhost and ``-d`` options is not
-required for the app, but required to setup continer itself.
+You should give ``-l`` option for the simplest app container.
 
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python app/helloworld.py -l 4-6 -d 1 -fg
+    $ python3 app/helloworld.py -l 4-6 -fg
     ...
diff --git a/docs/guides/tools/sppc/getting_started.rst b/docs/guides/tools/sppc/getting_started.rst
index e088661..9a6107a 100644
--- a/docs/guides/tools/sppc/getting_started.rst
+++ b/docs/guides/tools/sppc/getting_started.rst
@@ -86,15 +86,17 @@ All of images are referred from ``docker images`` command.
 
 .. note::
 
-    The Name of containers is defined as a set of target, name and
+    The Name of container image is defined as a set of target, name and
     version of Linux distoribution.
-    For example, container image targetting dpdk apps on Ubuntu 16.04
-    is named as ``sppc/dpdk-ubuntu:16.04``.
+    For example, container image targetting dpdk apps on Ubuntu 18.04
+    is named as ``sppc/dpdk-ubuntu:18.04``.
 
-    Build script understands which of Dockerfile should be used based
+    There are several Dockerfiles for supporting several applications and
+    distro versions under ``build/ubuntu/``.
+    Build script understands which of Dockerfiles should be used based
     on the given options.
-    If you run build script with options for dpdk and Ubuntu 16.04 as
-    below, it finds ``build/ubuntu/dpdk/Dockerfile.16.04`` and runs
+    If you run build script with options for dpdk and Ubuntu 18.04 as
+    below, it finds ``build/ubuntu/dpdk/Dockerfile.18.04`` and runs
     ``docker build``.
     Options for Linux distribution have default value, ``ubuntu`` and
     ``latest``. So, you do not need to specify them if you use default.
@@ -112,14 +114,8 @@ All of images are referred from ``docker images`` command.
         $ python build/main.py -t dpdk --dist-ver 16.04
 
 
-.. warning::
-
-    Currently, the latest version of Ubuntu is 18.04 and DPDK is 18.05.
-    However, SPP is not stable on the latest versions, especially
-    running on containers.
-
-    It is better to use Ubuntu 16.04 and DPDK 18.02 for SPP containers
-    until be stabled.
+    Version of other than distro is also configurable by specifying a branch
+    number via command line options.
 
     .. code-block:: console
 
@@ -134,15 +130,20 @@ All of images are referred from ``docker images`` command.
 Launch SPP and App Containers
 -----------------------------
 
-Before launch containers, you should set IP address of host machine
-as ``SPP_CTL_IP`` environment variable
-for controller to be accessed from inside containers.
-It is better to define this variable in ``$HOME/.bashrc``.
+.. note::
+
+    In usecase described in this chapter, SPP processes other than
+    ``spp-ctl`` and CLI are containerized, but it is available to run as on
+    host for communicating with other container applications.
+
+Before launch containers, you should set IP address of host machine as
+``SPP_CTL_IP`` environment variable for controller to be accessed from
+inside containers.
 
 .. code-block:: console
 
     # Set your host IP address
-    export SPP_CTL_IP=HOST_IPADDR
+    $ export SPP_CTL_IP=YOUR_HOST_IPADDR
 
 
 SPP Controller
@@ -153,14 +154,14 @@ processes.
 
 .. note::
 
-    SPP controller provides ``topo term`` which shows network
-    topology in a terminal.
+    SPP controller also provides ``topo term`` command for containers which
+    shows network topology in a terminal.
 
     However, there are a few terminals supporing this feature.
     ``mlterm`` is the most useful and easy to customize.
     Refer :doc:`../../commands/experimental` for ``topo`` command.
 
-``spp-ctl`` is launched in the termina l.
+``spp-ctl`` is launched in the terminal 1.
 
 .. code-block:: console
 
@@ -180,11 +181,9 @@ processes.
 SPP Primary Container
 ~~~~~~~~~~~~~~~~~~~~~
 
-As ``SPP_CTL_IP`` is activated, you are enalbed to run
-``app/spp-primary.py`` with options of EAL and SPP primary
-in terminal 3.
-In this case, launch spp-primary in background mode using one core
-and two ports.
+As ``SPP_CTL_IP`` is activated, it is able to run ``app/spp-primary.py``
+with options. In this case, launch ``spp_primary`` in background mode using
+one core and two physical ports in terminal 3.
 
 .. code-block:: console
 
@@ -196,12 +195,11 @@ and two ports.
 SPP Secondary Container
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-For secondary process, ``spp_nfv`` is only supported for running on container
-currently.
+``spp_nfv`` is only supported for running on container currently.
 
-Launch ``spp_nfv`` in terminal 3
-with options for secondary ID is ``1`` and
-core list is ``1-2`` for using 2nd and 3rd cores.
+Launch ``spp_nfv`` in terminal 3 with options for secondary ID is
+``1`` and core list is ``1-2`` for using 2nd and 3rd cores.
+It is also run in background mode.
 
 .. code-block:: console
 
@@ -209,7 +207,7 @@ core list is ``1-2`` for using 2nd and 3rd cores.
     $ python app/spp-nfv.py -i 1 -l 1-2
 
 If it is succeeded, container is running in background.
-You can find it with ``docker -ps`` command.
+You can find it with ``docker ps`` command.
 
 
 App Container
@@ -224,39 +222,13 @@ before launching the app container.
 .. code-block:: console
 
     # Terminal 2
-    spp > nfv 1; add vhost 1
-    spp > nfv 1; add vhost 2
-
-``spp_nfv`` of ID 1 running inside container creates
-``vhost:1`` and ``vhost:2``.
-Vhost PMDs are referred as an option ``-d 1,2`` from the
-app container launcher.
-
-.. code-block:: console
+    spp > nfv 1; add vhost:1
+    spp > nfv 1; add vhost:2
 
-    # Terminal 3
-    $ cd /path/to/spp/tools/sppc
-    $ app/testpmd.py -l 3-4 -d 1,2
-    sudo docker run -it \
-    ...
-    EAL: Detected 16 lcore(s)
-    EAL: Auto-detected process type: PRIMARY
-    EAL: Multi-process socket /var/run/.testpmd1_unix
-    EAL: Probing VFIO support...
-    EAL: VFIO support initialized
-    Interactive-mode selected
-    Warning: NUMA should be configured manually by using --port-numa-...
-    testpmd: create a new mbuf pool <mbuf_pool_socket_0>: n=155456,...
-    testpmd: preferred mempool ops selected: ring_mp_mc
-    Configuring Port 0 (socket 0)
-    Port 0: 32:CB:1D:72:68:B9
-    Configuring Port 1 (socket 0)
-    Port 1: 52:73:C3:5B:94:F1
-    Checking link statuses...
-    Done
-    testpmd>
-
-It launches ``testpmd`` in foreground mode.
+``spp_nfv`` of ID 1 running inside container creates ``vhost:1`` and
+``vhost:2``. So assign them to ``testpmd`` with ``-d`` option which is for
+attaching vdevs as a comma separated list of resource UIDs in SPP.
+``testpmd`` is launched in foreground mode with ``-fg`` option in this case.
 
 .. note::
 
@@ -268,10 +240,8 @@ It launches ``testpmd`` in foreground mode.
     ``--pci-blacklist`` EAL option to exclude ports on host. PCI address of
     port can be inspected by using ``dpdk-devbind.py -s``.
 
-If you have ports on host and assign them to SPP, you should to exclude them
-from the app container by specifying PCI addresses of the ports with ``-b``
-or ``--pci-blacklist``.
-
+To exclude ``testpmd`` container tries to own physical ports, you should
+specify PCI addresses of the ports with ``-b`` or ``--pci-blacklist``.
 You can find PCI addresses from ``dpdk-devbind.py -s``.
 
 .. code-block:: console
@@ -294,13 +264,15 @@ with ``-b`` option.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ app/testpmd.py -l 3-4 -d 1,2 \
+    $ app/testpmd.py -l 3-4 \
+      -d vhost:1,vhost:2 \
+      -fg \
       -b 0000:0a:00.0 0000:0a:00.1
-    sudo docker run -it \
-    ...
-    -b 0000:0a:00.0 \
-    -b 0000:0a:00.1 \
-    ...
+     sudo docker run -it \
+     ...
+     -b 0000:0a:00.0 \
+     -b 0000:0a:00.1 \
+     ...
 
 
 .. _sppc_gs_run_apps:
@@ -326,16 +298,19 @@ with it.
 .. code-block:: console
 
     # Terminal 2
-    spp > nfv 1; add ring 0
+    spp > nfv 1; add ring:0
     spp > nfv 1; patch vhost:1 ring:0
     spp > nfv 1; patch ring:0 vhost:2
     spp > nfv 1; forward
     spp > nfv 1; status
-    status: running
-    ports:
-      - 'ring:0 -> vhost:2'
-      - 'vhost:1 -> ring:0'
-      - 'vhost:2'
+    - status: running
+    - lcore_ids:
+      - master: 1
+      - slave: 2
+    - ports:
+      - ring:0 -> vhost:2
+      - vhost:1 -> ring:0
+      - vhost:2
 
 Start forwarding on port 0 by ``start tx_first``.
 
diff --git a/docs/guides/tools/sppc/usecases.rst b/docs/guides/tools/sppc/usecases.rst
index 80f0fac..8da7fd2 100644
--- a/docs/guides/tools/sppc/usecases.rst
+++ b/docs/guides/tools/sppc/usecases.rst
@@ -65,7 +65,7 @@ Then, ``spp.py`` in terminal 2.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 Move to terminal 3, launch app containers of ``spp_primary``
 and ``spp_nfv`` step by step in background mode.
@@ -79,27 +79,27 @@ You can also assign a physical port instead of this vhost device.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x01 -dv 1
-    $ python app/spp-nfv.py -i 1 -l 1-2
-    $ python app/spp-nfv.py -i 2 -l 3-4
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 1
+    $ python3 app/spp-nfv.py -i 1 -l 1-2
+    $ python3 app/spp-nfv.py -i 2 -l 3-4
 
 Then, add two vhost PMDs for pktgen app container from SPP CLI.
 
 .. code-block:: console
 
     # Terminal 2
-    spp > nfv 1; add vhost 1
-    spp > nfv 2; add vhost 2
+    spp > nfv 1; add vhost:1
+    spp > nfv 2; add vhost:2
 
 It is ready for launching pktgen app container. In this usecase,
 use five lcores for pktgen. One lcore is used for master, and remaining
 lcores are used for rx and tx evenly.
-Device ID option ``-d 1,2`` is for refferring vhost 1 and 2.
+Device ID option ``-d vhost:1,vhost:2`` is for refferring vhost 1 and 2.
 
 .. code-block:: console
 
     # Terminal 3
-    $ python app/pktgen.py -fg -l 5-9 -d 1,2
+    $ python3 app/pktgen.py -fg -l 5-9 -d vhost:1,vhost:2
 
 Finally, configure network path from SPP controller,
 
@@ -115,7 +115,7 @@ and start forwarding from pktgen.
 
 .. code-block:: console
 
-    # Terminal 2
+    # Terminal 3
     $ Pktgen:/> start 1
 
 You find that packet count of rx of port 0 and tx of port 1
@@ -165,7 +165,7 @@ Then, launch ``spp.py`` in terminal 2.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 In terminal 3, launch ``spp_primary`` and ``spp_nfv`` containers
 in background mode.
@@ -176,11 +176,11 @@ portmask option.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x03
-    $ python app/spp-nfv.py -i 1 -l 1-2
-    $ python app/spp-nfv.py -i 2 -l 3-4
-    $ python app/spp-nfv.py -i 3 -l 5-6
-    $ python app/spp-nfv.py -i 4 -l 7-8
+    $ python3 app/spp-primary.py -l 0 -p 0x03
+    $ python3 app/spp-nfv.py -i 1 -l 1-2
+    $ python3 app/spp-nfv.py -i 2 -l 3-4
+    $ python3 app/spp-nfv.py -i 3 -l 5-6
+    $ python3 app/spp-nfv.py -i 4 -l 7-8
 
 
 .. note::
@@ -196,7 +196,7 @@ portmask option.
 
     .. code-block:: console
 
-        $ python tools/spp-launcher.py -n 4
+        $ python3 tools/spp-launcher.py -n 4
 
     You will find that lcore assignment is the same as below.
     Lcore is assigned from 0 for primary, and next two lcores for the
@@ -204,11 +204,11 @@ portmask option.
 
     .. code-block:: console
 
-        $ python app/spp-primary.py -l 0 -p 0x03
-        $ python app/spp-nfv.py -i 1 -l 1,2
-        $ python app/spp-nfv.py -i 2 -l 3,4
-        $ python app/spp-nfv.py -i 3 -l 5,6
-        $ python app/spp-nfv.py -i 4 -l 7,8
+        $ python3 app/spp-primary.py -l 0 -p 0x03
+        $ python3 app/spp-nfv.py -i 1 -l 1,2
+        $ python3 app/spp-nfv.py -i 2 -l 3,4
+        $ python3 app/spp-nfv.py -i 3 -l 5,6
+        $ python3 app/spp-nfv.py -i 4 -l 7,8
 
     You can also assign lcores with ``--shared`` to master lcore
     be shared among ``spp_nfv`` processes.
@@ -217,18 +217,18 @@ portmask option.
 
     .. code-block:: console
 
-        $ python tools/spp-launcher.py -n 4 --shared
+        $ python3 tools/spp-launcher.py -n 4 --shared
 
     The result of assignment of this command is the same as below.
     Master lcore 1 is shared among secondary processes.
 
     .. code-block:: console
 
-        $ python app/spp-primary.py -l 0 -p 0x03
-        $ python app/spp-nfv.py -i 1 -l 1,2
-        $ python app/spp-nfv.py -i 2 -l 1,3
-        $ python app/spp-nfv.py -i 3 -l 1,4
-        $ python app/spp-nfv.py -i 4 -l 1,5
+        $ python3 app/spp-primary.py -l 0 -p 0x03
+        $ python3 app/spp-nfv.py -i 1 -l 1,2
+        $ python3 app/spp-nfv.py -i 2 -l 1,3
+        $ python3 app/spp-nfv.py -i 3 -l 1,4
+        $ python3 app/spp-nfv.py -i 4 -l 1,5
 
 Add ring PMDs considering which of rings is shared between which of
 containers.
@@ -311,7 +311,7 @@ First of all, launch ``spp-ctl`` and ``spp.py``.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 Then, launch ``spp_primary`` and ``spp_nfv`` containers in background.
 It does not use physical NICs as similar to
@@ -322,11 +322,11 @@ Use four of ``spp_nfv`` containers for using four vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x01 -dv 9
-    $ python app/spp-nfv.py -i 1 -l 1-2
-    $ python app/spp-nfv.py -i 2 -l 3-4
-    $ python app/spp-nfv.py -i 3 -l 5-6
-    $ python app/spp-nfv.py -i 4 -l 7-8
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-nfv.py -i 1 -l 1-2
+    $ python3 app/spp-nfv.py -i 2 -l 3-4
+    $ python3 app/spp-nfv.py -i 3 -l 5-6
+    $ python3 app/spp-nfv.py -i 4 -l 7-8
 
 Assign ring and vhost PMDs. Each of vhost IDs to be the same as
 its secondary ID.
@@ -353,7 +353,7 @@ In this case, ``pktgen`` container owns vhost 1 and 2,
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/pktgen.py -l 9-11 -d 1,2
+    $ python3 app/pktgen.py -l 9-11 -d vhost:1,vhost:2
 
 and ``l2fwd`` container owns vhost 3 and 4.
 
@@ -361,7 +361,7 @@ and ``l2fwd`` container owns vhost 3 and 4.
 
     # Terminal 4
     $ cd /path/to/spp/tools/sppc
-    $ python app/l2fwd.py -l 12-13 -d 3,4
+    $ python app/l2fwd.py -l 12-13 -d vhost:3,vhost:4
 
 
 Then, configure network path by pactching each of ports
@@ -419,7 +419,7 @@ First of all, launch ``spp-ctl`` and ``spp.py``.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 Launch ``spp_primary`` and ``spp_nfv`` containers in background.
 It does not use physical NICs as similar to
@@ -430,9 +430,9 @@ Use two of ``spp_nfv`` containers for using four vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x01 -dv 9
-    $ python app/spp-nfv.py -i 1 -l 1,2
-    $ python app/spp-nfv.py -i 2 -l 1,3
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-nfv.py -i 1 -l 1,2
+    $ python3 app/spp-nfv.py -i 2 -l 1,3
 
 The number of process and CPUs are fewer than previous example.
 You can reduce the number of ``spp_nfv`` processes by assigning
@@ -464,7 +464,7 @@ In this case, ``pktgen`` container uses vhost 1 and 2,
 .. code-block:: console
 
     # Terminal 3
-    $ python app/pktgen.py -l 1,4,5 -d 1,2
+    $ python app/pktgen.py -l 1,4,5 -d vhost:1,vhost:2
 
 and ``l2fwd`` container uses vhost 3 and 4.
 
@@ -472,7 +472,7 @@ and ``l2fwd`` container uses vhost 3 and 4.
 
     # Terminal 4
     $ cd /path/to/spp/tools/sppc
-    $ python app/l2fwd.py -l 1,6 -d 3,4
+    $ python app/l2fwd.py -l 1,6 -d vhost:3,vhost:4
 
 
 Then, configure network path by pactching each of ports
@@ -548,7 +548,7 @@ First of all, launch ``spp-ctl`` and ``spp.py``.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 Launch ``spp_primary`` and ``spp_nfv`` containers in background.
 It does not use physical NICs as similar to
@@ -559,13 +559,13 @@ Use six ``spp_nfv`` containers for using six vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x01 -dv 9
-    $ python app/spp-nfv.py -i 1 -l 1,2
-    $ python app/spp-nfv.py -i 2 -l 1,3
-    $ python app/spp-nfv.py -i 3 -l 1,4
-    $ python app/spp-nfv.py -i 4 -l 1,5
-    $ python app/spp-nfv.py -i 5 -l 1,6
-    $ python app/spp-nfv.py -i 6 -l 1,7
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-nfv.py -i 1 -l 1,2
+    $ python3 app/spp-nfv.py -i 2 -l 1,3
+    $ python3 app/spp-nfv.py -i 3 -l 1,4
+    $ python3 app/spp-nfv.py -i 4 -l 1,5
+    $ python3 app/spp-nfv.py -i 5 -l 1,6
+    $ python3 app/spp-nfv.py -i 6 -l 1,7
 
 Assign ring and vhost PMDs. Each of vhost IDs to be the same as
 its secondary ID.
@@ -624,7 +624,7 @@ For ``pktgen`` container, assign lcores 8-10 and vhost 1-3.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/pktgen.py -l 8-10 -d 1-3 -T
+    $ python3 app/pktgen.py -l 8-10 -d vhost:1,vhost:2,vhost:3 -T
 
 
 For ``load_balancer`` container, assign lcores 12-15 and vhost 4-6.
@@ -636,7 +636,9 @@ or more queues. In this case, assign 4 queues.
 
     # Terminal 4
     $ cd /path/to/spp/tools/sppc
-    $ python app/load_balancer.py -l 11-14 -d 4-6 -fg -nq 4
+    $ python3 app/load_balancer.py -l 11-14 \
+      -d vhost:4,vhost:5,vhost:6 \
+      -fg -nq 4 \
       -rx "(0,0,11),(0,1,11),(0,2,11)" \
       -tx "(0,12),(1,12),(2,12)" \
       -w 13,14 \
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 25/29] docs: update versions in examples in sppc
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (23 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 24/29] docs: revise examples in sppc Yasufumi Ogawa
@ 2020-02-25 10:34 ` " Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 26/29] docs: update old example in spp_primary container Yasufumi Ogawa
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

In examples, versions of Ubuntu and DPDK are just bit old. This patch
is update them.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/app_launcher.rst    | 20 ++--------
 docs/guides/tools/sppc/build_img.rst       | 44 +++++++++++-----------
 docs/guides/tools/sppc/getting_started.rst | 32 ++++++++--------
 docs/guides/tools/sppc/usecases.rst        | 11 ------
 4 files changed, 41 insertions(+), 66 deletions(-)

diff --git a/docs/guides/tools/sppc/app_launcher.rst b/docs/guides/tools/sppc/app_launcher.rst
index 4d6492b..f1a590d 100644
--- a/docs/guides/tools/sppc/app_launcher.rst
+++ b/docs/guides/tools/sppc/app_launcher.rst
@@ -29,18 +29,6 @@ inside a container.
     ---- testpmd.py
 
 
-.. note::
-
-    As described in
-    :ref:`sppc_gs_build_docker_imgs`
-    section, you had better to use Ubuntu 16.04 with
-    ``--dist-ver`` option because SPP container is not stable for running
-    on the latest version.
-
-    Please notice that examples in this section does not use ``dist-ver``
-    options explicitly for simplicity.
-
-
 .. _sppc_appl_setup:
 
 Setup
@@ -816,10 +804,10 @@ and three vhost interfaces.
 
     $ cd /path/to/spp/tools/sppc
     $ python3 app/pktgen.py -l 8-14 -d vhost:1,vhost:2,vhost:3 \
-      -fg --dist-ver 16.04
+      -fg
      sudo docker run \
      ...
-     sppc/pktgen-ubuntu:16.04 \
+     sppc/pktgen-ubuntu:latest \
      /root/dpdk/../pktgen-dpdk/app/x86_64-native-linuxapp-gcc/pktgen \
      -l 8-14 \
      ...
@@ -1018,8 +1006,8 @@ and kill it.
 
     $ docker ps
     CONTAINER ID  IMAGE                   ...  NAMES
-    80ce3711b85e  sppc/dpdk-ubuntu:16.04  ...  competent_galileo  # kill it
-    281aa8f236ef  sppc/spp-ubuntu:16.04   ...  youthful_mcnulty
+    80ce3711b85e  sppc/dpdk-ubuntu:latest ...  competent_galileo  # kill it
+    281aa8f236ef  sppc/spp-ubuntu:latest  ...  youthful_mcnulty
     $ docker kill competent_galileo
 
 
diff --git a/docs/guides/tools/sppc/build_img.rst b/docs/guides/tools/sppc/build_img.rst
index 21046a1..148b5d4 100644
--- a/docs/guides/tools/sppc/build_img.rst
+++ b/docs/guides/tools/sppc/build_img.rst
@@ -19,14 +19,15 @@ with DPDK 18.11 as following.
 .. code-block:: console
 
     $ cd /path/to/spp/tools/sppc
-    $ python build/main.py --dpdk-branch v18.11 \
+    $ python3 build/main.py -t spp \
+      --dpdk-branch v18.11 \
       --spp-repo https://github.com/your/spp.git
 
 Refer all of options running with ``-h`` option.
 
 .. code-block:: console
 
-    $ python build/main.py -h
+    $ python3 build/main.py -h
     usage: main.py [-h] [-t TARGET] [-ci CONTAINER_IMAGE]
                    [--dist-name DIST_NAME] [--dist-ver DIST_VER]
                    [--dpdk-repo DPDK_REPO] [--dpdk-branch DPDK_BRANCH]
@@ -74,8 +75,8 @@ Version Control for Images
 
 SPP container provides version control as combination of
 target name, Linux distribution name and version.
-Built images are referred such as ``sppc/dpdk-ubuntu:latest`` or
-``sppc/spp-ubuntu:16.04``.
+Built images are referred such as ``sppc/dpdk-ubuntu:latest``,
+``sppc/spp-ubuntu:16.04`` or so.
 ``sppc`` is just a prefix to indicate an image of SPP container.
 
 Build script decides a name from given options or default values.
@@ -85,10 +86,10 @@ name and version, it uses default values ``ubuntu`` and ``latest``.
 .. code-block:: console
 
     # build 'sppc/dpdk-ubuntu:latest'
-    $ python build/main.py -t dpdk
+    $ python3 build/main.py -t dpdk
 
     # build 'sppc/spp-ubuntu:16.04'
-    $ python build/main.py -t spp --dist-ver 16.04
+    $ python3 build/main.py -t spp --dist-ver 16.04
 
 .. note::
 
@@ -104,28 +105,28 @@ name and version, it uses default values ``ubuntu`` and ``latest``.
 
 
 App container scripts also understand this naming rule.
-For launching ``testpmd`` on Ubuntu 16.04,
+For launching ``testpmd`` on Ubuntu 18.04,
 simply give ``--dist-ver`` to indicate the version and other options
 for ``testpmd`` itself.
 
 .. code-block:: console
 
-    # launch testpmd on 'sppc/dpdk-ubuntu:16.04'
-    $ python app/testpmd.py --dist-ver 16.04 -l 3-4 ...
+    # launch testpmd on 'sppc/dpdk-ubuntu:18.04'
+    $ python3 app/testpmd.py --dist-ver 18.04 -l 3-4 ...
 
 But, how can we build images for different versions of DPDK,
-such as 17.11 and 18.05, on the same distribution?
+such as 18.11 and 19.11, on the same distribution?
 In this case, you can use ``--container-image`` or ``-ci`` option for
 using any of names. It is also referred from app container scripts.
 
 .. code-block:: console
 
     # build image with arbitrary name
-    $ python build/main.py -t dpdk -ci sppc/dpdk17.11-ubuntu:latest \
-      --dpdk-branch v17.11
+    $ python3 build/main.py -t dpdk -ci sppc/dpdk18.11-ubuntu:latest \
+      --dpdk-branch v18.11
 
     # launch testpmd with '-ci'
-    $ python app/testpmd.py -ci sppc/dpdk17.11-ubuntu:latest -l 3-4 ...
+    $ python3 app/testpmd.py -ci sppc/dpdk18.11-ubuntu:latest -l 3-4 ...
 
 
 .. _sppc_build_img_dockerfiles:
@@ -177,21 +178,20 @@ script. However, building suricata requires few additional few steps.
 
 
 First, build an image with ``main.py`` script as similar to other apps.
-In this example, use DPDK v18.11 and Ubuntu 16.04.
+In this example, use DPDK v18.11 and Ubuntu 18.04.
 
 .. code-block:: console
 
-    $ python build/main.py -t suricata --dpdk-branch v18.11 --dist-ver 16.04
+    $ python3 build/main.py -t suricata --dpdk-branch v18.11 --dist-ver 18.04
 
 After build is completed, you can find image named as
-``sppc/suricata-ubuntu:16.04`` from ``docker images``.
+``sppc/suricata-ubuntu:18.04`` from ``docker images``.
 Run bash command with this image, and execute an installer script in home
 directory which is created while building.
 
 .. code-block:: console
 
-    sppc/suricata-ubuntu  16.04 ...
-    $ docker run -it sppc/suricata-ubuntu:16.04 /bin/bash
+    $ docker run -it sppc/suricata-ubuntu:18.04 /bin/bash
     # ./install_suricata.sh
 
 It clones and compiles suricata under home directory. You can find
@@ -204,14 +204,14 @@ with ``docker commit`` command.
 
 Logout and create a new docker image with ``docker commit`` image's
 container ID. In this example, new image is named as
-`sppc/suricata-ubuntu2:16.04`.
+`sppc/suricata-ubuntu2:18.04`.
 
 .. code-block:: console
 
     # exit
     $ docker ps -a
-    CONTAINER_ID  sppc/suricata-ubuntu:16.04  "/bin/bash"  3 minutes ...
-    $ docker commit CONTAINER_ID sppc/suricata-ubuntu2:16.04
+    CONTAINER_ID  sppc/suricata-ubuntu:18.04  "/bin/bash"  3 minutes ...
+    $ docker commit CONTAINER_ID sppc/suricata-ubuntu2:18.04
 
 You can run compiled suricata with the new image with docker as following,
 or app container launcher with specific options as described in.
@@ -219,7 +219,7 @@ or app container launcher with specific options as described in.
 
 .. code-block:: console
 
-    $ docker run -it sppc/suricata-ubuntu:16.04 /bin/bash
+    $ docker run -it sppc/suricata-ubuntu:18.04 /bin/bash
     # suricata --build-info
 
 
diff --git a/docs/guides/tools/sppc/getting_started.rst b/docs/guides/tools/sppc/getting_started.rst
index 9a6107a..ac8cc68 100644
--- a/docs/guides/tools/sppc/getting_started.rst
+++ b/docs/guides/tools/sppc/getting_started.rst
@@ -53,21 +53,19 @@ for the latest DPDK, pktgen or SPP.
 
     # Terminal 1
     $ cd /path/to/spp/tools/sppc
-    $ python build/main.py -t dpdk
-    $ python build/main.py -t pktgen
-    $ python build/main.py -t spp
+    $ python3 build/main.py -t dpdk
+    $ python3 build/main.py -t pktgen
+    $ python3 build/main.py -t spp
 
 Of course DPDK is required from pktgen and SPP, and it causes a
 problem of compatibility between them sometimes.
-At the time writing this document, SPP v18.02 is not compatible with
-the latest DPDK v18.05 and it is failed to compile.
 In this case, you should build SPP with ``--dpdk-branch`` option to tell
 the version of DPDK explicitly.
 
 .. code-block:: console
 
     # Terminal 1
-    $ python build/main.py -t spp --dpdk-branch v18.02
+    $ python3 build/main.py -t spp --dpdk-branch v19.11
 
 You can find all of options by ``build/main.py -h``.
 
@@ -105,13 +103,13 @@ All of images are referred from ``docker images`` command.
     .. code-block:: console
 
         # latest DPDK on latest Ubuntu
-        $ python build/main.py -t dpdk --dist-name ubuntu --dist-ver latest
+        $ python3 build/main.py -t dpdk --dist-name ubuntu --dist-ver latest
 
         # it is also the same
-        $ python build/main.py -t dpdk
+        $ python3 build/main.py -t dpdk
 
-        # or use Ubuntu 16.04
-        $ python build/main.py -t dpdk --dist-ver 16.04
+        # or use Ubuntu 18.04
+        $ python3 build/main.py -t dpdk --dist-ver 18.04
 
 
     Version of other than distro is also configurable by specifying a branch
@@ -119,10 +117,10 @@ All of images are referred from ``docker images`` command.
 
     .. code-block:: console
 
-        $ python build/main.py -t dpdk --dist-ver 16.04 --dpdk-branch v18.02
-        $ python build/main.py -t pktgen --dist-ver 16.04 \
+        $ python3 build/main.py -t dpdk --dist-ver 18.04 --dpdk-branch v19.11
+        $ python3 build/main.py -t pktgen --dist-ver 18.04 \
           --dpdk-branch v18.02 --pktgen-branch pktgen-3.4.9
-        $ python build/main.py -t spp --dist-ver 16.04 --dpdk-branch v18.02
+        $ python3 build/main.py -t spp --dist-ver 18.04 --dpdk-branch v19.11
 
 
 .. _sppc_gs_launch_containers:
@@ -175,7 +173,7 @@ processes.
 
     # Terminal 2
     $ cd /path/to/spp
-    $ python src/spp.py
+    $ python3 src/spp.py
 
 
 SPP Primary Container
@@ -189,7 +187,7 @@ one core and two physical ports in terminal 3.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python app/spp-primary.py -l 0 -p 0x03
+    $ python3 app/spp-primary.py -l 0 -p 0x03
 
 
 SPP Secondary Container
@@ -204,7 +202,7 @@ It is also run in background mode.
 .. code-block:: console
 
     # Terminal 3
-    $ python app/spp-nfv.py -i 1 -l 1-2
+    $ python3 app/spp-nfv.py -i 1 -l 1-2
 
 If it is succeeded, container is running in background.
 You can find it with ``docker ps`` command.
@@ -264,7 +262,7 @@ with ``-b`` option.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ app/testpmd.py -l 3-4 \
+    $ python3 app/testpmd.py -l 3-4 \
       -d vhost:1,vhost:2 \
       -fg \
       -b 0000:0a:00.0 0000:0a:00.1
diff --git a/docs/guides/tools/sppc/usecases.rst b/docs/guides/tools/sppc/usecases.rst
index 8da7fd2..8d3b73d 100644
--- a/docs/guides/tools/sppc/usecases.rst
+++ b/docs/guides/tools/sppc/usecases.rst
@@ -19,17 +19,6 @@ using expensive servers.
 
 This chapter describes examples of simple use cases of SPP container.
 
-.. note::
-
-    As described in
-    :ref:`sppc_gs_build_docker_imgs`
-    section, you had better to use Ubuntu 16.04 with
-    ``--dist-ver`` option because SPP container is not stable for running
-    on the latest version.
-
-    Please notice that examples in this section does not use ``dist-ver``
-    options explicitly for simplicity.
-
 
 .. _sppc_usecases_test_vhost_single:
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 26/29] docs: update old example in spp_primary container
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (24 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 25/29] docs: update versions in " Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 27/29] tools/sppc: python3 support for sppc build tool Yasufumi Ogawa
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Replace old vdev assignment of vhost with tap.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/usecases.rst | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/docs/guides/tools/sppc/usecases.rst b/docs/guides/tools/sppc/usecases.rst
index 8d3b73d..1bd5e0f 100644
--- a/docs/guides/tools/sppc/usecases.rst
+++ b/docs/guides/tools/sppc/usecases.rst
@@ -58,8 +58,8 @@ Then, ``spp.py`` in terminal 2.
 
 Move to terminal 3, launch app containers of ``spp_primary``
 and ``spp_nfv`` step by step in background mode.
-You notice that vhost device is attached with ``-dv 1`` which is not used
-actually.
+You notice that vhost device is attached with ``-d tap:1`` which is not
+required if you have physical ports on host.
 It is because that SPP primary requires at least one port even if
 it is no need.
 You can also assign a physical port instead of this vhost device.
@@ -68,7 +68,7 @@ You can also assign a physical port instead of this vhost device.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 1
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -d tap:1
     $ python3 app/spp-nfv.py -i 1 -l 1-2
     $ python3 app/spp-nfv.py -i 2 -l 3-4
 
@@ -311,7 +311,7 @@ Use four of ``spp_nfv`` containers for using four vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -d tap:1
     $ python3 app/spp-nfv.py -i 1 -l 1-2
     $ python3 app/spp-nfv.py -i 2 -l 3-4
     $ python3 app/spp-nfv.py -i 3 -l 5-6
@@ -419,7 +419,7 @@ Use two of ``spp_nfv`` containers for using four vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -d tap:1
     $ python3 app/spp-nfv.py -i 1 -l 1,2
     $ python3 app/spp-nfv.py -i 2 -l 1,3
 
@@ -548,7 +548,7 @@ Use six ``spp_nfv`` containers for using six vhost PMDs.
 
     # Terminal 3
     $ cd /path/to/spp/tools/sppc
-    $ python3 app/spp-primary.py -l 0 -p 0x01 -dv 9
+    $ python3 app/spp-primary.py -l 0 -p 0x01 -d tap:1
     $ python3 app/spp-nfv.py -i 1 -l 1,2
     $ python3 app/spp-nfv.py -i 2 -l 1,3
     $ python3 app/spp-nfv.py -i 3 -l 1,4
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 27/29] tools/sppc: python3 support for sppc build tool
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (25 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 26/29] docs: update old example in spp_primary container Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 28/29] docs: update app container help msg Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 29/29] docs: update howto define app container guide Yasufumi Ogawa
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Although python2 support was dropped in SPP itself, it is still
remained in SPP container tools. This update is to make the tools run
with python3.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/build/main.py | 81 +++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 38 deletions(-)

diff --git a/tools/sppc/build/main.py b/tools/sppc/build/main.py
index 023ec82..c0d02d2 100755
--- a/tools/sppc/build/main.py
+++ b/tools/sppc/build/main.py
@@ -1,8 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
-from __future__ import absolute_import
 import argparse
 import os
 import subprocess
@@ -86,22 +85,22 @@ def parse_args():
 
 
 def create_env_sh(dst_dir, rte_sdk, target, target_dir):
-    """Create config file for DPDK environment variables
+    """Create config file for DPDK environment variables.
 
     Create 'env.sh' which defines $RTE_SDK and $RTE_TARGET inside a
     container to be referredd from 'run.sh' and Dockerfile.
     """
-    contents = "export RTE_SDK=%s\n" % rte_sdk
-    contents += "export RTE_TARGET=%s\n" % env.RTE_TARGET
+    contents = "export RTE_SDK={:s}\n".format(rte_sdk)
+    contents += "export RTE_TARGET={:s}\n".format(env.RTE_TARGET)
     if target == 'pktgen':
-        contents += "export PKTGEN_DIR=%s" % target_dir
+        contents += "export PKTGEN_DIR={:s}".format(target_dir)
     elif target == 'spp':
-        contents += "export SPP_DIR=%s" % target_dir
+        contents += "export SPP_DIR={:s}".format(target_dir)
     elif target == 'suricata':
-        contents += "export SURICATA_DIR=%s" % target_dir
+        contents += "export SURICATA_DIR={:s}".format(target_dir)
 
     try:
-        f = open('%s/env.sh' % dst_dir, 'w')
+        f = open('{:s}/env.sh'.format(dst_dir), 'w')
         f.write(contents)
         f.close()
     except IOError:
@@ -112,7 +111,7 @@ def main():
     args = parse_args()
 
     if args.target is not None:
-        dockerfile_dir = '%s/%s/%s' % (  # Dockerfile is contained here
+        dockerfile_dir = '{:s}/{:s}/{:s}'.format(  # Dockerfile is here
             work_dir, args.dist_name, args.target)
         # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
         container_image = common.container_img_name(
@@ -124,7 +123,7 @@ def main():
         exit()
 
     # Decide which of Dockerfile with given base image version
-    dockerfile = '%s/Dockerfile.%s' % (dockerfile_dir, args.dist_ver)
+    dockerfile = '{:s}/Dockerfile.{:s}'.format(dockerfile_dir, args.dist_ver)
 
     # Overwrite container's name if it is given.
     if args.container_image is not None:
@@ -132,22 +131,22 @@ def main():
 
     # Setup branches if user specifies.
     if args.dpdk_branch is not None:
-        dpdk_branch = "-b %s" % args.dpdk_branch
+        dpdk_branch = "-b {:s}".format(args.dpdk_branch)
     else:
         dpdk_branch = ''
 
     if args.pktgen_branch is not None:
-        pktgen_branch = "-b %s" % args.pktgen_branch
+        pktgen_branch = "-b {:s}".format(args.pktgen_branch)
     else:
         pktgen_branch = ''
 
     if args.spp_branch is not None:
-        spp_branch = "-b %s" % args.spp_branch
+        spp_branch = "-b {:s}".format(args.spp_branch)
     else:
         spp_branch = ''
 
     if args.suricata_branch is not None:
-        suricata_branch = "-b %s" % args.suricata_branch
+        suricata_branch = "-b {:s}".format(args.suricata_branch)
     else:
         suricata_branch = ''
 
@@ -160,11 +159,11 @@ def main():
 
     # NOTE: Suricata has sub-directory as project root.
     suricata_ver = '4.1.4'
-    suricata_dir = '{}/suricata-{}'.format(
+    suricata_dir = '{:s}/suricata-{:s}'.format(
             args.suricata_repo.split('/')[-1].split('.')[0], suricata_ver)
 
     # RTE_SDK is decided with DPDK's dir.
-    rte_sdk = '%s/%s' % (env.HOMEDIR, dpdk_dir)
+    rte_sdk = '{:s}/{:s}'.format(env.HOMEDIR, dpdk_dir)
 
     # Check for just creating env.sh, or run docker build.
     if args.only_envsh is True:
@@ -174,13 +173,14 @@ def main():
             elif args.target == 'spp':
                 create_env_sh(dockerfile_dir, rte_sdk, args.target, spp_dir)
             elif args.target == 'suricata':
-                create_env_sh(dockerfile_dir, rte_sdk, args.target, suricata_dir)
+                create_env_sh(dockerfile_dir, rte_sdk, args.target,
+                              suricata_dir)
             elif args.target == 'dpdk':
                 create_env_sh(dockerfile_dir, rte_sdk, args.target, dpdk_dir)
-            print("Info: '%s/env.sh' created." % dockerfile_dir)
+            print("Info: '{:s}/env.sh' created.".format(dockerfile_dir))
             exit()
         else:
-            print("Info: Nothin done because you gave %s with %s." % (
+            print("Info: Nothin done because you gave {:s} with {:s}.".format(
                 '--only-envsh', '--dry-run'))
             exit()
     else:
@@ -205,35 +205,40 @@ def main():
     for opt in env_opts:
         if opt in os.environ.keys():
             docker_cmd += [
-                '--build-arg', '%s=%s' % (opt, os.environ[opt]), '\\']
+                    '--build-arg', '{:s}={:s}'.
+                    format(opt, os.environ[opt]), '\\']
 
     docker_cmd += [
-        '--build-arg', 'home_dir=%s' % env.HOMEDIR, '\\',
-        '--build-arg', 'rte_sdk=%s' % rte_sdk, '\\',
-        '--build-arg', 'rte_target=%s' % env.RTE_TARGET, '\\',
-        '--build-arg', 'dpdk_repo=%s' % args.dpdk_repo, '\\',
-        '--build-arg', 'dpdk_branch=%s' % dpdk_branch, '\\']
+        '--build-arg', 'home_dir={:s}'.format(env.HOMEDIR), '\\',
+        '--build-arg', 'rte_sdk={:s}'.format(rte_sdk), '\\',
+        '--build-arg', 'rte_target={:s}'.format(env.RTE_TARGET), '\\',
+        '--build-arg', 'dpdk_repo={:s}'.format(args.dpdk_repo), '\\',
+        '--build-arg', 'dpdk_branch={:s}'.format(dpdk_branch), '\\']
 
     if args.target == 'pktgen':
         docker_cmd += [
-            '--build-arg', 'pktgen_repo=%s' % args.pktgen_repo, '\\',
-            '--build-arg', 'pktgen_branch=%s' % pktgen_branch, '\\',
-            '--build-arg', 'pktgen_dir=%s' % pktgen_dir, '\\']
+                '--build-arg', 'pktgen_repo={:s}'.format(
+                    args.pktgen_repo), '\\',
+                '--build-arg', 'pktgen_branch={:s}'.format(
+                    pktgen_branch), '\\',
+                '--build-arg', 'pktgen_dir={:s}'.format(pktgen_dir), '\\']
     elif args.target == 'spp':
         docker_cmd += [
-            '--build-arg', 'spp_repo=%s' % args.spp_repo, '\\',
-            '--build-arg', 'spp_branch=%s' % spp_branch, '\\',
-            '--build-arg', 'spp_dir=%s' % spp_dir, '\\']
+                '--build-arg', 'spp_repo={:s}'.format(args.spp_repo), '\\',
+                '--build-arg', 'spp_branch={:s}'.format(spp_branch), '\\',
+                '--build-arg', 'spp_dir={:s}'.format(spp_dir), '\\']
     elif args.target == 'suricata':
         docker_cmd += [
-            '--build-arg', 'suricata_repo=%s' % args.suricata_repo, '\\',
-            '--build-arg', 'suricata_branch=%s' % suricata_branch, '\\',
-            '--build-arg', 'suricata_dir=%s' % suricata_dir, '\\']
+                '--build-arg', 'suricata_repo={:s}'.format(
+                    args.suricata_repo), '\\',
+                '--build-arg', 'suricata_branch={:s}'.format(
+                    suricata_branch), '\\',
+                '--build-arg', 'suricata_dir={:s}'.format(suricata_dir), '\\']
 
     docker_cmd += [
-        '-f', '%s' % dockerfile, '\\',
-        '-t', container_image, '\\',
-        dockerfile_dir]
+            '-f', '{:s}'.format(dockerfile), '\\',
+            '-t', container_image, '\\',
+            dockerfile_dir]
 
     common.print_pretty_commands(docker_cmd)
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 28/29] docs: update app container help msg
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (26 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 27/29] tools/sppc: python3 support for sppc build tool Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  2020-02-25 10:34 ` [spp] [PATCH 29/29] docs: update howto define app container guide Yasufumi Ogawa
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

As some opitons of app container is changed, update help messages of
them.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/app_launcher.rst | 209 ++++++++++++++----------
 1 file changed, 121 insertions(+), 88 deletions(-)

diff --git a/docs/guides/tools/sppc/app_launcher.rst b/docs/guides/tools/sppc/app_launcher.rst
index f1a590d..b368a15 100644
--- a/docs/guides/tools/sppc/app_launcher.rst
+++ b/docs/guides/tools/sppc/app_launcher.rst
@@ -126,16 +126,16 @@ On the other hand, application specific options are different each other.
 
     $ python3 app/spp-primary.py -h
     usage: spp-primary.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                          [--socket-mem SOCKET_MEM]
+                          [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                           [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                           [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                          [--single-file-segment]
-                          [--nof-memchan NOF_MEMCHAN] [-n NOF_RING]
-                          [-p PORT_MASK]
-                          [-dv DEV_VHOST_IDS] [-dt DEV_TAP_IDS] [-ip CTRL_IP]
-                          [--ctrl-port CTRL_PORT] [--dist-name DIST_NAME]
-                          [--dist-ver DIST_VER] [--workdir WORKDIR]
-                          [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
+                          [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                          [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]]
+                          [-nq NOF_QUEUES] [--no-privileged] [-n NOF_RING]
+                          [-p PORT_MASK] [-ip CTL_IP] [--ctl-port CTL_PORT]
+                          [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                          [--workdir WORKDIR] [--name NAME] [-ci CONTAINER_IMAGE]
+                          [-fg] [--dry-run]
 
     Launcher for spp-primary application container
 
@@ -146,39 +146,43 @@ On the other hand, application specific options are different each other.
       -c CORE_MASK, --core-mask CORE_MASK
                             Core mask
       -m MEM, --mem MEM     Memory size (default is 1024)
+      --vdev [VDEV [VDEV ...]]
+                            Virtual device in the format of DPDK
       --socket-mem SOCKET_MEM
                             Memory size
-      -b [PCI_BLACKLIST [PCI_BLACKLIST ...]], --pci-blacklist [PCI_BLACKLIST..
+      -b [PCI_BLACKLIST [PCI_BLACKLIST ...]], --pci-blacklist [PCI_BLACKLIST...
                             PCI blacklist for excluding devices
-      -w [PCI_WHITELIST [PCI_WHITELIST ...]], --pci-whitelist [PCI_WHITELIST..
+      -w [PCI_WHITELIST [PCI_WHITELIST ...]], --pci-whitelist [PCI_WHITELIST...
                             PCI whitelist for including devices
       --single-file-segments
                             Create fewer files in hugetlbfs (non-legacy mode
                             only).
       --nof-memchan NOF_MEMCHAN
                             Number of memory channels (default is 4)
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
+      -v [VOLUME [VOLUME ...]], --volume [VOLUME [VOLUME ...]]
+                            Bind mount a volume (for docker)
+      -nq NOF_QUEUES, --nof-queues NOF_QUEUES
+                            Number of queues of virtio (default is 1)
+      --no-privileged       Disable docker's privileged mode if it's needed
       -n NOF_RING, --nof-ring NOF_RING
                             Maximum number of Ring PMD
       -p PORT_MASK, --port-mask PORT_MASK
                             Port mask
-      -dv DEV_VHOST_IDS, --dev-vhost-ids DEV_VHOST_IDS
-                            vhost device IDs
-      -dt DEV_TAP_IDS, --dev-tap-ids DEV_TAP_IDS
-                            TAP device IDs
-      -ip CTRL_IP, --ctrl-ip CTRL_IP
-                            IP address of SPP controller
-      --ctrl-port CTRL_PORT
-                            Port of SPP controller
+      -ip CTL_IP, --ctl-ip CTL_IP
+                            IP address of spp-ctl
+      --ctl-port CTL_PORT   Port for primary of spp-ctl
       --dist-name DIST_NAME
                             Name of Linux distribution
       --dist-ver DIST_VER   Version of Linux distribution
       --workdir WORKDIR     Path of directory in which the command is launched
+      --name NAME           Name of container
       -ci CONTAINER_IMAGE, --container-image CONTAINER_IMAGE
                             Name of container image
       -fg, --foreground     Run container as foreground mode
       --dry-run             Only print matrix, do not run, and exit
 
-
 .. _sppc_appl_spp_secondary:
 
 SPP Secondary Container
@@ -204,12 +208,14 @@ It shows only application specific options for simplicity.
 
     $ python3 app/spp-nfv.py -h
     usage: spp-nfv.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                      [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
+                      [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                       [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                       [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                      [--single-file-segment]
-                      [-i SEC_ID] [-ip CTRL_IP] [--ctrl-port CTRL_PORT]
-                      [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                      [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                      [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]] [-nq NOF_QUEUES]
+                      [--no-privileged] [-i SEC_ID] [-ip CTL_IP]
+                      [--ctl-port CTL_PORT] [--dist-name DIST_NAME]
+                      [--dist-ver DIST_VER] [--workdir WORKDIR] [--name NAME]
                       [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for spp-nfv application container
@@ -218,10 +224,9 @@ It shows only application specific options for simplicity.
       ...
       -i SEC_ID, --sec-id SEC_ID
                             Secondary ID
-      -ip CTRL_IP, --ctrl-ip CTRL_IP
-                            IP address of SPP controller
-      --ctrl-port CTRL_PORT
-                            Port of SPP controller
+      -ip CTL_IP, --ctl-ip CTL_IP
+                            IP address of spp-ctl
+      --ctl-port CTL_PORT   Port for secondary of spp-ctl
       ...
 
 
@@ -256,21 +261,21 @@ It shows options without of EAL and container for simplicity.
 
     $ python3 app/l2fwd.py -h
     usage: l2fwd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                    [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
+                    [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                     [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
-                    [--single-file-segment]
                     [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                    [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
-                    [-p PORT_MASK]
-                    [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                    [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                    [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]] [-nq NOF_QUEUES]
+                    [--no-privileged] [-p PORT_MASK] [--dist-name DIST_NAME]
+                    [--dist-ver DIST_VER] [--workdir WORKDIR] [--name NAME]
                     [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for l2fwd application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -374,24 +379,24 @@ It shows options without of EAL and container for simplicity.
 
     $ python3 app/l3fwd.py -h
     usage: l3fwd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                    [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
+                    [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                     [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                     [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                    [--single-file-segment]
-                    [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
-                    [-p PORT_MASK] [--config CONFIG] [-P] [-E] [-L]
-                    [-dst [ETH_DEST [ETH_DEST ...]]] [--enable-jumbo]
-                    [--max-pkt-len MAX_PKT_LEN] [--no-numa]
-                    [--hash-entry-num] [--ipv6] [--parse-ptype PARSE_PTYPE]
-                    [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                    [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                    [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]] [-nq NOF_QUEUES]
+                    [--no-privileged] [-p PORT_MASK] [--config CONFIG] [-P] [-E]
+                    [-L] [-dst [ETH_DEST [ETH_DEST ...]]] [--enable-jumbo]
+                    [--max-pkt-len MAX_PKT_LEN] [--no-numa] [--hash-entry-num]
+                    [--ipv6] [--parse-ptype PARSE_PTYPE] [--dist-name DIST_NAME]
+                    [--dist-ver DIST_VER] [--workdir WORKDIR] [--name NAME]
                     [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for l3fwd application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -513,12 +518,26 @@ It shows options without of EAL and container for simplicity.
                         [--workdir WORKDIR] [-ci CONTAINER_IMAGE] [-fg]
                         [--dry-run]
 
+    usage: l3fwd-acl.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
+                        [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
+                        [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
+                        [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
+                        [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                        [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]]
+                        [-nq NOF_QUEUES] [--no-privileged] [-p PORT_MASK]
+                        [--config CONFIG] [-P]
+                        [--rule_ipv4 RULE_IPV4] [--rule_ipv6 RULE_IPV6]
+                        [--scalar] [--enable-jumbo] [--max-pkt-len MAX_PKT_LEN]
+                        [--no-numa] [--dist-name DIST_NAME]
+                        [--dist-ver DIST_VER] [--workdir WORKDIR] [--name NAME]
+                        [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
+
     Launcher for l3fwd-acl application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -595,13 +614,14 @@ It shows options without of EAL and container.
 
     $ python3 app/testpmd.py -h
     usage: testpmd.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                      [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
+                      [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                       [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                       [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                      [--single-file-segment]
-                      [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
-                      [--pci] [-i] [-a] [--tx-first]
-                      [--stats-period STATS_PERIOD]
+                      [--single-file-segments]
+                      [--nof-memchan NOF_MEMCHAN] [-d DEV_UIDS]
+                      [-v [VOLUME [VOLUME ...]]]
+                      [-nq NOF_QUEUES] [--no-privileged] [--pci] [-i] [-a]
+                      [--tx-first] [--stats-period STATS_PERIOD]
                       [--nb-cores NB_CORES] [--coremask COREMASK]
                       [--portmask PORTMASK] [--no-numa]
                       [--port-numa-config PORT_NUMA_CONFIG]
@@ -613,37 +633,40 @@ It shows options without of EAL and container.
                       [--eth-peer ETH_PEER] [--pkt-filter-mode PKT_FILTER_MODE]
                       [--pkt-filter-report-hash PKT_FILTER_REPORT_HASH]
                       [--pkt-filter-size PKT_FILTER_SIZE]
-                      [--pkt-filter-flexbytes-offset PKT_FILTER_FLEXBYTES...]
+                      [--pkt-filter-flexbytes-offset PKT_FILTER_FLEXBYTES_OFFSET]
                       [--pkt-filter-drop-queue PKT_FILTER_DROP_QUEUE]
                       [--disable-crc-strip] [--enable-lro] [--enable-rx-cksum]
                       [--enable-scatter] [--enable-hw-vlan]
-                      [--enable-hw-vlan-filter] [--enable-hw-vlan-strip]
-                      [--enable-hw-vlan-extend] [--enable-drop-en]
-                      [--disable-rss] [--port-topology PORT_TOPOLOGY]
+                      [--enable-hw-vlan-filter]
+                      [--enable-hw-vlan-strip] [--enable-hw-vlan-extend]
+                      [--enable-drop-en] [--disable-rss]
+                      [--port-topology PORT_TOPOLOGY]
                       [--forward-mode FORWARD_MODE] [--rss-ip] [--rss-udp]
                       [--rxq RXQ] [--rxd RXD] [--txq TXQ] [--txd TXD]
-                      [--burst BURST] [--mbcache MBCACHE] [--rxpt RXPT]
-                      [--rxht RXHT] [--rxfreet RXFREET] [--rxwt RXWT]
-                      [--txpt TXPT] [--txht TXHT] [--txwt TXWT]
+                      [--burst BURST] [--mbcache MBCACHE]
+                      [--rxpt RXPT] [--rxht RXHT] [--rxfreet RXFREET]
+                      [--rxwt RXWT] [--txpt TXPT] [--txht TXHT] [--txwt TXWT]
                       [--txfreet TXFREET] [--txrst TXRST]
                       [--rx-queue-stats-mapping RX_QUEUE_STATS_MAPPING]
                       [--tx-queue-stats-mapping TX_QUEUE_STATS_MAPPING]
-                      [--no-flush-rx] [--txpkts TXPKTS] [--disable-link-check]
-                      [--no-lsc-interrupt] [--no-rmv-interrupt]
+                      [--no-flush-rx] [--txpkts TXPKTS]
+                      [--disable-link-check] [--no-lsc-interrupt]
+                      [--no-rmv-interrupt]
                       [--bitrate-stats [BITRATE_STATS [BITRATE_STATS ...]]]
                       [--print-event PRINT_EVENT] [--mask-event MASK_EVENT]
                       [--flow-isolate-all] [--tx-offloads TX_OFFLOADS]
                       [--hot-plug] [--vxlan-gpe-port VXLAN_GPE_PORT]
-                      [--mlockall] [--no-mlockall] [--dist-name DIST_NAME]
-                      [--dist-ver DIST_VER] [-ci CONTAINER_IMAGE] [-fg]
-                      [--dry-run]
+                      [--mlockall] [--no-mlockall]
+                      [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                      [--workdir WORKDIR]
+                      [--name NAME] [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for testpmd application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -882,21 +905,25 @@ It shows options without of EAL and container for simplicity.
 
     $ python3 app/pktgen.py -h
     usage: pktgen.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                     [--socket-mem SOCKET_MEM] [--nof-memchan NOF_MEMCHAN]
+                     [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                      [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                      [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                     [--single-file-segment]
-                     [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
-                     [--matrix MATRIX] [--log-level LOG_LEVEL]
-                     [--dist-name DIST_NAME] [--dist-ver DIST_VER]
-                     [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
+                     [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
+                     [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]]
+                     [-nq NOF_QUEUES] [--no-privileged] [-s PCAP_FILE]
+                     [-f SCRIPT_FILE]
+                     [-lf LOG_FILE] [-P] [-G] [-g SOCK_ADDRESS] [-T] [-N]
+                     [--matrix MATRIX] [--dist-name DIST_NAME]
+                     [--dist-ver DIST_VER]
+                     [--workdir WORKDIR] [--name NAME] [-ci CONTAINER_IMAGE]
+                     [-fg] [--dry-run]
 
     Launcher for pktgen-dpdk application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -1092,24 +1119,27 @@ Refer options and usages by ``load-balancer.py -h``.
 
     $ python3 app/load-balancer.py -h
     usage: load-balancer.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
+                            [--vdev [VDEV [VDEV ...]]]
                             [--socket-mem SOCKET_MEM]
                             [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                             [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                            [--single-file-segment]
+                            [--single-file-segments]
                             [--nof-memchan NOF_MEMCHAN]
-                            [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
-                            [-rx RX_PORTS] [-tx TX_PORTS] [-w WORKER_LCORES]
-                            [-rsz RING_SIZES] [-bsz BURST_SIZES] [--lpm LPM]
-                            [--pos-lb POS_LB] [--dist-name DIST_NAME]
-                            [--dist-ver DIST_VER] [-ci CONTAINER_IMAGE]
-                            [-fg] [--dry-run]
+                            [-d DEV_UIDS] [-v [VOLUME [VOLUME ...]]]
+                            [-nq NOF_QUEUES] [--no-privileged]
+                            [-rx RX_PORTS] [-tx TX_PORTS] [-wl WORKER_LCORES]
+                            [-rsz RING_SIZES] [-bsz BURST_SIZES]
+                            [--lpm LPM] [--pos-lb POS_LB]
+                            [--dist-name DIST_NAME] [--dist-ver DIST_VER]
+                            [--workdir WORKDIR] [--name NAME]
+                            [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for load-balancer application container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
@@ -1168,20 +1198,23 @@ Refer options and usages by ``load-balancer.py -h``.
 
     $ python3 app/suricata.py -h
     usage: suricata.py [-h] [-l CORE_LIST] [-c CORE_MASK] [-m MEM]
-                       [--socket-mem SOCKET_MEM]
+                       [--vdev [VDEV [VDEV ...]]] [--socket-mem SOCKET_MEM]
                        [-b [PCI_BLACKLIST [PCI_BLACKLIST ...]]]
                        [-w [PCI_WHITELIST [PCI_WHITELIST ...]]]
-                       [--single-file-segments] [--nof-memchan NOF_MEMCHAN]
-                       [-d DEV_IDS] [-nq NOF_QUEUES] [--no-privileged]
+                       [--single-file-segments]
+                       [--nof-memchan NOF_MEMCHAN] [-d DEV_UIDS]
+                       [-v [VOLUME [VOLUME ...]]] [-nq NOF_QUEUES]
+                       [--no-privileged]
                        [--dist-name DIST_NAME] [--dist-ver DIST_VER]
-                       [--workdir WORKDIR] [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
+                       [--workdir WORKDIR] [--name NAME]
+                       [-ci CONTAINER_IMAGE] [-fg] [--dry-run]
 
     Launcher for suricata container
 
     optional arguments:
       ...
-      -d DEV_IDS, --dev-ids DEV_IDS
-                            two or more even vhost device IDs
+      -d DEV_UIDS, --dev-uids DEV_UIDS
+                            Virtual devices of SPP in resource UID format
       -nq NOF_QUEUES, --nof-queues NOF_QUEUES
                             Number of queues of virtio (default is 1)
       --no-privileged       Disable docker's privileged mode if it's needed
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

* [spp] [PATCH 29/29] docs: update howto define app container guide
  2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
                   ` (27 preceding siblings ...)
  2020-02-25 10:34 ` [spp] [PATCH 28/29] docs: update app container help msg Yasufumi Ogawa
@ 2020-02-25 10:34 ` Yasufumi Ogawa
  28 siblings, 0 replies; 30+ messages in thread
From: Yasufumi Ogawa @ 2020-02-25 10:34 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Update contents of `How to Define Your App Launcher` because
implemention is changed.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/howto_launcher.rst | 210 +++++++++-------------
 1 file changed, 85 insertions(+), 125 deletions(-)

diff --git a/docs/guides/tools/sppc/howto_launcher.rst b/docs/guides/tools/sppc/howto_launcher.rst
index 77c4bf8..3f21f4a 100644
--- a/docs/guides/tools/sppc/howto_launcher.rst
+++ b/docs/guides/tools/sppc/howto_launcher.rst
@@ -61,10 +61,10 @@ DPDK Sample App Container
 
 Procedure of App container script is defined in main() and
 consists of three steps of
-(1)parsing options, (2)building docker command and
-(3)application command run inside the container.
+(1) parsing options, (2) setup docker command and
+(3) application command run inside the container.
 
-Here is a sample code of :ref:`sppc_appl_helloworld`.
+Here is a sample code of :ref:`sppc_appl_l2fwd`.
 ``parse_args()`` is defined in each
 of app container scripts to parse all of EAL, docker and application
 specific options.
@@ -78,30 +78,48 @@ for parsing the arguments.
     def main():
         args = parse_args()
 
+        # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+        if args.container_image is not None:
+            container_image = args.container_image
+        else:
+            container_image = common.container_img_name(
+                common.IMG_BASE_NAMES['dpdk'],
+                args.dist_name, args.dist_ver)
+
         # Check for other mandatory opitons.
-        if args.dev_ids is None:
-            common.error_exit('--dev-ids')
+        if args.port_mask is None:
+            common.error_exit('--port-mask')
+
+If the name of container is given via ``args.container_image``, it is
+decided as a combination of basename, distribution and its version.
+Basenames are defined as ``IMG_BASE_NAMES`` in ``lib/common.py``.
+In general, You do not need to change for using DPDK sample apps.
+
+.. code-block:: python
 
-        # Setup for vhost devices with given device IDs.
-        dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-        sock_files = app_helper.sock_files(dev_ids_list)
+    # defined in lib/common.py
+    IMG_BASE_NAMES = {
+        'dpdk': 'sppc/dpdk',
+        'pktgen': 'sppc/pktgen',
+        'spp': 'sppc/spp',
+        'suricata': 'sppc/suricata',
+        }
 
-Each of options is accessible as ``args.dev_ids`` or
-``args.core_list``.
-Before step (2) and (3), you had better to check given option,
+Options can be referred via ``args``. For example, the name of container
+image can be referred via ``args.container_image``.
+
+Before go to step (2) and (3), you had better to check given option,
 expecially mandatory options.
-In this case, ``--dev-ids`` is the mandatory and you should terminate
-the application if it is not given.
 ``common.error_exit()`` is a helper method to print an error message
-for given option and do ``exit()``.
+for given option and do ``exit()``. In this case, ``--port-mask`` must
+be given, or exit with an error message.
 
-Setup of ``dev_ids_list`` and ``sock_files`` is required for launching
-container.
-``lib/app_helper.py`` defines helper functions commonly used
-for app containers.
+Setup of ``sock_files`` is required for creating network interfaces
+for the container. ``sock_files()`` defined in ``lib/app_helper.py`` is
+provided for creating socket files from given device UIDs.
 
 Then, setup docker command and its options as step (2).
-Docker options are setup by using helper method
+Docker options are added by using helper method
 ``setup_docker_opts()`` which generates commonly used options for app
 containers.
 This methods returns a list of a part of options to give it to
@@ -111,73 +129,43 @@ This methods returns a list of a part of options to give it to
 
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
-    docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
-
-You should notice a option ``target_name``.
-It is used as a label to choose which of container image you use.
-The name of container image is defined as a combination of basename,
-distribution name and version.
-Basename is defined as a member of ``CONTAINER_IMG_NAME`` in
-``conf/env.py``.
-
-.. code-block:: python
-
-    # defined in conf/env.py
-    CONTAINER_IMG_NAME = {
-        'dpdk': 'sppc/dpdk',
-        'pktgen': 'sppc/pktgen',
-        'spp': 'sppc/spp'}
-
-This usecase is for DPDK sample app, so you should define target as
-``dpdk``.
-You do not need to change for using DPDK sample apps in general.
-But it can be changed by using other target name.
-For example, if you give target ``pktgen`` and
-use default dist name and verion of ``ubuntu`` and ``latest``,
-The name of image is ``sppc/pktgen-ubuntu:latest``.
-
-For using images other than defined above, you can override it with
-``--container-image`` option.
-It enables to use any of container images and applications.
+    docker_opts = app_helper.setup_docker_opts(args, sock_files)
 
-You also notice that ``docker_cmd`` has ``\\`` at the end of the list.
+You also notice that ``docker_cmd`` has a backslash ``\\`` at the end of
+the list.
 It is only used to format the printed command on the terminal.
-If you do no care about formatting, you do not need to add it.
+If you do no care about formatting, you do not need to add this character.
 
 Next step is (3), to setup the application command.
-You should change ``cmd_path`` and ``file_prefix`` to specify
-the application.
-For ``cmd_path``, ``helloworld`` should be changed to other name of
-application, for example,
+You should change ``cmd_path`` to specify your application.
+In ``app/l2fwd.py``, the application compiled under ``RTE_SDK`` in DPDK's
+directory, but your application might be different.
 
 .. code-block:: python
 
-    # Setup helloworld run on container.
-    cmd_path = '%s/examples/helloworld/%s/helloworld' % (
-        env.RTE_SDK, env.RTE_TARGET)
+    # Setup l2fwd command run on container.
+    cmd_path = '{0:s}/examples/{2:s}/{1:s}/{2:s}'.format(
+        env.RTE_SDK, env.RTE_TARGET, APP_NAME)
 
-    hello_cmd = [cmd_path, '\\']
+    l2fwd_cmd = [cmd_path, '\\']
 
-    file_prefix = 'spp-hello-container%d' % dev_ids_list[0]
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
+    # Setup EAL options.
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
-    # No application specific options for helloworld
-    hello_opts = []
+    # Setup l2fwd options.
+    l2fwd_opts = ['-p', args.port_mask, '\\']
 
-``file_prefix`` for EAL option should be unique on the system
-because it is used as the name of hugepage file.
-In SPP container, it is a combination of fixed text and vhost device ID
-because this ID is unique in SPP container and cannot be overlapped,
-at least among app containers in SPP container.
-EAL options are also generated by helper method.
+While setting up EAL option in ``setup_eal_opts()``, ``--file-prefix`` is
+generated by using the name of application and a random number. It should
+be unique on the system because it is used as the name of hugepage file.
 
-Finally, combine all of commands and its options and launch
-from ``subprocess.call()``.
+Finally, combine command and all of options before launching from
+``subprocess.call()``.
 
 .. code-block:: python
 
-    cmds = docker_cmd + docker_opts + hello_cmd + eal_opts + hello_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        l2fwd_cmd + eal_opts + l2fwd_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
@@ -190,20 +178,17 @@ from ``subprocess.call()``.
         cmds.remove('\\')
     subprocess.call(cmds)
 
-All of commands and options are combined in to a list ``cmds``
-to give it to ``subprocess.call()``.
-You can ignore procedures for ``\\`` and
-``common.print_pretty_commands()``
-if you do not care about printing commands in the terminal.
-However, you should not to shortcut for ``args.dry_run`` because
-it is very important for users to check the command syntax
-before running it.
+There are some optional behaviors in the final step.
+``common.print_pretty_commands()`` replaces ``\\`` with a newline character
+and prints command line in pretty format.
+If you give ``--dry-run`` option, this launcher script prints command line
+and exits without launching container.
 
 
-.. _sppc_howto_dpdk_appc_nots:
+.. _sppc_howto_none_dpdk_sample_apps:
 
-App Container not for DPDK Sample
----------------------------------
+None DPDK Sample Applications in Container
+------------------------------------------
 
 There are several application using DPDK but not included in
 `sample applications
@@ -247,61 +232,36 @@ For your application, you can simply add options to ``parser`` object.
     def main():
         args = parse_args()
 
-        # Setup for vhost devices with given device IDs.
-        dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
-        sock_files = app_helper.sock_files(dev_ids_list)
-
-        # Setup docker command.
-        docker_cmd = ['sudo', 'docker', 'run', '\\']
-        docker_opts = app_helper.setup_docker_opts(
-            args, target_name, sock_files,
-            '%s/../pktgen-dpdk' % env.RTE_SDK)
-
-        cmd_path = '%s/../pktgen-dpdk/app/%s/pktgen' % (
-            env.RTE_SDK, env.RTE_TARGET)
-
-Setup for docker command is the same as the example.
-The ``terget_name`` might be different from the image you will use,
-but you do not need to care about which of container image is used
-because it is overriden with given image with ``--container-image``
-option.
-However, you should care about the path of application ``cmd_path``
-which is run in the container.
-
-Then, you should decide ``file_prefix`` to your application container
-be unique on the system.
-The ``file_prefix`` of SPP container is named as
-``spp-[APP_NAME]-container[VHOST_ID]`` convensionally to it be unique.
+Setup of socket files for network interfaces is the same as DPDK sample apps.
+However, you might need to change paht of command  which is run in the
+container. In ``app/pktgen.py``, directory of ``pktgen`` is defined as
+``wd``, and the name of application s defined as ``APP_NAME``.
+This directory can be changed with ``--workdir`` option.
 
 .. code-block:: python
 
-    # Setup pktgen command
-    pktgen_cmd = [cmd_path, '\\']
-
-    file_prefix = 'spp-pktgen-container%d' % dev_ids_list[0]
-    eal_opts = app_helper.setup_eal_opts(args, file_prefix)
-
-You should check the arguments for the application.
-
-.. code-block:: python
+    # Setup docker command.
+    if args.workdir is not None:
+        wd = args.workdir
+    else:
+        wd = '/root/pktgen-dpdk'
+    docker_cmd = ['sudo', 'docker', 'run', '\\']
+    docker_opts = app_helper.setup_docker_opts(args, sock_files, None, wd)
 
-    ...
-    if args.pcap_file is not None:
-        pktgen_opts += ['-s', args.pcap_file, '\\']
+    # Setup pktgen command
+    pktgen_cmd = [APP_NAME, '\\']
 
-    if args.script_file is not None:
-        pktgen_opts += ['-f', args.script_file, '\\']
+    # Setup EAL options.
+    eal_opts = app_helper.setup_eal_opts(args, APP_NAME)
 
-    if args.log_file is not None:
-        pktgen_opts += ['-l', args.log_file, '\\']
-    ...
 
 Finally, combine all of commands and its options and launch
 from ``subprocess.call()``.
 
 .. code-block:: python
 
-    cmds = docker_cmd + docker_opts + pktgen_cmd + eal_opts + pktgen_opts
+    cmds = docker_cmd + docker_opts + [container_image, '\\'] + \
+        pktgen_cmd + eal_opts + pktgen_opts
     if cmds[-1] == '\\':
         cmds.pop()
     common.print_pretty_commands(cmds)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, back to index

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 10:34 [spp] [PATCH 00/29] Update SPP Container tools Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 01/29] tools/sppc: update options for assigning devices Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 02/29] tools/sppc: update dev options of l2fwd Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 03/29] tools/sppc: add container name option Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 04/29] tools/sppc: update l2fwd app for " Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 05/29] tools/sppc: update dev options of l3fwd Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 06/29] tools/sppc: update dev options of l3fwd-acl Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 07/29] tools/sppc: update dev options of testpmd Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 08/29] tools/sppc: update dev options of pktgen Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 09/29] tools/sppc: update dev options of load-balancer Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 10/29] tools/sppc: version checker for container DPDK ver Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 11/29] tools/sppc: check DPDK ver in load-balancer Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 12/29] tools/sppc: setup spp_pri opts in app_helper Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 13/29] tools/sppc: define file prefix for SPP Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 14/29] tools/sppc: update dev options of spp_primary Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 15/29] tools/sppc: setup with docker opts in SPP pri Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 16/29] tools/sppc: update calling setup_docker_opts() Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 17/29] tools/sppc: update dev options of helloworld Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 18/29] tools/sppc: update dev options of suricata Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 19/29] tools/sppc: update dev options of spp_nfv Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 20/29] tools/sppc: change to gen EAL opts with app name Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 21/29] tools/sppc: remove nouse variable Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 22/29] bin: remove sock files created by docker Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 23/29] tools/sppc: skip checking rule file if dry run Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 24/29] docs: revise examples in sppc Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 25/29] docs: update versions in " Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 26/29] docs: update old example in spp_primary container Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 27/29] tools/sppc: python3 support for sppc build tool Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 28/29] docs: update app container help msg Yasufumi Ogawa
2020-02-25 10:34 ` [spp] [PATCH 29/29] docs: update howto define app container guide Yasufumi Ogawa

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox