Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 3/8] spp-ctl: add launch command support for REST API
Date: Tue, 29 Jan 2019 21:21:56 +0900	[thread overview]
Message-ID: <1548764521-2827-4-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1548764521-2827-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

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

This update is to add REST API support of launch command for
spp_primary. This launch API of PUT accepts a name of secondary
process, secondary ID and all args of the application. Here is an
example.

  $ curl -X PUT -d '{"client_id":1,"proc_name":"spp_nfv","eal":...}' \
    http://127.0.0.1:7777/v1/primary/launch

This launch API supports only spp_nfv currently. Other secondaries can
be launched, but have no components and do not work correctly.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp-ctl/spp_proc.py   | 113 ++++++++++++++++++++++++++++++++++++++++++++++
 src/spp-ctl/spp_webapi.py |  11 +++++
 2 files changed, 124 insertions(+)

diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py
index 19a5e53..a2d2adf 100644
--- a/src/spp-ctl/spp_proc.py
+++ b/src/spp-ctl/spp_proc.py
@@ -18,6 +18,76 @@ TYPE_NFV = "nfv"
 TYPE_MIRROR = "mirror"
 TYPE_PCAP = "pcap"
 
+EAL_OPTS = [
+        # Lcore-related options
+        '-c',  # core mask
+        '-l',  # core list
+        '--lcores',  # core map
+        '--master-lcore',  # is used as master
+        '-s',  # Hex bitmask of cores used as service cores
+        # Device-related options
+        '-b', '--pci-blacklist',  # Blacklist of PCI devs
+        '-w', '--pci-whitelist',  # Blacklist of PCI devs
+        '--vdev',  # Add a virtual device
+        '-d',  # Load external drivers
+        '--no-pci',  # Disable PCI bus.
+        # Multiprocessing-related options
+        '--proc-type',  # primamry, secondary or auto
+        # Memory-related options
+        '-n',  # number of memory channels
+        '-r',  # number of memory ranks
+        '-m',  # Amount of memory to preallocate at startup
+        '--in-memory',  # not create shared data and run entirely in memory
+        '--iova-mode',  # Force IOVA mode to a specific value
+        # Debugging options
+        '--no-shconf',  # No shared files created (no sec)
+        '--no-huge',  # Use anonymous memory instead of hugepages (no sec)
+        '--log-level',   # Specify log level, e.g. '--log-level eal:8'
+        '--file-prefix',  # Use different shared file prefix for a DPDK process
+        # Linux-specific EAL parameters
+        '--create-uio-dev',  # Create /dev/uioX bound to igb_uio
+        '--vmware-tsc-map',  # Use VMware TSC map instead of native RDTSC
+        '--no-hpet',  # Do not use the HPET timer
+        '--vfio-intr',  # Use specified interrupt mode for devs bound to VFIO
+        '--base-virtaddr',  # use different addr for all memmaps of primary
+        '--legacy-mem',  # Use legacy DPDK memory allocation mode
+        '--socket-mem',  # Preallocate memory per socket
+        '--socket-limit',  # Place a per-socket upper limit on memory
+        '--single-file-segments',  # Create fewer files in hugetlbfs
+        '--huge-dir',  # Use specified hugetlbfs instead of autodetected
+        '--huge-unlink',  # Unlink hugepage files after creating
+        '--match-allocations',  # Free hugepages back as original
+        '--syslog'  # syslog facility
+        ]
+
+APP_OPTS = {
+        'spp_nfv':
+        [
+            '-n',  # sec ID
+            '-s',  # address and port
+            '--vhost-client'  # enable client mode
+            ],
+        'spp_vf':
+        [
+            '--client-id',  # sec ID
+            '-s',  # address nd port
+            '--vhost-client'  # enable client mode
+            ],
+        'spp_mirror':
+        [
+            '--client-id',  # sec ID
+            '-s',  # address nd port
+            '--vhost-client'  # enable client mode
+            ],
+        'spp_pcap':
+        [
+            '--client-id',  # sec ID
+            '-s',  # address nd port
+            '-i',
+            '--output',
+            '--limit_file_size'
+            ]}
+
 
 def exec_command(func):
     """Decorator for Sending command and receiving reply.
@@ -227,6 +297,49 @@ class PrimaryProc(SppProc):
         return "clear"
 
     @exec_command
+    def do_launch_sec_proc(self, args):
+        proc_name = args['proc_name']
+        sec_id = args['client_id']
+
+        eal_opts = []
+        app_opts = []
+
+        # EAL options
+        # Check mandatory options
+        mandatory = False
+        for key in ['-c', '-l', '--lcores']:
+            if key in args['eal'].keys():
+                mandatory = True
+                break
+        if mandatory is False:
+            return None
+
+        if '--proc-type' not in args['eal'].keys():
+            return None
+
+        for opt in EAL_OPTS:
+            if opt in args['eal'].keys():
+                eal_opts.append(opt)
+                val = args['eal'][opt]
+                if (val is not None) and (val != ''):
+                    eal_opts.append(str(val))
+
+        if proc_name in APP_OPTS.keys():
+            for opt in APP_OPTS[proc_name]:
+                if opt in args['app'].keys():
+                    app_opts.append(opt)
+                    val = args['app'][opt]
+                    if (val is not None) and (val != ''):
+                        app_opts.append(str(val))
+
+        query = "launch {} {} {} -- {}".format(
+                sec_id, proc_name, ' '.join(eal_opts), ' '.join(app_opts))
+
+        LOG.info("Query: {}".format(query))
+
+        return query
+
+    @exec_command
     def do_exit(self):
         return "exit"
 
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index 0fd2f2a..10b4098 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -436,10 +436,13 @@ class V1PrimaryHandler(BaseHandler):
         self.set_route()
 
         self.install(self.make_response)
+        self.install(self.get_body)
 
     def set_route(self):
         self.route('/status', 'GET', callback=self.get_status)
         self.route('/status', 'DELETE', callback=self.clear_status)
+        self.route('/launch', 'PUT',
+                   callback=self.launch_sec_proc)
         self.route('/', 'DELETE', callback=self.pri_exit)
 
     def _get_proc(self):
@@ -464,6 +467,14 @@ class V1PrimaryHandler(BaseHandler):
         proc = self._get_proc()
         proc.clear()
 
+    def launch_sec_proc(self, body):  # the arg should be "body"
+        for key in ['client_id', 'proc_name', 'eal', 'app']:
+            if key not in body:
+                raise KeyRequired(key)
+
+        proc = self._get_proc()
+        proc.do_launch_sec_proc(body)
+
     def pri_exit(self):
         proc = self._get_proc()
         self.ctrl.do_exit(proc.type, proc.id)
-- 
2.7.4

  parent reply	other threads:[~2019-01-29 12:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 12:21 [spp] [PATCH 0/8] Add launch command to spp_primary ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 1/8] shared: add func for getting dirname of secondary ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 2/8] spp_priamry: add launch command ogawa.yasufumi
2019-01-29 12:21 ` ogawa.yasufumi [this message]
2019-01-29 12:21 ` [spp] [PATCH 4/8] controller: add launch sub command in pri ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 5/8] spp_primary: change launching sec to use python ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 6/8] tools/helpers: add sec launcher script ogawa.yasufumi
2019-01-29 12:22 ` [spp] [PATCH 7/8] controller: revise completion of launch command ogawa.yasufumi
2019-01-29 12:22 ` [spp] [PATCH 8/8] tools/helpers: move cpu_layout script to helpers ogawa.yasufumi

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=1548764521-2827-4-git-send-email-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).