diff options
author | Daniel Cederman <cederman@gaisler.com> | 2014-11-14 08:58:00 +0100 |
---|---|---|
committer | Daniel Hellstrom <daniel@gaisler.com> | 2014-12-02 13:41:15 +0100 |
commit | 69e3f272d9c67c1b46801670882c3df149e2d941 (patch) | |
tree | 0ce7bf68c69bd3ba0afc49e2c851bb0815262f90 /cpukit/libnetworking/rtems | |
parent | tools: Provide strnlen() if missing (diff) | |
download | rtems-69e3f272d9c67c1b46801670882c3df149e2d941.tar.bz2 |
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.
Diffstat (limited to 'cpukit/libnetworking/rtems')
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_bsdnet.h | 9 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_bsdnet_internal.h | 12 | ||||
-rw-r--r-- | cpukit/libnetworking/rtems/rtems_glue.c | 34 |
3 files changed, 55 insertions, 0 deletions
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet.h b/cpukit/libnetworking/rtems/rtems_bsdnet.h index 9dd44fec84..5a95b3a2d2 100644 --- a/cpukit/libnetworking/rtems/rtems_bsdnet.h +++ b/cpukit/libnetworking/rtems/rtems_bsdnet.h @@ -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 }; /* diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h index 865b644d4c..5be781b4c8 100644 --- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h +++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h @@ -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, diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c index 8ed17d1bf0..897b868291 100644 --- a/cpukit/libnetworking/rtems/rtems_glue.c +++ b/cpukit/libnetworking/rtems/rtems_glue.c @@ -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); /* @@ -281,6 +285,14 @@ rtems_bsdnet_initialize (void) 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 */ if (rtems_bsdnet_config.mbuf_bytecount) @@ -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 */ |