Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org
Cc: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 08/15] tools/sppc: add l2fwd app continer
Date: Fri, 15 Jun 2018 17:37:47 +0900	[thread overview]
Message-ID: <20180615083754.20220-9-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20180615083754.20220-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 tools/sppc/app/l2fwd.py | 96 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)
 create mode 100755 tools/sppc/app/l2fwd.py

diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
new file mode 100755
index 0000000..3b7789c
--- /dev/null
+++ b/tools/sppc/app/l2fwd.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
+
+import argparse
+import os
+import subprocess
+import sys
+
+work_dir = os.path.dirname(__file__)
+sys.path.append(work_dir + '/..')
+from conf import env
+from lib import app_helper
+from lib import common
+
+target_name = 'dpdk'
+
+
+def parse_args():
+    parser = argparse.ArgumentParser(
+        description="Launcher for l2fwd application container")
+
+    parser = app_helper.add_eal_args(parser)
+    parser = app_helper.add_appc_args(parser)
+
+    # Application specific args
+    parser.add_argument(
+        '-p', '--port-mask',
+        type=str,
+        help="Port mask")
+
+    parser = app_helper.add_sppc_args(parser)
+    return parser.parse_args()
+
+
+def main():
+    args = parse_args()
+
+    # 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 docker command.
+    docker_cmd = ['sudo', 'docker', 'run', '\\']
+    docker_opts = app_helper.setup_docker_opts(
+        args, target_name, sock_files)
+
+    # Check if the number of ports is even for l2fwd.
+    nof_ports = app_helper.count_ports(args.port_mask)
+    if (nof_ports % 2) != 0:
+        print("Error: Number of ports must be an even number!")
+        exit()
+
+    # Setup l2fwd command run on container.
+    cmd_path = '%s/examples/l2fwd/%s/l2fwd' % (
+        env.RTE_SDK, env.RTE_TARGET)
+
+    l2fwd_cmd = [cmd_path, '\\']
+
+    file_prefix = 'spp-l2fwd-container%d' % dev_ids_list[0]
+    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'." % (
+            args.port_mask,
+            format(int(args.port_mask, 16), 'b'),
+            args.dev_ids))
+        exit()
+
+    cmds = docker_cmd + docker_opts + l2fwd_cmd + eal_opts + l2fwd_opts
+    if cmds[-1] == '\\':
+        cmds.pop()
+    common.print_pretty_commands(cmds)
+
+    if args.dry_run is True:
+        exit()
+
+    # Remove delimiters for print_pretty_commands().
+    while '\\' in cmds:
+        cmds.remove('\\')
+    subprocess.call(cmds)
+
+
+if __name__ == '__main__':
+    main()
-- 
2.17.1

  parent reply	other threads:[~2018-06-15  8:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  8:37 [spp] [PATCH 00/15] Add SPP container tools ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 01/15] tools/sppc: add SPP container build tool ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 02/15] tools/sppc: add dockerfiles for DPDK ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 03/15] tools/sppc: add dockerfiles for pktgen ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 04/15] tools/sppc: add dockerfiles for SPP ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 05/15] tools/sppc: add spp-primary app continer ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 06/15] tools/sppc: add spp-nfv " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 07/15] tools/sppc: add spp-vm " ogawa.yasufumi
2018-06-15  8:37 ` ogawa.yasufumi [this message]
2018-06-15  8:37 ` [spp] [PATCH 09/15] tools/sppc: add testpmd " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 10/15] tools/sppc: add l3fwd " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 11/15] tools/sppc: add pktgen " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 12/15] tools/sppc: add load-balancer " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 13/15] tools/sppc: add helloworld " ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 14/15] tools/sppc: add helper script for build ogawa.yasufumi
2018-06-15  8:37 ` [spp] [PATCH 15/15] tools/sppc: add spp launcher script ogawa.yasufumi
2018-08-15 15:34 ` [spp] [PATCH 00/15] Add SPP container tools Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180615083754.20220-9-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).