Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix updating stats when running Lua scripts. #243

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24.03.0
24.03.1
1 change: 0 additions & 1 deletion app/lpktgenlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,6 @@ __delay(int32_t t)
int32_t n;

while (t > 0) {
cli_use_timers();
n = (t > 10) ? 10 : t;
rte_delay_us_sleep(n * 1000);
t -= n;
Expand Down
2 changes: 0 additions & 2 deletions app/pktgen-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,6 @@ main(int argc, char **argv)
argc -= ret;
argv += ret;

rte_timer_subsystem_init();

/* Configure pktgen data which will be encapsulated in the mbuf. */
pktgen_dynfield_offset = rte_mbuf_dynfield_register(&pktgen_dynfield_desc);
if (pktgen_dynfield_offset < 0)
Expand Down
58 changes: 41 additions & 17 deletions app/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1553,19 +1553,41 @@ pktgen_page_display(void)
pktgen_print_packet_dump();
}

static struct rte_timer update_stats_timer;
static struct rte_timer update_display_timer;

static void
stats_cb(__rte_unused struct rte_timer *tim, __rte_unused void *arg)
static void *
_timer_thread(void *arg)
{
pktgen_process_stats();
}
uint64_t process, page, prev;

static void
display_cb(__rte_unused struct rte_timer *tim, __rte_unused void *arg)
{
pktgen_page_display();
this_scrn = arg;

pktgen.stats_timeout = pktgen.hz;
pktgen.page_timeout = UPDATE_DISPLAY_TICK_RATE;

page = prev = pktgen_get_time();
process = page + pktgen.stats_timeout;
page += pktgen.page_timeout;

pktgen.timer_running = 1;

while (pktgen.timer_running) {
uint64_t curr;

curr = pktgen_get_time();

if (curr >= process) {
process = curr + pktgen.stats_timeout;
pktgen_process_stats();
prev = curr;
}

if (curr >= page) {
page = curr + pktgen.page_timeout;
pktgen_page_display();
}

rte_pause();
}
return NULL;
}

/**
Expand All @@ -1583,12 +1605,14 @@ display_cb(__rte_unused struct rte_timer *tim, __rte_unused void *arg)
void
pktgen_timer_setup(void)
{
unsigned int main_lcore = rte_get_main_lcore();
uint64_t hz = rte_get_timer_hz();
rte_cpuset_t cpuset_data;
rte_cpuset_t *cpuset = &cpuset_data;
pthread_t tid;

CPU_ZERO(cpuset);

rte_timer_init(&update_stats_timer);
rte_timer_init(&update_display_timer);
pthread_create(&tid, NULL, _timer_thread, this_scrn);

rte_timer_reset(&update_stats_timer, hz, PERIODICAL, main_lcore, stats_cb, NULL);
rte_timer_reset(&update_display_timer, hz / 4, PERIODICAL, main_lcore, display_cb, NULL);
CPU_SET(rte_get_main_lcore(), cpuset);
pthread_setaffinity_np(tid, sizeof(cpuset), cpuset);
}
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Pktgen-DPDK - Traffic Generator powered by DPDK
** (Pktgen) Sounds like 'Packet-Gen'**

**=== Modifications ===**
- 24.03.1 - Fix updating stats when running Lua scripts.
Remove a number of old .map files.
Remove the unused CLI support for running with timers.
- 24.03.0 - Fix a number of problems with save command for lua scripts.
Removed the decompile/compile/sendPkt/recvPkt references.
Compiled with DPDK 24.03.0
Expand Down
23 changes: 2 additions & 21 deletions lib/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ static int (*__dofile_lua)(void *, const char *);

RTE_DEFINE_PER_LCORE(struct cli *, cli);

void
cli_use_timers(void)
{
if (this_cli && this_cli->flags & CLI_USE_TIMERS)
rte_timer_manage();
}

int
cli_nodes_unlimited(void)
{
Expand Down Expand Up @@ -560,9 +553,8 @@ cli_start(const char *msg)

RTE_ASSERT(this_cli != NULL);

cli_printf("\n** Version: %s, %s with%s timers\n", rte_version(),
(msg == NULL) ? "Command Line Interface" : msg,
(this_cli->flags & CLI_USE_TIMERS) ? "" : "out");
cli_printf("\n** Version: %s, %s\n", rte_version(),
(msg == NULL) ? "Command Line Interface" : msg);

this_cli->plen = this_cli->prompt(0);

Expand All @@ -574,23 +566,12 @@ cli_start(const char *msg)
while (!this_cli->quit_flag) {
if (cli_poll(&c))
cli_input(&c, 1);
rte_timer_manage();
rte_pause();
}

cli_printf("\n");
}

void
cli_start_with_timers(const char *msg)
{
RTE_ASSERT(this_cli != NULL);

this_cli->flags |= CLI_USE_TIMERS;

cli_start(msg);
}

/* Create a CLI root node for the tree */
struct cli_node *
cli_create_root(const char *dirname)
Expand Down
20 changes: 0 additions & 20 deletions lib/cli/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ RTE_DECLARE_PER_LCORE(struct cli *, cli);
#define DELETE_CHAR (1 << 3)
#define CLEAR_LINE (1 << 4)

