* [spp] [PATCH 0/5] Add config command
@ 2019-02-04 3:11 ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 1/5] controller: add " ogawa.yasufumi
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:11 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
`config` command is for managing default configurations of SPP CLI.
For example, you can change default command prompt `spp > ` to another
one.
List of all of configurations is referred with `config`, or list of
started with `p` is referred with `config p`.
# show all configs
spp > config
- max_secondary: "16" # The maximum number of secondary processes
- sec_nfv_nof_lcores: "1" # Default num of lcores for workers ...
- topo_size: "60%" # Percentage or ratio of topo
- sec_base_lcore: "1" # Shared lcore among secondaryes
- prompt: "spp > " # Command prompt
- sec_pcap_nof_lcores: "2" # Default num of lcores for ...
- sec_mirror_nof_lcores: "2" # Default num of lcores for ...
...
# only started with `p`
spp > config p
- prompt: "spp > " # Command prompt
To change configuration, specify key and its value.
# set prompt
Set prompt: "$ spp "
$ spp
Config params starting with `sec_` is used for options of `pri; launch`
command.
- sec_vf_nof_lcores
- sec_mirror_nof_lcores
- sec_pcap_nof_lcores
...
For instance, if secondary ID is `3` and `sec_vf_nof_lcores` is 3,
woker lcores is suggested as `3-5`, started from `3` and use three
cores.
Yasufumi Ogawa (5):
controller: add config command
controller: refactor pri launch command
controller: remove nouse check_sec_cmds
controller: add max_secondary to config
controller: change nof worker lcores configurable
src/controller/commands/pri.py | 121 ++++++++++++++++++++++++++------
src/controller/shell.py | 152 +++++++++++++++++++++++++++++------------
2 files changed, 210 insertions(+), 63 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 1/5] controller: add config command
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
@ 2019-02-04 3:11 ` ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 2/5] controller: refactor pri launch command ogawa.yasufumi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:11 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
`config` command is for managing default configurations of SPP CLI.
For example, you can change default command prompt `spp > ` to another
one.
List of all of configurations is referred with `config`, or list of
started with `p` is referred with `config p`.
# show all configs
spp > config
- topo_size: "60%" # Percentage or ratio of topo
- prompt: "spp > " # Command prompt
...
# only started with `p`
spp > config p
- prompt: "spp > " # Command prompt
To change configuration, specify key and its value.
# set prompt
Set prompt: "$ spp "
$ spp
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/pri.py | 14 ++++--
src/controller/shell.py | 103 ++++++++++++++++++++++++++++++++++++++---
2 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index b9f1234..b03524b 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -141,7 +141,7 @@ class SppPrimary(object):
rports['id'], rports['rx'], rports['tx'],
rports['rx_drop'], rports['tx_drop']))
- def complete(self, text, line, begidx, endidx):
+ def complete(self, text, line, begidx, endidx, cli_config, template):
"""Completion for primary process commands.
Called from complete_pri() to complete primary command.
@@ -150,8 +150,12 @@ class SppPrimary(object):
candidates = []
tokens = line.split(' ')
- base_core = 1 # shared among secondaries
- mytemplate = "-l {},{} -m 512 -- {} {} -s {}"
+ template = template.replace('__MEM__', cli_config['sec_mem']['val'])
+ template = template.replace('__BASE_LCORE__', cli_config['sec_base_lcore']['val'])
+ if cli_config['sec_vhost_cli']['val']:
+ template = template.replace('__VHOST_CLI__', '--vhost-client')
+ else:
+ template = template.replace('__VHOST_CLI__', '')
if tokens[0].endswith(';'):
@@ -195,8 +199,8 @@ class SppPrimary(object):
elif ptype == 'pcap': # at least two cores
rest_core = '{}-{}'.format(int(sid), int(sid)+1)
- candidates = [mytemplate.format(
- base_core, rest_core, opt_sid, sid, server_addr)]
+ candidates = [template.format(
+ rest_core, opt_sid, sid, server_addr)]
if not text:
completions = candidates
diff --git a/src/controller/shell.py b/src/controller/shell.py
index e68ac63..8cf10e6 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -23,17 +23,43 @@ import subprocess
class Shell(cmd.Cmd, object):
"""SPP command prompt."""
- recorded_file = None
+ # Default config, but changed via `config` command
+ cli_config = {
+ 'prompt': {
+ 'val': 'spp > ', 'desc': 'Command prompt'},
+ 'topo_size': {
+ 'val': '60%', 'desc': 'Percentage or ratio of topo'},
+ 'sec_mem': {
+ 'val':'-m 512', 'desc': 'Mem size'},
+ 'sec_base_lcore': {
+ 'val': '1', 'desc': 'Shared lcore among secondaryes'},
+ 'sec_vf_nof_lcores': {
+ 'val': '3', 'desc': 'Number of lcores for vf workers'},
+ 'sec_vhost_cli': {
+ 'val': '', 'desc': 'Vhost client mode'},
+ }
+
+ # Setup template of `pri; launch`
+ template = "-l __BASE_LCORE__,{} "
+ template = template + "__MEM__ "
+ template = template + "-- "
+ template = template + "{} {} " # '-n 1' or '--client-id 1'
+ template = template + "-s {} " # '-s 192.168.1.100:6666'
+ template = template + "__VHOST_CLI__"
+
hist_file = os.path.expanduser('~/.spp_history')
+ PLUGIN_DIR = 'plugins'
# Commands not included in history
HIST_EXCEPT = ['bye', 'exit', 'history', 'redo']
+ # Shell settings which are reserved vars of Cmd class.
+ # `intro` is to be shown as a welcome message.
intro = 'Welcome to the SPP CLI. Type `help` or `?` to list commands.\n'
- prompt = 'spp > '
+ prompt = cli_config['prompt']['val'] # command prompt
- PLUGIN_DIR = 'plugins'
- topo_size = '60%'
+ # Recipe file to be recorded with `record` command
+ recorded_file = None
# setup history file
if os.path.exists(hist_file):
@@ -47,7 +73,8 @@ class Shell(cmd.Cmd, object):
self.spp_ctl_cli = spp_cli_objs[0]
self.use_cache = use_cache
self.init_spp_procs()
- self.spp_topo = topo.SppTopo(self.spp_ctl_cli, {}, self.topo_size)
+ self.spp_topo = topo.SppTopo(
+ self.spp_ctl_cli, {}, self.cli_config['topo_size']['val'])
common.set_current_server_addr(
self.spp_ctl_cli.ip_addr, self.spp_ctl_cli.port)
@@ -249,7 +276,7 @@ class Shell(cmd.Cmd, object):
"""Close record file"""
if self.recorded_file:
- print("closing file")
+ print("Closing file")
self.recorded_file.close()
self.recorded_file = None
@@ -331,7 +358,8 @@ class Shell(cmd.Cmd, object):
"""Completion for primary process commands."""
line = re.sub(r'\s+', " ", line)
- return self.primary.complete(text, line, begidx, endidx)
+ return self.primary.complete(text, line, begidx, endidx,
+ self.cli_config, self.template)
def do_nfv(self, cmd):
"""Send a command to spp_nfv specified with ID.
@@ -618,6 +646,67 @@ class Shell(cmd.Cmd, object):
def complete_playback(self, text, line, begidx, endidx):
return common.compl_common(text, line)
+ def do_config(self, args):
+ """Show or update config.
+
+ # show list of config
+ spp > config
+
+ # set prompt to "$ spp "
+ spp > config prompt "$ spp "
+ """
+
+ tokens = args.strip().split(' ')
+ if len(tokens) == 1:
+ key = tokens[0]
+ if key == '':
+ for k,v in self.cli_config.items():
+ print('- {}: "{}"\t# {}'.format(k, v['val'], v['desc']))
+ elif key in self.cli_config.keys():
+ print('- {}: "{}"\t# {}'.format(
+ key, self.cli_config[key]['val'],
+ self.cli_config[key]['desc']))
+ else:
+ res = {}
+ for k, v in self.cli_config.items():
+ if k.startswith(key):
+ res[k] = {'val': v['val'], 'desc': v['desc']}
+ for k, v in res.items():
+ print('- {}: "{}"\t# {}'.format(k, v['val'], v['desc']))
+
+ elif len(tokens) > 1:
+ key = tokens[0]
+ if key in self.cli_config.keys():
+ for s in ['"', "'"]:
+ args = args.replace(s, '')
+
+ # TODO(yasufum) add validation for given value
+ self.cli_config[key]['val'] = args[(len(key) + 1):]
+ print('Set {}: "{}"'.format(key, self.cli_config[key]['val']))
+
+ # Command prompt should be updated immediately
+ if key == 'prompt':
+ self.prompt = self.cli_config['prompt']['val']
+
+ def complete_config(self, text, line, begidx, endidx):
+ candidates = []
+ tokens = line.strip().split(' ')
+
+ if len(tokens) == 1:
+ candidates = self.cli_config.keys()
+ elif len(tokens) == 2:
+ if text:
+ candidates = self.cli_config.keys()
+
+ if not text:
+ completions = candidates
+ else:
+ logger.debug(candidates)
+ completions = [p for p in candidates
+ if p.startswith(text)
+ ]
+ return completions
+
def do_pwd(self, args):
"""Show corrent directory.
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 2/5] controller: refactor pri launch command
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 1/5] controller: add " ogawa.yasufumi
@ 2019-02-04 3:11 ` ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 3/5] controller: remove nouse check_sec_cmds ogawa.yasufumi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:11 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This patch is to move variables related to launch command from Shell
class to SppPrimary because these vars are used only in SppPrimary
actually.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/pri.py | 58 ++++++++++++++++++++++++++++++++++--------
src/controller/shell.py | 17 ++++---------
2 files changed, 53 insertions(+), 22 deletions(-)
diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index b03524b..aa78cef 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -6,7 +6,6 @@ from __future__ import absolute_import
from .. import spp_common
from ..shell_lib import common
from ..spp_common import logger
-#from .. import spp_common
class SppPrimary(object):
@@ -25,6 +24,22 @@ class SppPrimary(object):
def __init__(self, spp_ctl_cli):
self.spp_ctl_cli = spp_ctl_cli
+ # Default args for `pri; launch`, used if given cli_config is invalid
+ self.launch_default = {
+ 'mem': '-m 512',
+ 'base_lcore': '1',
+ 'vhost_cli': ''
+ }
+
+ # Setup template of args for `pri; launch`
+ temp = "-l __BASE_LCORE__,{} "
+ temp = temp + "__MEM__ "
+ temp = temp + "-- "
+ temp = temp + "{} {} " # '-n 1' or '--client-id 1'
+ temp = temp + "-s {} " # '-s 192.168.1.100:6666'
+ temp = temp + "__VHOST_CLI__"
+ self.launch_template = temp
+
def run(self, cmd):
"""Called from do_pri() to Send command to primary process."""
@@ -141,7 +156,7 @@ class SppPrimary(object):
rports['id'], rports['rx'], rports['tx'],
rports['rx_drop'], rports['tx_drop']))
- def complete(self, text, line, begidx, endidx, cli_config, template):
+ def complete(self, text, line, begidx, endidx, cli_config):
"""Completion for primary process commands.
Called from complete_pri() to complete primary command.
@@ -150,13 +165,7 @@ class SppPrimary(object):
candidates = []
tokens = line.split(' ')
- template = template.replace('__MEM__', cli_config['sec_mem']['val'])
- template = template.replace('__BASE_LCORE__', cli_config['sec_base_lcore']['val'])
- if cli_config['sec_vhost_cli']['val']:
- template = template.replace('__VHOST_CLI__', '--vhost-client')
- else:
- template = template.replace('__VHOST_CLI__', '')
-
+ # Parse command line
if tokens[0].endswith(';'):
# Show sub commands
@@ -199,7 +208,10 @@ class SppPrimary(object):
elif ptype == 'pcap': # at least two cores
rest_core = '{}-{}'.format(int(sid), int(sid)+1)
- candidates = [template.format(
+ temp = self._setup_launch_template(
+ cli_config, self.launch_template,
+ self.launch_default)
+ candidates = [temp.format(
rest_core, opt_sid, sid, server_addr)]
if not text:
@@ -211,6 +223,32 @@ class SppPrimary(object):
return completions
+ def _setup_launch_template(self, cli_config, template, defaults):
+ """Check given `cli_config` for params of launch."""
+
+ if 'sec_mem' in cli_config.keys():
+ sec_mem = cli_config['sec_mem']['val']
+ else:
+ sec_mem = defaults['mem']
+ template = template.replace('__MEM__', sec_mem)
+
+ if 'sec_base_lcore' in cli_config.keys():
+ sec_base_lcore = cli_config['sec_base_lcore']['val']
+ else:
+ sec_base_lcore = defaults['base_lcore']
+ template = template.replace('__BASE_LCORE__', sec_base_lcore)
+
+ if 'sec_vhost_cli' in cli_config.keys():
+ if cli_config['sec_vhost_cli']['val']:
+ vhost_client = '--vhost-client'
+ else:
+ vhost_client = ''
+ else:
+ vhost_client = defaults['vhost_cli']
+ template = template.replace('__VHOST_CLI__', vhost_client)
+
+ return template
+
def _get_sec_ids(self):
sec_ids = []
res = self.spp_ctl_cli.get('processes')
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 8cf10e6..78795f7 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -30,7 +30,7 @@ class Shell(cmd.Cmd, object):
'topo_size': {
'val': '60%', 'desc': 'Percentage or ratio of topo'},
'sec_mem': {
- 'val':'-m 512', 'desc': 'Mem size'},
+ 'val': '-m 512', 'desc': 'Mem size'},
'sec_base_lcore': {
'val': '1', 'desc': 'Shared lcore among secondaryes'},
'sec_vf_nof_lcores': {
@@ -39,14 +39,6 @@ class Shell(cmd.Cmd, object):
'val': '', 'desc': 'Vhost client mode'},
}
- # Setup template of `pri; launch`
- template = "-l __BASE_LCORE__,{} "
- template = template + "__MEM__ "
- template = template + "-- "
- template = template + "{} {} " # '-n 1' or '--client-id 1'
- template = template + "-s {} " # '-s 192.168.1.100:6666'
- template = template + "__VHOST_CLI__"
-
hist_file = os.path.expanduser('~/.spp_history')
PLUGIN_DIR = 'plugins'
@@ -358,8 +350,9 @@ class Shell(cmd.Cmd, object):
"""Completion for primary process commands."""
line = re.sub(r'\s+', " ", line)
- return self.primary.complete(text, line, begidx, endidx,
- self.cli_config, self.template)
+ return self.primary.complete(
+ text, line, begidx, endidx,
+ self.cli_config)
def do_nfv(self, cmd):
"""Send a command to spp_nfv specified with ID.
@@ -660,7 +653,7 @@ class Shell(cmd.Cmd, object):
if len(tokens) == 1:
key = tokens[0]
if key == '':
- for k,v in self.cli_config.items():
+ for k, v in self.cli_config.items():
print('- {}: "{}"\t# {}'.format(k, v['val'], v['desc']))
elif key in self.cli_config.keys():
print('- {}: "{}"\t# {}'.format(
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 3/5] controller: remove nouse check_sec_cmds
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 1/5] controller: add " ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 2/5] controller: refactor pri launch command ogawa.yasufumi
@ 2019-02-04 3:11 ` ogawa.yasufumi
2019-02-04 3:12 ` [spp] [PATCH 4/5] controller: add max_secondary to config ogawa.yasufumi
2019-02-04 3:12 ` [spp] [PATCH 5/5] controller: change nof worker lcores configurable ogawa.yasufumi
4 siblings, 0 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:11 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
`check_sec_cmds()` was used for validation of `sec` command which is
already replaced with `nfv`, `vf` or so. This update is to remove nouse
method.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/shell.py | 37 -------------------------------------
1 file changed, 37 deletions(-)
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 78795f7..e8b0a0e 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -203,43 +203,6 @@ class Shell(cmd.Cmd, object):
return True
return False
- def check_sec_cmds(self, cmds):
- """Validate secondary commands before sending"""
-
- # TODO(yasufum) change to return True or False, or None
- # instead of 0 or 1
-
- level1 = ['status', 'exit', 'forward', 'stop']
- level2 = ['add', 'patch', 'del']
- patch_args = ['reset']
- add_del_args = ['ring', 'vhost', 'pcap', 'nullpmd']
- cmdlist = cmds.split(' ')
- valid = 0
-
- length = len(cmdlist)
- if length == 1:
- if cmdlist[0] in level1:
- valid = 1
-
- elif length == 2:
- if cmdlist[0] == 'patch':
- if cmdlist[1] in patch_args:
- valid = 1
-
- elif cmdlist[0] == 'add' or cmdlist[0] == 'del':
- p_type, p_id = cmdlist[1].split(':')
- if p_type in add_del_args:
- if str.isdigit(p_id):
- valid = 1
-
- elif length == 3:
- if cmdlist[0] in level2:
- if cmdlist[0] == 'patch':
- if self.is_patched_ids_valid(cmdlist[1], cmdlist[2]):
- valid = 1
-
- return valid
-
def clean_cmd(self, cmdstr):
"""remove unwanted spaces to avoid invalid command error"""
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 4/5] controller: add max_secondary to config
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
` (2 preceding siblings ...)
2019-02-04 3:11 ` [spp] [PATCH 3/5] controller: remove nouse check_sec_cmds ogawa.yasufumi
@ 2019-02-04 3:12 ` ogawa.yasufumi
2019-02-04 3:12 ` [spp] [PATCH 5/5] controller: change nof worker lcores configurable ogawa.yasufumi
4 siblings, 0 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:12 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
The number of secondary processes is limited with MAX_SECONDARY defined
in `spp_common.py`, and it is used to show candidates of secondary ID
while launching secondary process. This patch is to add `max_secondary`
to make MAX_SECONDARY configurable after launching SPP CLI.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/pri.py | 14 ++++++++++++--
src/controller/shell.py | 26 ++++++++++++++++++--------
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index aa78cef..b455b2d 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -179,13 +179,23 @@ class SppPrimary(object):
candidates.append('{}'.format(pt))
elif len(tokens) == 4 and tokens[1] == 'launch':
+ if 'max_secondary' in cli_config.keys():
+ max_secondary = int(cli_config['max_secondary']['val'])
+ else:
+ max_secondary = spp_common.MAX_SECONDARY
+
if tokens[2] in spp_common.SEC_TYPES:
candidates = [
- str(i+1) for i in range(spp_common.MAX_SECONDARY)]
+ str(i+1) for i in range(max_secondary)]
elif len(tokens) == 5 and tokens[1] == 'launch':
+ if 'max_secondary' in cli_config.keys():
+ max_secondary = int(cli_config['max_secondary']['val'])
+ else:
+ max_secondary = spp_common.MAX_SECONDARY
+
if (tokens[2] in spp_common.SEC_TYPES) and \
- (int(tokens[3])-1 in range(spp_common.MAX_SECONDARY)):
+ (int(tokens[3])-1 in range(max_secondary)):
ptype = tokens[2]
sid = tokens[3]
diff --git a/src/controller/shell.py b/src/controller/shell.py
index e8b0a0e..7a192fb 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -24,19 +24,29 @@ class Shell(cmd.Cmd, object):
"""SPP command prompt."""
# Default config, but changed via `config` command
+ # TODO(yasufum) move defaults to config file and include from.
cli_config = {
- 'prompt': {
- 'val': 'spp > ', 'desc': 'Command prompt'},
- 'topo_size': {
- 'val': '60%', 'desc': 'Percentage or ratio of topo'},
+ 'max_secondary': {
+ 'val': spp_common.MAX_SECONDARY,
+ 'desc': 'The maximum number of secondary processes'},
'sec_mem': {
- 'val': '-m 512', 'desc': 'Mem size'},
+ 'val': '-m 512',
+ 'desc': 'Mem size'},
'sec_base_lcore': {
- 'val': '1', 'desc': 'Shared lcore among secondaryes'},
+ 'val': '1',
+ 'desc': 'Shared lcore among secondaryes'},
'sec_vf_nof_lcores': {
- 'val': '3', 'desc': 'Number of lcores for vf workers'},
+ 'val': '3',
+ 'desc': 'Number of lcores for vf workers'},
'sec_vhost_cli': {
- 'val': '', 'desc': 'Vhost client mode'},
+ 'val': '',
+ 'desc': 'Vhost client mode'},
+ 'prompt': {
+ 'val': 'spp > ',
+ 'desc': 'Command prompt'},
+ 'topo_size': {
+ 'val': '60%',
+ 'desc': 'Percentage or ratio of topo'},
}
hist_file = os.path.expanduser('~/.spp_history')
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [spp] [PATCH 5/5] controller: change nof worker lcores configurable
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
` (3 preceding siblings ...)
2019-02-04 3:12 ` [spp] [PATCH 4/5] controller: add max_secondary to config ogawa.yasufumi
@ 2019-02-04 3:12 ` ogawa.yasufumi
4 siblings, 0 replies; 6+ messages in thread
From: ogawa.yasufumi @ 2019-02-04 3:12 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
This update is to change the number of worker lcores of each of
secondary processes configurable.
It is decides with secondary ID and config value referred from `config`
command.
- sec_vf_nof_lcores
- sec_mirror_nof_lcores
- sec_pcap_nof_lcores
If secondary ID is `3` and `sec_vf_nof_lcores` is 3, woker lcores is
suggested as `3-5`, started from `3` and use three cores.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/pri.py | 53 +++++++++++++++++++++++++++++++++---------
src/controller/shell.py | 13 +++++++++--
2 files changed, 53 insertions(+), 13 deletions(-)
diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index b455b2d..d780f35 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -28,7 +28,11 @@ class SppPrimary(object):
self.launch_default = {
'mem': '-m 512',
'base_lcore': '1',
- 'vhost_cli': ''
+ 'vhost_cli': '',
+ 'nof_lcores_nfv': '1',
+ 'nof_lcores_vf': '3',
+ 'nof_lcores_mirror': '2',
+ 'nof_lcores_pcap': '2',
}
# Setup template of args for `pri; launch`
@@ -204,19 +208,46 @@ class SppPrimary(object):
else:
opt_sid = '--client-id'
+ # Need to replace port from `7777` of spp-ctl to `6666`
+ # of secondary process.
server_addr = common.current_server_addr()
server_addr = server_addr.replace('7777', '6666')
- # Define rest of cores dynamically.
- # TODO(yasufum) decide rest of cores considering used cores
- if ptype == 'nfv': # one core is enough
- rest_core = sid
- elif ptype == 'vf': # at least three cores
- rest_core = '{}-{}'.format(int(sid), int(sid)+2)
- elif ptype == 'mirror': # two cores
- rest_core = sid
- elif ptype == 'pcap': # at least two cores
- rest_core = '{}-{}'.format(int(sid), int(sid)+1)
+ # Lcore ID of worker lcore starts from sec ID in default.
+ lcore_base = int(sid)
+
+ # Define rest of worker lcores from config dynamically.
+ if ptype == 'nfv': # one worker lcore is enough
+ if 'sec_nfv_nof_lcores' in cli_config.keys():
+ nof_workers = int(cli_config['sec_nfv_nof_lcores']['val'])
+ else:
+ nof_workers = int(self.defaults['nof_lcores_nfv'])
+
+ elif ptype == 'vf':
+ if 'sec_vf_nof_lcores' in cli_config.keys():
+ nof_workers = int(cli_config['sec_vf_nof_lcores']['val'])
+ else:
+ nof_workers = int(self.defaults['nof_lcores_vf'])
+
+ elif ptype == 'mirror': # two worker cores
+ if 'sec_mirror_nof_lcores' in cli_config.keys():
+ nof_workers = int(cli_config['sec_mirror_nof_lcores']['val'])
+ else:
+ nof_workers = int(self.defaults['nof_lcore_mirror'])
+
+ elif ptype == 'pcap': # at least two worker cores
+ if 'sec_pcap_nof_lcores' in cli_config.keys():
+ nof_workers = int(cli_config['sec_pcap_nof_lcores']['val'])
+ else:
+ nof_workers = int(self.defaults['nof_lcore_pcap'])
+
+ last_core = lcore_base + nof_workers - 1
+
+ # Decide lcore option based on configured number of lcores.
+ if last_core == lcore_base:
+ rest_core = '{}'.format(last_core)
+ else:
+ rest_core = '{}-{}'.format(lcore_base, last_core)
temp = self._setup_launch_template(
cli_config, self.launch_template,
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 7a192fb..985e141 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -35,12 +35,21 @@ class Shell(cmd.Cmd, object):
'sec_base_lcore': {
'val': '1',
'desc': 'Shared lcore among secondaryes'},
+ 'sec_nfv_nof_lcores': {
+ 'val': '1',
+ 'desc': 'Default num of lcores for workers of spp_nfv'},
'sec_vf_nof_lcores': {
'val': '3',
- 'desc': 'Number of lcores for vf workers'},
+ 'desc': 'Default num of lcores for workers of spp_vf'},
+ 'sec_mirror_nof_lcores': {
+ 'val': '2',
+ 'desc': 'Default num of lcores for workers of spp_mirror'},
+ 'sec_pcap_nof_lcores': {
+ 'val': '2',
+ 'desc': 'Default num of lcores for workers of spp_pcap'},
'sec_vhost_cli': {
'val': '',
- 'desc': 'Vhost client mode'},
+ 'desc': 'Vhost client mode, activated if set any of values'},
'prompt': {
'val': 'spp > ',
'desc': 'Command prompt'},
--
2.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-04 3:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04 3:11 [spp] [PATCH 0/5] Add config command ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 1/5] controller: add " ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 2/5] controller: refactor pri launch command ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 3/5] controller: remove nouse check_sec_cmds ogawa.yasufumi
2019-02-04 3:12 ` [spp] [PATCH 4/5] controller: add max_secondary to config ogawa.yasufumi
2019-02-04 3:12 ` [spp] [PATCH 5/5] controller: change nof worker lcores configurable ogawa.yasufumi
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).