Merge pull request #812 from renzibei/dev

Add ff_stop_run to stop the poll loop
This commit is contained in:
johnjiang 2024-04-18 20:33:32 +08:00 committed by GitHub
commit 5d56188040
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 0 deletions

View File

@ -49,6 +49,12 @@ However, it is supported only before F-Stack is started.
The ioctl() function manipulates the underlying device parameters of special files.
more info see man ioctl.
#### ff_stop_run
void ff_stop_run();
Stop the infinite poll loop started by `ff_run`.
### Network API
#### ff_socket

View File

@ -55,6 +55,8 @@ int ff_init(int argc, char * const argv[]);
void ff_run(loop_func_t loop, void *arg);
void ff_stop_run(void);
/* POSIX-LIKE api begin */
int ff_fcntl(int fd, int cmd, ...);

View File

@ -80,6 +80,7 @@ static int numa_on;
static unsigned idle_sleep;
static unsigned pkt_tx_delay;
static uint64_t usr_cb_tsc;
static int stop_loop;
static struct rte_timer freebsd_clock;
@ -2005,6 +2006,11 @@ main_loop(void *arg)
qconf = &lcore_conf;
while (1) {
if (unlikely(stop_loop)) {
break;
}
cur_tsc = rte_rdtsc();
if (unlikely(freebsd_clock.expire < cur_tsc)) {
rte_timer_manage();
@ -2136,6 +2142,7 @@ void
ff_dpdk_run(loop_func_t loop, void *arg) {
struct loop_routine *lr = rte_malloc(NULL,
sizeof(struct loop_routine), 0);
stop_loop = 0;
lr->loop = loop;
lr->arg = arg;
rte_eal_mp_remote_launch(main_loop, lr, CALL_MAIN);
@ -2143,6 +2150,11 @@ ff_dpdk_run(loop_func_t loop, void *arg) {
rte_free(lr);
}
void
ff_dpdk_stop(void) {
stop_loop = 1;
}
void
ff_dpdk_pktmbuf_free(void *m)
{

View File

@ -39,6 +39,7 @@ struct loop_routine {
int ff_dpdk_init(int argc, char **argv);
int ff_dpdk_if_up(void);
void ff_dpdk_run(loop_func_t loop, void *arg);
void ff_dpdk_stop(void);
struct ff_dpdk_if_context;
struct ff_port_cfg;

View File

@ -61,3 +61,9 @@ ff_run(loop_func_t loop, void *arg)
ff_dpdk_run(loop, arg);
}
void
ff_stop_run(void)
{
ff_dpdk_stop();
}