#define CLI_USE_TIMERS (1 << 8) /**< call rte_timer_manage() on input */
#define CLI_NODES_UNLIMITED (1 << 9) /**< Allocate nodes with no limit */
#define CLI_YIELD_IO (1 << 10)
#define CLI_DEFAULT_TREE (1 << 11)
Expand Down Expand Up @@ -704,18 +703,6 @@ void cli_destroy(void);
*/
void cli_start(const char *msg);

/**
* Start the CLI running and use timerss
*
* @note Uses thread variable this_cli.
*
* @param msg
* User message to be displayed on startup
* @return
* N/A
*/
void cli_start_with_timers(const char *msg);

/**
* Execute command line string in cli->input
*
Expand Down Expand Up @@ -918,13 +905,6 @@ int cli_execute_cmdfiles(void);
*/
int cli_remove_node(struct cli_node *node);

/**
* Handle calling the rte_timer_manage routine if trimers are enabled
*
* @note Uses thread variable this_cli.
*/
void cli_use_timers(void);

/**
* return true if allocating unlimited nodes are enabled.
*
Expand Down
2 changes: 0 additions & 2 deletions lib/cli/cli_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ sleep_cmd(int argc __rte_unused, char **argv)
}

while (cnt--) {
cli_use_timers();
rte_delay_us_sleep(250 * 1000);
}
return 0;
Expand All @@ -534,7 +533,6 @@ delay_cmd(int argc __rte_unused, char **argv)
int cnt = (ms / 1000) * 4;

while (cnt--) {
cli_use_timers();
rte_delay_us_sleep(250 * 1000);
ms -= 250;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/cli/cli_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ cli_poll(char *c)
fds.events = POLLIN;
fds.revents = 0;

cli_use_timers();

if (poll(&fds, 1, 0)) {
if ((fds.revents & (POLLERR | POLLNVAL)) == 0) {
if ((fds.revents & POLLHUP))
Expand Down
88 changes: 0 additions & 88 deletions lib/cli/cli_version.map

This file was deleted.

9 changes: 0 additions & 9 deletions lib/common/common_version.map

This file was deleted.

5 changes: 0 additions & 5 deletions lib/lua/lua_version.map

This file was deleted.

6 changes: 0 additions & 6 deletions lib/plugin/plugin_version.map

This file was deleted.

13 changes: 0 additions & 13 deletions lib/utils/utils_version.map

This file was deleted.

13 changes: 0 additions & 13 deletions lib/vec/vec_version.map

This file was deleted.

8 changes: 8 additions & 0 deletions test/portstats_with_delay.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package.path = package.path .. ";?.lua;test/?.lua;"
require("Pktgen")

pktgen.start("0");
TEST_DURATION = 10
pktgen.delay(TEST_DURATION * 1000);
pktgen.stop("0");
prints("portStats", pktgen.portStats('0', 'port'));
1 change: 1 addition & 0 deletions themes/black-yellow.theme
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ theme stats.mac green none off
theme stats.ip cyan none off
theme pktgen.prompt green none off
cls
on
2 changes: 2 additions & 0 deletions themes/white-black.theme
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ theme stats.mac green none bold
theme stats.ip cyan none bold
theme pktgen.prompt green none off
theme on
cls
on
Loading