summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Wiles <keith.wiles@intel.com>2019-03-04 08:55:40 -0600
committerKeith Wiles <keith.wiles@intel.com>2019-03-04 08:55:40 -0600
commitf6e9e335a3ca40464eccfba13a5cd146eb1a39c0 (patch)
tree3da0ae48260175b230c29b1a34e0601d4821786f
parent4199555481cd08fe08e32986c94e59836ca1cd4f (diff)
downloadpktgen-dpdk-f6e9e335a3ca40464eccfba13a5cd146eb1a39c0.zip
pktgen-dpdk-f6e9e335a3ca40464eccfba13a5cd146eb1a39c0.tar.gz
pktgen-dpdk-f6e9e335a3ca40464eccfba13a5cd146eb1a39c0.tar.xz
fix crash not resetting tty and other fixes
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
-rw-r--r--app/cli-functions.c2
-rw-r--r--app/pktgen-main.c18
-rw-r--r--app/pktgen.c35
-rw-r--r--cfg/two-ports.cfg58
-rw-r--r--lib/cli/cli_scrn.h1
-rw-r--r--lib/meson.build111
-rw-r--r--meson.build97
-rw-r--r--meson_options.txt2
-rw-r--r--pktgen-20190203-135615-0.pcapbin7824 -> 0 bytes
-rw-r--r--subprojects/dpdk.wrap4
-rwxr-xr-xtools/run.py11
11 files changed, 266 insertions, 73 deletions
diff --git a/app/cli-functions.c b/app/cli-functions.c
index c496204..74c9fb2 100644
--- a/app/cli-functions.c
+++ b/app/cli-functions.c
@@ -1013,7 +1013,7 @@ dbg_cmd(int argc, char **argv)
break;
#endif
case 80:
- kill(getpid(), SIGINT);
+ kill(0, SIGINT);
break;
case 91:
cnt = atoi(argv[2]);
diff --git a/app/pktgen-main.c b/app/pktgen-main.c
index 72bc757..6b9d90e 100644
--- a/app/pktgen-main.c
+++ b/app/pktgen-main.c
@@ -296,18 +296,18 @@ sig_handler(int v __rte_unused)
char **strings;
size_t i;
- if (v == SIGINT)
- return;
-
scrn_setw(1); /* Reset the window size, from possible crash run. */
scrn_printf(100, 1, "\n"); /* Move the cursor to the bottom of the screen again */
scrn_destroy();
printf("\n======");
+
if (v == SIGSEGV)
printf(" Pktgen got a Segment Fault\n");
else if (v == SIGHUP)
printf(" Pktgen received a SIGHUP\n");
+ else if (v == SIGINT)
+ printf(" Pktgen received a SIGINT\n");
else if (v == SIGPIPE) {
printf(" Pktgen received a SIGPIPE\n");
return;
@@ -326,7 +326,7 @@ sig_handler(int v __rte_unused)
free (strings);
- abort();
+ exit(-1);
}
static int
@@ -339,6 +339,14 @@ pktgen_lua_dofile(void *ld, const char * filename)
return ret;
}
+RTE_FINI(pktgen_fini)
+{
+ scrn_setw(1); /* Reset the window size, from possible crash run. */
+ scrn_printf(999, 1, "\n"); /* Move the cursor to the bottom of the screen again */
+ scrn_destroy();
+ cli_destroy();
+}
+
/**************************************************************************//**
*
* main - Main routine to setup pktgen.
@@ -454,7 +462,7 @@ main(int argc, char **argv)
if (ret != 0)
pktgen_log_error("Failed to start lcore %d, return %d", i, ret);
- rte_delay_us_sleep(50000); /* Wait for the lcores to start up. */
+ rte_delay_us_sleep(250000); /* Wait for the lcores to start up. */
/* Disable printing log messages of level info and below to screen, */
/* erase the screen and start updating the screen again. */
diff --git a/app/pktgen.c b/app/pktgen.c
index 738762e..26de8eb 100644
--- a/app/pktgen.c
+++ b/app/pktgen.c
@@ -1578,10 +1578,10 @@ _page_display(void)
/**************************************************************************//**
*
- * pktgen_page_display - Display the correct page based on timer0 callback.
+ * pktgen_page_display - Display the correct page based on timer callback.
*
* DESCRIPTION
- * When timer0 is active update or display the correct page of data.
+ * When timer is active update or display the correct page of data.
*
* RETURNS: N/A
*
@@ -1618,9 +1618,6 @@ pktgen_page_display(struct rte_timer *tim __rte_unused, void *arg __rte_unused)
pktgen_print_packet_dump();
}
-static struct rte_timer timer0;
-static struct rte_timer timer1;
-
static void *
_timer_thread(void *arg)
{
@@ -1656,7 +1653,7 @@ _timer_thread(void *arg)
/**************************************************************************//**
*
- * pktgen_timer_setup - Set up the timer callback routines.
+ * rte_timer_setup - Set up the timer callback routines.
*
* DESCRIPTION
* Setup the two timers to be used for display and calculating statistics.
@@ -1669,31 +1666,7 @@ _timer_thread(void *arg)
void
rte_timer_setup(void)
{
- int lcore_id = rte_get_master_lcore();
pthread_t tid;
- /* init RTE timer library */
- rte_timer_subsystem_init();
-
- /* init timer structures */
- rte_timer_init(&timer0);
- rte_timer_init(&timer1);
-
- /* load timer0, every 1/2 seconds, on Display lcore, reloaded automatically */
- rte_timer_reset(&timer0,
- UPDATE_DISPLAY_TICK_RATE,
- PERIODICAL,
- lcore_id,
- pktgen_page_display,
- NULL);
-
- /* load timer1, every second, on timer lcore, reloaded automatically */
- rte_timer_reset(&timer1,
- pktgen.hz,
- PERIODICAL,
- lcore_id,
- pktgen_process_stats,
- NULL);
-
- rte_ctrl_thread_create(&tid, "Stats-thread", NULL, _timer_thread, this_scrn);
+ pthread_create(&tid, NULL, _timer_thread, this_scrn);
}
diff --git a/cfg/two-ports.cfg b/cfg/two-ports.cfg
new file mode 100644
index 0000000..21016a7
--- /dev/null
+++ b/cfg/two-ports.cfg
@@ -0,0 +1,58 @@
+description = 'A Pktgen default simple configuration'
+
+# Setup configuration
+setup = {
+ 'exec': (
+ 'sudo', '-E'
+ ),
+
+ 'devices': (
+ '81:00.0', '81:00.1', '81:00.2', '81:00.3',
+ '83:00.0', '83:00.1', '83:00.2', '83:00.3'
+ ),
+ # UIO module type, igb_uio, vfio-pci or uio_pci_generic
+ 'uio': 'vfio-pci'
+ }
+
+# Run command and options
+run = {
+ 'exec': (
+ 'sudo', '-E'
+ ),
+
+ # Application name and use app_path to help locate the app
+ 'app_name': 'pktgen',
+
+ # using (sdk) or (target) for specific variables
+ # add (app_name) of the application
+ # Each path is tested for the application
+ 'app_path': (
+ './app/%(target)s/%(app_name)s',
+ '%(sdk)s/%(target)s/app/%(app_name)s',
+ ),
+
+ 'cores': '14,15-18',
+ 'nrank': '4',
+ 'proc': 'primary',
+ 'log': '7',
+ 'prefix': 'pg',
+ 'plugin': (
+ ),
+
+ 'blacklist': (
+ '81:00.0', '81:00.1', '81:00.2', '81:00.3',
+ #'83:00.0', '83:00.1', '83:00.2', '83:00.3',
+ '83:00.2', '83:00.3'
+ ),
+
+ 'opts': (
+ '-T',
+ '-P',
+ ),
+ 'map': (
+ '[15:16].0',
+ '[17:18].1'
+ ),
+
+ 'theme': 'themes/black-yellow.theme'
+ }
diff --git a/lib/cli/cli_scrn.h b/lib/cli/cli_scrn.h
index 1befd0b..9ce0da5 100644
--- a/lib/cli/cli_scrn.h
+++ b/lib/cli/cli_scrn.h
@@ -139,7 +139,6 @@ struct vt100_cmds {
/** Structure to hold information about the screen and control access. */
struct cli_scrn {
rte_atomic32_t pause; /**< Pause the update of the screen. */
- rte_atomic32_t state; /**< Screen state on or off */
uint16_t nrows; /**< Max number of rows. */
uint16_t ncols; /**< Max number of columns. */
uint16_t theme; /**< Current theme state on or off */
diff --git a/lib/meson.build b/lib/meson.build
index 88f4eac..bdf97de 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -1,18 +1,101 @@
-dirs = ['common', 'cli']
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
-foreach d: dirs
+libraries = ['common', 'utils', 'vec', 'lua']
+
+# Set default cflags
+#default_cflags = glb_default_cflags
+default_cflags = []
+
+foreach l:libraries
+ build = true
+ name = l
+ version = 1
+ allow_experimental_apis = false
sources = []
+ headers = []
+ includes = [global_inc]
+ cflags = default_cflags
+ objs = [] # other object files to link against, used e.g. for
+ # instruction-set optimized versions of code
+
+ # use "deps" for internal PMDK dependencies, and "ext_deps" for
+ # external package/library requirements
+ ext_deps = []
deps = []
- cflags = []
- subdir(d)
-
- inc = include_directories(d)
- lib = static_library(d, sources,
- include_directories: inc,
- c_args: cflags,
- dependencies: deps)
- set_variable('dep_' + d,
- declare_dependency(include_directories: inc,
- link_with: lib,
- dependencies: deps))
+
+ dir_name = l
+ message('Process ' + dir_name)
+ subdir(dir_name)
+
+ if build
+ enabled_libs += name
+ pmdk_conf.set('PME_LIB' + name.to_upper(), 1)
+ install_headers(headers)
+
+ libname = name
+ includes += include_directories(dir_name)
+
+ if sources.length() == 0
+ message(' No sources in '+ libname)
+ # if no C files, just set a dependency on header path
+ shared_dep = declare_dependency(include_directories: includes)
+ static_dep = shared_dep
+ else
+ message(' Sources in '+ libname)
+ shared_deps = ext_deps
+ static_deps = ext_deps
+ foreach d:deps
+ if not is_variable('static_pme_' + d)
+ error('Missing dependency ' + d +
+ ' for library ' + libname)
+ else
+ message(' === Found dependency ' + d)
+ endif
+ shared_deps += [get_variable('shared_pme_' + d)]
+ static_deps += [get_variable('static_pme_' + d)]
+ endforeach
+
+ if allow_experimental_apis
+ cflags += '-DALLOW_EXPERIMENTAL_API'
+ endif
+
+ lib_version = major_version
+ so_version = major_version
+
+ # first build static lib
+ static_lib = static_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: static_deps,
+ include_directories: includes,
+ install: true)
+ static_dep = declare_dependency(link_with: static_lib,
+ include_directories: includes,
+ dependencies: static_deps)
+
+ # then use pre-build objects to build shared lib
+ sources = []
+ objs += static_lib.extract_all_objects(recursive: false)
+ shared_lib = shared_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: shared_deps,
+ include_directories: includes,
+ version: lib_version,
+ soversion: so_version,
+ install: true)
+ shared_dep = declare_dependency(link_with: shared_lib,
+ include_directories: includes,
+ dependencies: shared_deps)
+
+ pmdk_shared_libraries = [shared_lib] + pmdk_shared_libraries
+ pmdk_static_libraries = [static_lib] + pmdk_static_libraries
+ endif # sources.length() > 0
+
+ set_variable('shared_pme_' + libname, shared_dep)
+ set_variable('static_pme_' + libname, static_dep)
+ endif # if build
endforeach
diff --git a/meson.build b/meson.build
index ca06028..d2761e9 100644
--- a/meson.build
+++ b/meson.build
@@ -1,26 +1,93 @@
project('pktgen', 'C',
license: 'BSD',
default_options: ['buildtype=release', 'default_library=static'],
- meson_version: '>= 0.41'
+ meson_version: '>= 0.47.1'
)
-add_project_arguments('-D_GNU_SOURCE', '-O3', language: 'c')
+cmd = run_command('sh', '-c', 'echo $RTE_SDK')
+if cmd.returncode() == 0
+ rte_sdk = cmd.stdout().strip()
+ message('RTE_SDK=' + rte_sdk)
+else
+ # not found, do fallback
+ error('Please set RTE_SDK env')
+endif
+
+cmd = run_command('sh', '-c', 'echo $RTE_TARGET')
+if cmd.returncode() == 0
+ rte_target = cmd.stdout().strip()
+ message('RTE_TARGET=' + rte_target)
+else
+ # not found, do fallback
+ error('Please set RTE_TARGET')
+endif
+
+# set up some global vars for compiler, platform, configuration, etc.
cc = meson.get_compiler('c')
-dpdk_dep = dependency('libdpdk', version: '>=17.11', required: false)
-if not dpdk_dep.found()
- dpdk_sp = subproject('dpdk')
- dpdk_dep = declare_dependency(
- compile_args: ['-include', 'rte_config.h'] +
- dpdk_sp.get_variable('machine_args'),
- dependencies: [dpdk_sp.get_variable('static_rte_ethdev'),
- dpdk_sp.get_variable('static_rte_timer'),
- dpdk_sp.get_variable('static_rte_pmd_i40e'),
- dpdk_sp.get_variable('static_rte_pmd_pcap'),
- dpdk_sp.get_variable('static_rte_cmdline'),
- dpdk_sp.get_variable('static_rte_lpm')],
- link_args: dpdk_sp.get_variable('dpdk_extra_ldflags'))
+pktgen_conf = configuration_data()
+dpdk_libraries = []
+dpdk_static_libraries = []
+dpdk_drivers = []
+dpdk_extra_ldflags = []
+dpdk_app_link_libraries = []
+
+add_project_arguments('-D_GNU_SOURCE', '-O3', '-g', language: 'c')
+
+dpdk_incs = include_directories(rte_sdk + '/' + rte_target + '/include')
+dpdk_libdir = rte_sdk + '/' + rte_target + '/lib'
+if get_option('lib_dir') != ''
+ if run_command('[', '-d', dpdk_libdir + '/' + get_option('lib_dir'), ']').returncode() == 0
+ dpdk_libdir = dpdk_libdir + '/' + get_option('lib_dir')
+ endif
endif
+message('Using dpkd_libdir = ' + dpdk_libdir)
+
subdir('lib')
subdir('app')
+
+pkg = import('pkgconfig')
+pkg.generate(name: meson.project_name(),
+ filebase: 'lib' + meson.project_name().to_lower(),
+ version: meson.project_version(),
+ libraries: dpdk_libraries,
+ libraries_private: dpdk_drivers + dpdk_static_libraries +
+ ['-Wl,-Bdynamic'] + dpdk_extra_ldflags,
+ description: '''The Data Plane Development Kit (DPDK).
+Note that CFLAGS might contain an -march flag higher than typical baseline.
+This is required for a number of static inline functions in the public headers.''',
+ subdirs: [get_option('include_subdir_arch'), '.'],
+ extra_cflags: ['-include', 'rte_config.h'] + machine_args
+)
+
+# final output, list all the libs and drivers to be built
+# this does not affect any part of the build, for information only.
+output_message = '\n=================\nLibraries Enabled\n=================\n'
+output_message += '\nlibs:\n\t'
+output_count = 0
+foreach lib:enabled_libs
+ output_message += lib + ', '
+ output_count += 1
+ if output_count == 8
+ output_message += '\n\t'
+ output_count = 0
+ endif
+endforeach
+message(output_message + '\n')
+
+output_message = '\n===============\nDrivers Enabled\n===============\n'
+foreach class:driver_classes
+ class_drivers = get_variable(class + '_drivers')
+ output_message += '\n' + class + ':\n\t'
+ output_count = 0
+ foreach drv:class_drivers
+ output_message += drv + ', '
+ output_count += 1
+ if output_count == 8
+ output_message += '\n\t'
+ output_count = 0
+ endif
+ endforeach
+endforeach
+message(output_message + '\n')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..98f729c
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('lib_dir', type: 'string', value: 'x86_64-linux-gnu',
+ description: 'Set the directory where the libs are located in x86_64-native-linuxapp-gcc')
diff --git a/pktgen-20190203-135615-0.pcap b/pktgen-20190203-135615-0.pcap
deleted file mode 100644
index a6d2816..0000000
--- a/pktgen-20190203-135615-0.pcap
+++ /dev/null
Binary files differ
diff --git a/subprojects/dpdk.wrap b/subprojects/dpdk.wrap
deleted file mode 100644
index 8fd8b16..0000000
--- a/subprojects/dpdk.wrap
+++ /dev/null
@@ -1,4 +0,0 @@
-[wrap-git]
-directory = dpdk-latest
-url = http://dpdk.org/git/dpdk
-revision = master
diff --git a/tools/run.py b/tools/run.py
index fe30473..1153656 100755
--- a/tools/run.py
+++ b/tools/run.py
@@ -94,7 +94,9 @@ def add_run_options(s, arg_list, p):
for a in mk_tuple(cfg.run, s):
if p is not None:
arg_list.append(p)
- arg_list.append(a)
+
+ _p = a % globals()
+ arg_list.append(_p)
def add_setup_options(s, arg_list):
''' Append options to arg list '''
@@ -200,6 +202,7 @@ def run_cfg(cfg_file):
add_run_options('blacklist', args, '-b')
add_run_options('whitelist', args, '-w')
add_run_options('vdev', args, '--vdev')
+ add_run_options('plugin', args, '-d')
args.extend(["--"])
add_run_options('opts', args, None)
add_run_options('map', args, '-m')
@@ -400,12 +403,16 @@ def parse_args():
def main():
'''program main function'''
- global sdk, target
+ global sdk, target, pmdk
sdk = os.getenv('RTE_SDK')
if sdk == None:
err_exit("Set RTE_SDK environment variable or use 'sudo -E ...'")
+ pmdk = os.getenv('PMDK_SDK')
+ if pmdk == None:
+ pmdk = 'pmdk-not-set';
+
target = os.getenv('RTE_TARGET')
if target == None:
err_exit("Set the RTE_TARET environment variable or use 'sudo -E ...'")