From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 12/29] tools/sppc: setup spp_pri opts in app_helper
Date: Tue, 25 Feb 2020 19:34:29 +0900 [thread overview]
Message-ID: <20200225103446.8243-13-yasufum.o@gmail.com> (raw)
In-Reply-To: <20200225103446.8243-1-yasufum.o@gmail.com>
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
next prev parent reply other threads:[~2020-02-25 10:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Yasufumi Ogawa [this message]
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
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=20200225103446.8243-13-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--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).