mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 19:35:42 +08:00
net: Add network task affinity config
This patch adds a default network tasks CPU affinity configuration option. The network drivers have the option to create their own daemon tasks with a custom CPU affinity set, or rely on the default set.
This commit is contained in:
committed by
Daniel Hellstrom
parent
9ab1558f6e
commit
69e3f272d9
@@ -11,6 +11,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
#include <sys/cpuset.h>
|
||||
|
||||
/*
|
||||
* If this file is included from inside the Network Stack proper or
|
||||
@@ -181,6 +182,14 @@ struct rtems_bsdnet_config {
|
||||
*/
|
||||
unsigned long tcp_tx_buf_size;
|
||||
unsigned long tcp_rx_buf_size;
|
||||
|
||||
/*
|
||||
* Default Network Tasks CPU Affinity
|
||||
*/
|
||||
#ifdef RTEMS_SMP
|
||||
const cpu_set_t *network_task_cpuset;
|
||||
size_t network_task_cpuset_size;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -157,6 +157,18 @@ rtems_id rtems_bsdnet_newproc (
|
||||
void *arg
|
||||
);
|
||||
|
||||
#ifdef RTEMS_SMP
|
||||
/* As rtems_bsdnet_newproc() but with ability to set CPU affinity too */
|
||||
rtems_id rtems_bsdnet_newproc_affinity (
|
||||
char *name,
|
||||
int stacksize,
|
||||
void (*entry)(void *),
|
||||
void *arg,
|
||||
const cpu_set_t *set,
|
||||
const size_t setsize
|
||||
);
|
||||
#endif
|
||||
|
||||
rtems_status_code rtems_bsdnet_event_receive (
|
||||
rtems_event_set event_in,
|
||||
rtems_option option_set,
|
||||
|
||||
@@ -56,6 +56,10 @@ Semaphore_Control *the_networkSemaphore;
|
||||
#endif
|
||||
static rtems_id networkDaemonTid;
|
||||
static uint32_t networkDaemonPriority;
|
||||
#ifdef RTEMS_SMP
|
||||
static const cpu_set_t *networkDaemonCpuset = 0;
|
||||
static size_t networkDaemonCpusetSize = 0;
|
||||
#endif
|
||||
static void networkDaemon (void *task_argument);
|
||||
|
||||
/*
|
||||
@@ -280,6 +284,14 @@ rtems_bsdnet_initialize (void)
|
||||
else
|
||||
networkDaemonPriority = rtems_bsdnet_config.network_task_priority;
|
||||
|
||||
/*
|
||||
* Default network task CPU affinity
|
||||
*/
|
||||
#ifdef RTEMS_SMP
|
||||
networkDaemonCpuset = rtems_bsdnet_config.network_task_cpuset;
|
||||
networkDaemonCpusetSize = rtems_bsdnet_config.network_task_cpuset_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the memory allocation limits
|
||||
*/
|
||||
@@ -660,11 +672,25 @@ taskEntry (rtems_task_argument arg)
|
||||
rtems_panic ("Network task returned!\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Start a network task
|
||||
*/
|
||||
#ifdef RTEMS_SMP
|
||||
rtems_id
|
||||
rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg)
|
||||
{
|
||||
return rtems_bsdnet_newproc_affinity( name, stacksize, entry, arg,
|
||||
networkDaemonCpuset, networkDaemonCpusetSize );
|
||||
}
|
||||
|
||||
rtems_id
|
||||
rtems_bsdnet_newproc_affinity (char *name, int stacksize, void(*entry)(void *),
|
||||
void *arg, const cpu_set_t *set, const size_t setsize)
|
||||
#else
|
||||
rtems_id
|
||||
rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg)
|
||||
#endif
|
||||
{
|
||||
struct newtask *t;
|
||||
char nm[4];
|
||||
@@ -681,6 +707,14 @@ rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
rtems_panic ("Can't create network daemon `%s': `%s'\n", name, rtems_status_text (sc));
|
||||
|
||||
#ifdef RTEMS_SMP
|
||||
/*
|
||||
* Use the default affinity or use the user-provided CPU set
|
||||
*/
|
||||
if ( set != 0 )
|
||||
rtems_task_set_affinity( tid, setsize, set );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set up task arguments
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user